|
|
@ -81,10 +81,14 @@ |
|
|
|
</el-input> |
|
|
|
</el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="已选数据"> |
|
|
|
<el-form-item label="已选数据"> |
|
|
|
<el-button type="primary" @click="configData" style="margin-bottom: 10px;">配置数据权限</el-button> |
|
|
|
<el-button type="primary" @click="configData">配置数据权限</el-button> |
|
|
|
<!-- <div class="type-wrap" ref="typeWrap" @scroll="loadType" v-if='checkedIds.length>0'> --> |
|
|
|
<div class="type-wrap" ref="typeWrap" @scroll="loadType" v-if="configChecked.length"> |
|
|
|
<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> |
|
|
|
<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"> |
|
|
|
<!-- </div> --> |
|
|
|
<span class="custom-tree-node" slot-scope="{ node, data }"> |
|
|
|
|
|
|
|
<span :title="node.label">{{ node.label }}</span> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
</el-tree> |
|
|
|
|
|
|
|
</div> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
</el-form> |
|
|
|
<span slot="footer" class="dialog-footer" v-if="!isDetail"> |
|
|
|
<span slot="footer" class="dialog-footer" v-if="!isDetail"> |
|
|
@ -96,7 +100,7 @@ |
|
|
|
<el-dialog title="数据配置" :visible.sync="configVisible" width="70%" center @close="closeConfig" :close-on-click-modal="false"> |
|
|
|
<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-container style="padding: 20px 0 20px 20px;background-color: #f0f0f0;"> |
|
|
|
<el-aside width="300px"> |
|
|
|
<el-aside width="300px"> |
|
|
|
<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"> |
|
|
|
<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"> |
|
|
|
<span class="custom-tree-node" slot-scope="{ node, data }"> |
|
|
|
<span class="custom-tree-node" slot-scope="{ node, data }"> |
|
|
|
<span :title="node.label">{{ node.label }}</span> |
|
|
|
<span :title="node.label">{{ node.label }}</span> |
|
|
|
</span> |
|
|
|
</span> |
|
|
@ -181,7 +185,7 @@ export default { |
|
|
|
typeList: [], |
|
|
|
typeList: [], |
|
|
|
defaultProps: { |
|
|
|
defaultProps: { |
|
|
|
children: 'children', |
|
|
|
children: 'children', |
|
|
|
label: 'categoryName' |
|
|
|
label: 'label' |
|
|
|
}, |
|
|
|
}, |
|
|
|
checkedIds: [], |
|
|
|
checkedIds: [], |
|
|
|
isDetail: false, |
|
|
|
isDetail: false, |
|
|
@ -199,6 +203,7 @@ export default { |
|
|
|
configIds: [], |
|
|
|
configIds: [], |
|
|
|
updateTime: '', |
|
|
|
updateTime: '', |
|
|
|
keywordConfig: '', |
|
|
|
keywordConfig: '', |
|
|
|
|
|
|
|
typeConfigList: [], |
|
|
|
pageConfig: 1, |
|
|
|
pageConfig: 1, |
|
|
|
pageSizeConfig: 10, |
|
|
|
pageSizeConfig: 10, |
|
|
|
totalConfig: 0, |
|
|
|
totalConfig: 0, |
|
|
@ -255,7 +260,7 @@ export default { |
|
|
|
this.getData() |
|
|
|
this.getData() |
|
|
|
}, |
|
|
|
}, |
|
|
|
getTable(n,isConcat){ |
|
|
|
getTable(n,isConcat){ |
|
|
|
this.$post(`${this.api.getIdQueryTable}?categoryId=${n.id}&showName=&pageNum=${n.typePage}&pageSize=${this.typeUnit}&updateTime=`).then(res => { |
|
|
|
this.$post(`${this.api.getIdQueryTable}?categoryId=${n.originId}&showName=&pageNum=${n.typePage}&pageSize=${this.typeUnit}&updateTime=`).then(res => { |
|
|
|
let list = res.pageList.records |
|
|
|
let list = res.pageList.records |
|
|
|
list.map(n => { |
|
|
|
list.map(n => { |
|
|
|
n.label = n.showName |
|
|
|
n.label = n.showName |
|
|
@ -273,25 +278,40 @@ export default { |
|
|
|
}).catch(res => {}) |
|
|
|
}).catch(res => {}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 获取分类 |
|
|
|
// 获取分类 |
|
|
|
getType(node, resolve){ |
|
|
|
getType(){ |
|
|
|
this.$post(`${this.api.getLevel}?parentId=${node.level ? node.data.id : 0}`).then(res => { |
|
|
|
this.productVisible = true |
|
|
|
|
|
|
|
this.$post(this.api.getTableByClassification).then(res => { |
|
|
|
const that = this |
|
|
|
const that = this |
|
|
|
const list = res.list |
|
|
|
function handleId(data){ |
|
|
|
this.node = node |
|
|
|
data.map(n => { |
|
|
|
this.resolve = resolve |
|
|
|
n.originId = n.id |
|
|
|
resolve(list) |
|
|
|
n.id = String(++that.typeIndex) |
|
|
|
|
|
|
|
n.label = n.categoryName |
|
|
|
|
|
|
|
n.disabled = true |
|
|
|
|
|
|
|
if(n.children.length){ |
|
|
|
|
|
|
|
handleId(n.children) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
handleId(res) |
|
|
|
|
|
|
|
|
|
|
|
// 获取分类下的表 |
|
|
|
// 获取分类下的表 |
|
|
|
function getTable(data){ |
|
|
|
function getTable(data){ |
|
|
|
data.map(n => { |
|
|
|
data.map(n => { |
|
|
|
if(n.children && n.children.length){ |
|
|
|
if(n.children.length){ |
|
|
|
getTable(n.children) |
|
|
|
getTable(n.children) |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
n.typePage = 1 |
|
|
|
n.typePage = 1 |
|
|
|
|
|
|
|
n.disabled = true |
|
|
|
that.getTable(n) |
|
|
|
that.getTable(n) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
getTable(list) |
|
|
|
getTable(res) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
this.typeList = res |
|
|
|
|
|
|
|
},500) |
|
|
|
this.importVisible = true |
|
|
|
this.importVisible = true |
|
|
|
}).catch(res => {}) |
|
|
|
}).catch(res => {}) |
|
|
|
}, |
|
|
|
}, |
|
|
@ -362,20 +382,17 @@ export default { |
|
|
|
this.productName = data.productName |
|
|
|
this.productName = data.productName |
|
|
|
this.market = data.market |
|
|
|
this.market = data.market |
|
|
|
this.configChecked = data.tableId |
|
|
|
this.configChecked = data.tableId |
|
|
|
// this.checkedIds = this.handleType(data.tableId.split(','),this.typeList) |
|
|
|
this.checkedIds = this.handleType(data.tableId.split(','),this.typeList) |
|
|
|
this.configIds = data.tableId.split(',') |
|
|
|
this.$refs.type.setCheckedNodes(this.checkedIds) |
|
|
|
console.log('getDetail', this.configIds) |
|
|
|
|
|
|
|
// this.$refs.type.setCheckedNodes(this.checkedIds) |
|
|
|
|
|
|
|
}).catch(res => {}) |
|
|
|
}).catch(res => {}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
add(){ |
|
|
|
add(){ |
|
|
|
this.productVisible = true |
|
|
|
this.getType() |
|
|
|
this.id = '' |
|
|
|
this.id = '' |
|
|
|
this.checkedIds = [] |
|
|
|
this.checkedIds = [] |
|
|
|
}, |
|
|
|
}, |
|
|
|
edit(row){ |
|
|
|
edit(row){ |
|
|
|
this.productVisible = true |
|
|
|
this.getType() |
|
|
|
// this.getType() |
|
|
|
|
|
|
|
this.id = row.id |
|
|
|
this.id = row.id |
|
|
|
this.userId = row.userId |
|
|
|
this.userId = row.userId |
|
|
|
this.getDetail() |
|
|
|
this.getDetail() |
|
|
@ -399,8 +416,7 @@ export default { |
|
|
|
}, |
|
|
|
}, |
|
|
|
preview(row){ |
|
|
|
preview(row){ |
|
|
|
this.isDetail = true |
|
|
|
this.isDetail = true |
|
|
|
this.productVisible = true |
|
|
|
this.getType() |
|
|
|
// this.getType() |
|
|
|
|
|
|
|
this.id = row.id |
|
|
|
this.id = row.id |
|
|
|
this.getDetail() |
|
|
|
this.getDetail() |
|
|
|
}, |
|
|
|
}, |
|
|
@ -450,58 +466,47 @@ export default { |
|
|
|
// 获取tableId,提交的时候需要 |
|
|
|
// 获取tableId,提交的时候需要 |
|
|
|
getIds(){ |
|
|
|
getIds(){ |
|
|
|
// 获取已经勾选的分类 |
|
|
|
// 获取已经勾选的分类 |
|
|
|
let list = this.$refs.type.getCheckedNodes() |
|
|
|
let list = this.checkedIds |
|
|
|
return new Promise((resolve,reject) => { |
|
|
|
this.tableId = [] |
|
|
|
let getLen = 0 |
|
|
|
const proList = [] |
|
|
|
list.map(n => { |
|
|
|
list.map(e => { |
|
|
|
// 如果tableLen大于子级的数量,则表示这个分类下的子级是没有全部加载出来的,要在下面去查询出来,这里先记载要查询的分类数量 |
|
|
|
proList.push(new Promise((resolve,reject) => { |
|
|
|
if(n.tableLen && n.tableLen > n.children.length) getLen++ |
|
|
|
this.$get(`${this.api.getAllTableIdBycategoryId}?categoryId=${e}`).then(res => { |
|
|
|
}) |
|
|
|
res.tableId && this.tableId.push(...res.tableId.split(',')) |
|
|
|
list.map((n,i) => { |
|
|
|
resolve() |
|
|
|
if(n.tableLen && n.tableLen > n.children.length){ |
|
|
|
}).catch(res => { |
|
|
|
// pageSize传10000是要查询全部表,后续如果数据多了,则按需调整 |
|
|
|
this.submited = false |
|
|
|
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)) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
// 查询完1个,则数量-1 |
|
|
|
|
|
|
|
getLen-- |
|
|
|
|
|
|
|
// 清0后,才执行resolve |
|
|
|
|
|
|
|
if(!getLen) resolve() |
|
|
|
|
|
|
|
}).catch(res => {}) |
|
|
|
|
|
|
|
}else if(n.name && !this.tableId.includes(n.id)){ // 如果是表,并且没重复,则添加进去 |
|
|
|
|
|
|
|
this.tableId.push(n.id) |
|
|
|
|
|
|
|
if(!getLen) resolve() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
return Promise.all(proList).then(res => { |
|
|
|
|
|
|
|
resolve() |
|
|
|
|
|
|
|
}).catch(err => {}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
confirm(){ |
|
|
|
confirm(){ |
|
|
|
if(this.submited) return false |
|
|
|
if(this.submited) return false |
|
|
|
if(!this.productName) return this.$message.warning('请输入数据产品名称') |
|
|
|
if(!this.productName) return this.$message.warning('请输入数据产品名称') |
|
|
|
if(!this.market) return this.$message.warning('请输入市场价格') |
|
|
|
if(!this.market) return this.$message.warning('请输入市场价格') |
|
|
|
if(isNaN(this.market)) return this.$message.warning('市场价格请输入数字') |
|
|
|
if(isNaN(this.market)) return this.$message.warning('市场价格请输入数字') |
|
|
|
if(!this.checkedIds.length) return this.$message.warning('请选择数据') |
|
|
|
if(!this.$refs.type.getCheckedNodes().length) return this.$message.warning('请选择数据') |
|
|
|
|
|
|
|
|
|
|
|
this.submited = true |
|
|
|
this.submited = true |
|
|
|
|
|
|
|
|
|
|
|
// this.getIds().then(() => { |
|
|
|
this.getIds().then(() => { |
|
|
|
// let tableId = Array.from(new Set(this.tableId)) |
|
|
|
let tableId = Array.from(new Set(this.tableId)) |
|
|
|
// if(!tableId.length) return this.$message.warning('请选择数据') |
|
|
|
if(!tableId.length) return this.$message.warning('请选择数据') |
|
|
|
// return console.log(333, this.checkedIds) |
|
|
|
|
|
|
|
let data = { |
|
|
|
let data = { |
|
|
|
id: this.id, |
|
|
|
id: this.id, |
|
|
|
productName: this.productName, |
|
|
|
productName: this.productName, |
|
|
|
market: this.market, |
|
|
|
market: this.market, |
|
|
|
tableId: this.checkedIds.join(), |
|
|
|
tableId: tableId.join(), |
|
|
|
userId: this.userId, |
|
|
|
userId: this.userId, |
|
|
|
userName: this.userName, |
|
|
|
userName: this.userName, |
|
|
|
createTime: '', |
|
|
|
createTime: '', |
|
|
|
orderNum: '', |
|
|
|
orderNum: '', |
|
|
|
status: '', |
|
|
|
status: '', |
|
|
|
tableNum: this.checkedIds.length, |
|
|
|
tableNum: tableId.length, |
|
|
|
updateTime: '' |
|
|
|
updateTime: '', |
|
|
|
} |
|
|
|
} |
|
|
|
if(this.id){ |
|
|
|
if(this.id){ |
|
|
|
this.$post(this.api.updateProduct,data).then(res => { |
|
|
|
this.$post(this.api.updateProduct,data).then(res => { |
|
|
@ -522,18 +527,19 @@ export default { |
|
|
|
this.submited = false |
|
|
|
this.submited = false |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
// }) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
configData(){ |
|
|
|
configData(){ |
|
|
|
this.configVisible = true |
|
|
|
this.configVisible = true |
|
|
|
|
|
|
|
this.getConfigType() |
|
|
|
if (this.id) { |
|
|
|
if (this.id) { |
|
|
|
// let list = this.$refs.type.getCheckedNodes() |
|
|
|
let list = this.$refs.type.getCheckedNodes() |
|
|
|
// let configIds = [] |
|
|
|
let configIds = [] |
|
|
|
// list.map(n => { |
|
|
|
list.map(n => { |
|
|
|
// if(!n.name) configIds.push(n.id) |
|
|
|
if(!n.name) configIds.push(n.originId) |
|
|
|
// }) |
|
|
|
}) |
|
|
|
// this.configIds = configIds |
|
|
|
this.configIds = configIds |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
typeConfigClick(data,node){ |
|
|
|
typeConfigClick(data,node){ |
|
|
@ -545,12 +551,23 @@ export default { |
|
|
|
this.$refs.typeConfig.setCheckedNodes([]) |
|
|
|
this.$refs.typeConfig.setCheckedNodes([]) |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 获取配置数据里面的分类 |
|
|
|
// 获取配置数据里面的分类 |
|
|
|
getConfigType(node, resolve){ |
|
|
|
getConfigType(){ |
|
|
|
this.$post(`${this.api.getLevel}?parentId=${node.level ? node.data.id : 0}`).then(res => { |
|
|
|
this.$post(this.api.getTableByClassification).then(res => { |
|
|
|
const list = res.list |
|
|
|
function handleId(data){ |
|
|
|
resolve(list) |
|
|
|
data.map(n => { |
|
|
|
if(list.length){ |
|
|
|
n.id = String(n.id) |
|
|
|
this.categoryId = list[0].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 |
|
|
|
} |
|
|
|
} |
|
|
|
this.getConfigTable() |
|
|
|
this.getConfigTable() |
|
|
|
}).catch(res => {}) |
|
|
|
}).catch(res => {}) |
|
|
@ -600,7 +617,7 @@ export default { |
|
|
|
list.map(n => { |
|
|
|
list.map(n => { |
|
|
|
if(n.children && n.children.length){ |
|
|
|
if(n.children && n.children.length){ |
|
|
|
this.getTableId(n.children) |
|
|
|
this.getTableId(n.children) |
|
|
|
if(checked.includes(n.id) && n.children[0].name){ |
|
|
|
if(checked.includes(n.originId) && n.children[0].name){ |
|
|
|
this.configCheckedTableId = [...this.configCheckedTableId,...n.children.map(n => n.id)] |
|
|
|
this.configCheckedTableId = [...this.configCheckedTableId,...n.children.map(n => n.id)] |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
this.getTableId(n.children) |
|
|
|
this.getTableId(n.children) |
|
|
@ -609,10 +626,15 @@ export default { |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
confirmConfig(){ |
|
|
|
confirmConfig(){ |
|
|
|
this.checkedIds = this.$refs.typeConfig.getCheckedKeys().map(n => Number(n)) |
|
|
|
this.configChecked = this.$refs.typeConfig.getCheckedKeys().map(n => n) |
|
|
|
this.configVisible = false |
|
|
|
// this.getTableId(this.typeList) |
|
|
|
console.log(22, this.$refs.typeConfig.getCheckedNodes()) |
|
|
|
this.checkedIds = this.configChecked |
|
|
|
this.typeList = this.$refs.typeConfig.getCheckedNodes() |
|
|
|
console.log(44, this.checkedIds, this.configChecked, this.typeList) |
|
|
|
|
|
|
|
this.getIds().then(() => { |
|
|
|
|
|
|
|
this.configVisible = false |
|
|
|
|
|
|
|
console.log(33, this.tableId) |
|
|
|
|
|
|
|
this.$refs.type.setCheckedNodes([...this.tableId, ...this.checkedIds]) |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|