You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
520 lines
15 KiB
520 lines
15 KiB
<template>
|
|
<view>
|
|
<view class="cc-card cc-form-card">
|
|
<view class="form-title">监督检查</view>
|
|
<view class="form-item">
|
|
<text class="form-label">项目名称</text>
|
|
<view class="form-content">
|
|
<input v-model="form.projectName" class="form-input" placeholder="请选择项目名称" disabled/>
|
|
<picker mode="selector" :range="projectNames" @change="onProjectChange">
|
|
<view class="form-select">
|
|
选择
|
|
</view>
|
|
</picker>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="form-item">
|
|
<text class="form-label">检查类型</text>
|
|
<view class="form-content">
|
|
<input v-model="showForm.checkType" class="form-input" placeholder="请选择检查类型" disabled/>
|
|
<picker mode="selector" :range="checkNameTypes" @change="onCheckTypeChange">
|
|
<view class="form-select">
|
|
选择
|
|
</view>
|
|
</picker>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="form-item">
|
|
<text class="form-label">检查时间</text>
|
|
<view class="form-content">
|
|
<input v-model="form.inspectionTime" class="form-input" placeholder="请选择检查时间" disabled/>
|
|
<picker mode="date" @change="onCheckTimeChange">
|
|
<view class="form-select">
|
|
选择
|
|
</view>
|
|
</picker>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="form-item">
|
|
<text class="form-label">检查单位</text>
|
|
<view class="form-content">
|
|
<input v-model="form.inspectionUnit" class="form-input" placeholder="请输入检查单位" />
|
|
</view>
|
|
</view>
|
|
|
|
|
|
<view class="form-item">
|
|
<text class="form-label">被检查单位</text>
|
|
<view class="form-content">
|
|
<input v-model="form.inspectionPerson" class="form-input" placeholder="请输入被检查单位" />
|
|
</view>
|
|
</view>
|
|
|
|
<view class="form-item">
|
|
<text class="form-label">组成成员</text>
|
|
<view class="form-content">
|
|
<input v-model="form.constituentMember" class="form-input" placeholder="请输入组成成员" />
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="cc-form-card" style="margin-top: 16px;">
|
|
<view class="form-title">
|
|
<view>检查通知</view>
|
|
<view class="form-tips">支持png、jpg、pdf、word等格式,不大于200M</view>
|
|
</view>
|
|
|
|
<view class="form-item" style="margin-bottom: 0;">
|
|
<uni-file-picker
|
|
ref="filePicker1"
|
|
:autoUpload="false"
|
|
file-mediatype="all"
|
|
file-extname="png,jpg,pdf,,doc,docx,xls,xlsx"
|
|
limit="10"
|
|
@select="handleSelectCheckFile"
|
|
@success="handleCheckFileSuccess"
|
|
>
|
|
</uni-file-picker>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="cc-form-card" style="margin-top: 16px;">
|
|
<view class="form-title">
|
|
<view>整改通知</view>
|
|
<view class="form-tips">支持png、jpg、pdf、word等格式,不大于200M</view>
|
|
</view>
|
|
|
|
<view class="form-item" style="margin-bottom: 0;">
|
|
<uni-file-picker
|
|
ref="filePicker2"
|
|
:autoUpload="false"
|
|
file-mediatype="all"
|
|
file-extname="png,jpg,pdf,,doc,docx,xls,xlsx"
|
|
limit="10"
|
|
@select="handleSelectCheckFile1"
|
|
@success="handleCheckFileSuccess"
|
|
></uni-file-picker>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="cc-form-card" style="margin-top: 16px;">
|
|
<view class="form-title">
|
|
<view>整改回复</view>
|
|
<view class="form-tips">支持png、jpg、pdf、word等格式,不大于200M</view>
|
|
</view>
|
|
|
|
<view class="form-item" style="margin-bottom: 0;">
|
|
<uni-file-picker
|
|
ref="filePicker3"
|
|
:autoUpload="false"
|
|
file-mediatype="all"
|
|
file-extname="png,jpg,pdf,,doc,docx,xls,xlsx"
|
|
limit="10"
|
|
@select="handleSelectCheckFile2"
|
|
@success="handleCheckFileSuccess"
|
|
></uni-file-picker>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { getProjectListApi } from '@/api/system/project'
|
|
import { addNewInspections, getInspections, updateInspections } from '@/api/system/check/inspections'
|
|
import { addInspectionsDraft, getInspectionsDraft, updateInspectionsDraft } from '@/api/system/check/inspectionsDraft'
|
|
import {getToken} from "@/utils/auth";
|
|
import {uploadFileData} from "@/api/common/upload";
|
|
import {baseUrl} from "@/config";
|
|
export default {
|
|
name: "MonitorAdd",
|
|
props: {
|
|
monitorDraftId: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
monitorId: {
|
|
type: String,
|
|
default: ''
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
form: {
|
|
"menuType": "0",
|
|
"inspectionTypes": null,
|
|
"inspectionTime": "",
|
|
"inspectionPerson": "",
|
|
"constituentMember": "",
|
|
"noticeAttachment": "",
|
|
"checklist": "",
|
|
"rectificationReport": null,
|
|
"createTime": null,
|
|
"updateTime": null,
|
|
"remark": null,
|
|
"createUid": null,
|
|
"updateUid": null,
|
|
"owerDept": null,
|
|
"proCode": "",
|
|
"proNo": "",
|
|
"projectName": "",
|
|
"checkType": "",
|
|
"inspectionUnit": "",
|
|
"rectificationDtoList": []
|
|
},
|
|
showForm: {
|
|
checkType: ''
|
|
},
|
|
fileList1: [],
|
|
fileList2: [],
|
|
fileList3: [],
|
|
projectNames: [],
|
|
checkTypes: [],
|
|
checkNameTypes: [],
|
|
queryParams: {
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
params: {orderBy: "create_time", sortBy: "desc"},
|
|
data: {
|
|
projectName: ''
|
|
}
|
|
},
|
|
projects: [],
|
|
headers: {
|
|
jianwei: "jwtech " + getToken(),
|
|
},
|
|
}
|
|
},
|
|
|
|
created() {
|
|
console.log("88888888888888888888888")
|
|
console.log(this.monitorId)
|
|
|
|
this.getProjectList()
|
|
this.getDicts("check_type").then((response) =>{
|
|
this.checkTypes = response.data
|
|
this.checkNameTypes = this.checkTypes.map(item => item.dictLabel)
|
|
})
|
|
if (this.monitorDraftId) {
|
|
getInspectionsDraft(this.monitorDraftId).then(res => {
|
|
this.form = res.data
|
|
this.showForm.checkType = this.checkTypeFormat(this.form.checkType)
|
|
})
|
|
} else if (this.monitorId) {
|
|
getInspections(this.monitorId).then(res => {
|
|
this.form = res.data
|
|
if (this.form.noticeAttachment) {
|
|
this.fileList1 = JSON.parse(this.form.noticeAttachment);
|
|
this.$refs.filePicker1.setValue(this.fileList1)
|
|
}
|
|
if (this.form.checklist) {
|
|
this.fileList2 = JSON.parse(this.form.checklist);
|
|
this.$refs.filePicker2.setValue(this.fileList2)
|
|
|
|
}
|
|
if (this.form.rectificationReport) {
|
|
this.fileList3 = JSON.parse(this.form.rectificationReport);
|
|
this.$refs.filePicker3.setValue(this.fileList3)
|
|
|
|
}
|
|
console.log(11111,this.fileList1)
|
|
this.showForm.checkType = this.checkTypeFormat(this.form.checkType)
|
|
})
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
// 获取项目列表
|
|
getProjectList() {
|
|
uni.showLoading({
|
|
title: '加载中...',
|
|
mask: true
|
|
})
|
|
getProjectListApi(this.queryParams).then(res => {
|
|
this.projects = res.records
|
|
this.projectNames = this.projects.map(item => item.projectName)
|
|
uni.hideLoading()
|
|
})
|
|
},
|
|
|
|
// 处理选择项目
|
|
onProjectChange(e) {
|
|
const index = e.detail.value
|
|
this.form.projectName = this.projects[index].projectName
|
|
this.form.proNo = this.projects[index].id
|
|
this.form.proCode = this.projects[index].proCode
|
|
this.$forceUpdate()
|
|
},
|
|
|
|
onCheckTypeChange(e) {
|
|
this.showForm.checkType = this.checkTypes[e.detail.value].dictLabel
|
|
this.form.checkType = this.checkTypes[e.detail.value].dictValue
|
|
},
|
|
|
|
onCheckTimeChange(e) {
|
|
this.form.inspectionTime = e.detail.value
|
|
},
|
|
|
|
//行政区划字典
|
|
checkTypeFormat(checkType, column) {
|
|
return this.selectDictLabel(
|
|
this.checkTypes,
|
|
checkType
|
|
);
|
|
},
|
|
|
|
// handleSelectCheckFile(e) {
|
|
// const tempFiles = e.tempFiles
|
|
// tempFiles.forEach(item => {
|
|
// const reader = new FileReader()
|
|
// reader.onload = (e) => {
|
|
// const fileRaw = e.target.result
|
|
// console.log(e.target.result) // 这里是文件的原始内容
|
|
// let formData = new FormData()
|
|
// formData.append('file', fileRaw);
|
|
// uploadFileData(formData).then(res => {
|
|
// uni.showToast({
|
|
// title: `添加成功!`,
|
|
// icon: 'none'
|
|
// })
|
|
// })
|
|
// }
|
|
// reader.readAsText(item.file)
|
|
// // uni.readFile({
|
|
// // filePath: item, // 选择的文件路径
|
|
// // encoding: 'utf8', // 文件编码
|
|
// // success: (res) => {
|
|
// // console.log('文件内容:', res.data); // 处理文件内容
|
|
// // },
|
|
// // fail: (err) => {
|
|
// // console.error('读取文件失败:', err);
|
|
// // }
|
|
// // });
|
|
// })
|
|
|
|
// const tempFiles = e.tempFiles
|
|
// tempFiles.forEach(item => {
|
|
// uploadFileData({ file: item.file }).then(res => {
|
|
// console.log(res)
|
|
// })
|
|
// })
|
|
// console.log("1111111111")
|
|
// console.log(e)
|
|
// },
|
|
|
|
handleSelectCheckFile(e) {
|
|
const files = e.tempFiles;
|
|
// 遍历选择的文件并逐个上传
|
|
files.forEach((file) => {
|
|
this.uploadFile(file,"fileList1");
|
|
});
|
|
},
|
|
handleSelectCheckFile1(e) {
|
|
const files = e.tempFiles;
|
|
// 遍历选择的文件并逐个上传
|
|
files.forEach((file) => {
|
|
this.uploadFile(file,"fileList2");
|
|
});
|
|
},
|
|
handleSelectCheckFile2(e) {
|
|
const files = e.tempFiles;
|
|
// 遍历选择的文件并逐个上传
|
|
files.forEach((file) => {
|
|
this.uploadFile(file,"fileList3");
|
|
});
|
|
},
|
|
// 处理文件上传成功事件
|
|
handleCheckFileSuccess(e,fileList) {
|
|
console.log('文件上传成功11111', e);
|
|
},
|
|
// 上传文件的方法
|
|
uploadFile(file,fileList) {
|
|
let token="jwtech " + getToken()
|
|
console.log(file)
|
|
// 替换为你的后端接口地址
|
|
const uploadUrl = baseUrl+'/common/upload';
|
|
uni.uploadFile({
|
|
header: {
|
|
'jianwei':token,
|
|
},
|
|
url: uploadUrl,
|
|
filePath: file.path,
|
|
name: 'file',
|
|
success: (res) => {
|
|
console.log('上传成功', res.data);
|
|
const responseData = JSON.parse(res.data);
|
|
this[fileList].push({
|
|
name: file.name,
|
|
fileName: responseData.fileName,
|
|
url: responseData.url,
|
|
uid: file.uid,
|
|
});
|
|
console.log(fileList, this[fileList]);
|
|
},
|
|
fail: (err) => {
|
|
console.error('上传失败', err);
|
|
},
|
|
});
|
|
},
|
|
|
|
// 判断必填项是否填写
|
|
judgeAttrWrite() {
|
|
const form = this.form
|
|
if (!form.projectName) {
|
|
uni.showToast({
|
|
title: `项目名称不能为空!`,
|
|
icon: 'none'
|
|
})
|
|
return false
|
|
}
|
|
if (!form.checkType) {
|
|
uni.showToast({
|
|
title: `检查类型不能为空!`,
|
|
icon: 'none'
|
|
})
|
|
return false
|
|
}
|
|
if (!form.inspectionTime) {
|
|
uni.showToast({
|
|
title: `检查时间不能为空!`,
|
|
icon: 'none'
|
|
})
|
|
return false
|
|
}
|
|
if (!form.inspectionUnit) {
|
|
uni.showToast({
|
|
title: `检查单位不能为空!`,
|
|
icon: 'none'
|
|
})
|
|
return false
|
|
}
|
|
if (!form.inspectionPerson) {
|
|
uni.showToast({
|
|
title: `被检查单位不能为空!`,
|
|
icon: 'none'
|
|
})
|
|
return false
|
|
}
|
|
if (!form.constituentMember) {
|
|
uni.showToast({
|
|
title: `组成成员不能为空!`,
|
|
icon: 'none'
|
|
})
|
|
return false
|
|
}
|
|
// if (!form.noticeAttachment) {
|
|
// uni.showToast({
|
|
// title: `检查通知不能为空!`,
|
|
// icon: 'none'
|
|
// })
|
|
// return false
|
|
// }
|
|
// if (!form.checklist) {
|
|
// uni.showToast({
|
|
// title: `整改通知不能为空!`,
|
|
// icon: 'none'
|
|
// })
|
|
// return false
|
|
// }
|
|
// if (!form.rectificationReport) {
|
|
// uni.showToast({
|
|
// title: `整改回复不能为空!`,
|
|
// icon: 'none'
|
|
// })
|
|
// return false
|
|
// }
|
|
return true
|
|
},
|
|
|
|
// 保存检查
|
|
handleConfirm() {
|
|
if (!this.judgeAttrWrite()) {
|
|
return
|
|
}
|
|
uni.showLoading({
|
|
title: '加载中...',
|
|
mask: true
|
|
})
|
|
console.log("88888888", this.form)
|
|
addNewInspections(this.form).then(res => {
|
|
uni.showToast({
|
|
title: `操作成功`,
|
|
icon: 'none'
|
|
})
|
|
uni.navigateTo({
|
|
url: `/pages/monitoring/list/index`
|
|
});
|
|
})
|
|
},
|
|
|
|
// 暂存功能
|
|
handleConfirmDraft() {
|
|
if (!this.judgeAttrWrite()) {
|
|
return
|
|
}
|
|
uni.showLoading({
|
|
title: '加载中...',
|
|
mask: true
|
|
})
|
|
if (this.monitorDraftId) {
|
|
this.form.id = this.monitorDraftId
|
|
console.log(9999,this.form)
|
|
updateInspectionsDraft(this.form).then(res => {
|
|
uni.showToast({
|
|
title: `操作成功`,
|
|
icon: 'none'
|
|
})
|
|
uni.navigateTo({
|
|
url: `/pages/monitoring/list/index`
|
|
});
|
|
})
|
|
} else {
|
|
addInspectionsDraft(this.form).then(res => {
|
|
uni.showToast({
|
|
title: `操作成功`,
|
|
icon: 'none'
|
|
})
|
|
uni.navigateTo({
|
|
url: `/pages/monitoring/list/index`
|
|
});
|
|
})
|
|
}
|
|
},
|
|
|
|
// 带问题列表的监督提交
|
|
handleConfirmMonitor() {
|
|
if (this.monitorId) {
|
|
this.form.noticeAttachment = JSON.stringify(this.fileList1);
|
|
this.form.checklist = JSON.stringify(this.fileList2);
|
|
this.form.rectificationReport = JSON.stringify(this.fileList3);
|
|
updateInspections(this.form).then(res => {
|
|
uni.showToast({
|
|
title: `操作成功`,
|
|
icon: 'none'
|
|
})
|
|
uni.navigateTo({
|
|
url: `/pages/monitoring/list/index`
|
|
});
|
|
})
|
|
} else {
|
|
addNewInspections(this.form).then(res => {
|
|
uni.showToast({
|
|
title: `操作成功`,
|
|
icon: 'none'
|
|
})
|
|
uni.navigateTo({
|
|
url: `/pages/monitoring/list/index`
|
|
});
|
|
})
|
|
}
|
|
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
</style>
|
|
|