index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <produceOrder-search
  5. @search="reload"
  6. ref="searchRef"
  7. :statusOpt="statusOpt"
  8. :planType="planType"
  9. :activeName="activeName"
  10. >
  11. </produceOrder-search>
  12. <el-tabs v-model="activeName" type="card">
  13. <el-tab-pane label="未完成工单" name="first"></el-tab-pane>
  14. <el-tab-pane label="已完成工单" name="second"></el-tab-pane>
  15. </el-tabs>
  16. <!-- 数据表格 -->
  17. <ele-pro-table
  18. ref="table"
  19. :key="activeName"
  20. :initLoad="false"
  21. :columns="columns"
  22. :datasource="datasource"
  23. :cache-key="`${activeName}produceOrderTable`"
  24. :selection.sync="selection"
  25. >
  26. <template v-slot:toolbar>
  27. <!-- <el-button type="primary">工单刷新</el-button> -->
  28. <el-button type="success" @click="handlePicking">领料</el-button>
  29. <el-button type="success" @click="toEnd()">批量完结</el-button>
  30. <el-button type="success" @click="handleCreate">创建工单</el-button>
  31. <!-- <el-button type="success">工单操作控制</el-button> -->
  32. </template>
  33. <template v-slot:code="{ row }">
  34. <el-link type="primary" :underline="false" @click="goDetail(row)">
  35. {{ row.code }}
  36. </el-link>
  37. </template>
  38. <template v-slot:status="{ row }">
  39. <span :class="{ 'ele-text-danger': row.status == 3 }">
  40. {{ statusFormatter(row.status) }}
  41. </span>
  42. </template>
  43. <!-- 操作列 -->
  44. <template v-slot:action="{ row }">
  45. <template v-if="activeName == 'second'">
  46. <el-link
  47. type="primary"
  48. :underline="false"
  49. icon="el-icon-truck"
  50. v-if="row.status == 6"
  51. @click="toCancel(row)"
  52. >
  53. 取消完结
  54. </el-link></template
  55. >
  56. <template v-else>
  57. <el-link
  58. type="primary"
  59. :underline="false"
  60. icon="el-icon-truck"
  61. @click="handleOrderPublish(1, row)"
  62. >
  63. 报工
  64. </el-link>
  65. <el-link
  66. type="primary"
  67. v-if="row.status == 4"
  68. :underline="false"
  69. icon="el-icon-truck"
  70. @click="toUnpack(row)"
  71. >
  72. 拆分
  73. </el-link>
  74. <el-link
  75. type="primary"
  76. :underline="false"
  77. icon="el-icon-edit"
  78. @click="toEnd(row)"
  79. >
  80. 完结
  81. </el-link>
  82. </template>
  83. </template>
  84. </ele-pro-table>
  85. </el-card>
  86. <createDialog ref="createRef" @success="createSuccess" />
  87. <unpackDialog ref="unpackRef" @success="createSuccess" />
  88. <pickingDialog ref="PickingRef" />
  89. </div>
  90. </template>
  91. <script>
  92. import {
  93. getPage,
  94. batchCompletion,
  95. cancelCompletion
  96. } from '@/api/produceOrder/index.js';
  97. import produceOrderSearch from './components/produceOrder-search.vue';
  98. import createDialog from './components/createDialog.vue';
  99. import unpackDialog from './components/unpackDialog.vue';
  100. import pickingDialog from './components/pickingDialog.vue';
  101. export default {
  102. components: {
  103. produceOrderSearch,
  104. pickingDialog,
  105. createDialog,
  106. unpackDialog
  107. },
  108. data () {
  109. return {
  110. activeName: 'first',
  111. // 加载状态
  112. loading: false,
  113. pageType: 'add',
  114. dialogTitle: '',
  115. isBindPlan: false,
  116. statusOpt: {
  117. first: [
  118. { label: '所有状态', value: '5,4' },
  119. { label: '待生产', value: '4' },
  120. { label: '生产中', value: '5' }
  121. // { label: '已延期', value: '7' }
  122. ],
  123. second: [{ label: '已完成', value: '6' }]
  124. },
  125. planType: [
  126. { label: '所有计划类型', value: null },
  127. { label: '内销计划', value: '1' },
  128. { label: '外销计划', value: '2' },
  129. { label: '预制计划', value: '3' }
  130. ],
  131. selection: []
  132. };
  133. },
  134. computed: {
  135. // 表格列配置
  136. columns () {
  137. const opt = {
  138. first: [
  139. // {
  140. // prop: 'deliveryTime',
  141. // label: '预测交货日期',
  142. // align: 'center',
  143. // showOverflowTooltip: true,
  144. // minWidth: 110
  145. // }
  146. ],
  147. second: [
  148. {
  149. prop: 'completeTime',
  150. label: '完成时间',
  151. align: 'center'
  152. },
  153. {
  154. prop: 'cycle',
  155. label: '生产周期',
  156. align: 'center'
  157. }
  158. ]
  159. };
  160. return [
  161. {
  162. width: 45,
  163. type: 'selection',
  164. columnKey: 'selection',
  165. align: 'center',
  166. fixed: 'left'
  167. },
  168. {
  169. columnKey: 'index',
  170. label: '序号',
  171. type: 'index',
  172. width: 55,
  173. align: 'center',
  174. showOverflowTooltip: true,
  175. fixed: 'left'
  176. },
  177. {
  178. slot: 'code',
  179. label: '生产工单号',
  180. align: 'center',
  181. minWidth: 110
  182. },
  183. {
  184. prop: 'originalCode',
  185. label: '原始工单号',
  186. align: 'center',
  187. minWidth: 110
  188. },
  189. {
  190. prop: 'productionPlanCode',
  191. label: '计划编号',
  192. align: 'center'
  193. },
  194. {
  195. prop: 'planType',
  196. label: '计划类型',
  197. align: 'center',
  198. formatter: (row) => {
  199. const obj = this.planType.find((i) => i.value == row.planType);
  200. return obj && obj.label;
  201. }
  202. },
  203. {
  204. prop: 'produceVersionName',
  205. label: '生产版本',
  206. align: 'center'
  207. },
  208. {
  209. prop: 'productCode',
  210. label: '产品编号',
  211. align: 'center'
  212. },
  213. {
  214. prop: 'productName',
  215. label: '产品名称',
  216. align: 'center'
  217. },
  218. {
  219. prop: 'brandNo',
  220. label: '牌号',
  221. align: 'center'
  222. },
  223. {
  224. prop: 'model',
  225. label: '型号',
  226. align: 'center'
  227. },
  228. {
  229. prop: 'formingNum',
  230. label: '要求成型数量',
  231. align: 'center',
  232. showOverflowTooltip: true,
  233. minWidth: 110
  234. },
  235. {
  236. prop: 'formingWeight',
  237. label: '要求成型重量',
  238. align: 'center',
  239. showOverflowTooltip: true,
  240. minWidth: 110
  241. },
  242. {
  243. prop: 'formedNum',
  244. label: '已成型数量',
  245. align: 'center',
  246. showOverflowTooltip: true,
  247. minWidth: 110
  248. },
  249. {
  250. prop: 'formedWeight',
  251. label: '已成型重量',
  252. align: 'center',
  253. showOverflowTooltip: true,
  254. minWidth: 110
  255. },
  256. {
  257. prop: 'planStartTime',
  258. label: '计划开始时间',
  259. align: 'center',
  260. showOverflowTooltip: true,
  261. minWidth: 110
  262. },
  263. {
  264. prop: 'startTime',
  265. label: '实际开始时间',
  266. align: 'center',
  267. showOverflowTooltip: true,
  268. minWidth: 110
  269. },
  270. ...opt[this.activeName],
  271. {
  272. prop: 'createTime',
  273. label: '创建时间',
  274. align: 'center',
  275. showOverflowTooltip: true,
  276. minWidth: 110
  277. },
  278. {
  279. slot: 'status',
  280. label: '状态',
  281. align: 'center',
  282. formatter: (row) => {
  283. const obj = this.statusOpt[this.activeName].find(
  284. (i) => i.value == row.status
  285. );
  286. return obj && obj.label;
  287. }
  288. },
  289. {
  290. columnKey: 'action',
  291. label: '操作',
  292. width: 250,
  293. align: 'center',
  294. resizable: false,
  295. fixed: 'right',
  296. slot: 'action',
  297. showOverflowTooltip: true
  298. }
  299. ];
  300. }
  301. },
  302. methods: {
  303. handlePicking () {
  304. this.$router.push({
  305. path: '/produceOrder/picking'
  306. });
  307. },
  308. statusFormatter (status) {
  309. const obj = this.statusOpt[this.activeName].find(
  310. (i) => i.value == status
  311. );
  312. return obj && obj.label;
  313. },
  314. /* 表格数据源 */
  315. datasource ({ page, limit, where }) {
  316. return getPage({
  317. pageNum: page,
  318. size: limit,
  319. ...where
  320. });
  321. },
  322. createSuccess () {
  323. this.reload();
  324. },
  325. handleCreate () {
  326. this.$refs.createRef.open(0);
  327. },
  328. // 发布工单
  329. handleOrderPublish (type, row) {
  330. this.$router.push({
  331. path: '/produceOrder/report',
  332. query: {
  333. type,
  334. id: row.id
  335. }
  336. });
  337. },
  338. // 完结与批量完结
  339. toEnd (row) {
  340. if (row) {
  341. this.$confirm(`是否要完结工单【${row.code}】?`, '提醒', {
  342. confirmButtonText: '确认',
  343. cancelButtonText: '取消',
  344. type: 'warning'
  345. })
  346. .then(() => {
  347. batchCompletion([row.id]).then((res) => {
  348. this.$message.success('成功');
  349. this.reload();
  350. });
  351. })
  352. .catch(() => {});
  353. } else {
  354. if (!this.selection.length) {
  355. return this.$message.warning('请至少选择一条工单!');
  356. }
  357. const ids = [];
  358. this.selection.map((item) => {
  359. ids.push(item.id);
  360. });
  361. const h = this.$createElement;
  362. this.$msgbox({
  363. title: '提醒',
  364. message: h('p', null, [
  365. h('span', null, '是否要完结 '),
  366. h(
  367. 'span',
  368. { style: 'color: #70B603' },
  369. `${this.selection.length}`
  370. ),
  371. h('span', null, ' 条工单?')
  372. ]),
  373. showCancelButton: true,
  374. confirmButtonText: '确认',
  375. cancelButtonText: '取消',
  376. type: 'warning'
  377. })
  378. .then(() => {
  379. batchCompletion(ids).then((res) => {
  380. this.$message.success('成功');
  381. this.reload();
  382. });
  383. })
  384. .catch(() => {});
  385. }
  386. },
  387. // 取消完结
  388. toCancel (row) {
  389. cancelCompletion([row.id]).then((res) => {
  390. this.$message.success('成功');
  391. this.reload();
  392. });
  393. },
  394. // 拆分
  395. toUnpack (row) {
  396. this.$refs.unpackRef.open(row);
  397. },
  398. handleTabChange () {
  399. this.$refs.searchRef.reset();
  400. },
  401. /* 刷新表格 */
  402. reload (where = {}) {
  403. this.$nextTick(() => {
  404. where.statusList = (
  405. where.status || this.statusOpt[this.activeName][0].value
  406. ).split(',');
  407. this.$refs.table.reload({ page: 1, where });
  408. });
  409. },
  410. goDetail (row) {
  411. this.$router.push({
  412. path: '/produceOrder/detail',
  413. query: {
  414. id: row.id,
  415. produceVersionId: row.produceVersionId
  416. }
  417. });
  418. },
  419. handleDelete ({ id }) {
  420. this.$confirm('确定删除当前数据?', '提示').then(async () => {
  421. await del(id);
  422. this.$message.success('删除成功!');
  423. this.reload();
  424. });
  425. }
  426. }
  427. };
  428. </script>
  429. <style lang="scss" scoped></style>