产品修复

dev
e 3 years ago
parent 29180b5c69
commit 65ff633cd4
  1. 9
      src/views/data/Introduce.vue
  2. 88
      src/views/data/Product.vue

@ -22,7 +22,7 @@
<el-input placeholder="请输入简介" v-model="introduce" type="textarea" rows="5" :disabled="!editing"></el-input> <el-input placeholder="请输入简介" v-model="introduce" type="textarea" rows="5" :disabled="!editing"></el-input>
<div class="field"> <div class="field">
<p class="label">数据源</p> <p class="label">数据源</p>
<el-input style="width: 250px" placeholder="请输入数据源" v-model="source" type="text"></el-input> <el-input style="width: 250px" placeholder="请输入数据源" v-model="dataSource" type="text" :disabled="!editing"></el-input>
</div> </div>
</template> </template>
<div class="btns" v-if="editing"> <div class="btns" v-if="editing">
@ -64,7 +64,7 @@ export default {
defaultActive: [], defaultActive: [],
editing: false, editing: false,
introduce: '', introduce: '',
source: '', dataSource: '',
introduceText: '', introduceText: '',
categoryId: '', categoryId: '',
keywordList: [], keywordList: [],
@ -98,6 +98,7 @@ export default {
this.typeList = res this.typeList = res
// id // id
this.dataSource = res[0].dataSource
if(res[0].children.length){ if(res[0].children.length){
let item = res[0].children[0] let item = res[0].children[0]
this.categoryId = item.id this.categoryId = item.id
@ -118,6 +119,7 @@ export default {
this.categoryId = data.id this.categoryId = data.id
this.introduceText = data.introduce this.introduceText = data.introduce
this.introduce = data.introduce this.introduce = data.introduce
this.dataSource = data.dataSource
this.getKeyword() this.getKeyword()
}, },
getKeyword(){ getKeyword(){
@ -134,7 +136,8 @@ export default {
confirmEdit(){ confirmEdit(){
this.$post(this.api.updateCategory,{ this.$post(this.api.updateCategory,{
id: this.categoryId, id: this.categoryId,
introduce: this.introduce introduce: this.introduce,
dataSource: this.dataSource
}).then(res => { }).then(res => {
this.$message.success(this.introduceText ? '编辑成功' : '新增成功') this.$message.success(this.introduceText ? '编辑成功' : '新增成功')
this.introduceText = this.introduce this.introduceText = this.introduce

@ -83,7 +83,7 @@
<el-form-item label="已选数据"> <el-form-item label="已选数据">
<el-button type="primary" @click="configData">配置数据权限</el-button> <el-button type="primary" @click="configData">配置数据权限</el-button>
<div class="type-wrap" ref="typeWrap" @scroll="loadType"> <div class="type-wrap" ref="typeWrap" @scroll="loadType">
<el-tree ref="type" :data="typeList" accordion node-key="id" :props="defaultProps" @node-expand="typeExpand"> <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 class="custom-tree-node" slot-scope="{ node, data }">
<span :title="node.label">{{ node.label }}</span> <span :title="node.label">{{ node.label }}</span>
</span> </span>
@ -93,7 +93,7 @@
</el-form> </el-form>
<span slot="footer" class="dialog-footer" v-if="!isDetail"> <span slot="footer" class="dialog-footer" v-if="!isDetail">
<el-button @click="productVisible = false"> </el-button> <el-button @click="productVisible = false"> </el-button>
<el-button type="primary" :loading="loading" @click="confirm"> </el-button> <el-button type="primary" :loading="submited" @click="confirm"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
@ -211,7 +211,7 @@ export default {
previewVisible: false, previewVisible: false,
previewHead: [], previewHead: [],
previewData: [], previewData: [],
loading: false submited: false,
}; };
}, },
watch: { watch: {
@ -265,6 +265,7 @@ export default {
list.map(n => { list.map(n => {
n.label = n.showName n.label = n.showName
n.id = String(n.id) n.id = String(n.id)
n.disabled = true
}) })
// , // ,
if(isConcat){ if(isConcat){
@ -286,6 +287,7 @@ export default {
n.originId = n.id n.originId = n.id
n.id = String(++that.typeIndex) n.id = String(++that.typeIndex)
n.label = n.categoryName n.label = n.categoryName
n.disabled = true
if(n.children.length){ if(n.children.length){
handleId(n.children) handleId(n.children)
} }
@ -300,6 +302,7 @@ export default {
getTable(n.children) getTable(n.children)
}else{ }else{
n.typePage = 1 n.typePage = 1
n.disabled = true
that.getTable(n) that.getTable(n)
} }
}) })
@ -307,6 +310,7 @@ export default {
getTable(res) getTable(res)
setTimeout(() => { setTimeout(() => {
console.log(11, res)
this.typeList = res this.typeList = res
},500) },500)
this.importVisible = true this.importVisible = true
@ -376,17 +380,20 @@ export default {
}, },
getDetail(){ getDetail(){
this.$post(`${this.api.findById}?id=${this.id}`).then(res => { this.$post(`${this.api.findById}?id=${this.id}`).then(res => {
this.productVisible = true
let data = res.product let data = res.product
this.productName = data.productName this.productName = data.productName
this.market = data.market this.market = data.market
this.checkedIds = this.handleType(data.tableId.split(','),this.typeList)
this.$refs.type.setCheckedNodes(this.checkedIds)
}).catch(res => {}) }).catch(res => {})
}, },
add(){ add(){
this.productVisible = true this.getType()
this.id = '' this.id = ''
this.checkedIds = []
}, },
edit(row){ edit(row){
this.getType()
this.id = row.id this.id = row.id
this.userId = row.userId this.userId = row.userId
this.getDetail() this.getDetail()
@ -410,7 +417,7 @@ export default {
}, },
preview(row){ preview(row){
this.isDetail = true this.isDetail = true
// this.getType() this.getType()
this.id = row.id this.id = row.id
this.getDetail() this.getDetail()
}, },
@ -455,34 +462,46 @@ export default {
this.typeIndex = 100000 this.typeIndex = 100000
this.typeList = [] this.typeList = []
this.tableId = [] this.tableId = []
this.configIds = []
}, },
// tableId, // tableId,
getIds(){ getIds(){
// //
let list = this.configIds let list = this.$refs.type.getCheckedNodes()
let len = list.length
return new Promise((resolve,reject) => { 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) => { list.map((n,i) => {
this.$post(`${this.api.getIdQueryTable}?categoryId=${n}&showName=&pageNum=1&pageSize=10000&updateTime=`).then(res => { if(n.tableLen && n.tableLen > n.children.length){
res.pageList.records.map(n => { // pageSize10000,,
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.tableId.push(String(n.id)) this.tableId.push(String(n.id))
}) })
// 1,-1 // 1,-1
len-- getLen--
// 0,resolve // 0,resolve
if(!len) resolve() if(!getLen) resolve()
}).catch(res => {}) }).catch(res => {})
}else if(n.name && !this.tableId.includes(n.id)){ // ,,
this.tableId.push(n.id)
if(!getLen) resolve()
}
}) })
}) })
}, },
confirm(){ confirm(){
if(this.loading) 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.configIds.length) return this.$message.warning('请选择数据') if(!this.$refs.type.getCheckedNodes().length) return this.$message.warning('请选择数据')
this.loading = 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('请选择数据')
@ -499,24 +518,23 @@ export default {
tableNum: tableId.length, tableNum: tableId.length,
updateTime: '', updateTime: '',
} }
this.$refs.typeConfig.setCheckedNodes([])
if(this.id){ if(this.id){
this.$post(this.api.updateProduct,data).then(res => { this.$post(this.api.updateProduct,data).then(res => {
this.$message.success('新增成功') this.$message.success('新增成功')
this.productVisible = false this.productVisible = false
this.getData() this.getData()
this.loading = false this.submited = false
}).catch(res => { }).catch(res => {
this.loading = false this.submited = false
}) })
}else{ }else{
this.$post(this.api.saveProduct,data).then(res => { this.$post(this.api.saveProduct,data).then(res => {
this.$message.success('新增成功') this.$message.success('新增成功')
this.productVisible = false this.productVisible = false
this.getData() this.getData()
this.loading = false this.submited = false
}).catch(res => { }).catch(res => {
this.loading = false this.submited = false
}) })
} }
}) })
@ -525,6 +543,13 @@ export default {
configData(){ configData(){
this.configVisible = true this.configVisible = true
this.getConfigType() 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){ typeConfigClick(data,node){
this.categoryId = data.id this.categoryId = data.id
@ -610,24 +635,11 @@ export default {
}) })
}, },
confirmConfig(){ confirmConfig(){
this.configIds = this.$refs.typeConfig.getCheckedKeys() this.configChecked = this.$refs.typeConfig.getCheckedKeys().map(n => Number(n))
const list = this.$refs.typeConfig.getCheckedNodes() this.getTableId(this.typeList)
function uniqData(e, i) { this.checkedIds = Array.from(new Set(this.configCheckedTableId))
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.configVisible = false
this.$refs.type.setCheckedNodes(this.checkedIds)
} }
} }
}; };

Loading…
Cancel
Save