index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <el-dialog
  3. title="首件两检报工"
  4. :visible.sync="dialogVisible"
  5. width="60%"
  6. :before-close="handleClose"
  7. >
  8. <div>
  9. <!-- <el-button type="primary" plain round @click="openMaintenancePlan">
  10. 设备保养计划
  11. </el-button> -->
  12. <div v-if="loading" class="step-list" v-loading="loading">
  13. <ele-pro-table
  14. ref="table"
  15. row-key="id"
  16. :columns="columns"
  17. :datasource="list"
  18. cache-key="mes-ruleRecordsList-2511172018"
  19. autoAmendPage
  20. :need-page="false"
  21. @refresh="getData"
  22. >
  23. <template v-slot:action="{ row }">
  24. <el-button
  25. :type="row.executeStatus == 0 ? 'primary' : 'default'"
  26. class="status-btn"
  27. @click="openMaintenancePlan(row)"
  28. >
  29. {{ executeStatusTest(row.executeStatus) }}
  30. </el-button>
  31. </template>
  32. </ele-pro-table>
  33. </div>
  34. <el-empty v-else></el-empty>
  35. </div>
  36. <template #footer>
  37. <el-button @click="handleUpdate" type="primary" :loading="butLoad"
  38. >更新</el-button
  39. >
  40. <el-button @click="handleClose">关闭</el-button>
  41. </template>
  42. </el-dialog>
  43. </template>
  44. <script>
  45. import {
  46. getLastRuleRecords,
  47. getProduceTaskInstanceId
  48. } from '@/api/producetaskrulerecord/index.js';
  49. import { pageFirstArticleDualInspectionRecord } from '@/api/firstarticledualinspectionrecord/index.js';
  50. import dictMixins from '@/mixins/dictMixins';
  51. import tableColumnsMixin from '@/mixins/tableColumnsMixin';
  52. export default {
  53. mixins: [dictMixins, tableColumnsMixin],
  54. components: {},
  55. data() {
  56. return {
  57. dialogVisible: false,
  58. loading: true,
  59. produceTaskInfo: null,
  60. workOrder: null,
  61. butLoad: false,
  62. list: []
  63. };
  64. },
  65. computed: {
  66. columns() {
  67. return [
  68. {
  69. width: 50,
  70. type: 'index',
  71. columnKey: 'index',
  72. label: '序号',
  73. align: 'center'
  74. },
  75. {
  76. prop: 'produceTaskName',
  77. label: '名称',
  78. align: 'center',
  79. showOverflowTooltip: true,
  80. minWidth: 150,
  81. formatter: (row) => {
  82. return row.ruleName || row.itemTaskName || row.planConfigName;
  83. }
  84. },
  85. {
  86. prop: 'executeMethod',
  87. label: '执行方式',
  88. align: 'center',
  89. showOverflowTooltip: true,
  90. minWidth: 150,
  91. formatter: (row) => {
  92. return this.getDictValue('记录规则执行方式', row.executeMethod);
  93. }
  94. },
  95. {
  96. prop: 'reportUserName',
  97. label: '报工人',
  98. align: 'center',
  99. showOverflowTooltip: true,
  100. minWidth: 150
  101. },
  102. {
  103. prop: 'finishTime',
  104. label: '报工时间',
  105. align: 'center',
  106. showOverflowTooltip: true,
  107. minWidth: 150
  108. },
  109. {
  110. prop: 'duration',
  111. label: '工时',
  112. align: 'center',
  113. showOverflowTooltip: true,
  114. minWidth: 150,
  115. formatter: (row) => {
  116. // 毫秒转小时
  117. return row.duration
  118. ? (row.duration / 1000 / 60 / 60).toFixed(2) + ' 时'
  119. : '';
  120. }
  121. },
  122. // 操作
  123. {
  124. label: '操作',
  125. align: 'center',
  126. width: 130,
  127. fixed: 'right',
  128. slot: 'action'
  129. }
  130. ];
  131. }
  132. },
  133. methods: {
  134. open(workOrder, produceTaskInfo) {
  135. this.workOrder = workOrder;
  136. this.produceTaskInfo = produceTaskInfo;
  137. console.log('this.workOrder', this.workOrder);
  138. console.log('this.produceTaskInfo', this.produceTaskInfo);
  139. this.dialogVisible = true;
  140. },
  141. executeStatusTest(status) {
  142. switch (status) {
  143. case 0:
  144. return '未报工';
  145. case 1:
  146. return '执行中';
  147. default:
  148. return '已报工';
  149. }
  150. },
  151. // 获取数据
  152. async getData() {
  153. const data = await pageFirstArticleDualInspectionRecord({});
  154. this.list = data.list || [];
  155. },
  156. handleClose() {
  157. this.dialogVisible = false;
  158. this.$emit('close');
  159. },
  160. async handleUpdate() {
  161. try {
  162. this.butLoad = true;
  163. await this.getData();
  164. // 更新逻辑
  165. this.$message.success('已更新');
  166. this.butLoad = false;
  167. } catch (error) {
  168. this.butLoad = false;
  169. }
  170. }
  171. }
  172. };
  173. </script>
  174. <style lang="scss" scoped></style>