index.vue 12 KB

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