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

hs-input-select优化

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