cloud-web-corejs 1.0.54-dev.514 → 1.0.54-dev.516
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 +1 -1
- package/src/components/xform/form-designer/form-widget/field-widget/text-widget.vue +58 -4
- package/src/components/xform/form-designer/setting-panel/property-editor/formatType-editor.vue +137 -0
- package/src/components/xform/form-designer/setting-panel/propertyRegister.js +1 -0
- package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +4 -0
- package/src/components/xform/utils/format.js +14 -4
- package/src/layout/components/Sidebar/default.vue +2 -1
package/package.json
CHANGED
|
@@ -20,6 +20,7 @@ import FormItemWrapper from "./form-item-wrapper";
|
|
|
20
20
|
import emitter from "../../../../../components/xform/utils/emitter";
|
|
21
21
|
import i18n from "../../../../../components/xform/utils/i18n";
|
|
22
22
|
import fieldMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/fieldMixin";
|
|
23
|
+
import * as formatUtil from "../../../../../components/xform/utils/format.js";
|
|
23
24
|
|
|
24
25
|
export default {
|
|
25
26
|
name: "text-widget",
|
|
@@ -63,9 +64,7 @@ export default {
|
|
|
63
64
|
},
|
|
64
65
|
computed: {
|
|
65
66
|
showVaule() {
|
|
66
|
-
let value =
|
|
67
|
-
? this.fieldModel
|
|
68
|
-
: this.handleCustomEvent(this.field.options.autoValueHanlde);
|
|
67
|
+
let value = this.formatterValue();
|
|
69
68
|
return value;
|
|
70
69
|
},
|
|
71
70
|
},
|
|
@@ -92,7 +91,62 @@ export default {
|
|
|
92
91
|
this.unregisterFromRefList();
|
|
93
92
|
},
|
|
94
93
|
|
|
95
|
-
methods: {
|
|
94
|
+
methods: {
|
|
95
|
+
formatterValue() {
|
|
96
|
+
let formatType = this.field.options.formatType;
|
|
97
|
+
let cellValue = this.fieldModel;
|
|
98
|
+
if (formatType === null || formatType === undefined) return cellValue;
|
|
99
|
+
if (formatType)
|
|
100
|
+
switch (formatType) {
|
|
101
|
+
case "render":
|
|
102
|
+
return this.handleCustomEvent(this.field.options.renderHandle);
|
|
103
|
+
break;
|
|
104
|
+
case "money":
|
|
105
|
+
return cellValue.toFixed(2);
|
|
106
|
+
break;
|
|
107
|
+
case "d1":
|
|
108
|
+
return formatUtil.formatDate1(cellValue);
|
|
109
|
+
break;
|
|
110
|
+
case "d2":
|
|
111
|
+
return formatUtil.formatDate2(cellValue);
|
|
112
|
+
break;
|
|
113
|
+
case "d3":
|
|
114
|
+
return formatUtil.formatDate3(cellValue);
|
|
115
|
+
break;
|
|
116
|
+
case "d4":
|
|
117
|
+
return formatUtil.formatDate4(cellValue);
|
|
118
|
+
break;
|
|
119
|
+
case "d5":
|
|
120
|
+
return formatUtil.formatDate4(cellValue);
|
|
121
|
+
break;
|
|
122
|
+
case "n0":
|
|
123
|
+
return cellValue.toFixed(this.field.options.formatDecimal || 0);
|
|
124
|
+
break;
|
|
125
|
+
case "n1":
|
|
126
|
+
return formatUtil.formatNumber1(cellValue);
|
|
127
|
+
break;
|
|
128
|
+
case "n2":
|
|
129
|
+
return formatUtil.formatNumber2(cellValue);
|
|
130
|
+
break;
|
|
131
|
+
case "n3":
|
|
132
|
+
return formatUtil.formatNumber3(cellValue);
|
|
133
|
+
break;
|
|
134
|
+
case "n4":
|
|
135
|
+
return formatUtil.formatNumber4(cellValue);
|
|
136
|
+
break;
|
|
137
|
+
case "n5":
|
|
138
|
+
return formatUtil.formatNumber5(cellValue);
|
|
139
|
+
break;
|
|
140
|
+
case "n6":
|
|
141
|
+
return formatUtil.formatNumber6(cellValue);
|
|
142
|
+
break;
|
|
143
|
+
case "n7":
|
|
144
|
+
return formatUtil.formatNumber7(cellValue);
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
return cellValue;
|
|
148
|
+
},
|
|
149
|
+
},
|
|
96
150
|
};
|
|
97
151
|
</script>
|
|
98
152
|
|
package/src/components/xform/form-designer/setting-panel/property-editor/formatType-editor.vue
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<el-form-item label="格式化"> </el-form-item>
|
|
4
|
+
<el-form-item label-width="0">
|
|
5
|
+
<el-select v-model="optionModel.formatType" clearable style="width: 100%">
|
|
6
|
+
<el-option-group v-for="t in op" :key="t.label" :label="t.label">
|
|
7
|
+
<el-option
|
|
8
|
+
v-for="e in t.options"
|
|
9
|
+
:key="e.value"
|
|
10
|
+
:value="e.value"
|
|
11
|
+
:label="e.label"
|
|
12
|
+
></el-option>
|
|
13
|
+
</el-option-group>
|
|
14
|
+
</el-select>
|
|
15
|
+
</el-form-item>
|
|
16
|
+
|
|
17
|
+
<el-form-item
|
|
18
|
+
:label="i18nt('自定义渲染处理')"
|
|
19
|
+
v-if="optionModel.formatType === 'render'"
|
|
20
|
+
>
|
|
21
|
+
<a
|
|
22
|
+
href="javascript:void(0);"
|
|
23
|
+
class="a-link link-oneLind"
|
|
24
|
+
@click="editEventHandler('renderHandle', funConfigParams)"
|
|
25
|
+
>
|
|
26
|
+
<span>{{ optionModel.renderHandle }}</span>
|
|
27
|
+
<i class="el-icon-edit"></i>
|
|
28
|
+
</a>
|
|
29
|
+
</el-form-item>
|
|
30
|
+
<el-form-item :label="i18nt('格式化小数位')" v-if="optionModel.formatType === 'n0'">
|
|
31
|
+
<el-input-number v-model="optionModel.formatDecimal" />
|
|
32
|
+
</el-form-item>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script>
|
|
37
|
+
import i18n from "../../../../../components/xform/utils/i18n";
|
|
38
|
+
import eventMixin from "./event-handler/eventMixin";
|
|
39
|
+
export default {
|
|
40
|
+
name: "formatType-editor",
|
|
41
|
+
mixins: [i18n, eventMixin],
|
|
42
|
+
props: {
|
|
43
|
+
designer: Object,
|
|
44
|
+
selectedWidget: Object,
|
|
45
|
+
optionModel: Object,
|
|
46
|
+
},
|
|
47
|
+
data() {
|
|
48
|
+
return {
|
|
49
|
+
funConfigParams: ["dataId", "formCode"],
|
|
50
|
+
op: [
|
|
51
|
+
{
|
|
52
|
+
label: "自定义",
|
|
53
|
+
options: [
|
|
54
|
+
{
|
|
55
|
+
value: "render",
|
|
56
|
+
label: "自定义渲染",
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
label: "业务",
|
|
62
|
+
options: [
|
|
63
|
+
{
|
|
64
|
+
value: "money",
|
|
65
|
+
label: "金额",
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
label: "日期",
|
|
71
|
+
options: [
|
|
72
|
+
{
|
|
73
|
+
value: "d1",
|
|
74
|
+
label: "yyyy-MM-dd",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
value: "d2",
|
|
78
|
+
label: "yyyy/MM/dd",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
value: "d3",
|
|
82
|
+
label: "yyyy年MM月dd日",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
value: "d4",
|
|
86
|
+
label: "yyyy-MM-dd HH:mm:ss",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
value: "d5",
|
|
90
|
+
label: "yyyy-MM-dd hh:mm:ss",
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
label: "数值",
|
|
96
|
+
options: [
|
|
97
|
+
{
|
|
98
|
+
value: "n0",
|
|
99
|
+
label: "自定义小数位",
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
value: "n1",
|
|
103
|
+
label: "###,###,###,##0.######",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
value: "n2",
|
|
107
|
+
label: "###,###,###,##0.00####",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
value: "n3",
|
|
111
|
+
label: "###,###,###,##0.000000",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
value: "n4",
|
|
115
|
+
label: "###,###,###,##0.000",
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
value: "n5",
|
|
119
|
+
label: "###,###,###,##0.00",
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
value: "n6",
|
|
123
|
+
label: "###,###,###,##0",
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
value: "n7",
|
|
127
|
+
label: "###,##0.00##%",
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
</script>
|
|
136
|
+
|
|
137
|
+
<style scoped></style>
|
|
@@ -1948,6 +1948,8 @@ export const basicFields = [
|
|
|
1948
1948
|
|
|
1949
1949
|
autoValueEnabled: false,
|
|
1950
1950
|
autoValueHanlde: null,
|
|
1951
|
+
formatType: null,
|
|
1952
|
+
renderHandle: null,
|
|
1951
1953
|
|
|
1952
1954
|
showRuleFlag: 1,
|
|
1953
1955
|
showRuleEnabled: 1,
|
|
@@ -1989,6 +1991,8 @@ export const basicFields = [
|
|
|
1989
1991
|
underline: false,
|
|
1990
1992
|
href: "",
|
|
1991
1993
|
colorClass: "f-red",
|
|
1994
|
+
formatType: null,
|
|
1995
|
+
renderHandle: null,
|
|
1992
1996
|
|
|
1993
1997
|
onCreated: "",
|
|
1994
1998
|
onMounted: "",
|
|
@@ -50,8 +50,7 @@ export function formatNumber1(v) {
|
|
|
50
50
|
if (typeof(v) != "number") {
|
|
51
51
|
return v;
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
let length = v.toString().split(".")[1].length;
|
|
53
|
+
let length = getFixedSize(v);
|
|
55
54
|
switch(length){
|
|
56
55
|
case 0:
|
|
57
56
|
v = v.toFixed(0)
|
|
@@ -82,13 +81,23 @@ export function formatNumber1(v) {
|
|
|
82
81
|
return res;
|
|
83
82
|
}
|
|
84
83
|
|
|
84
|
+
function getFixedSize(v){
|
|
85
|
+
let size = 0;
|
|
86
|
+
if(v!==null && v!==undefined){
|
|
87
|
+
let arr = v.toString().split(".");
|
|
88
|
+
if(arr.length>1){
|
|
89
|
+
size = arr[1].length;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return size;
|
|
93
|
+
}
|
|
85
94
|
//###,###,###,##0.00####
|
|
86
95
|
export function formatNumber2(v) {
|
|
87
96
|
if (typeof(v) != "number") {
|
|
88
97
|
return v;
|
|
89
98
|
}
|
|
90
99
|
|
|
91
|
-
let length = v
|
|
100
|
+
let length = getFixedSize(v);
|
|
92
101
|
switch(length){
|
|
93
102
|
case 0:
|
|
94
103
|
case 1:
|
|
@@ -181,7 +190,7 @@ export function formatNumber7(v) {
|
|
|
181
190
|
return v;
|
|
182
191
|
}
|
|
183
192
|
|
|
184
|
-
let length = v
|
|
193
|
+
let length = getFixedSize(v);
|
|
185
194
|
v = v*100
|
|
186
195
|
switch(length){
|
|
187
196
|
case 0:
|
|
@@ -203,3 +212,4 @@ export function formatNumber7(v) {
|
|
|
203
212
|
})
|
|
204
213
|
return res+'%';
|
|
205
214
|
}
|
|
215
|
+
|
|
@@ -411,12 +411,13 @@ export default {
|
|
|
411
411
|
isLoading: true,
|
|
412
412
|
success: (res) => {
|
|
413
413
|
path = res.objx;
|
|
414
|
+
window.open(path);
|
|
414
415
|
},
|
|
415
416
|
});
|
|
416
417
|
} else if (path.indexOf("token={token}") >= 0) {
|
|
417
418
|
path = path.replace("token={token}", "token=" + getToken());
|
|
419
|
+
window.open(path);
|
|
418
420
|
}
|
|
419
|
-
window.open(path);
|
|
420
421
|
}
|
|
421
422
|
},
|
|
422
423
|
getCustomReqUrlAndCleanUrl(url) {
|