浏览代码

维保详情交互优化

pengyh 1 年之前
父节点
当前提交
3503624096
共有 1 个文件被更改,包括 40 次插入33 次删除
  1. 40 33
      src/views/engineeringMaintenance/basicData/detail.vue

+ 40 - 33
src/views/engineeringMaintenance/basicData/detail.vue

@@ -134,7 +134,7 @@
 										<el-select v-model="scope.row.brand" @change="(e)=>{
 											scope.row.brandId = e.id
 											scope.row.brandName = e.brandName
-										}" value-key="id" :disabled="isEdit != scope.$index || formType == 2" placeholder="请选择" style="width: 100%;">
+										}" value-key="id" :disabled="isEdit1 != scope.$index || formType == 2" placeholder="请选择" style="width: 100%;">
 										    <el-option
 										      v-for="item in brandList"
 										      :key="item.id"
@@ -161,8 +161,8 @@
 												scope.row.smallId = ''
 											}
 											
-											scope.row.smallList = e.children?e.children:[]
-										}" :disabled="isEdit != scope.$index || formType == 2" placeholder="请选择" style="width: 100%;">
+											scope.row.smallList = e.children?[...[{categoryId: '0', name: '不限'}],...e.children]:[]
+										}" :disabled="isEdit1 != scope.$index || formType == 2" placeholder="请选择" style="width: 100%;">
 										    <el-option
 										      v-for="item in mainList"
 										      :key="item.categoryId"
@@ -182,7 +182,7 @@
 												scope.row.smallName = e.name
 												scope.row.smallId = e.categoryId
 												scope.row.smallImg = e.imgUrl
-											}" :disabled="isEdit != scope.$index || formType == 2" value-key="categoryId" placeholder="请选择" style="width: 100%;">
+											}" :disabled="isEdit1 != scope.$index || formType == 2" value-key="categoryId" placeholder="请选择" style="width: 100%;">
 										    <el-option
 										      v-for="item in scope.row.smallList"
 										      :key="item.categoryId"
@@ -196,41 +196,41 @@
 							<el-table-column prop="" align="center" label="系列名称">
 								<template slot-scope="scope">
 									<el-form-item>
-										<el-input type="text" v-model="scope.row.seriesName" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
+										<el-input type="text" v-model="scope.row.seriesName" :disabled="isEdit1 != scope.$index || formType == 2" placeholder="请输入"></el-input>
 									</el-form-item>
 								</template>
 							</el-table-column>
 							<el-table-column prop="" align="center" label="机型名称">
 								<template slot-scope="scope">
 									<el-form-item>
-										<el-input type="text" v-model="scope.row.productName" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
+										<el-input type="text" v-model="scope.row.productName" :disabled="isEdit1 != scope.$index || formType == 2" placeholder="请输入"></el-input>
 									</el-form-item>
 								</template>
 							</el-table-column>
 							<el-table-column align="center" label="设备套数">
 								<template slot-scope="scope">
 									<el-form-item :prop="'productList.' + scope.$index + '.num'" :rules="[{ required: true, message: `请输入设备套数`, trigger: 'blur' }]">
-										<el-input type="number" v-model="scope.row.num" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
+										<el-input type="number" v-model="scope.row.num" :disabled="isEdit1 != scope.$index || formType == 2" placeholder="请输入"></el-input>
 									</el-form-item>
 								</template>
 							</el-table-column>
 							<el-table-column prop="" align="center" label="内机数量" >
 								<template slot-scope="scope">
 									<el-form-item>
-										<el-input type="number" v-model="scope.row.inNum" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
+										<el-input type="number" v-model="scope.row.inNum" :disabled="isEdit1 != scope.$index || formType == 2" placeholder="请输入"></el-input>
 									</el-form-item>
 								</template>
 							</el-table-column>
 							<el-table-column prop="" align="center" label="外机数量">
 								<template slot-scope="scope">
 									<el-form-item>
-										<el-input type="number" v-model="scope.row.outNum" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
+										<el-input type="number" v-model="scope.row.outNum" :disabled="isEdit1 != scope.$index || formType == 2" placeholder="请输入"></el-input>
 									</el-form-item>
 								</template>
 							</el-table-column>
 							<el-table-column label="操作" align="right" width="140">
 								<template slot-scope="scope" v-if="formType != 2">
-									<el-button size="mini" type="primary" v-if="scope.$index != isEdit" @click="isEdit = scope.$index">编辑</el-button>
+									<el-button size="mini" type="primary" v-if="scope.$index != isEdit1" @click="edit(1,scope.$index)">编辑</el-button>
 									<el-button size="mini" type="danger" @click="del(scope.$index)">删除</el-button>
 								</template>
 							</el-table-column>
@@ -242,7 +242,7 @@
 							<el-table-column align="center" label="姓名">
 								<template slot-scope="scope">
 									<el-form-item :prop="'byList.' + scope.$index + '.name'" :rules="[{ required: true, message: `请输入姓名`, trigger: 'blur' }]">
-										<el-input type="text" v-model="scope.row.name" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
+										<el-input type="text" v-model="scope.row.name" :disabled="isEdit2 != scope.$index || formType == 2" placeholder="请输入"></el-input>
 									</el-form-item>
 								</template>
 							</el-table-column>
@@ -250,14 +250,14 @@
 								<template slot-scope="scope">
 									<el-form-item :prop="'byList.' + scope.$index + '.mobile'"
 										:rules="[{ required: true, message: `请输入联系电话`, trigger: 'blur' },{ pattern:/^((1[3456789]\d{9}))$/, message: '电话号码格式不正确', trigger: 'blur' }]">
