Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/views/data/Introduce.vue
dev_2022-03-03
e 3 years ago
commit 880d7e1795
  1. 179
      src/views/data/Framework.vue
  2. 24
      src/views/data/Introduce.vue
  3. 27
      src/views/data/Product.vue

@ -1,6 +1,7 @@
<template>
<div class="wrap">
<el-container>
<!-- 左边的分类 -->
<el-aside width="300px">
<div class="plus">
<i class="el-icon-circle-plus-outline" @click.stop="addType(0)"></i>
@ -16,7 +17,7 @@
</span>
</el-tree>
</el-aside>
<!-- 右边的表 -->
<el-main style="padding-top: 0">
<el-card class="main-wrap" shadow="hover">
<el-form label-width="80px" class="flex-between mgb20">
@ -64,7 +65,7 @@
</el-card>
</el-main>
</el-container>
<!-- 导入数据 -->
<el-dialog title="导入" :visible.sync="importVisible" width="80%" center @close="closeImport" class="dialog" :close-on-click-modal="false">
<el-container style="padding: 20px 0 20px 20px;background-color: #f0f0f0;">
<div style="overflow:auto;height: 558px;width:330px;padding:15px;background:#fff" ref="typeTreeWrap" @scroll="loadType">
@ -104,7 +105,7 @@
<el-button type="primary" :loading="submited" @click="confirmImport"> </el-button>
</span>
</el-dialog>
<!-- 新增编辑分类 -->
<el-dialog :title="id ? '编辑分类' : '新增分类'" :visible.sync="typeVisible" width="24%" center @close="closeType" :close-on-click-modal="false">
<el-input placeholder="请输入分类名称" v-model="categoryName"></el-input>
<span slot="footer" class="dialog-footer">
@ -112,14 +113,14 @@
<el-button type="primary" @click="confirmType"> </el-button>
</span>
</el-dialog>
<!-- 预览 -->
<el-dialog title="预览" :visible.sync="previewVisible" width="60%" center :close-on-click-modal="false">
<el-table :data="previewData" class="table" stripe header-align="center" row-key="id">
<el-table-column type="index" width="100" label="序号" align="center"></el-table-column>
<el-table-column v-for="(item,index) in previewHead" :prop="item.field" :key="index" :label="item.comment" align="center"></el-table-column>
</el-table>
</el-dialog>
<!-- 编辑产品数据表名称 -->
<el-dialog title="编辑产品数据表名称" :visible.sync="nameVisible" width="24%" center :close-on-click-modal="false">
<el-input placeholder="请输入产品数据表名称" v-model="curRow.showName"></el-input>
<span slot="footer" class="dialog-footer">
@ -127,7 +128,7 @@
<el-button type="primary" @click="confirmName"> </el-button>
</span>
</el-dialog>
<!-- 自定义表头 -->
<el-dialog title="自定义表头" :visible.sync="headVisible" width="60%" center :close-on-click-modal="false">
<el-table :data="previewData" class="table" stripe header-align="center" row-key="id" :key="editIndex">
<el-table-column type="index" width="100" label="序号" align="center">
@ -162,7 +163,7 @@ export default {
label: 'label'
},
defaultActive: [],
added: false,
addEd: false,
typeVisible: false,
categoryName: '',
categoryId: '',
@ -194,7 +195,7 @@ export default {
previewData: [],
curComment: [],
submited: false,
names: [],
categorys: [],
nameVisible: false,
curRow: {},
headVisible: false,
@ -216,6 +217,7 @@ export default {
this.getType()
},
methods: {
//
getType(){
this.$post(this.api.getTableByClassification).then(res => {
// ,
@ -230,29 +232,31 @@ export default {
})
}
handleId(res)
this.typeList = res
if (!this.added) {
if(res[0].children.length){
// addEd
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
//
this.$nextTick(() => {
this.$refs.type.setCurrentKey(res[0].children[0].id)
this.$refs.type.setCurrentKey(this.categoryId)
})
}
this.added = false
this.addEd = false // false
this.getData()
}).catch(res => {})
},
//
getData(){
this.$post(`${this.api.getIdQueryTable}?categoryId=${this.categoryId}&showName=${this.keyword}&pageNum=${this.page}&pageSize=${this.pageSize}&updateTime=${this.updateTime ? this.updateTime : ''}`).then(res => {
const list = res.pageList.records
list.map(e => {
//
const startTime = e.startTime ? e.startTime.slice(0, 10) : ''
const endTime = e.endTime ? e.endTime.slice(0, 10) : ''
if (startTime && endTime) {
@ -267,40 +271,46 @@ export default {
this.total = res.pageList.total
}).catch(res => {})
},
// 1
initData(){
this.page = 1
this.getData()
},
//
typeClick(data,node){
this.categoryId = data.id
this.getData()
},
//
addType(row){
if (row) this.defaultActive = [row.data.id]
if (row) this.defaultActive = [row.data.id] // idrow0
this.typeVisible = true
this.levelId = row ? row.data.id : 0
this.levelId = row ? row.data.id : 0 // levelIdidid0
},
//
editType(row){
this.typeVisible = true
this.id = row.data.id
this.categoryName = row.data.categoryName
},
//
delType(row){
//
this.$confirm('确定要删除吗?', '提示', {
type: 'warning'
}).then(() => {
this.added = true
this.addEd = true
this.$post(`${this.api.deleteCategory}?categoryId=${row.data.id}`).then(res => {
this.$message.success('删除成功')
this.getType()
}).catch(res => {})
}).catch(() => {})
},
//
confirmType(){
if(this.submited) return false
if(this.submited) return false //
this.submited = true
this.added = true
this.addEd = true
if(this.id){
this.$post(this.api.updateCategory,{
id: this.id,
@ -331,22 +341,30 @@ export default {
})
}
},
//
closeType(){
this.id = 0
this.levelId = 0
this.categoryName = ''
},
/**
* 表预览
* @param row 行数据
* @param isEdit 是否是从自定义表头进来的
*/
preview(row, isEdit){
this.$get(`${this.api.previewData}?tableName=${row.name}&tableId=${row.id}`).then(res => {
let comment = res.comment
let previewHead = []
this.curComment = comment
this.curComment = comment //
comment.map(n => {
// id
n.field != 'id' && n.field != 'operation_time' && previewHead.push(n)
})
this.previewHead = previewHead
let data = res.data
// custom
isEdit && data.unshift({
custom: true
})
@ -357,9 +375,10 @@ export default {
}
})
this.previewData = data
if (!isEdit) this.previewVisible = true
if (!isEdit) this.previewVisible = true //
}).catch(res => {})
},
//
delTable(row){
this.$confirm('确定要删除吗?', '提示', {
type: 'warning'
@ -370,10 +389,12 @@ export default {
}).catch(res => {})
}).catch(() => {})
},
//
editName(row){
this.curRow = JSON.parse(JSON.stringify(row))
this.nameVisible = true
},
//
confirmName(){
this.$post(this.api.editTableName, {
id: this.curRow.id,
@ -384,12 +405,14 @@ export default {
this.getData()
}).catch(res => {})
},
//
editHead(row){
this.curRow = JSON.parse(JSON.stringify(row))
this.preview(row, 1)
this.editIndex++
this.editIndex++ //
this.headVisible = true
},
//
confirmHead(){
let data = JSON.parse(JSON.stringify(this.curComment))
this.$post(`${this.api.updateTableCommit}?tableName=${this.curRow.name}`, data).then(res => {
@ -487,9 +510,12 @@ export default {
n.typeTreePage++
}).catch(res => {})
},
//
batchImport(){
//
this.$post(this.api.originalList).then(res => {
const that = this
// idlabelnamekeylabelnamekey
function handleId(data){
data.map(n => {
that.importTypeIndex++
@ -503,10 +529,12 @@ export default {
})
}
handleId(res)
// pageSize3000
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)
this.defaultTypeChecked = list.map(n => n.copyId) // copyIdidid
const that = this
//
function handleId(data){
data.map(n => {
if(n.children.length){
@ -519,7 +547,17 @@ export default {
})
}
handleId(res)
//
function handleDisabled (list) {
list.map(e => {
if (e.children && e.children.length) {
if (e.children.every(e => e.disabled)) e.disabled = true
handleDisabled(e.children)
}
})
}
setTimeout(() => {
handleDisabled(res)
this.importTypeList = res
},500)
}).catch(res => {})
@ -527,6 +565,7 @@ export default {
this.importVisible = true
}).catch(res => {})
},
//
getFields(){
this.$get(`${this.api.staticPreview}?tableName=${this.tableName}`).then(res => {
let comment = res.comment
@ -548,6 +587,7 @@ export default {
}).catch(res => {})
this.importVisible = true
},
//
importTypeClick(data){
// ,,
if(data.name){
@ -561,48 +601,74 @@ export default {
this.curExpand = obj.id
this.renderChecked()
},
//
closeImport(){
this.$refs.typeTree.setCheckedKeys([])
this.names = []
this.categorys = []
},
// namesshowNames,
// id
getNames(list){
const categoryId = Number(this.categoryId)
return new Promise((resolve,reject) => {
// idid
this.$get(`${this.api.getAllTableInfoByCategoryId}?categoryId=${list.join()}`).then(res => {
const list = res.tableInfo
list.map(e => {
delete e.id
delete e.id // id
e.categoryId = categoryId
})
this.names = list
this.categorys = list
resolve()
}).catch(res => {})
})
},
//
saveSuccess() {
this.$message.success('导入成功')
this.getData()
this.importVisible = false
setTimeout(() => {
this.submited = false
},1000)
},
//
confirmImport(){
if(this.submited) return false
const checked = this.$refs.typeTree.getCheckedNodes() //
if(this.submited) return false //
const checked = this.$refs.typeTree.getCheckedNodes().filter(e => !e.disabled) //
//
if(!checked.length) return this.$message.warning('请选择数据')
this.submited = true
const typeIds = checked.filter(e => !e.name).map(e => e.realId) // idid
const tableIds = checked.filter(e => e.name)
const categoryId = Number(this.categoryId)
// ididid
const typeIds = checked.filter(e => !e.name).map(e => e.realId) // idnamenameididididrealIdid
const tableIds = checked.filter(e => e.name) //
const categoryId = Number(this.categoryId) //
// categoryId
tableIds.map(e => {
delete e.id
e.categoryId = categoryId
})
/**
* 根据某个值给数组对象去重
* @param arr 要处理的数组
* @param val 去重依据的值
*/
function uniq (arr, val) {
const res = new Map()
return arr.filter(e => !res.has(e[val]) && res.set(e[val], 1))
}
// ididid
if (typeIds.length) {
this.getNames(typeIds).then(() => {
const data = this.names
const allIds = [...this.categorys, ...tableIds] // idid
const data = uniq(allIds, 'name')
const dataList = []
// 2000
for (let i = 0, len = data.length; i < len; i += 2000) {
dataList.push(data.slice(i, i + 2000))
}
const promiseList = []
dataList.map(e => {
// 2000item6item6item2000item6item6item2000666
if (dataList.length > 6) {
dataList.slice(0, 6).map(e => {
promiseList.push(new Promise((resolve,reject) => {
this.$post(this.api.saveTable, e).then(res => {
resolve()
@ -612,24 +678,43 @@ export default {
}))
})
Promise.all(promiseList).then(res => {
this.$message.success('导入成功')
this.getData()
this.importVisible = false
setTimeout(() => {
this.submited = false
},1000)
dataList.slice(6).map(e => {
promiseList.push(new Promise((resolve,reject) => {
this.$post(this.api.saveTable, e).then(res => {
resolve()
}).catch(res => {
reject()
})
}))
})
Promise.all(promiseList).then(res => {
this.saveSuccess()
}).catch(err => {
this.submited = false
})
}).catch(err => {
this.submited = false
})
} else {
this.$post(this.api.saveTable, tableIds).then(res => {
this.$message.success('导入成功')
this.getData()
this.importVisible = false
setTimeout(() => {
dataList.map(e => {
promiseList.push(new Promise((resolve,reject) => {
this.$post(this.api.saveTable, e).then(res => {
resolve()
}).catch(res => {
reject()
})
}))
})
Promise.all(promiseList).then(res => {
this.saveSuccess()
}).catch(err => {
this.submited = false
},1000)
})
}
})
} else { //
this.$post(this.api.saveTable, tableIds).then(res => {
this.saveSuccess()
}).catch(res => {
this.submited = false
})

@ -24,7 +24,6 @@
<p class="label">数据源</p>
<el-input style="width: 250px" placeholder="请输入数据源" v-model="dataSource" type="text" :disabled="!editing"></el-input>
</div>
</template>
<div class="field">
<p class="label">关键字</p>
@ -124,6 +123,7 @@ export default {
this.getKeyword()
}).catch(res => {})
},
//
typeClick(data,node){
this.editing = false
this.categoryId = data.id
@ -133,6 +133,7 @@ export default {
this.dataSource = data.dataSource
this.getKeyword()
},
//
getKeyword(){
this.$get(this.api.getKeywordByCategoryId,{
categoryId: this.categoryId
@ -140,12 +141,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,
@ -158,6 +161,7 @@ export default {
this.getData()
}).catch(res => {})
},
//
delKeyword(item) {
this.$post(`${this.api.deleteKeyword}?categoryId=${this.categoryId}&keyword=${item.keyword}`).then(res => {
this.$message.success('删除成功')
@ -180,20 +184,24 @@ export default {
this.confirmEdit()
}
},
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()
}
}
}

@ -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(() => {

Loading…
Cancel
Save