Commit ad93985a authored by 何虹's avatar 何虹 💬

hs-input-select优化

parent 20d0918c
......@@ -130,7 +130,7 @@ export default {
await this.remoteMethodsDebounce(query, this.configData)
},
dealWithDefaultData() {
const { sourceData } = _.cloneDeep(this.allSourceData)
const sourceData = _.cloneDeep(this.data || [])
const sourceData_ = _.cloneDeep(sourceData)
return Array.isArray(sourceData_)
? this.tansLate(sourceData_)
......
......@@ -62,7 +62,7 @@
</hs-table>
<div
v-if='this.lookupConfig.multiple'
v-if='this.configData.multiple'
slot="footer"
class="dialog-footer"
>
......@@ -88,7 +88,7 @@ export default {
name: 'lookup-component',
computed: {
getDisabled: function() {
const { disabled, disabledLevel } = this.lookupConfig
const { disabled, disabledLevel } = this.configData
const type = typeof disabled
if (disabledLevel === 1) {
// 以自己的的配置为优先级最高
......@@ -105,13 +105,10 @@ export default {
}
}
},
lookupConfig: function() {
return this.allSourceData.config || {}
},
hsTableData() {
console.log('测试hsTableData')
const data = this.tableData
const { value } = this.lookupConfig
const { value } = this.configData
const list = this.value ? this.value.split(',') : []
list.forEach(x => { // 设置默认勾选
const target = data.find(item => item[value] === x)
......@@ -150,7 +147,7 @@ export default {
this.hsTableEl.position,
'hsTableSimple'
)
const { multiple } = this.lookupConfig
const { multiple } = this.configData
config.selection = !!multiple
return config
},
......@@ -161,7 +158,7 @@ export default {
}
},
configData: function() {
return this.allSourceData.config || {}
return this.config || {}
}
},
watch: {
......@@ -225,7 +222,7 @@ export default {
},
async showDialog() {
// 弹出之前做逻辑判断
const { value, multiple } = this.lookupConfig
const { value, multiple } = this.configData
if (this.value && multiple) {
// 多选
const ids = this.value.split(',')
......@@ -260,7 +257,7 @@ export default {
init_value() {
if (!this.hsTableConfig) return
const sourceData = this.hsTableData
const { multiple, value, displayfield } = this.lookupConfig
const { multiple, value, displayfield } = this.configData
const displayfield_value = this.formData[displayfield]
if (displayfield_value) {
const list = displayfield_value.split(',')
......@@ -296,13 +293,12 @@ export default {
}
},
async queryByIds() {
this.allSourceData.sourceData = []
const { value } = this.lookupConfig
const { value } = this.configData
// 调用外面的查询方法
const obj = {}
obj[value] = this.value
const data = await this.$listeners.queryLookup(
this.allSourceData.config,
this.configData,
obj,
this.formData
)
......@@ -317,10 +313,9 @@ export default {
* 查询table数据
*/
async queryTable() {
this.allSourceData.sourceData = []
this.setDefaultQueryParms()
// 如果有分页信息则要分页
const { per_page } = this.lookupConfig
const { per_page } = this.configData
if (per_page && this.firstQuery) {
this.firstQuery = false
this.searchForm.per_page = per_page
......@@ -328,7 +323,7 @@ export default {
}
// 调用外面的查询方法
const data = await this.$listeners.queryLookup(
this.allSourceData.config,
this.configData,
this.searchForm,
this.formData
)
......@@ -337,7 +332,7 @@ export default {
this.paging = paging
}
// 做一个合并数据
const { multiple } = this.lookupConfig
const { multiple } = this.configData
let returnData = []
if (Array.isArray(data)) {
returnData = data
......@@ -354,7 +349,7 @@ export default {
}
},
unShiftData(queryData) {
const { value } = this.lookupConfig
const { value } = this.configData
const selectIds = this.selectedData.map(item => item[value])
const data_ = _.remove(queryData, function(item) {
const item_value = item[value]
......@@ -379,7 +374,7 @@ export default {
*/
submit() {
const selectData = this.hsTableData.filter(x => x.isSelected)
const prop = this.allSourceData.config.value
const prop = this.configData.value
const list_ids = selectData.map(x => {
return x[prop]
})
......@@ -398,7 +393,7 @@ export default {
* 双击行时设置当前行为选中项
*/
tableRowDblclick(row) {
const prop = this.allSourceData.config.value
const prop = this.configData.value
this.$emit('input', row[prop])
this.changeAction(row[prop])
this.setWritebackfield([row])
......@@ -407,7 +402,7 @@ export default {
},
setLabelValue(data) {
const selectData = data
const label = this.allSourceData.config.displayfield
const label = this.configData.displayfield
const label_list = selectData.map(x => x[label])
this.label_value = label_list.join(',')
this.label_value_old = this.label_value
......@@ -418,7 +413,7 @@ export default {
setWritebackfield(data) {
this.isChange = true
const selectData = data
const writebackfield = this.allSourceData.config.writebackfield
const writebackfield = this.configData.writebackfield
if (writebackfield) {
// 解析回写字段
writebackfield.forEach(item => {
......@@ -436,7 +431,7 @@ export default {
* 清除回写字段
*/
clearWritebackfield() {
const writebackfield = this.allSourceData.config.writebackfield
const writebackfield = this.configData.writebackfield
writebackfield.forEach(item => {
const [v1, v2] = item.split('=')
if (v2) {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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