pickPlan.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. @columns-change="handleColumnChange"
  18. :cacheKey="cacheKeyUrl"
  19. >
  20. <template v-slot:toolbar>
  21. <el-button type="primary" @click="handleEdit('add')"
  22. >创建计划</el-button
  23. >
  24. </template>
  25. <template v-slot:name="{ row }">
  26. <el-link
  27. type="primary"
  28. :underline="false"
  29. @click="openEdit('detail', row)"
  30. >{{ row.name }}</el-link
  31. >
  32. </template>
  33. <template v-slot:status="{ row }">
  34. <span :class="{ 'ele-text-danger': row.status == 3 }">
  35. {{ statusFormatter(row.status) }}
  36. </span>
  37. </template>
  38. <!-- 操作列 -->
  39. <template v-slot:action="{ row }">
  40. <el-link
  41. type="primary"
  42. :underline="false"
  43. icon="el-icon-edit"
  44. @click="handleEdit('edit', row)"
  45. >
  46. 修改计划
  47. </el-link>
  48. <el-link
  49. @click="handleDel(row)"
  50. type="danger"
  51. :underline="false"
  52. icon="el-icon-delete"
  53. >
  54. 删除
  55. </el-link>
  56. </template>
  57. </ele-pro-table>
  58. </el-card>
  59. <produceEditDialog
  60. ref="produceEditDialogRef"
  61. @success="reload"
  62. ></produceEditDialog>
  63. </div>
  64. </template>
  65. <script>
  66. import materialPlanSearch from './components/materialPlan-search.vue';
  67. import produceEditDialog from './components/produce-edit-dialog';
  68. import { getList, del } from '@/api/materialPlan/index';
  69. import tabMixins from '@/mixins/tableColumnsMixin';
  70. export default {
  71. components: {
  72. produceEditDialog,
  73. materialPlanSearch
  74. },
  75. mixins: [tabMixins],
  76. data() {
  77. return {
  78. activeName: 'second',
  79. cacheKeyUrl: 'c32a9c7d-aps-cuttingPlan-index',
  80. columnsVersion: 1,
  81. // 加载状态
  82. loading: false,
  83. statusOpt: {
  84. second: [
  85. { label: '所有状态', value: null },
  86. { label: '待排产', value: '1' },
  87. { label: '待发布', value: '2' },
  88. { label: '发布失败', value: '3' },
  89. { label: '已完成', value: '6' }
  90. ]
  91. }
  92. };
  93. },
  94. computed: {
  95. // 表格列配置
  96. columns() {
  97. let num = this.columnsVersion;
  98. return [
  99. {
  100. columnKey: 'index',
  101. label: '序号',
  102. type: 'index',
  103. width: 55,
  104. align: 'center',
  105. fixed: 'left'
  106. },
  107. {
  108. slot: 'name',
  109. prop: 'name',
  110. label: '领料名称',
  111. align: 'center',
  112. showOverflowTooltip: true
  113. },
  114. {
  115. prop: 'code',
  116. label: '领料编号',
  117. align: 'center',
  118. showOverflowTooltip: true
  119. },
  120. {
  121. columnKey: 'status',
  122. label: '状态',
  123. align: 'center',
  124. slot: 'status',
  125. action: 'status',
  126. showOverflowTooltip: true
  127. },
  128. {
  129. prop: 'createUserName',
  130. label: '创建人',
  131. align: 'center',
  132. showOverflowTooltip: true
  133. },
  134. {
  135. prop: 'createTime',
  136. label: '创建时间',
  137. align: 'center',
  138. showOverflowTooltip: true
  139. },
  140. {
  141. columnKey: 'action',
  142. label: '操作',
  143. width: 250,
  144. align: 'center',
  145. resizable: false,
  146. fixed: 'right',
  147. slot: 'action'
  148. }
  149. ];
  150. }
  151. },
  152. methods: {
  153. statusFormatter(status) {
  154. const obj = this.statusOpt[this.activeName].find(
  155. (i) => i.value == status
  156. );
  157. return obj && obj.label;
  158. },
  159. /* 表格数据源 */
  160. datasource({ page, limit, where }) {
  161. where.type = 2;
  162. // delete where.statusList;
  163. return getList({
  164. pageNum: page,
  165. size: limit,
  166. ...where
  167. });
  168. },
  169. handleEdit(type, row) {
  170. this.$refs.produceEditDialogRef.open(type, row);
  171. },
  172. handleDel({ id }) {
  173. this.$confirm('确认删除当前数据!', '提示').then(async () => {
  174. await del([id]);
  175. this.$message.success('删除成功!');
  176. this.reload();
  177. });
  178. },
  179. handleTabChange() {
  180. this.$refs.searchRef.reset();
  181. },
  182. openEdit(type, row) {
  183. this.$refs.produceEditDialogRef.open(type, row);
  184. },
  185. /* 刷新表格 */
  186. reload(where = {}) {
  187. if (where.statusList) {
  188. where.statusList = where.statusList.split(',');
  189. }
  190. this.$nextTick(() => {
  191. this.$refs.table.reload({ page: 1, where });
  192. });
  193. }
  194. }
  195. };
  196. </script>
  197. <style lang="scss" scoped></style>