index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. <el-tabs v-model="activeName" type="card">
  7. <el-tab-pane label="采购配料计划" name="first"></el-tab-pane>
  8. <el-tab-pane label="生产配料计划" name="second"></el-tab-pane>
  9. </el-tabs>
  10. <!-- 数据表格 -->
  11. <ele-pro-table ref="table" :key="activeName" :initLoad="false" :columns="columns" :datasource="datasource"
  12. :cache-key="`${activeName}materialPlanTable`">
  13. <template v-slot:toolbar>
  14. <el-button type="primary" @click="handleEdit('add')">创建计划</el-button>
  15. </template>
  16. <template v-slot:status="{ row }">
  17. <span :class="{ 'ele-text-danger': row.status == 3 }">
  18. {{ statusFormatter(row.status) }}
  19. </span>
  20. </template>
  21. <!-- 操作列 -->
  22. <template v-slot:action="{ row }">
  23. <el-link type="primary" :underline="false" icon="el-icon-edit" @click="handleEdit('edit', row)">
  24. 修改计划
  25. </el-link>
  26. <el-link @click="handleDel(row)" type="danger" :underline="false" icon="el-icon-delete">
  27. 删除
  28. </el-link>
  29. </template>
  30. </ele-pro-table>
  31. </el-card>
  32. <planEditDialog ref="planEditDialogRef" @success="reload" />
  33. </div>
  34. </template>
  35. <script>
  36. import materialPlanSearch from './components/materialPlan-search.vue';
  37. import planEditDialog from './components/plan-edit-dialog.vue';
  38. import { getList, del } from '@/api/materialPlan/index';
  39. export default {
  40. components: {
  41. planEditDialog,
  42. materialPlanSearch
  43. },
  44. data() {
  45. return {
  46. activeName: 'first',
  47. // 加载状态
  48. loading: false,
  49. pageType: 'add',
  50. dialogTitle: '',
  51. isBindPlan: false,
  52. statusOpt: {
  53. first: [
  54. { label: '所有状态', value: '3,2' },
  55. { label: '待发布', value: '2' },
  56. { label: '发布失败', value: '3' }
  57. ],
  58. second: [
  59. { label: '所有状态', value: '7,4,5,6' },
  60. { label: '待生产', value: '4' },
  61. { label: '生产中', value: '5' },
  62. { label: '已完成', value: '6' },
  63. { label: '已延期', value: '7' }
  64. ]
  65. }
  66. };
  67. },
  68. computed: {
  69. // 表格列配置
  70. columns() {
  71. return [
  72. {
  73. columnKey: 'index',
  74. label: '序号',
  75. type: 'index',
  76. width: 55,
  77. align: 'center',
  78. fixed: 'left'
  79. },
  80. {
  81. slot: 'name',
  82. prop: 'name',
  83. label: '计划名称',
  84. align: 'center',
  85. },
  86. {
  87. prop: 'code',
  88. label: '计划编号',
  89. align: 'center',
  90. },
  91. {
  92. columnKey: 'status',
  93. label: '状态',
  94. align: 'center',
  95. slot: 'status',
  96. action: 'status'
  97. },
  98. {
  99. prop: 'createUserName',
  100. label: '创建人',
  101. align: 'center'
  102. },
  103. {
  104. prop: 'createTime',
  105. label: '创建时间',
  106. align: 'center',
  107. },
  108. {
  109. columnKey: 'action',
  110. label: '操作',
  111. width: 250,
  112. align: 'center',
  113. resizable: false,
  114. fixed: 'right',
  115. slot: 'action'
  116. }
  117. ];
  118. }
  119. },
  120. methods: {
  121. statusFormatter(status) {
  122. const obj = this.statusOpt[this.activeName].find(
  123. (i) => i.value == status
  124. );
  125. return obj && obj.label;
  126. },
  127. /* 表格数据源 */
  128. datasource({ page, limit, where, order }) {
  129. return getList({
  130. pageNum: page,
  131. size: limit,
  132. ...where
  133. });
  134. },
  135. handleEdit(type, row) {
  136. if (this.activeName == 'first') {
  137. this.$refs.planEditDialogRef.open(type, row);
  138. }
  139. },
  140. handleDel({ id }) {
  141. this.$confirm('确认删除当前数据!', '提示').then(async () => {
  142. await del([id]);
  143. this.$message.success('删除成功!');
  144. this.reload();
  145. });
  146. },
  147. handleTabChange() {
  148. this.$refs.searchRef.reset();
  149. },
  150. /* 刷新表格 */
  151. reload(where = {}) {
  152. where.statusList = this.statusOpt[this.activeName][0].value.split(',');
  153. this.$nextTick(() => {
  154. this.$refs.table.reload({ page: 1, where });
  155. });
  156. },
  157. }
  158. };
  159. </script>
  160. <style lang="scss" scoped></style>