Commit e86af82e by guoxw

物理表异常字段查询和同步

parent 9b970461
......@@ -68,6 +68,30 @@ export function getAllTemplateField(templateId) {
}
/**
* 查询模板异常字段
* @param templateId
* @returns {*}
*/
export function getTemplateErrorField(templateId) {
return request({
url: `${prefix}/fieldError`,
method: 'get',
params: {templateId}
})
}
/**
* 同步异常字段
*/
export function syncTemplateErrorField(data) {
return request({
url: `${prefix}/syncFieldError`,
method: 'post',
data
})
}
/**
* 查询模板的所有规则数据
* @param templateId
* @returns {*}
......
......@@ -15,7 +15,7 @@
</el-select>
<i class="el-icon-circle-plus-outline form_icon" @click="openYearDialog"></i>
</el-form-item>
<el-form-item label="数据类型:" label-width="80px">
<el-form-item label="机构类型:" label-width="80px">
<el-select v-model="queryForm.orgName" :popper-append-to-body="false">
<el-option v-for="item in orgDict" :key="item.id" :label="item.label" :value="item.value">
<span style="float: left">{{ item.label }}</span>
......@@ -93,6 +93,9 @@
</el-dropdown-item>
<el-dropdown-item icon="el-icon-view" @click.native="openFieldDrawer(scope.row)">查看字段
</el-dropdown-item>
<el-dropdown-item icon="el-icon-view" @click.native="openTemplateErrorDialog(scope.row)">
异常字段查询
</el-dropdown-item>
<el-dropdown-item icon="el-icon-view" @click.native="openTemplateRuleDialog(scope.row)">模板规则
</el-dropdown-item>
</el-dropdown-menu>
......@@ -275,9 +278,13 @@
<el-table-column align="center" label="指标名称" min-width="200" prop="title" show-overflow-tooltip/>
<el-table-column align="center" label="旧指标" min-width="300">
<template slot-scope="scope">
<el-select :value="scope.row.oldId" clearable filterable style="width: 100%" @change="value=>changeFieldSelect(scope.row,value)">
<el-option v-for="item in fieldDrawer.fieldDict" :key="item.id" :label="item.label" :value="item.id" />
</el-select>
<el-select :value="scope.row.oldId" clearable filterable style="width: 100%"
@change="value=>changeFieldSelect(scope.row,value)"
>
<el-option v-for="item in fieldDrawer.fieldDict" :key="item.id" :label="item.label"
:value="item.id"
/>
</el-select>
</template>
</el-table-column>
<el-table-column align="center" label="字段名" min-width="260" prop="fieldName"
......@@ -364,6 +371,46 @@
:content="analyzeData.content"
:loading="analyzeData.loading"
/>
<!-- 异常字段查询对话框 -->
<el-dialog :visible.sync="templateErrorDialog.show"
append-to-body
close-on-click-modal
title="错误字段查询"
width="80%"
>
<div style="width: 100%">
<el-form size="small">
<el-form-item>
<el-button icon="el-icon-plus" type="success" :disabled="templateErrorDialog.multiple" v-on:click="handleErrorFieldSync">同步
</el-button>
</el-form-item>
</el-form>
<el-table ref="errorFieldTable"
v-loading="templateErrorDialog.loading"
:data="templateErrorDialog.errorFieldList"
@select="selectErrorField"
@selection-change="handleErrorFieldSelectionChange"
border height="500px" max-height="500px" stripe style="width: 100%"
>
<el-table-column type="selection" min-width="55" :selectable="errorFieldSelectable"/>
<el-table-column align="center" label="字段标题" prop="title" show-overflow-tooltip
min-width="120"
/>
<el-table-column align="center" label="元字段名" prop="fieldName" show-overflow-tooltip
min-width="120"
/>
<el-table-column align="center" label="元字段类型" prop="fieldType" show-overflow-tooltip
min-width="120"
/>
<el-table-column align="center" label="物理表字段类型" prop="columnType" show-overflow-tooltip
min-width="120"
/>
<el-table-column align="center" label="物理表名" prop="tableName" show-overflow-tooltip
min-width="120"
/>
</el-table>
</div>
</el-dialog>
<!-- 模板规则 -->
<el-dialog :visible.sync="templateRuleDialog.show" append-to-body close-on-click-modal title="模板规则"
width="80%"
......@@ -431,8 +478,11 @@
>
<el-form inline size="small">
<el-form-item>
<el-button v-if="false" icon="el-icon-plus" type="success" @click="openAddOrgListDialog">添加</el-button>
<el-button :loading="orgDictDialog.loading" icon="el-icon-plus" type="success" @click="exportExcel">导出</el-button>
<el-button v-if="false" icon="el-icon-plus" type="success" @click="openAddOrgListDialog">添加
</el-button>
<el-button :loading="orgDictDialog.loading" icon="el-icon-plus" type="success" @click="exportExcel">
导出
</el-button>
</el-form-item>
<el-form-item label="查询全部">
<el-switch
......@@ -440,7 +490,8 @@
active-color="#13ce66"
active-value="1"
inactive-value="0"
@change="typeChange">
@change="typeChange"
>
</el-switch>
</el-form-item>
</el-form>
......@@ -454,7 +505,9 @@
<el-table-column align="center" label="机构地址" prop="MAILING_ADDRESS" show-overflow-tooltip/>
<el-table-column align="center" label="行政区划代码" prop="AREA_NUMBER_CODE" show-overflow-tooltip/>
<el-table-column v-if="false" align="center" label="所属市" prop="CITY" show-overflow-tooltip/>
<el-table-column :formatter="AREAFormatter" align="center" label="对应区名称" prop="AREA" show-overflow-tooltip/>
<el-table-column :formatter="AREAFormatter" align="center" label="对应区名称" prop="AREA"
show-overflow-tooltip
/>
<el-table-column align="center" label="操作" width="80">
<template slot-scope="scope">
<el-button circle icon="el-icon-edit" plain
......@@ -482,12 +535,13 @@
<el-input v-model="orgListDialog.data.MAILING_ADDRESS" autosize size="small" type="textarea"/>
</el-form-item>
<el-form-item label="行政区划代码" prop="AREA_NUMBER_CODE">
<!-- <el-input v-model="orgListDialog.data.AREA_NUMBER_CODE" size="small"/>-->
<!-- <el-input v-model="orgListDialog.data.AREA_NUMBER_CODE" size="small"/>-->
<el-autocomplete v-model="orgListDialog.data.AREA_NUMBER_CODE"
:fetch-suggestions="areaSearch"
size="small">
size="small"
>
<template slot-scope="{ item }">
{{item.suggestion}}
{{ item.suggestion }}
</template>
</el-autocomplete>
</el-form-item>
......@@ -514,7 +568,9 @@
>
<el-form size="small">
<el-form-item>
<el-button :loading="syncFieldDialog.loading" icon="el-icon-plus" type="success" @click="syncField">同步新增数据库字段</el-button>
<el-button :loading="syncFieldDialog.loading" icon="el-icon-plus" type="success" @click="syncField">
同步新增数据库字段
</el-button>
</el-form-item>
</el-form>
<el-table v-loading="syncFieldDialog.loading" :data="syncFieldDialog.list"
......@@ -547,10 +603,12 @@
>
<el-table
:data="errorDialog.data"
style="width: 100%">
style="width: 100%"
>
<el-table-column
prop="error"
label="错误信息">
label="错误信息"
>
</el-table-column>
</el-table>
</el-dialog>
......@@ -568,6 +626,7 @@ import StringUtil from '@/utils/document/StringUtil'
import AutoUpload from '@/views/emport/emport/AutoUpload.vue'
import AutoLoading from '@/views/emport/emport/AutoLoading.vue'
import ArraySelect from '@/views/emport/rule/ArraySelect.vue'
import { syncTemplateErrorField } from '@/api/emport/DataTemplate'
export default {
name: 'Emport',
......@@ -592,8 +651,8 @@ export default {
tableList: [], // 表列表
fieldDict: [], // 字段字典
metaFieldDict: [], //
errorDialog : { // 错误列表dialog
show : false,
errorDialog: { // 错误列表dialog
show: false,
data: []
},
yearDialog: { // 年份dialog
......@@ -637,7 +696,7 @@ export default {
total: 0
},
queryFieldLoading: false,
fieldDict:[], // 匹配上个模板的字段字典
fieldDict: [] // 匹配上个模板的字段字典
},
quicklyBindDialog: { // 字段dialog
show: false,
......@@ -649,6 +708,14 @@ export default {
show: false,
loading: false
},
templateErrorDialog: {// 错误字段查询dialog
template: null,
errorFieldList: [],
selectErrorFieldList: [],
show: false,
loading: false,
multiple: true
},
templateRuleDialog: { // 模板规则dialog
template: null,
ruleList: [],
......@@ -682,15 +749,15 @@ export default {
list: [],
type: ''
},
syncFieldDialog:{ // 字段同步
syncFieldDialog: { // 字段同步
show: false,
loading: false,
list: [],
checked:[]
checked: []
},
sameFieldDialog:{ // 相同字段列表
show: false,
list:[],
sameFieldDialog: { // 相同字段列表
show: false,
list: []
},
importLoading: false, // 导入数据loading
queryTemplateLoading: false, // 模板查询loading
......@@ -793,11 +860,11 @@ export default {
},
// 初始化匹配上个模板的字段字典
initFieldDict() {
DataField.queryFieldDict({templateId: this.fieldDrawer.template.id}).then(res=>{
this.fieldDrawer.fieldDict = res.data.map(item=>{
DataField.queryFieldDict({ templateId: this.fieldDrawer.template.id }).then(res => {
this.fieldDrawer.fieldDict = res.data.map(item => {
return {
id: item.id,
label: StringUtil.merge(" ",item.code,item.title),
label: StringUtil.merge(' ', item.code, item.title),
field: item.field
}
})
......@@ -966,16 +1033,16 @@ export default {
ExcelData.uploadExcel(formData)
.then((res) => {
if (res.code === 200) {
if (res.data && res.data.length > 0){
if (res.data && res.data.length > 0) {
onError()
// 弹出数据导入异常
this.errorDialog = {
show : true,
data: res.data.map(item=>{
return {error:item}
show: true,
data: res.data.map(item => {
return { error: item }
})
}
}else {
} else {
onSuccess()
}
} else {
......@@ -990,9 +1057,9 @@ export default {
triggerImport() {
if (this.queryForm.file) {
let template = this.templateList.find(item => item.orgName === this.queryForm.orgName)
if (template){
if (template) {
this.$refs.upload.submit()
}else {
} else {
this.$message.warning('没有此类型的模板,请选择其它的数据类型')
}
......@@ -1095,15 +1162,15 @@ export default {
})
},
// 字段匹配选择
changeFieldSelect(row,id){
changeFieldSelect(row, id) {
this.fieldDrawer.queryFieldLoading = true
let data = {
id: row.id,
field: ''
}
if (id){
let temp = this.fieldDrawer.fieldDict.find(item=>item.id === id)
if(temp){
if (id) {
let temp = this.fieldDrawer.fieldDict.find(item => item.id === id)
if (temp) {
data.field = temp.field
}
}
......@@ -1231,10 +1298,10 @@ export default {
return '未上传'
}
},
dataStatusFormat(row){
if (row.dataStatus){
dataStatusFormat(row) {
if (row.dataStatus) {
return '已上传'
}else{
} else {
return '未上传'
}
},
......@@ -1392,13 +1459,68 @@ export default {
}
}).finally(_ => this.syncDbLoading = false)
},
getErrorFieldList(row) {
this.templateErrorDialog.loading = true
DataTemplate.getTemplateErrorField(row.id).then(res => {
this.templateErrorDialog.errorFieldList = res.data
this.templateErrorDialog.loading = false
})
},
// 异常字段查询弹窗
openTemplateErrorDialog(row) {
this.templateErrorDialog.template = { ...row }
this.templateErrorDialog.show = true
this.getErrorFieldList(row)
},
handleErrorFieldSelectionChange(selection) {
this.templateErrorDialog.selectErrorFieldList = selection
this.templateErrorDialog.multiple = !selection.length
},
selectErrorField(selection, row) {
//校验数据类型
let fieldType = row.fieldType.substring(0, row.fieldType.indexOf('('))
let columnType = row.columnType.substring(0, row.columnType.indexOf('('))
if (fieldType !== columnType) this.$message.warning('字段类型不相同,强行同步可能会造成数据丢失!')
//校验长度
if (row.fieldType.search('NUMBER') !== -1) {
let fieldPrecision = row.fieldType.substring(row.fieldType.indexOf('(') + 1, row.fieldType.indexOf(','))
let fieldScale = row.fieldType.substring(row.fieldType.indexOf(',') + 1, row.fieldType.indexOf(')'))
let columnPrecision = row.columnType.substring(row.columnType.indexOf('(') + 1, row.columnType.indexOf(','))
let columnScale = row.columnType.substring(row.columnType.indexOf(',') + 1, row.columnType.indexOf(')'))
if (columnPrecision < fieldPrecision) this.$message.warning('字段长度减小可能会造成数据丢失!')
if (columnScale < fieldScale) this.$message.warning('字段精度减小可能会造成数据丢失!')
} else {
let fieldLength = row.fieldType.substring(row.fieldType.indexOf('(') + 1, row.fieldType.indexOf(')'))
let columnLength = row.columnType.substring(row.columnType.indexOf('(') + 1, row.columnType.indexOf(')'))
if (Number('columnLength') > Number('fieldLength')) this.$message.warning('长度减小可能会造成数据丢失!')
}
},
errorFieldSelectable(row, rowIndex) {
let flag = false
let fieldType = row.fieldType.substring(0, row.fieldType.indexOf('('))
let columnType = row.columnType.substring(0, row.columnType.indexOf('('))
if (fieldType === columnType) {
flag = true
} else if (fieldType.search('VARCHAR') !== -1 && columnType.search('VARCHAR') !== -1) {
flag = true
}
return flag
},
handleErrorFieldSync() {
console.log('selection',this.templateErrorDialog.selectErrorFieldList)
DataTemplate.syncTemplateErrorField(this.templateErrorDialog.selectErrorFieldList).then(res => {
this.getErrorFieldList(this.templateErrorDialog.template)
this.$message.success('同步成功')
})
},
// 打开模板规则弹框
openTemplateRuleDialog(row) {
this.templateRuleDialog.template = { ...row }
this.queryTemplateRule()
this.templateRuleDialog.show = true
DataTemplate.getAllTemplateField(row.id).then(res => {
console.log('模板规则查询',res)
console.log('模板规则查询', res)
this.templateRuleDialog.fieldList = res.data.map(item => {
return {
value: item.field,
......@@ -1513,13 +1635,13 @@ export default {
this.orgDictDialog.type = '0'
// 查询机构字典
DictData.queryDict('area').then(res => {
this.orgDictDialog.areaDict = res.data.map(item=>{
this.orgDictDialog.areaDict = res.data.map(item => {
return {
...item,
suggestion: StringUtil.mergeStr(item.label,item.value)
suggestion: StringUtil.mergeStr(item.label, item.value)
}
})
ExcelData.queryArea(this.queryForm.orgName, this.queryForm.year,this.orgDictDialog.type).then(res => {
ExcelData.queryArea(this.queryForm.orgName, this.queryForm.year, this.orgDictDialog.type).then(res => {
if (res.code === 200) {
this.orgDictDialog.orgList = res.data.map(item => {
if (item.AREA_NUMBER_CODE) {
......@@ -1534,16 +1656,16 @@ export default {
}).finally(_ => this.orgDictDialog.loading = false)
})
},
typeChange(){
typeChange() {
this.orgDictDialog.loading = true
ExcelData.queryArea(this.queryForm.orgName, this.queryForm.year,this.orgDictDialog.type).then(res => {
ExcelData.queryArea(this.queryForm.orgName, this.queryForm.year, this.orgDictDialog.type).then(res => {
if (res.code === 200) {
this.orgDictDialog.orgList = res.data
}
}).finally(_ => this.orgDictDialog.loading = false)
},
AREAFormatter(row){
if (row.AREA_NUMBER_CODE){
AREAFormatter(row) {
if (row.AREA_NUMBER_CODE) {
let temp = this.orgDictDialog.areaDict.find(area => area.value === row.AREA_NUMBER_CODE)
return temp ? temp.label : ''
}
......@@ -1639,36 +1761,36 @@ export default {
})
},
// 导出修改后的excel
exportExcel(){
exportExcel() {
this.orgDictDialog.loading = true
ExcelData.exportExcel(this.queryForm.orgName, this.queryForm.year).then(async res=>{
ExcelData.exportExcel(this.queryForm.orgName, this.queryForm.year).then(async res => {
const isFile = await ExcelData.blobValidate(res)
if (isFile) {
saveAs(res, this.queryForm.orgName+this.queryForm.year+"年.xlsx")
saveAs(res, this.queryForm.orgName + this.queryForm.year + '年.xlsx')
}
}).finally(_=>this.orgDictDialog.loading = false)
}).finally(_ => this.orgDictDialog.loading = false)
},
// 字段同步
querySyncField(){
querySyncField() {
this.syncFieldDialog.show = true
this.syncFieldDialog.loading = true
this.syncFieldDialog.checked = []
DataField.querySyncField(this.fieldDrawer.template.id).then(res=>{
DataField.querySyncField(this.fieldDrawer.template.id).then(res => {
this.syncFieldDialog.list = res.data
}).finally(_=>this.syncFieldDialog.loading = false)
}).finally(_ => this.syncFieldDialog.loading = false)
},
syncField(){
if (this.syncFieldDialog.checked && this.syncFieldDialog.checked.length > 0){
syncField() {
if (this.syncFieldDialog.checked && this.syncFieldDialog.checked.length > 0) {
this.syncFieldDialog.loading = true
DataField.syncField(this.syncFieldDialog.checked).then(res=>{
if (res.code === 200){
this.$message.success("新增字段成功")
DataField.syncField(this.syncFieldDialog.checked).then(res => {
if (res.code === 200) {
this.$message.success('新增字段成功')
this.syncFieldDialog.show = false
}
}).finally(_=>this.syncFieldDialog.loading = false)
}).finally(_ => this.syncFieldDialog.loading = false)
}
},
handleSelectionChange(val){
handleSelectionChange(val) {
this.syncFieldDialog.checked = val
},
areaSearch(qs, callback) {
......@@ -1686,17 +1808,17 @@ export default {
callback(this.orgDictDialog.areaDict)
}
},
sameFieldCheck(){
sameFieldCheck() {
let templateId = this.fieldDrawer.template.id
DataField.sameFieldCheck(templateId).then(res=>{
if (!res.data || res.data.length === 0){
this.$message.success("无重复字段,可建表")
}else {
DataField.sameFieldCheck(templateId).then(res => {
if (!res.data || res.data.length === 0) {
this.$message.success('无重复字段,可建表')
} else {
this.sameFieldDialog.list = res.data
this.sameFieldDialog.show = true
}
})
},
}
}
}
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment