cloud-web-corejs 1.1.0-dev.83 → 1.1.0-dev.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,9 +22,7 @@
22
22
  :clearable="field.options.clearable"
23
23
  :filterable="field.options.filterable"
24
24
  :collapse-tags="!field.options.flatCollapseTags"
25
- :placeholder="
26
- field.options.placeholder || i18nt('render.hint.selectPlaceholder')
27
- "
25
+ :placeholder="getI18nLabel(field.options.placeholder || $t1('请选择'))"
28
26
  :show-all-levels="showFullPath"
29
27
  :props="cascaderProps"
30
28
  @visible-change="hideDropDownOnClick"
@@ -99,7 +97,7 @@ export default {
99
97
  cascaderOptions() {
100
98
  return this.lazyEnabled
101
99
  ? this.lazyEmptyOptions
102
- : this.field.options.optionItems;
100
+ : this.translateOptionNodes(this.field.options.optionItems);
103
101
  },
104
102
 
105
103
  cascaderProps() {
@@ -287,7 +285,7 @@ export default {
287
285
  settled = true;
288
286
  const nodes = this.normalizeLazyNodes(list);
289
287
  this.rememberLazyNodes(node, nodes);
290
- resolve(nodes);
288
+ resolve(this.translateOptionNodes(nodes));
291
289
  };
292
290
  const abortLazyLoad = () => {
293
291
  if (settled) return;
@@ -318,7 +316,7 @@ export default {
318
316
  settled = true;
319
317
  const nodes = this.normalizeLazyNodes(list);
320
318
  this.rememberLazyNodes(node, nodes);
321
- resolve(nodes);
319
+ resolve(this.translateOptionNodes(nodes));
322
320
  };
323
321
  // 请求失败不能 resolve([]):Element 会把 node.loaded 置 true,之后不再 lazyLoad
324
322
  const abortLazyLoad = () => {
@@ -349,6 +347,48 @@ export default {
349
347
  error: abortLazyLoad,
350
348
  });
351
349
  },
350
+ // 展示用副本。原文留在不可枚举的 __rawLabel,脚本仍拿原文
351
+ translateOptionNodes(list) {
352
+ if (!Array.isArray(list) || this.designState) return list;
353
+ const labelKey = this.labelKey;
354
+ const childrenKey = this.childrenKey;
355
+ return list.map((item) => {
356
+ if (!item || typeof item !== "object") return item;
357
+ const next = { ...item };
358
+ const rawLabel = item[labelKey];
359
+ Object.defineProperty(next, "__rawLabel", {
360
+ value: rawLabel,
361
+ enumerable: false,
362
+ });
363
+ if (rawLabel != null && rawLabel !== "") {
364
+ next[labelKey] = this.getI18nLabel(rawLabel);
365
+ }
366
+ if (Array.isArray(item[childrenKey])) {
367
+ next[childrenKey] = this.translateOptionNodes(item[childrenKey]);
368
+ }
369
+ return next;
370
+ });
371
+ },
372
+ rawNodeLabel(node) {
373
+ const data = node && node.data;
374
+ if (data && Object.prototype.hasOwnProperty.call(data, "__rawLabel")) {
375
+ return data.__rawLabel;
376
+ }
377
+ return node && node.label != null ? node.label : "";
378
+ },
379
+ rawOptionData(data) {
380
+ if (!data || typeof data !== "object") return data || null;
381
+ if (!Object.prototype.hasOwnProperty.call(data, "__rawLabel")) return data;
382
+ const next = { ...data };
383
+ next[this.labelKey] = data.__rawLabel;
384
+ const childrenKey = this.childrenKey;
385
+ if (Array.isArray(data[childrenKey])) {
386
+ next[childrenKey] = data[childrenKey].map((child) =>
387
+ this.rawOptionData(child)
388
+ );
389
+ }
390
+ return next;
391
+ },
352
392
  // 展开节点时的路径上下文(与 onSelect 的 item 字段含义一致)
353
393
  buildCascaderNodePathContext(node) {
354
394
  if (!node || node.root || node.level === 0) {
@@ -366,15 +406,15 @@ export default {
366
406
  const levels = pathNodes.map((seg, index) => ({
367
407
  level: index,
368
408
  value: seg.value,
369
- label: seg.label,
370
- data: seg.data || null,
409
+ label: this.rawNodeLabel(seg),
410
+ data: this.rawOptionData(seg.data),
371
411
  }));
372
412
  return {
373
- row: node.data || null,
413
+ row: this.rawOptionData(node.data),
374
414
  level: path.length ? path.length - 1 : 0,
375
415
  path: path,
376
- pathLabels: node.pathLabels ? node.pathLabels.slice() : [],
377
- pathRows: pathNodes.map((seg) => seg.data || null),
416
+ pathLabels: pathNodes.map((seg) => this.rawNodeLabel(seg)),
417
+ pathRows: pathNodes.map((seg) => this.rawOptionData(seg.data)),
378
418
  levels: levels,
379
419
  };
380
420
  },
@@ -579,7 +619,7 @@ export default {
579
619
  const ctx = this.buildCascaderNodePathContext(node);
580
620
  return {
581
621
  value: node.value,
582
- label: node.label,
622
+ label: this.rawNodeLabel(node),
583
623
  level: ctx.level == null ? 0 : ctx.level,
584
624
  path: ctx.path,
585
625
  pathLabels: ctx.pathLabels,
@@ -12,14 +12,14 @@
12
12
  :limit="field.options.limit" :on-exceed="handleFileExceed" :before-upload="beforeFileUpload"
13
13
  :on-success="handleFileUpload" :on-error="handleUploadError">
14
14
  <div slot="tip" class="el-upload__tip"
15
- v-if="!!field.options.uploadTip">{{field.options.uploadTip}}</div>
15
+ v-if="!!field.options.uploadTip">{{getI18nLabel(field.options.uploadTip)}}</div>
16
16
  <i slot="default" class="el-icon-plus avatar-uploader-icon"></i>
17
17
  <template #file="{ file }">
18
18
  <div class="upload-file-list">
19
19
  <span class="upload-file-name" :title="file.name">{{file.name}}</span>
20
20
  <a :href="file.url" download="" target="_blank">
21
- <i class="el-icon-download file-action" :title="i18nt('render.hint.downloadFile')"></i></a>
22
- <i class="el-icon-delete file-action" :title="i18nt('render.hint.removeFile')" v-if="!field.options.disabled"
21
+ <i class="el-icon-download file-action" :title="$t1('下载')"></i></a>
22
+ <i class="el-icon-delete file-action" :title="$t1('移除')" v-if="!field.options.disabled"
23
23
  @click="removeUploadFile(file.name, file.url, file.uid)"></i>
24
24
  </div>
25
25
  </template>
@@ -30,16 +30,13 @@
30
30
  <script>
31
31
  import FormItemWrapper from './form-item-wrapper'
32
32
  import emitter from '../../../../../components/xform/utils/emitter'
33
- import i18n, {translate} from "../../../../../components/xform/utils/i18n";
34
33
  import {deepClone} from "../../../../../components/xform/utils/util";
35
34
  import fieldMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/fieldMixin";
36
35
 
37
- let selectFileText = "'" + translate('render.hint.selectFile') + "'"
38
-
39
36
  export default {
40
37
  name: "file-upload-widget",
41
38
  componentName: 'FieldWidget', //必须固定为FieldWidget,用于接收父级组件的broadcast事件
42
- mixins: [emitter, fieldMixin, i18n],
39
+ mixins: [emitter, fieldMixin],
43
40
  props: {
44
41
  field: Object,
45
42
  parentWidget: Object,
@@ -86,14 +83,14 @@
86
83
  },
87
84
  fileList: [], //上传文件列表
88
85
  uploadBtnHidden: false,
89
-
90
- styleVariables: {
91
- '--select-file-action': selectFileText,
92
- },
93
86
  }
94
87
  },
95
88
  computed: {
96
-
89
+ styleVariables() {
90
+ return {
91
+ '--select-file-action': "' " + this.$t1('选择文件') + "'",
92
+ };
93
+ },
97
94
  },
98
95
  beforeCreate() {
99
96
  /* 这里不能访问方法和属性!! */
@@ -121,7 +118,7 @@
121
118
  methods: {
122
119
  handleFileExceed() {
123
120
  let uploadLimit = this.field.options.limit
124
- this.$message.warning( this.i18nt('render.hint.uploadExceed').replace('${uploadLimit}', uploadLimit) )
121
+ this.$message.warning(this.$t1('最大上传数量({p0})已超出.', { p0: uploadLimit }))
125
122
  },
126
123
 
127
124
  beforeFileUpload(file) {
@@ -136,7 +133,7 @@
136
133
  }
137
134
  }
138
135
  if (!fileTypeCheckResult) {
139
- this.$message.error(this.i18nt('render.hint.unsupportedFileType') + extFileName)
136
+ this.$message.error(this.$t1('不支持格式: {p0}', { p0: extFileName }))
140
137
  return false;
141
138
  }
142
139
 
@@ -147,7 +144,7 @@
147
144
  }
148
145
  fileSizeCheckResult = file.size / 1024 / 1024 <= uploadFileMaxSize
149
146
  if (!fileSizeCheckResult) {
150
- this.$message.error(this.i18nt('render.hint.fileSizeExceed') + uploadFileMaxSize + 'MB')
147
+ this.$message.error(this.$t1('文件大小已超出: {p0}MB', { p0: uploadFileMaxSize }))
151
148
  return false;
152
149
  }
153
150
 
@@ -250,7 +247,7 @@
250
247
  customFn.call(this, err, file, fileList)
251
248
  } else {
252
249
  this.$message({
253
- message: this.i18nt('render.hint.uploadError') + err,
250
+ message: this.$t1('上传错误: {p0}', { p0: err }),
254
251
  duration: 3000,
255
252
  type: 'error',
256
253
  })
@@ -108,7 +108,7 @@
108
108
  <template v-if="field.options.labelIconPosition === 'front'">
109
109
  <template v-if="!!field.options.labelTooltip">
110
110
  <el-tooltip
111
- :content="field.options.labelTooltip"
111
+ :content="getI18nLabel(field.options.labelTooltip)"
112
112
  effect="dark"
113
113
  popper-class="label-tooltip-pre-line"
114
114
  >
@@ -130,7 +130,7 @@
130
130
  label
131
131
  }}</span
132
132
  ><el-tooltip
133
- :content="field.options.labelTooltip"
133
+ :content="getI18nLabel(field.options.labelTooltip)"
134
134
  effect="dark"
135
135
  popper-class="label-tooltip-pre-line"
136
136
  >
@@ -127,7 +127,7 @@
127
127
  methods: {
128
128
  handlePictureExceed() {
129
129
  let uploadLimit = this.field.options.limit
130
- this.$message.warning( this.i18nt('render.hint.uploadExceed').replace('${uploadLimit}', uploadLimit) )
130
+ this.$message.warning(this.$t1('最大上传数量({p0})已超出.', { p0: uploadLimit }))
131
131
  },
132
132
 
133
133
  handlePicturePreview(file) {
@@ -146,7 +146,7 @@
146
146
  }
147
147
  }
148
148
  if (!fileTypeCheckResult) {
149
- this.$message.error(this.i18nt('render.hint.unsupportedFileType') + file.type)
149
+ this.$message.error(this.$t1('不支持格式: {p0}', { p0: file.type }))
150
150
  return false;
151
151
  }
152
152
 
@@ -157,7 +157,7 @@
157
157
  }
158
158
  fileSizeCheckResult = file.size / 1024 / 1024 <= uploadFileMaxSize
159
159
  if (!fileSizeCheckResult) {
160
- this.$message.error(this.i18nt('render.hint.fileSizeExceed') + uploadFileMaxSize + 'MB')
160
+ this.$message.error(this.$t1('文件大小已超出: {p0}MB', { p0: uploadFileMaxSize }))
161
161
  return false;
162
162
  }
163
163
 
@@ -246,7 +246,7 @@
246
246
  customFn.call(this, err, file, fileList)
247
247
  } else {
248
248
  this.$message({
249
- message: this.i18nt('render.hint.uploadError') + err,
249
+ message: this.$t1('上传错误: {p0}', { p0: err }),
250
250
  duration: 3000,
251
251
  type: 'error',
252
252
  })
@@ -3,7 +3,7 @@
3
3
  :parent-widget="parentWidget" :parent-list="parentList" :index-of-parent-list="indexOfParentList"
4
4
  :sub-form-row-index="subFormRowIndex" :sub-form-col-index="subFormColIndex" :sub-form-row-id="subFormRowId">
5
5
  <div ref="fieldEditor" :style="!!field.options.fontSize ? `font-size: ${field.options.fontSize};`: ''" :class="widgetClass">
6
- <pre :style="{'white-space': !!field.options.preWrap ? 'pre-wrap' : 'pre', 'text-align': !!field.options.textAlign ? field.options.textAlign : 'left'}">{{field.options.textContent}}</pre></div>
6
+ <pre :style="{'white-space': !!field.options.preWrap ? 'pre-wrap' : 'pre', 'text-align': !!field.options.textAlign ? field.options.textAlign : 'left'}">{{getI18nLabel(field.options.textContent)}}</pre></div>
7
7
  </static-content-wrapper>
8
8
  </template>
9
9
 
@@ -4,7 +4,7 @@
4
4
  :sub-form-row-index="subFormRowIndex" :sub-form-col-index="subFormColIndex" :sub-form-row-id="subFormRowId">
5
5
  <el-switch ref="fieldEditor" v-model="fieldModel"
6
6
  :disabled="field.options.disabled"
7
- :active-text="field.options.activeText" :inactive-text="field.options.inactiveText"
7
+ :active-text="getI18nLabel(field.options.activeText)" :inactive-text="getI18nLabel(field.options.inactiveText)"
8
8
  :active-color="field.options.activeColor" :inactive-color="field.options.inactiveColor"
9
9
  :width="field.options.switchWidth"
10
10
  @change="handleChangeEvent">
@@ -92,8 +92,8 @@
92
92
  return rawValue;
93
93
  }
94
94
  return rawValue
95
- ? this.field.options.activeText
96
- : this.field.options.inactiveText;
95
+ ? this.getI18nLabel(this.field.options.activeText)
96
+ : this.getI18nLabel(this.field.options.inactiveText);
97
97
  },
