From 4c4c6475fde41dbee74c6a071a187a47a1c4a243 Mon Sep 17 00:00:00 2001
From: XiaoRuby <3114200645@qq.com>
Date: 星期二, 22 八月 2023 09:24:08 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/views/laboratory/measure/Add.vue |  170 ++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 127 insertions(+), 43 deletions(-)

diff --git a/src/views/laboratory/measure/Add.vue b/src/views/laboratory/measure/Add.vue
index 0cf9cd1..224b34e 100644
--- a/src/views/laboratory/measure/Add.vue
+++ b/src/views/laboratory/measure/Add.vue
@@ -8,15 +8,15 @@
                 <el-form-item>
                     <el-col :span="6" style="display: flex;justify-content: space-around;">
                         <span>璐熻矗浜猴細</span>
-                        <el-select v-model="planAddInfo.measurePerson" placeholder="璇烽�夋嫨娲诲姩鍖哄煙">
-                            <el-option label="鍖哄煙涓�" value="shanghai"></el-option>
-                            <el-option label="鍖哄煙浜�" value="beijing"></el-option>
+                        <el-select v-model="planAddInfo.measurePerson" placeholder="璇烽�夋嫨璐熻矗浜�">
+                            <el-option v-for="item in userList" :key="item.value" :label="item.label" :value="item.value">
+                            </el-option>
                         </el-select>
                     </el-col>
                     <el-col :span="8" style="display: flex;justify-content: space-around;">
                         <span>璁″垝鏃堕棿锛�</span>
-                        <el-date-picker v-model="planAddInfo.planDate" type="daterange" range-separator="鑷�" start-placeholder="寮�濮嬫棩鏈�"
-                            end-placeholder="缁撴潫鏃ユ湡">
+                        <el-date-picker v-model="planAddInfo.planDate" type="daterange" range-separator="鑷�"
+                            start-placeholder="寮�濮嬫棩鏈�" end-placeholder="缁撴潫鏃ユ湡">
                         </el-date-picker>
                     </el-col>
                     <el-col :span="5"></el-col>
@@ -36,39 +36,54 @@
                     :show-text="false"></el-progress>
             </el-col>
         </el-col>
+
         <el-col style="width:93%;height: 20vh;margin-top: 30px; margin-left: 40px;">
+            <el-button icon="el-icon-plus" @click="addcodePointsTable()" style="margin-bottom: 10px;"
+                type="primary">鏂板璁¢噺</el-button>
             <el-table ref="codePointsTable" :cell-style="{ textAlign: 'center' }"
                 :header-cell-style="{ border: '0px', background: '#f5f7fa', color: '#606266', boxShadow: 'inset 0 1px 0 #ebeef5', textAlign: 'center' }"
                 :data="codePointsTable" style="width: 100%">
-                <el-table-column type="index" label="搴忓彿" min-width="90" />
-                <el-table-column prop="equipmentPointName" label="浠櫒璁惧鍚嶇О" min-width="150">
+                <el-table-column type="index" v-model="codePointsTable.index" label="搴忓彿" min-width="90" />
+                <el-table-column prop="equipmentPointName" label="浠櫒璁惧" min-width="150">
                     <template slot-scope="scope">
-                        <span v-show="!codePointesTableStatus">{{ scope.row.equipmentPoint }}</span>
-                        <el-input v-show="codePointesTableStatus" v-model="scope.row.equipmentPoint" />
+                        <span v-show="!codePointesTableStatus">{{ scope.row.equipmentPointName }}</span>
+                        <el-select @change="insListChange(scope.row.equipmentPointName,scope)" v-model="scope.row.equipmentPointName" placeholder="璇烽�夋嫨浠櫒璁惧">
+                            <el-option v-for="item in insList" :key="item.value" :label="item.label" :value="item.value">
+                            </el-option>
+                        </el-select>
                     </template>
                 </el-table-column>
-
                 <el-table-column prop="measuringRange" label="娴嬮噺鑼冨洿" min-width="150">
                     <template slot-scope="scope">
                         <span v-show="!codePointesTableStatus">{{ scope.row.measuringRange }}</span>
-                        <el-input v-show="codePointesTableStatus" v-model="scope.row.measuringRange" />
+                        <el-input disabled v-show="codePointesTableStatus" v-model="scope.row.measuringRange" />
                     </template>
                 </el-table-column>
-                <el-table-column prop="unit" label="鍗曚綅" min-width="150">
+                <el-table-column prop="termValidity" label="璁¢噺鍛ㄦ湡" min-width="150">
                     <template slot-scope="scope">
-                        <span v-show="!codePointesTableStatus">{{ scope.row.unit }}</span>
-                        <el-input v-show="codePointesTableStatus" v-model="scope.row.unit" />
+                        <span v-show="!codePointesTableStatus">{{ scope.row.termValidity }}</span>
+                        <el-input disabled v-show="codePointesTableStatus" v-model="scope.row.termValidity" />
                     </template>
                 </el-table-column>
-                <el-table-column prop="descriptiveness" label="鎻忚堪" min-width="200">
+                <el-table-column prop="result" label="璁¢噺缁撴灉" min-width="200">
                     <template slot-scope="scope">
-                        <span v-show="!codePointesTableStatus">{{ scope.row.descriptiveness }}</span>
-                        <el-input v-show="codePointesTableStatus" v-model="scope.row.descriptiveness" />
+                        <span v-show="!codePointesTableStatus">{{ scope.row.result }}</span>
+                        <el-select v-model="scope.row.result" placeholder="璇烽�夋嫨">
+                            <el-option v-for="item in result" :key="item.value" :label="item.label" :value="item.value">
+                            </el-option>
+                        </el-select>
                     </template>
                 </el-table-column>
