弹窗选择控件优化!

product
巴卫 2 years ago
parent 685c8adfd2
commit 0e06e24c62

@ -1,33 +1,56 @@
<template>
<div>
<el-input v-model="value" placeholder="用于展示弹窗选择的属性,且数据不会保存" readonly v-if="!isDetail" />
<p v-else>{{value}}</p>
<template v-if="!isDetail">
<el-input v-model="innerValue" placeholder="用于展示关联弹窗的属性,且数据不会保存" readonly
v-if="isStorage==1" />
<el-input v-model="innerValue" placeholder="用于展示关联弹窗的属性,且数据同时会保存入库" readonly
v-else-if="isStorage==2" />
</template>
<p v-else>{{innerValue}}</p>
</div>
</template>
<script>
export default {
model: {
prop: 'value',
event: 'input'
},
name: 'popupAttr',
props: ["showField", "relationField", 'isDetail'],
props: ["showField", "relationField", 'isDetail', 'isStorage', 'defaultValue'],
data() {
return {
value: ''
innerValue: this.value,
}
},
computed: {
relationData() {
if (this.isStorage == 2 && this.defaultValue) {
this.$emit('input', this.defaultValue)
return this.innerValue = this.defaultValue
}
return this.$store.state.generator.relationData
}
},
created() {
this.$eventBus.$on('popupAttrEventBus', (val, vModel) => {
if (!this.showField || !this.relationField || this.relationField != vModel) return
let obj = val[this.relationField] || {}
this.innerValue = obj[this.showField] ? obj[this.showField] : ''
this.$emit('input', this.innerValue)
})
},
watch: {
relationData: {
handler(val) {
if (this.isStorage == 2) return
if (!this.showField || !this.relationField) return
let obj = val[this.relationField] || {}
this.value = obj[this.showField] ? obj[this.showField] : ''
this.innerValue = obj[this.showField] ? obj[this.showField] : ''
this.$emit('input', this.innerValue)
},
deep: true
}
}
}
</script>
</script>

@ -333,6 +333,7 @@ export default {
setDefault() {
if (this.value) {
if (!this.interfaceId) return
const paramList = this.getParamList()
let query = {
id: this.value,
interfaceId: this.interfaceId,
@ -341,9 +342,10 @@ export default {
excludeFields: this.excludeFields,
propsValue: this.propsValue,
relationField: this.relationField,
paramList
}
getDataInterfaceDataInfo(this.interfaceId, query).then(res => {
const data = res.data && res.data.length ? res.data[0] : {}
const data = res.data && res.data.length ? res.data[0] : {}
this.innerValue = res.data[this.relationField]
if (!this.field) return
let relationData = this.$store.state.generator.relationData
@ -356,7 +358,7 @@ export default {
if (!this.field) return
let relationData = this.$store.state.generator.relationData
this.$set(relationData, this.field, {})
this.$eventBus.$emit('popupAttrEventBus', relationData, this.field)
//this.$eventBus.$emit('popupAttrEventBus', relationData, this.field)
this.$store.commit('generator/UPDATE_RELATION_DATA', relationData)
}
}

@ -26,6 +26,9 @@ import * as filters from './filters' // global filters
import permission from "@/directive/permission";
Vue.use(permission)
//eventBus挂载
Vue.prototype.$eventBus = new Vue()
Vue.use(Element, {
size: jnpf.storageGet('size') || 'small', // set element-ui default size
i18n: (key, value) => i18n.t(key, value)
@ -56,4 +59,4 @@ const vm = new Vue({
i18n,
render: h => h(App)
})
export default vm
export default vm

Loading…
Cancel
Save