功能变化: 注册selectorTable前端组件

pull/103/head
李强 2023-06-10 15:37:54 +08:00
parent ccf21dcb1e
commit 3d662e0f0e
2 changed files with 23 additions and 8 deletions

View File

@ -3,6 +3,7 @@ import Vue from 'vue'
import d2Container from './d2-container'
import tableProgress from './table-progress/lib/table-progress.vue'
import cardSelect from '@/components/card-select/index'
import selectorTable from '@/components/selector-table/index'
// 注意 有些组件使用异步加载会有影响
Vue.component('d2-container', d2Container)
Vue.component('d2-icon', () => import('./d2-icon'))
@ -14,4 +15,5 @@ Vue.component('d2p-tree-selector', () => import('./tree-selector/lib/tree-select
Vue.component('dept-format', () => import('./dept-format/lib/dept-format.vue'))
Vue.component('dvaHtml2pdf', () => import('./dvaHtml2pdf/index.vue'))
Vue.component('table-progress', tableProgress)
Vue.use(selectorTable)
Vue.use(cardSelect)

View File

@ -92,6 +92,7 @@ export default {
default () {
return {
tableConfig: {
pagination: true,
multiple: false,
columns: []
}
@ -160,10 +161,10 @@ export default {
handler (newValue, oldVal) {
const { tableConfig } = this._elProps
//
if (!tableConfig.multiple) {
this.currentValue = [newValue]
} else {
if (tableConfig.multiple) {
this.currentValue = newValue
} else {
this.currentValue = [newValue]
}
},
deep: true,
@ -196,19 +197,27 @@ export default {
methods: {
//
setCurrentValue (val) {
const params = {}
if (this._elProps.tableConfig.pagination) {
params.page = this.pageConfig.page
params.limit = this.pageConfig.limit
}
if (val.toString().length > 0) {
// value
const { url, value, label } = this.dict
const params = {}
params[value] = val
params.query = `{${label},${value}}`
return request({
url: url,
params: params,
method: 'get'
}).then(res => {
const { data } = res.data
if (data && data.length > 0) {
this.currentValue = data
const { data, page, limit, total } = res
this.pageConfig.page = page
this.pageConfig.limit = limit
this.pageConfig.total = total
if (data.data && data.data.length > 0) {
this.currentValue = data.data
} else {
this.currentValue = null
}
@ -220,6 +229,7 @@ export default {
//
getDict () {
const that = this
const { value, label } = this.dict
let url
if (typeof that.dict.url === 'function') {
const form = that.d2CrudContext.getForm()
@ -233,7 +243,8 @@ export default {
}
const params = {
page: that.pageConfig.page,
limit: that.pageConfig.limit
limit: that.pageConfig.limit,
query: `{${label},${value}}`
}
if (that.search) {
params.search = that.search
@ -269,6 +280,7 @@ export default {
const { tableConfig } = that._elProps
if (tableConfig.multiple) {
that.$refs.tableRef.clearSelection() // ,
// eslint-disable-next-line no-unused-expressions
that.currentValue ? that.currentValue.forEach(item => {
that.$refs.tableRef.toggleRowSelection(item, true)
}) : null
@ -333,6 +345,7 @@ export default {
this.$emit('input', '')
this.$emit('change', '')
} else {
// eslint-disable-next-line no-unused-expressions
this.$refs.tableRef?.toggleRowSelection(obj, false)
// const { value } = this.dict
// const result = this.currentValue.map((item) => {