|
|
|
@ -83,7 +83,7 @@ |
|
|
|
|
<el-form-item label="已选数据"> |
|
|
|
|
<el-button type="primary" @click="configData">配置数据权限</el-button> |
|
|
|
|
<div class="type-wrap" ref="typeWrap" @scroll="loadType"> |
|
|
|
|
<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"> |
|
|
|
|
<el-tree ref="type" :data="typeList" accordion node-key="id" :props="defaultProps" @node-expand="typeExpand"> |
|
|
|
|
<span class="custom-tree-node" slot-scope="{ node, data }"> |
|
|
|
|
<span :title="node.label">{{ node.label }}</span> |
|
|
|
|
</span> |
|
|
|
@ -93,7 +93,7 @@ |
|
|
|
|
</el-form> |
|
|
|
|
<span slot="footer" class="dialog-footer" v-if="!isDetail"> |
|
|
|
|
<el-button @click="productVisible = false">取 消</el-button> |
|
|
|
|
<el-button type="primary" @click="confirm">确 定</el-button> |
|
|
|
|
<el-button type="primary" :loading="loading" @click="confirm">确 定</el-button> |
|
|
|
|
</span> |
|
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
|
@ -211,7 +211,7 @@ export default { |
|
|
|
|
previewVisible: false, |
|
|
|
|
previewHead: [], |
|
|
|
|
previewData: [], |
|
|
|
|
submited: false, |
|
|
|
|
loading: false |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
watch: { |
|
|
|
@ -307,7 +307,6 @@ export default { |
|
|
|
|
getTable(res) |
|
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
console.log(11, res) |
|
|
|
|
this.typeList = res |
|
|
|
|
},500) |
|
|
|
|
this.importVisible = true |
|
|
|
@ -377,20 +376,17 @@ export default { |
|
|
|
|
}, |
|
|
|
|
getDetail(){ |
|
|
|
|
this.$post(`${this.api.findById}?id=${this.id}`).then(res => { |
|
|
|
|
this.productVisible = true |
|
|
|
|
let data = res.product |
|
|
|
|
this.productName = data.productName |
|
|
|
|
this.market = data.market |
|
|
|
|
this.checkedIds = this.handleType(data.tableId.split(','),this.typeList) |
|
|
|
|
this.$refs.type.setCheckedNodes(this.checkedIds) |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}, |
|
|
|
|
add(){ |
|
|
|
|
this.getType() |
|
|
|
|
this.productVisible = true |
|
|
|
|
this.id = '' |
|
|
|
|
this.checkedIds = [] |
|
|
|
|
}, |
|
|
|
|
edit(row){ |
|
|
|
|
this.getType() |
|
|
|
|
this.id = row.id |
|
|
|
|
this.userId = row.userId |
|
|
|
|
this.getDetail() |
|
|
|
@ -414,7 +410,7 @@ export default { |
|
|
|
|
}, |
|
|
|
|
preview(row){ |
|
|
|
|
this.isDetail = true |
|
|
|
|
this.getType() |
|
|
|
|
// this.getType() |
|
|
|
|
this.id = row.id |
|
|
|
|
this.getDetail() |
|
|
|
|
}, |
|
|
|
@ -459,46 +455,34 @@ export default { |
|
|
|
|
this.typeIndex = 100000 |
|
|
|
|
this.typeList = [] |
|
|
|
|
this.tableId = [] |
|
|
|
|
this.configIds = [] |
|
|
|
|
}, |
|
|
|
|
// 获取tableId,提交的时候需要 |
|
|
|
|
getIds(){ |
|
|
|
|
// 获取已经勾选的分类 |
|
|
|
|
let list = this.$refs.type.getCheckedNodes() |
|
|
|
|
let list = this.configIds |
|
|
|
|
let len = list.length |
|
|
|
|
return new Promise((resolve,reject) => { |
|
|
|
|
let getLen = 0 |
|
|
|
|
list.map(n => { |
|
|
|
|
// 如果tableLen大于子级的数量,则表示这个分类下的子级是没有全部加载出来的,要在下面去查询出来,这里先记载要查询的分类数量 |
|
|
|
|
if(n.tableLen && n.tableLen > n.children.length) getLen++ |
|
|
|
|
}) |
|
|
|
|
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 => { |
|
|
|
|
let tableList = res.pageList.records |
|
|
|
|
tableList.map(n => { |
|
|
|
|
this.$post(`${this.api.getIdQueryTable}?categoryId=${n}&showName=&pageNum=1&pageSize=10000&updateTime=`).then(res => { |
|
|
|
|
res.pageList.records.map(n => { |
|
|
|
|
this.tableId.push(String(n.id)) |
|
|
|
|
}) |
|
|
|
|
// 查询完1个,则数量-1 |
|
|
|
|
getLen-- |
|
|
|
|
len-- |
|
|
|
|
// 清0后,才执行resolve |
|
|
|
|
if(!getLen) resolve() |
|
|
|
|
if(!len) resolve() |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}else if(n.name && !this.tableId.includes(n.id)){ // 如果是表,并且没重复,则添加进去 |
|
|
|
|
this.tableId.push(n.id) |
|
|
|
|
if(!getLen) resolve() |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
confirm(){ |
|
|
|
|
if(this.submited) return false |
|
|
|
|
if(this.loading) return false |
|
|
|
|
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('请选择数据') |
|
|
|
|
|
|
|
|
|
this.submited = true |
|
|
|
|
|
|
|
|
|
if(!this.configIds.length) return this.$message.warning('请选择数据') |
|
|
|
|
this.loading = true |
|
|
|
|
this.getIds().then(() => { |
|
|
|
|
let tableId = Array.from(new Set(this.tableId)) |
|
|
|
|
if(!tableId.length) return this.$message.warning('请选择数据') |
|
|
|
@ -515,23 +499,24 @@ export default { |
|
|
|
|
tableNum: tableId.length, |
|
|
|
|
updateTime: '', |
|
|
|
|
} |
|
|
|
|
this.$refs.typeConfig.setCheckedNodes([]) |
|
|
|
|
if(this.id){ |
|
|
|
|
this.$post(this.api.updateProduct,data).then(res => { |
|
|
|
|
this.$message.success('新增成功') |
|
|
|
|
this.productVisible = false |
|
|
|
|
this.getData() |
|
|
|
|
this.submited = false |
|
|
|
|
this.loading = false |
|
|
|
|
}).catch(res => { |
|
|
|
|
this.submited = false |
|
|
|
|
this.loading = false |
|
|
|
|
}) |
|
|
|
|
}else{ |
|
|
|
|
this.$post(this.api.saveProduct,data).then(res => { |
|
|
|
|
this.$message.success('新增成功') |
|
|
|
|
this.productVisible = false |
|
|
|
|
this.getData() |
|
|
|
|
this.submited = false |
|
|
|
|
this.loading = false |
|
|
|
|
}).catch(res => { |
|
|
|
|
this.submited = false |
|
|
|
|
this.loading = false |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
@ -540,13 +525,6 @@ export default { |
|
|
|
|
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 |
|
|
|
|
}, |
|
|
|
|
typeConfigClick(data,node){ |
|
|
|
|
this.categoryId = data.id |
|
|
|
@ -632,11 +610,24 @@ 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.configIds = this.$refs.typeConfig.getCheckedKeys() |
|
|
|
|
const list = this.$refs.typeConfig.getCheckedNodes() |
|
|
|
|
function uniqData(e, i) { |
|
|
|
|
e.children.map(n => { |
|
|
|
|
const index = list.findIndex(e => e.id === n.id) |
|
|
|
|
if (index) { |
|
|
|
|
list.splice(index, 1) |
|
|
|
|
} |
|
|
|
|
if (n.children && n.children.length) { |
|
|
|
|
uniqData(n, i) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
list.map((e, i) => { |
|
|
|
|
uniqData(e, i) |
|
|
|
|
}) |
|
|
|
|
this.typeList = list |
|
|
|
|
this.configVisible = false |
|
|
|
|
this.$refs.type.setCheckedNodes(this.checkedIds) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|