Merge branch 'dev'

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

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

@ -5,7 +5,7 @@
<div class="plus">
<i class="el-icon-circle-plus-outline" @click.stop="addType(0)"></i>
</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 :title="node.label">{{ node.label }}</span>
<span class="actions">
@ -156,10 +156,9 @@
export default {
data() {
return {
typeList: [],
defaultProps: {
children: 'children',
label: 'label'
label: 'categoryName'
},
defaultActive: [],
added: false,
@ -195,11 +194,13 @@ export default {
curComment: [],
submited: false,
names: [],
showNames: [],
nameVisible: false,
curRow: {},
headVisible: false,
editIndex: 0
editIndex: 0,
node: [],
resolve: null,
curNode: {}
};
},
watch: {
@ -210,37 +211,20 @@ export default {
},500)
}
},
mounted(){
this.getType()
},
mounted(){},
methods: {
getType(){
this.$post(this.api.getTableByClassification).then(res => {
// ,
function handleId(data,level = 0){
data.map(n => {
n.id = String(n.id)
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
getType(node, resolve){
this.$post(`${this.api.getLevel}?parentId=${node.level ? node.data.id : 0}`).then(res => {
const list = res.list
this.node = node
this.resolve = resolve
resolve(list)
// id
if (!this.added && list.length) {
this.categoryId = list[0].id
this.defaultActive = [list[0].id]
this.$nextTick(() => {
this.$refs.type.setCurrentKey(res[0].children[0].id)
this.$refs.type.setCurrentKey(list[0].id)
})
}
this.added = false
@ -274,6 +258,7 @@ export default {
this.getData()
},
addType(row){
this.categoryId = row.data.id
if (row) this.defaultActive = [row.data.id]
this.typeVisible = true
this.levelId = row ? row.data.id : 0
@ -282,6 +267,8 @@ export default {
this.typeVisible = true
this.id = row.data.id
this.categoryName = row.data.categoryName
this.curNode = row
this.categoryId = row.data.id
},
delType(row){
//
@ -291,7 +278,7 @@ export default {
this.added = true
this.$post(`${this.api.deleteCategory}?categoryId=${row.data.id}`).then(res => {
this.$message.success('删除成功')
this.getType()
this.$refs.type.remove(row)
}).catch(res => {})
}).catch(() => {})
},
@ -305,7 +292,9 @@ export default {
categoryName: this.categoryName
}).then(res => {
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
setTimeout(() => {
this.submited = false
@ -319,7 +308,10 @@ export default {
categoryName: this.categoryName
}).then(res => {
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
setTimeout(() => {
this.submited = false
@ -492,7 +484,7 @@ export default {
data.map(n => {
that.importTypeIndex++
n.realId = n.id
// idid,,
// idid,
n.id = String(that.importTypeIndex + n.id)
n.label = n.categoryName
if(n.children.length){
@ -501,7 +493,7 @@ export default {
})
}
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
this.defaultTypeChecked = list.map(n => n.copyId)
const that = this
@ -562,74 +554,58 @@ export default {
closeImport(){
this.$refs.typeTree.setCheckedKeys([])
this.names = []
this.showNames = []
},
// namesshowNames,
getNames(){
//
let list = this.$refs.typeTree.getCheckedNodes()
getNames(list){
const categoryId = Number(this.categoryId)
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){
// 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
if(!getLen) resolve()
}).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()
}
})
// idid
this.$get(`${this.api.getAllTableInfoByCategoryId}?categoryId=${list.join()}`).then(res => {
const list = res.tableInfo
list.map(e => {
delete e.id
e.categoryId = categoryId
})
this.names = list
resolve()
}).catch(res => {})
})
},
confirmImport(){
if(this.submited) return false
const checked = this.$refs.typeTree.getCheckedNodes() //
//
if(!this.$refs.typeTree.getCheckedNodes().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
let data = []
let categoryId = Number(this.categoryId)
names.map((n,i) => {
data.push({
categoryId,
name: n,
showName: showNames[i],
})
if(!checked.length) return this.$message.warning('请选择数据')
this.submited = true
const typeIds = checked.filter(e => !e.name).map(e => e.realId) // idid
this.getNames(typeIds).then(() => {
const data = this.names
const dataList = []
for (let i = 0, len = data.length; i < len; i += 2000) {
dataList.push(data.slice(i, i + 2000))
}
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.getData()
this.importVisible = false
setTimeout(() => {
this.submited = false
},1000)
}).catch(res => {
}).catch(err => {
this.submited = false
})
})
},
}
}
};
</script>

@ -2,7 +2,7 @@
<div>
<el-container>
<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-main style="padding-top: 0">
@ -56,10 +56,9 @@
export default {
data() {
return {
typeList: [],
defaultProps: {
children: 'children',
label: 'label'
label: 'categoryName'
},
defaultActive: [],
editing: false,
@ -69,7 +68,10 @@ export default {
introduceText: '',
categoryId: '',
keywordList: [],
newKeyword: ''
newKeyword: '',
node: [],
resolve: null,
curNode: {}
};
},
watch: {
@ -80,42 +82,22 @@ export default {
},500)
}
},
mounted(){
this.getData()
},
mounted(){},
methods: {
getData(){
getData(node, resolve){
//
this.$post(this.api.getTableByClassification).then(res => {
// idlabel
function handleId(data){
data.map(n => {
n.id = String(n.id)
n.label = n.categoryName
if(n.children.length){
handleId(n.children)
}
})
}
handleId(res)
this.typeList = res
this.$post(`${this.api.getLevel}?parentId=${node.level ? node.data.id : 0}`).then(res => {
const list = res.list
this.node = node
this.resolve = resolve
resolve(list)
// id
if (!this.edited) {
if(res[0].children.length){
let item = res[0].children[0]
this.categoryId = item.id
this.dataSource = res[0].children[0].dataSource
this.defaultActive = [item.id]
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
}
if (!this.edited && list.length) {
this.categoryId = list[0].id
this.dataSource = list[0].dataSource
this.defaultActive = [list[0].id]
this.introduceText = list[0].introduce
this.introduce = list[0].introduce
}
this.getKeyword()
}).catch(res => {})

@ -80,9 +80,9 @@
<span slot="suffix">/账号</span>
</el-input>
</el-form-item>
<el-form-item label="已选数据">
<el-form-item label="配置数据">
<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">
<span class="custom-tree-node" slot-scope="{ node, data }">
<span :title="node.label">{{ node.label }}</span>
@ -285,9 +285,9 @@ export default {
function handleId(data){
data.map(n => {
n.originId = n.id
n.id = String(++that.typeIndex)
n.id = String(++that.typeIndex) // idididoriginIdid
n.label = n.categoryName
n.disabled = true
n.disabled = true //
if(n.children.length){
handleId(n.children)
}
@ -462,46 +462,37 @@ export default {
this.typeList = []
this.tableId = []
this.configChecked = []
this.configIds = []
},
// tableId,
getIds(){
//
let list = this.$refs.type.getCheckedNodes()
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){
// 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))
})
// 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()
}
})
let list = this.checkedIds
this.tableId = []
const proList = []
// ididid
list.map(e => {
proList.push(new Promise((resolve,reject) => {
this.$get(`${this.api.getAllTableIdBycategoryId}?categoryId=${e}`).then(res => {
res.tableId && this.tableId.push(...res.tableId.split(','))
resolve()
}).catch(res => {
this.submited = false
})
}))
})
// idresolve
return Promise.all(proList).then(res => {
resolve()
}).catch(err => {})
},
confirm(){
if(this.submited) 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.checkedIds.length) return this.$message.warning('请选择数据')
this.submited = true //
this.getIds().then(() => {
let tableId = Array.from(new Set(this.tableId))
if(!tableId.length) return this.$message.warning('请选择数据')
@ -516,7 +507,7 @@ export default {
orderNum: '',
status: '',
tableNum: tableId.length,
updateTime: '',
updateTime: ''
}
if(this.id){
this.$post(this.api.updateProduct,data).then(res => {
@ -539,17 +530,18 @@ 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
//
if (this.id) {
let list = this.$refs.type.getCheckedNodes()
let configIds = []
list.map(n => {
if(!n.name) configIds.push(n.originId) // nameidid
})
this.configIds = configIds
}
},
typeConfigClick(data,node){
this.categoryId = data.id
@ -605,6 +597,7 @@ export default {
this.$get(`${this.api.previewData}?tableName=${row.name}&tableId=${row.id}`).then(res => {
let comment = res.comment
let previewHead = []
// id
comment.map(n => {
n.field != 'id' && n.field != 'operation_time' && previewHead.push(n)
})
@ -613,6 +606,7 @@ export default {
let data = res.data
data.map(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]))
}
})
@ -626,7 +620,7 @@ export default {
list.map(n => {
if(n.children && n.children.length){
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)]
}else{
this.getTableId(n.children)
@ -635,11 +629,12 @@ 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.configChecked = this.$refs.typeConfig.getCheckedKeys().map(n => n) // id
this.checkedIds = this.configChecked
this.configVisible = false
this.$refs.type.setCheckedNodes(this.checkedIds)
this.$nextTick(() => {
this.$refs.type.setCheckedNodes(this.checkedIds)
})
}
}
};

Loading…
Cancel
Save