我的地区选择框,要两次选一样的才能选中,而且选择框是黑色的,

deny_crack





if (type == 'regionSelect') {

Object.assign(columnItem, {

type: 'cascader', lazy: true, dictType: 'region',

props: { label: 'name', value: 'id' },

lazyLoad: (node, resolve) => {

const level = node.level;

const data = node.data || {}

let pid = data.id

const regionType = columnItem.regionType

if (level == 0) pid = regionType == 'gj' ? 0 : 1

// callApiFun('get', '/system/area/tree', { params: { ip :pid } }).then(res => {

callApiFun('get', '/system/area/tree-by-id', { params: { id:pid } }).then(res => {

res = res.map(item => {

item.id = item.id + ''

if (['gj', 's'].includes(regionType) || (regionType == 'ss' && node.level == 1)) item.leaf = true

return item

})

resolve(res)

})

},

dataType: columnItem.multiple ? 'json' : 'string',

formatter: (row, value, valueText, column) => {

if (!value) {

row[`$${column.prop}`] = ''

return ''

}

const separator = column.separator || (column.multiple ? ' | ' : '/')

if (isValidJson(value)) value = JSON.parse(value)

row[`$${column.prop}`] = (value instanceof Array ? value : value.split(',')).map(id => {

if (id instanceof Array) return id.map(i => lowStore.dicObj[regionDicKey]?.[i] || i).join('/')

return lowStore.dicObj[regionDicKey]?.[id] || id

}).join(separator)

return row[`$${column.prop}`]

}

})

}

回答9

deny_crack

我自己没有改,要

点两次才能选中,第一次选中一个,框里没有值,然后你第二次又点开控件又选你上次的那个值,就能选中了



超级管理员
@deny_crack

演示环境可以复现?看一下控制台有没有报错之类的

deny_crack

我也可以打印出来选中的值,就是不回显到控件上

超级管理员
@deny_crack

我知道你的问题,但是演示环境复现不了我这边也不知道怎么调试,或者你把你的表单导到演示环境看看,能不能出现这个问题

超级管理员
@deny_crack

嗯...地区选择器是定制好的用的是懒加载逻辑,尽量不要改,要自己一次性返回所有数据就用,级联选择器去弄例如

return {

 dicUrl: '/system/area/tree-by-id', //请求接口

 dicMethod: 'get', //请求类型

 dicHeaders: {},

 props: { //字典text 字典value对应的字段名

   label: 'name',

   value: 'id',

 },

 dicQuery: { //请求参数

   pid: '1'

 },

 dicFormatter: (res) => { //请求数据格式化

   console.log('===远端数据===', res)

   return res

 }

}

写回答

扫码关注

微信公众号二维码