关联模型使用table选择器代替;

This commit is contained in:
2022-07-09 16:36:44 +08:00
parent 6a7e45bd8e
commit ec8e3cdaed
4 changed files with 40 additions and 88 deletions

View File

@@ -76,24 +76,24 @@ define(['jquery', 'vue'], function ($, Vue) {
},
created() {
this.value = options.selectValue;
if(typeof this.value != 'string') {
if (typeof this.value != 'string') {
this.value = this.value.toString();
}
var valueLength = this.value.split(',').length;
loading.show();
$.get(options.index,{
page:1,
limit:valueLength,
filter:JSON.stringify({id:this.value}),
op: JSON.stringify({id:'in'})
},(result)=>{
$.get(options.index, {
page: 1,
limit: valueLength,
filter: JSON.stringify({ id: this.value }),
op: JSON.stringify({ id: 'in' })
}, (result) => {
loading.hide()
this.listSelected = result.data;
})
},
mounted() {
if(options.required == 1){
if (options.required == 1) {
$(this.$refs['tableData']).closest('.layui-form-item').children('.layui-form-label').addClass('required');
}
},
@@ -103,12 +103,12 @@ define(['jquery', 'vue'], function ($, Vue) {
openSelectPage() {
var selectedIds = this.listSelected.map(item => item.id);
var index = layer.open({
title: '选择数据',
type: 2,
area: [options.width, options.height],
content: options.index+'&selectedIds='+selectedIds.join(','),
content: options.index + '&selectedIds=' + selectedIds.join(','),
maxmin: true,
moveOut: true,
shadeClose: true,
@@ -116,6 +116,10 @@ define(['jquery', 'vue'], function ($, Vue) {
window[options.selectConfirmCallback] = (data) => {
data.forEach(dataItem => {
if (options.selectType == 'radio') {
this.listSelected = [];
}
var itemFind = this.listSelected.find(itemSelect => itemSelect[valueField] == dataItem[valueField])
if (itemFind == undefined) {