index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <!-- 让步接收列表 -->
  2. <template>
  3. <div class="ele-body">
  4. <el-card shadow="never" v-loading="loading">
  5. <order-search @search="reload" ref="searchRef"> </order-search>
  6. <ele-pro-table
  7. ref="table"
  8. :columns="columns"
  9. :datasource="datasource"
  10. :selection.sync="selection"
  11. :page-size="20"
  12. @columns-change="handleColumnChange"
  13. :cache-key="cacheKeyUrl"
  14. row-key="id"
  15. >
  16. <!-- 表头工具栏 -->
  17. <template v-slot:toolbar>
  18. <el-button
  19. size="small"
  20. type="primary"
  21. icon="el-icon-plus"
  22. class="ele-btn-icon"
  23. @click="openEdit('add')"
  24. v-if="$hasPermission('qms:badname:save')"
  25. >
  26. 新增
  27. </el-button>
  28. </template>
  29. <template v-slot:action="{ row }">
  30. <el-link
  31. type="primary"
  32. :underline="false"
  33. @click="openEdit('edit', row)"
  34. v-if="$hasPermission('qms:badname:update')"
  35. >
  36. 修改
  37. </el-link>
  38. <el-popconfirm
  39. class="ele-action"
  40. title="确定要删除吗?"
  41. @confirm="remove(row)"
  42. v-if="$hasPermission('qms:badname:delete')"
  43. >
  44. <template v-slot:reference>
  45. <el-link type="danger" :underline="false" icon="el-icon-delete">
  46. 删除
  47. </el-link>
  48. </template>
  49. </el-popconfirm>
  50. </template>
  51. </ele-pro-table>
  52. </el-card>
  53. <edit ref="editRef" @done="reload"></edit>
  54. </div>
  55. </template>
  56. <script>
  57. import OrderSearch from './components/order-search.vue';
  58. import edit from './components/edit.vue';
  59. import tabMixins from '@/mixins/tableColumnsMixin';
  60. import { getList, deleteList } from '@/api/unacceptedProduct/unqualifiedName';
  61. export default {
  62. components: {
  63. OrderSearch,
  64. edit
  65. },
  66. mixins: [tabMixins],
  67. data() {
  68. return {
  69. cacheKeyUrl: 'qms-c2e9664a-unqualifiedName-index',
  70. loading: false,
  71. selection: []
  72. };
  73. },
  74. computed: {
  75. // 表格列配置
  76. columns() {
  77. return [
  78. {
  79. columnKey: 'index',
  80. label: '序号',
  81. type: 'index',
  82. width: 55,
  83. align: 'center',
  84. showOverflowTooltip: true,
  85. fixed: 'left'
  86. },
  87. {
  88. prop: 'code',
  89. label: '不良代码',
  90. align: 'center',
  91. showOverflowTooltip: true
  92. },
  93. {
  94. prop: 'name',
  95. label: '不良名称',
  96. align: 'center',
  97. showOverflowTooltip: true
  98. },
  99. {
  100. prop: 'badTypeName',
  101. label: '不良类型名称',
  102. align: 'center',
  103. showOverflowTooltip: true
  104. },
  105. {
  106. prop: 'badTypeCode',
  107. label: '不良类型编码',
  108. align: 'center',
  109. showOverflowTooltip: true
  110. },
  111. {
  112. prop: 'status',
  113. label: '启用状态',
  114. align: 'center',
  115. showOverflowTooltip: true,
  116. formatter: (_row, _column, cellValue) => {
  117. return cellValue == 1 ? '启用' : '禁用';
  118. }
  119. },
  120. {
  121. prop: 'remark',
  122. label: '备注',
  123. align: 'center',
  124. showOverflowTooltip: true
  125. },
  126. {
  127. prop: 'createUserName',
  128. label: '创建人',
  129. align: 'center'
  130. },
  131. {
  132. prop: 'createTime',
  133. label: '创建时间',
  134. align: 'center'
  135. },
  136. {
  137. columnKey: 'action',
  138. label: '操作',
  139. width: 150,
  140. align: 'center',
  141. resizable: false,
  142. fixed: 'right',
  143. slot: 'action',
  144. showOverflowTooltip: true
  145. }
  146. ];
  147. }
  148. },
  149. created() {},
  150. filters: {},
  151. methods: {
  152. /* 表格数据源 */
  153. datasource({ page, limit, where }) {
  154. return getList({
  155. pageNum: page,
  156. size: limit,
  157. ...where
  158. });
  159. },
  160. remove(row) {
  161. let ids = row ? [row.id] : this.selection.map((item) => item.id);
  162. deleteList(ids).then((res) => {
  163. this.$message.success('删除' + res);
  164. this.reload();
  165. });
  166. },
  167. openEdit(type, row = {}) {
  168. this.$refs.editRef.open(row, type);
  169. },
  170. /* 刷新表格 */
  171. reload(where) {
  172. this.$nextTick(() => {
  173. this.$refs.table.reload({ page: 1, where });
  174. });
  175. }
  176. }
  177. };
  178. </script>
  179. <style lang="scss" scoped></style>