67ede380 by fanguang Committed by lihua

fix

1 parent 11d8c7f2
...@@ -29,8 +29,10 @@ ...@@ -29,8 +29,10 @@
29 show-checkbox 29 show-checkbox
30 check-strictly 30 check-strictly
31 placeholder="请选择" 31 placeholder="请选择"
32 :disabled="parentGuidDisabled" 32 :disabled="treeSelectDisabled"
33 clearable
33 @check="parentGuidCheck" 34 @check="parentGuidCheck"
35 @clear="parentGuidClear"
34 /> 36 />
35 <!-- <el-cascader 37 <!-- <el-cascader
36 v-model="form.parentGuid" 38 v-model="form.parentGuid"
...@@ -73,26 +75,26 @@ ...@@ -73,26 +75,26 @@
73 </el-form-item> 75 </el-form-item>
74 </el-col> 76 </el-col>
75 <el-col :span="24"> 77 <el-col :span="24">
76 <el-form-item label="自定义字段选择" v-if="form.fieldRQVOS" required> 78 <el-form-item label="自定义字段选择" v-if="fieldsTableShow" required>
77 <div class="table-form"> 79 <div class="table-form">
78 <div class="table-form-wrapper" v-for="item,index in form.fieldRQVOS" :key="index"> 80 <div class="table-form-wrapper" v-for="item,index in form.fieldRQVOS" :key="index">
79 <div class="table-form-item"> 81 <div class="table-form-item">
80 <el-select v-model="item.fileNameCode" style="width:160px" filterable clearable :disabled="fieldsDisabled || fieldsControlDisabled"> 82 <el-select v-model="item.fileNameCode" style="width:160px" filterable clearable :disabled="fieldsDisabled">
81 <el-option v-for="item in fieldOptions" :label="item.label" :value="item.value" :key="item.value"></el-option> 83 <el-option v-for="item in fieldOptions" :label="item.label" :value="item.value" :key="item.value"></el-option>
82 </el-select> 84 </el-select>
83 </div> 85 </div>
84 <div class="table-form-item"> 86 <div class="table-form-item">
85 <el-select v-model="item.isNotnull" style="width: 96px" placeholder="是否必填" clearable :disabled="fieldsDisabled || fieldsControlDisabled"> 87 <el-select v-model="item.isNotnull" style="width: 96px" placeholder="是否必填" clearable :disabled="fieldsDisabled">
86 <el-option v-for="item in isBooleanOptions" :label="item.label" :value="item.value" :key="item.value"></el-option> 88 <el-option v-for="item in isBooleanOptions" :label="item.label" :value="item.value" :key="item.value"></el-option>
87 </el-select> 89 </el-select>
88 </div> 90 </div>
89 <div class="table-form-item"> 91 <div class="table-form-item">
90 <el-select v-model="item.isDisplay" style="width:96px" placeholder="是否展示" clearable :disabled="fieldsDisabled || fieldsControlDisabled"> 92 <el-select v-model="item.isDisplay" style="width:96px" placeholder="是否展示" clearable :disabled="fieldsDisabled">
91 <el-option v-for="item in isBooleanOptions" :label="item.label" :value="item.value" :key="item.value"></el-option> 93 <el-option v-for="item in isBooleanOptions" :label="item.label" :value="item.value" :key="item.value"></el-option>
92 </el-select> 94 </el-select>
93 </div> 95 </div>
94 <div class="table-form-item"> 96 <div class="table-form-item">
95 <el-select v-model="item.inputTypeCode" style="width:130px" clearable :disabled="fieldsDisabled || fieldsControlDisabled" 97 <el-select v-model="item.inputTypeCode" style="width:130px" clearable :disabled="fieldsDisabled"
96 @change="v => inputTypeChange(v, item)"> 98 @change="v => inputTypeChange(v, item)">
97 <el-option v-for="item in inputOptions" :label="item.label" :value="item.value" :key="item.value"></el-option> 99 <el-option v-for="item in inputOptions" :label="item.label" :value="item.value" :key="item.value"></el-option>
98 </el-select> 100 </el-select>
...@@ -102,24 +104,24 @@ ...@@ -102,24 +104,24 @@
102 v-if="item.inputTypeCode == 2" 104 v-if="item.inputTypeCode == 2"
103 v-model="item.dataTypeCode" 105 v-model="item.dataTypeCode"
104 style="width:160px" filterable clearable 106 style="width:160px" filterable clearable
105 :disabled="fieldsDisabled || fieldsControlDisabled"> 107 :disabled="fieldsDisabled">
106 <el-option v-for="item in allDictOptions" :label="item.dictTypeName" :value="item.dictTypeName" :key="item.guid"></el-option> 108 <el-option v-for="item in allDictOptions" :label="item.dictTypeName" :value="item.dictTypeName" :key="item.guid"></el-option>
107 </el-select> 109 </el-select>
108 <el-input 110 <el-input
109 v-else-if="item.inputTypeCode == 3" 111 v-else-if="item.inputTypeCode == 3"
110 v-model="item.validateExpression" 112 v-model="item.validateExpression"
111 :disabled="fieldsDisabled || fieldsControlDisabled" 113 :disabled="fieldsDisabled"
112 placeholder="请输入" 114 placeholder="请输入"
113 ></el-input> 115 ></el-input>
114 </div> 116 </div>
115 <div class="table-form-operation" v-if="!fieldsDisabled && !fieldsControlDisabled"> 117 <div class="table-form-operation" v-if="!fieldsDisabled">
116 <!-- <el-icon color="#4fa1a4" @click="() => addTableItem(index)"> 118 <!-- <el-icon color="#4fa1a4" @click="() => addTableItem(index)">
117 <CirclePlus /> 119 <CirclePlus />
118 </el-icon> --> 120 </el-icon> -->
119 <el-icon color="#b2b2b2" @click="() => deleteTableItem(index)" :size="22" class="custom-icon" style="margin-top:3px"><Delete /></el-icon> 121 <el-icon color="#b2b2b2" @click="() => deleteTableItem(index)" :size="22" class="custom-icon" style="margin-top:3px"><Delete /></el-icon>
120 </div> 122 </div>
121 </div> 123 </div>
122 <div class="table-form-add" v-if="!fieldsDisabled && !fieldsControlDisabled"> 124 <div class="table-form-add" v-if="!fieldsDisabled">
123 <el-icon color="#4fa1a4" @click="() => addTableItem(index)" :size="20" class="custom-icon"> 125 <el-icon color="#4fa1a4" @click="() => addTableItem(index)" :size="20" class="custom-icon">
124 <CirclePlus /> 126 <CirclePlus />
125 </el-icon> 127 </el-icon>
...@@ -186,35 +188,6 @@ const visible = computed({ ...@@ -186,35 +188,6 @@ const visible = computed({
186 const title = computed(() => { 188 const title = computed(() => {
187 return props.type === 'add' ? '新增元数据标准' : '编辑元数据标准' 189 return props.type === 'add' ? '新增元数据标准' : '编辑元数据标准'
188 }) 190 })
189 const parentGuidDisabled = computed(() => {
190 // 元数据标准有数据,有子集,不可编辑上级标准
191 let { currentNode, type } = props
192 if (type === 'add') {
193 return false
194 }
195 if (currentNode.isHaveData === 'Y' || currentNode.children) {
196 return true
197 }
198 })
199 const fieldsDisabled = computed(() => {
200 // 二级节点: 该节点,所有子节点有字段数据后不可修改
201 // 三级节点以下:禁止修改
202 let { currentNode, type } = props
203 if (type === 'add') {
204 return false
205 }
206 if (currentNode.level == 2) {
207 if (currentNode.isHaveData === 'Y' || currentNode.children) {
208 return true
209 }
210 return false
211 }
212 if (currentNode.level <= 3) {
213 return true
214 }
215 })
216 const fieldsControlDisabled = ref(true)
217 const treeSelectData = ref([])
218 191
219 /** 192 /**
220 * 配置项列表 193 * 配置项列表
...@@ -266,16 +239,53 @@ function parentGuidChange (val) { ...@@ -266,16 +239,53 @@ function parentGuidChange (val) {
266 form.value.fieldRQVOS = [{...tableFormTpl}] 239 form.value.fieldRQVOS = [{...tableFormTpl}]
267 } 240 }
268 } 241 }
269 function parentGuidCheck (node, {checkedKeys}) { 242 /** 上级标准树选择 */
270 fieldsControlDisabled.value = false 243 const treeSelectData = ref([])
271 if (node.level == 1) { 244 const treeCurrentNode = ref({})
272 let fieldRQVOS = null 245 const treeSelectDisabled = ref(false)
273 if (checkedKeys.length) { 246 const fieldsDisabled = ref(false)
274 fieldRQVOS = [{...tableFormTpl}] 247 const fieldsTableShow = ref(false)
248 watch(
249 () => treeCurrentNode,
250 (currentNode:any) => {
251 console.log('currentNode', currentNode.value)
252 let { level, isHaveData } = currentNode.value
253 fieldsTableShow.value = level ? true : false
254 fieldsDisabled.value = false
255 if (!level) {
256 form.value.fieldRQVOS = null
257 return
258 }
259 if (props.type === 'add') {
260 if (level == 1) {
261 // 所选为一级节点,当前二级节点
262 form.value.fieldRQVOS = [{...tableFormTpl}]
263 }
264 if (level >= 2) {
265 // 所选为二级节点,当前三级节点以下,只读
266 fieldsDisabled.value = true
267 }
268 } else if (props.type === 'edit') {
269 if (level == 1) {
270 // 所选为一级节点,当前二级节点
271 form.value.fieldRQVOS = [{...tableFormTpl}]
272 fieldsDisabled.value = false
273 }
274 if (level >= 2) {
275 fieldsDisabled.value = true
276 }
275 } 277 }
276 form.value.fieldRQVOS = fieldRQVOS 278 },
279 { deep: true}
280 )
281 function parentGuidCheck (node, {checkedKeys}) {
282 // fieldsControlDisabled.value = false
283 treeCurrentNode.value = node
284 if (checkedKeys.length === 0) {
285 treeCurrentNode.value = {}
277 return 286 return
278 } 287 }
288 if (node.level == 1) return
279 289
280 // 上级标准带出标准编号和发布单位 290 // 上级标准带出标准编号和发布单位
281 // loading.value = true 291 // loading.value = true
...@@ -289,14 +299,12 @@ function parentGuidCheck (node, {checkedKeys}) { ...@@ -289,14 +299,12 @@ function parentGuidCheck (node, {checkedKeys}) {
289 form.value.publishingUnitCode = data.publishingUnitCode 299 form.value.publishingUnitCode = data.publishingUnitCode
290 } 300 }
291 form.value.fieldRQVOS = data.fieldRSVOS 301 form.value.fieldRQVOS = data.fieldRSVOS
292 if (data.fieldRSVOS) {
293 fieldsControlDisabled.value = true
294 } else {
295 fieldsControlDisabled.value = false
296 }
297 } 302 }
298 }) 303 })
299 } 304 }
305 function parentGuidClear () {
306 treeCurrentNode.value = {}
307 }
300 308
301 const tableFormTpl = { 309 const tableFormTpl = {
302 fileNameCode: '', 310 fileNameCode: '',
...@@ -335,6 +343,17 @@ function getDetail () { ...@@ -335,6 +343,17 @@ function getDetail () {
335 const data = res.data 343 const data = res.data
336 data.fieldRQVOS = data.fieldRSVOS 344 data.fieldRQVOS = data.fieldRSVOS
337 form.value = { ...data } 345 form.value = { ...data }
346 let { level, isHaveData } = treeCurrentNode.value
347 if (level == 1) {
348 // 所选为一级节点,当前二级节点
349 fieldsTableShow.value = false
350 }
351 if (level == 2) {
352 fieldsDisabled.value = isHaveData === 'Y' ? true : false
353 }
354 if (level >= 3) {
355 fieldsDisabled.value = true
356 }
338 } 357 }
339 }).finally(() => loading.value = false) 358 }).finally(() => loading.value = false)
340 } 359 }
...@@ -377,32 +396,40 @@ watch( ...@@ -377,32 +396,40 @@ watch(
377 () => visible.value, 396 () => visible.value,
378 (v) => { 397 (v) => {
379 if (!v) return 398 if (!v) return
399 // console.log(props.currentNode)
380 // 上级标准:不能选自己,有数据的标准不能选 400 // 上级标准:不能选自己,有数据的标准不能选
381 // treeSelectData.value = JSON.parse(JSON.stringify(props.standardOptions)) 401 // treeSelectData.value = JSON.parse(JSON.stringify(props.standardOptions))
382 if (props.type === 'edit') { 402 if (props.type === 'edit') {
383 fieldsControlDisabled.value = false 403 // fieldsControlDisabled.value = false
404
384 getTreeSelectOptions().then(() => { 405 getTreeSelectOptions().then(() => {
385 getDetail().then(() => formatOptions(treeSelectData.value)) 406 getDetail().then(() => formatOptions(treeSelectData.value))
386 }) 407 })
408 treeCurrentNode.value = props.currentNode
387 } else { 409 } else {
388 fieldsControlDisabled.value = true 410 // fieldsControlDisabled.value = true
389 form.value = { ...formTpl } 411 form.value = { ...formTpl }
390 getTreeSelectOptions().then(() => formatOptions(treeSelectData.value)) 412 getTreeSelectOptions().then(() => {
413 formatOptions(treeSelectData.value)
414 })
415 treeCurrentNode.value = {}
391 } 416 }
392 setTimeout(() => { 417 setTimeout(() => {
393 formEl.value.clearValidate() 418 formEl.value.clearValidate()
419
394 }, 100) 420 }, 100)
395 } 421 }
396 ) 422 )
397 function formatOptions (options) { 423 function formatOptions (options, level = 1) {
398 options.forEach((item:any) => { 424 options.forEach((item:any) => {
399 let disabled = form.value.guid === item.guid ? true : false 425 let disabled = form.value.guid === item.guid ? true : false
400 if (item.isHaveData === 'Y') { 426 if (item.isHaveData === 'Y') {
401 disabled = true 427 disabled = true
402 } 428 }
403 item.disabled = disabled 429 item.disabled = disabled
430 item.level = level
404 if (item.children) { 431 if (item.children) {
405 formatOptions(item.children) 432 formatOptions(item.children, level + 1)
406 } 433 }
407 }) 434 })
408 } 435 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!