From b5d7cad27e6d6382cc375a7bbfb91aad0c31195c Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期二, 31 十月 2023 18:05:56 +0800
Subject: [PATCH] 	modified:   src/api/quality/finishedProduct.js 	modified:   src/api/quality/rawMaterial.js 	modified:   src/router/views/index.js 	new file:   src/views/common/rawMaterial-part.vue 	modified:   src/views/common/ztt-table.vue 	modified:   src/views/quality/finishedProductInspection/finishedProductInspectionAdd.vue 	modified:   src/views/quality/finishedProductInspection/index.vue 	modified:   src/views/quality/rawMaterial/rawMaterial-form.vue

---
 src/views/quality/finishedProductInspection/finishedProductInspectionAdd.vue |  387 ++++++++++++++++--------------------------------------
 1 files changed, 116 insertions(+), 271 deletions(-)

diff --git a/src/views/quality/finishedProductInspection/finishedProductInspectionAdd.vue b/src/views/quality/finishedProductInspection/finishedProductInspectionAdd.vue
index c45132a..3115e72 100644
--- a/src/views/quality/finishedProductInspection/finishedProductInspectionAdd.vue
+++ b/src/views/quality/finishedProductInspection/finishedProductInspectionAdd.vue
@@ -7,7 +7,7 @@
             <h2>缂栬緫-浜у搧妫�楠�</h2>
         </div>
         <div class="btn-group header-right">
-            <el-button @click="addTestProjevt">鐢熸垚妫�楠岄」鐩�</el-button>
+            <el-button @click="addTestProject">鐢熸垚妫�楠岄」鐩�</el-button>
         </div>
     </div>
     <div class="page-main">
@@ -34,21 +34,21 @@
                             </el-form-item>
                         </el-col>
                         <el-col :span="6">
-                            <el-form-item label="浜у搧鍚嶇О锛�">
-                                <el-select style="width: 100%" @change="changeOptionsSamplename"
-                                    v-model="processInspectVo.material" size="small" placeholder="璇烽�夋嫨浜у搧鍚嶇О">
-                                    <el-option v-for="item in optionsSamplename" :key="item.id" :label="item.name"
-                                        :value="item.id + '-' + item.name">
-                                    </el-option>
-                                </el-select>
+                            <el-form-item label="璐ㄩ噺杩芥函鍙凤細">
+                                <el-input disabled v-model="processInspectVo.qualityTraceability"
+                                    placeholder="璇疯緭鍏ヨ川閲忚拷婧彿" autocomplete="off" />
                             </el-form-item>
                         </el-col>
                     </el-row>
                     <el-row>
                         <el-col :span="6">
-                            <el-form-item label="璐ㄩ噺杩芥函鍙凤細">
-                                <el-input disabled v-model="processInspectVo.qualityTraceability"
-                                    placeholder="璇疯緭鍏ヨ拷婧彿" autocomplete="off" />
+                            <el-form-item label="浜у搧鍚嶇О锛�">
+                                <el-select style="width: 100%" @change="changeOptionsSamplename"
+                                    v-model="processInspectVo.material" size="small" placeholder="璇烽�夋嫨浜у搧鍚嶇О">
+                                    <el-option v-for="(item,index) in optionsSamplename" :key="index" :label="item.material"
+                                        :value="item.materialCode">
+                                    </el-option>
+                                </el-select>
                             </el-form-item>
                         </el-col>
                         <el-col :span="6">
@@ -60,13 +60,13 @@
                         <el-col :span="6">
                             <el-form-item label="瑙勬牸鍨嬪彿锛�">
                                 <el-input disabled v-model="processInspectVo.specificationsModel"
-                                    placeholder="璇疯緭鍏ヤ骇鍝佺紪鐮�" autocomplete="off" />
+                                    placeholder="璇疯緭鍏ヨ鏍煎瀷鍙�" autocomplete="off" />
                             </el-form-item>
                         </el-col>
                         <el-col :span="6">
                             <el-form-item label="鍗曚綅锛�">
                                 <el-input disabled v-model="processInspectVo.unit"
-                                    placeholder="璇疯緭鍏ヤ骇鍝佺紪鐮�" autocomplete="off" />
+                                    placeholder="璇疯緭鍏ュ崟浣�" autocomplete="off" />
                             </el-form-item>
                         </el-col>
                     </el-row>
@@ -91,21 +91,22 @@
             </el-row>
             <el-row style="width:100%;">
                 <el-col :span="24">
