index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <!-- 搜索表单 -->
  5. <user-search @search="reload" />
  6. <!-- 数据表格 -->
  7. <ele-pro-table ref="table"
  8. :columns="columns"
  9. :datasource="datasource"
  10. :selection.sync="selection"
  11. row-key="id"
  12. :page-size="this.$store.state.tablePageSize"
  13. @columns-change="handleColumnChange"
  14. :cache-key="cacheKeyUrl"
  15. >
  16. <!-- 表头工具栏 -->
  17. <template v-slot:toolbar>
  18. <el-button size="small" type="primary" icon="el-icon-plus" class="ele-btn-icon"
  19. @click="openEdit(null)">新增</el-button>
  20. <el-button size="small" type="primary" icon="el-icon-refresh-left" class="ele-btn-icon" :loading="loading"
  21. @click="toRefresh()">
  22. 刷新
  23. </el-button>
  24. </template>
  25. <!-- 状态列 -->
  26. <!-- <template v-slot:status="{ row }">
  27. {{ checkStatus(row) }}
  28. </template> -->
  29. <!-- 操作列 -->
  30. <template v-slot:action="{ row }">
  31. <el-link type="primary" :underline="false" icon="el-icon-edit" @click="openEdit(row)">
  32. 修改
  33. </el-link>
  34. <el-link type="primary" :underline="false" @click="btnView(row)">
  35. 查看
  36. </el-link>
  37. <el-popconfirm class="ele-action" title="确定要删除此版本吗?" @confirm="remove(row)">
  38. <template v-slot:reference>
  39. <el-link type="danger" :underline="false" icon="el-icon-delete">
  40. 删除
  41. </el-link>
  42. </template>
  43. </el-popconfirm>
  44. </template>
  45. </ele-pro-table>
  46. </el-card>
  47. <!-- 编辑弹窗 -->
  48. <user-edit :visible.sync="showEdit" :data="current" @done="reload" ref="userEdit" />
  49. </div>
  50. </template>
  51. <script>
  52. import tabMixins from '@/mixins/tableColumnsMixin';
  53. import UserSearch from './components/user-search.vue';
  54. import UserEdit from './components/user-edit.vue';
  55. import { pageList, syncVersion, removeItem } from '@/api/technology/version/version.js';
  56. export default {
  57. name: 'technologyVersion',
  58. mixins: [tabMixins],
  59. components: {
  60. UserSearch,
  61. UserEdit
  62. },
  63. data() {
  64. return {
  65. // 表格列配置
  66. columns: [
  67. {
  68. columnKey: 'index',
  69. label: '序号',
  70. type: 'index',
  71. width: 55,
  72. align: 'center',
  73. showOverflowTooltip: true,
  74. fixed: 'left'
  75. },
  76. {
  77. align: 'center',
  78. prop: 'code',
  79. label: '工艺类型编码',
  80. showOverflowTooltip: true,
  81. minWidth: 110
  82. },
  83. {
  84. prop: 'name',
  85. label: '工艺类型名称',
  86. align: 'center',
  87. showOverflowTooltip: true,
  88. minWidth: 110
  89. },
  90. {
  91. align: 'center',
  92. prop: 'version',
  93. label: '版本号',
  94. showOverflowTooltip: true,
  95. minWidth: 110
  96. },
  97. {
  98. align: 'center',
  99. prop: 'createTime',
  100. label: '创建时间',
  101. showOverflowTooltip: true,
  102. minWidth: 110
  103. },
  104. {
  105. columnKey: 'action',
  106. label: '操作',
  107. width: 220,
  108. align: 'center',
  109. resizable: false,
  110. slot: 'action',
  111. showOverflowTooltip: true
  112. }
  113. ],
  114. // 表格选中数据
  115. selection: [],
  116. // 当前编辑数据
  117. current: null,
  118. // 是否显示编辑弹窗
  119. showEdit: false,
  120. // 是否显示导入弹窗
  121. showImport: false,
  122. statusList: [
  123. { label: '草稿', value: -1 },
  124. { label: '失效', value: 0 },
  125. { label: '生效', value: 1 }
  126. ],
  127. loading: false,
  128. cacheKeyUrl:"a864b0cd-technology-version"
  129. };
  130. },
  131. methods: {
  132. /* 表格数据源 */
  133. datasource({ page, limit, where, order }) {
  134. return pageList({ pageNum: page, size: limit, ...where });
  135. },
  136. // async datasource({ page, limit, where, order }) {
  137. // const res = await pageList({
  138. // ...where,
  139. // ...order,
  140. // pageNum: page,
  141. // size: limit
  142. // });
  143. // return res;
  144. // },
  145. /* 点击刷新 */
  146. toRefresh() {
  147. this.loading = true;
  148. syncVersion().then(res => {
  149. if (res == '0') {
  150. this.loading = false;
  151. this.$message.success('数据刷新成功!')
  152. this.reload()
  153. }
  154. })
  155. .catch((e) => {
  156. this.loading = false;
  157. });
  158. },
  159. /* 刷新表格 */
  160. reload(where) {
  161. this.$refs.table.reload({ page: 1, where: where });
  162. },
  163. /* 打开编辑弹窗 */
  164. openEdit(row) {
  165. this.current = row;
  166. this.showEdit = true;
  167. this.$refs.userEdit.$refs.form &&
  168. this.$refs.userEdit.$refs.form.clearValidate();
  169. },
  170. /* 查看详情 */
  171. btnView({ id }) {
  172. this.$router.push({
  173. path: '/technology/version/details',
  174. query: { id }
  175. })
  176. },
  177. /* 删除 */
  178. remove (row) {
  179. const loading = this.$loading({ lock: true });
  180. removeItem([row.id ]).then((msg) => {
  181. loading.close();
  182. this.$message.success(msg);
  183. this.reload();
  184. });
  185. },
  186. }
  187. };
  188. </script>