<template>
|
<div class="add">
|
<el-dialog
|
:isEdit="isEdit"
|
:title="isEdit ? '编辑工作监督记录':'新增工作监督记录'"
|
:visible.sync="dialogVisible"
|
width="800"
|
>
|
<el-steps v-if="isEdit" :active="active" :align-center="true" finish-status="success">
|
<el-step style="cursor: pointer;" title="检测" @click.native="setStep(0)"></el-step>
|
<el-step style="cursor: pointer;" title="审批" @click.native="setStep(1)"></el-step>
|
</el-steps>
|
<SuperviseForm
|
v-show="pageStatus == 0"
|
ref="superviseFormRef"
|
:disabled="active != 0"
|
:isEdit="isEdit"
|
:superviseForm.sync="mainForm.superviseForm"
|
:userList="userList"
|
@addData="addData"
|
@close="closeDialog"
|
@submit="submit"
|
></SuperviseForm>
|
<ApproveForm
|
v-show="pageStatus == 1"
|
ref="approveFormRef"
|
:approveForm.sync="mainForm.approveForm"
|
:disabled="active != 1"
|
:isEdit="isEdit"
|
:userList="userList"
|
@close="toClose"
|
@submit="submit"
|
></ApproveForm>
|
<el-result v-show="pageStatus == 2" icon="success" subTitle="处理完成" title="审核完成">
|
</el-result>
|
</el-dialog>
|
</div>
|
</template>
|
<script>
|
import SuperviseForm from './supervise/SuperviseForm.vue'
|
import ApproveForm from './supervise/ApproveForm.vue'
|
import {
|
getUserListApi,
|
addOrUpdatePersonSupervisionRecord
|
} from "../../../../../assets/api/api"
|
import dayjs from 'dayjs'
|
|
export default {
|
components: {
|
SuperviseForm,
|
ApproveForm
|
},
|
data() {
|
return {
|
active: 0,
|
pageStatus: 0,
|
isEdit: false,
|
dialogVisible: false,
|
userList: [],
|
id: undefined,
|
mainForm: {
|
superviseForm: {
|
testerId: undefined,
|
supervisorId: undefined,
|
testItem: undefined,
|
sampleNumber: undefined,
|
detectionDate: undefined,
|
personnel: [],
|
instrumentEquipment: undefined,
|
workingEnvironment: undefined,
|
sampleCollection: undefined,
|
samplePreparation: undefined,
|
testMethod: undefined,
|
testingRecords: undefined,
|
testReport: undefined,
|
evaluationSupervisionSituation: undefined,
|
doNotMeetTheHandlingOpinions: undefined,
|
},
|
approveForm: {
|
technicalDirector: undefined
|
}
|
}
|
}
|
},
|
methods: {
|
async openDialog(row, type=false) {
|
this.dialogVisible = true
|
this.isEdit = type
|
await this.getUserList()
|
if(this.isEdit) {
|
// 编辑
|
this.loadForm(row)
|
this.id = row.id
|
} else {
|
// 新增
|
this.resetForm(row)
|
this.id = undefined
|
}
|
},
|
/**
|
* @desc 加载表单
|
*/
|
loadForm(row) {
|
if(row.currentState) {
|
this.active = Number(row.currentState)
|
this.pageStatus = Number(row.currentState === '2' ? 0 : row.currentState)
|
}
|
// 第1步
|
this.mainForm.superviseForm.testerId = row.testerId
|
this.mainForm.superviseForm.supervisorId = row.supervisorId
|
this.mainForm.superviseForm.testItem = row.testItem
|
this.mainForm.superviseForm.sampleNumber = row.sampleNumber
|
this.mainForm.superviseForm.detectionDate = row.detectionDate
|
let personList = row.personnel.split(',')
|
this.mainForm.superviseForm.personnel = personList.map(item => {
|
return Number(item)
|
});
|
this.mainForm.superviseForm.instrumentEquipment = row.instrumentEquipment
|
this.mainForm.superviseForm.workingEnvironment = row.workingEnvironment
|
this.mainForm.superviseForm.sampleCollection = row.sampleCollection
|
this.mainForm.superviseForm.samplePreparation = row.samplePreparation
|
this.mainForm.superviseForm.testMethod = row.testMethod
|
this.mainForm.superviseForm.testingRecords = row.testingRecords
|
this.mainForm.superviseForm.testReport = row.testReport
|
this.mainForm.superviseForm.evaluationSupervisionSituation = row.evaluationSupervisionSituation
|
this.mainForm.superviseForm.doNotMeetTheHandlingOpinions = row.doNotMeetTheHandlingOpinions
|
// 第2步
|
this.mainForm.approveForm.technicalDirector = row.technicalDirector
|
},
|
/**
|
* @desc 重置表单
|
*/
|
resetForm(row) {
|
console.log(row)
|
this.active = 0
|
this.pageStatus = 0
|
// 第1个
|
this.mainForm.superviseForm.currentState = undefined
|
this.mainForm.superviseForm.testerId = undefined
|
this.mainForm.superviseForm.supervisorId = undefined
|
this.mainForm.superviseForm.testItem = undefined
|
this.mainForm.superviseForm.sampleNumber = undefined
|
this.mainForm.superviseForm.detectionDate = undefined
|
this.mainForm.superviseForm.personnel = [row.departId]
|
this.mainForm.superviseForm.instrumentEquipment = undefined
|
this.mainForm.superviseForm.workingEnvironment = undefined
|
this.mainForm.superviseForm.sampleCollection = undefined
|
this.mainForm.superviseForm.samplePreparation = undefined
|
this.mainForm.superviseForm.testMethod = undefined
|
this.mainForm.superviseForm.testingRecords = undefined
|
this.mainForm.superviseForm.testReport = undefined
|
this.mainForm.superviseForm.evaluationSupervisionSituation = undefined
|
this.mainForm.superviseForm.doNotMeetTheHandlingOpinions = undefined
|
// 第2个
|
this.mainForm.approveForm.technicalDirector = undefined
|
},
|
closeDialog() {
|
this.dialogVisible = false
|
},
|
/**
|
* @desc 获取用户信息
|
*/
|
async getUserList() {
|
const { code, data } = await this.$axios({
|
method: 'get',
|
url: getUserListApi,
|
})
|
if(code == 200) {
|
this.userList = data
|
}
|
},
|
/**
|
* @desc 驳回
|
*/
|
toClose() {
|
this.submitFormApi({
|
id: this.id,
|
currentState: 0,
|
})
|
},
|
/**
|
* @desc 新增
|
*/
|
addData(step) {
|
let data = this.setParams(step)
|
this.submitFormApi(data)
|
},
|
/**
|
* @desc 编辑
|
*/
|
submit(step) {
|
console.log('编辑', this.isEdit)
|
let data = this.setParams(step)
|
data.id = this.id
|
this.submitFormApi(data)
|
},
|
// 设置参数
|
setParams(step) {
|
if(step == 1) {
|
let result = this.mainForm.superviseForm
|
result.currentState = this.active + 1
|
result.personnel = result.personnel.join(",")
|
result.technicalDirectorDate = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
return result
|
}
|
if(step == 2) {
|
let result = this.mainForm.approveForm
|
result.currentState = this.active + 1
|
return result
|
}
|
},
|
// 向服务器发送表单
|
async submitFormApi(data) {
|
console.log('接口表单', data)
|
const { code } = await this.$axios({
|
method: 'post',
|
url: addOrUpdatePersonSupervisionRecord,
|
data: data,
|
noQs: true
|
})
|
if(code == 200) {
|
this.$message.success('操作成功')
|
this.dialogVisible = false
|
this.$emit('submit')
|
}
|
},
|
setStep(e) {
|
this.pageStatus = e
|
}
|
}
|
}
|
</script>
|
<style scoped>
|
.foot {
|
width: 100%;
|
}
|
.add >>> .el-dialog__footer {
|
padding-right: 20px;
|
}
|
.main_right {
|
text-align: left;
|
}
|
</style>
|