t20-common-lib 0.14.9 → 0.15.1

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": "t20-common-lib",
3
- "version": "0.14.9",
3
+ "version": "0.15.1",
4
4
  "description": "T20",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
@@ -0,0 +1,7 @@
1
+ import DynamicForm from './src/main.vue'
2
+
3
+ DynamicForm.install = function (Vue) {
4
+ Vue.component(DynamicForm.name, DynamicForm)
5
+ }
6
+
7
+ export default DynamicForm
@@ -0,0 +1,66 @@
1
+ <!--
2
+ * @Author: yanshuang yanshuang@nstc.com.cn
3
+ * @Date: 2023-09-05 10:13:07
4
+ * @LastEditors: yanshuang yanshuang@nstc.com.cn
5
+ * @LastEditTime: 2023-09-15 11:52:16
6
+ * @FilePath: \投资理财\gts-invest_web\invset\src\views\dynamicForms\components\Amount.vue
7
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
8
+ -->
9
+ <!--
10
+ * @fileName Amount
11
+ * @filePath E:\code\jiuhengxing\T20\gts-invest_web 投资理财\invset\src\views\dynamicForms\components\Amount.vue
12
+ * @author wanghailing
13
+ * @date 2023-08-14 13:42:15
14
+ * @description 参数1
15
+ !-->
16
+ <template>
17
+ <N20-input-number
18
+ :max="items.elementType == 'RATE' ? 999.999999 : 9999999999999.99"
19
+ :min="0.0"
20
+ :type="items.elementType == 'RATE' ? 'rate' : 'money'"
21
+ :is-clearable="true"
22
+ v-model="_value"
23
+ :placeholder="$attrs.placeholder ? $attrs.placeholder : '请输入' | $l"
24
+ v-bind="$attrs"
25
+ v-on="$listeners"
26
+ @change="changeFn"
27
+ />
28
+ </template>
29
+
30
+ <script>
31
+ export default {
32
+ name: 'Amount',
33
+ props: {
34
+ value: {
35
+ type: [String, Number],
36
+ defalut: ''
37
+ },
38
+ items: {
39
+ type: Object,
40
+ default: () => {}
41
+ }
42
+ },
43
+ computed: {
44
+ _value: {
45
+ get() {
46
+ return this.value
47
+ },
48
+ set(value) {
49
+ this.$emit('input', [null, undefined].includes(value) ? null : value)
50
+ }
51
+ }
52
+ },
53
+ data(vm) {
54
+ return {
55
+ type: 'money'
56
+ }
57
+ },
58
+ watch: {},
59
+ methods: {
60
+ changeFn(val) {
61
+ this.$emit('change')
62
+ }
63
+ }
64
+ }
65
+ </script>
66
+ <style scoped lang="scss"></style>
@@ -0,0 +1,72 @@
1
+ <!--
2
+ * @Author: yanshuang yanshuang@nstc.com.cn
3
+ * @Date: 2023-09-05 10:13:08
4
+ * @LastEditors: yanshuang yanshuang@nstc.com.cn
5
+ * @LastEditTime: 2023-10-09 13:38:45
6
+ * @FilePath: \投资理财\gts-invest_web\invset\src\views\dynamicForms\components\AmountRange.vue
7
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
8
+ -->
9
+ <!--
10
+ * @fileName Amount
11
+ * @filePath E:\code\jiuhengxing\T20\gts-invest_web 投资理财\invset\src\views\dynamicForms\components\Amount.vue
12
+ * @author wanghailing
13
+ * @date 2023-08-14 13:42:15
14
+ * @description 参数1
15
+ !-->
16
+ <template>
17
+ <N20-input-number-range
18
+ :max="items.elementType == 'RATE_RANGE' ?999.99:9999999999999.99"
19
+ :min="0.00"
20
+ :start-value.sync="_value1"
21
+ :end-value.sync="_value2"
22
+ :type="items.elementType == 'RATE_RANGE' ? 'rate' : 'money' "
23
+ :is-clearable="true"
24
+ v-bind="$attrs"
25
+ />
26
+ </template>
27
+
28
+ <script>
29
+ export default {
30
+ name: 'amountRange',
31
+ props: {
32
+ value: {
33
+ type: [String, Number],
34
+ defalut: "",
35
+ },
36
+ items: {
37
+ type: Object,
38
+ default: () => {},
39
+ },
40
+ },
41
+ data() {
42
+ return {};
43
+ },
44
+ computed: {
45
+ // 计算属性
46
+ _value1: {
47
+ get() {
48
+ if (this.value) {
49
+ return this.value.split(",")[0];
50
+ }
51
+ return "";
52
+ },
53
+ set(val) {
54
+ this.$emit("input", `${val},${this._value2 || this._value2===0?this._value2 : ''}`);
55
+ },
56
+ },
57
+ _value2: {
58
+ get() {
59
+ if (this.value) {
60
+ return this.value.split(",")[1];
61
+ }
62
+ return "";
63
+ },
64
+ set(val) {
65
+ this.$emit("input", `${this._value1},${val || val===0?val : ''}`);
66
+ },
67
+ },
68
+ },
69
+ }
70
+ </script>
71
+ <style scoped lang='scss'>
72
+ </style>
@@ -0,0 +1,63 @@
1
+ <template>
2
+ <div>
3
+ <el-checkbox-group v-model="_value" v-bind="$attrs" v-on="$listeners">
4
+ <el-checkbox
5
+ :label="item.value"
6
+ v-for="(item, index) in (items.options || [])"
7
+ :key="index"
8
+ >{{ $l(item.label) }}</el-checkbox
9
+ >
10
+ </el-checkbox-group>
11
+ </div>
12
+ </template>
13
+ <script>
14
+ export default {
15
+ name: "Checkbox",
16
+ props: {
17
+ value: {
18
+ type: [Array, String],
19
+ defalut: () => [],
20
+ },
21
+ items: {
22
+ type: Object,
23
+ defalut: () => {
24
+ return {
25
+ options: [],
26
+ };
27
+ },
28
+ },
29
+ },
30
+ methods: {
31
+ changeTime(value=[]) {
32
+ let temp = [];
33
+ for (let i of value) {
34
+ let res = (this.items.options || []).find((row) => row.value === i);
35
+ if (res) temp.push(res?.label);
36
+ }
37
+ this.$emit(`update:label`, temp.join(","));
38
+ },
39
+ },
40
+ computed: {
41
+ _value: {
42
+ get() {
43
+ let valueList = this.value || []
44
+ let value = (this.items.options || []).filter(item=>{
45
+ return valueList.findIndex(row=>row===item.value)>-1
46
+ })
47
+ let valuer = value.map(item=>item.value)
48
+ this.changeTime(valuer);
49
+ return valuer || [];
50
+ },
51
+ set(value) {
52
+ this.changeTime(value);
53
+ this.$emit("input", value || []);
54
+ },
55
+ },
56
+ },
57
+ mounted() {
58
+ },
59
+ data() {
60
+ return {};
61
+ },
62
+ };
63
+ </script>
@@ -0,0 +1,126 @@
1
+ <!--
2
+ * @fileName DMY
3
+ * @filePath E:\code\jiuhengxing\T20\gts-invest_web 投资理财\invset\src\views\dynamicForms\components\DMY.vue
4
+ * @author wanghailing
5
+ * @date 2023-08-15 11:05:24
6
+ * @description 参数1
7
+ !-->
8
+ <template>
9
+ <div class="DMY">
10
+ <el-input
11
+ class="DMY-input"
12
+ clearable
13
+ v-title
14
+ :show-overflow-tooltip="true"
15
+ :maxlength="$attrs.maxlength ? $attrs.maxlength : 64"
16
+ v-model.number="value1"
17
+ :placeholder="$attrs.placeholder ? $attrs.placeholder : '请输入' | $l"
18
+ :key="items.prop"
19
+ v-bind="$attrs"
20
+ />
21
+ <el-select
22
+ v-model="value2"
23
+ class="DMY-select"
24
+ :placeholder="$attrs.placeholder2 ? $attrs.placeholder2 : $l('请选择')"
25
+ v-title
26
+ v-bind="$attrs"
27
+ >
28
+ <el-option
29
+ v-for="item in periodUnitList"
30
+ :key="item.code"
31
+ :label="item.name | $l"
32
+ :value="item.code"
33
+ />
34
+ </el-select>
35
+ </div>
36
+ </template>
37
+
38
+ <script>
39
+ export default {
40
+ props: {
41
+ // 父辈向子辈传参
42
+ value: {
43
+ type: String,
44
+ defalut: ",D",
45
+ },
46
+ items: Object
47
+ },
48
+ name: "DMY",
49
+ data() {
50
+ return {
51
+ periodUnitList: [
52
+ {
53
+ "code": "D",
54
+ "name": "天"
55
+ },
56
+ {
57
+ "code": "M",
58
+ "name": "月"
59
+ },
60
+ {
61
+ "code": "Y",
62
+ "name": "年"
63
+ }
64
+ ]
65
+ };
66
+ },
67
+ created() {
68
+ // 实例被创建之后执行代码
69
+ },
70
+ computed: {
71
+ // 计算属性
72
+ value1: {
73
+ get() {
74
+ if (this.value && ['D', 'M', 'Y'].includes(this.value.slice(-1))) {
75
+ return this.value.slice(0, -1);
76
+ } else if (this.value && !['D', 'M', 'Y'].includes(this.value.slice(-1))) {
77
+ return this.value;
78
+ }
79
+ return "";
80
+ },
81
+ set(val) {
82
+ this.$emit("input", `${val}${this.value2}`);
83
+ },
84
+ },
85
+ value2: {
86
+ get() {
87
+ if (this.value && ['D', 'M', 'Y'].includes(this.value.slice(-1))) {
88
+ return this.value.slice(-1);
89
+ } else if (this.value && !['D', 'M', 'Y'].includes(this.value.slice(-1))) {
90
+ return "";
91
+ }
92
+ return "D";
93
+ },
94
+ set(val) {
95
+ this.$emit("input", `${this.value1}${val}`);
96
+ },
97
+ },
98
+ },
99
+ components: {
100
+ // 组件的引用
101
+ },
102
+ methods: {
103
+ // 方法
104
+ },
105
+ mounted() {
106
+ // 页面进入时加载内容
107
+ },
108
+ watch: {
109
+ // 监测变化
110
+ },
111
+ };
112
+ </script>
113
+ <style scoped>
114
+ .DMY {
115
+ width: 100%;
116
+ }
117
+ .DMY .DMY-input {
118
+ width: 134px;
119
+ }
120
+ .DMY .DMY-input ::v-deep .el-input__inner {
121
+ width: 134px !important;
122
+ }
123
+ .DMY .DMY-select {
124
+ width: 80px;
125
+ }
126
+ </style>
@@ -0,0 +1,50 @@
1
+ <template>
2
+ <div :style="{minWidth:$attrs.isShowAuto?'310px':'224px'}">
3
+ <N20-date-picker
4
+ v-model="_value"
5
+ class="input-w"
6
+ placeholder="请选择"
7
+ :type="$attrs.type ? $attrs.type : 'date'"
8
+ :value-format="$attrs.valueFormat ? $attrs.valueFormat : 'yyyy-MM-dd'"
9
+ v-bind="$attrs"
10
+ v-on="$listeners"
11
+ />
12
+ <el-tooltip v-if="$attrs.isShowtoolTip" effect="dark" :content="$l($attrs.toolTip)" placement="top">
13
+ <i class="n20-icon-xinxitishi m-l-ss" style="color: var(--color-text-secondary); position: absolute; top: 10px"></i>
14
+ </el-tooltip>
15
+ </div>
16
+ </template>
17
+ <script>
18
+ export default {
19
+ name: "Date",
20
+ props: {
21
+ value: {
22
+ type: String,
23
+ defalut: "",
24
+ },
25
+ },
26
+ computed: {
27
+ _value: {
28
+ get() {
29
+ return this.value;
30
+ },
31
+ set(value) {
32
+ this.$emit("input", value);
33
+ },
34
+ },
35
+ },
36
+ data(vm) {
37
+ return {
38
+ setDateRange: {
39
+ disabledDate: vm.disabledDateCur
40
+ }
41
+ };
42
+ },
43
+ mounted() {},
44
+ methods: {
45
+ disabledDateCur(time){
46
+ return this.disabledDate(time,this)
47
+ }
48
+ },
49
+ };
50
+ </script>
@@ -0,0 +1,46 @@
1
+ <template>
2
+ <N20-date-picker-por
3
+ :start-date.sync="startDate"
4
+ :end-date.sync="endDate"
5
+ type="daterange"
6
+ @change="changeTime"
7
+ :value-format="$attrs['value-format'] ? $attrs['value-format'] : 'yyyy-MM-dd'"
8
+ v-bind="$attrs"
9
+ v-on="$listeners"
10
+ />
11
+ </template>
12
+ <script>
13
+ export default {
14
+ name: "DateRange",
15
+ props: {
16
+ value: {
17
+ type: [Array,String],
18
+ defalut: () => [],
19
+ },
20
+ },
21
+ data() {
22
+ return {};
23
+ },
24
+ computed: {
25
+ startDate() {
26
+ if (this.value) {
27
+ return this.value.split(",")[0];
28
+ }
29
+ return "";
30
+ },
31
+ endDate() {
32
+ if (this.value) {
33
+ return this.value.split(",")[1];
34
+ }
35
+ return "";
36
+ },
37
+ },
38
+ methods: {
39
+ changeTime(val) {
40
+ this.$emit("input", val ? `${val[0]},${val[1]}` : '');
41
+ },
42
+ },
43
+ watch: {
44
+ },
45
+ };
46
+ </script>
@@ -0,0 +1,194 @@
1
+ <template>
2
+ <div>
3
+ <N20-input-search
4
+ class="input-w"
5
+ clearable
6
+ v-title
7
+ :select="items.api.reqKeys.isSelect"
8
+ :show-overflow-tooltip="true"
9
+ :suffix-icon="items.api.icon || 'el-icon-zoom-in'"
10
+ :maxlength="$attrs.maxlength ? $attrs.maxlength : 64"
11
+ v-model="_value"
12
+ :placeholder="'请选择' | $l"
13
+ :key="items.prop"
14
+ @search="showDialog"
15
+ @change="changeFn"
16
+ @blur="changValue"
17
+ @clear="clearFn"
18
+ v-bind="$attrs"
19
+ default-first-option
20
+ >
21
+ </N20-input-search>
22
+ <el-tooltip v-if="$attrs.isShowtoolTip" effect="dark" :content="$l($attrs.toolTip)" placement="top">
23
+ <i
24
+ class="n20-icon-xinxitishi m-l-ss"
25
+ style="color: var(--color-text-secondary); position: absolute; top: 10px; left: 224px;"
26
+ ></i>
27
+ </el-tooltip>
28
+ <component
29
+ :is="items.api.reqKeys.dialogName"
30
+ v-if="visible"
31
+ :visible.sync="visible"
32
+ :formData="formData"
33
+ @change="changeData"
34
+ ></component>
35
+ </div>
36
+ </template>
37
+ <script>
38
+ import dayjs from 'dayjs'
39
+ import { getDataForPost, getDataForGet } from '../utils/request'
40
+ export default {
41
+ name: 'Dialog',
42
+ props: {
43
+ value: {
44
+ type: [String, Number],
45
+ defalut: ''
46
+ },
47
+ groupProp: {
48
+ type: [String],
49
+ defalut: ''
50
+ },
51
+ items: Object,
52
+ formData: Object,
53
+ variable: Object
54
+ },
55
+ data() {
56
+ return {
57
+ visible: false,
58
+ options: []
59
+ }
60
+ },
61
+ computed: {
62
+ _value: {
63
+ get() {
64
+ return this.value
65
+ },
66
+ set(value) {
67
+ this.$emit('input', value)
68
+ }
69
+ },
70
+ curOptions() {
71
+ if (!this.items.api.reqKeys.beforeShow) {
72
+ return this.options
73
+ }
74
+ if (!this.formData[this.groupProp][this.items.api.reqKeys.beforeShow]) {
75
+ return []
76
+ } else {
77
+ return this.options
78
+ }
79
+ },
80
+ labelKey() {
81
+ return this.items?.api?.labelKey.includes(',') || this.items?.api?.labelKey.includes('{')
82
+ }
83
+ },
84
+ components: {
85
+ // 组件的引用
86
+ },
87
+ mounted() {
88
+ this.init()
89
+ },
90
+ methods: {
91
+ changValue(e) {
92
+ let value = e.target.value
93
+ // 之前有带出来的值的话,在手动输入后,之前带出来的值清空;如果之前的值是输入的值,则不执行这步操作;
94
+ if (
95
+ this.items.api.reqKeys.isSelect &&
96
+ !this.options.find(t => t.label == value) &&
97
+ this.options.find(t => t.label == this._value) &&
98
+ value != this._value
99
+ ) {
100
+ this._value = value
101
+ this.$emit('change', {})
102
+ return
103
+ }
104
+ if (value) {
105
+ this._value = value
106
+ }
107
+ },
108
+ async changeData(obj) {
109
+ this.visible = false
110
+ this.$emit('dialogChange', obj || {})
111
+ },
112
+ showDialog() {
113
+ console.log(this.items.api.reqKeys.dialogName, '9999')
114
+ this.visible = true
115
+ },
116
+ clearFn() {
117
+ this.visible = false
118
+ },
119
+ async changeFn(val) {
120
+ let item = Array.isArray(this.options) ? this.options.find(t => t.value == val) : {}
121
+ this.$emit('change', item || {})
122
+ },
123
+ async init() {
124
+ if (!this.items?.api?.apiUrl || !this.items?.api?.requestMethod) {
125
+ this.options = this.items.options || '{}' || []
126
+ return
127
+ }
128
+ if (!this.items.api.reqKeys.isSelect) {
129
+ return
130
+ }
131
+ let res = null
132
+ let searchObj = this.items?.api?.reqKeys || '{}'
133
+ Object.keys(searchObj).map(t => {
134
+ searchObj[t] = this.changVariable(searchObj[t])
135
+ })
136
+
137
+ ;['GET', 'get'].includes(this.items?.api?.requestMethod) &&
138
+ (res = await getDataForGet(this.items?.api?.apiUrl, searchObj || {}))
139
+ ;['POST', 'post'].includes(this.items?.api?.requestMethod) &&
140
+ (res = await getDataForPost(this.items?.api?.apiUrl, searchObj || {}))
141
+ this.options = (
142
+ (this.items?.api?.dataProp ? new Function('res', `return res.${this.items?.api?.dataProp}`)(res) : res.data) ||
143
+ []
144
+ ).map(item => {
145
+ if (this.items?.api?.labelKey.includes(',')) {
146
+ let keyArr = this.items?.api?.labelKey.split(',')
147
+ let label = ''
148
+ keyArr.map((key, index) => {
149
+ if (index == keyArr.length - 1) {
150
+ label += item[key]
151
+ } else {
152
+ label += item[key] + ' '
153
+ }
154
+ })
155
+ item._label = label
156
+ item.label = item[keyArr[0]]
157
+ } else if (this.items?.api?.labelKey && this.items?.api?.labelKey.includes('{')) {
158
+ let regex = /\{([^}]+)\}/g
159
+ var modifiedStr = this.items?.api?.labelKey.replace(regex, (match, p1) => {
160
+ if (p1.includes('label:')) {
161
+ item.label = item[p1.replace('label:', '')]
162
+ return item[p1.replace('label:', '')]
163
+ }
164
+ return item[p1]
165
+ })
166
+ item._label = modifiedStr
167
+ } else {
168
+ item.label = item[this.items?.api?.labelKey || 'label']
169
+ }
170
+ item.value = item[this.items?.api?.valueKey || 'value']
171
+ return item
172
+ })
173
+ },
174
+ changVariable(val) {
175
+ if (!val) {
176
+ return val || ''
177
+ }
178
+ let str = String(val)
179
+ if (str == '${nowDate}') {
180
+ return dayjs().format('YYYY-MM-DD')
181
+ }
182
+ if (Object.prototype.toString.call(val) == '[object String]' && val.includes('.')) {
183
+ let [key, subkey] = val.split('.')
184
+ return this.formData[key][subkey]
185
+ }
186
+ if (str && str.includes('$')) {
187
+ let key = str.replace('${', '').replace('}', '')
188
+ return this.variable[key] || ''
189
+ }
190
+ return val || ''
191
+ }
192
+ }
193
+ }
194
+ </script>
@@ -0,0 +1,41 @@
1
+ <template>
2
+ <div :style="{minWidth:$attrs.isShowAuto?'310px':'224px'}">
3
+ <el-input
4
+ class="input-w"
5
+ clearable
6
+ v-title
7
+ :show-overflow-tooltip="true"
8
+ :maxlength="$attrs.maxlength ? $attrs.maxlength : 64"
9
+ v-model="_value"
10
+ :placeholder="$attrs.placeholder ? $attrs.placeholder : '请输入' | $l"
11
+ :key="items.prop"
12
+ v-on="$listeners"
13
+ v-bind="$attrs"
14
+ />
15
+ <el-tooltip v-if="$attrs.isShowtoolTip" effect="dark" :content="$l($attrs.toolTip)" placement="top">
16
+ <i class="n20-icon-xinxitishi m-l-ss" style="color: var(--color-text-secondary); position: absolute; top: 10px"></i>
17
+ </el-tooltip>
18
+ </div>
19
+ </template>
20
+ <script>
21
+ export default {
22
+ name: "Input",
23
+ props: {
24
+ value: {
25
+ type: [String,Number],
26
+ defalut: "",
27
+ },
28
+ items: Object,
29
+ },
30
+ computed: {
31
+ _value: {
32
+ get() {
33
+ return this.value;
34
+ },
35
+ set(value) {
36
+ this.$emit("input", value);
37
+ },
38
+ },
39
+ },
40
+ };
41
+ </script>