From 14d29f928b24d203e76f1dcefc1a51182657cd45 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期一, 10 三月 2025 16:29:09 +0800
Subject: [PATCH] Merge branch 'dev' of http://114.132.189.42:9002/r/center-lims-before-ruoyi into dev

---
 src/views/CNAS/personnel/personnelInfo/Department/components/Records/Add.vue |  234 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 234 insertions(+), 0 deletions(-)

diff --git a/src/views/CNAS/personnel/personnelInfo/Department/components/Records/Add.vue b/src/views/CNAS/personnel/personnelInfo/Department/components/Records/Add.vue
new file mode 100644
index 0000000..0919282
--- /dev/null
+++ b/src/views/CNAS/personnel/personnelInfo/Department/components/Records/Add.vue
@@ -0,0 +1,234 @@
+<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>

--
Gitblit v1.9.3