-                    <el-table border :data="inspectionItems" max-height="400" :span-method="handleSpanMethod" height="calc(100vh - 550px)"
-                        style="width: 100%">
+                    <el-table border :data="inspectionItems" max-height="400" height="calc(100vh - 550px)"
+                        :header-cell-style="{textAlign:'center',color:'black',backgroundColor:'#fafafa'}" 
+                        :cell-style="{textAlign:'center'}" row-key="iid"
+                        style="width: 100%" ref="table" :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
                         <el-table-column type="index" label="搴忓彿" width="60"></el-table-column>
                         <el-table-column label="椤圭洰" prop="father"></el-table-column>
-                        <el-table-column prop="name" label="鎸囨爣"></el-table-column>
-                        <el-table-column prop="unit" label="鍗曚綅"></el-table-column>
+                        <el-table-column prop="iname" label="鎸囨爣"></el-table-column>
+                        <el-table-column prop="iunit" label="鍗曚綅"></el-table-column>
                         <el-table-column prop="required" label="鏍囧噯鍊�"></el-table-column>
-                        <el-table-column prop="internal" label="鍐呮祴鍊�"></el-table-column>
                         <el-table-column prop="inspectionValue" v-for="(item, index) in empiricalValueAdd" :key="index" label="妫�娴嬪��"
                             min-width="100" style="text-align: center;">
                             <template slot-scope="scope">
                                 <el-tooltip :disabled="scope.row.dname != null" class="item" effect="dark" content="璇峰厛閫夋嫨璁惧锛�"
                                     placement="top-start">
-                                    <el-input :disabled="scope.row.dname === null" v-model="scope.row.empiricalValueAddss[index]"
-                                        @blur="changeState(scope.row, index)" placeholder="璇疯緭鍏ユ娴嬪��"></el-input>
+                                    <!-- <el-input :disabled="scope.row.dname === null" v-model="scope.row.empiricalValueAddss[index]"
+                                        @blur="changeState(scope.row, index)" placeholder="璇疯緭鍏ユ娴嬪��"></el-input> -->
                                 </el-tooltip>
                             </template>
                         </el-table-column>
@@ -120,7 +121,15 @@
                                 </el-select>
                             </template>
                         </el-table-column>
-                        <el-table-column label="缁撹">
+                        <el-table-column prop="deviceName" label="璇曢獙璁惧" min-width="260">
+                            <template slot-scope="scope">
+                            <el-select style="width:100%" v-model="scope.row.equipmentId" filterable @change="updateDevice(scope.row)">
+                                <el-option v-for="(item,index) in deviceList" 
+                                :key="index" :value="item.id" :label="item.number +'-'+ item.name"></el-option>
+                            </el-select>
+                            </template>
+                        </el-table-column>
+                        <el-table-column label="缁撹" fixed="right" min-width="100">
                             <template slot-scope="scope">
                                 <span style="color: #34BD66;" v-if="scope.row.result === 1">鍚堟牸</span>
                                 <span style="color: #E84738;" v-else-if="scope.row.result === 0">涓嶅悎鏍�</span>
@@ -137,7 +146,9 @@
             </el-row>
             <el-row style="width:100%;margin-top:-180px">
                 <el-col :span="24">
-                    <el-table border max-height="400" :data="inspectionResultForm">
+                    <el-table border max-height="400" :data="inspectionResultForm"
+                    :header-cell-style="{textAlign:'center',color:'black',backgroundColor:'#fafafa'}" 
+                    :cell-style="{textAlign:'center'}">
                         <el-table-column prop="id" label="鐗╂枡缂栧彿"></el-table-column>
                         <el-table-column prop="name" label="鐗╂枡鍚嶇О"></el-table-column>
                         <el-table-column prop="inspecter" label="妫�楠屽憳"></el-table-column>
@@ -160,9 +171,16 @@
 </template>
 
 <script>
