提交 314514bf 编写于 作者: tony001's avatar tony001

Merge branch 'dev'

...@@ -123,6 +123,12 @@ export default class DropDownListDynamic extends Vue { ...@@ -123,6 +123,12 @@ export default class DropDownListDynamic extends Vue {
*/ */
@Prop() public placeholder?: string; @Prop() public placeholder?: string;
/**
* 属性类型
* @type {string}
* @memberof DropDownList
*/
@Prop() public valueType?: string;
/** /**
* 计算属性(当前值) * 计算属性(当前值)
...@@ -199,9 +205,10 @@ export default class DropDownListDynamic extends Vue { ...@@ -199,9 +205,10 @@ export default class DropDownListDynamic extends Vue {
if(this.tag && Object.is(this.codelistType,"STATIC")){ if(this.tag && Object.is(this.codelistType,"STATIC")){
const codelist = this.$store.getters.getCodeList(this.tag); const codelist = this.$store.getters.getCodeList(this.tag);
if (codelist) { if (codelist) {
this.items = [...JSON.parse(JSON.stringify(codelist.items))]; let items: Array<any> = [...JSON.parse(JSON.stringify(codelist.items))];
this.formatCodeList(items);
} else { } else {
console.log(`----${this.tag}----${(this.$t('app.commonWords.codeNotExist') as string)}`); console.log(`----${this.tag}----代码表不存在`);
} }
}else if(this.tag && Object.is(this.codelistType,"DYNAMIC")){ }else if(this.tag && Object.is(this.codelistType,"DYNAMIC")){
// 公共参数处理 // 公共参数处理
...@@ -211,9 +218,10 @@ export default class DropDownListDynamic extends Vue { ...@@ -211,9 +218,10 @@ export default class DropDownListDynamic extends Vue {
let _context = data.context; let _context = data.context;
let _param = data.param; let _param = data.param;
this.codeListService.getItems(this.tag,_context,_param).then((res:any) => { this.codeListService.getItems(this.tag,_context,_param).then((res:any) => {
this.items = res; let items: Array<any> = [...res];
this.formatCodeList(items);
}).catch((error:any) => { }).catch((error:any) => {
console.log(`----${this.tag}----${(this.$t('app.commonWords.codeNotExist') as string)}`); console.log(`----${this.tag}----代码表不存在`);
}); });
} }
} }
...@@ -234,14 +242,51 @@ export default class DropDownListDynamic extends Vue { ...@@ -234,14 +242,51 @@ export default class DropDownListDynamic extends Vue {
let _context = data.context; let _context = data.context;
let _param = data.param; let _param = data.param;
this.codeListService.getItems(this.tag,_context,_param).then((res:any) => { this.codeListService.getItems(this.tag,_context,_param).then((res:any) => {
this.items = res; let items: Array<any> = [...res];
this.formatCodeList(items);
}).catch((error:any) => { }).catch((error:any) => {
console.log(`----${this.tag}----${(this.$t('app.commonWords.codeNotExist') as string)}`); console.log(`----${this.tag}----代码表不存在`);
}); });
} }
} }
} }
/**
* 代码表类型和属性匹配
*
* @param {*} items
* @memberof DropDownList
*/
public formatCodeList(items: Array<any>){
let matching: boolean = true;
this.items = [];
try{
if(this.valueType){
items.forEach((item: any)=>{
const type = this.$util.typeOf(item.value);
if(type != this.valueType){
matching = false;
if(type == 'number'){
item.value = item.value.toString();
}else{
if(item.value.indexOf('.') == -1){
item.value = parseInt(item.value);
}else{
item.value = parseFloat(item.value);
}
}
}
this.items.push(item);
});
if(!matching){
console.warn(`代码表 ${ this.tag } 值类型和属性类型不匹配,已自动强制转换,请修正代码表值类型和属性类型匹配`);
}
}else{
this.items = items;
}
}catch(error){
console.warn('代码表值类型和属性类型不匹配,自动强制转换异常,请修正代码表值类型和属性类型匹配');
}
}
} }
</script> </script>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
:filterable="filterable === true ? true : false" :filterable="filterable === true ? true : false"
@on-open-change="onClick" @on-open-change="onClick"
:placeholder="$t('components.dropDownList.placeholder')"> :placeholder="$t('components.dropDownList.placeholder')">
<i-option v-for="(item, index) in items" :key="index" :value="item.value.toString()">{{($t('codelist.'+tag+'.'+item.value)!== ('codelist.'+tag+'.'+item.value))?$t('codelist.'+tag+'.'+item.value) : item.text}}</i-option> <i-option v-for="(item, index) in items" :key="index" :value="item.value">{{($t('codelist.'+tag+'.'+item.value)!== ('codelist.'+tag+'.'+item.value))?$t('codelist.'+tag+'.'+item.value) : item.text}}</i-option>
</i-select> </i-select>
</template> </template>
...@@ -116,7 +116,7 @@ export default class DropDownList extends Vue { ...@@ -116,7 +116,7 @@ export default class DropDownList extends Vue {
* @memberof AppFormDRUIPart * @memberof AppFormDRUIPart
*/ */
@Prop() public viewparams!: any; @Prop() public viewparams!: any;
/** /**
* 是否禁用 * 是否禁用
* @type {any} * @type {any}
...@@ -139,6 +139,12 @@ export default class DropDownList extends Vue { ...@@ -139,6 +139,12 @@ export default class DropDownList extends Vue {
*/ */
@Prop() public placeholder?: string; @Prop() public placeholder?: string;
/**
* 属性类型
* @type {string}
* @memberof DropDownList
*/
@Prop() public valueType?: string;
/** /**
* 计算属性(当前值) * 计算属性(当前值)
...@@ -157,7 +163,7 @@ export default class DropDownList extends Vue { ...@@ -157,7 +163,7 @@ export default class DropDownList extends Vue {
* @memberof DropDownList * @memberof DropDownList
*/ */
get currentVal() { get currentVal() {
return this.itemValue ? this.itemValue.toString() : undefined; return this.itemValue;
} }
/** /**
...@@ -199,9 +205,10 @@ export default class DropDownList extends Vue { ...@@ -199,9 +205,10 @@ export default class DropDownList extends Vue {
if(this.tag && Object.is(this.codelistType,"STATIC")){ if(this.tag && Object.is(this.codelistType,"STATIC")){
const codelist = this.$store.getters.getCodeList(this.tag); const codelist = this.$store.getters.getCodeList(this.tag);
if (codelist) { if (codelist) {
this.items = [...JSON.parse(JSON.stringify(codelist.items))]; let items: Array<any> = [...JSON.parse(JSON.stringify(codelist.items))];
this.formatCodeList(items);
} else { } else {
console.log(`----${this.tag}----${(this.$t('app.commonWords.codeNotExist') as string)}`); console.log(`----${this.tag}----代码表不存在`);
} }
}else if(this.tag && Object.is(this.codelistType,"DYNAMIC")){ }else if(this.tag && Object.is(this.codelistType,"DYNAMIC")){
// 公共参数处理 // 公共参数处理
...@@ -211,9 +218,10 @@ export default class DropDownList extends Vue { ...@@ -211,9 +218,10 @@ export default class DropDownList extends Vue {
let _context = data.context; let _context = data.context;
let _param = data.param; let _param = data.param;
this.codeListService.getItems(this.tag,_context,_param).then((res:any) => { this.codeListService.getItems(this.tag,_context,_param).then((res:any) => {
this.items = res; let items: Array<any> = [...res];
this.formatCodeList(items);
}).catch((error:any) => { }).catch((error:any) => {
console.log(`----${this.tag}----${(this.$t('app.commonWords.codeNotExist') as string)}`); console.log(`----${this.tag}----代码表不存在`);
}); });
} }
} }
...@@ -234,14 +242,52 @@ export default class DropDownList extends Vue { ...@@ -234,14 +242,52 @@ export default class DropDownList extends Vue {
let _context = data.context; let _context = data.context;
let _param = data.param; let _param = data.param;
this.codeListService.getItems(this.tag,_context,_param).then((res:any) => { this.codeListService.getItems(this.tag,_context,_param).then((res:any) => {
this.items = res; let items: Array<any> = [...res];
this.formatCodeList(items);
}).catch((error:any) => { }).catch((error:any) => {
console.log(`----${this.tag}----${(this.$t('app.commonWords.codeNotExist') as string)}`); console.log(`----${this.tag}----代码表不存在`);
}); });
} }
} }
} }
/**
* 代码表类型和属性匹配
*
* @param {*} items
* @memberof DropDownList
*/
public formatCodeList(items: Array<any>){
let matching: boolean = true;
this.items = [];
try{
if(this.valueType){
items.forEach((item: any)=>{
const type = this.$util.typeOf(item.value);
if(type != this.valueType){
matching = false;
if(type == 'number'){
item.value = item.value.toString();
}else{
if(item.value.indexOf('.') == -1){
item.value = parseInt(item.value);
}else{
item.value = parseFloat(item.value);
}
}
}
this.items.push(item);
});
if(!matching){
console.warn(`代码表 ${ this.tag } 值类型和属性类型不匹配,已自动强制转换,请修正代码表值类型和属性类型匹配`);
}
}else{
this.items = items;
}
}catch(error){
console.warn('代码表值类型和属性类型不匹配,自动强制转换异常,请修正代码表值类型和属性类型匹配');
}
}
} }
</script> </script>
......
...@@ -54,7 +54,7 @@ export class UIActionTool { ...@@ -54,7 +54,7 @@ export class UIActionTool {
let value: string | null = _params[name]; let value: string | null = _params[name];
if (value && typeof(value) === 'string' && value.startsWith('%') && value.endsWith('%')) { if (value && typeof(value) === 'string' && value.startsWith('%') && value.endsWith('%')) {
const key = value.substring(1, value.length - 1); const key = value.substring(1, value.length - 1);
if (arg && arg.hasOwnProperty(key)) { if (arg && arg.hasOwnProperty(key) && Object.is(actionTarget, 'SINGLEKEY')) {
value = (arg[key] !== null && arg[key] !== undefined) ? arg[key] : null; value = (arg[key] !== null && arg[key] !== undefined) ? arg[key] : null;
} else if(parentContext && parentContext.hasOwnProperty(key)){ } else if(parentContext && parentContext.hasOwnProperty(key)){
value = (parentContext[key] !== null && parentContext[key] !== undefined) ? parentContext[key] : null; value = (parentContext[key] !== null && parentContext[key] !== undefined) ? parentContext[key] : null;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册