产品及导入数据修改

dev
yujialong 3 years ago
parent f1ecd77ff6
commit ff1d6c3ce8
  1. 1
      src/utils/api.js
  2. 72
      src/views/data/Framework.vue
  3. 25
      src/views/data/Product.vue

@ -164,6 +164,7 @@ export default {
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`, getLevel: `${host}/data/category/getLevel`,
getAllTableInfoByCategoryId: `${host}/data/data/product/getAllTableInfoByCategoryId`,
// 产品管理 // 产品管理
deleteProduct: `${host}/data/data/product/delete`, deleteProduct: `${host}/data/data/product/delete`,

@ -70,8 +70,7 @@
<div style="overflow:auto;height: 558px;width:330px;padding:15px;background:#fff" ref="typeTreeWrap" @scroll="loadType"> <div style="overflow:auto;height: 558px;width:330px;padding:15px;background:#fff" ref="typeTreeWrap" @scroll="loadType">
<el-tree <el-tree
ref="typeTree" ref="typeTree"
:load="getType" :data="importTypeList"
lazy
node-key="id" node-key="id"
accordion accordion
:default-expanded-keys="defaultTypeActive" :default-expanded-keys="defaultTypeActive"
@ -195,7 +194,6 @@ export default {
curComment: [], curComment: [],
submited: false, submited: false,
names: [], names: [],
showNames: [],
nameVisible: false, nameVisible: false,
curRow: {}, curRow: {},
headVisible: false, headVisible: false,
@ -486,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){
@ -495,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
@ -556,63 +554,31 @@ 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(() => { const typeIds = checked.filter(e => !e.name).map(e => e.realId) // idid
let names = Array.from(new Set(this.names)) this.getNames(typeIds).then(() => {
let showNames = Array.from(new Set(this.showNames)) this.$post(this.api.saveTable, this.names).then(res => {
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],
})
})
this.$post(this.api.saveTable,data).then(res => {
this.$message.success('导入成功') this.$message.success('导入成功')
this.getData() this.getData()
this.importVisible = false this.importVisible = false
@ -623,7 +589,7 @@ export default {
this.submited = false this.submited = false
}) })
}) })
}, }
} }
}; };
</script> </script>

@ -82,7 +82,6 @@
</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"> -->
<div class="type-wrap" ref="typeWrap" @scroll="loadType" style="display: none"> <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 }">
@ -286,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)
} }
@ -471,6 +470,7 @@ export default {
let list = this.checkedIds let list = this.checkedIds
this.tableId = [] this.tableId = []
const proList = [] const proList = []
// ididid
list.map(e => { list.map(e => {
proList.push(new Promise((resolve,reject) => { proList.push(new Promise((resolve,reject) => {
this.$get(`${this.api.getAllTableIdBycategoryId}?categoryId=${e}`).then(res => { this.$get(`${this.api.getAllTableIdBycategoryId}?categoryId=${e}`).then(res => {
@ -481,6 +481,7 @@ export default {
}) })
})) }))
}) })
// idresolve
return Promise.all(proList).then(res => { return Promise.all(proList).then(res => {
resolve() resolve()
}).catch(err => {}) }).catch(err => {})
@ -490,10 +491,8 @@ export default {
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('请选择数据')
@ -508,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 => {
@ -531,15 +530,15 @@ export default {
} }
}) })
}, },
configData(){ configData(){
this.configVisible = true this.configVisible = true
this.getConfigType() this.getConfigType()
//
if (this.id) { 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
} }
@ -598,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)
}) })
@ -606,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]))
} }
}) })
@ -619,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)
@ -628,7 +629,7 @@ export default {
}) })
}, },
confirmConfig(){ confirmConfig(){
this.configChecked = this.$refs.typeConfig.getCheckedKeys().map(n => n) this.configChecked = this.$refs.typeConfig.getCheckedKeys().map(n => n) // id
this.checkedIds = this.configChecked this.checkedIds = this.configChecked
this.configVisible = false this.configVisible = false
this.$nextTick(() => { this.$nextTick(() => {

Loading…
Cancel
Save