产品及导入数据修改

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`,
updateTableCommit: `${host}/data/data/updateTableCommit`,
getLevel: `${host}/data/category/getLevel`,
getAllTableInfoByCategoryId: `${host}/data/data/product/getAllTableInfoByCategoryId`,
// 产品管理
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">
<el-tree
ref="typeTree"
:load="getType"
lazy
:data="importTypeList"
node-key="id"
accordion
:default-expanded-keys="defaultTypeActive"
@ -195,7 +194,6 @@ export default {
curComment: [],
submited: false,
names: [],
showNames: [],
nameVisible: false,
curRow: {},
headVisible: false,
@ -486,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){
@ -495,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
@ -556,63 +554,31 @@ 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)
}
// idid
this.$get(`${this.api.getAllTableInfoByCategoryId}?categoryId=${list.join()}`).then(res => {
const list = res.tableInfo
list.map(e => {
delete e.id
e.categoryId = categoryId
})
// 0,resolve
if(!getLen) resolve()
this.names = list
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()
}
})
})
},
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],
})
})
this.$post(this.api.saveTable,data).then(res => {
if(!checked.length) return this.$message.warning('请选择数据')
const typeIds = checked.filter(e => !e.name).map(e => e.realId) // idid
this.getNames(typeIds).then(() => {
this.$post(this.api.saveTable, this.names).then(res => {
this.$message.success('导入成功')
this.getData()
this.importVisible = false
@ -623,7 +589,7 @@ export default {
this.submited = false
})
})
},
}
}
};
</script>

@ -82,7 +82,6 @@
</el-form-item>
<el-form-item label="配置数据">
<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">
<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 }">
@ -286,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)
}
@ -471,6 +470,7 @@ export default {
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 => {
@ -481,6 +481,7 @@ export default {
})
}))
})
// idresolve
return Promise.all(proList).then(res => {
resolve()
}).catch(err => {})
@ -490,10 +491,8 @@ export default {
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('请选择数据')
@ -508,7 +507,7 @@ export default {
orderNum: '',
status: '',
tableNum: tableId.length,
updateTime: '',
updateTime: ''
}
if(this.id){
this.$post(this.api.updateProduct,data).then(res => {
@ -531,15 +530,15 @@ export default {
}
})
},
configData(){
this.configVisible = true
this.getConfigType()
//
if (this.id) {
let list = this.$refs.type.getCheckedNodes()
let configIds = []
list.map(n => {
if(!n.name) configIds.push(n.originId)
if(!n.name) configIds.push(n.originId) // nameidid
})
this.configIds = configIds
}
@ -598,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)
})
@ -606,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]))
}
})
@ -619,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)
@ -628,7 +629,7 @@ export default {
})
},
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.configVisible = false
this.$nextTick(() => {

Loading…
Cancel
Save