产品新增编辑、关键词等

dev
yujialong 3 years ago
parent e1efe0a166
commit 74c7bd4b83
  1. 9
      src/views/data/Framework.vue
  2. 38
      src/views/data/Introduce.vue
  3. 85
      src/views/data/Product.vue

@ -134,7 +134,7 @@
<el-table-column v-for="(item,index) in previewHead" :prop="item.field" :key="index" :label="item.oldComment" align="center"> <el-table-column v-for="(item,index) in previewHead" :prop="item.field" :key="index" :label="item.oldComment" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<template v-if="scope.row.custom"> <template v-if="scope.row.custom">
<el-input placeholder="请输入" :key="item.comment" v-model="item.comment"></el-input> <el-input placeholder="请输入" v-model="item.comment"></el-input>
</template> </template>
<template v-else>{{scope.row[item.field]}}</template> <template v-else>{{scope.row[item.field]}}</template>
</template> </template>
@ -186,6 +186,7 @@ export default {
previewVisible: false, previewVisible: false,
previewHead: [], previewHead: [],
previewData: [], previewData: [],
curComment: [],
submited: false, submited: false,
names: [], names: [],
showNames: [], showNames: [],
@ -313,6 +314,7 @@ export default {
this.$get(`${this.api.previewData}?tableName=${row.name}&tableId=${row.id}`).then(res => { this.$get(`${this.api.previewData}?tableName=${row.name}&tableId=${row.id}`).then(res => {
let comment = res.comment let comment = res.comment
let previewHead = [] let previewHead = []
this.curComment = comment
comment.map(n => { comment.map(n => {
n.field != 'id' && n.field != 'operation_time' && previewHead.push(n) n.field != 'id' && n.field != 'operation_time' && previewHead.push(n)
}) })
@ -364,11 +366,10 @@ export default {
this.headVisible = true this.headVisible = true
}, },
confirmHead(){ confirmHead(){
let data = JSON.parse(JSON.stringify(this.previewHead)) let data = JSON.parse(JSON.stringify(this.curComment))
// data.map(e => delete e.oldComment)
this.$post(`${this.api.updateTableCommit}?tableName=${this.curRow.name}`, data).then(res => { this.$post(`${this.api.updateTableCommit}?tableName=${this.curRow.name}`, data).then(res => {
this.$message.success('修改成功') this.$message.success('修改成功')
this.nameVisible = false this.headVisible = false
this.getData() this.getData()
}).catch(res => {}) }).catch(res => {})
}, },

@ -31,6 +31,10 @@
</div> </div>
<div class="field"> <div class="field">
<p class="label">关键字</p> <p class="label">关键字</p>
<div class="tag-add">
<el-input placeholder="请输入关键字" size="small" v-model="newKeyword"></el-input>
<el-button size="small" type="primary" @click="addKeyword">添加</el-button>
</div>
<div class="tag-wrap"> <div class="tag-wrap">
<el-tag <el-tag
:key="tag.id" :key="tag.id"
@ -40,16 +44,6 @@
@close="delKeyword(tag)"> @close="delKeyword(tag)">
{{tag.keyword}} {{tag.keyword}}
</el-tag> </el-tag>
<el-input
class="input-new-tag"
v-if="inputVisible"
v-model="newKeyword"
ref="saveTagInput"
size="small"
@keyup.enter.native="handleInputConfirm"
>
</el-input>
<el-button v-else class="button-new-tag" @click="showInput">+</el-button>
</div> </div>
</div> </div>
</el-card> </el-card>
@ -74,7 +68,6 @@ export default {
introduceText: '', introduceText: '',
categoryId: '', categoryId: '',
keywordList: [], keywordList: [],
inputVisible: false,
newKeyword: '' newKeyword: ''
}; };
}, },
@ -125,7 +118,6 @@ 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
console.log(11, data, node)
this.getKeyword() this.getKeyword()
}, },
getKeyword(){ getKeyword(){
@ -155,17 +147,10 @@ export default {
this.getKeyword() this.getKeyword()
}).catch(res => {}) }).catch(res => {})
}, },
showInput() { addKeyword() {
this.inputVisible = true
this.$nextTick(_ => {
this.$refs.saveTagInput.$refs.input.focus()
})
},
handleInputConfirm() {
const keyword = this.newKeyword const keyword = this.newKeyword
if (keyword) { if (keyword) {
if (this.keywordList.find(e => e.keyword === keyword)) return this.$message.error('请不要输入重复关键字!') if (this.keywordList.find(e => e.keyword === keyword)) return this.$message.error('请不要输入重复关键字!')
this.inputVisible = false
this.$post(this.api.addKeyword,{ this.$post(this.api.addKeyword,{
categoryId: this.categoryId, categoryId: this.categoryId,
keyword keyword
@ -173,6 +158,8 @@ export default {
this.newKeyword = '' this.newKeyword = ''
this.getKeyword() this.getKeyword()
}).catch(res => {}) }).catch(res => {})
} else {
this.$message.error('请输入关键字!')
} }
} }
} }
@ -209,6 +196,17 @@ export default {
margin-top: 20px; margin-top: 20px;
} }
} }
.tag-add {
display: flex;
align-items: center;
margin-bottom: 10px;
.el-input {
width: 200px;
}
.el-button {
margin-left: 5px;
}
}
.mag{ .mag{
margin-right: 20px; margin-right: 20px;
margin-left: 20px; margin-left: 20px;

@ -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" 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 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" @click="confirm"> </el-button> <el-button type="primary" :loading="loading" @click="confirm"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
@ -211,7 +211,7 @@ export default {
previewVisible: false, previewVisible: false,
previewHead: [], previewHead: [],
previewData: [], previewData: [],
submited: false, loading: false
}; };
}, },
watch: { watch: {
@ -307,7 +307,6 @@ 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
@ -377,20 +376,17 @@ 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.getType() this.productVisible = true
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()
@ -414,7 +410,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()
}, },
@ -459,46 +455,34 @@ 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.$refs.type.getCheckedNodes() let list = this.configIds
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) => {
if(n.tableLen && n.tableLen > n.children.length){ this.$post(`${this.api.getIdQueryTable}?categoryId=${n}&showName=&pageNum=1&pageSize=10000&updateTime=`).then(res => {
// pageSize10000,, res.pageList.records.map(n => {
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
getLen-- len--
// 0,resolve // 0,resolve
if(!getLen) resolve() if(!len) 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.submited) return false if(this.loading) 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.$refs.type.getCheckedNodes().length) return this.$message.warning('请选择数据') if(!this.configIds.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('请选择数据')
@ -515,23 +499,24 @@ 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.submited = false this.loading = false
}).catch(res => { }).catch(res => {
this.submited = false this.loading = 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.submited = false this.loading = false
}).catch(res => { }).catch(res => {
this.submited = false this.loading = false
}) })
} }
}) })
@ -540,13 +525,6 @@ 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
@ -632,11 +610,24 @@ export default {
}) })
}, },
confirmConfig(){ confirmConfig(){
this.configChecked = this.$refs.typeConfig.getCheckedKeys().map(n => Number(n)) this.configIds = this.$refs.typeConfig.getCheckedKeys()
this.getTableId(this.typeList) const list = this.$refs.typeConfig.getCheckedNodes()
this.checkedIds = Array.from(new Set(this.configCheckedTableId)) 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.configVisible = false
this.$refs.type.setCheckedNodes(this.checkedIds)
} }
} }
}; };

Loading…
Cancel
Save