code-list.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <div>
  3. <!-- 数据表格 -->
  4. <ele-pro-table
  5. ref="table"
  6. :columns="columns"
  7. :datasource="datasource"
  8. height="calc(100vh - 265px)"
  9. full-height="calc(100vh - 116px)"
  10. tool-class="ele-toolbar-form"
  11. :page-size="pageSize"
  12. @columns-change="handleColumnChange"
  13. :cache-key="cacheKeyUrl"
  14. >
  15. <!-- 表头工具栏 -->
  16. <template v-slot:toolbar>
  17. <code-search @search="reload">
  18. <el-button
  19. size="small"
  20. type="primary"
  21. icon="el-icon-plus"
  22. class="ele-btn-icon"
  23. @click="openEdit()"
  24. >
  25. 添加
  26. </el-button>
  27. </code-search>
  28. </template>
  29. <!-- 操作列 -->
  30. <template v-slot:action="{ row }">
  31. <el-link
  32. type="primary"
  33. :underline="false"
  34. icon="el-icon-edit"
  35. @click="openEdit(row)"
  36. >
  37. 编辑
  38. </el-link>
  39. <el-popconfirm
  40. class="ele-action"
  41. title="确定要删除此用户吗?"
  42. @confirm="remove(row)"
  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. <!-- 编辑弹窗 -->
  53. <addDialog ref="addDialog" @done="reload"></addDialog>
  54. </div>
  55. </template>
  56. <script>
  57. import tabMixins from '@/mixins/tableColumnsMixin';
  58. import CodeSearch from './code-search.vue';
  59. import addDialog from './addDialog.vue';
  60. import { getCodeList, removeCodeInfo } from '@/api/codeManagement/index';
  61. export default {
  62. mixins: [tabMixins],
  63. components: { CodeSearch, addDialog },
  64. props: {
  65. // 机构id
  66. organizationId: [Number, String],
  67. // 全部机构
  68. organizationList: Array
  69. },
  70. data() {
  71. return {
  72. // 表格列配置
  73. columns: [
  74. {
  75. columnKey: 'index',
  76. type: 'index',
  77. width: 45,
  78. align: 'center',
  79. showOverflowTooltip: true,
  80. fixed: 'left'
  81. },
  82. {
  83. prop: 'code',
  84. label: '编码',
  85. // sortable: 'custom',
  86. showOverflowTooltip: true,
  87. minWidth: 110
  88. },
  89. {
  90. prop: 'name',
  91. label: '名称',
  92. // sortable: 'custom',
  93. showOverflowTooltip: true,
  94. minWidth: 110
  95. },
  96. {
  97. prop: 'remark',
  98. label: '描述',
  99. align: 'left',
  100. // sortable: 'custom',
  101. minWidth: 200,
  102. showOverflowTooltip: true
  103. },
  104. {
  105. prop: 'enable',
  106. align: 'center',
  107. label: '是否启用',
  108. showOverflowTooltip: true,
  109. formatter: (row, column) => {
  110. return row.enable === 0
  111. ? '停用'
  112. : row.enable === 1
  113. ? '启用'
  114. : '';
  115. }
  116. },
  117. {
  118. prop: 'createTime',
  119. label: '创建时间',
  120. align: 'left',
  121. sortable: 'custom',
  122. width: 160,
  123. showOverflowTooltip: true
  124. },
  125. {
  126. columnKey: 'action',
  127. label: '操作',
  128. width: 130,
  129. align: 'center',
  130. resizable: false,
  131. slot: 'action',
  132. showOverflowTooltip: true
  133. }
  134. ],
  135. // 当前编辑数据
  136. current: null,
  137. // 是否显示编辑弹窗
  138. showEdit: false,
  139. pageSize: this.$store.state.tablePageSize,
  140. cacheKeyUrl: '4267221d-codeManagement'
  141. };
  142. },
  143. methods: {
  144. /* 表格数据源 */
  145. datasource({ page, limit, where, order }) {
  146. return getCodeList({
  147. ...where,
  148. ...order,
  149. pageNum: page,
  150. size: limit
  151. // groupId: 1
  152. });
  153. },
  154. /* 刷新表格 */
  155. reload(where) {
  156. this.$refs.table.reload({ pageNum: 1, where: where });
  157. },
  158. /* 显示编辑 */
  159. openEdit(row) {
  160. if (row) {
  161. this.$refs.addDialog.open('edit', row);
  162. } else {
  163. this.$refs.addDialog.open('add');
  164. }
  165. },
  166. /* 删除 */
  167. remove(row) {
  168. const loading = this.$loading({ lock: true });
  169. removeCodeInfo([row.id])
  170. .then((msg) => {
  171. loading.close();
  172. this.$message.success(msg);
  173. this.reload();
  174. })
  175. .catch((e) => {
  176. loading.close();
  177. // this.$message.error(e.message);
  178. });
  179. }
  180. },
  181. watch: {
  182. // 监听机构id变化
  183. // organizationId() {
  184. // this.reload();
  185. // }
  186. }
  187. };
  188. </script>