Merge branch 'dev' of ssh://git.czcyedu.com:222/huoran/FE_middlePlatform_server into dev

dev
luoJunYong.123 3 years ago
commit babd4bc261
  1. 112
      src/views/data/Framework.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: '',
@ -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,6 +547,7 @@ export default {
})
}
handleId(res)
//
function handleDisabled (list) {
list.map(e => {
if (e.children && e.children.length) {
@ -536,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
@ -557,6 +587,7 @@ export default {
}).catch(res => {})
this.importVisible = true
},
//
importTypeClick(data){
// ,,
if(data.name){
@ -570,19 +601,19 @@ export default {
this.curExpand = obj.id
this.renderChecked()
},
//
closeImport(){
this.$refs.typeTree.setCheckedKeys([])
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.categorys = list
@ -590,6 +621,7 @@ export default {
}).catch(res => {})
})
},
//
saveSuccess() {
this.$message.success('导入成功')
this.getData()
@ -598,32 +630,43 @@ export default {
this.submited = false
},1000)
},
//
confirmImport(){
if(this.submited) return false
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 allIds = [...this.categorys, ...tableIds]
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 = []
// 2000item6item6item2000item6item6item2000666
if (dataList.length > 6) {
dataList.slice(0, 6).map(e => {
promiseList.push(new Promise((resolve,reject) => {
@ -669,14 +712,9 @@ export default {
})
}
})
} else {
} else { //
this.$post(this.api.saveTable, tableIds).then(res => {
this.$message.success('导入成功')
this.getData()
this.importVisible = false
setTimeout(() => {
this.submited = false
},1000)
this.saveSuccess()
}).catch(res => {
this.submited = false
})

Loading…
Cancel
Save