index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <ele-modal
  3. title="工序工步列表"
  4. :maxable="true"
  5. custom-class="ele-dialog-form long-dialog-form"
  6. :centered="true"
  7. :visible.sync="visible"
  8. :close-on-click-modal="false"
  9. width="85%"
  10. append-to-body
  11. @close="handleClose"
  12. >
  13. <ele-pro-table
  14. style="min-height: 400px"
  15. ref="fileTable"
  16. :columns="columns"
  17. :datasource="workList"
  18. >
  19. <template v-slot:starttime="{ row, $index }">
  20. <el-date-picker
  21. v-model="row.startTime"
  22. type="datetime"
  23. value-format="yyyy-MM-dd HH:mm:ss"
  24. placeholder="选择开始日期"
  25. >
  26. </el-date-picker>
  27. </template>
  28. <template v-slot:endtime="{ row, $index }">
  29. <el-date-picker
  30. v-model="row.endTime"
  31. type="datetime"
  32. value-format="yyyy-MM-dd HH:mm:ss"
  33. placeholder="选择结束日期"
  34. >
  35. </el-date-picker>
  36. </template>
  37. <template v-slot:wuping="{ row }">
  38. <el-button type="primary" @click="goDetails(row, 'toolList')"
  39. >物品({{ dataLeng(row, 'toolList') }})</el-button
  40. >
  41. </template>
  42. <template v-slot:zysx="{ row }">
  43. <el-button type="primary" @click="goDetails(row, 'postscriptList')"
  44. >注意事项({{ dataLeng(row, 'postscriptList') }})</el-button
  45. >
  46. </template>
  47. <template v-slot:action="{ row }">
  48. <el-link type="primary" @click="saveData(row)" :underline="false"
  49. >确定</el-link
  50. >
  51. <el-link
  52. v-if="row.hasStepWorkTimeRecord"
  53. type="primary"
  54. @click="showWorkTimeHistoryDialog(row)"
  55. :underline="false"
  56. >报工记录</el-link
  57. >
  58. </template>
  59. <!-- 表头工具栏 -->
  60. </ele-pro-table>
  61. <Details
  62. v-if="detailsVisible"
  63. :detailsVisible="detailsVisible"
  64. @close="close"
  65. :list="list"
  66. :title="detailTitle"
  67. />
  68. <WorkTimeHistory
  69. :details-visible="stepWorkTimeDialogVisible"
  70. :produceStepWorkTimeId="produceStepWorkTimeId"
  71. @close="stepWorkDialogClose"/>
  72. </ele-modal>
  73. </template>
  74. <script>
  75. import Details from './details.vue';
  76. import WorkTimeHistory from './workTimeHistory.vue';
  77. import { listByParam, addStepWorkTime, listStepWorkTimeRecord } from '@/api/produce/workOrder';
  78. import dayjs from 'dayjs';
  79. export default {
  80. components: { WorkTimeHistory, Details },
  81. data() {
  82. return {
  83. visible: false,
  84. columns: [
  85. {
  86. columnKey: 'index',
  87. label: '序号',
  88. type: 'index',
  89. width: 55,
  90. align: 'center',
  91. showOverflowTooltip: true
  92. },
  93. {
  94. label: '编码',
  95. prop: 'code',
  96. width: 110,
  97. align: 'center',
  98. showOverflowTooltip: true
  99. },
  100. {
  101. label: '名称',
  102. prop: 'name',
  103. width: 180,
  104. align: 'center',
  105. showOverflowTooltip: true
  106. },
  107. {
  108. label: '内容',
  109. prop: 'defaultValue',
  110. minWidth: 300,
  111. align: 'center',
  112. showOverflowTooltip: true
  113. },
  114. {
  115. slot: 'wuping',
  116. label: '物品清单',
  117. prop: 'wuping',
  118. width: 130,
  119. align: 'center',
  120. showOverflowTooltip: true
  121. },
  122. {
  123. slot: 'zysx',
  124. label: '注意事项',
  125. prop: 'zysx',
  126. width: 130,
  127. align: 'center',
  128. showOverflowTooltip: true
  129. },
  130. {
  131. label: '工时',
  132. prop: 'totalTimeStr',
  133. width: 150,
  134. align: 'center',
  135. showOverflowTooltip: true
  136. },
  137. {
  138. label: '开始时间',
  139. slot: 'starttime',
  140. prop: 'starttime',
  141. width: 250,
  142. align: 'center',
  143. showOverflowTooltip: true
  144. },
  145. {
  146. label: '结束时间',
  147. slot: 'endtime',
  148. prop: 'endtime',
  149. width: 250,
  150. align: 'center',
  151. showOverflowTooltip: true
  152. },
  153. {
  154. columnKey: 'action',
  155. slot: 'action',
  156. label: '操作',
  157. align: 'center',
  158. width: 130,
  159. resizable: false,
  160. showOverflowTooltip: true
  161. }
  162. ],
  163. workList: [],
  164. detailsVisible: false,
  165. list: [],
  166. detailTitle: null,
  167. queryParam: {},
  168. stepWorkTimeDialogVisible: false,
  169. produceStepWorkTimeId: null,
  170. };
  171. },
  172. computed: {
  173. dataLeng() {
  174. return (row, type) => {
  175. if (!row[type]) {
  176. return 0;
  177. }
  178. return row[type].length;
  179. };
  180. }
  181. },
  182. methods: {
  183. open(queryParam) {
  184. this.queryParam = queryParam;
  185. this.visible = true;
  186. this.getList();
  187. },
  188. getList() {
  189. listByParam(this.queryParam)
  190. .then((res) => {
  191. this.workList = res;
  192. })
  193. .catch((err) => {
  194. this.$message.error('获取数据失败');
  195. });
  196. },
  197. // 保存
  198. saveData(row) {
  199. // 注意判断时间 是否填写
  200. if (!row.startTime) {
  201. this.$message.warning('请选择开始时间');
  202. return;
  203. }
  204. // 判断结束时间大于开始时间
  205. if (row.endTime) {
  206. const startTime = dayjs(row.startTime);
  207. const endTime = dayjs(row.endTime);
  208. const isEndAfterStart = endTime.isAfter(startTime)
  209. if (!isEndAfterStart) {
  210. this.$message.warning('结束时间必须大于开始时间,请重新选择结束时间')
  211. return;
  212. }
  213. }
  214. const formData = {
  215. produceStepId: row.stepId, // 工步ID,
  216. taskId: row.paramId, // 工艺ID
  217. workOrderId: this.queryParam.workOrderId, // 工单ID
  218. startTime: row.startTime,
  219. endTime: row.endTime
  220. };
  221. const loading = this.$messageLoading('保存中...');
  222. addStepWorkTime(formData)
  223. .then((res) => {
  224. loading.close();
  225. if (res) {
  226. this.$message.success('保存成功');
  227. this.getList();
  228. } else {
  229. this.$message.error('保存失败');
  230. }
  231. })
  232. .catch((e) => {
  233. loading.close();
  234. this.$message.error('保存失败');
  235. });
  236. },
  237. showWorkTimeHistoryDialog(row) {
  238. if (!row.produceStepWorkTimeId) return;
  239. this.produceStepWorkTimeId = row.produceStepWorkTimeId
  240. this.stepWorkTimeDialogVisible = true;
  241. },
  242. handleClose() {
  243. this.visible = false;
  244. },
  245. close() {
  246. this.detailsVisible = false;
  247. },
  248. stepWorkDialogClose() {
  249. this.stepWorkTimeDialogVisible = false;
  250. },
  251. goDetails(row, type) {
  252. if (!row[type] || row[type].length === 0) {
  253. return this.$message.warning('暂无详细数据');
  254. }
  255. this.list = row[type];
  256. this.detailTitle = type === 'toolList' ? '物品清单' : '注意事项';
  257. this.detailsVisible = true;
  258. }
  259. }
  260. };
  261. </script>