index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <productionPlan-search
  5. @search="reload"
  6. ref="searchRef"
  7. :statusOpt="statusOpt"
  8. :planType="planType"
  9. :activeName="activeName"
  10. >
  11. </productionPlan-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}ProductionPlanTable`"
  24. >
  25. <template v-slot:code="{ row }">
  26. <el-link type="primary" :underline="false" @click="goDetail(row)">
  27. {{ row.code }}
  28. </el-link>
  29. </template>
  30. <template v-slot:productWeight="{ row }">
  31. {{ row.productWeight }} {{ row.weightUnit }}
  32. </template>
  33. <template v-slot:newSumOrderWeight="{ row }">
  34. {{ row.newSumOrderWeight }} {{ row.newWeightUnit }}
  35. </template>
  36. <template v-slot:status="{ row }">
  37. <span :class="{ 'ele-text-danger': row.status == 3 }">
  38. {{ statusFormatter(row.status) }}
  39. </span>
  40. </template>
  41. <!-- 操作列 -->
  42. <template v-slot:action="{ row }">
  43. <el-link
  44. type="primary"
  45. :underline="false"
  46. icon="el-icon-truck"
  47. v-if="row.status == 2"
  48. @click="handleOrderPublish(1, row)"
  49. >
  50. 发布工单
  51. </el-link>
  52. <el-link
  53. type="primary"
  54. v-if="row.status == 3"
  55. :underline="false"
  56. icon="el-icon-truck"
  57. @click="handleOrderPublish(2, row)"
  58. >
  59. 重新发布
  60. </el-link>
  61. <el-link
  62. type="primary"
  63. :underline="false"
  64. icon="el-icon-edit"
  65. @click="planEdit(row)"
  66. >
  67. 修改计划
  68. </el-link>
  69. <el-link
  70. type="primary"
  71. :underline="false"
  72. @click="handleDelete(row)"
  73. icon="el-icon-edit"
  74. >
  75. 删除
  76. </el-link>
  77. </template>
  78. </ele-pro-table>
  79. </el-card>
  80. </div>
  81. </template>
  82. <script>
  83. import { getList, del } from '@/api/productionPlan/index.js';
  84. import productionPlanSearch from './components/productionPlan-search.vue';
  85. import { release } from '@/api/productionPlan/order.js';
  86. import { multiply } from '@/utils/math';
  87. import { getCode } from '@/api/codeManagement';
  88. export default {
  89. components: {
  90. productionPlanSearch
  91. },
  92. data() {
  93. return {
  94. activeName: 'first',
  95. // 加载状态
  96. loading: false,
  97. pageType: 'add',
  98. dialogTitle: '',
  99. isBindPlan: false,
  100. statusOpt: {
  101. first: [
  102. { label: '所有状态', value: '3,2' },
  103. { label: '待发布', value: '2' },
  104. { label: '发布失败', value: '3' }
  105. ],
  106. second: [
  107. { label: '所有状态', value: '7,4,5,6' },
  108. { label: '待生产', value: '4' },
  109. { label: '生产中', value: '5' },
  110. { label: '已完成', value: '6' },
  111. { label: '已延期', value: '7' }
  112. ]
  113. },
  114. planType: [
  115. { label: '所有计划类型', value: null },
  116. { label: '内销计划', value: '1' },
  117. { label: '外销计划', value: '2' },
  118. { label: '预制计划', value: '3' }
  119. ]
  120. };
  121. },
  122. computed: {
  123. // 表格列配置
  124. columns() {
  125. const opt = {
  126. first: [
  127. // {
  128. // prop: 'deliveryTime',
  129. // label: '预测交货日期',
  130. // align: 'center',
  131. // showOverflowTooltip: true,
  132. // minWidth: 110
  133. // }
  134. ],
  135. second: [
  136. // {
  137. // prop: 'formingTime',
  138. // label: '实际生产日期',
  139. // align: 'center',
  140. // showOverflowTooltip: true,
  141. // minWidth: 110
  142. // },
  143. {
  144. prop: 'releaseTime',
  145. label: '工单发布日期',
  146. align: 'center',
  147. showOverflowTooltip: true,
  148. minWidth: 110
  149. },
  150. {
  151. prop: 'planFormingTime',
  152. label: '预测生产日期',
  153. align: 'center',
  154. showOverflowTooltip: true,
  155. minWidth: 110
  156. },
  157. {
  158. prop: 'deliveryTime',
  159. label: '预测交货日期',
  160. align: 'center',
  161. showOverflowTooltip: true,
  162. minWidth: 110
  163. },
  164. {
  165. prop: 'formingTime',
  166. label: '实际交货日期',
  167. align: 'center',
  168. showOverflowTooltip: true,
  169. minWidth: 110
  170. }
  171. ]
  172. };
  173. return [
  174. {
  175. columnKey: 'index',
  176. label: '序号',
  177. type: 'index',
  178. width: 55,
  179. align: 'center',
  180. showOverflowTooltip: true,
  181. fixed: 'left'
  182. },
  183. {
  184. slot: 'code',
  185. prop: 'code',
  186. action: 'code',
  187. label: '计划编号',
  188. align: 'center',
  189. showOverflowTooltip: true,
  190. minWidth: 180
  191. },
  192. {
  193. prop: 'productCode',
  194. label: '物料编号',
  195. align: 'center',
  196. showOverflowTooltip: true,
  197. minWidth: 140
  198. },
  199. {
  200. prop: 'brandNo',
  201. label: '牌号',
  202. align: 'center',
  203. showOverflowTooltip: true
  204. },
  205. {
  206. prop: 'model',
  207. label: '型号',
  208. align: 'center',
  209. showOverflowTooltip: true
  210. },
  211. {
  212. prop: 'productNum',
  213. label: '计划数量',
  214. align: 'center',
  215. showOverflowTooltip: true
  216. },
  217. {
  218. prop: 'productWeight',
  219. label: '计划重量',
  220. align: 'center',
  221. showOverflowTooltip: true,
  222. slot: 'productWeight'
  223. },
  224. {
  225. prop: 'requiredFormingNum',
  226. label: '要求生产数量',
  227. align: 'center',
  228. showOverflowTooltip: true
  229. },
  230. {
  231. prop: 'newSumOrderWeight',
  232. label: '要求生产重量',
  233. align: 'center',
  234. showOverflowTooltip: true,
  235. slot: 'newSumOrderWeight',
  236. },
  237. // {
  238. // prop: '',
  239. // label: '已生产数量',
  240. // align: 'center',
  241. // showOverflowTooltip: true,
  242. // minWidth: 110
  243. // },
  244. {
  245. prop: 'reqMoldTime',
  246. label: '要求生产日期',
  247. align: 'center',
  248. showOverflowTooltip: true,
  249. minWidth: 110
  250. },
  251. ...opt[this.activeName],
  252. {
  253. prop: 'orderType',
  254. label: '计划类型',
  255. align: 'center',
  256. showOverflowTooltip: true,
  257. formatter: (row) => {
  258. const obj = this.planType.find((i) => i.value == row.planType);
  259. return obj && obj.label;
  260. }
  261. },
  262. {
  263. prop: 'createTime',
  264. label: '创建时间',
  265. align: 'center',
  266. showOverflowTooltip: true,
  267. minWidth: 110
  268. },
  269. {
  270. columnKey: 'status',
  271. slot: 'status',
  272. label: '状态',
  273. align: 'center',
  274. formatter: (row) => {
  275. const obj = this.statusOpt[this.activeName].find(
  276. (i) => i.value == row.status
  277. );
  278. return obj && obj.label;
  279. }
  280. },
  281. // ...(this.activeName === 'second'
  282. // ? [
  283. // {
  284. // prop: 'releaseTime',
  285. // label: '发布时间',
  286. // align: 'center',
  287. // showOverflowTooltip: true,
  288. // minWidth: 110
  289. // }
  290. // ]
  291. // : []),
  292. ...(this.activeName === 'first'
  293. ? [
  294. {
  295. columnKey: 'action',
  296. label: '操作',
  297. width: 350,
  298. align: 'center',
  299. resizable: false,
  300. fixed: 'right',
  301. slot: 'action',
  302. showOverflowTooltip: true
  303. }
  304. ]
  305. : [])
  306. ];
  307. }
  308. },
  309. methods: {
  310. statusFormatter(status) {
  311. const obj = this.statusOpt[this.activeName].find(
  312. (i) => i.value == status
  313. );
  314. return obj && obj.label;
  315. },
  316. /* 表格数据源 */
  317. datasource({ page, limit, where }) {
  318. return getList({
  319. pageNum: page,
  320. size: limit,
  321. ...where
  322. });
  323. },
  324. // 发布工单
  325. handleOrderPublish(type, row) {
  326. this.$confirm('发布工单后不可撤回,确定发布吗?', '发布确认')
  327. .then(async () => {
  328. const loading = this.$loading({
  329. lock: true,
  330. fullscreen: true,
  331. text: '工单发布中...'
  332. });
  333. try {
  334. let code = row.workOrderCode;
  335. if (!code) {
  336. code = await getCode('product_order_code');
  337. }
  338. // 反显对象会报错 status
  339. const data = await release([ row.id ]);
  340. if (data || data === 0) {
  341. this.$message.success('发布成功!');
  342. } else {
  343. this.$message.error('发布失败,请重新发布!');
  344. }
  345. this.reload();
  346. } catch (error) {
  347. console.error(error);
  348. }
  349. loading.close();
  350. })
  351. .catch((err) => {
  352. console.error(err);
  353. });
  354. // this.$router.push({
  355. // path: '/productionPlan/workOrderPublish',
  356. // query: {
  357. // type,
  358. // id: row.id
  359. // }
  360. // });
  361. },
  362. // 修改计划
  363. planEdit({ id }) {
  364. this.$router.push({
  365. path: '/saleOrder/salesToProduction',
  366. query: {
  367. type: 'edit',
  368. id
  369. }
  370. });
  371. },
  372. handleTabChange() {
  373. this.$refs.searchRef.reset();
  374. },
  375. /* 刷新表格 */
  376. reload(where) {
  377. this.$nextTick(() => {
  378. this.$refs.table.reload({ page: 1, where });
  379. });
  380. },
  381. goDetail({ id }) {
  382. this.$router.push({
  383. path: '/productionPlan/detail/' + id
  384. });
  385. },
  386. handleDelete({ id }) {
  387. this.$confirm('确定删除当前数据?', '提示')
  388. .then(async () => {
  389. await del(id);
  390. this.$message.success('删除成功!');
  391. this.reload();
  392. })
  393. .catch((err) => {
  394. console.error(err);
  395. });
  396. }
  397. }
  398. };
  399. </script>
  400. <style lang="scss" scoped></style>