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

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

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

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

Loading…
Cancel
Save