dcat-admin icon indicating copy to clipboard operation
dcat-admin copied to clipboard

from表单使用selectTable组件的时候,需求通过其他select组件选择后的值过滤数据。

Open a624012869 opened this issue 3 years ago • 4 comments

  • Laravel Version: #.#.#
  • PHP Version: #.#.#
  • Dcat Admin Version: #.#.#

Description:

想通过其他select组件选择后的值来过滤selectTable数据源,这个怎么能实现?

Steps To Reproduce:

a624012869 avatar Jun 26 '21 15:06 a624012869

后续会增加这个功能,临时解决方法如下:

selectTable表单的html中有个url,你可以通过监听select组件的变化更改这个url的值来达到更改数据源的目的。

jqhph avatar Jun 28 '21 07:06 jqhph

不知道怎樣實現, 已添加了select的聯動, 但不知道要怎樣更改url

已測試過更改select裡面template的data-url, 沒效果

`
var templateHtml = $($('template')[0]).html();

var template = $(templateHtml);

var content = template.closest('.dialog-table').find("div");

var link = $(content[1]).attr('data-url');

$(content[1]).attr('data-url',link+'&co='+this.value); `

lokpui avatar Dec 01 '22 09:12 lokpui

刚好碰到同样的需求,查了下版本迭代记录,此功能还没发版或者自己没找到 : )。按照老大的思路试着写了下。希望可以有所帮助。( js 写的不是很好)

先说下我的场景吧,我是在form表单新增的时候,hasMany 里面做select 和 selectTable 的联动效果。 遇到的坑:https://zhuanlan.zhihu.com/p/340015952


关键代码

  // hasMany 计算当前是新增的第几个元素
    var tableIndex = $(this).closest('.fields-group').siblings().length + 1
    if (String(this.value) !== '0' && ! this.value) {
        return;
    }

    let tmpTemplateClass = 'select-plus-' + tableIndex
    $(".$setBatchProductClass").siblings('div').find('span template:first').css('color', 'red').addClass(tmpTemplateClass);
    const template = document.querySelector("." + tmpTemplateClass);
    const currentSelectTableUrl = template.content.querySelector('div div.async-table').getAttribute('data-url');
    // 当前弹出的表单链接拼接 link+'&pid='+this.value
    currentSelectTableUrlNew = currentSelectTableUrl + '&pid='+this.value;
    template.content.querySelector('div div.async-table').setAttribute('data-url', currentSelectTableUrlNew)

answer666 avatar Jan 28 '23 08:01 answer666

这个目前还是需要自己实现吗?》

PrinceCoder8 avatar Mar 30 '24 16:03 PrinceCoder8