ocpview-pro 0.1.29 → 0.1.31

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.29",
3
+ "version": "0.1.31",
4
4
  "title": "ocpviewPlus",
5
5
  "description": "A high quality Service UI components Library with Vue.js",
6
6
  "homepage": "",
@@ -10,17 +10,15 @@
10
10
  </div>
11
11
  <Card :padding="0" :bordered="false" style="padding-top:0px;padding-left:16px;padding-right:16px;padding-bottom:14px;" dis-hover>
12
12
  <div :id="headid" :style="style2" @scroll="handleScroll">
13
- <div v-for="(item,index) in myConfig.formsConfig.items" :id="item.divId" :key="item.divId" v-show="headVisible[index].visible">
14
- <Formcard :ref="item.name" :config="item" :dictData="dictData" @doAction="doAction" >
13
+ <div v-for="temp in renderItems" :key="temp.el.divId" :id="temp.el.divId" v-show="temp.isHead ? headVisible[temp.index].visible : detailVisible[temp.index].visible" >
14
+ <Formcard v-if="temp.isHead" :ref="temp.el.name" :config="temp.el" :dictData="dictData" @doAction="doAction" >
15
15
  </Formcard>
16
- </div>
17
- <div v-for="(temp2,index) in detailConfig.items" :key="temp2.divId" :id="temp2.divId" v-show="detailVisible[index].visible" >
18
- <EditGridCardS v-if="temp2.type === 'EditGridCard'" :ref="temp2.name" :config="temp2" :dictData="dictData" @doAction="doAction"/>
19
- <DetailsBoxs v-if="temp2.type === 'DetailsBox'" :ref="temp2.name" :config="temp2" :dictData="dictData" @doAction="doAction"/>
20
- <FormCardBox v-if="temp2.type === 'FormCardBox'" :ref="temp2.name" :config="temp2" :dictData="dictData"/>
21
- <AppendixBoxs v-if="temp2.type === 'AppendixBox'" :ref="temp2.name" :config="temp2" :modulecode="modulecode" @doAction="doAction"/>
22
- <FormCardBox2 v-if="temp2.type === 'FormCardBox2'" :ref="temp2.name" :config="temp2" :dictData="dictData"/>
23
- <AppendixBoxs2 v-if="temp2.type === 'AppendixBox2'" :ref="temp2.name" :config="temp2" :dictData="dictData" :modulecode="modulecode" @handleSuccessAfter="handleSuccessAfter" @doAction="doAction"/>
16
+ <EditGridCardS v-if="!temp.isHead && temp.el.type === 'EditGridCard'" :ref="temp.el.name" :config="temp.el" :dictData="dictData" @doAction="doAction"/>
17
+ <DetailsBoxs v-if="!temp.isHead && temp.el.type === 'DetailsBox'" :ref="temp.el.name" :config="temp.el" :dictData="dictData" @doAction="doAction"/>
18
+ <FormCardBox v-if="!temp.isHead && temp.el.type === 'FormCardBox'" :ref="temp.el.name" :config="temp.el" :dictData="dictData"/>
19
+ <AppendixBoxs v-if="!temp.isHead && temp.el.type === 'AppendixBox'" :ref="temp.el.name" :config="temp.el" :modulecode="modulecode" @doAction="doAction"/>
20
+ <FormCardBox2 v-if="!temp.isHead && temp.el.type === 'FormCardBox2'" :ref="temp.el.name" :config="temp.el" :dictData="dictData"/>
21
+ <AppendixBoxs2 v-if="!temp.isHead && temp.el.type === 'AppendixBox2'" :ref="temp.el.name" :config="temp.el" :dictData="dictData" :modulecode="modulecode" @handleSuccessAfter="handleSuccessAfter" @doAction="doAction"/>
24
22
  </div>
25
23
  </div>
26
24
  </Card>
@@ -123,7 +121,7 @@ export default {
123
121
  el.modetype = modetype;
124
122
  el.divId = 'headForm_' + this.getRandom() + '_' + index;
125
123
  this.headVisible.push({refname:el.name,visible:true});
126
- this.anchorData.push({id:'#'+el.divId ,name:el.title ? this.$t(el.title) : el.title,visible:true,refname:el.name,isHead:true});
124
+ this.anchorData.push({id:'#'+el.divId ,name:el.title ? this.$t(el.title) : el.title,visible:true,refname:el.name,isHead:true,sort:el.sort === undefined ? 0 : el.sort});
127
125
  });
