index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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,7' },
  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: 'productionPlanCode',
  185. label: '计划编号',
  186. align: 'center'
  187. },
  188. {
  189. prop: 'planType',
  190. label: '计划类型',
  191. align: 'center'
  192. },
  193. {
  194. prop: 'produceVersionName',
  195. label: '生产版本',
  196. align: 'center'
  197. },
  198. {
  199. prop: 'productCode',
  200. label: '产品编号',
  201. align: 'center'
  202. },
  203. {
  204. prop: 'productName',
  205. label: '产品名称',
  206. align: 'center'
  207. },
  208. {
  209. prop: 'brandNo',
  210. label: '牌号',
  211. align: 'center'
  212. },
  213. {
  214. prop: 'model',
  215. label: '型号',
  216. align: 'center'
  217. },
  218. {
  219. prop: 'formingNum',
  220. label: '要求成型数量',
  221. align: 'center',
  222. showOverflowTooltip: true,
  223. minWidth: 110
  224. },
  225. {
  226. prop: 'formingWeight',
  227. label: '要求成型重量',
  228. align: 'center',
  229. showOverflowTooltip: true,
  230. minWidth: 110
  231. },
  232. {
  233. prop: 'formedNum',
  234. label: '已成型数量',
  235. align: 'center',
  236. showOverflowTooltip: true,
  237. minWidth: 110
  238. },
  239. {
  240. prop: 'formedWeight',
  241. label: '已成型重量',
  242. align: 'center',
  243. showOverflowTooltip: true,
  244. minWidth: 110
  245. },
  246. {
  247. prop: 'planStartTime',
  248. label: '计划开始时间',
  249. align: 'center',
  250. showOverflowTooltip: true,
  251. minWidth: 110
  252. },
  253. {
  254. prop: 'startTime',
  255. label: '实际开始时间',
  256. align: 'center',
  257. showOverflowTooltip: true,
  258. minWidth: 110
  259. },
  260. ...opt[this.activeName],
  261. {
  262. prop: 'createTime',
  263. label: '创建时间',
  264. align: 'center',
  265. showOverflowTooltip: true,
  266. minWidth: 110
  267. },
  268. {
  269. slot: 'status',
  270. label: '状态',
  271. align: 'center',
  272. formatter: (row) => {
  273. const obj = this.statusOpt[this.activeName].find(
  274. (i) => i.value == row.status
  275. );
  276. return obj && obj.label;
  277. }
  278. },
  279. {
  280. columnKey: 'action',
  281. label: '操作',
  282. width: 250,
  283. align: 'center',
  284. resizable: false,
  285. fixed: 'right',
  286. slot: 'action',
  287. showOverflowTooltip: true
  288. }
  289. ];
  290. }
  291. },
  292. methods: {
  293. handlePicking () {
  294. this.$router.push({
  295. path: '/produceOrder/picking'
  296. });
  297. },
  298. statusFormatter (status) {
  299. const obj = this.statusOpt[this.activeName].find(
  300. (i) => i.value == status
  301. );
  302. return obj && obj.label;
  303. },
  304. /* 表格数据源 */
  305. datasource ({ page, limit, where }) {
  306. return getPage({
  307. pageNum: page,
  308. size: limit,
  309. ...where
  310. });
  311. },
  312. createSuccess () {
  313. this.reload();
  314. },
  315. handleCreate () {
  316. this.$refs.createRef.open(0);
  317. },
  318. // 发布工单
  319. handleOrderPublish (type, row) {
  320. this.$router.push({
  321. path: '/produceOrder/report',
  322. query: {
  323. type,
  324. id: row.id
  325. }
  326. });
  327. },
  328. // 完结与批量完结
  329. toEnd (row) {
  330. if (row) {
  331. this.$confirm(`是否要完结工单【${row.code}】?`, '提醒', {
  332. confirmButtonText: '确认',
  333. cancelButtonText: '取消',
  334. type: 'warning'
  335. })
  336. .then(() => {
  337. batchCompletion([row.id]).then((res) => {
  338. this.$message.success('成功');
  339. this.reload();
  340. });
  341. })
  342. .catch(() => {});
  343. } else {
  344. if (!this.selection.length) {
  345. return this.$message.warning('请至少选择一条工单!');
  346. }
  347. const ids = [];
  348. this.selection.map((item) => {
  349. ids.push(item.id);
  350. });
  351. this.$confirm(`是否要完结${this.selection.length}条工单?`, '提醒', {
  352. confirmButtonText: '确认',
  353. cancelButtonText: '取消',
  354. type: 'warning'
  355. })
  356. .then(() => {
  357. batchCompletion(ids).then((res) => {
  358. this.$message.success('成功');
  359. this.reload();
  360. });
  361. })
  362. .catch(() => {});
  363. }
  364. },
  365. // 取消完结
  366. toCancel (row) {
  367. cancelCompletion([row.id]).then((res) => {
  368. this.$message.success('成功');
  369. this.reload();
  370. });
  371. },
  372. // 拆分
  373. toUnpack (row) {
  374. this.$refs.unpackRef.open(row);
  375. },
  376. handleTabChange () {
  377. this.$refs.searchRef.reset();
  378. },
  379. /* 刷新表格 */
  380. reload (where = {}) {
  381. this.$nextTick(() => {
  382. where.statusList = (
  383. where.status || this.statusOpt[this.activeName][0].value
  384. ).split(',');
  385. this.$refs.table.reload({ page: 1, where });
  386. });
  387. },
  388. goDetail (row) {
  389. this.$router.push({
  390. path: '/produceOrder/detail',
  391. query: {
  392. id: row.id,
  393. produceVersionId: row.produceVersionId
  394. }
  395. });
  396. },
  397. handleDelete ({ id }) {
  398. this.$confirm('确定删除当前数据?', '提示').then(async () => {
  399. await del(id);
  400. this.$message.success('删除成功!');
  401. this.reload();
  402. });
  403. }
  404. }
  405. };
  406. </script>
  407. <style lang="scss" scoped></style>