Commit 126a7be0 authored by arvin's avatar arvin

修改组件

parent cf072ca2
export default {
props: {},
layoutConfigData: [
{
title: '高级组件配置',
data: [
{
key: 'linkageAttr',
title: '联动属性',
component: {
defaultValue: 'extProductAreaId',
name: 'el-input'
}
},
{
key: 'syncOutAttr',
title: '同步输出',
component: {
defaultValue: 'extWorkCenteName:extname',
name: 'el-input'
}
}
]
}
],
data() {
return {
}
},
created() {
},
computed: {
},
methods: {
}
}
<template>
<div>
<el-select v-model="form.extWorkCenterId">
<el-option
v-for="(item,i) in warehouseOptions"
:key="i"
:label="item.extname"
:value="item.id"
/>
</el-select>
</div>
<el-select v-model="cloneValue" @change="change">
<el-option
v-for="(item,i) in warehouseOptions"
:key="i"
:label="item.extname"
:value="item.id"
/>
</el-select>
</template>
<script>
import config from './config'
import _get from 'lodash.get'
import _set from 'lodash.set'
export default {
componentName: '库房',
name: 'Warehouse',
components: {},
mixins: [config],
props: {
form: {}
itemObj: {
type: Object,
default: null
},
form: {
type: Object,
default: () => {}
},
value: {
type: [Number, String, Object],
default: () => ''
}
},
data() {
return {
warehouseOptions: [],
areaList: [],
cloneValue: '',
linkageValue: '',
dataType: 'string',
isFirst: true
}
},
computed: {},
watch: {
async 'form.extProductArea.id'() {
this.$set(this.form, 'extWorkCenterId', this.form.extWorkCenterId || '')
if (!this.isFirst) {
this.$set(this.form, 'extWorkCenterId', '')
'value': {
immediate: true,
handler(val) {
if (!val) {
this.cloneValue = ''
return
}
if (typeof (val) === 'object') {
this.cloneValue = val.id
this.dataType = 'object'
} else {
this.cloneValue = val
this.dataType = 'string'
}
}
if (this.areaList.length) {
this.findWarehouse()
} else {
await this.searchApi()
},
form: {
immediate: true,
deep: true,
handler() {
if (!this.itemObj.linkageAttr) {
return
}
const _val = _get(this.form, this.itemObj.linkageAttr)
if (_val !== this.linkageValue) {
this.linkageValue = _val
this.linkageValue && this.searchApi()
if (this.linkageValue) {
this.cloneValue = ''
this.update()
}
}
}
}
},
......@@ -51,17 +90,47 @@ export default {
mounted() {
},
methods: {
async searchApi() {
this.isFirst = false
const params = { 'openProps': [{ 'name': 'extDxProductWorkCenters' }] }
await this.$api.searchApi('ExtDxProductArea', params).then(res => {
this.areaList = res.items.content
this.findWarehouse()
validate() {
return !!this.cloneValue
},
searchApi() {
const params = { 'openProps': [{ 'name': 'extDxProductWorkCenters' }],
searchItems: {
items: [{ 'fieldName': 'id', operator: 'EQ', value: this.linkageValue }],
operator: 'AND'
}
}
this.$api.searchApi('ExtDxProductArea', params).then(res => {
this.warehouseOptions = res.items.content[0].extDxProductWorkCenters
})
},
update() {
let item = null
if (this.dataType === 'string') {
this.$emit('input', this.cloneValue)
this.$emit('change', this.cloneValue)
} else {
item = this.warehouseOptions.find(r => r.id === this.cloneValue)
this.$emit('input', item)
this.$emit('change', item)
}
this.syncOut(item)
},
syncOut(obj) {
if (!this.itemObj.syncOutAttr) {
return
}
const list = this.itemObj.syncOutAttr.split(',')
list.forEach(r => {
const keyname = r.split(':')
if (keyname.length === 2) {
const val = obj ? _get(obj, keyname[1]) : ''
_set(this.form, keyname[0], val)
}
})
},
findWarehouse() {
const warehouse = this.areaList.find(item => item.id === this.form.extProductArea.id)
this.warehouseOptions = warehouse.extDxProductWorkCenters
change() {
this.update()
}
}
}
......
......@@ -7,11 +7,21 @@ const privateComponents = []
requireComponent.keys().forEach(fileName => {
const comp = requireComponent(fileName)
if (comp.default.componentName) {
let layoutConfigData = comp.default.layoutConfigData
if (!layoutConfigData && comp.default.mixins) {
const hasLayoutConfigData = comp.default.mixins.find(el => {
return el.layoutConfigData
})
if (hasLayoutConfigData) {
layoutConfigData = hasLayoutConfigData.layoutConfigData
}
}
privateComponents.push(
{
componentName: comp.default.componentName,
name: comp.default.name,
path: fileName.slice(1)
path: fileName.slice(1),
layoutConfigData: layoutConfigData || []
}
)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment