From 032ddb30a8d9d884cc176a4a506580b4a1272586 Mon Sep 17 00:00:00 2001 From: zouyu <2723363702@qq.com> Date: 星期二, 26 十二月 2023 17:14:07 +0800 Subject: [PATCH] 模态框ui调整 --- src/views/quality/packageinspect/packageInspect-form.vue | 338 +++++++++++++++++++++++++++++++------------------------ 1 files changed, 190 insertions(+), 148 deletions(-) diff --git a/src/views/quality/packageinspect/packageInspect-form.vue b/src/views/quality/packageinspect/packageInspect-form.vue index 5fbff88..4dc8c5c 100644 --- a/src/views/quality/packageinspect/packageInspect-form.vue +++ b/src/views/quality/packageinspect/packageInspect-form.vue @@ -3,10 +3,10 @@ <div class="page-header"> <div class="header-left"> <a @click="$router.go(-1)"><i class="icon-btn-back"></i></a> - <h2>缂栬緫-鍖呰妫�楠�</h2> + <h2 v-if="resultVal=='' || resultVal==null">缂栬緫-鍖呰妫�楠�</h2> + <h2 v-else>鏌ョ湅-鍖呰妫�楠�</h2> </div> <div class="btn-group header-right"> - <el-button @click="save()" type="primary">淇濆瓨</el-button> </div> </div> <div class="page-main"> @@ -63,10 +63,14 @@ </el-form> </div> <div class="packageInspect-detail"> - <el-row style="width:100%;z-index: 10;height:50px;"> - <el-col :span="22">妫�楠岄」鐩�</el-col> - <el-col :span="2"> - <el-button style="width:100%" size="small" @click="clickAddLine()">娣诲姞妫�楠岄」鐩�</el-button> + <el-row :gutter="10" style="width:100%;z-index: 10;height:50px;"> + <el-col :sm="18" :lg="20">妫�楠岄」鐩�</el-col> + <el-col :sm="3" :lg="2" > + <el-button v-if="resultVal=='' || resultVal==null" size="small" @click="clickAddLine()">娣诲姞妫�楠岄」鐩�</el-button> + </el-col> + <el-col :sm="3" :lg="2"> + <el-button v-if="resultVal=='' || resultVal==null" style="width:100%" type="primary" size="small" + @click="savePackIns()">淇濆瓨</el-button> </el-col> </el-row> <el-row style="width:100%;"> @@ -84,42 +88,43 @@ :tree-props="{children: 'children', hasChildren: 'hasChildren'}"> <el-table-column type="index" label="搴忓彿" width="60"> </el-table-column> - <el-table-column prop="name" label="椤圭洰" width="260"> + <el-table-column prop="name" label="椤圭洰" width="160"> <template slot-scope="scope"> - <el-input v-if="scope.row.children" class="inline-input" style="width:90%;" v-model="scope.row.name" + <el-input :readonly="resultVal!=null" v-if="scope.row.children" class="inline-input" style="width:80%;" v-model="scope.row.name" placeholder="璇疯緭鍏ラ」鐩悕绉�"></el-input> </template> </el-table-column> - <el-table-column prop="required" label="瑕佹眰" width="260"> + <el-table-column prop="required" label="瑕佹眰" width="160" show-overflow-tooltip> <template slot-scope="scope"> - <div> - <el-input v-model="scope.row.required" + <div v-if="!scope.row.children"> + <el-input :readonly="resultVal!=null" v-model="scope.row.required" placeholder="璇疯緭鍏ヨ姹�"></el-input> </div> </template> </el-table-column> - <el-table-column prop="note" label="妫�楠屾弿杩�" width="260" > + <el-table-column prop="note" label="妫�楠屾弿杩�" width="160" show-overflow-tooltip> <template slot-scope="scope"> - <div> - <el-input v-model="scope.row.note" placeholder="妫�楠屾弿杩�"></el-input> + <div v-if="!scope.row.children"> + <el-input :readonly="resultVal!=null" v-model="scope.row.note" placeholder="妫�楠屾弿杩�"></el-input> </div> </template> </el-table-column> - <el-table-column fixed="right" prop="testState" label="缁撹" min-width="150"> + <el-table-column prop="testState" label="缁撹" min-width="150"> <template slot-scope="scope"> - <el-select v-model="scope.row.result"> + <el-select style="width:100%" :disabled="resultVal!=null" @change="changeResult" v-model="scope.row.result" v-if="!scope.row.children"> <el-option label="鍚堟牸" value="鍚堟牸"></el-option> <el-option label="涓嶅悎鏍�" value="涓嶅悎鏍�"></el-option> </el-select> </template> </el-table-column> - <el-table-column fixed="right" style="background-color: white;" label="鎿嶄綔" width="200"> + <el-table-column v-if="resultVal=='' || resultVal==null" fixed="right" style="background-color: white;" label="鎿嶄綔" width="200"> <template slot-scope="scope"> - <el-button icon="el-icon-circle-check" type="text" @click="savePackIns(scope.row,scope.$index)">淇濆瓨</el-button> <el-button v-if="scope.row.children" icon="el-icon-circle-plus-outline" type="text" @click="clickAddChildren(scope.row,scope.$index)">娣诲姞琛�</el-button> - <el-button v-if="!scope.row.children || scope.row.children.length==0" - icon="el-icon-circle-close" type="text" + <el-button v-if="!scope.row.children" icon="el-icon-circle-close" type="text" @click="clickDelLine(scope.row,scope.$index,scope.row.children!=null)">鍙栨秷</el-button> + <el-button v-if="scope.row.children" icon="el-icon-circle-close" type="text" + @click="clickDelLine(scope.row,scope.$index,scope.row.children!=null)">鍒犻櫎椤圭洰</el-button> + </template> </el-table-column> </el-table> @@ -132,21 +137,22 @@ </el-row> <el-row style="width:100%"> <el-col :span="24"> - <el-table border height="90" :data="conclusionTable" ref="conclusion" v-model="conclusion" + <el-table class="l-mes" border height="90" :data="conclusionTable" ref="conclusion" v-model="conclusion" :header-cell-style="{textAlign:'center',color:'black',backgroundColor:'#fafafa'}" :cell-style="{textAlign:'center'}"> - <el-table-column prop="packageNo" label="鍖呰缂栧彿"></el-table-column> - <el-table-column prop="name" label="鐗╂枡鍚嶇О"></el-table-column> - <el-table-column prop="userName" label="妫�楠屽憳"></el-table-column> - <el-table-column prop="judgeState" label="妫�楠岀粨璁�"> + <el-table-column prop="packageNo" label="鍖呰缂栧彿" width="200" show-overflow-tooltip></el-table-column> + <el-table-column prop="userName" label="妫�楠屽憳" width="200" show-overflow-tooltip></el-table-column> + <el-table-column prop="result" label="妫�楠岀粨璁�"> <template slot-scope="scope"> - <el-tag type="success" v-if="scope.row.testState == '1'">鍚堟牸</el-tag> - <el-tag type="danger" v-else-if="scope.row.testState == '0'">涓嶅悎鏍�</el-tag> + <el-select :disabled="resultVal!=null" style="width:100%" v-model="scope.row.result"> + <el-option label="鍚堟牸" value="鍚堟牸"></el-option> + <el-option label="涓嶅悎鏍�" value="涓嶅悎鏍�"></el-option> + </el-select> </template> </el-table-column> <el-table-column label="鎿嶄綔"> <template> - <el-button type="text" :disabled="resultVal!=null && dataForm.id!=null" @click="showDialog()" size="small">涓婃姤</el-button> + <el-button type="text" :disabled="resultVal!=null" @click="submitSave()" size="small">涓婃姤</el-button> </template> </el-table-column> </el-table> @@ -155,18 +161,17 @@ </div> </div> <el-dialog - title="涓婃姤" + title="鎻愮ず" :visible.sync="dialogVisible" - width="30%" class="l-mes"> - <el-row> - <el-col> - <span>涓嶅悎鏍兼暟閲�:</span> - <el-input type="number" v-model="unqualifiedNum" placeholder="璇疯緭鍏ヤ笉鍚堟牸鏁伴噺"/> - </el-col> - </el-row> + width="30%"> + <el-form :model="submitData" ref="form" label-width="100px" > + <el-form-item label="璇疯緭鍏ヨ鍙�" prop="lineNo" :rules="{required:true,message:'琛屽彿涓嶈兘涓虹┖',trigger:'blur'}"> + <el-input v-model="submitData.lineNo" /> + </el-form-item> + </el-form> <span slot="footer" class="dialog-footer"> <el-button @click="dialogVisible = false">鍙� 娑�</el-button> - <el-button type="primary" @click="submitSave()">纭� 瀹�</el-button> + <el-button type="primary" @click="confirmSubmit(submitData,false)">纭� 瀹�</el-button> </span> </el-dialog> </div> @@ -176,6 +181,8 @@ import { fetchListById, updatePackageInsProduct, + updatePackageInspectById, + getCustomer, } from '@/api/quality/packageInspect' export default { computed:{}, @@ -183,16 +190,14 @@ }, data(){ return{ + submitData: { + id:null, + result: null, + lineNo: null, + }, + dialogVisible: false, loading: false, - unqualifiedNum: null, - dialogVisible:false, resultVal: null, - projectList: [], - // 娣诲姞鍒� - empiricalValueAdd: 1, - // 缂栬緫鏃跺瓨鍌ㄦ渶闀跨殑鍒楁暟瀛楋紝鍋氬垹闄ゅ垽鏂� - empiricalValueAddMaxNumber: 0, - columnList: [], dataForm:{ id: null, packInsNo: null, @@ -215,9 +220,8 @@ conclusion: null, conclusionTable: [{ packageNo: '', - name: '', userName: '', - testState: '' + result: '' }], dataRule: {}, } @@ -229,80 +233,103 @@ }, created(){ this.dataForm.id = this.$route.query.id + this.resultVal = this.$route.params.resultVal + if(!this.resultVal){ + let val = sessionStorage.getItem("packIns-resultVal-"+this.dataForm.id) + if(val){ + this.resultVal=val + } + } this.init() }, watch:{ dialogVisible(newVal){ - if(newVal){ - this.unqualifiedNum = null + if(!newVal){ + this.$refs.form.resetFields(); } - }, + } }, methods:{ - checkTestState(){ - let resultVal = '1' - this.list.forEach(item=>{ - if(item.children){ - item.children.forEach(ele=>{ - if(ele.testState == 0){ - resultVal = '0' - } - }) - } + changeResult(){ + let result = '' + let data = this.list + if(data){ + result='鍚堟牸' + data.forEach(item=>{ + if(item.children){ + item.children.forEach(ele=>{ + if(ele.result=='涓嶅悎鏍�'){ + result='涓嶅悎鏍�' + } + }) + } }) - this.resultVal = resultVal - this.conclusionTable[0].testState = resultVal - sessionStorage.setItem("raw-resultVal-"+this.dataForm.id,resultVal) - }, - showDialog(){ - let size = 0 //涓嶅悎鏍奸」鐩暟閲� - this.list.forEach(item=>{ - if(item.children){ - let num = item.children.filter(e=>{ - return e.testState == 0 - }).length - size+=num - } - }) - if (size > 0) { - this.dialogVisible = true - }else{ - this.submitSave() } + this.conclusionTable[0].result = result }, //涓婃姤 submitSave(){ - let data = { - id: this.dataForm.id, - number: this.unqualifiedNum, + const _than = this + this.$confirm('涓婃姤鍓嶏紝璇风‘璁ゆ楠岄」鐩槸鍚﹀凡淇濆瓨!', '鎻愮ず', { + confirmButtonText: '纭涓婃姤', + cancelButtonText: '鍙栨秷', + type: 'warning' + }).then(() => { + _than.submitData.id = _than.dataForm.id, + _than.submitData.result = _than.conclusionTable[0].result, + getCustomer(_than.dataForm.id).then(res=>{ + if(res.status===200){ + _than.confirmSubmit(_than.submitData,true) + } + }).catch(error=>{ + _than.dialogVisible = true + }) + + }).catch(() => {}) + }, + confirmSubmit(data,isOtc){ + const _than = this + let isSubmit = false + if(isOtc){ + isSubmit = true + }else{ + _than.$refs.form.validate(valid=>{ + if(valid){ + isSubmit = true + _than.dialogVisible = false + } + }) } - updateRawInspectsById(data).then(res => { - if(res.data.code == 0 && (res.data.data=='1'|| res.data.data=='0')){ - sessionStorage.setItem("raw-resultVal-"+this.dataForm.id,res.data.data) - this.$message.success("涓婃姤鎴愬姛"); - }else{ - this.$message.error("涓婃姤澶辫触锛�",res.data.data); - } - this.dialogVisible = false - this.checkTestState() - }); + if(isSubmit){ + updatePackageInspectById(data).then(res => { + if(res.data.code === 0){ + _than.resultVal = res.data.data + sessionStorage.setItem("packIns-resultVal-"+_than.dataForm.id,res.data.data) + _than.$message.success("涓婃姤鎴愬姛"); + }else{ + _than.$message.error("涓婃姤澶辫触",res.data.data); + } + }) + } }, // 娣诲姞琛� - clickAddLine(row) { + clickAddLine() { this.list.push({ - pId: '', name: '', - note: '', - required: '', - result: '', randomId: Math.random(), - children: [] + children: [{ + name: '', + note: '', + required: '', + result: '', + randomId: Math.random(), + }] }) }, //娣诲姞瀛愮骇 clickAddChildren(row,index){ - console.log(row,index); row.children.push({ + name: row.name, note: '', required: '', result: '', @@ -325,21 +352,38 @@ }) this.list[i].children.splice(childrenIndex,1) } + this.changeResult() }, //淇濆瓨妫�鏌ラ」 - savePackIns(row,index){ - if(row){ - let obj = { - name: row.anme, - note: row.note, - packageInspectId: row.packageInspectId, - required: row.required, - result: row.result, - } - updatePackageInsProduct(obj).then(res=>{ - console.log(res); + savePackIns(){ + if(this.list.length==0){ + this.$message.error("妫�楠岄」鐩负绌�!") + return + }else{ + let dataList = [] + this.list.forEach(item=>{ + if(item.children){ + item.children.forEach(ele=>{ + let obj = { + id: ele.pid || null, + name: item.name, + note: ele.note, + packageInspectId: this.dataForm.id, + required: ele.required, + result: ele.result, + } + dataList.push(obj) + }) + } + }) + updatePackageInsProduct(dataList).then(res=>{ + if(res.status===200){ + this.$message.success("淇濆瓨鎴愬姛") + this.init() + } }).catch(error=>{ console.log(error); + this.$message.error("淇濆瓨澶辫触") }) } }, @@ -354,51 +398,49 @@ this.dataForm.projectName = data.projectName this.dataForm.createTime = data.createTime this.dataForm.createUser = data.createUser - this.list = data.packageInsProductS - + this.list = [] + let userNameList = [] + data.packageInsProductS.forEach(item => { + if (item.children) { + let ele = { + randomId: Math.random(), + name: null, + children: [] + } + ele.name = item.name + item.children.forEach(obj => { + if(obj.userName){ + userNameList.push(obj.userName) + } + let o = { + name: item.name, + randomId: Math.random(), + required: obj.required, + pid: obj.pid, + note: obj.note?obj.note:'', + result: obj.presult + } + ele.children.push(o) + }) + this.list.push(ele) + } + }) + this.conclusionTable = [{ + packageNo: data.packageNo, + userName: Array.from(new Set(userNameList)).join(','), + result: null + }] + this.$nextTick(()=>{ + if(this.list.length>0){ + this.changeResult() + } + }) }).catch(error=>{ this.$message.error("鑾峰彇澶辫触",error) }) }else{ this.conclusionTable = [] } - }, - changeState(row, index) { - if (row.rpId != null && row.rpId != '') { - let val = row.testValueList.join(",") - if (val === undefined || val === '' || val === null) { - return - } - let obj = { - deviceId: row.deviceId, - rpId: row.rpId, - testValue: val, - note: row.note - } - updateRawInsProduct(obj).then(res => { - if (res.data.code == 0) { - this.$message.success("鏇存柊鎴愬姛") - } else { - this.$message.error("鏇存柊澶辫触") - } - this.init() - }) - } - }, - save(){ - let data = this.dataForm - this.list.forEach(item=>{ - item.children.forEach(c=>{ - c.testValue=c.testValueList.join(",") - }) - }) - data.packageInsProductS = this.list - addRawInspects(data).then(res=>{ - this.$message.success("淇濆瓨鎴愬姛") - this.$router.go(-1) - }).catch(error=>{ - this.$message.error(error) - }) }, }, } -- Gitblit v1.9.3