mirror of
https://github.com/vxcontrol/ncform.git
synced 2026-07-19 18:23:32 -04:00
Merge pull request #52 from ncform/develop
refactor: rename $t to $nclang, in order to avoid conflicts with vue-…
This commit is contained in:
+2
-2
@@ -71,8 +71,8 @@ npm i @ncform/ncform-common --save
|
||||
|
||||
<template>
|
||||
<div >
|
||||
<!-- use $t to get i18n data -->
|
||||
<label>{{$t('hi', {name: mergeConfig.name})}}</label>
|
||||
<!-- use $nclang to get i18n data -->
|
||||
<label>{{$nclang('hi', {name: mergeConfig.name})}}</label>
|
||||
|
||||
<!-- disabled / readonly / placeholder / hidden : use the computed version, not the config version. -->
|
||||
<!-- modelVal: for binding value. -->
|
||||
|
||||
@@ -119,7 +119,7 @@ export default {
|
||||
return modelVal;
|
||||
},
|
||||
|
||||
$t(key, data) {
|
||||
$nclang(key, data) {
|
||||
return Object.prototype.toString.call(data) !== "[object Object]" ? this.$data.i18n[key] : _template(this.$data.i18n[key])(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ export default {
|
||||
this.$data.collapsed = !this.$data.collapsed;
|
||||
},
|
||||
|
||||
$t(key, data) {
|
||||
$nclang(key, data) {
|
||||
return Object.prototype.toString.call(data) !== "[object Object]" ? this.$data.i18n[key] : _template(this.$data.i18n[key])(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
:indeterminate="isIndeterminate"
|
||||
v-model="isCheckAll"
|
||||
@change="handleCheckAllChange"
|
||||
>{{$t('all')}}</el-checkbox>
|
||||
>{{$nclang('all')}}</el-checkbox>
|
||||
|
||||
<el-checkbox-group
|
||||
v-if="!readonly"
|
||||
@@ -157,7 +157,7 @@
|
||||
const modelVal = vm.modelVal;
|
||||
|
||||
if (typeof modelVal === 'boolean') {
|
||||
res.push(modelVal ? this.$t('yes') : this.$t('no'));
|
||||
res.push(modelVal ? this.$nclang('yes') : this.$nclang('no'));
|
||||
} else {
|
||||
for (let m in modelVal) {
|
||||
for (let i in vm.$data.dataSource) {
|
||||
@@ -236,7 +236,7 @@
|
||||
if (enumSourceRemote && enumSourceRemote.remoteUrl) {
|
||||
vm.getRemoteSource();
|
||||
} else if (!vm.mergeConfig.enumSource.length) {
|
||||
vm.$data.dataSource = [ {label: this.$t('yes'), value: true}];
|
||||
vm.$data.dataSource = [ {label: this.$nclang('yes'), value: true}];
|
||||
} else {
|
||||
vm.$data.dataSource = vm.mergeConfig.enumSource;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<template>
|
||||
<el-date-picker class="ncform-date-picker"
|
||||
v-if="type && typeOptions[type]"
|
||||
:placeholder="placeholder || $t(typeOptions[type].placeholder)"
|
||||
:placeholder="placeholder || $nclang(typeOptions[type].placeholder)"
|
||||
:disabled="disabled"
|
||||
:readonly="readonly"
|
||||
:clearable="mergeConfig.clearable"
|
||||
v-show="!hidden"
|
||||
v-model="modelVal"
|
||||
:type="type"
|
||||
:format="mergeConfig.format || $t(typeOptions[type].format)"
|
||||
:format="mergeConfig.format || $nclang(typeOptions[type].format)"
|
||||
>
|
||||
</el-date-picker>
|
||||
</template>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
v-if="mergeConfig.compound.prependSelect"
|
||||
v-model="prependSelectVal"
|
||||
slot="prepend"
|
||||
:placeholder="$t('selectPls')"
|
||||
:placeholder="$nclang('selectPls')"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in prependSelectOptions"
|
||||
@@ -52,7 +52,7 @@
|
||||
v-if="mergeConfig.compound.appendSelect"
|
||||
v-model="appendSelectVal"
|
||||
slot="append"
|
||||
:placeholder="$t('selectPls')"
|
||||
:placeholder="$nclang('selectPls')"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in appendSelectOptions"
|
||||
@@ -71,7 +71,7 @@
|
||||
class="ncform-input-upload"
|
||||
@click="handleClickUpload"
|
||||
>
|
||||
{{isUploading ? $t('uploading') : mergeConfig.upload.uploadText || $t('upload')}}
|
||||
{{isUploading ? $nclang('uploading') : mergeConfig.upload.uploadText || $nclang('upload')}}
|
||||
<input
|
||||
type="file"
|
||||
ref="upload"
|
||||
@@ -130,7 +130,7 @@
|
||||
v-if="mergeConfig.compound.prependSelect"
|
||||
v-model="prependSelectVal"
|
||||
slot="prepend"
|
||||
:placeholder="$t('selectPls')"
|
||||
:placeholder="$nclang('selectPls')"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in prependSelectOptions"
|
||||
@@ -144,7 +144,7 @@
|
||||
v-if="mergeConfig.compound.appendSelect"
|
||||
v-model="appendSelectVal"
|
||||
slot="append"
|
||||
:placeholder="$t('selectPls')"
|
||||
:placeholder="$nclang('selectPls')"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in appendSelectOptions"
|
||||
@@ -452,7 +452,7 @@ export default {
|
||||
fileSize > vm.mergeConfig.upload.constraint.maxSize
|
||||
) {
|
||||
vm.$message({
|
||||
message: vm.$t("sizeTips1", {
|
||||
message: vm.$nclang("sizeTips1", {
|
||||
right: vm.mergeConfig.upload.constraint.maxSize,
|
||||
wrong: fileSize.toFixed(0)
|
||||
}),
|
||||
@@ -465,7 +465,7 @@ export default {
|
||||
fileSize < vm.mergeConfig.upload.constraint.minSize
|
||||
) {
|
||||
vm.$message({
|
||||
message: vm.$t("sizeTips2", {
|
||||
message: vm.$nclang("sizeTips2", {
|
||||
right: vm.mergeConfig.upload.constraint.minSize,
|
||||
wrong: fileSize.toFixed(0)
|
||||
}),
|
||||
@@ -501,7 +501,7 @@ export default {
|
||||
if (!pass) {
|
||||
if (vm.mergeConfig.upload.constraint.sizeFixed) {
|
||||
vm.$message({
|
||||
message: vm.$t("resolutionTip1", {
|
||||
message: vm.$nclang("resolutionTip1", {
|
||||
right: `${vm.mergeConfig.upload.constraint.width}x${
|
||||
vm.mergeConfig.upload.constraint.height
|
||||
}`,
|
||||
@@ -511,7 +511,7 @@ export default {
|
||||
});
|
||||
} else {
|
||||
vm.$message({
|
||||
message: vm.$t("resolutionTip2", {
|
||||
message: vm.$nclang("resolutionTip2", {
|
||||
right: vm._getFractionalExpression(
|
||||
vm.mergeConfig.upload.constraint.width /
|
||||
vm.mergeConfig.upload.constraint.height,
|
||||
@@ -552,7 +552,7 @@ export default {
|
||||
this.$data.isUploading = false;
|
||||
})
|
||||
.catch(() => {
|
||||
vm.$message.error(this.$t("uploadFail"));
|
||||
vm.$message.error(this.$nclang("uploadFail"));
|
||||
this.$data.isUploading = false;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -174,7 +174,7 @@
|
||||
if (enumSourceRemote && enumSourceRemote.remoteUrl) {
|
||||
vm.getRemoteSource();
|
||||
} else if (!vm.mergeConfig.enumSource.length) {
|
||||
vm.$data.dataSource = [ {value: true, label: this.$t('yes')}, {value: false, label: this.$t('no')} ];
|
||||
vm.$data.dataSource = [ {value: true, label: this.$nclang('yes')}, {value: false, label: this.$nclang('no')} ];
|
||||
} else {
|
||||
vm.$data.dataSource = vm.mergeConfig.enumSource
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<el-select
|
||||
v-model="modelVal"
|
||||
:placeholder="placeholder || $t('selectPls')"
|
||||
:placeholder="placeholder || $nclang('selectPls')"
|
||||
v-show="!hidden"
|
||||
:disabled="disabled || readonly"
|
||||
:clearable="mergeConfig.clearable"
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<!-- 1. 可拖拽 -->
|
||||
<template v-if="!readonly && mergeConfig.drag" slot="trigger">
|
||||
<i class="el-icon-upload"></i>
|
||||
<div class="el-upload__text" v-html="$t('uploadTips')"></div>
|
||||
<div class="el-upload__text" v-html="$nclang('uploadTips')"></div>
|
||||
</template>
|
||||
<div v-if="mergeConfig.drag && disabled" class="disabled-mask"></div>
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
size="small"
|
||||
type="success"
|
||||
@click="submitUpload"
|
||||
>{{$t('uploadServer')}}</el-button>
|
||||
>{{$nclang('uploadServer')}}</el-button>
|
||||
|
||||
<!-- 3. 不可拖拽,自动上传-->
|
||||
<el-button
|
||||
@@ -44,7 +44,7 @@
|
||||
:disabled="disabled"
|
||||
size="small"
|
||||
type="primary"
|
||||
>{{$t('upload')}}</el-button>
|
||||
>{{$nclang('upload')}}</el-button>
|
||||
|
||||
<!-- 4. 不可拖拽,非自动上传 -->
|
||||
<template v-if="!readonly && !mergeConfig.drag && !mergeConfig.autoUpload">
|
||||
@@ -53,14 +53,14 @@
|
||||
slot="trigger"
|
||||
size="small"
|
||||
type="primary"
|
||||
>{{$t('chFile')}}</el-button>
|
||||
>{{$nclang('chFile')}}</el-button>
|
||||
<el-button
|
||||
:disabled="disabled"
|
||||
class="upload-btn"
|
||||
size="small"
|
||||
type="success"
|
||||
@click="submitUpload"
|
||||
>{{$t('uploadServer')}}</el-button>
|
||||
>{{$nclang('uploadServer')}}</el-button>
|
||||
</template>
|
||||
|
||||
</el-upload>
|
||||
@@ -228,7 +228,7 @@
|
||||
&& !vm.mergeConfig.showFileList
|
||||
&& fileList.length) {
|
||||
vm.$message({
|
||||
message: this.$t('successChTips', {fileCount: fileList.length}),
|
||||
message: this.$nclang('successChTips', {fileCount: fileList.length}),
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
@@ -265,12 +265,12 @@
|
||||
let content;
|
||||
if (total === vm.uploadInfo.num[state]) {
|
||||
vm.$message({
|
||||
message: state === 'success' ? vm.$t('uploadSuccess') : vm.$t('uploadFail'),
|
||||
message: state === 'success' ? vm.$nclang('uploadSuccess') : vm.$nclang('uploadFail'),
|
||||
type: state
|
||||
});
|
||||
} else {
|
||||
vm.$message({
|
||||
message: vm.$t('uploadSomeFail'),
|
||||
message: vm.$nclang('uploadSomeFail'),
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
@@ -284,7 +284,7 @@
|
||||
handleUploadExceed(files, fileList) {
|
||||
const vm = this;
|
||||
vm.$message({
|
||||
message: vm.$t('limitTips', {limit: vm.mergeConfig.limit}),
|
||||
message: vm.$nclang('limitTips', {limit: vm.mergeConfig.limit}),
|
||||
type: 'warning'
|
||||
});
|
||||
},
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
</small>
|
||||
</th>
|
||||
|
||||
<th v-if="!mergeConfig.disableDel || !mergeConfig.disableReorder">{{$t('action')}}</th>
|
||||
<th v-if="!mergeConfig.disableDel || !mergeConfig.disableReorder">{{$nclang('action')}}</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(dataItem, idx) in schema.value" :key="dataItem.__dataSchema.__id">
|
||||
@@ -49,8 +49,8 @@
|
||||
<td :colspan="renderSchemas.length + 1">
|
||||
<!-- 列表控制按钮 -->
|
||||
<div class="el-button-group" v-if="!mergeConfig.disableAdd || !mergeConfig.disableDel">
|
||||
<button @click="addItem()" v-if="!mergeConfig.disableAdd" type="button" class="el-button el-button--mini"><i class="el-icon-circle-plus-outline"></i> {{mergeConfig.addTxt || $t('add')}}</button>
|
||||
<button @click="delAllItems()" v-if="!mergeConfig.disableDel" type="button" class="el-button el-button--danger el-button--mini"><i class="el-icon-remove"></i> {{mergeConfig.delAllTxt || $t('delAll')}}</button>
|
||||
<button @click="addItem()" v-if="!mergeConfig.disableAdd" type="button" class="el-button el-button--mini"><i class="el-icon-circle-plus-outline"></i> {{mergeConfig.addTxt || $nclang('add')}}</button>
|
||||
<button @click="delAllItems()" v-if="!mergeConfig.disableDel" type="button" class="el-button el-button--danger el-button--mini"><i class="el-icon-remove"></i> {{mergeConfig.delAllTxt || $nclang('delAll')}}</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -44,8 +44,8 @@
|
||||
|
||||
<!-- 列表控制按钮 -->
|
||||
<div v-show="!collapsed" class="el-button-group" v-if="!mergeConfig.disableAdd || !mergeConfig.disableDel">
|
||||
<button @click="addItem()" v-if="!mergeConfig.disableAdd" type="button" class="el-button el-button--mini"><i class="el-icon-circle-plus-outline"></i> {{mergeConfig.addTxt || $t('add')}}</button>
|
||||
<button @click="delAllItems()" v-if="!mergeConfig.disableDel" type="button" class="el-button el-button--danger el-button--mini"><i class="el-icon-remove"></i> {{mergeConfig.delAllTxt || $t('delAll')}}</button>
|
||||
<button @click="addItem()" v-if="!mergeConfig.disableAdd" type="button" class="el-button el-button--mini"><i class="el-icon-circle-plus-outline"></i> {{mergeConfig.addTxt || $nclang('add')}}</button>
|
||||
<button @click="delAllItems()" v-if="!mergeConfig.disableDel" type="button" class="el-button el-button--danger el-button--mini"><i class="el-icon-remove"></i> {{mergeConfig.delAllTxt || $nclang('delAll')}}</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
let extComponents = {
|
||||
helloWorld: {
|
||||
mixins: [ncformCommon.mixins.vue.controlMixin],
|
||||
template: '<div>{{$t("hi", {msg: modelVal})}} {{modelVal}}</div>',
|
||||
template: '<div>{{$nclang("hi", {msg: modelVal})}} {{modelVal}}</div>',
|
||||
i18nData: {
|
||||
en: {
|
||||
hi: 'hello world: <%= msg %>'
|
||||
@@ -63,7 +63,7 @@
|
||||
},
|
||||
helloDaniel: {
|
||||
mixins: [ncformCommon.mixins.vue.controlMixin],
|
||||
template: '<div>{{$t("hi", {msg: modelVal})}} {{modelVal}}</div>',
|
||||
template: '<div>{{$nclang("hi", {msg: modelVal})}} {{modelVal}}</div>',
|
||||
i18nData: {
|
||||
en: {
|
||||
hi: 'Hi daniel: <%= msg %>'
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</small>
|
||||
</th>
|
||||
|
||||
<th v-if="!mergeConfig.disableDel || !mergeConfig.disableReorder">{{$t('action')}}</th>
|
||||
<th v-if="!mergeConfig.disableDel || !mergeConfig.disableReorder">{{$nclang('action')}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -44,8 +44,8 @@
|
||||
<td :colspan="renderSchemas.length + 1">
|
||||
<!-- 列表控制按钮 -->
|
||||
<div class="btn-group btn-group-sm" v-if="!mergeConfig.disableAdd || !mergeConfig.disableDel">
|
||||
<button @click="addItem()" v-if="!mergeConfig.disableAdd" type="button" class="btn btn-secondary">{{mergeConfig.addTxt || $t('add')}}</button>
|
||||
<button @click="delAllItems()" v-if="!mergeConfig.disableDel" type="button" class="btn btn-danger btn-secondary">{{mergeConfig.delAllTxt || $t('delAll')}}</button>
|
||||
<button @click="addItem()" v-if="!mergeConfig.disableAdd" type="button" class="btn btn-secondary">{{mergeConfig.addTxt || $nclang('add')}}</button>
|
||||
<button @click="delAllItems()" v-if="!mergeConfig.disableDel" type="button" class="btn btn-danger btn-secondary">{{mergeConfig.delAllTxt || $nclang('delAll')}}</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
|
||||
<!-- 列表控制按钮 -->
|
||||
<div v-show="!collapsed" class="btn-group btn-group-sm" v-if="!mergeConfig.disableAdd || !mergeConfig.disableDel">
|
||||
<button @click="addItem()" v-if="!mergeConfig.disableAdd" type="button" class="btn btn-secondary">{{mergeConfig.addTxt || $t('add')}}</button>
|
||||
<button @click="delAllItems()" v-if="!mergeConfig.disableDel" type="button" class="btn btn-danger btn-secondary">{{mergeConfig.delAllTxt || $t('delAll')}}</button>
|
||||
<button @click="addItem()" v-if="!mergeConfig.disableAdd" type="button" class="btn btn-secondary">{{mergeConfig.addTxt || $nclang('add')}}</button>
|
||||
<button @click="delAllItems()" v-if="!mergeConfig.disableDel" type="button" class="btn btn-danger btn-secondary">{{mergeConfig.delAllTxt || $nclang('delAll')}}</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user