Merge branch 'dev'

dev
yujialong 3 years ago
commit 2673ddb745
  1. 3
      src/utils/api.js
  2. 144
      src/views/data/Framework.vue
  3. 56
      src/views/data/Introduce.vue
  4. 75
      src/views/data/Product.vue

@ -163,6 +163,8 @@ export default {
staticPreview: `${host}/data/data/staticPreview`, staticPreview: `${host}/data/data/staticPreview`,
editTableName: `${host}/data/data/table/editTableName`, editTableName: `${host}/data/data/table/editTableName`,
updateTableCommit: `${host}/data/data/updateTableCommit`, updateTableCommit: `${host}/data/data/updateTableCommit`,
getLevel: `${host}/data/category/getLevel`,
getAllTableInfoByCategoryId: `${host}/data/data/product/getAllTableInfoByCategoryId`,
// 产品管理 // 产品管理
deleteProduct: `${host}/data/data/product/delete`, deleteProduct: `${host}/data/data/product/delete`,
@ -171,6 +173,7 @@ export default {
saveProduct: `${host}/data/data/product/save`, saveProduct: `${host}/data/data/product/save`,
updateProduct: `${host}/data/data/product/update`, updateProduct: `${host}/data/data/product/update`,
saveRecord: `${host}/data/data/dataRecord/saveRecord`, saveRecord: `${host}/data/data/dataRecord/saveRecord`,
getAllTableIdBycategoryId: `${host}/data/data/product/getAllTableIdBycategoryId`,
// 关键词 // 关键词
addKeyword: `${host}/data/keyword/addKeyword`, addKeyword: `${host}/data/keyword/addKeyword`,

@ -5,7 +5,7 @@
<div class="plus"> <div class="plus">
<i class="el-icon-circle-plus-outline" @click.stop="addType(0)"></i> <i class="el-icon-circle-plus-outline" @click.stop="addType(0)"></i>
</div> </div>
<el-tree ref="type" :data="typeList" node-key="id" accordion :default-expanded-keys="defaultActive" :current-node-key="categoryId" :props="defaultProps" :highlight-current="true" @current-change="typeClick"> <el-tree ref="type" :load="getType" lazy node-key="id" accordion :default-expanded-keys="defaultActive" :current-node-key="categoryId" :props="defaultProps" :highlight-current="true" @current-change="typeClick">
<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 class="actions"> <span class="actions">
@ -156,10 +156,9 @@
export default { export default {
data() { data() {
return { return {
typeList: [],
defaultProps: { defaultProps: {
children: 'children', children: 'children',
label: 'label' label: 'categoryName'
}, },
defaultActive: [], defaultActive: [],
added: false, added: false,
@ -195,11 +194,13 @@ export default {
curComment: [], curComment: [],
submited: false, submited: false,
names: [], names: [],
showNames: [],
nameVisible: false, nameVisible: false,
curRow: {}, curRow: {},
headVisible: false, headVisible: false,
editIndex: 0 editIndex: 0,
node: [],
resolve: null,
curNode: {}
}; };
}, },
watch: { watch: {
@ -210,37 +211,20 @@ export default {
},500) },500)
} }
}, },
mounted(){ mounted(){},
this.getType()
},
methods: { methods: {
getType(){ getType(node, resolve){
this.$post(this.api.getTableByClassification).then(res => { this.$post(`${this.api.getLevel}?parentId=${node.level ? node.data.id : 0}`).then(res => {
// , const list = res.list
function handleId(data,level = 0){ this.node = node
data.map(n => { this.resolve = resolve
n.id = String(n.id) resolve(list)
n.label = n.categoryName
n.level = level + 1
if(n.children.length){
handleId(n.children,n.level)
}
})
}
handleId(res)
this.typeList = res
if (!this.added) {
if(res[0].children.length){
this.categoryId = res[0].children[0].id
this.defaultActive = [res[0].children[0].id]
}else{
this.categoryId = res[0].id
this.defaultActive = [res[0].id]
}
// id // id
if (!this.added && list.length) {
this.categoryId = list[0].id
this.defaultActive = [list[0].id]
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.type.setCurrentKey(res[0].children[0].id) this.$refs.type.setCurrentKey(list[0].id)
}) })
} }
this.added = false this.added = false
@ -274,6 +258,7 @@ export default {
this.getData() this.getData()
}, },
addType(row){ addType(row){
this.categoryId = row.data.id
if (row) this.defaultActive = [row.data.id] if (row) this.defaultActive = [row.data.id]
this.typeVisible = true this.typeVisible = true
this.levelId = row ? row.data.id : 0 this.levelId = row ? row.data.id : 0
@ -282,6 +267,8 @@ export default {
this.typeVisible = true this.typeVisible = true
this.id = row.data.id this.id = row.data.id
this.categoryName = row.data.categoryName this.categoryName = row.data.categoryName
this.curNode = row
this.categoryId = row.data.id
}, },
delType(row){ delType(row){
// //
@ -291,7 +278,7 @@ export default {
this.added = true this.added = true
this.$post(`${this.api.deleteCategory}?categoryId=${row.data.id}`).then(res => { this.$post(`${this.api.deleteCategory}?categoryId=${row.data.id}`).then(res => {
this.$message.success('删除成功') this.$message.success('删除成功')
this.getType() this.$refs.type.remove(row)
}).catch(res => {}) }).catch(res => {})
}).catch(() => {}) }).catch(() => {})
}, },
@ -305,7 +292,9 @@ export default {
categoryName: this.categoryName categoryName: this.categoryName
}).then(res => { }).then(res => {
this.$message.success('编辑成功') this.$message.success('编辑成功')
this.getType() this.curNode.data.categoryName = this.categoryName
this.$refs.type.updateKeyChildren(this.id, this.curNode)
this.getType(this.node, this.resolve)
this.typeVisible = false this.typeVisible = false
setTimeout(() => { setTimeout(() => {
this.submited = false this.submited = false
@ -319,7 +308,10 @@ export default {
categoryName: this.categoryName categoryName: this.categoryName
}).then(res => { }).then(res => {
this.$message.success('添加成功') this.$message.success('添加成功')
this.getType() this.getType(this.node, this.resolve)
let node = this.$refs.type.getNode(this.categoryId)
node.loaded = false
node.expand()
this.typeVisible = false this.typeVisible = false
setTimeout(() => { setTimeout(() => {
this.submited = false this.submited = false
@ -492,7 +484,7 @@ export default {
data.map(n => { data.map(n => {
that.importTypeIndex++ that.importTypeIndex++
n.realId = n.id n.realId = n.id
// idid,, // idid,
n.id = String(that.importTypeIndex + n.id) n.id = String(that.importTypeIndex + n.id)
n.label = n.categoryName n.label = n.categoryName
if(n.children.length){ if(n.children.length){
@ -501,7 +493,7 @@ export default {
}) })
} }
handleId(res) handleId(res)
this.$post(`${this.api.getIdQueryTable}?categoryId=${this.categoryId}&showName=${this.keyword}&pageNum=1&pageSize=10000&updateTime=${this.updateTime ? this.updateTime : ''}`).then(res1 => { this.$post(`${this.api.getIdQueryTable}?categoryId=${this.categoryId}&showName=${this.keyword}&pageNum=1&pageSize=3000&updateTime=${this.updateTime ? this.updateTime : ''}`).then(res1 => {
let list = res1.pageList.records let list = res1.pageList.records
this.defaultTypeChecked = list.map(n => n.copyId) this.defaultTypeChecked = list.map(n => n.copyId)
const that = this const that = this
@ -562,74 +554,58 @@ export default {
closeImport(){ closeImport(){
this.$refs.typeTree.setCheckedKeys([]) this.$refs.typeTree.setCheckedKeys([])
this.names = [] this.names = []
this.showNames = []
}, },
// namesshowNames, // namesshowNames,
getNames(){ getNames(list){
// const categoryId = Number(this.categoryId)
let list = this.$refs.typeTree.getCheckedNodes()
return new Promise((resolve,reject) => { return new Promise((resolve,reject) => {
let getLen = 0 // idid
list.map(n => { this.$get(`${this.api.getAllTableInfoByCategoryId}?categoryId=${list.join()}`).then(res => {
// tableLen const list = res.tableInfo
if(n.tableLen && n.tableLen > n.children.length) getLen++ list.map(e => {
}) delete e.id
list.map((n,i) => { e.categoryId = categoryId
if(n.tableLen && n.tableLen > n.children.length){
// pageSize10000,,
this.$post(`${this.api.originalListById}?categoryId=${n.realId}&pageNum=1&pageSize=10000`).then(res => {
let tableList = res.list.records
// 1,-1
getLen--
tableList.map(n => {
// ,
if(!this.defaultTypeChecked.includes(String(n.id))){
this.names.push(n.name)
this.showNames.push(n.showName)
}
}) })
// 0,resolve this.names = list
if(!getLen) resolve() resolve()
}).catch(res => {}) }).catch(res => {})
}else if(n.name && !n.disabled && !this.names.includes(n.name)){ // ,,,
this.names.push(n.name)
this.showNames.push(n.showName)
if(!getLen) resolve()
}
})
}) })
}, },
confirmImport(){ confirmImport(){
if(this.submited) return false if(this.submited) return false
const checked = this.$refs.typeTree.getCheckedNodes() //
// //
if(!this.$refs.typeTree.getCheckedNodes().length) return this.$message.warning('请选择数据') if(!checked.length) return this.$message.warning('请选择数据')
this.getNames().then(() => {
let names = Array.from(new Set(this.names))
let showNames = Array.from(new Set(this.showNames))
if(!names.length) return this.$message.warning('请选择数据')
this.submited = true this.submited = true
let data = [] const typeIds = checked.filter(e => !e.name).map(e => e.realId) // idid
let categoryId = Number(this.categoryId) this.getNames(typeIds).then(() => {
names.map((n,i) => { const data = this.names
data.push({ const dataList = []
categoryId, for (let i = 0, len = data.length; i < len; i += 2000) {
name: n, dataList.push(data.slice(i, i + 2000))
showName: showNames[i], }
const promiseList = []
dataList.map(e => {
promiseList.push(new Promise((resolve,reject) => {
this.$post(this.api.saveTable, e).then(res => {
resolve()
}).catch(res => {
reject()
}) })
}))
}) })
this.$post(this.api.saveTable,data).then(res => { Promise.all(promiseList).then(res => {
this.$message.success('导入成功') this.$message.success('导入成功')
this.getData() this.getData()
this.importVisible = false this.importVisible = false
setTimeout(() => { setTimeout(() => {
this.submited = false this.submited = false
},1000) },1000)
}).catch(res => { }).catch(err => {
this.submited = false this.submited = false
}) })
}) })
}, }
} }
}; };
</script> </script>

@ -2,7 +2,7 @@
<div> <div>
<el-container> <el-container>
<el-aside width="350px"> <el-aside width="350px">
<el-tree ref="type" :data="typeList" node-key="id" accordion :default-expanded-keys="defaultActive" :current-node-key="categoryId" :props="defaultProps" highlight-current @node-click="typeClick"></el-tree> <el-tree ref="type" :load="getData" lazy node-key="id" accordion :default-expanded-keys="defaultActive" :current-node-key="categoryId" :props="defaultProps" :highlight-current="true" @current-change="typeClick"></el-tree>
</el-aside> </el-aside>
<el-main style="padding-top: 0"> <el-main style="padding-top: 0">
@ -56,10 +56,9 @@
export default { export default {
data() { data() {
return { return {
typeList: [],
defaultProps: { defaultProps: {
children: 'children', children: 'children',
label: 'label' label: 'categoryName'
}, },
defaultActive: [], defaultActive: [],
editing: false, editing: false,
@ -69,7 +68,10 @@ export default {
introduceText: '', introduceText: '',
categoryId: '', categoryId: '',
keywordList: [], keywordList: [],
newKeyword: '' newKeyword: '',
node: [],
resolve: null,
curNode: {}
}; };
}, },
watch: { watch: {
@ -80,42 +82,22 @@ export default {
},500) },500)
} }
}, },
mounted(){ mounted(){},
this.getData()
},
methods: { methods: {
getData(){ getData(node, resolve){
// //
this.$post(this.api.getTableByClassification).then(res => { this.$post(`${this.api.getLevel}?parentId=${node.level ? node.data.id : 0}`).then(res => {
// idlabel const list = res.list
function handleId(data){ this.node = node
data.map(n => { this.resolve = resolve
n.id = String(n.id) resolve(list)
n.label = n.categoryName
if(n.children.length){
handleId(n.children)
}
})
}
handleId(res)
this.typeList = res
// id // id
if (!this.edited) { if (!this.edited && list.length) {
if(res[0].children.length){ this.categoryId = list[0].id
let item = res[0].children[0] this.dataSource = list[0].dataSource
this.categoryId = item.id this.defaultActive = [list[0].id]
this.dataSource = res[0].children[0].dataSource this.introduceText = list[0].introduce
this.defaultActive = [item.id] this.introduce = list[0].introduce
this.introduceText = item.introduce
this.introduce = item.introduce
}else{
this.categoryId = res[0].id
this.dataSource = res[0].dataSource
this.defaultActive = [res[0].id]
this.introduceText = res[0].introduce
this.introduce = res[0].introduce
}
} }
this.getKeyword() this.getKeyword()
}).catch(res => {}) }).catch(res => {})

@ -80,9 +80,9 @@
<span slot="suffix">/账号</span> <span slot="suffix">/账号</span>
</el-input> </el-input>
</el-form-item> </el-form-item>
<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" v-if='configChecked.length>0'> <div class="type-wrap" ref="typeWrap" @scroll="loadType" style="display: none">
<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" 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>
@ -285,9 +285,9 @@ export default {
function handleId(data){ function handleId(data){
data.map(n => { data.map(n => {
n.originId = n.id n.originId = n.id
n.id = String(++that.typeIndex) n.id = String(++that.typeIndex) // idididoriginIdid
n.label = n.categoryName n.label = n.categoryName
n.disabled = true n.disabled = true //
if(n.children.length){ if(n.children.length){
handleId(n.children) handleId(n.children)
} }
@ -462,46 +462,37 @@ export default {
this.typeList = [] this.typeList = []
this.tableId = [] this.tableId = []
this.configChecked = [] this.configChecked = []
this.configIds = []
}, },
// 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 => { // ididid
// tableLen list.map(e => {
if(n.tableLen && n.tableLen > n.children.length) getLen++ proList.push(new Promise((resolve,reject) => {
}) this.$get(`${this.api.getAllTableIdBycategoryId}?categoryId=${e}`).then(res => {
list.map((n,i) => { res.tableId && this.tableId.push(...res.tableId.split(','))
if(n.tableLen && n.tableLen > n.children.length){ resolve()
// pageSize10000,, }).catch(res => {
this.$post(`${this.api.getIdQueryTable}?categoryId=${n.originId}&showName=&pageNum=1&pageSize=10000&updateTime=`).then(res => { this.submited = false
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()
}
}) })
}))
}) })
// idresolve
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.$refs.type.getCheckedNodes().length) return this.$message.warning('请选择数据') if(!this.checkedIds.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('请选择数据')
@ -516,7 +507,7 @@ export default {
orderNum: '', orderNum: '',
status: '', status: '',
tableNum: tableId.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 => {
@ -539,17 +530,18 @@ export default {
} }
}) })
}, },
configData(){ configData(){
this.configVisible = true this.configVisible = true
this.getConfigType() this.getConfigType()
//
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.originId) if(!n.name) configIds.push(n.originId) // nameidid
}) })
this.configIds = configIds this.configIds = configIds
}
}, },
typeConfigClick(data,node){ typeConfigClick(data,node){
this.categoryId = data.id this.categoryId = data.id
@ -605,6 +597,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 = []
// id
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)
}) })
@ -613,6 +606,7 @@ export default {
let data = res.data let data = res.data
data.map(n => { data.map(n => {
for(let i in n){ for(let i in n){
//
if(typeof n[i] == 'string' && n[i].endsWith('+0000')) n[i] = this.formatDate('yyyy-MM-dd hh:mm:ss',new Date(n[i])) if(typeof n[i] == 'string' && n[i].endsWith('+0000')) n[i] = this.formatDate('yyyy-MM-dd hh:mm:ss',new Date(n[i]))
} }
}) })
@ -626,7 +620,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.originId) && n.children[0].name){ if(checked.includes(n.originId) && n.children[0].name){ // 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)
@ -635,11 +629,12 @@ export default {
}) })
}, },
confirmConfig(){ confirmConfig(){
this.configChecked = this.$refs.typeConfig.getCheckedKeys().map(n => Number(n)) this.configChecked = this.$refs.typeConfig.getCheckedKeys().map(n => n) // id
this.getTableId(this.typeList) this.checkedIds = this.configChecked
this.checkedIds = Array.from(new Set(this.configCheckedTableId))
this.configVisible = false this.configVisible = false
this.$nextTick(() => {
this.$refs.type.setCheckedNodes(this.checkedIds) this.$refs.type.setCheckedNodes(this.checkedIds)
})
} }
} }
}; };

Loading…
Cancel
Save