Commit 88fca213 by 刘泽志

最终版本

parent a9c80479
......@@ -462,3 +462,44 @@ export function getAllTemplateRule(templateId) {
params:{templateId}
})
}
/**
* 新增规则
* @param data
* @returns {*}
*/
export function addRuleByTemplate(data) {
return request({
url: `${prefix}/rule/template`,
method: 'post',
data
})
}
/**
* 修改规则
* @param data
* @returns {*}
*/
export function updateRuleByTemplate(data) {
return request({
url: `${prefix}/rule/template`,
method: 'put',
data
})
}
/**
* 删除规则
* @param ruleId
* @param templateId
* @returns {*}
*/
export function deleteRuleByTemplate(ruleId,templateId) {
return request({
url: `${prefix}/rule/template`,
method: 'delete',
params:{ruleId,templateId}
})
}
......@@ -31,4 +31,8 @@ export default class StringUtil {
return !this.isEmpty(item)
}).join(" - ")
}
static mergeRule(code,title){
return `${code}${title?title:''})`
}
}
......@@ -47,9 +47,10 @@
<el-form-item>
<el-button icon="el-icon-pie-chart" plain
size="small"
style="margin-left:6px;" @click="analyzeExport">分析并导出
style="margin-left:6px;" @click="analyzeExport"
>分析并导出
</el-button>
<el-button size="small" icon="el-icon-set-up" plain>设置机构字典</el-button>
<el-button icon="el-icon-set-up" plain size="small" @click="openOrgDictDialog">设置机构字典</el-button>
<el-button size="small" icon="el-icon-refresh" plain :loading="clearTempLoading" @click="clearTemp">
清空数据
</el-button>
......@@ -100,7 +101,9 @@
<div style="margin-left:6px;margin-bottom: 8px;">
<span style="font-size: 14px;color: #E6A23C;">温馨提示:分析后,数据没有问题再往正式库中导入数据!</span>
</div>
<el-button icon="el-icon-upload" plain size="small" style="margin-left:6px;" :loading="syncDbLoading" @click="syncDb">
<el-button :loading="syncDbLoading" icon="el-icon-upload" plain size="small" style="margin-left:6px;"
@click="syncDb"
>
一键导入正式库
</el-button>
<span></span>
......@@ -335,19 +338,131 @@
<!-- 分析loading -->
<AutoLoading
:content="analyzeData.content"
:loading="analyzeData.loading"/>
:loading="analyzeData.loading"
/>
<!-- 模板规则 -->
<el-dialog :visible.sync="templateRuleDialog.show" append-to-body close-on-click-modal title="模板规则"
width="400px"
width="80%"
>
<el-form ref="orgForm" label-width="100px" size="small">
<el-form-item label="规则" prop="ruleId">
<el-select v-model="quicklyBindDialog.ruleId" size="small">
<el-option v-for="item in ruleDict" :key="item.value" :label="item.label" :value="item.value"/>
<el-form size="small">
<el-form-item>
<el-button icon="el-icon-plus" type="success" @click="openRuleAddDialog">添加</el-button>
</el-form-item>
</el-form>
<el-table v-loading="templateRuleDialog.loading" :data="templateRuleDialog.ruleList"
border height="500px" max-height="500px" stripe
>
<el-table-column align="center" type="index" width="50"/>
<el-table-column align="center" label="规则名称" prop="name" show-overflow-tooltip width="180"/>
<el-table-column align="center" label="验证模式" prop="mode" show-overflow-tooltip width="120"
/>
<el-table-column :formatter="contentFormat" align="center" label="验证内容" min-width="200" prop="content"
show-overflow-tooltip
/>
<el-table-column align="center" label="操作" width="120">
<template slot-scope="scope">
<el-button circle icon="el-icon-edit" plain
size="small" type="primary" @click.stop="updateRuleByTemplate(scope.row)"
></el-button>
<el-button circle icon="el-icon-delete" plain
size="small" type="danger" @click.stop="deleteRuleByTemplate(scope.row)"
></el-button>
</template>
</el-table-column>
</el-table>
</el-dialog>
<!--规则增改-->
<el-dialog :close-on-click-modal="false" :title="ruleDialog.title" :visible.sync="ruleDialog.show"
append-to-body width="400px"
>
<el-form ref="ruleForm" :model="ruleDialog.data" label-width="80px">
<el-form-item label="规则名称" prop="name" required>
<el-input v-model="ruleDialog.data.name" size="small"/>
</el-form-item>
<el-form-item label="验证模式" prop="mode" required>
<el-select v-model="ruleDialog.data.mode" size="small" style="width: 160px" @change="modeChange">
<el-option label="逻辑相加" value="逻辑相加"/>
</el-select>
</el-form-item>
<span style="font-size: 13px;color: #F56C6C">设置后将为每一条字段添加此规则!</span>
<!--id1,id2=id1,id2-->
<el-form-item prop="content">
<ArraySelect v-if="ruleDialog.data.mode === '逻辑相加'"
v-model="ruleDialog.data.content"
:data="templateRuleDialog.fieldList"
/>
</el-form-item>
<el-form-item label="备注" prop="remarks">
<el-input v-model="ruleDialog.data.remarks" placeholder="备注" type="textarea"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitRule">确 定</el-button>
<el-button @click="ruleDialog.show = false">取 消</el-button>
</div>
</el-dialog>
<!-- 机构字典 -->
<el-dialog :visible.sync="orgDictDialog.show" append-to-body close-on-click-modal title="设置机构字典"
width="80%"
>
<el-form size="small">
<el-form-item>
<el-button icon="el-icon-plus" type="success" @click="openAddOrgListDialog">添加</el-button>
</el-form-item>
</el-form>
<el-table v-loading="orgDictDialog.loading" :data="orgDictDialog.orgList"
border height="500px" max-height="500px" stripe
>
<el-table-column align="center" type="index" width="50"/>
<el-table-column align="center" label="标识" prop="value" show-overflow-tooltip/>
<el-table-column align="center" label="机构类型" prop="orgType" show-overflow-tooltip/>
<el-table-column align="center" label="机构名称" prop="label" show-overflow-tooltip/>
<el-table-column align="center" label="机构地址" prop="address" show-overflow-tooltip/>
<el-table-column align="center" label="行政区划代码" prop="unifiedCode" show-overflow-tooltip/>
<el-table-column align="center" label="所属市" prop="city" show-overflow-tooltip/>
<el-table-column align="center" label="所属区" prop="region" show-overflow-tooltip/>
<el-table-column align="center" label="操作" width="120">
<template slot-scope="scope">
<el-button circle icon="el-icon-edit" plain
size="small" type="primary" @click.stop="openUpdateOrgListDialog(scope.row)"
></el-button>
<el-button circle icon="el-icon-delete" plain
size="small" type="danger" @click.stop="deleteOrgList(scope.row)"
></el-button>
</template>
</el-table-column>
</el-table>
</el-dialog>
<!--机构增改-->
<el-dialog :close-on-click-modal="false" :title="orgListDialog.title" :visible.sync="orgListDialog.show"
append-to-body width="500px"
>
<el-form ref="orgListForm" :model="orgListDialog.data" label-width="100px">
<el-form-item label="标识" prop="value" required>
<el-input v-model="orgListDialog.data.value" size="small"/>
</el-form-item>
<el-form-item label="机构类型" prop="orgType" required>
<el-input v-model="orgListDialog.data.orgType" size="small"/>
</el-form-item>
<el-form-item label="机构名称" prop="label" required>
<el-input v-model="orgListDialog.data.label" size="small"/>
</el-form-item>
<el-form-item label="机构地址" prop="address">
<el-input v-model="orgListDialog.data.address" size="small"/>
</el-form-item>
<el-form-item label="行政区划代码" prop="unifiedCode">
<el-input v-model="orgListDialog.data.unifiedCode" size="small"/>
</el-form-item>
<el-form-item label="所属市" prop="city">
<el-input v-model="orgListDialog.data.city" size="small"/>
</el-form-item>
<el-form-item label="所属区" prop="region">
<el-input v-model="orgListDialog.data.region" size="small"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitOrgList">确 定</el-button>
<el-button @click="orgListDialog.show = false">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
......@@ -357,10 +472,11 @@ import * as Emport from '@/api/emport/Emport'
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'
export default {
name: 'Emport',
components: {AutoLoading, AutoUpload},
components: { ArraySelect, AutoLoading, AutoUpload },
data() {
return {
// 页面查询字段
......@@ -430,11 +546,28 @@ export default {
},
templateRuleDialog: { // 模板规则dialog
template: null,
ruleList:[],
fieldList:[],
ruleList: [],
fieldList: [],
show: false,
loading: false
},
orgDictDialog: { // 机构字典弹出框
loading: false,
show: false,
orgList: []
},
orgListDialog: { // 模板规则数据
show: false,
loading: false,
title: '',
data: {}
},
ruleDialog: { // 模板规则数据
show: false,
loading: false,
title: '',
data: {}
},
importLoading: false, // 导入数据loading
queryTemplateLoading: false, // 模板查询loading
queryTableLoading: false, // 查询数据表loading
......@@ -443,7 +576,7 @@ export default {
templateList: [], // 模板列表
analyzeData: {
loading: false,
content: ""
content: ''
}
}
},
......@@ -540,6 +673,8 @@ export default {
},
// 初始化模板列表
initTemplate() {
this.$refs.upload.clearFiles()
this.queryForm.file = null
this.queryTemplateLoading = true
Emport.queryTemplate({
year: this.queryForm.year
......@@ -562,7 +697,7 @@ export default {
// 打开年份字典编辑框
editYearDialog(data) {
this.yearDialog.title = '编辑年份'
this.yearDialog.data = {...data}
this.yearDialog.data = { ...data }
this.yearDialog.show = true
},
// 提交年份dialog
......@@ -586,7 +721,7 @@ export default {
})
},
// 删除年份字典
deleteYear({id, label}) {
deleteYear({ id, label }) {
this.$confirm(`是否删除数据项 ${label} ?`, '删除',
{
type: 'warning',
......@@ -608,13 +743,13 @@ export default {
// 打开机构类型字典新增框
openOrgDialog() {
this.orgDialog.title = '新增机构类型'
this.orgDialog.data = {type: 'org', value: ''}
this.orgDialog.data = { type: 'org', value: '' }
this.orgDialog.show = true
},
// 打开机构类型字典编辑框
editOrgDialog(data) {
this.orgDialog.title = '编辑机构类型'
this.orgDialog.data = {...data}
this.orgDialog.data = { ...data }
this.orgDialog.show = true
},
// 提交机构类型dialog
......@@ -644,7 +779,7 @@ export default {
})
},
// 删除机构类型字典
deleteOrg({id, label}) {
deleteOrg({ id, label }) {
this.$confirm(`是否删除数据项 ${label} ?`, '删除',
{
type: 'warning',
......@@ -680,15 +815,15 @@ export default {
this.queryForm.file = fileList[0]
},
// 文件上传方法
fileUpload({file, onError, onProgress, onSuccess}) {
fileUpload({ file, onError, onProgress, onSuccess }) {
this.importLoading = true
let formData = new FormData()
formData.append('file', file)
let template = this.templateList.find(item => item.orgName === this.queryForm.orgName)
formData.append("type", "1")
formData.append("templateId", template.id)
formData.append("year", template.year)
formData.append("orgName", template.orgName)
formData.append('type', '1')
formData.append('templateId', template.id)
formData.append('year', template.year)
formData.append('orgName', template.orgName)
//formData.append("templateId", this.checkTemplate.id);
Emport.uploadExcel(formData)
.then((res) => {
......@@ -761,7 +896,7 @@ export default {
// 打开模板编辑框
editTemplateDialog(row) {
this.templateDialog.title = '编辑模板'
this.templateDialog.data = {...row}
this.templateDialog.data = { ...row }
this.templateDialog.show = true
},
// 删除模板
......@@ -806,7 +941,7 @@ export default {
},
// 打开字段抽屉
openFieldDrawer(row) {
this.fieldDrawer.template = {...row}
this.fieldDrawer.template = { ...row }
this.fieldDrawer.queryForm = {
templateId: row.id,
code: '',
......@@ -842,7 +977,7 @@ export default {
// 打开修改字段的dialog
editFieldDialog(row) {
this.fieldDialog.title = '修改字段'
this.fieldDialog.data = {...row}
this.fieldDialog.data = { ...row }
this.fieldDialog.show = true
},
// 删除字段
......@@ -923,7 +1058,7 @@ export default {
this.initTemplateDialog.show = true
},
// 初始化模板上上传方法
initTemplateUpload({file, onSuccess}) {
initTemplateUpload({ file, onSuccess }) {
let formData = new FormData()
formData.append('file', file)
formData.append('type', '2')
......@@ -962,7 +1097,7 @@ export default {
.then(async res => {
const isFile = await Emport.blobValidate(res)
if (isFile) {
const {data} = await Emport.getTemplateFileName(row.excelId)
const { data } = await Emport.getTemplateFileName(row.excelId)
//const blob = new Blob([res])
saveAs(res, data.fileName)
}
......@@ -984,7 +1119,7 @@ export default {
message: '物理表创建成功',
duration: 1000 * 5
})
this.initTemplate();
this.initTemplate()
done()
}
}).finally(_ => instance.confirmButtonLoading = false)
......@@ -1012,59 +1147,227 @@ export default {
analyzeExport() {
let template = this.templateList.find(item => item.orgName === this.queryForm.orgName)
if (!template || !this.queryForm.file || this.queryForm.file.status !== 'success') {
this.$message.warning("请先导入数据文件")
return;
this.$message.warning('请先导入数据文件')
return
}
this.analyzeData.content = `正在分析 ${template.orgName} 数据...`
this.analyzeData.loading = true
Emport.analyzeExport(template.id)
.then(res => {
saveAs(res, "分析结果.xlsx")
saveAs(res, '分析结果.xlsx')
}).finally(_ => this.analyzeData.loading = false)
},
// 清空数据
clearTemp() {
let template = this.templateList.find(item => item.orgName === this.queryForm.orgName)
if (!template || !this.queryForm.file || this.queryForm.file.status !== 'success') {
this.$message.warning("请先导入数据")
return;
this.$message.warning('请先导入数据')
return
}
this.clearTempLoading = true
Emport.clearTemp(template).then(res => {
if (res.code === 200){
this.$message.success("清空成功")
if (res.code === 200) {
this.$message.success('清空成功')
this.initTemplate()
this.$refs.upload.clearFiles()
}
}).finally(_=> this.clearTempLoading = false)
}).finally(_ => this.clearTempLoading = false)
},
// 一键导入正式库
syncDb() {
let template = this.templateList.find(item => item.orgName === this.queryForm.orgName)
if (!template || !this.queryForm.file || this.queryForm.file.status !== 'success') {
this.$message.warning("请先导入数据")
return;
this.$message.warning('请先导入数据')
return
}
this.syncDbLoading = true
Emport.syncDb(template).then(res => {
if (res.code === 200){
this.$message.success("导入成功")
if (res.code === 200) {
this.$message.success('导入成功')
this.initTemplate()
this.$refs.upload.clearFiles()
}
}).finally(_=> this.syncDbLoading = false)
}).finally(_ => this.syncDbLoading = false)
},
// 打开模板规则弹框
openTemplateRuleDialog(row){
this.templateRuleDialog.template = {...row}
this.templateRuleDialog.loading = true
openTemplateRuleDialog(row) {
this.templateRuleDialog.template = { ...row }
this.queryTemplateRule()
this.templateRuleDialog.show = true
Emport.getAllTemplateRule(row.id).then(res=>{
Emport.getAllTemplateField(row.id).then(res => {
this.templateRuleDialog.fieldList = res.data.map(item => {
return {
value: item.id,
label: StringUtil.mergeRule(item.code, item.title)
}
})
})
},
// 查询更新模板规则列表
queryTemplateRule() {
this.templateRuleDialog.loading = true
Emport.getAllTemplateRule(this.templateRuleDialog.template.id).then(res => {
this.templateRuleDialog.ruleList = res.data
}).finally(_ => this.templateRuleDialog.loading = false)
},
// 验证模式修改触发事件
modeChange(value) {
this.$set(this.ruleDialog.data, 'content', '')
},
// 提交规则
submitRule() {
this.$refs.ruleForm.validate(validate => {
if (validate) {
if (this.ruleDialog.title === '新增规则') {
Emport.addRuleByTemplate({
...this.ruleDialog.data,
tid: this.templateRuleDialog.template.id
}).then(res => {
this.ruleDialog.show = false
this.queryTemplateRule()
})
} else {
Emport.updateRuleByTemplate(this.ruleDialog.data).then(res => {
this.ruleDialog.show = false
this.queryTemplateRule()
})
}
}
})
},
// 打开规则新增框框
openRuleAddDialog() {
this.ruleDialog.data = {
type: '模板规则'
}
this.ruleDialog.title = '新增规则'
this.ruleDialog.show = true
},
// 打开规则修改弹框
updateRuleByTemplate(row) {
this.ruleDialog.data = { ...row }
this.ruleDialog.title = '修改规则'
this.ruleDialog.show = true
},
// 验证模式格式化
modeFormat(row) {
if (row.mode === '1') {
return '逻辑相加'
}
return ''
},
// 规则配置格式化
contentFormat(row) {
if (row.content) {
let split = row.content.split('=')
let arr1 = split[0].split(',')
let arr2 = split[1].split(',')
return arr1.map(item => {
let data = this.templateRuleDialog.fieldList.find(i => i.value === item)
if (data) {
return data.label
} else {
return item
}
}).join('+') + '=' + arr2.map(item => {
let data = this.templateRuleDialog.fieldList.find(i => i.value === item)
if (data) {
return data.label
} else {
return item
}
})
}
},
// 删除模板规则
deleteRuleByTemplate(row) {
this.$confirm(`是否删除规则 ${row.name} ?`, '删除',
{
type: 'warning',
confirmButtonText: '确定',
cancelButtonText: '取消',
beforeClose: (action, instance, done) => {
if (action === 'confirm') {
Emport.deleteRuleByTemplate(row.id, this.templateRuleDialog.template.id).then(res => {
done()
this.queryTemplateRule()
})
} else {
done()
}
}
}
)
},
// 打开机构字典列表
openOrgDictDialog() {
this.initOrgList()
this.orgDictDialog.show = true
},
openAddOrgListDialog() {
this.orgListDialog.title = '新增机构'
this.orgListDialog.data = {}
this.orgListDialog.show = true
},
openUpdateOrgListDialog(row) {
this.orgListDialog.title = '修改机构'
this.orgListDialog.data = { ...row }
this.orgListDialog.show = true
},
deleteOrgList(row) {
this.$confirm(`是否删除机构 ${row.label}`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
Emport.deleteDict(row.id).then(res => {
if (res.code === 200) {
this.$message.success('删除成功')
this.initOrgList()
}
})
})
},
// 初始化机构列表
initOrgList() {
this.orgDictDialog.loading = true
Emport.queryDict('orgList').then(res => {
if (res.code === 200) {
this.orgDictDialog.orgList = res.data
}
}).finally(_ => this.orgDictDialog.loading = false)
},
// 提交机构字典信息
submitOrgList() {
this.$refs.orgListForm.validate(valid => {
if (valid) {
let data = {
id: this.orgListDialog.data.id,
type: 'orgList',
label: this.orgListDialog.data.label,
value: this.orgListDialog.data.value,
remarks: JSON.stringify({
orgType: this.orgListDialog.data.orgType,
address: this.orgListDialog.data.address,
unifiedCode: this.orgListDialog.data.unifiedCode,
city: this.orgListDialog.data.city,
region: this.orgListDialog.data.region
})
}
if (this.orgListDialog.title === '新增机构') {
Emport.addDict(data)
.then(res => {
this.orgListDialog.show = false
this.initOrgList()
})
} else {
Emport.updateDict(data)
.then(res => {
this.orgListDialog.show = false
this.initOrgList()
})
}
}
})
Emport.getAllTemplateField(row.id).then(res=>{
this.templateRuleDialog.fieldList = res.data
}).finally(_=>this.templateRuleDialog.loading = false)
}
}
}
......
<template>
<div>
<i class="el-icon-circle-plus-outline" style="cursor: pointer" @click="addFirst"></i>
<div v-for="(item,index) in arr1">
<el-select :value="item" :value-key="config.value" filterable
size="small"
@change="(v)=>doSelectFirst(v,index)"
>
<el-option v-for="item in data" :key="item[config.value]"
:label="item[config.label]"
:value="item[config.value]+''">
<el-tooltip :disabled="item[config.label].length < 17" placement="top">
<div slot="content">
<span>{{ item[config.label] }}</span>
</div>
<div style="max-width: 500px;">{{ item[config.label] }}</div>
</el-tooltip>
</el-option>
</el-select>
<i class="el-icon-remove-outline" style="cursor: pointer;margin-left: 4px" @click="removeFirst(index)"></i>
</div>
<el-divider class="divider" />
<i class="el-icon-circle-plus-outline" style="cursor: pointer" @click="addSecond"></i>
<div v-for="(item,index) in arr2">
<el-select :key="item" :value="item" :value-key="config.value" filterable
size="small"
@change="(v)=>doSelectSecond(v,index)"
>
<el-option v-for="item in data" :key="item[config.value]"
:label="item[config.label]"
:value="item[config.value]+''">
<el-tooltip :disabled="item[config.label].length < 17" placement="top">
<div slot="content">
<span>{{ item[config.label] }}</span>
</div>
<div style="max-width: 500px;">{{ item[config.label] }}</div>
</el-tooltip>
</el-option>
</el-select>
<i class="el-icon-remove-outline" style="cursor: pointer;margin-left: 4px" @click="removeSecond(index)"></i>
</div>
</div>
</template>
<script>
export default {
name: 'ArraySelect',
props: {
data: {
type: Array,
default: () => []
},
value: {
type: String,
default: ''
},
config: {
type: Object,
default: () => {
return {
label: 'label',
value: 'value'
}
}
}
},
model: {
prop: 'value',
event: 'changeValue'
},
computed: {
arr1() {
let split = this.value.split('=')
if (split && split.length > 0) {
return split[0].split(',')
}
return []
},
arr2() {
let split = this.value.split('=')
if (split && split.length > 1) {
return split[1].split(',')
}
return []
}
},
methods: {
addFirst() {
let split = this.value.split('=')
if (split.length === 1) {
this.$emit('changeValue', split[0] + ',=')
} else if (split.length === 2) {
this.$emit('changeValue', split[0] + ',=' + split[1])
}
this.$forceUpdate()
},
addSecond() {
let split = this.value.split('=')
if (split.length === 1) {
this.$emit('changeValue', split[0] + '=')
} else if (split.length === 2) {
this.$emit('changeValue', split[0] + '=' + split[1] + ',')
}
this.$forceUpdate()
},
doSelectFirst(value, index) {
let split = this.value.split('=')
let arr = split[0].split(',')
arr[index] = value
this.$emit('changeValue', arr.join(',') + '=' + split[1] )
this.$forceUpdate()
},
doSelectSecond(value, index) {
let split = this.value.split('=')
let arr = split[1].split(',')
arr[index] = value
this.$emit('changeValue', split[0] + '=' + arr.join(','))
this.$forceUpdate()
},
removeFirst(index){
let split = this.value.split('=')
let arr = split[0].split(',')
arr.splice(index, 1)
this.$emit('changeValue', arr.join(',') + '=' + split[1] )
this.$forceUpdate()
},
removeSecond(index){
let split = this.value.split('=')
let arr = split[1].split(',')
arr.splice(index, 1)
this.$emit('changeValue', split[0] + '=' + arr.join(','))
this.$forceUpdate()
}
}
}
</script>
<style lang="scss" scoped>
.divider{
margin: 8px;
}
</style>
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