free-fe-core-modules 0.0.2 → 0.0.4

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.
Files changed (104) hide show
  1. package/components/Basic/EIcon.vue +2 -4
  2. package/components/Basic/LeveledMenus.vue +0 -5
  3. package/components/Basic/SummaryHead.vue +23 -3
  4. package/components/Dialog/BasicDialog.vue +2 -3
  5. package/components/SlidingCarousel/index.vue +13 -3
  6. package/components/SlidingNews/index.vue +13 -3
  7. package/components/ThemeSwitch/index.vue +7 -5
  8. package/composible/useObjectData.js +69 -0
  9. package/free-field/Fields/AgreementCheck.js +170 -0
  10. package/free-field/Fields/ApiCall.js +123 -0
  11. package/{field-components/Fields/Boolean.vue → free-field/Fields/Boolean.js} +40 -46
  12. package/free-field/Fields/Category.js +28 -0
  13. package/free-field/Fields/Check.js +106 -0
  14. package/free-field/Fields/Customize.js +87 -0
  15. package/free-field/Fields/Date.js +133 -0
  16. package/free-field/Fields/DateRange.js +226 -0
  17. package/free-field/Fields/DynamicList.js +565 -0
  18. package/{field-components → free-field}/Fields/FixedList.vue +78 -83
  19. package/free-field/Fields/InputFieldList.vue +324 -0
  20. package/{field-components → free-field}/Fields/Labels.vue +24 -15
  21. package/{field-components → free-field}/Fields/MixedTable.vue +53 -61
  22. package/free-field/Fields/Number.js +167 -0
  23. package/free-field/Fields/Password.js +81 -0
  24. package/{field-components → free-field}/Fields/Permission.vue +17 -13
  25. package/{field-components → free-field}/Fields/PermissionEditor.vue +62 -105
  26. package/{field-components → free-field}/Fields/QueryFilters.vue +65 -48
  27. package/{field-components → free-field}/Fields/RadioList.vue +36 -12
  28. package/{field-components → free-field}/Fields/Rich.vue +104 -114
  29. package/{field-components → free-field}/Fields/Search.vue +35 -26
  30. package/{field-components → free-field}/Fields/Select.vue +116 -87
  31. package/{field-components → free-field}/Fields/SelectionChain.vue +89 -67
  32. package/{field-components/Fields/Separator.vue → free-field/Fields/Separator.js} +11 -16
  33. package/{field-components → free-field}/Fields/SingleList.vue +27 -21
  34. package/free-field/Fields/Static.js +27 -0
  35. package/free-field/Fields/String.js +105 -0
  36. package/free-field/Fields/Text.js +80 -0
  37. package/{field-components → free-field}/Fields/Time.vue +59 -43
  38. package/{field-components → free-field}/Fields/TimeRange.vue +107 -92
  39. package/free-field/Fields/Year.js +137 -0
  40. package/{field-components → free-field}/Fields/YearRange.vue +63 -73
  41. package/{field-components → free-field}/Fields/index.js +28 -30
  42. package/free-field/composible/fieldWrapper.js +221 -0
  43. package/free-field/composible/freeFieldLabel.js +22 -0
  44. package/free-field/composible/readonlyContent.js +36 -0
  45. package/free-field/composible/useFileSizeUtils.js +52 -0
  46. package/free-field/composible/useFreeField.js +143 -0
  47. package/{field-components → free-field}/index.js +3 -3
  48. package/i18n/en-us/index.js +1 -1
  49. package/i18n/zh-cn/index.js +1 -1
  50. package/index.js +1 -4
  51. package/package.json +2 -2
  52. package/router/error/data.js +4 -1
  53. package/view/dict/index.vue +13 -2
  54. package/view/error/list.vue +22 -14
  55. package/view/menu/index.vue +19 -4
  56. package/view/system/index.vue +15 -2
  57. package/field-components/Fields/AgreementCheck.vue +0 -161
  58. package/field-components/Fields/ApiCall.vue +0 -139
  59. package/field-components/Fields/Category.vue +0 -33
  60. package/field-components/Fields/Check.vue +0 -131
  61. package/field-components/Fields/Customize.vue +0 -103
  62. package/field-components/Fields/Date.vue +0 -142
  63. package/field-components/Fields/DateRange.vue +0 -199
  64. package/field-components/Fields/DynamicList.vue +0 -575
  65. package/field-components/Fields/FieldEditor.vue +0 -379
  66. package/field-components/Fields/File.vue +0 -382
  67. package/field-components/Fields/FileList.vue +0 -405
  68. package/field-components/Fields/FileListCombined.vue +0 -142
  69. package/field-components/Fields/Image.vue +0 -328
  70. package/field-components/Fields/ImageList.vue +0 -285
  71. package/field-components/Fields/ImageListCombined.vue +0 -76
  72. package/field-components/Fields/InputFieldList.vue +0 -299
  73. package/field-components/Fields/Number.vue +0 -247
  74. package/field-components/Fields/Password.vue +0 -79
  75. package/field-components/Fields/Static.vue +0 -22
  76. package/field-components/Fields/String.vue +0 -185
  77. package/field-components/Fields/Text.vue +0 -89
  78. package/field-components/Fields/UltimateFile.vue +0 -100
  79. package/field-components/Fields/Year.vue +0 -124
  80. package/field-components/Fields/components/FieldTypeOptions.vue +0 -248
  81. package/field-components/components/FieldComponents.vue +0 -246
  82. package/free-fields/AutoHide.js +0 -66
  83. package/free-fields/CenterContent.js +0 -15
  84. package/free-fields/Draggable.js +0 -30
  85. package/free-fields/Droppable.js +0 -114
  86. package/free-fields/EditableString.js +0 -63
  87. package/free-fields/FieldCategory.js +0 -83
  88. package/free-fields/FieldTypeSelect.js +0 -94
  89. package/free-fields/fieldEditors/arrayEditor.js +0 -3
  90. package/free-fields/fieldEditors/boolEditor.js +0 -22
  91. package/free-fields/fieldEditors/dateEditor.js +0 -23
  92. package/free-fields/fieldEditors/datetimeEditor.js +0 -23
  93. package/free-fields/fieldEditors/index.js +0 -21
  94. package/free-fields/fieldEditors/jsonEditor.js +0 -371
  95. package/free-fields/fieldEditors/labeledField.js +0 -74
  96. package/free-fields/fieldEditors/numberEditor.js +0 -51
  97. package/free-fields/fieldEditors/objectEditor.js +0 -3
  98. package/free-fields/fieldEditors/selectEditor.js +0 -0
  99. package/free-fields/fieldEditors/stringEditor.js +0 -49
  100. package/free-fields/fieldEditors/textEditor.js +0 -50
  101. package/free-fields/fieldEditors/timeEditor.js +0 -23
  102. package/free-fields/index.js +0 -402
  103. /package/{field-components/Display → free-field/Layout}/index.js +0 -0
  104. /package/{field-components → free-field}/style.sass +0 -0
