index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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="handleOrderPublish(1, 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. v-if="row.status == 2"
  62. @click="handleOrderPublish(1, row)"
  63. >
  64. 报工
  65. </el-link>
  66. <el-link
  67. type="primary"
  68. v-if="row.status == 4"
  69. :underline="false"
  70. icon="el-icon-truck"
  71. @click="toUnpack(row)"
  72. >
  73. 拆分
  74. </el-link>
  75. <el-link
  76. type="primary"
  77. :underline="false"
  78. icon="el-icon-edit"
  79. @click="toEnd(row)"
  80. >
  81. 完结
  82. </el-link>
  83. </template>
  84. </template>
  85. </ele-pro-table>
  86. </el-card>
  87. <createDialog ref="createRef" @success="createSuccess" />
  88. <unpackDialog ref="unpackRef" @success="createSuccess" />
  89. <pickingDialog ref="PickingRef" />
  90. </div>
  91. </template>
  92. <script>
  93. import { getPage } from '@/api/produceOrder/index.js';
  94. import produceOrderSearch from './components/produceOrder-search.vue';
  95. import createDialog from './components/createDialog.vue';
  96. import unpackDialog from './components/unpackDialog.vue';
  97. import pickingDialog from './components/pickingDialog.vue';
  98. export default {
  99. components: {
  100. produceOrderSearch,
  101. pickingDialog,
  102. createDialog,
  103. unpackDialog
  104. },
  105. data () {
  106. return {
  107. activeName: 'first',
  108. // 加载状态
  109. loading: false,
  110. pageType: 'add',
  111. dialogTitle: '',
  112. isBindPlan: false,
  113. statusOpt: {
  114. first: [
  115. { label: '所有状态', value: '5,4,7' },
  116. { label: '待生产', value: '4' },
  117. { label: '生产中', value: '5' },
  118. { label: '已延期', value: '7' }
  119. ],
  120. second: [{ label: '已完成', value: '6' }]
  121. },
  122. planType: [
  123. { label: '所有计划类型', value: null },
  124. { label: '内销计划', value: '1' },
  125. { label: '外销计划', value: '2' },
  126. { label: '预制计划', value: '3' }
  127. ],
  128. selection: []
  129. };
  130. },
  131. computed: {
  132. // 表格列配置
  133. columns () {
  134. const opt = {
  135. first: [
  136. // {
  137. // prop: 'deliveryTime',
  138. // label: '预测交货日期',
  139. // align: 'center',
  140. // showOverflowTooltip: true,
  141. // minWidth: 110
  142. // }
  143. ],
  144. second: [
  145. {
  146. prop: 'completeTime',
  147. label: '完成时间',
  148. align: 'center'
  149. },
  150. {
  151. prop: 'cycle',
  152. label: '生产周期',
  153. align: 'center'
  154. }
  155. ]
  156. };
  157. return [
  158. {
  159. width: 45,
  160. type: 'selection',
  161. columnKey: 'selection',
  162. align: 'center',
  163. fixed: 'left'
  164. },
  165. {
  166. columnKey: 'index',
  167. label: '序号',
  168. type: 'index',
  169. width: 55,
  170. align: 'center',
  171. showOverflowTooltip: true,
  172. fixed: 'left'
  173. },
  174. {
  175. slot: 'code',
  176. label: '生产工单号',
  177. align: 'center',
  178. minWidth: 110
  179. },
  180. {
  181. prop: 'productionPlanCode',
  182. label: '计划编号',
  183. align: 'center'
  184. },
  185. {
  186. prop: 'planType',
  187. label: '计划类型',
  188. align: 'center'
  189. },
  190. {
  191. prop: 'produceVersionName',
  192. label: '生产版本',
  193. align: 'center'
  194. },
  195. {
  196. prop: 'productCode',
  197. label: '产品编号',
  198. align: 'center'
  199. },
  200. {
  201. prop: 'productName',
  202. label: '产品名称',
  203. align: 'center'
  204. },
  205. {
  206. prop: 'brandNo',
  207. label: '牌号',
  208. align: 'center'
  209. },
  210. {
  211. prop: 'model',
  212. label: '型号',
  213. align: 'center'
  214. },
  215. {
  216. prop: 'formingNum',
  217. label: '要求成型数量',
  218. align: 'center',
  219. showOverflowTooltip: true,
  220. minWidth: 110
  221. },
  222. {
  223. prop: 'formingWeight',
  224. label: '要求成型重量',
  225. align: 'center',
  226. showOverflowTooltip: true,
  227. minWidth: 110
  228. },
  229. {
  230. prop: 'formedNum',
  231. label: '已成型数量',
  232. align: 'center',
  233. showOverflowTooltip: true,
  234. minWidth: 110
  235. },
  236. {
  237. prop: 'formedWeight',
  238. label: '已成型重量',
  239. align: 'center',
  240. showOverflowTooltip: true,
  241. minWidth: 110
  242. },
  243. {
  244. prop: 'planStartTime',
  245. label: '计划开始时间',
  246. align: 'center',
  247. showOverflowTooltip: true,
  248. minWidth: 110
  249. },
  250. {
  251. prop: 'startTime',
  252. label: '实际开始时间',
  253. align: 'center',
  254. showOverflowTooltip: true,
  255. minWidth: 110
  256. },
  257. ...opt[this.activeName],
  258. {
  259. prop: 'createTime',
  260. label: '创建时间',
  261. align: 'center',
  262. showOverflowTooltip: true,
  263. minWidth: 110
  264. },
  265. {
  266. slot: 'status',
  267. label: '状态',
  268. align: 'center',
  269. formatter: (row) => {
  270. const obj = this.statusOpt[this.activeName].find(
  271. (i) => i.value == row.status
  272. );
  273. return obj && obj.label;
  274. }
  275. },
  276. {
  277. columnKey: 'action',
  278. label: '操作',
  279. width: 350,
  280. align: 'center',
  281. resizable: false,
  282. fixed: 'right',
  283. slot: 'action',
  284. showOverflowTooltip: true
  285. }
  286. ];
  287. }
  288. },
  289. methods: {
  290. handlePicking () {
  291. this.$router.push({
  292. path: '/produceOrder/picking'
  293. });
  294. },
  295. statusFormatter (status) {
  296. const obj = this.statusOpt[this.activeName].find(
  297. (i) => i.value == status
  298. );
  299. return obj && obj.label;
  300. },
  301. /* 表格数据源 */
  302. datasource ({ page, limit, where }) {
  303. return getPage({
  304. pageNum: page,
  305. size: limit,
  306. ...where
  307. });
  308. },
  309. createSuccess () {
  310. this.reload();
  311. },
  312. handleCreate () {
  313. this.$refs.createRef.open(0);
  314. },
  315. // 发布工单
  316. handleOrderPublish (type, row) {
  317. this.$router.push({
  318. path: '/productionPlan/workOrderPublish',
  319. query: {
  320. type,
  321. id: row.id
  322. }
  323. });
  324. },
  325. // 完结与批量完结
  326. toEnd (row) {
  327. if (row) {
  328. this.$confirm(`是否要完结工单【${row.code}】?`, '提醒', {
  329. confirmButtonText: '确认',
  330. cancelButtonText: '取消',
  331. type: 'warning'
  332. })
  333. .then(() => {})
  334. .catch(() => {});
  335. } else {
  336. if (!this.selection.length)
  337. return this.$message.warning('请至少选择一条工单!');
  338. this.$confirm(`是否要完结${this.selection.length}条工单?`, '提醒', {
  339. confirmButtonText: '确认',
  340. cancelButtonText: '取消',
  341. type: 'warning'
  342. })
  343. .then(() => {})
  344. .catch(() => {});
  345. }
  346. },
  347. // 拆分
  348. toUnpack (row) {
  349. this.$refs.unpackRef.open(row);
  350. },
  351. handleTabChange () {
  352. this.$refs.searchRef.reset();
  353. },
  354. /* 刷新表格 */
  355. reload (where = {}) {
  356. this.$nextTick(() => {
  357. this.$refs.table.reload({ page: 1, where });
  358. });
  359. },
  360. goDetail (row) {
  361. this.$router.push({
  362. path: '/produceOrder/detail',
  363. query: {
  364. id: row.id
  365. }
  366. });
  367. },
  368. handleDelete ({ id }) {
  369. this.$confirm('确定删除当前数据?', '提示').then(async () => {
  370. await del(id);
  371. this.$message.success('删除成功!');
  372. this.reload();
  373. });
  374. }
  375. }
  376. };
  377. </script>
  378. <style lang="scss" scoped></style>