|
|
@ -235,6 +235,7 @@ function switchPage(eventName, page) { |
|
|
|
* radio checkbox 其他输入框值处理 |
|
|
|
*/ |
|
|
|
function setOtherValueLabel (event, config) { |
|
|
|
|
|
|
|
let value = this[this.formConf.formModel][config.__vModel__] |
|
|
|
// 临时保存其他的选项值 |
|
|
|
this.$nextTick(() => { |
|
|
@ -254,24 +255,57 @@ function setOtherValueLabel(event, config) { |
|
|
|
* @param scheme |
|
|
|
*/ |
|
|
|
function setValueLabel (event, config, scheme) { |
|
|
|
console.log(event) |
|
|
|
console.log(config) |
|
|
|
console.log(scheme) |
|
|
|
// 需要处理的类型 如果是input等则不需要处理 |
|
|
|
let tagOptionKey = processType[config.tag] |
|
|
|
|
|
|
|
if (tagOptionKey) { |
|
|
|
|
|
|
|
if (event instanceof Array) { |
|
|
|
// 多选 其他自定义输入 |
|
|
|
let labelArr = new Array() |
|
|
|
if (!event.includes(0)) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!event.includes(0) && config.tag != 'el-cascader') { |
|
|
|
// 如果多选里没有选择其他,就清掉other |
|
|
|
this.$set(this[this.formConf.labelFormModel], `${scheme.__vModel__}other`, '') |
|
|
|
// 同时把输入框清空 |
|
|
|
document.querySelector('.' + config.tag).querySelector('.item-other-input').value = '' |
|
|
|
} |
|
|
|
// debugger |
|
|
|
|
|
|
|
if (config.tag === 'el-cascader') { |
|
|
|
let labelFormModelArray = [] |
|
|
|
if (scheme.props.props.multiple) {//多选 |
|
|
|
|
|
|
|
event.forEach(item => { |
|
|
|
let itemObj = getCascaderData(item, tagOptionKey, scheme) |
|
|
|
labelFormModelArray.push(itemObj) |
|
|
|
}) |
|
|
|
|
|
|
|
} else {//单选 |
|
|
|
let itemObj = getCascaderData(event, tagOptionKey, scheme) |
|
|
|
labelFormModelArray.push(itemObj) |
|
|
|
|
|
|
|
} |
|
|
|
this.$set(this[this.formConf.labelFormModel], scheme.__vModel__, labelFormModelArray) |
|
|
|
|
|
|
|
} else { |
|
|
|
let labelArr = new Array() |
|
|
|
event.forEach(item => { |
|
|
|
// 拼到头部 其他选项 |
|
|
|
let { label } = getObject(_.get(scheme, tagOptionKey), 'value', item) |
|
|
|
labelArr.push(label) |
|
|
|
}) |
|
|
|
this.$set(this[this.formConf.labelFormModel], scheme.__vModel__, labelArr.join(',')) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
console.log('最终结果') |
|
|
|
console.log(this[this.formConf.labelFormModel]) |
|
|
|
|
|
|
|
} else { |
|
|
|
// 单选 其他自定义输入 |
|
|
|
if (event == 0) { |
|
|
@ -296,14 +330,38 @@ function setValueLabel(event, config, scheme) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function getCascaderData (array, tagOptionKey, scheme) { |
|
|
|
let labelArr = new Array() |
|
|
|
array.forEach(item => { |
|
|
|
// 拼到头部 其他选项 |
|
|
|
let { label } = getObject(_.get(scheme, tagOptionKey), 'value', item) |
|
|
|
labelArr.push(label) |
|
|
|
}) |
|
|
|
|
|
|
|
const item = array[array.length - 1] |
|
|
|
let itemObj = getObject(_.get(scheme, tagOptionKey), 'value', item) |
|
|
|
itemObj.labels = labelArr |
|
|
|
|
|
|
|
itemObj.pathName = labelArr.join(scheme.separator) |
|
|
|
return itemObj |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function getObject (array, key, value) { |
|
|
|
|
|
|
|
let o |
|
|
|
array.some(function iter (a) { |
|
|
|
|
|
|
|
if (a[key].isArray) { |
|
|
|
this.getObject(a[key], key, value) |
|
|
|
} else { |
|
|
|
if (a[key] === value) { |
|
|
|
o = a |
|
|
|
return true |
|
|
|
} |
|
|
|
return Array.isArray(a.children) && a.children.some(iter) |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
return o |
|
|
|
} |
|
|
|