index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <el-dialog
  3. title="报工"
  4. :visible.sync="dialogVisible"
  5. width="600px"
  6. :before-close="handleClose"
  7. >
  8. <div>
  9. <!-- <el-button type="primary" plain round @click="openMaintenancePlan">
  10. 设备保养计划
  11. </el-button> -->
  12. <div
  13. v-if="loading || ruleRecordsList.length > 0"
  14. class="step-list"
  15. v-loading="loading"
  16. >
  17. <div
  18. class="step-item"
  19. v-for="(item, index) in ruleRecordsList"
  20. :key="item.id"
  21. @click="openMaintenancePlan(item)"
  22. >
  23. <div class="circle">{{ index + 1 }}</div>
  24. <div class="desc">{{ item.ruleName || item.itemTaskName }}</div>
  25. <div class="methods">{{ item.recordRulesExecuteMethodName }}</div>
  26. <el-button
  27. :type="item.executeStatus == 0 ? 'primary' : 'default'"
  28. class="status-btn"
  29. >
  30. {{ executeStatusTest(item.executeStatus) }}
  31. </el-button>
  32. </div>
  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="handleConfirm" type="primary">确定</el-button>
  41. <el-button @click="handleClose">取消</el-button>
  42. </template>
  43. <programRulesDialog
  44. ref="programRulesDialogRef"
  45. :dialogTitle="dialogTitle"
  46. @reload="getData"
  47. />
  48. <releaseRulesDialog ref="releaseRulesDialogRef" @reload="getData" />
  49. <taskDialog ref="taskDialogRef" @reload="getData" />
  50. </el-dialog>
  51. </template>
  52. <script>
  53. import releaseRulesDialog from './releaseRulesDialog.vue';
  54. import programRulesDialog from './programRulesDialog.vue';
  55. import { getLastRuleRecords } from '@/api/producetaskrulerecord/index.js';
  56. import { getDate } from '@/utils/dateUtils';
  57. import taskDialog from './taskDialog.vue';
  58. export default {
  59. components: { programRulesDialog, releaseRulesDialog, taskDialog },
  60. data() {
  61. return {
  62. dialogVisible: false,
  63. dialogTitle: '设备保养计划',
  64. ruleRecordsList: [],
  65. // 工艺路线
  66. workOrderInfo: null,
  67. // 工序信息
  68. produceTaskInfo: null,
  69. // 报工类型,参考字典项:record_rules_report_work_type,1-产前准备,2-过程监测,3-产后检查
  70. reportWorkType: 1,
  71. butLoad: false,
  72. // 记录规则
  73. showReleaseRulesDialog: false,
  74. loading: true
  75. };
  76. },
  77. methods: {
  78. open(workOrderInfo, produceTaskInfo, reportWorkType) {
  79. console.log('workOrderInfo 工单信息', workOrderInfo);
  80. console.log('工序信息', produceTaskInfo);
  81. this.workOrderInfo = workOrderInfo;
  82. this.produceTaskInfo = produceTaskInfo;
  83. this.reportWorkType = reportWorkType;
  84. this.dialogVisible = true;
  85. this.getData(workOrderInfo.id, produceTaskInfo.id);
  86. },
  87. executeStatusTest(status) {
  88. switch (status) {
  89. case 0:
  90. return '未报工';
  91. case 1:
  92. return '执行中';
  93. default:
  94. return '已报工';
  95. }
  96. },
  97. // 获取数据
  98. async getData() {
  99. this.loading = true;
  100. const body = {
  101. workOrderId: this.workOrderInfo.id,
  102. produceTaskId: this.produceTaskInfo.id,
  103. reportWorkType: this.reportWorkType,
  104. isTempRecord: 0
  105. };
  106. const data = await getLastRuleRecords(body);
  107. this.ruleRecordsList = data.map(i => {
  108. // 工序名称
  109. i.produceTaskName = this.produceTaskInfo.name
  110. return i;
  111. });
  112. console.log('报工流程 事项', this.ruleRecordsList);
  113. this.loading = false;
  114. },
  115. handleClose() {
  116. this.$emit('close');
  117. this.dialogVisible = false;
  118. },
  119. async handleUpdate() {
  120. try {
  121. this.butLoad = true;
  122. await this.getData();
  123. // 更新逻辑
  124. this.$message.success('已更新');
  125. this.butLoad = false;
  126. } catch (error) {
  127. this.butLoad = false;
  128. }
  129. },
  130. handleConfirm() {
  131. // 确定逻辑
  132. this.dialogVisible = false;
  133. },
  134. openMaintenancePlan(item) {
  135. console.log('item', item);
  136. if (item.executeMethod == 1) {
  137. // 设备保养计划相关逻辑
  138. this.dialogTitle = '新增设备保养计划';
  139. this.$refs.programRulesDialogRef.init(
  140. item,
  141. this.workOrderInfo,
  142. this.produceTaskInfo
  143. );
  144. } else if (item.executeMethod == 2) {
  145. this.$refs.releaseRulesDialogRef.open(
  146. item,
  147. this.workOrderInfo,
  148. this.produceTaskInfo
  149. );
  150. } else {
  151. // 任务确认
  152. this.$refs.taskDialogRef.open(
  153. item,
  154. this.workOrderInfo,
  155. this.produceTaskInfo
  156. );
  157. }
  158. }
  159. }
  160. };
  161. </script>
  162. <style lang="scss" scoped>
  163. .step-list {
  164. display: flex;
  165. flex-direction: column;
  166. gap: 24px;
  167. padding: 24px;
  168. }
  169. .step-item {
  170. display: flex;
  171. flex-flow: row wrap;
  172. align-items: center;
  173. gap: 32px;
  174. .circle {
  175. width: 28px;
  176. height: 28px;
  177. background: #6cb300;
  178. color: #fff;
  179. border-radius: 50%;
  180. display: flex;
  181. align-items: center;
  182. justify-content: center;
  183. font-size: 16px;
  184. font-weight: bold;
  185. flex-shrink: 0;
  186. }
  187. .desc {
  188. flex: 1;
  189. font-size: 14px;
  190. color: #333;
  191. max-width: 300px;
  192. white-space: pre-line;
  193. word-break: break-all;
  194. }
  195. .methods {
  196. max-width: 90px;
  197. white-space: pre-line;
  198. word-break: break-all;
  199. }
  200. .status-btn {
  201. width: 100px;
  202. height: 40px;
  203. font-size: 16px;
  204. &.el-button--default {
  205. background: #e1e1e1;
  206. color: #999;
  207. border: none;
  208. }
  209. &.el-button--primary {
  210. background: #17a2f8;
  211. color: #fff;
  212. border: none;
  213. }
  214. }
  215. }
  216. </style>