|
|
|
@ -81,14 +81,10 @@ |
|
|
|
|
</el-input> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="已选数据"> |
|
|
|
|
<el-button type="primary" @click="configData">配置数据权限</el-button> |
|
|
|
|
<div class="type-wrap" ref="typeWrap" @scroll="loadType" v-if='configChecked.length>0'> |
|
|
|
|
<el-tree ref="type" :data="typeList" show-checkbox accordion node-key="id" :default-expanded-keys="checkedIds" :default-checked-keys="checkedIds" :props="defaultProps" @node-expand="typeExpand"> |
|
|
|
|
<span class="custom-tree-node" slot-scope="{ node, data }"> |
|
|
|
|
<span :title="node.label">{{ node.label }}</span> |
|
|
|
|
</span> |
|
|
|
|
</el-tree> |
|
|
|
|
</div> |
|
|
|
|
<el-button type="primary" @click="configData" style="margin-bottom: 10px;">配置数据权限</el-button> |
|
|
|
|
<!-- <div class="type-wrap" ref="typeWrap" @scroll="loadType" v-if='checkedIds.length>0'> --> |
|
|
|
|
<el-tree ref="type" :data="typeList" accordion node-key="id" :default-expanded-keys="checkedIds" :default-checked-keys="checkedIds" :props="defaultProps" @node-expand="typeExpand"></el-tree> |
|
|
|
|
<!-- </div> --> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-form> |
|
|
|
|
<span slot="footer" class="dialog-footer" v-if="!isDetail"> |
|
|
|
@ -100,7 +96,7 @@ |
|
|
|
|
<el-dialog title="数据配置" :visible.sync="configVisible" width="70%" center @close="closeConfig" :close-on-click-modal="false"> |
|
|
|
|
<el-container style="padding: 20px 0 20px 20px;background-color: #f0f0f0;"> |
|
|
|
|
<el-aside width="300px"> |
|
|
|
|
<el-tree style="margin: 10px;" ref="typeConfig" :data="typeConfigList" show-checkbox node-key="id" accordion :default-expanded-keys="configIds" :default-checked-keys="configIds" :current-node-key="categoryId" :props="defaultProps" highlight-current @current-change="typeConfigClick"> |
|
|
|
|
<el-tree style="margin: 10px;" ref="typeConfig" :load="getConfigType" lazy show-checkbox node-key="id" accordion :default-expanded-keys="configIds" :default-checked-keys="configIds" :current-node-key="categoryId" :props="defaultProps" highlight-current @current-change="typeConfigClick"> |
|
|
|
|
<span class="custom-tree-node" slot-scope="{ node, data }"> |
|
|
|
|
<span :title="node.label">{{ node.label }}</span> |
|
|
|
|
</span> |
|
|
|
@ -185,7 +181,7 @@ export default { |
|
|
|
|
typeList: [], |
|
|
|
|
defaultProps: { |
|
|
|
|
children: 'children', |
|
|
|
|
label: 'label' |
|
|
|
|
label: 'categoryName' |
|
|
|
|
}, |
|
|
|
|
checkedIds: [], |
|
|
|
|
isDetail: false, |
|
|
|
@ -203,7 +199,6 @@ export default { |
|
|
|
|
configIds: [], |
|
|
|
|
updateTime: '', |
|
|
|
|
keywordConfig: '', |
|
|
|
|
typeConfigList: [], |
|
|
|
|
pageConfig: 1, |
|
|
|
|
pageSizeConfig: 10, |
|
|
|
|
totalConfig: 0, |
|
|
|
@ -260,7 +255,7 @@ export default { |
|
|
|
|
this.getData() |
|
|
|
|
}, |
|
|
|
|
getTable(n,isConcat){ |
|
|
|
|
this.$post(`${this.api.getIdQueryTable}?categoryId=${n.originId}&showName=&pageNum=${n.typePage}&pageSize=${this.typeUnit}&updateTime=`).then(res => { |
|
|
|
|
this.$post(`${this.api.getIdQueryTable}?categoryId=${n.id}&showName=&pageNum=${n.typePage}&pageSize=${this.typeUnit}&updateTime=`).then(res => { |
|
|
|
|
let list = res.pageList.records |
|
|
|
|
list.map(n => { |
|
|
|
|
n.label = n.showName |
|
|
|
@ -278,40 +273,25 @@ export default { |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}, |
|
|
|
|
// 获取分类 |
|
|
|
|
getType(){ |
|
|
|
|
this.productVisible = true |
|
|
|
|
this.$post(this.api.getTableByClassification).then(res => { |
|
|
|
|
getType(node, resolve){ |
|
|
|
|
this.$post(`${this.api.getLevel}?parentId=${node.level ? node.data.id : 0}`).then(res => { |
|
|
|
|
const that = this |
|
|
|
|
function handleId(data){ |
|
|
|
|
data.map(n => { |
|
|
|
|
n.originId = n.id |
|
|
|
|
n.id = String(++that.typeIndex) |
|
|
|
|
n.label = n.categoryName |
|
|
|
|
n.disabled = true |
|
|
|
|
if(n.children.length){ |
|
|
|
|
handleId(n.children) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
handleId(res) |
|
|
|
|
|
|
|
|
|
const list = res.list |
|
|
|
|
this.node = node |
|
|
|
|
this.resolve = resolve |
|
|
|
|
resolve(list) |
|
|
|
|
// 获取分类下的表 |
|
|
|
|
function getTable(data){ |
|
|
|
|
data.map(n => { |
|
|
|
|
if(n.children.length){ |
|
|
|
|
if(n.children && n.children.length){ |
|
|
|
|
getTable(n.children) |
|
|
|
|
}else{ |
|
|
|
|
n.typePage = 1 |
|
|
|
|
n.disabled = true |
|
|
|
|
that.getTable(n) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
getTable(res) |
|
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.typeList = res |
|
|
|
|
},500) |
|
|
|
|
getTable(list) |
|
|
|
|
this.importVisible = true |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}, |
|
|
|
@ -382,17 +362,20 @@ export default { |
|
|
|
|
this.productName = data.productName |
|
|
|
|
this.market = data.market |
|
|
|
|
this.configChecked = data.tableId |
|
|
|
|
this.checkedIds = this.handleType(data.tableId.split(','),this.typeList) |
|
|
|
|
this.$refs.type.setCheckedNodes(this.checkedIds) |
|
|
|
|
// this.checkedIds = this.handleType(data.tableId.split(','),this.typeList) |
|
|
|
|
this.configIds = data.tableId.split(',') |
|
|
|
|
console.log('getDetail', this.configIds) |
|
|
|
|
// this.$refs.type.setCheckedNodes(this.checkedIds) |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}, |
|
|
|
|
add(){ |
|
|
|
|
this.getType() |
|
|
|
|
this.productVisible = true |
|
|
|
|
this.id = '' |
|
|
|
|
this.checkedIds = [] |
|
|
|
|
}, |
|
|
|
|
edit(row){ |
|
|
|
|
this.getType() |
|
|
|
|
this.productVisible = true |
|
|
|
|
// this.getType() |
|
|
|
|
this.id = row.id |
|
|
|
|
this.userId = row.userId |
|
|
|
|
this.getDetail() |
|
|
|
@ -416,7 +399,8 @@ export default { |
|
|
|
|
}, |
|
|
|
|
preview(row){ |
|
|
|
|
this.isDetail = true |
|
|
|
|
this.getType() |
|
|
|
|
this.productVisible = true |
|
|
|
|
// this.getType() |
|
|
|
|
this.id = row.id |
|
|
|
|
this.getDetail() |
|
|
|
|
}, |
|
|
|
@ -476,7 +460,7 @@ export default { |
|
|
|
|
list.map((n,i) => { |
|
|
|
|
if(n.tableLen && n.tableLen > n.children.length){ |
|
|
|
|
// pageSize传10000是要查询全部表,后续如果数据多了,则按需调整 |
|
|
|
|
this.$post(`${this.api.getIdQueryTable}?categoryId=${n.originId}&showName=&pageNum=1&pageSize=10000&updateTime=`).then(res => { |
|
|
|
|
this.$post(`${this.api.getIdQueryTable}?categoryId=${n.id}&showName=&pageNum=1&pageSize=10000&updateTime=`).then(res => { |
|
|
|
|
let tableList = res.pageList.records |
|
|
|
|
tableList.map(n => { |
|
|
|
|
this.tableId.push(String(n.id)) |
|
|
|
@ -498,25 +482,26 @@ export default { |
|
|
|
|
if(!this.productName) return this.$message.warning('请输入数据产品名称') |
|
|
|
|
if(!this.market) return this.$message.warning('请输入市场价格') |
|
|
|
|
if(isNaN(this.market)) return this.$message.warning('市场价格请输入数字') |
|
|
|
|
if(!this.$refs.type.getCheckedNodes().length) return this.$message.warning('请选择数据') |
|
|
|
|
if(!this.checkedIds.length) return this.$message.warning('请选择数据') |
|
|
|
|
|
|
|
|
|
this.submited = true |
|
|
|
|
|
|
|
|
|
this.getIds().then(() => { |
|
|
|
|
let tableId = Array.from(new Set(this.tableId)) |
|
|
|
|
if(!tableId.length) return this.$message.warning('请选择数据') |
|
|
|
|
// this.getIds().then(() => { |
|
|
|
|
// let tableId = Array.from(new Set(this.tableId)) |
|
|
|
|
// if(!tableId.length) return this.$message.warning('请选择数据') |
|
|
|
|
// return console.log(333, this.checkedIds) |
|
|
|
|
let data = { |
|
|
|
|
id: this.id, |
|
|
|
|
productName: this.productName, |
|
|
|
|
market: this.market, |
|
|
|
|
tableId: tableId.join(), |
|
|
|
|
tableId: this.checkedIds.join(), |
|
|
|
|
userId: this.userId, |
|
|
|
|
userName: this.userName, |
|
|
|
|
createTime: '', |
|
|
|
|
orderNum: '', |
|
|
|
|
status: '', |
|
|
|
|
tableNum: tableId.length, |
|
|
|
|
updateTime: '', |
|
|
|
|
tableNum: this.checkedIds.length, |
|
|
|
|
updateTime: '' |
|
|
|
|
} |
|
|
|
|
if(this.id){ |
|
|
|
|
this.$post(this.api.updateProduct,data).then(res => { |
|
|
|
@ -537,19 +522,19 @@ export default { |
|
|
|
|
this.submited = false |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
// }) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
configData(){ |
|
|
|
|
this.configVisible = true |
|
|
|
|
this.getConfigType() |
|
|
|
|
|
|
|
|
|
let list = this.$refs.type.getCheckedNodes() |
|
|
|
|
let configIds = [] |
|
|
|
|
list.map(n => { |
|
|
|
|
if(!n.name) configIds.push(n.originId) |
|
|
|
|
}) |
|
|
|
|
this.configIds = configIds |
|
|
|
|
if (this.id) { |
|
|
|
|
// let list = this.$refs.type.getCheckedNodes() |
|
|
|
|
// let configIds = [] |
|
|
|
|
// list.map(n => { |
|
|
|
|
// if(!n.name) configIds.push(n.id) |
|
|
|
|
// }) |
|
|
|
|
// this.configIds = configIds |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
typeConfigClick(data,node){ |
|
|
|
|
this.categoryId = data.id |
|
|
|
@ -560,23 +545,12 @@ export default { |
|
|
|
|
this.$refs.typeConfig.setCheckedNodes([]) |
|
|
|
|
}, |
|
|
|
|
// 获取配置数据里面的分类 |
|
|
|
|
getConfigType(){ |
|
|
|
|
this.$post(this.api.getTableByClassification).then(res => { |
|
|
|
|
function handleId(data){ |
|
|
|
|
data.map(n => { |
|
|
|
|
n.id = String(n.id) |
|
|
|
|
n.label = n.categoryName |
|
|
|
|
if(n.children.length){ |
|
|
|
|
handleId(n.children) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
handleId(res) |
|
|
|
|
this.typeConfigList = res |
|
|
|
|
if(res[0].children.length){ |
|
|
|
|
this.categoryId = res[0].children[0].id |
|
|
|
|
}else{ |
|
|
|
|
this.categoryId = res[0].id |
|
|
|
|
getConfigType(node, resolve){ |
|
|
|
|
this.$post(`${this.api.getLevel}?parentId=${node.level ? node.data.id : 0}`).then(res => { |
|
|
|
|
const list = res.list |
|
|
|
|
resolve(list) |
|
|
|
|
if(list.length){ |
|
|
|
|
this.categoryId = list[0].id |
|
|
|
|
} |
|
|
|
|
this.getConfigTable() |
|
|
|
|
}).catch(res => {}) |
|
|
|
@ -626,7 +600,7 @@ export default { |
|
|
|
|
list.map(n => { |
|
|
|
|
if(n.children && n.children.length){ |
|
|
|
|
this.getTableId(n.children) |
|
|
|
|
if(checked.includes(n.originId) && n.children[0].name){ |
|
|
|
|
if(checked.includes(n.id) && n.children[0].name){ |
|
|
|
|
this.configCheckedTableId = [...this.configCheckedTableId,...n.children.map(n => n.id)] |
|
|
|
|
}else{ |
|
|
|
|
this.getTableId(n.children) |
|
|
|
@ -635,11 +609,10 @@ export default { |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
confirmConfig(){ |
|
|
|
|
this.configChecked = this.$refs.typeConfig.getCheckedKeys().map(n => Number(n)) |
|
|
|
|
this.getTableId(this.typeList) |
|
|
|
|
this.checkedIds = Array.from(new Set(this.configCheckedTableId)) |
|
|
|
|
this.checkedIds = this.$refs.typeConfig.getCheckedKeys().map(n => Number(n)) |
|
|
|
|
this.configVisible = false |
|
|
|
|
this.$refs.type.setCheckedNodes(this.checkedIds) |
|
|
|
|
console.log(22, this.$refs.typeConfig.getCheckedNodes()) |
|
|
|
|
this.typeList = this.$refs.typeConfig.getCheckedNodes() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|