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.
......@@ -21,6 +21,134 @@
@clickLabel='clickToolLabel'
></tool-column>
</span>
<template v-if='!tableConfig.expandChild'>
<u-table
:data-changes-scroll-top='false'
:big-data-checkbox="true"
ref="plTable"
:data="tableData"
:height="tableHeight"
use-virtual
showHeaderOverflow="title"
border
:show-summary='showSummary'
:summary-method="getSummaries"
@select-all='selectAll'
@select='selectCheckBox'
@sort-change='sortChange'
@row-dblclick='rowDblclick'
@row-click="rowClick"
@selection-change='selectionChange'
:pagination-show="!!paging"
:total="pagingConfig.total"
:page-size="pagingConfig.per_page"
:current-page="pagingConfig.page"
:page-sizes='pageSizes'
@handlePageSize='handlePageSize'
:row-height="rowHeight"
:row-style='setRowStyle'
>
<template v-for='(column,index) in tableColumns'>
<template v-if="!column.childs">
<u-table-column
v-if='tableConfig.expandChild'
:key="index"
type="expand"
>
<template slot-scope="props">
<rowTable :rowTable='props.row._childTable'></rowTable>
</template>
</u-table-column>
<u-table-column
v-else-if="column.showType==='index'"
:key="index"
type="index"
width="55"
/>
<u-table-column
v-else-if="column.showType==='selection'"
:key="index"
type="selection"
width="55"
:selectable="selectable"
/>
<u-table-column
v-else-if='column.showType==="handleColumn"'
:key="index"
fixed="right"
label="操作"
:width='tableConfig.handleWidth'
>
<template slot-scope="scope">
<handle-column
:data='tableHandleColumns'
:row='scope.row'
:showItem='showItem'
:disabledItem='disabledItem'
@itemClickHandle='itemClickHandle'
/>
</template>
</u-table-column>
<u-table-column
v-else
:key="index"
:resizable="column.resizable"
:show-overflow-tooltip="column.showOverflow"
:prop="column.prop"
:label="column.label"
:fixed="column.fixed"
:min-width="column.width||80"
:sortable="column.isSort?'custom':false"
>
<template slot-scope="scope">
<i
v-if="column.type==='checkBox'"
:class="rowCellBoolean(scope.row[column.prop])"
></i>
<childItem
v-else
:editable='editable'
v-bind="$attrs"
v-on="$listeners"
:item='column'
:prop="column.prop"
:formParms='scope.row'
>
</childItem>
</template>
</u-table-column>
</template>
<template v-else-if='column.childs'>
<u-table-column
:label="column.label"
:key="index"
>
<template v-for="item in column.childs">
<u-table-column
:prop="item.prop"
:label="item.label"
:key="item.label"
:min-width="column.width||80"
>
<template slot-scope="scope">
<childItem
:item='item'
:formParms='scope.row'
v-bind="$attrs"
v-on="$listeners"
:editable='editable'
>
</childItem>
</template>
</u-table-column>
</template>
</u-table-column>
</template>
</template>
</u-table>
</template>
<template v-else>
<ux-grid
:data-changes-scroll-top='false'
:big-data-checkbox="true"
......@@ -149,6 +277,7 @@
</template>
</ux-grid>
</template>
<tbaleColumsSet
v-model="dialogVisibleTbaleColums"
:tableDataColums='tableDataColums'
......
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