| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- <template>
- <div>
- <!-- 数据表格 -->
- <ele-pro-table
- ref="table"
- :columns="columns"
- :datasource="datasource"
- height="calc(100vh - 265px)"
- full-height="calc(100vh - 116px)"
- tool-class="ele-toolbar-form"
- :page-size="pageSize"
- @columns-change="handleColumnChange"
- :cache-key="cacheKeyUrl"
- >
- <!-- 表头工具栏 -->
- <template v-slot:toolbar>
- <code-search @search="reload">
- <el-button
- size="small"
- type="primary"
- icon="el-icon-plus"
- class="ele-btn-icon"
- @click="openEdit()"
- >
- 添加
- </el-button>
- </code-search>
- </template>
- <!-- 操作列 -->
- <template v-slot:action="{ row }">
- <el-link
- type="primary"
- :underline="false"
- icon="el-icon-edit"
- @click="openEdit(row)"
- >
- 编辑
- </el-link>
- <el-popconfirm
- class="ele-action"
- title="确定要删除此用户吗?"
- @confirm="remove(row)"
- >
- <template v-slot:reference>
- <el-link type="danger" :underline="false" icon="el-icon-delete">
- 删除
- </el-link>
- </template>
- </el-popconfirm>
- </template>
- </ele-pro-table>
- <!-- 编辑弹窗 -->
- <addDialog ref="addDialog" @done="reload"></addDialog>
- </div>
- </template>
- <script>
- import tabMixins from '@/mixins/tableColumnsMixin';
- import CodeSearch from './code-search.vue';
- import addDialog from './addDialog.vue';
- import { getCodeList, removeCodeInfo } from '@/api/codeManagement/index';
- export default {
- mixins: [tabMixins],
- components: { CodeSearch, addDialog },
- props: {
- // 机构id
- organizationId: [Number, String],
- // 全部机构
- organizationList: Array
- },
- data() {
- return {
- // 表格列配置
- columns: [
- {
- columnKey: 'index',
- type: 'index',
- width: 45,
- align: 'center',
- showOverflowTooltip: true,
- fixed: 'left'
- },
- {
- prop: 'code',
- label: '编码',
- // sortable: 'custom',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'name',
- label: '名称',
- // sortable: 'custom',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'remark',
- label: '描述',
- align: 'left',
- // sortable: 'custom',
- minWidth: 200,
- showOverflowTooltip: true
- },
- {
- prop: 'enable',
- align: 'center',
- label: '是否启用',
- showOverflowTooltip: true,
- formatter: (row, column) => {
- return row.enable === 0
- ? '停用'
- : row.enable === 1
- ? '启用'
- : '';
- }
- },
-
- {
- prop: 'createTime',
- label: '创建时间',
- align: 'left',
- sortable: 'custom',
- width: 160,
- showOverflowTooltip: true
- },
- {
- columnKey: 'action',
- label: '操作',
- width: 130,
- align: 'center',
- resizable: false,
- slot: 'action',
- showOverflowTooltip: true
- }
- ],
- // 当前编辑数据
- current: null,
- // 是否显示编辑弹窗
- showEdit: false,
- pageSize: this.$store.state.tablePageSize,
- cacheKeyUrl: '4267221d-codeManagement'
- };
- },
- methods: {
- /* 表格数据源 */
- datasource({ page, limit, where, order }) {
- return getCodeList({
- ...where,
- ...order,
- pageNum: page,
- size: limit
- // groupId: 1
- });
- },
- /* 刷新表格 */
- reload(where) {
- this.$refs.table.reload({ pageNum: 1, where: where });
- },
- /* 显示编辑 */
- openEdit(row) {
- if (row) {
- this.$refs.addDialog.open('edit', row);
- } else {
- this.$refs.addDialog.open('add');
- }
- },
- /* 删除 */
- remove(row) {
- const loading = this.$loading({ lock: true });
- removeCodeInfo([row.id])
- .then((msg) => {
- loading.close();
- this.$message.success(msg);
- this.reload();
- })
- .catch((e) => {
- loading.close();
- // this.$message.error(e.message);
- });
- }
- },
- watch: {
- // 监听机构id变化
- // organizationId() {
- // this.reload();
- // }
- }
- };
- </script>
|