|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<el-row :gutter="20" class="Layout">
|
|
|
<el-col v-for="(item, index) in customs" :key="index" :span="12">
|
|
|
- <span v-show="item.bool" style="margin-bottom:20px;" class="Layout_space_between">
|
|
|
+ <span v-show="!show && isShow(item) || show && item.bool" style="margin-bottom:20px;" class="Layout_space_between">
|
|
|
<span class="from-name"><span v-if="item.required" style="color: red;">*</span>{{ item.fieldName }} </span>
|
|
|
<el-input v-if="item.type === 1" v-model="item.content" size="small" :disabled="disab" style="width:100%;" placeholder="请输入" @change="getFormValue" />
|
|
|
<el-input v-if="item.type === 2" v-model="item.content" type="textarea" size="small" :disabled="disab" :rows="1" style="width:100%;" placeholder="请输入" @change="getFormValue" />
|
|
@@ -20,20 +20,34 @@
|
|
|
export default {
|
|
|
props: {
|
|
|
custom: { type: Array, required: false, default: null },
|
|
|
+ baseFrom: { type: Object, required: false, default: null },
|
|
|
disab: { type: Boolean, default: false }
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- customs: []
|
|
|
+ customs: [],
|
|
|
+ show: false
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
custom: {
|
|
|
handler(newV) {
|
|
|
+ this.customs = newV.map(e => e)
|
|
|
+ console.log(this.customs, '新的志')
|
|
|
if (newV && newV[0].bool) {
|
|
|
- this.customs = newV
|
|
|
+ this.show = true
|
|
|
+ this.customs.map(item => {
|
|
|
+ this.baseFrom[`${item.fieldKey}_${item.content}`] = item.content
|
|
|
+ if (item.contents && item.contents[0]) {
|
|
|
+ item.contents.map(elm => {
|
|
|
+ this.baseFrom[`${item.fieldKey}_${elm}`] = elm
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ console.log(this.customs, '新的志')
|
|
|
return
|
|
|
}
|
|
|
+ this.show = false
|
|
|
this.customs = newV.map(item => ({
|
|
|
...item,
|
|
|
bool: item.conditions === '默认展示' || this.getBoolValue(item.conditions)
|
|
@@ -43,6 +57,16 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ isShow(item) {
|
|
|
+ if (item.conditions === '默认展示') {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ console.log(this.baseFrom, item.conditions, item)
|
|
|
+ if (this.baseFrom[item.conditions] === item.conditions.split('_')[1]) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ },
|
|
|
getBoolValue(conditions) {
|
|
|
const checkList = []
|
|
|
this.customs.forEach(item => {
|
|
@@ -55,29 +79,86 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
- console.log(checkList.indexOf(conditions) !== -1)
|
|
|
return checkList.indexOf(conditions) !== -1
|
|
|
},
|
|
|
getFormValue(e) {
|
|
|
- if (e) {
|
|
|
- console.log(e)
|
|
|
- this.customs.map(item => {
|
|
|
- if (item.conditions === e.fieldKey + '_' + e.content || item.conditions === e.fieldKey + '_' + e.contents) {
|
|
|
- item.bool = true
|
|
|
- item.content = ''
|
|
|
- item.contents = null
|
|
|
- } else {
|
|
|
- item.bool = item.conditions === '默认展示' || this.getBoolValue(item.conditions)
|
|
|
- }
|
|
|
- if (!item.bool) {
|
|
|
- item.content = ''
|
|
|
- item.contents = null
|
|
|
- }
|
|
|
+ console.log(e)
|
|
|
+ this.show = false
|
|
|
+ const params = {}
|
|
|
+ const keys = []
|
|
|
+ this.customs.map(item => {
|
|
|
+ if (e.type < 4) {
|
|
|
+ item.conditions === `${e.fieldKey}_${e.content}` ? item.bool = true : ''
|
|
|
+ } else if (e.type === 4) {
|
|
|
+ e.contents.map(i => {
|
|
|
+ item.conditions === `${e.fieldKey}_${i}` ? item.bool = true : ''
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 单选
|
|
|
+ if (e.type === 3) {
|
|
|
+ params[`${e.fieldKey}_${e.content}`] = e.content
|
|
|
+ }
|
|
|
+ // 多选
|
|
|
+ if (e.type === 4) {
|
|
|
+ e.contents.forEach(elm => {
|
|
|
+ params[`${e.fieldKey}_${elm}`] = elm
|
|
|
})
|
|
|
- this.customs = [...this.customs]
|
|
|
}
|
|
|
- console.log(this.customs, '导出的结果')
|
|
|
- this.$emit('formData', this.customs)
|
|
|
+ // 删除多余字段
|
|
|
+ Object.keys(this.baseFrom).forEach(key => {
|
|
|
+ if (key.indexOf(e.fieldKey) > -1) {
|
|
|
+ keys.push(key)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.$emit('formData', {
|
|
|
+ customs: this.customs,
|
|
|
+ keys,
|
|
|
+ params
|
|
|
+ })
|
|
|
+ },
|
|
|
+ CustomSet(e) {
|
|
|
+ const key = Object.keys(e)[0]
|
|
|
+ const custom = {
|
|
|
+ followVersion: {
|
|
|
+ key: 'followVersion',
|
|
|
+ label: '是否跟版',
|
|
|
+ values: 0
|
|
|
+ },
|
|
|
+ isCodeReview: {
|
|
|
+ key: 'isCodeReview',
|
|
|
+ label: '是否codereview',
|
|
|
+ values: 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const label = custom[key].label
|
|
|
+ // const value = e[key] + custom[key].values
|
|
|
+ const value = e[key]
|
|
|
+
|
|
|
+ // this.customs.forEach(elm => {
|
|
|
+ // elm.conditions = ''
|
|
|
+ // })
|
|
|
+ const keys = []
|
|
|
+ const params = {
|
|
|
+ [`${label}_${value}`]: `${value}`
|
|
|
+ }
|
|
|
+ // 删除多余字段
|
|
|
+ Object.keys(this.baseFrom).forEach(key => {
|
|
|
+ if (key.indexOf(label) > -1) {
|
|
|
+ keys.push(key)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.$emit('formData', {
|
|
|
+ customs: this.customs.map(e => e),
|
|
|
+ keys,
|
|
|
+ params
|
|
|
+ })
|
|
|
+ // this.$emit('formData', {
|
|
|
+ // customs: this.customs,
|
|
|
+ // keys,
|
|
|
+ // params
|
|
|
+ // })
|
|
|
+ // console.log(e, this.customs, this.baseFrom, 'xcdjks ncjksdjnk')
|
|
|
}
|
|
|
}
|
|
|
}
|