提交 b592a1af 编写于 作者: ibizdev's avatar ibizdev

zhujiamin 发布系统代码 [TrainSys,网页端]

上级 f9b52580
......@@ -30,6 +30,12 @@ export const IBizMPicker = defineComponent({
// 加载中
const loading: Ref<boolean> = ref(false);
// 组件实例
const selectRef: Ref<Vue | null> = ref(null);
// 远程搜索默认值
const defaultLabel: Ref<string[]> = ref([]);
// 监听传入值
watch(
() => props.value,
......@@ -38,36 +44,47 @@ export const IBizMPicker = defineComponent({
selectItems.value = [];
if (newVal) {
selectItems.value = JSON.parse(newVal);
selectItems.value.forEach((item: IData) => {
// 选项没有的时候补充选项
const index = items.value.findIndex(i =>
Object.is(i.srfkey, item.srfkey),
);
if (index < 0) {
items.value.push({
srfkey: item.srfkey,
srfmajortext: item.srfmajortext,
});
}
// 赋值
curValue.value.push(item.srfkey);
});
if (selectItems.value.length > 0) {
selectItems.value.forEach((item: IData) => {
// 选项没有的时候补充选项
const index = items.value.findIndex(i =>
Object.is(i.srfkey, item.srfkey),
);
if (index < 0) {
items.value.push(item);
defaultLabel.value.push(item.srfmajortext);
}
// 赋值
curValue.value.push(item.srfkey);
});
}
}
},
{ immediate: true, deep: true },
);
// 处理视图关闭,往外抛值
const handleOpenViewClose = (result: IData[]) => {
const handleOpenViewClose = async (result: IData[]) => {
// 抛出值集合
const valArr: IData[] = [];
if (result && Array.isArray(result)) {
result.forEach((select: IData) => {
for (let i = 0; i < result.length; i++) {
const select = result[i];
// 回显并且回来的选中值只有srfkey和srfmajortext,所以||
const formattedItem = {
srfkey: select[c.keyName] || select.srfkey,
srfmajortext: select[c.textName] || select.srfmajortext,
};
// 自填模式
// eslint-disable-next-line no-await-in-loop
const dataItems = await c.calcFillDataItems(select);
if (dataItems.length > 0) {
dataItems.forEach(dataItem => {
Object.assign(formattedItem, {
[dataItem.name]: dataItem.value,
});
});
}
valArr.push(formattedItem);
// 选项不存在的补充到选项里
......@@ -77,7 +94,7 @@ export const IBizMPicker = defineComponent({
if (index < 0) {
items.value.push(formattedItem);
}
});
}
}
const value = valArr.length > 0 ? JSON.stringify(valArr) : '';
emit('change', value);
......@@ -104,10 +121,7 @@ export const IBizMPicker = defineComponent({
Object.is(item.srfkey, select),
);
if (findItem) {
valArr.push({
srfkey: findItem.srfkey,
srfmajortext: findItem.srfmajortext,
});
valArr.push(findItem);
}
});
const value = valArr.length > 0 ? JSON.stringify(valArr) : '';
......@@ -124,7 +138,7 @@ export const IBizMPicker = defineComponent({
try {
const res = await c.getServiceData(query, props.data!);
loading.value = false;
if (res) {
if (res.data.length > 0) {
items.value = res.data.map(item => ({
srfkey: item[c.keyName],
srfmajortext: item[c.textName],
......@@ -154,17 +168,24 @@ export const IBizMPicker = defineComponent({
.join(',');
});
const setDefaultOptions = (options: IData[]) => {
items.value = options;
};
return {
ns,
c,
selectRef,
curValue,
loading,
items,
defaultLabel,
valueText,
onSearch,
onOpenChange,
onSelect,
openPickUpView,
setDefaultOptions,
};
},
render() {
......@@ -179,21 +200,23 @@ export const IBizMPicker = defineComponent({
{this.readonly && this.valueText}
{!this.readonly && (
<i-select
ref='selectRef'
value={this.curValue}
filterable
transfer
multiple
default-label={this.defaultLabel}
loading={this.loading}
placeholder={this.c.placeHolder}
remote-method={this.c.model.appDataEntity ? this.onSearch : null}
remote-method={this.onSearch}
on-on-open-change={this.onOpenChange}
on-on-change={this.onSelect}
disabled={this.disabled}
>
{this.items.map((item, index) => {
{this.items.map(item => {
return (
<i-option
key={index}
key={item.srfkey}
value={item.srfkey}
label={item.srfmajortext}
>
......
......@@ -1224,16 +1224,16 @@
"mOSFilePath" : "pssysapps/TemplatePublish/psappviewmsggroups/VMGroup2",
"name" : "视图消息组2",
"getPSAppViewMsgGroupDetails" : [ {
"name" : "视图消息2",
"name" : "视图消息",
"getPSAppViewMsg" : {
"modelref" : true,
"id" : "ViewMsg3"
"id" : "ViewMsg2"
}
}, {
"name" : "视图消息",
"name" : "视图消息2",
"getPSAppViewMsg" : {
"modelref" : true,
"id" : "ViewMsg2"
"id" : "ViewMsg3"
}
} ],
"rTMOSFilePath" : "pssysapps/TemplatePublish/psappviewmsggroups/VMGroup2"
......
......@@ -2500,16 +2500,16 @@
"mOSFilePath" : "pssysapps/Web/psappviewmsggroups/VMGroup2",
"name" : "视图消息组2",
"getPSAppViewMsgGroupDetails" : [ {
"name" : "视图消息2",
"name" : "视图消息",
"getPSAppViewMsg" : {
"modelref" : true,
"id" : "ViewMsg3"
"id" : "ViewMsg2"
}
}, {
"name" : "视图消息",
"name" : "视图消息2",
"getPSAppViewMsg" : {
"modelref" : true,
"id" : "ViewMsg2"
"id" : "ViewMsg3"
}
} ],
"rTMOSFilePath" : "pssysapps/Web/psappviewmsggroups/VMGroup2"
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册