提交 0c6a3c9e 编写于 作者: Cano1997's avatar Cano1997

update: 代码表多语言

上级 0b5c4415
<template> <template>
<checkbox-group class="app-checkbox-list" v-model="selectArray"> <checkbox-group class="app-checkbox-list" v-model="selectArray">
<checkbox v-for="(item,index) in items" :key="index" :label="item.value" :disabled="isDisabled || item.disabled"> <checkbox v-for="(item,index) in items" :key="index" :label="item.value" :disabled="isDisabled || item.disabled">
<span>{{Object.is(codelistType,'STATIC') ? $t('codelist.'+tag+'.'+item.value) : item.text}}</span> <span>{{ item.textLanRes ? $t(item.textLanRes, item.text) : item.text }}</span>
</checkbox> </checkbox>
</checkbox-group > </checkbox-group >
</template> </template>
......
<template> <template>
<el-radio-group class="app-radio-button" v-model="value"> <el-radio-group class="app-radio-button" v-model="value">
<el-radio-button v-for="(_item,index) in items" :key = "index" :label="_item.value" :disabled="isDisabled || _item.disabled"> <el-radio-button v-for="(_item,index) in items" :key = "index" :label="_item.value" :disabled="isDisabled || _item.disabled">
<span>{{Object.is(codelistType,'STATIC') ? $t('codelist.'+tag+'.'+_item.value) : _item.text}}</span> <span>{{ item.textLanRes ? $t(item.textLanRes, item.text) : item.text }}</span>
</el-radio-button> </el-radio-button>
</el-radio-group> </el-radio-group>
</template> </template>
......
<template> <template>
<radio-group class="app-radio-group" v-model="currentVal"> <radio-group class="app-radio-group" v-model="currentVal">
<radio v-for="(_item,index) in items" :key = "index" :label="_item.value" :disabled="isDisabled || _item.disabled"> <radio v-for="(_item,index) in items" :key = "index" :label="_item.value" :disabled="isDisabled || _item.disabled">
<span>{{Object.is(codelistType,'STATIC') ? $t('codelist.'+tag+'.'+_item.value) : _item.text}}</span> <span>{{ item.textLanRes ? $t(item.textLanRes, item.text) : item.text }}</span>
</radio> </radio>
</radio-group> </radio-group>
</template> </template>
......
<template> <template>
<div class="codelist"> <div class="codelist">
<span v-if="ifEmpty">{{$t('codelist.'+tag+'.empty')}}</span> <span v-if="ifEmpty">{{emptytext}}</span>
<template v-if="!ifEmpty"> <template v-if="!ifEmpty">
<template v-for="(item, index) in items"> <template v-for="(item, index) in items">
<div class="codelist-item" :key="index" :style="{ color: item.color, borderColor: item.color }"> <div class="codelist-item" :key="index" :style="{ color: item.color, borderColor: item.color }">
<i v-if="item.iconcls" :class="item.iconcls"></i> <i v-if="item.iconcls" :class="item.iconcls"></i>
<img v-if="item.icon" :src="getIcon(item.icon)" /> <img v-if="item.icon" :src="getIcon(item.icon)" />
<span :class="item.class"> <span :class="item.class">
{{ isUseLangres ? $t(item.text) : item.text }} {{ tem.text }}
</span> </span>
<span v-if="index != items.length-1">{{ textSeparator }}</span> <span v-if="index != items.length-1">{{ textSeparator }}</span>
</div> </div>
...@@ -141,11 +141,11 @@ export default class CodeList extends Vue { ...@@ -141,11 +141,11 @@ export default class CodeList extends Vue {
} }
/** /**
* 是否使用多语言资源 * 空值文本
* @type {boolean} * @type {string}
* @memberof CodeList * @memberof CodeList
*/ */
public isUseLangres:boolean = false; public emptytext: string = '';
/** /**
* 数据值变化 * 数据值变化
...@@ -178,7 +178,6 @@ export default class CodeList extends Vue { ...@@ -178,7 +178,6 @@ export default class CodeList extends Vue {
* @memberof CodeList * @memberof CodeList
*/ */
private dataHandle(){ private dataHandle(){
this.isUseLangres = false;
let _this = this; let _this = this;
// 空值判断 // 空值判断
if(Object.is(this.$util.typeOf(this.value), 'undefined') || Object.is(this.$util.typeOf(this.value), 'null')){ if(Object.is(this.$util.typeOf(this.value), 'undefined') || Object.is(this.$util.typeOf(this.value), 'null')){
...@@ -201,8 +200,13 @@ export default class CodeList extends Vue { ...@@ -201,8 +200,13 @@ export default class CodeList extends Vue {
}); });
// 静态处理 // 静态处理
} else if(Object.is(this.codelistType, "STATIC")){ } else if(Object.is(this.codelistType, "STATIC")){
this.isUseLangres = true; const codelist = this.$store.getters.getCodeList(this.tag);
_this.setItems(this.$store.getters.getCodeListItems(this.tag), _this); if (codelist) {
this.emptytext = codelist.emptytextLanRes ? this.$t(codelist.emptytextLanRes, codelist.emptytext) : codelist.emptytext;
_this.setItems(codelist.items, _this);
}
console.log(codelist, 888);
} }
} }
...@@ -219,7 +223,6 @@ export default class CodeList extends Vue { ...@@ -219,7 +223,6 @@ export default class CodeList extends Vue {
if (items) { if (items) {
let result:any = []; let result:any = [];
if(Object.is(_this.renderMode,"NUM")){ if(Object.is(_this.renderMode,"NUM")){
_this.isUseLangres = false;
items.map((_item: any, index: number)=>{ items.map((_item: any, index: number)=>{
const nValue = parseInt((_this.value as any), 10); const nValue = parseInt((_this.value as any), 10);
const codevalue = _item.value; const codevalue = _item.value;
...@@ -262,9 +265,11 @@ export default class CodeList extends Vue { ...@@ -262,9 +265,11 @@ export default class CodeList extends Vue {
} }
result = { ...arr[0] }; result = { ...arr[0] };
if(Object.is(this.codelistType,'STATIC')){ if(Object.is(this.codelistType,'STATIC')){
let value = JSON.parse(JSON.stringify(result)); let item = JSON.parse(JSON.stringify(result));
value.text = 'codelist.'+this.tag+'.'+value.value; if (item.textLanRes) {
return value; value.text = this.$t(item.textLanRes, item.text);
}
return item;
}else{ }else{
return result; return result;
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
:filterable="filterable" :filterable="filterable"
@on-open-change="onClick" @on-open-change="onClick"
:placeholder="placeholder?placeholder:$t('components.dropDownListHidden.placeholder')"> :placeholder="placeholder?placeholder:$t('components.dropDownListHidden.placeholder')">
<i-option v-for="(item, index) in items" :key="index" :disabled="item.disabled" :class="item.class" :value="item.value">{{($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" :disabled="item.disabled" :class="item.class" :value="item.value">{{ item.textLanRes ? $t(item.textLanRes, item.text) : item.text }}</i-option>
</i-select> </i-select>
<ibiz-select-tree v-if="hasChildren" class="tree-dropdown-list" :disabled="disabled" :NodesData="items" v-model="currentVal" :multiple="false"></ibiz-select-tree> <ibiz-select-tree v-if="hasChildren" class="tree-dropdown-list" :disabled="disabled" :NodesData="items" v-model="currentVal" :multiple="false"></ibiz-select-tree>
</div> </div>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
:placeholder="placeholder?placeholder:$t('components.dropDownListMpicker.placeholder')"> :placeholder="placeholder?placeholder:$t('components.dropDownListMpicker.placeholder')">
<i-option v-for="(item, index) in items" :key="index" :class="item.class" :value="item.value ? item.value.toString():''" :label="item.text"> <i-option v-for="(item, index) in items" :key="index" :class="item.class" :value="item.value ? item.value.toString():''" :label="item.text">
<Checkbox :value="(currentVal.indexOf(item.value ? item.value.toString() : '')) == -1 ? false : true"> <Checkbox :value="(currentVal.indexOf(item.value ? item.value.toString() : '')) == -1 ? false : true">
{{Object.is(codelistType,'STATIC') ? $t('codelist.'+tag+'.'+item.value) : item.text}} {{ item.textLanRes ? $t(item.textLanRes, item.text) : item.text }}
</Checkbox> </Checkbox>
</i-option> </i-option>
</i-select> </i-select>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
:filterable="filterable" :filterable="filterable"
@on-open-change="onClick" @on-open-change="onClick"
:placeholder="placeholder?placeholder:$t('components.dropDownList.placeholder')"> :placeholder="placeholder?placeholder:$t('components.dropDownList.placeholder')">
<i-option v-for="(item, index) in items" :key="index" :disabled="item.disabled" :class="item.class" :value="item.value">{{($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" :disabled="item.disabled" :class="item.class" :value="item.value">{{ item.textLanRes ? $t(item.textLanRes, item.text) : item.text }}</i-option>
</i-select> </i-select>
<ibiz-select-tree v-if="hasChildren" class="tree-dropdown-list" :disabled="disabled" :NodesData="items" v-model="currentVal" :multiple="false"></ibiz-select-tree> <ibiz-select-tree v-if="hasChildren" class="tree-dropdown-list" :disabled="disabled" :NodesData="items" v-model="currentVal" :multiple="false"></ibiz-select-tree>
</div> </div>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册