index.vue 11 KB

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