+import { 
+    chooseMater,
+    addFinish,
+    queryById, } from '@/api/quality/finishedProduct'
+import { updateDeviceById,selectDevice } from '@/api/quality/rawMaterial'
 export default {
     data() {
         return {
+            deviceList: [],
+            hasChildren: true,
             showUp: false,
             isAddProject: false,
             showLook: false,
@@ -195,7 +213,7 @@
                 mcode: null,
                 prname: null,
                 sname: null,
-                orderNumber: "",
+                orderNumber: "ZTTIC20230001",
                 qualityTraceability: null,
                 quantity: null,
                 specificationsModel: null,
@@ -254,27 +272,40 @@
         };
     },
     watch: {
-        // filterText(val) {
-        //     this.$refs.tree.filter(val);
-        // }
+    },
+    beforeUpdate(){
+      this.$nextTick(()=>{
+        this.$refs.table.doLayout();
+      })
+    },
+    created() {
     },
     mounted() {
-        this.getTableData()
-        // this.getOptions();
+        this.getDeviceList()
     },
     methods: {
-        changeOptionsSamplename() {
-            let id = this.processInspectVo.material.split("-")[0]
-            let sample = this.optionsSamplename.filter(o => {
-                return o.id == id
-            })[0]
-            this.processInspectVo.qualityTraceability = sample.qualityTraceability
-            this.processInspectVo.mcode = sample.mcode
-            this.processInspectVo.specificationsModel = sample.specifications
-            this.processInspectVo.unit = sample.unit
+        getDeviceList(){
+            selectDevice(null).then(res=>{
+            this.deviceList = res.data.data
+            })
         },
-        comBack() {
-            this.$parent.comBackMain()
+        updateDevice(row){
+            if(this.dataForm.id != null){
+            updateDeviceById({equiomentId:row.equipmentId,rpId:row.rpId}).then(res=>{
+            }).catch(error=>{
+                console.log(error)
+            })
+            }
+        },
+        changeOptionsSamplename(val) {
+            let sample = this.optionsSamplename.filter(o => {
+                return o.materialCode == val
+            })[0]
+            // this.processInspectVo.qualityTraceability = sample.qualityTraceability
+            this.processInspectVo.mcode = sample.materialCode
+            this.processInspectVo.material = sample.material
+            this.processInspectVo.specificationsModel = sample.specs
+            this.processInspectVo.unit = sample.unit
         },
         handleClick(row) {
             this.rowInfp = row
@@ -284,44 +315,10 @@
             this.rowInfp = row
             this.showUp = true
         },
-        combackMain() {
-            this.showUp = false
-            this.showLook = false
-        },
         searchPro() {
             this.search.countSize = this.pageSize
             this.search.pageSize = this.currentPage
             this.defaultInitializationTable()
-        },
-        // 鐐瑰嚮璁惧鏍戜繚瀛樼偣鍑昏褰�
-        nodeClick(data) {
-            if (data.id != undefined) this.nodeData = data;
-        },
-        // 璁惧鏍戣繃婊ゆ悳绱�
-        filterNode(value, data) {
-            if (!value) return true;
-            return data.name.indexOf(value) !== -1;
-        },
-        // 鑾峰彇璁惧鏍戝唴瀹�
-        getOptions(row) {
-            this.$axios.get(this.$api.url.inspectionItemChooseDev, {
-                params: {
-                    father: row.father,
-                    name: row.name,
-                    technologyId: this.processInspectVo.technologyId
-                }
-            }).then(res => {
-                this.materialOptions = res.data;
-                this.filterText = row.did
-                if(this.materialOptions.length===1){
-                    this.$message({
-                    message: '璇ラ」鐩笅鍙湁涓�涓瘯楠岃澶囷紝鏃犻渶閫夋嫨锛�',
-                    type: 'warning'
-                });
-                    return
-                }
-                row.isSelectDevice = true
-            });
         },
         // 鐐瑰嚮琛ㄦ牸閫夋嫨瑙﹀彂
         clickTableSelect(scope) {
@@ -331,35 +328,6 @@
             this.clickSelectDevice.index = scope.$index;
             this.clickSelectDevice.rpId = scope.row.id;
             this.getOptions(scope.row);
-        },
-        // 鐐瑰嚮鏍戦噷闈㈢殑纭畾
-        clickNodeSure(row) {
-            let select = this.materialOptions.filter(item => {
-                return item.id === this.filterText
-            })[0]
-            this.nodeData.id = select.id
-            this.nodeData.name = select.device
-            if (this.detailId == null) {
-                this.inspectionItems[
-                    this.clickSelectDevice.index
-                ].did = this.nodeData.id;
-                this.inspectionItems[
-                    this.clickSelectDevice.index
-                ].dname = this.nodeData.name;
-                this.centerDialogVisible = false;
-            } else {
-                this.$axios
-                    .post(this.$api.url.inspectionItemUpdateDevByInsId, {
-                        id: this.clickSelectDevice.rpId,
-                        type: 2,
-                        devId: this.nodeData.id
-                    })
-                    .then(res => {
-                        this.getTableData()
-                        this.centerDialogVisible = false;
-                        row.isSelectDevice=false
-                    });
-            }
         },
         changeState(row, index) {
             if (row.did != null && row.did != '') {
@@ -400,187 +368,67 @@
                 });
             }
         },
-        // 姣忛〉鏉℃暟鏀瑰彉鏃惰Е鍙� 閫夋嫨涓�椤垫樉绀哄灏戣
-        handleSizeChange(val) {
-            this.search.countSize = val;
-            this.defaultInitializationTable();
-        },
-        handleSpanMethod({ row, column, rowIndex, columnIndex }) {
-            if (columnIndex === 0) {
-                const _row = this.spanArr[rowIndex];
-                const _col = _row > 0 ? 1 : 0;
-                return {
-                    rowspan: _row,
-                    colspan: _col
-                }
+        addTestProject() {
+            let val = this.processInspectVo
+            let data = {
+                customerName: val.prname,
+                material: val.material,
+                materialCode: val.mcode,
+                orderNumber: val.orderNumber,
+                projectName: val.sname,
+                quantity: val.quantity,
+                specs: val.specificationsModel,
+                unit: val.unit,
             }
-            if (columnIndex === 1) {
-                const _row = this.spanArr[rowIndex];
-                const _col = _row > 0 ? 1 : 0;
-                return {
-                    rowspan: _row,
-                    colspan: _col
-                }
-            }
-        },
-        // 鍚堝苟琛ㄦ牸
-        mergeTable() {
-            this.rowList = []
-            this.spanArr = []
-            this.position = 0
-            this.inspectionItems.forEach((item, index) => {
-                if (index === 0) {
-                    this.spanArr.push(1);
-                    this.position = 0;
-                } else {
-                    if (this.inspectionItems[index].father === this.inspectionItems[index - 1].father) {
-                        this.spanArr[this.position] += 1;
-                        this.spanArr.push(0);
-                    } else {
-                        this.spanArr.push(1);
-                        this.position = index;
-                    }
-                }
-            })
-        },
-        changeOptionSoptionSprocesses() {
-            this.optionTechnology = []
-            let working = this.optionSoptionSprocesses.filter(item => {
-                return item.name === this.processInspectVo.techfather
-            })[0]
-            this.optionTechnology = working.children
-        },
-        addTestProjevt() {
-            // this.isAddProject = true
-            let val = JSON.parse(JSON.stringify(this.processInspectVo))
-            val.material = this.processInspectVo.material.split("-")[1]
-            val.id = this.processInspectVo.material.split("-")[0]
-            this.$axios.post(this.$api.url.finishedInspectAddFinish, val, {
-                headers: { "Content-Type": "application/json" }
-            }).then(res => {
-                if (res.code == 201) {
-                    this.$message({
-                        message: res.message,
-                        type: 'warning'
-                    });
-                    return
-                }
-                this.detailId = res.data
-                this.inspectionResultForm[0].id = val.mcode
-                this.inspectionResultForm[0].name = val.material
-                this.getTableData()
-            })
-        },
-        getTableData() {
-            this.$axios.get(this.$api.url.finishedInspectSelectFinishInspectsListById, {
-                params: {
-                    id: this.detailId
-                }
-            }).then(res => {
-                this.processInspectVo.technologyId = res.data[0].techId
-            })
-            this.$axios.get(this.$api.url.inspectionItemListUser, {
-                params: {
-                    id: this.detailId,
-                    type: 2
-                }
-            }).then(res => {
-                if (res.data.length < 1) {
-                    return
-                }
-                this.inspectionItems = res.data
-                let arr = []
-                let val = JSON.parse(JSON.stringify(this.inspectionItems))
-                const uName = []
-                //杞垚涓�缁存暟缁�
-                val.forEach(l => {
-                    let father = l.father
-                    l.children.forEach(c => {
-                        c.father = father
-                        c.empiricalValueAddss = []
-                        if (c.inspectionValue != '' && c.inspectionValue != null) {
-                            c.empiricalValueAddss = c.inspectionValue.split(",");
-                        } else {
-                            c.empiricalValueAddss.push("")
-                        }
-                        uName.push(c['username'])
-                        c.isSelectDevice = false
-                        arr.push(c)
+            addFinish(data).then(res=>{
+                let id = res.data.data
+                if(id != null){
+                    queryById(id).then(response=>{
+                        console.log(response.data.data.children)
+                        let proList = response.data.data.children
+                        proList.forEach(item=>{
+                            item.iid = Math.random();
+                        })
+                        this.inspectionItems = proList
+                    }).catch(error=>{
+                        console.log(error);
                     })
-                })
-                this.inspectionItems = arr
-                let arrSort = JSON.parse(JSON.stringify(arr))
-                //鏍规嵁闆嗗悎瀵硅薄鏁扮粍闀垮害鎺掑簭
-                arrSort.sort((a, b) => {
-                    if (a.empiricalValueAddss.length < b.empiricalValueAddss.length) {
-                        return -1; // a鎺掑湪b鍓嶉潰
-                    } else if (a.empiricalValueAddss.length > b.empiricalValueAddss.length) {
-                        return 1; // a鎺掑湪b鍚庨潰
-                    } else {
-                        return 0; // 淇濇寔鐩稿椤哄簭涓嶅彉
-                    }
-                });
-                // console.log(arrSort);
-                console.log(uName);
-                let name = [...new Set(uName)].filter(item => item !== null);
-                let rname = ''
-                name.forEach(m => {
-                    rname += m + ","
-                })
-                this.inspectionResultForm[0].inspecter = rname.slice(0, -1)
-                this.empiricalValueAdd = arrSort[arrSort.length - 1].empiricalValueAddss.length
-                this.mergeTable(arr)
+                }
+            }).catch(error=>{
+                console.log(error)
             })
-        },
-        selectSample() {
-            let sample = this.optionsSamplename.filter(item => {
-                return item.name === this.processInspectVo.material
-            })[0]
-            this.processInspectVo.techfather = null
-            this.processInspectVo.techname = null
-            this.processInspectVo.materialCode = sample.code
-            this.processInspectVo.specificationsModel = sample.specifications
-            this.processInspectVo.unit = sample.unit
-            this.optionSoptionSprocesses = []
-            this.optionSoptionSprocesses = sample.children
         },
         selectInfoByOrderId() {
-            this.$axios.get(this.$api.url.finishedInspectChooseMater, {
-                params: {
+            chooseMater({
                     orderNumber: this.processInspectVo.orderNumber
-                }
-            }).then(res => {
-                if (res.data.length > 0) {
-                    console.log(res.data);
-                    this.processInspectVo.sname = res.data[0].sname
-                    this.processInspectVo.prname = res.data[0].prname
-                    this.optionsSamplename = res.data[0].children
+                }).then(res => {
+                if (res.data.data != null) {
+                    this.processInspectVo.sname = res.data.data.projectName
+                    this.processInspectVo.prname = res.data.data.customerName
+                    this.optionsSamplename = res.data.data.children
                 } else {
                     this.$message({
                         message: '娌℃湁璇ヨ鍗曞彿锛�',
                         type: 'warning'
                     });
+                    this.processInspectVo.sname = null
+                    this.processInspectVo.prname = null
+                    this.optionsSamplename = []
+                    this.processInspectVo.mcode = null
+                    this.processInspectVo.material = null
+                    this.processInspectVo.specificationsModel = null
+                    this.processInspectVo.unit = null
                 }
             })
         },
-        // 褰撳墠椤垫敼鍙樻椂瑙﹀彂 璺宠浆鍏朵粬椤�
-        handleCurrentChange(val) {
-            this.search.pageSize = val;
-            this.defaultInitializationTable();
-        },
-        // 鏄剧ず鏂板椤甸潰
-        handleAddNew() {
-            this.showAddPage = true;
-            // this.getTableData()
-        },
         // 琛ㄦ牸鍒濆鍖栨帴鍙�
         defaultInitializationTable() {
-            this.$axios
-                .post(this.$api.url.selectProcessInspectsList, this.search)
-                .then(res => {
-                    this.inspectionTableTotal = res.data.total;
-                    this.inspectionTable = res.data.row;
-                });
+            // this.$axios
+            //     .post(this.$api.url.selectProcessInspectsList, this.search)
+            //     .then(res => {
+            //         this.inspectionTableTotal = res.data.total;
+            //         this.inspectionTable = res.data.row;
+            //     });
         },
         // 娣诲姞琛�
         clickAddLine() {
@@ -618,9 +466,6 @@
             this.empiricalValueAdd = this.empiricalValueAdd + 1;
         }
     },
-    created() {
-        this.defaultInitializationTable(); // 鍒濆鍖栬〃鏍兼暟鎹�
-    }
 }
 </script>
 
@@ -639,7 +484,7 @@
 
 .finishedProduct-basic {
   background-color: #fff;
-  height: 150px;
+  height: 155px;
   display: flex;
   flex-wrap: wrap;
   padding: 10px 20px;

--
Gitblit v1.9.3