usePlan.vue 5.8 KB

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