98
98
  }
99
99
  }
@@ -7,8 +7,8 @@
7
7
  :size="field.options.size"
8
8
  :clearable="field.options.clearable" :editable="field.options.editable"
9
9
  :format="field.options.format" value-format="HH:mm:ss"
10
- :start-placeholder="field.options.startPlaceholder || i18nt('render.hint.startTimePlaceholder')"
11
- :end-placeholder="field.options.endPlaceholder || i18nt('render.hint.endTimePlaceholder')"
10
+ :start-placeholder="getI18nLabel(field.options.startPlaceholder || $t1('起始时间'))"
11
+ :end-placeholder="getI18nLabel(field.options.endPlaceholder || $t1('截止时间'))"
12
12
  @focus="handleFocusCustomEvent" @blur="handleBlurCustomEvent"
13
13
  @change="handleChangeEvent">
14
14
  </el-time-picker>
@@ -2,7 +2,7 @@
2
2
  <static-content-wrapper :designer="designer" :field="field" :design-state="designState"
3
3
  :parent-widget="parentWidget" :parent-list="parentList" :index-of-parent-list="indexOfParentList"
4
4
  :sub-form-row-index="subFormRowIndex" :sub-form-col-index="subFormColIndex" :sub-form-row-id="subFormRowId">
5
- <div class="title" :class="field.options.styleTitClass"><b v-html="field.options.htmlContent"></b></div>
5
+ <div class="title" :class="field.options.styleTitClass"><b v-html="getI18nLabel(field.options.htmlContent)"></b></div>
6
6
  </static-content-wrapper>
7
7
  </template>
8
8