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

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

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