diff --git a/src/api/model/early.js b/src/api/model/early.js
index 3424dcb..2064272 100644
--- a/src/api/model/early.js
+++ b/src/api/model/early.js
@@ -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'});
+ }
+ },
}
diff --git a/src/components/scImport/index.vue b/src/components/scImport/index.vue
index 93885bd..1623206 100644
--- a/src/components/scImport/index.vue
+++ b/src/components/scImport/index.vue
@@ -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;
diff --git a/src/views/earlyManager/index.vue b/src/views/earlyManager/index.vue
index 857379a..ca39b5c 100644
--- a/src/views/earlyManager/index.vue
+++ b/src/views/earlyManager/index.vue
@@ -4,6 +4,14 @@
新增预警
批量修改预计用量
+
+
+ 批量导入
+
+
+ 下载导入模版
+
+
@@ -13,7 +21,14 @@
-
+
+
+
+
+
@@ -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;