-                <el-table-column prop="descriptiveness" label="鎿嶄綔" min-width="200">
+                <el-table-column prop="endDate" label="璁¢噺鏃ユ湡" min-width="200">
                     <template slot-scope="scope">
-                        <el-tag type="" icon=""></el-tag>
+                        <span v-show="!codePointesTableStatus">{{ scope.row.endDate }}</span>
+                        <el-date-picker v-model="scope.row.endDate" type="date" placeholder="閫夋嫨鏃ユ湡">
+                        </el-date-picker>
+                    </template>
+                </el-table-column>
+                <el-table-column prop="index" label="鎿嶄綔" min-width="200">
+                    <template slot-scope="scope">
+                        <span><a @click="removetableIndex(scope.row.index)" style="color: deepskyblue;">浣滃簾</a></span>
                     </template>
                 </el-table-column>
             </el-table>
@@ -76,41 +91,110 @@
     </div>
 </template>
 <script>
+import {
+    getListUserAndListIns, addPlanAndMeasure
+} from '@/api/laboratory/measure'
+import { dateFormat } from "../../../utils/dateUtil";
 export default {
     data() {
         return {
             planAddInfo: {
-                plannedOrderNumber: 7897897987,
-                measurePerson: '鏌愭煇浜�',
-                planDate: "2021-09-08 ~ 2024-08-09",
-                unit: '鏌愭煇妫�娴嬪眬',
-                createPerson: '鏌愭煇璐熻矗浜�',
-                createTime: '2021-09-08'
+                plannedOrderNumber: '',
+                measurePerson: '',
+                planDate: "",
+                unit: '',
+                createPerson: '',
+                createTime: ''
             },
             codePointsTable: [{
-                id: '',
+                "index": 1,
+                "equipmentPointName": '',
+                "measuringRange": '',
+                "termValidity": "",
+                "result": null,
+            }],
+            result: [{
+                label: '鍚堟牸',
+                value: 1
+            }, {
+                label: '鐭鍚庡彲鐢�',
+                value: 2
+            }, {
+                label: '涓嶅悎鏍�',
+                value: 3
+            }],
+            userList: [],
+            insList: [],
+            instrumentList:[],
+            // 鐮佺偣琛ㄦ牸鐨勭姸鎬侊細鏁版嵁灞曠ずfalse/鏂板杈撳叆true
+            codePointesTableStatus: false,
+        }
+    },
+    async created() {
+        this.codePointsTable = []
+        let res = await getListUserAndListIns()
+        res.data.userList.forEach(element => {
+            this.userList.push({ label: element.name, value: element.id })
+        });
+        this.instrumentList=res.data.instrumentList
+        res.data.instrumentList.forEach(item => {
+            this.insList.push({ label: item.equipmentName, value: item.id })
+        })
+        console.log(this.insList);
+    },
+    methods: {
+        addcodePointsTable() {
+            const newObj = {
+                index: this.codePointsTable.length + 1,
                 equipmentPointName: '',
                 measuringRange: '',
                 termValidity: "",
-                planDate: null,
-            }],
-            // 鐮佺偣琛ㄦ牸鐨勭姸鎬侊細鏁版嵁灞曠ずfalse/鏂板杈撳叆true
-            codePointesTableStatus: true,
-        }
-    },
-    methods: {
-        // 鏂板璁惧鐮佺偣
-        addNewCodePoints() {
-            //
-            if (!this.codePointsTable) {
-                this.codePointsTable = []
+                result: null,
+                endDate: null,
+                planDate: null
             }
-            const newObj = {}
-            newObj.equipmentPointName = ''
-            newObj.descriptiveness = ''
-            newObj.unit = ''
-            newObj.instrumentId = this.equipmentDetail.id
             this.codePointsTable.push(newObj)
+            this.codePointesTableStatus = true
+        },
+        removetableIndex(id) {
+            this.codePointsTable = this.codePointsTable.filter(item => {
+                return item.index != id;
+            })
+        },
+        async add() {
+            console.log(111111);
+            this.planAddInfo.startTime = dateFormat(this.planAddInfo.planDate[0])
+            this.planAddInfo.endTime = dateFormat(this.planAddInfo.planDate[1])
+            console.log(this.planAddInfo);
+            this.planAddInfo.planDate = null
+            this.codePointsTable.forEach(item => {
+                if(item.endDate!=null&&item.endDate!=''){
+                    item.endDate = dateFormat(item.endDate)
+                }
+            })
+            console.log(this.codePointsTable);            
+            let data = {}
+            this.codePointsTable.length>0?data = { measureList: this.codePointsTable, plan: this.planAddInfo }:data = {plan: this.planAddInfo }
+            let add = await addPlanAndMeasure(data)
+            this.planAddInfo={
+                plannedOrderNumber: '',
+                measurePerson: '',
+                planDate: "",
+                unit: '',
+                createPerson: '',
+                createTime: ''
+            }
+            this.codePointsTable=[]
+            return add.data
+        },
+        insListChange(i,s){
+            console.log(i);
+            console.log(s.$index);
+            let ins= this.instrumentList.filter(item=>{
+                return item.id==i
+            })[0]
+            this.codePointsTable[s.$index].measuringRange=ins.measuringRange
+            this.codePointsTable[s.$index].termValidity=ins.termValidity+'鏈�'
         }
     }
 }

--
Gitblit v1.9.3