ocpview-pro 0.1.28 → 0.1.30

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ocpview-pro",
3
- "version": "0.1.28",
3
+ "version": "0.1.30",
4
4
  "title": "ocpviewPlus",
5
5
  "description": "A high quality Service UI components Library with Vue.js",
6
6
  "homepage": "",
@@ -57,19 +57,35 @@ export default {
57
57
  },
58
58
  computed: {
59
59
  labeltext() {
60
- return this.label;
60
+ // ==============================================
61
+ // return this.label;
62
+ // ==============================================
63
+ return this.translateComboBoxText(this.label);
61
64
  },
62
65
  textLink() {
63
66
  return !!(this.config && this.config.textLink);
64
67
  },
65
68
  displayText() {
69
+ // ==============================================
70
+ // 备份 还原点
71
+ // if (this.resetText) {
72
+ // return this.resetText(
73
+ // this.doSpecialSymbols(this.label),
74
+ // this.label
75
+ // );
76
+ // }
77
+ // return this.doSpecialSymbols(this.label);
78
+ // ==============================================
79
+ let text = "";
66
80
  if (this.resetText) {
67
- return this.resetText(
81
+ text = this.resetText(
68
82
  this.doSpecialSymbols(this.label),
69
83
  this.label
70
84
  );
85
+ }else{
86
+ text = this.doSpecialSymbols(this.label);
71
87
  }
72
- return this.doSpecialSymbols(this.label);
88
+ return this.translateComboBoxText(text);
73
89
  },
74
90
  },
75
91
  mounted() {
@@ -93,6 +109,16 @@ export default {
93
109
  }
94
110
  },
95
111
  methods: {
112
+ translateComboBoxText(text) {
113
+ if (typeof text !== "string") {
114
+ return text;
115
+ }
116
+ const match = text.match(/^(\[[^\]]*\])([\s\S]*)$/);
117
+ if (match) {
118
+ return match[1] + this.$t(match[2]);
119
+ }
120
+ return this.$t(text);
121
+ },
96
122
  checkOverflow() {
97
123
  const content = this.$refs.content;
98
124
  this.hasOverflow = !!(
@@ -349,7 +349,7 @@ export default {
349
349
  row,
350
350
  item
351
351
  );
352
- return valueFormat;
352
+ return this.translateComboBoxText(valueFormat);
353
353
  },
354
354
  editRender: {
355
355
  enabled: false,
@@ -431,6 +431,16 @@ export default {
431
431
  },
432
432
  },
433
433
  methods: {
434
+ translateComboBoxText(text) {
435
+ if (typeof text !== "string") {
436
+ return text;
437
+ }
438
+ const match = text.match(/^(\[[^\]]*\])([\s\S]*)$/);
439
+ if (match) {
440
+ return match[1] + this.$t(match[2]);
441
+ }
442
+ return this.$t(text);
443
+ },
434
444
  // ==================================================================
435
445
 
436
446
  /**
@@ -306,7 +306,7 @@ export default {
306
306
  row,
307
307
  item
308
308
  );
309
- return valueFormat;
309
+ return this.translateComboBoxText(valueFormat);
310
310
  },
311
311
  ...(item._colorMap && {
312
312
  type: "html",
@@ -6,13 +6,21 @@
6
6
  <Icon custom='iconfont icon-custom-pack' color="#f3b352" v-show="showForm" size="14" />
7
7
  <Icon v-show="!showForm" color="#f3b352" custom='iconfont icon-custom-spread' size="14"/>
8
8
  <span style="margin-left:10px;font-size: 14px;font-weight:bold" v-text="myConfig.title ? $t(myConfig.title) : myConfig.title" />
9
+ <div v-if="myConfig.titleExtraStatus || myConfig.titleExtraRender" style="margin-left:auto">
10
+ <TitleExtra v-if="myConfig.titleExtraStatus" :render="titleExtraStatusRender" :params="getTitleExtraParams()" />
11
+ <TitleExtra v-if="myConfig.titleExtraRender" :render="myConfig.titleExtraRender" :params="getTitleExtraParams()" />
12
+ </div>
9
13
  </Row>
10
14
  </p>
11
15
  <Divider style="margin-left:24px;margin-top:0px;margin-bottom:10px;"/>
12
16
  </template>
13
17
  <template v-if="myConfig.modetype === '2'">
14
- <div style="margin-bottom:10px;">
18
+ <div :style="myConfig.titleExtraStatus || myConfig.titleExtraRender ? 'margin-bottom:10px;display:flex;align-items:center;' : 'margin-bottom:10px;'">
15
19
  <span class="efuture-title-verticalline" /> <span style="font-size: 14px;font-weight:bold" v-text="myConfig.title ? $t(myConfig.title) : myConfig.title" />
20
+ <div v-if="myConfig.titleExtraStatus || myConfig.titleExtraRender" style="margin-left:auto">
21
+ <TitleExtra v-if="myConfig.titleExtraStatus" :render="titleExtraStatusRender" :params="getTitleExtraParams()" />
22
+ <TitleExtra v-if="myConfig.titleExtraRender" :render="myConfig.titleExtraRender" :params="getTitleExtraParams()" />
23
+ </div>
16
24
  </div>
17
25
  </template>
18
26
  <Form ref="form" class="efuture-tip-form" v-show="showForm" :model="form" :rules="formRules" :label-position="myConfig.labelPosition" :label-width="myConfig.labelWidth" :inline="myConfig.inline" :id="myConfig.name" @submit.enter.prevent>
@@ -31,9 +39,9 @@
31
39
  <ControlBox :ref="item.name||item.sname" :valueData="form" :config="item" @inputValue="input" @doAction="doAction" ></ControlBox>
32
40
  <template #content>
33
41
  <ControlBox :ref="'effect_' + item.name||item.sname" style="width:100%" :valueData="effectForm" :config="effectConfig(item)" ></ControlBox>
34
- </template>
42
+ </template>
35
43
  </Poptip>
36
- </template>
44
+ </template>
37
45
  </FormItem>
38
46
  <ControlBox v-if="item.type === 'Divider'" :ref="item.dividerName" :style="getDividerStyle" :config="item"></ControlBox>
39
47
  </Col>
@@ -44,9 +52,15 @@
44
52
  </template>
45
53
 
46
54
  <script>
55
+ import { h } from 'vue';
47
56
  import Base from '@/components/form/formbox.vue';
57
+
58
+ // 标题右侧扩展的渲染包装:调用配置的 render 函数(函数式组件,无实例开销)
59
+ const TitleExtra = (props) => props.render(h, props.params);
60
+
48
61
  export default {
49
62
  name:'mformcard',
63
+ components: { TitleExtra },
50
64
  extends: Base,
51
65
  data () {
52
66
  return {
@@ -63,6 +77,39 @@ export default {
63
77
  };
64
78
  },
65
79
  methods:{
80
+ getTitleExtraParams() {
81
+ return {
82
+ form: this.form,
83
+ dictData: this.dictData,
84
+ config: this.myConfig
85
+ };
86
+ },
87
+ titleExtraStatusRender(h, params) {
88
+ let statusConfig = params.config.titleExtraStatus;
89
+ if (!statusConfig.codeField) {
90
+ return null;
91
+ }
92
+ let status = params.form[statusConfig.codeField];
93
+ if (status === undefined || status === null || status === '') {
94
+ return null;
95
+ }
96
+ let dicts = statusConfig.dicts;
97
+ if (!Array.isArray(dicts)) {
98
+ dicts = statusConfig.dictKey ? (params.dictData && params.dictData[statusConfig.dictKey]) : null;
99
+ }
100
+ let codeKey = statusConfig.codeKey || 'code';
101
+ let nameKey = statusConfig.nameKey || 'name';
102
+ let tmp = Array.isArray(dicts) ? dicts.find(el => el[codeKey] === status) : null;
103
+ if (!tmp || !tmp[nameKey]) {
104
+ // 字典未命中或无字典来源时,降级直接显示状态编码
105
+ return h('span', String(status));
106
+ }
107
+ if (statusConfig.showCode) {
108
+ // [编码]名称 形式;编码不参与转义,仅对名称做多语言转义,避免拼接后词条匹配失效
109
+ return h('span', '[' + tmp[codeKey] + ']' + this.$t(tmp[nameKey]));
110
+ }
111
+ return h('span', this.$t(tmp[nameKey]));
112
+ },
66
113
  customInit() {
67
114
  if (this.myConfig.showEffectValue !== undefined) {
68
115
  this.showEffectValue = this.myConfig.showEffectValue;
@@ -103,4 +150,4 @@ export default {
103
150
  }
104
151
  }
105
152
  };
106
- </script>
153
+ </script>