-										<el-input type="number" v-model="scope.row.mobile" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
+										<el-input type="number" v-model="scope.row.mobile" :disabled="isEdit2 != scope.$index || formType == 2" placeholder="请输入"></el-input>
 									</el-form-item>
 								</template>
 							</el-table-column>
 							<el-table-column label="费用审批">
 								<template slot-scope="scope">
 									<el-form-item :prop="'byList.' + scope.$index + '.feeExamine'" :rules="[{ required: true, message: `请选择费用审批`, trigger: 'change' }]">
-										<el-select v-model="scope.row.feeExamine" :disabled="isEdit != scope.$index || formType == 2" placeholder="请选择" style="width: 100%;">
+										<el-select v-model="scope.row.feeExamine" :disabled="isEdit2 != scope.$index || formType == 2" placeholder="请选择" style="width: 100%;">
 										    <el-option
 										      v-for="item in [{id: 'YES',name: '是'},{id: 'NO',name: '否'}]"
 										      :key="item.id"
@@ -270,7 +270,7 @@
 							</el-table-column>
 							<el-table-column label="操作" align="right" width="140">
 								<template slot-scope="scope" v-if="formType != 2">
-									<el-button size="mini" type="primary" v-if="scope.$index != isEdit" @click="isEdit = scope.$index">编辑</el-button>
+									<el-button size="mini" type="primary" v-if="scope.$index != isEdit2" @click="edit(2,scope.$index)">编辑</el-button>
 									<el-button size="mini" type="danger" @click="del(scope.$index)">删除</el-button>
 								</template>
 							</el-table-column>
@@ -288,7 +288,7 @@
 											scope.row.linkName = e.linkName
 											scope.row.mobile = e.websitPhone
 											scope.row.address = e.address
-										}" value-key="websitId" :disabled="isEdit != scope.$index || formType == 2" placeholder="请选择" style="width: 100%;">
+										}" value-key="websitId" :disabled="isEdit3 != scope.$index || formType == 2" placeholder="请选择" style="width: 100%;">
 										    <el-option
 										      v-for="item in websitData"
 										      :key="item.websitId"
@@ -322,7 +322,7 @@
 							</el-table-column>
 							<el-table-column label="操作" align="right" width="140">
 								<template slot-scope="scope" v-if="formType != 2">
-									<el-button size="mini" type="primary" v-if="scope.$index != isEdit" @click="isEdit = scope.$index">编辑</el-button>
+									<el-button size="mini" type="primary" v-if="scope.$index != isEdit3" @click="edit(3,scope.$index)">编辑</el-button>
 									<el-button size="mini" type="danger" @click="del(scope.$index)">删除</el-button>
 								</template>
 							</el-table-column>
@@ -413,7 +413,9 @@
 				formData3: {
 					websitList: [],
 				},
-				isEdit: 0,
+				isEdit1: 0,
+				isEdit2: 0,
+				isEdit3: 0,
 				companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
 				rules: {
 					projectName: [
@@ -453,17 +455,7 @@
 			};
 		},
 		computed: {
-			filterChildren(){
-				return function(id){
-					let data = []
-					this.mainList.forEach(item=>{
-						if(item.categoryId == id){
-							data = item.children?item.children:[]
-						}
-					})
-					return data
-				}
-			}
+			
 		},
 		created() {
 			if(this.id){
@@ -506,6 +498,15 @@
 					console.log(this.formData.checkTypeList,'123123123')
 				})
 			},
+			async filterChildren(id){
+				let data = []
+				this.mainList.forEach(item=>{
+					if(item.categoryId == id){
+						data = item.children?[...[{categoryId: '0', name: '不限'}],...item.children]:[]
+					}
+				})
+				return data
+			},
 			initData(){
 				this.getOrderType()
 				this.getBrandList()
@@ -627,7 +628,7 @@
 				})
 			},
 			changeType(){
-				this.isEdit = 0
+				
 			},
 			preserveRuleForm(name) {
 				let is_save = false
@@ -640,12 +641,18 @@
 				});
 				return is_save
 			},
+			edit(typeIndex,index){
+				if(this.preserveRuleForm('formData' + this.typeIndex)){
+					this['isEdit' + typeIndex] = index
+				}
+			},
 			add(){
 				if(!this.preserveRuleForm('formData' + this.typeIndex)){return false}
 				let name = this.typeIndex == 1?'productList':this.typeIndex == 2?'byList':'websitList'
-				if(this['formData' + this.typeIndex][name].length != 0){this.isEdit += 1}
+				this['isEdit' + this.typeIndex] = 0
+				// if(this['formData' + this.typeIndex][name].length != 0){this['isEdit' + this.typeIndex] += 1}
 				if(this.typeIndex == 1){
-					this['formData' + this.typeIndex][name].push({
+					this['formData' + this.typeIndex][name].unshift({
 						brand: null,
 						brandId: '',
 						brandName: '',
@@ -663,13 +670,13 @@
 						smallImg: ''
 					})
 				}else if(this.typeIndex == 2){
-					this['formData' + this.typeIndex][name].push({
+					this['formData' + this.typeIndex][name].unshift({
 						name: '',
 						mobile: '',
 						feeExamine: ''
 					})
 				}else{
-					this['formData' + this.typeIndex][name].push({
+					this['formData' + this.typeIndex][name].unshift({
 						websit: null,
 						websitId: '',
 						websitName: '',