<template>
|
<div class="fa-card-a" shadow="never">
|
<div class="mod-sys__dict">
|
<el-row :gutter="20">
|
<el-col :span="11">
|
<div class="">
|
<zt-table-wraper ref="typeTable" v-slot="{ table }" :paging='false'
|
delete-url="/sys/dict/type"
|
query-url="/sys/dict/type/tree">
|
<el-form :inline="true" :model="dataForm" @keyup.enter.native="table.query()">
|
<el-form-item>
|
<zt-button perm="sys:dict" type="add" @click="table.editHandle()"/>
|
</el-form-item>
|
</el-form>
|
<zt-button type='self' icon2="el-icon-upload2" @click="DictImport">导入</zt-button>
|
|
<el-table ref="table" v-adaptive="{bottomOffset:30}" v-loading="table.dataLoading"
|
:data="table.dataList" border
|
height="100px" highlight-current-row
|
row-key="id" @current-change="handleCurrentChange"
|
@selection-change="table.selectionChangeHandle"
|
:cell-style="dictNameleft"
|
@sort-change="table.sortChangeHandle">
|
<el-table-column :label="$t('dict.dictName')" align="left" prop="dictName"/>
|
<el-table-column :label="$t('dict.dictType')" header-align="center" prop="dictType"/>
|
<zt-table-column-dict v-if="$store.state.user.isPlatform" :label="$t('dict.canView')" dict="bool"
|
prop="canView"
|
width="80"/>
|
<zt-table-column-dict v-if="$store.state.user.isPlatform" :label="$t('dict.canOverload')" dict="bool"
|
prop="canOverload"
|
width="80"/>
|
<zt-table-column-handle v-if="$store.state.user.isPlatform" :table="table" delete-perm="sys:dict:delete"
|
edit-perm="sys:dict:update"/>
|
<!-- 租户按钮 -->
|
<zt-table-column-handle v-if="!$store.state.user.isPlatform" :has-delete="isCanDelete"
|
:has-edit="isCanUpdate"
|
:table="table" delete-perm="sys:dict:delete"
|
edit-perm="sys:dict:update">
|
<template v-slot="{ row }">
|
<zt-table-button v-if="isCanOverload(row)" @click="copy(row)">{{
|
$t('dict.copy')
|
}}
|
</zt-table-button>
|
</template>
|
</zt-table-column-handle>
|
</el-table>
|
<dictListImport ref="dictListImport" @refreshDataList="refresh()"></dictListImport>
|
<!-- 弹窗, 新增 / 修改 -->
|
<add-or-update @refreshDataList="table.query()"/>
|
</zt-table-wraper>
|
</div>
|
</el-col>
|
<el-col :span="13">
|
<dict-data ref="dictList"/>
|
</el-col>
|
</el-row>
|
</div>
|
|
</div>
|
</template>
|
<script>
|
import AddOrUpdate from './dict-type-add-or-update'
|
import DictData from './dict-data'
|
import {stringify} from "qs";
|
import dictListImport from './dict-list-import'
|
|
export default {
|
data() {
|
return {
|
dataForm: {
|
id: '0',
|
dictName: '',
|
dictType: ''
|
},
|
progress: {
|
id: null,
|
speed: 0,
|
text: '',
|
start: false,
|
timer: null
|
},
|
fileType: ['xlsx', 'xls'],
|
apiURL: '',
|
start: 0,
|
dialogVisible: false,
|
dialogMsg: '',
|
fileList: [],
|
resultData: []
|
}
|
},
|
components: {
|
AddOrUpdate,
|
DictData,
|
dictListImport,
|
},
|
methods: {
|
init() {
|
this.fileList = []
|
this.resultData = []
|
this.progress.id = guid()
|
let params = stringify({
|
token: Cookies.get('token'),
|
progressId:this.progress.id
|
})
|
this.apiURL = `http://localhost:8058/maintain/lifeManagement/importDataDictExcel?${params}`
|
},
|
DictImport() {
|
this.$refs.dictListImport.$refs.dialog.init()
|
},
|
dictNameleft({row, column, rowIndex, columnIndex}){
|
console.log({row, column, rowIndex, columnIndex},'row rowIndex')
|
if(column.property === 'dictName'){
|
return {'textAlign':'left'}
|
}
|
},
|
refresh() {
|
let page = this.$refs.tableObj.page
|
let limit = this.$refs.tableObj.limit
|
this.$refs.tableObj.pageLimitChange(page, limit)
|
this.$refs.ztBoatTree.getProductList()
|
this.$refs.tableObj.query()
|
},
|
handleCurrentChange(row) {
|
this.dataForm.id = row.id
|
if (row.children.length === 0) {
|
this.$refs['dictList'].init(row.id, row.dictName)
|
} else {
|
this.$refs['dictList'].$refs.dataTable.dataList = []
|
}
|
},
|
isCanUpdate(row) {
|
return row.tenantId !== this.$config.PLATFORM_TENANT_ID
|
},
|
isCanDelete(row) {
|
if (this.$store.state.user.isPlatform) { // 平台用户
|
return row.children.length === 0
|
} else { // 租户
|
return row.tenantId !== this.$config.PLATFORM_TENANT_ID && row.children.length === 0 // 租户的参数才可以删除
|
}
|
},
|
isCanOverload(row) { // 是否能拷贝
|
return row.tenantId === this.$config.PLATFORM_TENANT_ID && row.pid === this.$config.DICT_ROOT && row.canOverload === true
|
},
|
async copy(row) {
|
if (await this.$tip.confirm(this.$t('prompt.info', {'handle': this.$t('dict.copy')}))) {
|
let res = await this.$http.post(`/sys/dict/type/copy?id=${row.id}`)
|
if (res.success) {
|
await this.$tip.success()
|
this.$refs.typeTable.query()
|
}
|
}
|
}
|
}
|
}
|
</script>
|
|
<style>
|
.custom-tree-node {
|
flex: 1;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
font-size: 14px;
|
padding-right: 8px;
|
}
|
</style>
|