Commit a9c80479 by 刘泽志

数据导入全部完成

parent 12f2ed43
......@@ -405,6 +405,60 @@ export function analyzeExport(templateId){
return request({
url: `${prefix}/analyze/export`,
method: 'get',
params:{templateId},
responseType: "blob",
})
}
/**
* 清空数据
* @param data
* @returns {*}
*/
export function clearTemp(data){
return request({
url: `${prefix}/clearTemp`,
method: 'post',
data
})
}
/**
* 一键导入正式库
* @param data
* @returns {*}
*/
export function syncDb(data){
return request({
url: `${prefix}/syncDb`,
method: 'post',
data
})
}
/**
* 查询模板的所有字段数据
* @param templateId
* @returns {*}
*/
export function getAllTemplateField(templateId) {
return request({
url: `${prefix}/template/allField`,
method: 'get',
params:{templateId}
})
}
/**
* 查询模板的所有规则数据
* @param templateId
* @returns {*}
*/
export function getAllTemplateRule(templateId) {
return request({
url: `${prefix}/template/allRule`,
method: 'get',
params:{templateId}
})
}
......@@ -53,7 +53,7 @@ export default {
.dialog-loading-custom {
border-radius: 16px;
background-color: rgba(255, 255, 255,0.5);
background-color: rgba(255, 255, 255,1);
}
.el-dialog__body {
......
......@@ -47,9 +47,12 @@
<el-form-item>
<el-button icon="el-icon-pie-chart" plain
size="small"
style="margin-left:6px;" @click="analyzeExport">分析并导出</el-button>
style="margin-left:6px;" @click="analyzeExport">分析并导出
</el-button>
<el-button size="small" icon="el-icon-set-up" plain>设置机构字典</el-button>
<el-button size="small" icon="el-icon-refresh" plain>清空数据</el-button>
<el-button size="small" icon="el-icon-refresh" plain :loading="clearTempLoading" @click="clearTemp">
清空数据
</el-button>
<el-button icon="el-icon-folder-add" plain size="small" @click="openTemplateDialog">添加模板</el-button>
</el-form-item>
</el-form>
......@@ -86,6 +89,8 @@
</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="openTemplateRuleDialog(scope.row)">模板规则
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
......@@ -95,7 +100,7 @@
<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;" @click="triggerImport">
<el-button icon="el-icon-upload" plain size="small" style="margin-left:6px;" :loading="syncDbLoading" @click="syncDb">
一键导入正式库
</el-button>
<span></span>
......@@ -234,7 +239,8 @@
<el-input v-model="fieldDrawer.queryForm.coordinate"/>
</el-form-item>
<el-form-item label="">
<el-button :loading="fieldDrawer.queryFieldLoading" icon="el-icon-search" style="margin-left: 8px" type="primary"
<el-button :loading="fieldDrawer.queryFieldLoading" icon="el-icon-search" style="margin-left: 8px"
type="primary"
@click="queryFieldList"
>查询
</el-button>
......@@ -329,7 +335,20 @@
<!-- 分析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"
>
<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-select>
</el-form-item>
<span style="font-size: 13px;color: #F56C6C">设置后将为每一条字段添加此规则!</span>
</el-form>
</el-dialog>
</div>
</template>
......@@ -341,7 +360,7 @@ import AutoLoading from '@/views/emport/emport/AutoLoading.vue'
export default {
name: 'Emport',
components: { AutoLoading, AutoUpload },
components: {AutoLoading, AutoUpload},
data() {
return {
// 页面查询字段
......@@ -409,11 +428,20 @@ export default {
show: false,
loading: false
},
templateRuleDialog: { // 模板规则dialog
template: null,
ruleList:[],
fieldList:[],
show: false,
loading: false
},
importLoading: false, // 导入数据loading
queryTemplateLoading: false, // 模板查询loading
queryTableLoading: false, // 查询数据表loading
clearTempLoading: false, // 清空数据loading
syncDbLoading: false, // 一键导入正式库loading
templateList: [], // 模板列表
analyzeData:{
analyzeData: {
loading: false,
content: ""
}
......@@ -534,7 +562,7 @@ export default {
// 打开年份字典编辑框
editYearDialog(data) {
this.yearDialog.title = '编辑年份'
this.yearDialog.data = { ...data }
this.yearDialog.data = {...data}
this.yearDialog.show = true
},
// 提交年份dialog
......@@ -558,7 +586,7 @@ export default {
})
},
// 删除年份字典
deleteYear({ id, label }) {
deleteYear({id, label}) {
this.$confirm(`是否删除数据项 ${label} ?`, '删除',
{
type: 'warning',
......@@ -580,13 +608,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
......@@ -616,7 +644,7 @@ export default {
})
},
// 删除机构类型字典
deleteOrg({ id, label }) {
deleteOrg({id, label}) {
this.$confirm(`是否删除数据项 ${label} ?`, '删除',
{
type: 'warning',
......@@ -652,15 +680,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)
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("templateId", this.checkTemplate.id);
Emport.uploadExcel(formData)
.then((res) => {
......@@ -733,7 +761,7 @@ export default {
// 打开模板编辑框
editTemplateDialog(row) {
this.templateDialog.title = '编辑模板'
this.templateDialog.data = { ...row }
this.templateDialog.data = {...row}
this.templateDialog.show = true
},
// 删除模板
......@@ -778,7 +806,7 @@ export default {
},
// 打开字段抽屉
openFieldDrawer(row) {
this.fieldDrawer.template = { ...row }
this.fieldDrawer.template = {...row}
this.fieldDrawer.queryForm = {
templateId: row.id,
code: '',
......@@ -814,7 +842,7 @@ export default {
// 打开修改字段的dialog
editFieldDialog(row) {
this.fieldDialog.title = '修改字段'
this.fieldDialog.data = { ...row }
this.fieldDialog.data = {...row}
this.fieldDialog.show = true
},
// 删除字段
......@@ -895,7 +923,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')
......@@ -934,7 +962,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)
}
......@@ -956,6 +984,7 @@ export default {
message: '物理表创建成功',
duration: 1000 * 5
})
this.initTemplate();
done()
}
}).finally(_ => instance.confirmButtonLoading = false)
......@@ -980,10 +1009,63 @@ export default {
}
},
// 数据分析并导出
analyzeExport(){
this.analyzeData.content="正在分析导入数据"
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.analyzeData.content = `正在分析 ${template.orgName} 数据...`
this.analyzeData.loading = true
Emport.analyzeExport(template.id)
.then(res => {
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.clearTempLoading = true
Emport.clearTemp(template).then(res => {
if (res.code === 200){
this.$message.success("清空成功")
this.initTemplate()
this.$refs.upload.clearFiles()
}
}).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.syncDbLoading = true
Emport.syncDb(template).then(res => {
if (res.code === 200){
this.$message.success("导入成功")
this.initTemplate()
this.$refs.upload.clearFiles()
}
}).finally(_=> this.syncDbLoading = false)
},
// 打开模板规则弹框
openTemplateRuleDialog(row){
this.templateRuleDialog.template = {...row}
this.templateRuleDialog.loading = true
this.templateRuleDialog.show = true
Emport.getAllTemplateRule(row.id).then(res=>{
this.templateRuleDialog.ruleList = res.data
})
Emport.getAllTemplateField(row.id).then(res=>{
this.templateRuleDialog.fieldList = res.data
}).finally(_=>this.templateRuleDialog.loading = false)
}
}
}
</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