@@ -1,161 +0,0 @@
1
- <template>
2
- <span :class="`input-field-agreement-check row items-center no-wrap ${(Field.Options
3
- && Field.Options.Center) ? 'center full-width justify-center' : ''}`">
4
- <span class="field-label-empty" v-if="!Field.Options || !Field.Options.Center"></span>
5
- <div class="row no-wrap items-center relative-position"
6
- :class="`check ${hasError ? 'input-field--error' : ''}`">
7
- <q-checkbox
8
- :class="`check`"
9
- @input="validate(); $emit('input')"
10
- v-bind="$attrs"
11
- v-model="fieldData"
12
- />
13
-
14
- <div class="input-field-tips" v-if="Field.Tips && Field.Tips.length > 0">
15
- <span class="input-field-tips-prefix"></span>
16
- <span class="tips-list">
17
- <span v-for="(tip, index) in Field.Tips"
18
- :key="index" class="input-field-tips-tip">
19
- <span class="input-field-tips-tip-prefix"></span>
20
- <span v-for="(t, tindex) in fieldTip(tip)" :key="tindex">
21
- <span v-if="t.Link" class="tip-link">
22
- <span class="tip-link-prefix"></span>
23
- <a :href="t.Link">{{t.Text}}</a>
24
- <span class="tip-link-postfix"></span>
25
- </span>
26
- <span v-else class="tip-text">{{t.Text}}</span>
27
- </span>
28
- <span class="input-field-tips-tip-postfix"></span>
29
- </span>
30
- </span>
31
- <span class="input-field-tips-postfix"></span>
32
- </div>
33
-
34
- <div class="input-field--error-tag" v-if="hasError">
35
- <e-icon name="error"></e-icon>
36
- </div>
37
- </div>
38
- </span>
39
- </template>
40
-
41
- <script>
42
- import { defineComponent } from 'vue';
43
- import mixins from 'free-fe-mixins';
44
-
45
- export default defineComponent({
46
- name: 'InputFieldAgreementCheck',
47
- mixins: [mixins.InputFieldMixin],
48
- fieldInfo: {
49
- Category: 'Simple',
50
- Label: '协议同意勾选框',
51
- Value: 'AgreementCheck',
52
- Extra: [
53
- {
54
- Type: 'Check',
55
- Label: '居中显示',
56
- Name: 'Options.Center',
57
- },
58
- ],
59
- Description: '',
60
- },
61
- data() {
62
- return {
63
- hasError: false,
64
- };
65
- },
66
- watch: {
67
- fieldData() {
68
- if (!this.fieldData) {
69
- this.fieldData = false;
70
- }
71
- },
72
- },
73
- created() {
74
- if (!this.fieldData) {
75
- this.fieldData = false;
76
- }
77
- },
78
- computed: {
79
- fieldTip() {
80
- return (tip) => {
81
- if (!tip || !tip.Text) return '';
82
- if (!tip.Links || !Array.isArray(tip.Links) || tip.Links.length <= 0) {
83
- return [{ Text: tip.Text }];
84
- }
85
-
86
- // process tip with links
87
- let linkPos = [];
88
- tip.Links.forEach((tl) => {
89
- if (!tl || !tl.Text || !tl.Link) return;
90
-
91
- const start = tip.Text.indexOf(tl.Text);
92
- if (start >= 0) {
93
- linkPos.push({
94
- start,
95
- end: start + tl.Text.length,
96
- Link: tl.Link,
97
- File: tl.File,
98
- });
99
- }
100
- });
101
-
102
- const textSplit = [];
103
- let start = 0;
104
- linkPos = linkPos.sort((a, b) => a.start - b.start);
105
- for (let i = 0; i < linkPos.length; i += 1) {
106
- const lp = linkPos[i];
107
-
108
- const beforeText = tip.Text.substr(start, lp.start - start);
109
- if (beforeText) {
110
- textSplit.push({ Text: beforeText });
111
- }
112
-
113
- textSplit.push({
114
- Text: tip.Text.substr(lp.start, lp.end - lp.start),
115
- Link: lp.File
116
- ? this.$options.filters.serverDocument(lp.File)
117
- : lp.Link,
118
- });
119
-
120
- start += lp.end;
121
- }
122
-
123
- const afterText = tip.Text.substr(start);
124
- if (afterText) {
125
- textSplit.push({
126
- Text: afterText,
127
- });
128
- }
129
-
130
- if (textSplit.length > 0) return textSplit;
131
-
132
- return [{ Text: tip.Text }];
133
- };
134
- },
135
- },
136
- methods: {
137
- validate() {
138
- if (this.Field.Required) {
139
- this.hasError = typeof this.fieldData === 'undefined' || !this.fieldData;
140
- return !this.hasError;
141
- }
142
-
143
- const rules = Array.isArray(typeof this.Field.Rules)
144
- ? this.Field.Rules
145
- : [this.Field.Rules];
146
-
147
- let isValid = true;
148
- for (let i = 0; i < rules.length; i += 1) {
149
- const r = rules[i];
150
-
151
- if (typeof r === 'function') {
152
- isValid = isValid && r(this.fieldData);
153
- }
154
- }
155
-
156
- this.hasError = !isValid;
157
- return isValid;
158
- },
159
- },
160
- });
161
- </script>
@@ -1,139 +0,0 @@
1
- <template>
2
- <div class="simple-field input-field-apicall row items-start no-wrap">
3
- <span
4
- class="full-width"
5
- v-if="Field"
6
- >
7
- <span
8
- :class="`field-label field-label-readonly ${(Field.Label && Field.Label.trim().length)
9
- ? '' : 'field-label-empty'} ${Field.Required ? 'required' : ''}`"
10
- v-if="typeof Field.Label !== 'undefined'"
11
- >
12
- <q-tooltip
13
- v-if="Field.Description"
14
- anchor="top right"
15
- >{{Field.Description}}</q-tooltip>
16
- {{Field.Label || ''}}
17
- <span
18
- v-if="Field.Required"
19
- class="required-mark"
20
- >*</span>
21
- </span>
22
- <span class="readonly-content">
23
- <span class="prefix" v-if="Field.Options && Field.Options.Prefix">
24
- {{Field.Options.Prefix}}
25
- </span>
26
- <span :style="(Field.Info && Field.Info.Style) ? Field.Info.Style : ''">
27
- {{callResult}}
28
- </span>
29
- <span
30
- class="postfix"
31
- v-if="Field.Options && Field.Options.Postfix"
32
- >{{Field.Options.Postfix}}</span>
33
- </span>
34
- </span>
35
- <slot name="warning"></slot>
36
- </div>
37
- </template>
38
-
39
- <script>
40
- import { defineComponent } from 'vue';
41
- import mixins from 'free-fe-mixins';
42
-
43
- export default defineComponent({
44
- name: 'InputFieldApiCall',
45
- mixins: [mixins.InputFieldMixin],
46
- fieldInfo: {
47
- Category: 'Advanced',
48
- Label: '特定接口处理',
49
- Value: 'ApiCall',
50
- Extra: [
51
- {
52
- Type: 'String',
53
- Label: '数据获取地址',
54
- Name: 'Options.Url',
55
- },
56
- {
57
- Type: 'String',
58
- Label: '传送字段名',
59
- Name: 'Options.Fields',
60
- Placeholder: '逗号分割',
61
- Tips: [
62
- {
63
- Text: '默认将传送当前字段数据,但可以指定相同数据层级下的其他字段。',
64
- },
65
- ],
66
- },
67
- {
68
- Type: 'String',
69
- Label: '附加字段名',
70
- Name: 'Options.ExtraFieldNames',
71
- Placeholder: '逗号分割',
72
- Tips: [
73
- {
74
- Text: '如果接口返回值中有这些字段,他们将会被赋予当前父数据中。',
75
- },
76
- ],
77
- },
78
- ],
79
- Description: '',
80
- },
81
- data() {
82
- return {
83
- callResult: '',
84
- };
85
- },
86
- watch: {
87
- fieldData() {
88
- this.apiCall();
89
- },
90
- },
91
- // created() {
92
- // this.apiCall();
93
- // },
94
- // updated() {
95
- // this.apiCall();
96
- // },
97
- methods: {
98
- apiCall() {
99
- this.Field.Options.Fields = this.Field.Options.Fields || this.Field.Name;
100
-
101
- if (!this.Field || !this.Field.Options || !this.Field.Options.Fields) {
102
- return;
103
- }
104
-
105
- const paramObj = {};
106
- if (this.Field.Options.Fields.length > 0) {
107
- if (typeof this.Field.Options.Fields === 'string') {
108
- this.Field.Options.Fields = this.Field.Options.Fields.split(',');
109
- }
110
- for (let i = 0; i < this.Field.Options.Fields.length; i += 1) {
111
- const fld = this.Field.Options.Fields[i];
112
-
113
- if (fld) {
114
- Object.setValue(paramObj, fld, Object.nestValue(this.data, fld));
115
- }
116
- }
117
- } else {
118
- Object.setValue(paramObj, this.Field.Name, this.fieldData);
119
- }
120
-
121
- this.postRequest(this.Field.Options.Url, paramObj).then((d) => {
122
- if (d && d.msg === 'OK') {
123
- if (d.data && d.data.value) {
124
- this.callResult = d.data.value;
125
- } else {
126
- this.callResult = d.data;
127
- }
128
-
129
- // other extra new fields
130
- (this.Field.Options.ExtraFieldNames || '').split(',').forEach((fname) => {
131
- //this.$set(this.data, fname, d.data[fname]);
132
- this.data[fname] = d.data[fname];
133
- });
134
- }
135
- });
136
- },
137
- },
138
- });
139
- </script>
@@ -1,33 +0,0 @@
1
- <template>
2
- <div
3
- v-if="typeof Field.Label !== 'undefined'"
4
- v-bind="$attrs"
5
- class="input-field-category simple-field row items-center no-wrap">
6
- <span class="label">{{Field.Label}}</span>
7
- <slot name="warning"></slot>
8
- </div>
9
- </template>
10
-
11
- <script>
12
- import { defineComponent } from 'vue';
13
- import mixins from 'free-fe-mixins';
14
-
15
- export default defineComponent({
16
- name: 'InputFieldCategory',
17
- mixins: [mixins.InputFieldMixin],
18
- fieldInfo: {
19
- Category: 'Static',
20
- Label: '字段分类',
21
- Value: 'Category',
22
- Description: '',
23
- },
24
- });
25
- </script>
26
-
27
- <style lang="sass" scoped>
28
- .field-category
29
- font-size: 14px
30
- font-weight: bold
31
- margin-top: 12px
32
- margin-bottom: 12px
33
- </style>
@@ -1,131 +0,0 @@
1
- <template>
2
- <span class="simple-field input-field-check row items-center no-wrap">
3
- <span>
4
- <span
5
- :class="`field-label ${(Field.Label && Field.Label.trim().length)
6
- ? '' : 'field-label-empty'} ${Field.Required ? 'required' : ''}`"
7
- v-if="Field.showLabel && !Field.dense && typeof Field.Label !== 'undefined'"
8
- >
9
- <q-tooltip
10
- v-if="Field.Description"
11
- anchor="top right"
12
- >{{Field.Description}}</q-tooltip>
13
- {{Field.Label || ''}}
14
- <span
15
- v-if="Field.Required"
16
- class="required-mark"
17
- >*</span>
18
- </span>
19
- <span v-else-if="!Field.showLabel && !Field.dense" class="field-label-empty"></span>
20
-
21
- <q-checkbox
22
- @input="$emit('input')"
23
- :disable="Field.ReadOnly"
24
- v-bind="$attrs"
25
- :label="!Field.showLabel ? Field.Label : ''"
26
- v-model="fieldData"
27
- />
28
- </span>
29
- <slot name="warning"></slot>
30
- </span>
31
- </template>
32
-
33
- <script>
34
- import { defineComponent } from 'vue';
35
- import mixins from 'free-fe-mixins';
36
-
37
- export default defineComponent({
38
- name: 'InputFieldCheck',
39
- mixins: [mixins.InputFieldMixin],
40
- fieldInfo: {
41
- Category: 'Simple',
42
- Label: '勾选',
43
- Value: 'Check',
44
- Extra: [
45
- {
46
- Type: 'FixedList',
47
- Label: '选项',
48
- Name: 'Options',
49
- Options: {
50
- Columns: [
51
- {
52
- Label: 'Label',
53
- Name: 'Label',
54
- ReadOnly: true,
55
- },
56
- {
57
- Label: 'Value',
58
- Name: 'Value',
59
- ReadOnly: true,
60
- },
61
- {
62
- Label: 'Extra',
63
- Name: 'Extra',
64
- Type: 'FieldList',
65
- Options: {
66
- Columns: [
67
- {
68
- Label: '#',
69
- Name: 'Index',
70
- },
71
- {
72
- Label: '名称',
73
- Name: 'Name',
74
- },
75
- {
76
- Label: '标题',
77
- Name: 'Label',
78
- },
79
- ],
80
- },
81
- },
82
- ],
83
- Default: [
84
- {
85
- Label: '选中',
86
- Value: true,
87
- Extra: [],
88
- },
89
- {
90
- Label: '未选',
91
- Value: false,
92
- Extra: [],
93
- },
94
- ],
95
- },
96
- },
97
- ],
98
- Description: '',
99
- },
100
- watch: {
101
- fieldData() {
102
- if (!this.fieldData) {
103
- this.fieldData = false;
104
- }
105
- },
106
- },
107
- created() {
108
- if (!this.fieldData) {
109
- this.fieldData = false;
110
- }
111
- },
112
- methods: {
113
- validate() {
114
- if (this.Field.Required) return typeof this.fieldData !== 'undefined';
115
-
116
- const rules = Array.isArray(typeof this.Field.Rules) ? this.Field.Rules : [this.Field.Rules];
117
-
118
- let isValid = true;
119
- for (let i = 0; i < rules.length; i += 1) {
120
- const r = rules[i];
121
-
122
- if (typeof r === 'function') {
123
- isValid = isValid && r(this.fieldData);
124
- }
125
- }
126
-
127
- return isValid;
128
- },
129
- },
130
- });
131
- </script>
@@ -1,103 +0,0 @@
1
- <template>
2
- <div class="input-field-customize">
3
- <span
4
- :class="`field-label field-label-readonly ${(Field.Label && Field.Label.trim().length)
5
- ? '' : 'field-label-empty'} ${Field.Required ? 'required' : ''}`"
6
- v-if="Field.Label"
7
- >
8
- <q-tooltip
9
- v-if="Field.Description"
10
- anchor="top right"
11
- >{{Field.Description}}</q-tooltip>
12
- {{Field.Label || ''}}
13
- <span
14
- v-if="Field.Required"
15
- class="required-mark"
16
- >*</span>
17
- </span>
18
-
19
- <span ref="content"></span>
20
-
21
- <slot name="warning"></slot>
22
- </div>
23
- </template>
24
-
25
- <script>
26
- import { defineComponent } from 'vue';
27
- import mixins from 'free-fe-mixins';
28
-
29
- export default defineComponent({
30
- name: 'InputFieldCustomize',
31
- mixins: [mixins.InputFieldMixin],
32
- fieldInfo: {
33
- Category: 'Advanced',
34
- Label: '自定义模板',
35
- Value: 'Customize',
36
- Extra: [
37
- {
38
- Type: 'Rich',
39
- Label: '模板',
40
- enableField: true,
41
- Name: 'Options.Template',
42
- },
43
- ],
44
- Description: '',
45
- },
46
- watch: {
47
- htmlContent() {
48
- this.$refs.content.innerHTML = this.htmlContent;
49
- },
50
- // fieldData() {
51
- // if (this.fieldData && this.$refs.content) {
52
- // this.$refs.content.innerHTML = this.generateContent(this.fieldData);
53
- // }
54
- // },
55
- },
56
- mounted() {
57
- if (this.htmlContent) {
58
- this.$refs.content.innerHTML = this.htmlContent;
59
- }
60
- },
61
- computed: {
62
- htmlContent() {
63
- const template = this.Field && this.Field.Options ? this.Field.Options.Template : '';
64
- if (!template) return '';
65
-
66
- if (!this.fieldData) return template;
67
-
68
- const replaced = template.replace(
69
- /<efield>{([^<]*)}<\/efield>/g,
70
- (match, name) => {
71
- if (this.fieldData[name]) {
72
- // could be options
73
- if (this.fieldData.StepsDefinition) {
74
- const cStep = this.fieldData.StepsDefinition.find(
75
- (s) => s.Index === this.fieldData.CurrentStep,
76
- );
77
- if (cStep && cStep.Fields) {
78
- const fld = cStep.Fields.find((f) => f.Name === name);
79
-
80
- if (fld && fld.Options && Array.isArray(fld.Options)) {
81
- const fVal = fld.Options.find(
82
- (o) => o.Value === this.fieldData[name],
83
- );
84
-
85
- if (fVal && fVal.Label) {
86
- return fVal.Label;
87
- }
88
- }
89
- }
90
- }
91
-
92
- // otherwise.
93
- return this.fieldData[name];
94
- }
95
- return '';
96
- },
97
- );
98
-
99
- return replaced;
100
- },
101
- },
102
- });
103
- </script>
@@ -1,142 +0,0 @@
1
- <template>
2
- <span class="simple-field input-field-date row items-center no-wrap">
3
- <span v-if="Field.ReadOnly">
4
- <span
5
- :class="`field-label field-label-readonly ${(Field.Label && Field.Label.trim().length)
6
- ? '' : 'field-label-empty'} ${Field.Required ? 'required' : ''}`"
7
- v-if="typeof Field.Label !== 'undefined'">
8
- <q-tooltip v-if="Field.Description" anchor="top right">{{Field.Description}}</q-tooltip>
9
- {{Field.Label || ''}}
10
- <span v-if="Field.Required" class="required-mark">*</span>
11
- </span>
12
- <span class="readonly-content">{{localData}}</span>
13
- </span>
14
- <q-input
15
- v-else
16
- v-model="localData"
17
- hide-bottom-space
18
- :readonly="Field.ReadOnly"
19
- v-bind="$attrs"
20
- @input="$emit('input')"
21
- :ref="`input_field_validator_date`"
22
- >
23
- <template v-slot:before v-if="typeof Field.Label !== 'undefined'">
24
- <span
25
- :class="`field-label ${(Field.Label && Field.Label.trim().length)
26
- ? '' : 'field-label-empty'} ${Field.Required ? 'required' : ''}`">
27
- <q-tooltip v-if="Field.Description" anchor="top right">{{Field.Description}}</q-tooltip>
28
- {{Field.Label || ''}}
29
- <span v-if="Field.Required" class="required-mark">*</span>
30
- </span>
31
- </template>
32
- <q-popup-proxy
33
- v-if="!Field.ReadOnly"
34
- ref="qDateProxy"
35
- transition-show="scale"
36
- transition-hide="scale"
37
- >
38
- <span class="row">
39
- <q-date
40
- v-model="localData"
41
- v-bind="$attrs"
42
- :options="dateOptions"
43
- today-btn
44
- mask="YYYY-MM-DD"
45
- :locale="locale"
46
- @input="() => {$refs.qDateProxy.hide();$emit('input')}"
47
- />
48
- </span>
49
- </q-popup-proxy>
50
- <template v-slot:append>
51
- <q-icon name="event" class="cursor-pointer">
52
- </q-icon>
53
- </template>
54
- </q-input>
55
- <slot name="warning"></slot>
56
- </span>
57
- </template>
58
-
59
- <script>
60
- import { defineComponent } from 'vue';
61
- import mixins from 'free-fe-mixins';
62
-
63
- export default defineComponent({
64
- name: 'InputFieldDate',
65
- mixins: [mixins.InputFieldMixin],
66
- fieldInfo: {
67
- Category: 'DateTime',
68
- Label: '日期',
69
- Value: 'Date',
70
- Extra: [
71
- {
72
- Type: 'String',
73
- Label: '最小值',
74
- Name: 'MinValue',
75
- },
76
- {
77
- Type: 'String',
78
- Label: '最大值',
79
- Name: 'MaxValue',
80
- },
81
- {
82
- Type: 'Boolean',
83
- Label: '最大至“现在”',
84
- Name: 'Info.TillNow',
85
- },
86
- {
87
- Type: 'Boolean',
88
- Label: '最小从“现在”',
89
- Name: 'Info.FromNow',
90
- },
91
- ],
92
- Description: '',
93
- },
94
- data() {
95
- return {
96
- localData: '',
97
- };
98
- },
99
- watch: {
100
- fieldData() {
101
- if (!this.fieldData) {
102
- this.localData = '';
103
- return;
104
- }
105
- this.localData = this.$options.filters.normalDate(this.fieldData);
106
- },
107
- localData() {
108
- this.fieldData = this.localData;
109
- },
110
- },
111
- computed: {
112
- locale() {
113
- return this.ctx.config.locales.find(
114
- (l) => l.locale === (this.ctx.config.locale || this.ctx.config.defaultLocale),
115
- ).calendar;
116
- },
117
- dateOptions() {
118
- if (this.Field.Options && (typeof this.Field.Options === 'function' || Array.isArray(this.Field.Options))) return this.Field.Options;
119
-
120
- let minDate = '1900/01/01';
121
- let maxDate = '2100/12/31';
122
-
123
- if (this.Field.MinValue) {
124
- minDate = this.Field.MinValue;
125
- }
126
-
127
- if (this.Field.MaxValue === 'now') {
128
- maxDate = new Date().toLocaleDateString();
129
- } else if (this.Field.MaxValue) {
130
- maxDate = this.Field.MaxValue;
131
- }
132
-
133
- return (date) => date >= minDate && date <= maxDate;
134
- },
135
- },
136
- });
137
- </script>
138
-
139
- <style lang="sass" scoped>
140
- .q-field--with-bottom
141
- padding-bottom: 0
142
- </style>