index.vue 5.4 KB

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