增加预警管理导入
This commit is contained in:
parent
e83d210e0f
commit
b8a75caec3
@ -51,7 +51,21 @@ export default {
|
||||
post: async function (params) {
|
||||
return await http.post(this.url, params);
|
||||
},
|
||||
}
|
||||
},
|
||||
template:{
|
||||
url: `${config.API_URL}/warning.management.import.template`,
|
||||
name: "预计六个月用量导入模版",
|
||||
post: async function (params) {
|
||||
return await http.get(this.url,params,{responseType: 'arraybuffer'});
|
||||
}
|
||||
},
|
||||
import:{
|
||||
url: `${config.API_URL}/spare.parts.water.level.warning.batch.import`,
|
||||
name: "预计六个月用量导入",
|
||||
post: async function (params) {
|
||||
return await http.post(this.url,params,{'Content-Type': 'multipart/form-data'});
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -113,7 +113,7 @@ export default {
|
||||
},
|
||||
methods:{
|
||||
getWsResult(res){
|
||||
if(res.data && (res.data.type == 4 || res.data.type == 5 || res.data.type == 10 || res.data.type == 17 || res.data.type == 18 || res.data.type == 27 || res.data.type == 28 || res.data.type == 31 || res.data.type == 42 || res.data.type == 44 || res.data.type == 45 || res.data.type == 48 || res.data.type == 49)){
|
||||
if(res.data && (res.data.type == 4 || res.data.type == 5 || res.data.type == 10 || res.data.type == 17 || res.data.type == 18 || res.data.type == 27 || res.data.type == 28 || res.data.type == 31 || res.data.type == 42 || res.data.type == 44 || res.data.type == 45 || res.data.type == 48 || res.data.type == 49 || res.data.type == 50)){
|
||||
if(this.type == res.data.type){
|
||||
this.importInfo = res.data;
|
||||
this.progressShow = true;
|
||||
|
||||
@ -4,6 +4,14 @@
|
||||
<div class="left-panel">
|
||||
<el-button type="primary" v-auth="'sparePartsWaterLevelWarningEdit'" :size="size" icon="el-icon-plus" @click="add">新增预警</el-button>
|
||||
<el-button type="primary" v-auth="'sparePartsWaterLevelWarningBatchEdit'" :size="size" plain :disabled="selection.length==0" @click="usage">批量修改预计用量</el-button>
|
||||
<scImport ref="scImport" :size="size" type="50" :httpDisabled="httpDisabled" title="批量导入预计六个月用量" @parentParams="importUpload" @importSuccess="importSuccess">
|
||||
<template #header>
|
||||
<el-button v-auth="'maintenanceOrderImport'" type="primary" :size="size" plain @click="importFile" style="margin-right: 12px;">批量导入</el-button>
|
||||
</template>
|
||||
<template #download>
|
||||
<div v-auth="'maintenanceOrderImport'" @click="importTemplate">下载导入模版</div>
|
||||
</template>
|
||||
</scImport>
|
||||
<el-button type="danger" v-auth="'sparePartsWaterLevelWarningDelete'" plain :size="size" icon="el-icon-Delete" :disabled="selection.length==0" @click="batch_del"></el-button>
|
||||
</div>
|
||||
<div class="right-panel">
|
||||
@ -13,7 +21,14 @@
|
||||
</div>
|
||||
</el-header>
|
||||
<el-main class="nopadding">
|
||||
<div class="searchMain" :class="!searchHeaderShow?'emptySearchMain':''">
|
||||
<div class="fieldsSwitchBox searchConditionItem" style="margin-top: 10px;" v-if="!fieldsShow">
|
||||
<div class="leftBox"></div>
|
||||
<div class="rightBox" @click="searchClick">
|
||||
<el-icon class="icon"><sc-icon-SwitchQuery /></el-icon>
|
||||
<span class="name">切换查询方式</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="searchMain searchMainMarginNone" :class="!searchHeaderShow?'emptySearchMain':''" v-if="!fieldsShow">
|
||||
<scTableSearch ref="scSearch" :searchList="list.column" :paramsData="params" :searchShow="searchShow" @fetchSelectData="getSelectData" @changeHeaderData="getHeaderData"></scTableSearch>
|
||||
|
||||
<div class="searchItem searchBtn" v-if="searchHeaderShow">
|
||||
@ -22,6 +37,9 @@
|
||||
<el-button :size="size" type="info" icon="el-icon-RefreshRight" @click="reset">重置</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="searchMain searchMainMarginNone searchMainBodyMarginNone searchMainNoTop" v-if="fieldsShow">
|
||||
<herderMultipleSearch @fieldsSwitch="fieldsSwitch" @fieldsSearch="fieldsSearch" :fieldsShow="fieldsShow" :searchList="list.fields"></herderMultipleSearch>
|
||||
</div>
|
||||
<scTable ref="table" :apiObj="list.apiObj" :column="list.column" row-key="id" @selection-change="selectionChange" @columnBack="columnBack" border stripe :size="size">
|
||||
<el-table-column type="selection" align="center" width="40"></el-table-column>
|
||||
<template #region_name="scope">
|
||||
@ -70,7 +88,9 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
fieldsShow:false,
|
||||
size:'small',
|
||||
httpDisabled:false,
|
||||
dialog: {
|
||||
save: false,
|
||||
usageSave:false,
|
||||
@ -79,7 +99,8 @@ export default {
|
||||
exportShow:false,
|
||||
list:{
|
||||
apiObj: this.$API.early.earlyWarn.list,
|
||||
column:[]
|
||||
column:[],
|
||||
fields:{}
|
||||
},
|
||||
searchShow:false,
|
||||
searchHeaderShow:false,
|
||||
@ -87,7 +108,10 @@ export default {
|
||||
data:{}
|
||||
},
|
||||
selection: [],
|
||||
params: {}
|
||||
params: {},
|
||||
importParams:{
|
||||
is_save_repeat:false
|
||||
}
|
||||
}
|
||||
},
|
||||
provide(){
|
||||
@ -116,8 +140,20 @@ export default {
|
||||
/**
|
||||
* 表格检索开始
|
||||
* */
|
||||
columnBack(val){
|
||||
searchClick(){
|
||||
this.fieldsShow = true;
|
||||
},
|
||||
fieldsSwitch(val){
|
||||
this.fieldsShow = val;
|
||||
},
|
||||
fieldsSearch(params){
|
||||
this.params = params;
|
||||
this.upSearch();
|
||||
},
|
||||
|
||||
columnBack(val, fieldsData){
|
||||
this.list.column = val;
|
||||
this.list.fields = fieldsData;
|
||||
},
|
||||
async filterClick(item) {
|
||||
let {data, params} = item;
|
||||
@ -262,6 +298,55 @@ export default {
|
||||
|
||||
})
|
||||
},
|
||||
|
||||
// 批量导入
|
||||
importFile(){
|
||||
this.$nextTick(()=>{
|
||||
this.$refs.scImport.importFile();
|
||||
})
|
||||
},
|
||||
async importTemplate() {
|
||||
const res = await this.$API.early.earlyWarn.template.post();
|
||||
const blob = new Blob([res]);
|
||||
const text = new Date().getTime();
|
||||
const eLink = document.createElement('a');
|
||||
eLink.download = "预计六个月用量导入模版_"+text+'.xlsx';
|
||||
eLink.style.display = 'none';
|
||||
eLink.href = URL.createObjectURL(blob);
|
||||
document.body.appendChild(eLink);
|
||||
eLink.click();
|
||||
URL.revokeObjectURL(eLink.href);
|
||||
document.body.removeChild(eLink);
|
||||
},
|
||||
async importUpload(params) {
|
||||
const updateOrAppend = (formData, key, value) => {
|
||||
let found = false;
|
||||
for (let [k] of formData.entries()) {
|
||||
if (k === key) {
|
||||
formData.set(k, value); // 替换已存在的值
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
formData.append(key, value); // 如果没有找到,则添加新项
|
||||
}
|
||||
};
|
||||
updateOrAppend(params, 'is_save_repeat', this.importParams.is_save_repeat);
|
||||
|
||||
this.httpDisabled = true;
|
||||
const res = await this.$API.early.earlyWarn.import.post(params);
|
||||
if(res.code == 200){
|
||||
this.$message.success('上传成功,开始导入数据');
|
||||
}
|
||||
},
|
||||
importSuccess(refresh){
|
||||
this.httpDisabled = false;
|
||||
if(!refresh){
|
||||
this.$refs.table.refresh()
|
||||
}
|
||||
},
|
||||
|
||||
//表格选择后回调事件
|
||||
selectionChange(selection){
|
||||
this.selection = selection;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user