codeList.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <!-- 数据表格 -->
  3. <ele-pro-table
  4. ref="table"
  5. :columns="columns"
  6. :datasource="datasource"
  7. height="calc(100vh - 265px)"
  8. full-height="calc(100vh - 116px)"
  9. tool-class="ele-toolbar-form"
  10. :page-size="pageSize"
  11. @columns-change="handleColumnChange"
  12. :cache-key="cacheKeyUrl"
  13. :selection.sync="selection"
  14. >
  15. <template v-slot:name="{ row }">
  16. <span class="listName">
  17. <img src="../../../assets/code1.png" v-if="row.type == 1" />
  18. <img src="../../../assets/code2.png" v-if="row.type == 2" />
  19. {{ row.name }}
  20. </span>
  21. </template>
  22. <template v-slot:toolbar>
  23. <el-dropdown
  24. trigger="click"
  25. v-if="$hasPermission('mian:businessCode:save')"
  26. >
  27. <el-button type="primary">
  28. 新建<i class="el-icon-arrow-down el-icon--right"></i>
  29. </el-button>
  30. <el-dropdown-menu slot="dropdown">
  31. <el-dropdown-item @click.native="openType('add')"
  32. >新建分类</el-dropdown-item
  33. >
  34. <el-dropdown-item
  35. @click.native="openEdit('add')"
  36. v-if="parentData.parentId != 0"
  37. >新建编码</el-dropdown-item
  38. >
  39. </el-dropdown-menu>
  40. </el-dropdown>
  41. <el-button
  42. type="primary"
  43. @click.native="openEdit('edit')"
  44. :disabled="selection.length != 1"
  45. v-if="$hasPermission('mian:businessCode:update')"
  46. >
  47. 编辑
  48. </el-button>
  49. <el-popconfirm
  50. class="ele-action"
  51. title="确定要删除吗?"
  52. @confirm="remove()"
  53. v-if="$hasPermission('mian:businessCode:delete')"
  54. >
  55. <template v-slot:reference>
  56. <el-button type="danger" :disabled="selection.length == 0">
  57. 删除
  58. </el-button>
  59. </template>
  60. </el-popconfirm>
  61. <!-- <el-button type="primary"> 启用 </el-button>
  62. <el-button type="primary"> 停用 </el-button> -->
  63. </template>
  64. <TypeEdit
  65. ref="typeEditRef"
  66. :parentId="parentData.id"
  67. @done="done"
  68. ></TypeEdit>
  69. <codeEdit
  70. ref="codeEditRef"
  71. :parentId="parentData.id"
  72. @done="done"
  73. ></codeEdit>
  74. </ele-pro-table>
  75. </template>
  76. <script>
  77. import tabMixins from '@/mixins/tableColumnsMixin';
  78. import codeEdit from './components/codeEdit.vue';
  79. import TypeEdit from './components/typeEdit.vue';
  80. import { listParentId, removeCode } from '@/api/businessCode';
  81. export default {
  82. mixins: [tabMixins],
  83. components: {
  84. codeEdit,
  85. TypeEdit
  86. },
  87. props: {
  88. // 上级
  89. parentData: {
  90. type: Object,
  91. default: () => {}
  92. }
  93. },
  94. data() {
  95. return {
  96. selection: [],
  97. // 表格列配置
  98. columns: [
  99. {
  100. width: 45,
  101. type: 'selection',
  102. columnKey: 'selection',
  103. align: 'center'
  104. // selectable: (row, index) => {
  105. // return !this.disabledTableList
  106. // .map((item) => item.id)
  107. // .includes(row.id);
  108. // }
  109. },
  110. {
  111. label: '名称',
  112. prop: 'name',
  113. align: 'center',
  114. showOverflowTooltip: true,
  115. fixed: 'left',
  116. slot: 'name'
  117. },
  118. {
  119. prop: 'remark',
  120. label: '描述',
  121. align: 'center',
  122. showOverflowTooltip: true
  123. },
  124. {
  125. prop: 'createUserName',
  126. label: '创建人',
  127. align: 'center',
  128. showOverflowTooltip: true
  129. },
  130. {
  131. prop: 'createTime',
  132. label: '创建时间',
  133. align: 'center',
  134. showOverflowTooltip: true
  135. },
  136. {
  137. prop: 'updateUserName',
  138. label: '修改人',
  139. align: 'center',
  140. showOverflowTooltip: true
  141. },
  142. {
  143. prop: 'updateTime',
  144. label: '修改时间',
  145. align: 'center',
  146. showOverflowTooltip: true
  147. },
  148. {
  149. prop: '',
  150. label: '状态',
  151. align: 'center',
  152. showOverflowTooltip: true,
  153. minWidth: 100,
  154. formatter: (_row, _column, cellValue) => {
  155. return this.$util.toDateString(cellValue);
  156. }
  157. }
  158. ],
  159. // 是否显示编辑弹窗
  160. showEditFlag: false,
  161. pageSize: this.$store.state.tablePageSize,
  162. cacheKeyUrl: 'ad4181af-codeManagement-businessCode'
  163. };
  164. },
  165. created() {},
  166. methods: {
  167. /* 表格数据源 */
  168. datasource({ page, limit, where, order }) {
  169. return listParentId({
  170. ...where,
  171. pageNum: page,
  172. size: limit,
  173. parentId: this.parentData?.id
  174. });
  175. },
  176. /* 刷新表格 */
  177. reload(where) {
  178. this.$nextTick(() => {
  179. this.$refs.table.reload({ pageNum: 1, where: where });
  180. });
  181. },
  182. /* 显示编辑 */
  183. openEdit(type, row = '') {
  184. if (type == 'edit' && this.selection[0].type == 1) {
  185. this.openType(type, this.selection[0]);
  186. return;
  187. }
  188. this.$refs.codeEditRef.open(type, this.selection[0]);
  189. },
  190. openType(type, row = '') {
  191. this.$refs.typeEditRef.open(type, row);
  192. },
  193. // async success(current) {
  194. // await this.reload();
  195. // this.current = current;
  196. // this.$nextTick(() => {
  197. // this.$refs.PowerRef &&
  198. // this.$refs.PowerRef.setTableList(this.current.userAuthority);
  199. // });
  200. // },
  201. /* 删除 */
  202. remove(row) {
  203. removeCode(this.selection.map((item) => item.id))
  204. .then((msg) => {
  205. this.$message.success('操作成功');
  206. this.$emit('done', this.parentData);
  207. })
  208. .catch((e) => {
  209. // this.$message.error(e.message);
  210. });
  211. },
  212. done() {
  213. this.$emit('done', this.parentData);
  214. },
  215. getTableList() {
  216. return JSON.parse(JSON.stringify(this.selection));
  217. }
  218. }
  219. };
  220. </script>
  221. <style lang="scss" scoped>
  222. .listName {
  223. display: flex;
  224. align-items: center;
  225. justify-content: center;
  226. img {
  227. margin-right: 3px;
  228. }
  229. }
  230. </style>