<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" :departId="departId"
|
: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" :departId="departId" :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 {
|
selectUserList,
|
addOrUpdatePersonSupervisionRecord
|
} from '@/api/cnas/personnel/personnelInfo.js'
|
import { dateFormat } from '@/utils/date.js'
|
|
export default {
|
props: {
|
departId: {
|
type: Number,
|
default: null
|
}
|
},
|
|
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
|
console.log('type', this.isEdit);
|
await this.getUserList()
|
if (this.isEdit) {
|
// 编辑
|
this.loadForm(row)
|
this.id = row.id
|
console.log(1111);
|
} else {
|
// 新增
|
this.resetForm(row)
|
this.id = undefined
|
console.log(22222);
|
}
|
console.log('this.id', this.id);
|
},
|
/**
|
* @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.personnel = row.personnel
|
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 = undefined
|
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
|
console.log('新增', this.mainForm);
|
|
|
},
|
closeDialog() {
|
this.dialogVisible = false
|
},
|
/**
|
* @desc 获取用户信息
|
*/
|
async getUserList() {
|
const { code, data } = await selectUserList()
|
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) {
|
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.technicalDirectorDate = dateFormat(new Date(), '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)
|
// 将部门带入
|
if (data.id == null) {
|
data.departLimsId = this.departId
|
}
|
const { code } = await addOrUpdatePersonSupervisionRecord(data)
|
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>
|