128
126
  }
129
127
 
@@ -164,7 +162,7 @@ export default {
164
162
  }
165
163
  el.divId = 'detail_'+ this.getRandom() + '_'+ index;
166
164
  this.detailVisible.push({refname:el.name,visible:true});
167
- this.anchorData.push({id:'#'+ el.divId, name:el.title ? this.$t(el.title) : el.title,refname:el.name,visible:true,isHead:false});
165
+ this.anchorData.push({id:'#'+ el.divId, name:el.title ? this.$t(el.title) : el.title,refname:el.name,visible:true,isHead:false,sort:el.sort === undefined ? Number.MAX_SAFE_INTEGER : el.sort});
168
166
  });
169
167
  }
170
168
  }
@@ -185,7 +183,7 @@ export default {
185
183
  tmp.divId = 'detail_'+ this.getRandom() + '_'+ this.detailConfig.items.length;
186
184
  this.detailConfig.items.push(tmp);
187
185
  this.detailVisible.push({refname:tmp.name,visible:true});
188
- this.anchorData.push({id:'#'+ tmp.divId, name:tmp.title ? this.$t(tmp.title) : tmp.title,refname:tmp.name,visible:true});
186
+ this.anchorData.push({id:'#'+ tmp.divId, name:tmp.title ? this.$t(tmp.title) : tmp.title,refname:tmp.name,visible:true,sort:Number.MAX_SAFE_INTEGER});
189
187
  } else if (this.billAppendixConfig.showAppendix2) {
190
188
  let tmp = Object.assign({}, {}, this.billAppendixConfig);
191
189
  tmp.type = 'AppendixBox2';
@@ -195,14 +193,34 @@ export default {
195
193
  tmp.divId = 'detail_'+ this.getRandom() + '_'+ this.detailConfig.items.length;
196
194
  this.detailConfig.items.push(tmp);
197
195
  this.detailVisible.push({refname:tmp.name,visible:true});
198
- this.anchorData.push({id:'#'+ tmp.divId, name:tmp.title ? this.$t(tmp.title) : tmp.title,refname:tmp.name,visible:true});
196
+ this.anchorData.push({id:'#'+ tmp.divId, name:tmp.title ? this.$t(tmp.title) : tmp.title,refname:tmp.name,visible:true,sort:Number.MAX_SAFE_INTEGER});
199
197
  }
200
198
 
201
199
  if (this.myConfig.showAnchorLink !== undefined) {
202
200
  this.showAnchorLink = this.myConfig.showAnchorLink;
203
201
  }
202
+
203
+ // 锚点导航顺序与混排后的渲染顺序保持一致
204
+ this.anchorData.sort((a, b) => a.sort - b.sort);
204
205
  },
205
206
  computed:{
207
+ renderItems () {
208
+ // formsConfig.items 与 detailConfig.items 按 sort 升序混排;
209
+ // 未配置 sort 时 formsConfig 项视为 0、detailConfig 项视为最大值,保持 forms 在前 details 在后的现状
210
+ let heads = [];
211
+ let details = [];
212
+ if (this.myConfig.formsConfig && this.myConfig.formsConfig.items) {
213
+ heads = this.myConfig.formsConfig.items.map((el, index) => {
214
+ return { el: el, index: index, isHead: true, sort: el.sort === undefined ? 0 : el.sort };
215
+ });
216
+ }
217
+ if (this.detailConfig.items) {
218
+ details = this.detailConfig.items.map((el, index) => {
219
+ return { el: el, index: index, isHead: false, sort: el.sort === undefined ? Number.MAX_SAFE_INTEGER : el.sort };
220
+ });
221
+ }
222
+ return heads.concat(details).sort((a, b) => a.sort - b.sort);
223
+ },
206
224
  style2 () {
207
225
  let height = this.$Store.state.app.clientHeight;
208
226
  if (this.extraHeight) {
@@ -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>