From 37bf68f2e50127ad11e83dd0cabb751a54d6f94c Mon Sep 17 00:00:00 2001
From: yujialong <479214531@qq.com>
Date: Wed, 8 Dec 2021 14:26:32 +0800
Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9B=B8=E5=85=B3=E5=AE=8C?=
=?UTF-8?q?=E5=96=84=E6=B3=A8=E9=87=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/data/Introduce.vue | 25 +++++++++++++++++--------
src/views/data/Product.vue | 27 ++++++++++++++++++++++-----
2 files changed, 39 insertions(+), 13 deletions(-)
diff --git a/src/views/data/Introduce.vue b/src/views/data/Introduce.vue
index 66e5f3d..0548b6b 100644
--- a/src/views/data/Introduce.vue
+++ b/src/views/data/Introduce.vue
@@ -44,7 +44,7 @@
取 消
- 确 定
+ 确 定
@@ -120,6 +120,7 @@ export default {
this.getKeyword()
}).catch(res => {})
},
+ // 分类点击
typeClick(data,node){
this.editing = false
this.categoryId = data.id
@@ -129,6 +130,7 @@ export default {
this.dataSource = data.dataSource
this.getKeyword()
},
+ // 获取关键词
getKeyword(){
this.$get(this.api.getKeywordByCategoryId,{
categoryId: this.categoryId
@@ -136,12 +138,14 @@ export default {
this.keywordList = res.keywords
}).catch(res => {})
},
+ // 进入编辑状态
edit(){
this.editing = true
this.introduce = this.introduceText
},
- confirmEdit(){
- const id = this.categoryId
+ // 保存数据介绍和数据源
+ saveType(){
+ const id = this.categoryId // 获取当前分类id
this.$post(this.api.updateCategory,{
id,
introduce: this.introduce,
@@ -154,26 +158,31 @@ export default {
this.getData()
}).catch(res => {})
},
+ // 删除关键词
delKeyword(item) {
this.$post(`${this.api.deleteKeyword}?categoryId=${this.categoryId}&keyword=${item.keyword}`).then(res => {
this.$message.success('删除成功')
this.getKeyword()
}).catch(res => {})
},
- addKeyword() {
- const keyword = this.newKeyword
+ // 保存
+ confirmData() {
+ const keyword = this.newKeyword // 获取输入的关键词
+ // 如果有关键词,则调新增关键词的接口,否则,直接调保存分类信息的接口去保存数据介绍和数据源
if (keyword) {
+ // 同个分类下,关键词不能重复
if (this.keywordList.find(e => e.keyword === keyword)) return this.$message.error('请不要输入重复关键字!')
- this.confirmEdit()
+ this.saveType()
+ // 新增关键词
this.$post(this.api.addKeyword,{
categoryId: this.categoryId,
keyword
}).then(res => {
- this.newKeyword = ''
+ this.newKeyword = '' // 新增后,输入框清空
this.getKeyword()
}).catch(res => {})
} else {
- this.confirmEdit()
+ this.saveType()
}
}
}
diff --git a/src/views/data/Product.vue b/src/views/data/Product.vue
index ccd7e81..f3246a7 100644
--- a/src/views/data/Product.vue
+++ b/src/views/data/Product.vue
@@ -241,6 +241,7 @@ export default {
this.getData()
},
methods: {
+ // 获取产品列表
getData() {
this.$post(this.api.listByEntity,{
createTime: this.startTime,
@@ -254,17 +255,19 @@ export default {
this.totals = res.pageList.total
}).catch(res => {})
},
+ // 重置分页为1
initData(){
this.page = 1
this.getData()
},
+ // 获取分类下的表
getTable(n,isConcat){
this.$post(`${this.api.getIdQueryTable}?categoryId=${n.originId}&showName=&pageNum=${n.typePage}&pageSize=${this.typeUnit}&updateTime=`).then(res => {
let list = res.pageList.records
list.map(n => {
n.label = n.showName
n.id = String(n.id)
- n.disabled = true
+ n.disabled = true // 外面的弹框里的分类禁止操作,只能查看
})
// 如果是懒加载的情况,则拼接
if(isConcat){
@@ -293,7 +296,7 @@ export default {
})
}
handleId(res)
- this.typeConfigList = JSON.parse(JSON.stringify(res))
+ this.typeConfigList = JSON.parse(JSON.stringify(res)) // 深拷贝,用来数据配置里直接使用
// 获取分类下的表
function getTable(data){
@@ -301,8 +304,8 @@ export default {
if(n.children.length){
getTable(n.children)
}else{
- n.typePage = 1
- n.disabled = true
+ n.typePage = 1 // 获取表要用到的分页
+ n.disabled = true // 表同样禁止操作
that.getTable(n)
}
})
@@ -377,25 +380,29 @@ export default {
}
},50)
},
+ // 获取产品详情
getDetail(){
this.$post(`${this.api.findById}?id=${this.id}`).then(res => {
const data = res.product
this.productName = data.productName
this.market = data.market
this.checkedIds = data.tableId.split(',')
- this.$refs.type.setCheckedKeys(this.checkedIds)
+ this.$refs.type.setCheckedKeys(this.checkedIds) // 选中已选的表
}).catch(res => {})
},
+ // 新增产品
add(){
this.getType()
this.id = ''
this.checkedIds = []
},
+ // 编辑产品
edit(row){
this.getType(true)
this.id = row.id
this.userId = row.userId
},
+ // 启用禁用产品,直接调用编辑产品的接口,状态变下即可
switchOff(val,row) {
this.$post(this.api.updateProduct,{
id: row.id,
@@ -413,11 +420,13 @@ export default {
this.$message.success(val ? '上架成功' : '下架成功')
}).catch(err => {})
},
+ // 表预览
preview(row){
this.getType(true)
this.isDetail = true
this.id = row.id
},
+ // 删除产品
handleDelete(row) {
this.$confirm('确定要删除吗?', '提示', {
type: 'warning'
@@ -452,6 +461,7 @@ export default {
this.page = val
this.getData()
},
+ // 关闭产品弹框回调
closeProduct(){
this.productName = ''
this.market = ''
@@ -485,6 +495,7 @@ export default {
this.configLoading = false
})
},
+ // 操作产品保存
confirm(){
if(this.submited) return false
if(!this.productName) return this.$message.warning('请输入数据产品名称')
@@ -527,6 +538,7 @@ export default {
})
}
},
+ // 配置数据
configData(){
this.configVisible = true
this.getConfigType()
@@ -537,11 +549,13 @@ export default {
this.$refs.typeConfig.setCheckedKeys(this.configIds)
}
},
+ // 数据配置里的分类点击回调
typeConfigClick(data){
this.categoryId = data.id
this.categoryOriginId = data.originId
this.getConfigTable()
},
+ // 关闭数据配置弹框回调
closeConfig(){
// 关闭的时候清除多选
this.$refs.typeConfig.setCheckedNodes([])
@@ -577,6 +591,7 @@ export default {
this.totalConfig = res.pageList.total
}).catch(res => {})
},
+ // 重置数据配置里的分页
initConfigData(){
this.pageConfig = 1
this.getConfigTable()
@@ -585,6 +600,7 @@ export default {
this.pageConfig = val
this.getConfigTable()
},
+ // 预览
previewConfig(row){
this.$get(`${this.api.previewData}?tableName=${row.name}&tableId=${row.id}`).then(res => {
let comment = res.comment
@@ -606,6 +622,7 @@ export default {
this.previewVisible = true
}).catch(res => {})
},
+ // 数据配置保存
confirmConfig(){
const list = this.$refs.typeConfig.getCheckedNodes().map(e => e.originId) // 获取选中的id
this.getIds(list).then(() => {