index.vue 10 KB

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