index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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. export default {
  80. components: {
  81. productionPlanSearch
  82. },
  83. data() {
  84. return {
  85. activeName: 'first',
  86. // 加载状态
  87. loading: false,
  88. pageType: 'add',
  89. dialogTitle: '',
  90. isBindPlan: false,
  91. statusOpt: {
  92. first: [
  93. { label: '所有状态', value: '3,2' },
  94. { label: '待发布', value: '2' },
  95. { label: '发布失败', value: '3' }
  96. ],
  97. second: [
  98. { label: '所有状态', value: '7,4,5,6' },
  99. { label: '待生产', value: '4' },
  100. { label: '生产中', value: '5' },
  101. { label: '已完成', value: '6' },
  102. { label: '已延期', value: '7' }
  103. ]
  104. },
  105. planType: [
  106. { label: '所有计划类型', value: null },
  107. { label: '内销计划', value: '1' },
  108. { label: '外销计划', value: '2' },
  109. { label: '预制计划', value: '3' }
  110. ]
  111. };
  112. },
  113. computed: {
  114. // 表格列配置
  115. columns() {
  116. const opt = {
  117. first: [
  118. // {
  119. // prop: 'deliveryTime',
  120. // label: '预测交货日期',
  121. // align: 'center',
  122. // showOverflowTooltip: true,
  123. // minWidth: 110
  124. // }
  125. ],
  126. second: [
  127. // {
  128. // prop: 'formingTime',
  129. // label: '实际成型日期',
  130. // align: 'center',
  131. // showOverflowTooltip: true,
  132. // minWidth: 110
  133. // },
  134. {
  135. prop: 'releaseTime',
  136. label: '工单发布日期',
  137. align: 'center',
  138. showOverflowTooltip: true,
  139. minWidth: 110
  140. },
  141. {
  142. prop: 'planFormingTime',
  143. label: '预测成型日期',
  144. align: 'center',
  145. showOverflowTooltip: true,
  146. minWidth: 110
  147. },
  148. {
  149. prop: 'deliveryTime',
  150. label: '预测交货日期',
  151. align: 'center',
  152. showOverflowTooltip: true,
  153. minWidth: 110
  154. },
  155. {
  156. prop: 'formingTime',
  157. label: '实际交货日期',
  158. align: 'center',
  159. showOverflowTooltip: true,
  160. minWidth: 110
  161. }
  162. ]
  163. };
  164. return [
  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. prop: 'code',
  177. action: 'code',
  178. label: '计划编号',
  179. align: 'center',
  180. showOverflowTooltip: true,
  181. minWidth: 180
  182. },
  183. {
  184. prop: 'productCode',
  185. label: '物料编号',
  186. align: 'center',
  187. showOverflowTooltip: true,
  188. minWidth: 140
  189. },
  190. {
  191. prop: 'brandNo',
  192. label: '牌号',
  193. align: 'center',
  194. showOverflowTooltip: true
  195. },
  196. {
  197. prop: 'model',
  198. label: '型号',
  199. align: 'center',
  200. showOverflowTooltip: true
  201. },
  202. {
  203. prop: 'productNum',
  204. label: '计划数量',
  205. align: 'center',
  206. showOverflowTooltip: true
  207. },
  208. {
  209. prop: 'productWeight',
  210. label: '计划重量',
  211. align: 'center',
  212. showOverflowTooltip: true
  213. },
  214. {
  215. prop: 'requiredFormingNum',
  216. label: '要求成型数量',
  217. align: 'center',
  218. showOverflowTooltip: true
  219. },
  220. // {
  221. // prop: '',
  222. // label: '已成型数量',
  223. // align: 'center',
  224. // showOverflowTooltip: true,
  225. // minWidth: 110
  226. // },
  227. {
  228. prop: 'reqMoldTime',
  229. label: '要求成型日期',
  230. align: 'center',
  231. showOverflowTooltip: true,
  232. minWidth: 110
  233. },
  234. ...opt[this.activeName],
  235. {
  236. prop: 'orderType',
  237. label: '计划类型',
  238. align: 'center',
  239. showOverflowTooltip: true,
  240. formatter: (row) => {
  241. const obj = this.planType.find((i) => i.value == row.planType);
  242. return obj && obj.label;
  243. }
  244. },
  245. {
  246. prop: 'createTime',
  247. label: '创建时间',
  248. align: 'center',
  249. showOverflowTooltip: true,
  250. minWidth: 110
  251. },
  252. {
  253. columnKey: 'status',
  254. slot: 'status',
  255. label: '状态',
  256. align: 'center',
  257. formatter: (row) => {
  258. const obj = this.statusOpt[this.activeName].find(
  259. (i) => i.value == row.status
  260. );
  261. return obj && obj.label;
  262. }
  263. },
  264. // ...(this.activeName === 'second'
  265. // ? [
  266. // {
  267. // prop: 'releaseTime',
  268. // label: '发布时间',
  269. // align: 'center',
  270. // showOverflowTooltip: true,
  271. // minWidth: 110
  272. // }
  273. // ]
  274. // : []),
  275. ...(this.activeName === 'first'
  276. ? [
  277. {
  278. columnKey: 'action',
  279. label: '操作',
  280. width: 350,
  281. align: 'center',
  282. resizable: false,
  283. fixed: 'right',
  284. slot: 'action',
  285. showOverflowTooltip: true
  286. }
  287. ]
  288. : [])
  289. ];
  290. }
  291. },
  292. methods: {
  293. statusFormatter(status) {
  294. const obj = this.statusOpt[this.activeName].find(
  295. (i) => i.value == status
  296. );
  297. return obj && obj.label;
  298. },
  299. /* 表格数据源 */
  300. datasource({ page, limit, where }) {
  301. return getList({
  302. pageNum: page,
  303. size: limit,
  304. ...where
  305. });
  306. },
  307. // 发布工单
  308. handleOrderPublish(type, row) {
  309. this.$router.push({
  310. path: '/productionPlan/workOrderPublish',
  311. query: {
  312. type,
  313. id: row.id
  314. }
  315. });
  316. },
  317. // 修改计划
  318. planEdit({ id }) {
  319. this.$router.push({
  320. path: '/saleOrder/salesToProduction',
  321. query: {
  322. type: 'edit',
  323. id
  324. }
  325. });
  326. },
  327. handleTabChange() {
  328. this.$refs.searchRef.reset();
  329. },
  330. /* 刷新表格 */
  331. reload(where) {
  332. this.$nextTick(() => {
  333. this.$refs.table.reload({ page: 1, where });
  334. });
  335. },
  336. goDetail({ id }) {
  337. this.$router.push({
  338. path: '/productionPlan/detail/' + id
  339. });
  340. },
  341. handleDelete({ id }) {
  342. this.$confirm('确定删除当前数据?', '提示').then(async () => {
  343. await del(id);
  344. this.$message.success('删除成功!');
  345. this.reload();
  346. });
  347. }
  348. }
  349. };
  350. </script>
  351. <style lang="scss" scoped></style>