提交 0a824ee4 编写于 作者: Neuromancer255's avatar Neuromancer255

下拉列表(多选)加载逻辑调整

上级 f352e0ff
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="app-mobile-check-list"> <div class="app-mobile-check-list">
<div class="cancel-icon" v-if="curValue"><ion-icon name="close-circle-outline" @click="clear"></ion-icon></div> <div class="cancel-icon" v-if="curValue"><ion-icon name="close-circle-outline" @click="clear"></ion-icon></div>
<div v-if="curValue== null || curValue==''" class="ion-select-icon"></div> <div v-if="curValue== null || curValue==''" class="ion-select-icon"></div>
<ion-select ref="checkList" @ionChange="change" multiple="true" :ok-text="$t('app.button.confirm')" :cancel-text="$t('app.button.cancel')"> <ion-select ref="checkList" @ionChange="change" multiple="true" @click="load" :ok-text="$t('app.button.confirm')" :cancel-text="$t('app.button.cancel')">
<ion-select-option v-for="option of options" :key="option.value" :value="option.value">{{option.text}} <ion-select-option v-for="option of options" :key="option.value" :value="option.value">{{option.text}}
</ion-select-option> </ion-select-option>
</ion-select> </ion-select>
...@@ -42,18 +42,6 @@ ...@@ -42,18 +42,6 @@
*/ */
@Prop() public value ? : string; @Prop() public value ? : string;
/**
* 回填值
* @memberof AppCheckList
*/
@Watch('value')
valueChange(newValue: string, oldValue: string) {
this.value = newValue
const select:any = this.$refs.checkList;
let arr = this.value.split(',')
select.value = arr;
}
/** /**
* 当前选中值 * 当前选中值
* @memberof AppCheckList * @memberof AppCheckList
...@@ -116,6 +104,13 @@ ...@@ -116,6 +104,13 @@
*/ */
@Prop({ default: true }) protected isCache?: boolean; @Prop({ default: true }) protected isCache?: boolean;
/**
* 是否被缓存
*
* @type {*}
* @memberof AppSelect
*/
public isCached: boolean = false;
/** /**
* 传入表单数据 * 传入表单数据
...@@ -139,22 +134,40 @@ ...@@ -139,22 +134,40 @@
* @type {*} * @type {*}
* @memberof AppCheckList * @memberof AppCheckList
*/ */
public created() { public mounted() {
this.load();
}
/**
* 加载
*
* @returns {Promise<any>}
* @memberof AppSelect
*/
public async load(): Promise<any> {
if (this.tag && this.type) { if (this.tag && this.type) {
if (Object.is(this.type, "dynamic")) { if (Object.is(this.type, "static")) {
this.codeListService return;
.getItems(this.tag) }
.then((res: any) => {
this.options = res;
})
.catch((error: any) => {
this.options = [];
});
} else {
// 处理导航参数、上下文参数 // 处理导航参数、上下文参数
let param: any= {}; let param: any = {};
this.handleOtherParam(param); const bcancel: boolean =this.handleOtherParam(param);
this.options = this.$store.getters.getCodeListItems(this.tag ,this.isCache, param.context, param.param); if (!bcancel) {
return
}
let response: any = await this.codeListService.getItems(this.tag, param.context, param.param);
if (response) {
this.options = response
if (this.isCache) {
this.isCached = true;
}
if (this.value) {
const select:any = this.$refs.checkList;
let arr = this.value.split(',')
select.value = arr;
}
} else {
this.options = [];
} }
} }
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册