index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <materialPlan-search
  5. @search="reload"
  6. :statusOpt="statusOpt"
  7. :activeName="activeName"
  8. ref="searchRef"
  9. >
  10. </materialPlan-search>
  11. <!-- 数据表格 -->
  12. <ele-pro-table
  13. ref="table"
  14. :initLoad="false"
  15. :columns="columns"
  16. :datasource="datasource"
  17. cache-key="`materialPlanTable`"
  18. >
  19. <template v-slot:toolbar>
  20. <el-dropdown trigger="click" @command="handleClick">
  21. <el-link type="primary" icon="el-icon-plus">创建采购计划</el-link>
  22. <el-dropdown-menu slot="dropdown">
  23. <el-dropdown-item command="1">来源销售订单</el-dropdown-item>
  24. <el-dropdown-item command="2">来源生产计划</el-dropdown-item>
  25. </el-dropdown-menu>
  26. </el-dropdown>
  27. </template>
  28. <template v-slot:status="{ row }">
  29. <span :class="{ 'ele-text-danger': row.status == 3 }">
  30. {{ statusFormatter(row.status) }}
  31. </span>
  32. </template>
  33. <template v-slot:orderType="{ row }">
  34. <span>
  35. {{
  36. row.orderType == 1
  37. ? '销售订单'
  38. : row.orderType == 2
  39. ? '生产计划'
  40. : ''
  41. }}
  42. </span>
  43. </template>
  44. <template v-slot:approvalStatus="{ row }">
  45. <el-link
  46. type="primary"
  47. :underline="false"
  48. @click="handleDetails(row)"
  49. >
  50. {{ approvalStatusFormatter(row.approvalStatus) }}
  51. </el-link>
  52. </template>
  53. <!-- 操作列 -->
  54. <template v-slot:action="{ row }">
  55. <el-link
  56. type="primary"
  57. :underline="false"
  58. icon="el-icon-edit"
  59. @click="handleEdit('edit', row)"
  60. >
  61. 修改计划
  62. </el-link>
  63. <el-link
  64. @click="handleDel(row)"
  65. type="danger"
  66. :underline="false"
  67. icon="el-icon-delete"
  68. >
  69. 删除
  70. </el-link>
  71. <el-link
  72. type="primary"
  73. :underline="false"
  74. @click="todo(row)"
  75. v-if="row.approvalStatus == 0 || row.approvalStatus == 3"
  76. >
  77. 提交
  78. </el-link>
  79. </template>
  80. </ele-pro-table>
  81. </el-card>
  82. <planEditDialog ref="planEditDialogRef" @success="reload" />
  83. <producePlan ref="produceRef" @success="reload"></producePlan>
  84. <detail ref="detailRef"></detail>
  85. </div>
  86. </template>
  87. <script>
  88. import materialPlanSearch from './components/materialPlan-search.vue';
  89. import planEditDialog from './components/plan-edit-dialog.vue';
  90. import producePlan from './components/producePlan.vue';
  91. import detail from './components/detail.vue';
  92. import { getList, del, submit } from '@/api/materialPlan/index';
  93. export default {
  94. components: {
  95. planEditDialog,
  96. materialPlanSearch,
  97. detail,
  98. producePlan
  99. },
  100. data() {
  101. return {
  102. activeName: 'first',
  103. // 加载状态
  104. loading: false,
  105. statusOpt: {
  106. first: [
  107. { label: '所有状态', value: null },
  108. { label: '待排产', value: '1' },
  109. { label: '待发布', value: '2' },
  110. { label: '发布失败', value: '3' },
  111. { label: '已完成', value: '6' }
  112. ]
  113. },
  114. approvalStatusOpt: {
  115. first: [
  116. { label: '未提交', value: '0' },
  117. { label: '审核中', value: '1' },
  118. { label: '审核通过', value: '2' },
  119. { label: '审核未通过', value: '3' }
  120. ]
  121. }
  122. };
  123. },
  124. computed: {
  125. // 表格列配置
  126. columns() {
  127. return [
  128. {
  129. columnKey: 'index',
  130. label: '序号',
  131. type: 'index',
  132. width: 55,
  133. align: 'center',
  134. fixed: 'left'
  135. },
  136. {
  137. slot: 'name',
  138. prop: 'name',
  139. label: '计划名称',
  140. align: 'center'
  141. },
  142. {
  143. prop: 'code',
  144. label: '计划编号',
  145. align: 'center'
  146. },
  147. {
  148. prop: 'planStr',
  149. label: '生产计划编码',
  150. align: 'center',
  151. showOverflowTooltip: true
  152. },
  153. {
  154. prop: 'orderStr',
  155. label: '销售订单号',
  156. align: 'center',
  157. showOverflowTooltip: true
  158. },
  159. {
  160. prop: 'serialNoStr',
  161. label: '客户代号',
  162. align: 'center',
  163. showOverflowTooltip: true
  164. },
  165. {
  166. columnKey: 'status',
  167. label: '状态',
  168. align: 'center',
  169. slot: 'status',
  170. action: 'status'
  171. },
  172. {
  173. prop: 'approvalStatus',
  174. label: '审批状态',
  175. align: 'center',
  176. slot: 'approvalStatus',
  177. action: 'approvalStatus'
  178. },
  179. {
  180. prop: 'orderType',
  181. label: '来源类型',
  182. align: 'center',
  183. slot: 'orderType',
  184. action: 'orderType'
  185. },
  186. {
  187. prop: 'createUserName',
  188. label: '创建人',
  189. align: 'center'
  190. },
  191. {
  192. prop: 'createTime',
  193. label: '创建时间',
  194. align: 'center'
  195. },
  196. {
  197. columnKey: 'action',
  198. label: '操作',
  199. width: 250,
  200. align: 'center',
  201. resizable: false,
  202. fixed: 'right',
  203. slot: 'action'
  204. }
  205. ];
  206. }
  207. },
  208. methods: {
  209. statusFormatter(status) {
  210. const obj = this.statusOpt[this.activeName].find(
  211. (i) => i.value == status
  212. );
  213. return obj && obj.label;
  214. },
  215. approvalStatusFormatter(status) {
  216. const obj = this.approvalStatusOpt[this.activeName].find(
  217. (i) => i.value == status
  218. );
  219. return obj && obj.label;
  220. },
  221. /* 表格数据源 */
  222. datasource({ page, limit, where }) {
  223. where.type = 1;
  224. return getList({
  225. pageNum: page,
  226. size: limit,
  227. ...where
  228. });
  229. },
  230. handleEdit(type, row) {
  231. if (row.orderType == 1) {
  232. this.$refs.planEditDialogRef.open(type, row);
  233. } else if (row.orderType == 2) {
  234. this.$refs.produceRef.open(type, row);
  235. }
  236. },
  237. handleDel({ id }) {
  238. this.$confirm('确认删除当前数据!', '提示').then(async () => {
  239. await del([id]);
  240. this.$message.success('删除成功!');
  241. this.reload();
  242. });
  243. },
  244. handleClick(tab) {
  245. if (tab == 1) {
  246. this.$refs.planEditDialogRef.open('add');
  247. } else if (tab == 2) {
  248. this.$refs.produceRef.open('add');
  249. }
  250. },
  251. todo(row) {
  252. submit({ businessId: row.id }).then((res) => {
  253. if (res) {
  254. this.$message.success('提交成功!');
  255. this.reload();
  256. }
  257. });
  258. },
  259. handleTabChange() {
  260. this.$refs.searchRef.reset();
  261. },
  262. /* 刷新表格 */
  263. reload(where = {}) {
  264. if (where.statusList) {
  265. console.log(where.statusList);
  266. where.statusList = where.statusList.split(',');
  267. }
  268. console.log(44444);
  269. this.$nextTick(() => {
  270. this.$refs.table.reload({ page: 1, where });
  271. });
  272. },
  273. handleDetails(row) {
  274. if (row.approvalStatus == 0) {
  275. this.$message.info('未提交没有审核流程');
  276. } else {
  277. this.$refs.detailRef.open(row.processInstanceId);
  278. }
  279. }
  280. }
  281. };
  282. </script>
  283. <style lang="scss" scoped></style>