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

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

上级 f352e0ff
......@@ -2,7 +2,7 @@
<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 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>
</ion-select>
......@@ -42,18 +42,6 @@
*/
@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
......@@ -116,6 +104,13 @@
*/
@Prop({ default: true }) protected isCache?: boolean;
/**
* 是否被缓存
*
* @type {*}
* @memberof AppSelect
*/
public isCached: boolean = false;
/**
* 传入表单数据
......@@ -139,22 +134,40 @@
* @type {*}
* @memberof AppCheckList
*/
public created() {
public mounted() {
this.load();
}
/**
* 加载
*
* @returns {Promise<any>}
* @memberof AppSelect
*/
public async load(): Promise<any> {
if (this.tag && this.type) {
if (Object.is(this.type, "dynamic")) {
this.codeListService
.getItems(this.tag)
.then((res: any) => {
this.options = res;
})
.catch((error: any) => {
this.options = [];
});
} else {
if (Object.is(this.type, "static")) {
return;
}
// 处理导航参数、上下文参数
let param: any= {};
this.handleOtherParam(param);
this.options = this.$store.getters.getCodeListItems(this.tag ,this.isCache, param.context, param.param);
let param: any = {};
const bcancel: boolean =this.handleOtherParam(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 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册