安环管理-环保管理-废水处理-加药记录-导入添加传参接口

安环管理-环保管理-废气处理-加药记录-导入添加传参接口
dev-scheduling
ysn 8 hours ago
parent 04053cb61e
commit d23899c818
  1. 121
      src/components/basic-import/main.vue
  2. 57
      src/views/safetyManagement/wasteGasSet/components/dosingRecord.vue
  3. 5
      src/views/safetyManagement/wastewater/components/dosingRecord.vue

@ -1,7 +1,17 @@
<template> <template>
<el-dialog :title="title" append-to-body :modelValue="importBox" width="555px" @close="closeDialog"> <el-dialog
<avue-form :option="importOption" v-model="importForm" :upload-after="uploadAfter" :title="title"
:upload-error="uploadError"> append-to-body
:modelValue="importBox"
width="555px"
@close="closeDialog"
>
<avue-form
:option="importOption"
v-model="importForm"
:upload-after="uploadAfter"
:upload-error="uploadError"
>
<template #excelTemplate> <template #excelTemplate>
<el-button type="primary" @click="handleTemplate"> <el-button type="primary" @click="handleTemplate">
点击下载<i class="el-icon-download el-icon--right"></i> 点击下载<i class="el-icon-download el-icon--right"></i>
@ -18,36 +28,40 @@ import { getToken } from '@/utils/auth';
import { downloadXls } from '@/utils/util'; import { downloadXls } from '@/utils/util';
export default { export default {
props: { props: {
title:{ title: {
type:String, type: String,
default:'导入' default: '导入',
}, },
isShow:{ isShow: {
type:Boolean, type: Boolean,
default:false default: false,
}, },
templateUrl:{ templateUrl: {
type:String, type: String,
default:'' default: '',
}, },
templateName:{ templateName: {
type:String, type: String,
default:'模板' default: '模板',
}, },
importUrl:{ importUrl: {
type:String, type: String,
default:'' default: '',
}, },
showTips:{ showTips: {
type:String, type: String,
default:'请上传 .xls,.xlsx 标准格式文件' default: '请上传 .xls,.xlsx 标准格式文件',
} },
basicImportSearch: {
type: Object,
default: () => {},
}, },
data(){ },
return{ data() {
importBox:false, return {
importForm:{}, importBox: false,
importOption:{ importForm: {},
importOption: {
submitBtn: false, submitBtn: false,
emptyBtn: false, emptyBtn: false,
column: [ column: [
@ -61,6 +75,8 @@ export default {
propsHttp: { propsHttp: {
res: 'data', res: 'data',
}, },
//
data: this.basicImportSearch,
tip: this.showTips, tip: this.showTips,
action: this.importUrl, action: this.importUrl,
}, },
@ -71,29 +87,30 @@ export default {
span: 24, span: 24,
}, },
], ],
} },
} };
}, },
watch: { watch: {
isShow(newVal) { isShow(newVal) {
this.importBox = newVal; this.importBox = newVal;
}
}, },
mounted(){
console.log('isShowImport=================',this.isShow)
this.importBox = this.isShow
}, },
methods:{ mounted() {
console.log('isShowImport=================', this.isShow);
this.importBox = this.isShow;
},
methods: {
closeDialog(val) { closeDialog(val) {
this.importBox = false; this.importBox = false;
this.$emit('closeDialog',val); this.$emit('closeDialog', val);
}, },
handleTemplate() { handleTemplate() {
const url = `${this.templateUrl}?${this.website.tokenHeader}=${getToken()}`; const url = `${this.templateUrl}?${this.website.tokenHeader}=${getToken()}`;
console.log('下载模板URL:', url); console.log('下载模板URL:', url);
console.log('模板文件名:', this.templateName); console.log('模板文件名:', this.templateName);
exportBlob(url).then(res => { exportBlob(url)
.then(res => {
console.log('API返回状态:', res.status); console.log('API返回状态:', res.status);
console.log('res.data类型:', typeof res.data); console.log('res.data类型:', typeof res.data);
console.log('res.data instanceof Blob:', res.data instanceof Blob); console.log('res.data instanceof Blob:', res.data instanceof Blob);
@ -106,7 +123,8 @@ export default {
} }
// Excel // Excel
this.validateExcelBlob(res.data).then(isValid => { this.validateExcelBlob(res.data)
.then(isValid => {
if (!isValid) { if (!isValid) {
console.error('下载的文件不是有效的Excel文件'); console.error('下载的文件不是有效的Excel文件');
this.$message.error('下载的文件格式不正确'); this.$message.error('下载的文件格式不正确');
@ -122,7 +140,8 @@ export default {
console.log('开始下载文件:', fileName); console.log('开始下载文件:', fileName);
downloadXls(res.data, fileName); downloadXls(res.data, fileName);
this.$message.success('模板下载成功'); this.$message.success('模板下载成功');
}).catch(error => { })
.catch(error => {
console.error('验证文件失败:', error); console.error('验证文件失败:', error);
// 使 // 使
let fileName = this.templateName; let fileName = this.templateName;
@ -132,17 +151,20 @@ export default {
downloadXls(res.data, fileName); downloadXls(res.data, fileName);
this.$message.success('模板下载成功'); this.$message.success('模板下载成功');
}); });
}).catch(error => { })
.catch(error => {
console.error('下载模板失败:', error); console.error('下载模板失败:', error);
this.$message.error('下载失败,请检查网络或稍后重试'); this.$message.error('下载失败,请检查网络或稍后重试');
}); });
}, },
validateExcelBlob(blob) { validateExcelBlob(blob) {
return new Promise((resolve) => { return new Promise(resolve => {
const reader = new FileReader(); const reader = new FileReader();
reader.onloadend = (e) => { reader.onloadend = e => {
const arr = new Uint8Array(e.target.result); const arr = new Uint8Array(e.target.result);
const header = Array.from(arr.slice(0, 8)).map(b => b.toString(16).padStart(2, '0')).join(' '); const header = Array.from(arr.slice(0, 8))
.map(b => b.toString(16).padStart(2, '0'))
.join(' ');
console.log('文件头 (前8字节):', header); console.log('文件头 (前8字节):', header);
// XLSX (ZIP): 50 4B 03 04 // XLSX (ZIP): 50 4B 03 04
@ -160,17 +182,16 @@ export default {
}); });
}, },
uploadAfter(res, done, loading, column) { uploadAfter(res, done, loading, column) {
this.closeDialog(true) this.closeDialog(true);
done(); done();
}, },
uploadError(error, column){ uploadError(error, column) {
console.log('error-------------',error) console.log('error-------------', error);
this.closeDialog() this.closeDialog();
} },
} },
} };
</script> </script>
<style> <style>
</style> </style>

@ -35,6 +35,7 @@
templateName="废气加药记录导入模板.xls" templateName="废气加药记录导入模板.xls"
importUrl="/blade-desk/bsDosingRec/importExcel" importUrl="/blade-desk/bsDosingRec/importExcel"
@closeDialog="closeImportDialog" @closeDialog="closeImportDialog"
:basicImportSearch="search"
></basic-import> ></basic-import>
<!-- 新增 --> <!-- 新增 -->
<addEditDialogDosingRecord <addEditDialogDosingRecord
@ -43,28 +44,38 @@
@closeDialog="closeDialog" @closeDialog="closeDialog"
:moldAddMore="moldAddMore" :moldAddMore="moldAddMore"
:dosingManList="dosingManList" :dosingManList="dosingManList"
@submitData="handleSubmitData"> @submitData="handleSubmitData"
>
</addEditDialogDosingRecord> </addEditDialogDosingRecord>
</div> </div>
</template> </template>
<script> <script>
import basicImport from '@/components/basic-import/main.vue'; import basicImport from '@/components/basic-import/main.vue';
import addEditDialogDosingRecord from './addEditDialogDosingRecord.vue'; import addEditDialogDosingRecord from './addEditDialogDosingRecord.vue';
import { getList , remove , add , update , getDosingManList } from '@/api/safetyManagement/dosingRecord.js'; import {
getList,
remove,
add,
update,
getDosingManList,
} from '@/api/safetyManagement/dosingRecord.js';
export default { export default {
components: { components: {
basicImport, basicImport,
addEditDialogDosingRecord addEditDialogDosingRecord,
}, },
data() { data() {
return { return {
dosingManList:[], dosingManList: [],
addOpen: false, // addOpen: false, //
moldAddMore: false, moldAddMore: false,
isShowImport: false, isShowImport: false,
loading: false, loading: false,
selectionList: [], selectionList: [],
search: {
dorType: 1,
},
option: { option: {
addBtn: false, addBtn: false,
height: 'auto', height: 'auto',
@ -165,7 +176,7 @@ export default {
sortable: true, sortable: true,
filter: true, filter: true,
hide: true, hide: true,
editDisplay:false, editDisplay: false,
type: 'datetime', type: 'datetime',
format: 'YYYY-MM-DD HH:mm:ss', format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'YYYY-MM-DD HH:mm:ss',
@ -204,7 +215,7 @@ export default {
searchLabelWidth: 60, searchLabelWidth: 60,
sortable: true, sortable: true,
filter: true, filter: true,
type: "select", type: 'select',
dicData: [], dicData: [],
rules: [ rules: [
{ {
@ -215,7 +226,7 @@ export default {
], ],
props: { props: {
label: 'name', label: 'name',
value: 'id' value: 'id',
}, },
}, },
{ {
@ -224,7 +235,6 @@ export default {
search: false, search: false,
sortable: true, sortable: true,
filter: true, filter: true,
}, },
], ],
}, },
@ -237,7 +247,7 @@ export default {
}; };
}, },
mounted() { mounted() {
this.fetchDosingManList() this.fetchDosingManList();
}, },
methods: { methods: {
// //
@ -245,22 +255,22 @@ export default {
getDosingManList({ getDosingManList({
current: 1, current: 1,
size: 10000000, size: 10000000,
roleId: '2008474700619563009' roleId: '2008474700619563009',
}).then(res => { }).then(res => {
const result = res.data.data.records const result = res.data.data.records;
this.dosingManList = result this.dosingManList = result;
console.log("加药人result", result) console.log('加药人result', result);
this.option.column.forEach(col => { this.option.column.forEach(col => {
if (col.prop === 'dosingMan') { if (col.prop === 'dosingMan') {
col.dicData = this.dosingManList; col.dicData = this.dosingManList;
} }
}); });
}) });
}, },
// //
moldAddFn(row, flag) { moldAddFn(row, flag) {
this.addOpen = true this.addOpen = true;
this.moldAddMore = flag this.moldAddMore = flag;
}, },
// //
closeDialog() { closeDialog() {
@ -307,11 +317,10 @@ export default {
loading(); loading();
} }
); );
}, },
// //
handleImport() { handleImport() {
this.isShowImport = true this.isShowImport = true;
}, },
// //
refreshChange() { refreshChange() {
@ -353,23 +362,21 @@ export default {
searchChange(params, done) { searchChange(params, done) {
this.query = params; this.query = params;
this.page.currentPage = 1; this.page.currentPage = 1;
this.onLoad(this.page, params) this.onLoad(this.page, params);
done() done();
}, },
// //
searchReset() { searchReset() {
this.query = {} this.query = {};
this.onLoad(this.page) this.onLoad(this.page);
}, },
// //
onLoad(page, params = {}) { onLoad(page, params = {}) {
this.loading = true; this.loading = true;
this.query = { ...this.query, dorType: 1 } //12 this.query = { ...this.query, dorType: 1 }; //12
const requestParams = Object.assign({}, params, this.query); const requestParams = Object.assign({}, params, this.query);
// //
if (requestParams.queryDosingTime && Array.isArray(requestParams.queryDosingTime)) { if (requestParams.queryDosingTime && Array.isArray(requestParams.queryDosingTime)) {
requestParams.queryDosingTime = requestParams.queryDosingTime.join(','); requestParams.queryDosingTime = requestParams.queryDosingTime.join(',');
} }
getList(page.currentPage, page.pageSize, requestParams) getList(page.currentPage, page.pageSize, requestParams)

@ -16,6 +16,7 @@
@size-change="sizeChange" @size-change="sizeChange"
@refresh-change="refreshChange" @refresh-change="refreshChange"
@on-load="onLoad" @on-load="onLoad"
:search.sync="search"
> >
<template #menu-left> <template #menu-left>
<el-button type="primary" icon="el-icon-plus" @click="moldAddFn(null, true)" <el-button type="primary" icon="el-icon-plus" @click="moldAddFn(null, true)"
@ -45,6 +46,7 @@
templateName="废水加药记录导入模板.xls" templateName="废水加药记录导入模板.xls"
importUrl="/blade-desk/bsDosingRec/importExcel" importUrl="/blade-desk/bsDosingRec/importExcel"
@closeDialog="closeImportDialog" @closeDialog="closeImportDialog"
:basicImportSearch="search"
></basic-import> ></basic-import>
</div> </div>
</template> </template>
@ -71,6 +73,9 @@ export default {
loading: false, loading: false,
selectionList: [], selectionList: [],
dosingManList: [], dosingManList: [],
search: {
dorType: 2,
},
option: { option: {
addBtn: false, addBtn: false,
height: 'auto', height: 'auto',

Loading…
Cancel
Save