index.vue 9.4 KB

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