index.vue 10 KB

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