free-fe-core-modules 0.0.2 → 0.0.3

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 +10 -1
  4. package/components/Dialog/BasicDialog.vue +1 -1
  5. package/components/SlidingCarousel/index.vue +0 -1
  6. package/components/SlidingNews/index.vue +0 -1
  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/File.vue +1 -1
  19. package/{field-components → free-field}/Fields/FileList.vue +1 -1
  20. package/{field-components → free-field}/Fields/FileListCombined.vue +1 -1
  21. package/{field-components → free-field}/Fields/FixedList.vue +78 -83
  22. package/{field-components → free-field}/Fields/ImageList.vue +1 -1
  23. package/{field-components → free-field}/Fields/ImageListCombined.vue +1 -1
  24. package/free-field/Fields/InputFieldList.vue +324 -0
  25. package/{field-components → free-field}/Fields/Labels.vue +24 -15
  26. package/{field-components → free-field}/Fields/MixedTable.vue +53 -61
  27. package/free-field/Fields/Number.js +167 -0
  28. package/free-field/Fields/Password.js +81 -0
  29. package/{field-components → free-field}/Fields/Permission.vue +17 -13
  30. package/{field-components → free-field}/Fields/PermissionEditor.vue +63 -105
  31. package/{field-components → free-field}/Fields/QueryFilters.vue +65 -48
  32. package/{field-components → free-field}/Fields/RadioList.vue +36 -12
  33. package/{field-components → free-field}/Fields/Rich.vue +104 -114
  34. package/{field-components → free-field}/Fields/Search.vue +35 -26
  35. package/{field-components → free-field}/Fields/Select.vue +116 -87
  36. package/{field-components → free-field}/Fields/SelectionChain.vue +89 -67
  37. package/{field-components/Fields/Separator.vue → free-field/Fields/Separator.js} +11 -16
  38. package/{field-components → free-field}/Fields/SingleList.vue +27 -21
  39. package/free-field/Fields/Static.js +27 -0
  40. package/free-field/Fields/String.js +105 -0
  41. package/free-field/Fields/Text.js +80 -0
  42. package/{field-components → free-field}/Fields/Time.vue +59 -43
  43. package/{field-components → free-field}/Fields/TimeRange.vue +107 -92
  44. package/{field-components → free-field}/Fields/UltimateFile.vue +1 -1
  45. package/free-field/Fields/Year.js +137 -0
  46. package/{field-components → free-field}/Fields/YearRange.vue +63 -73
  47. package/{field-components → free-field}/Fields/index.js +16 -18
  48. package/free-field/composible/fieldWrapper.js +221 -0
  49. package/free-field/composible/freeFieldLabel.js +22 -0
  50. package/free-field/composible/readonlyContent.js +36 -0
  51. package/free-field/composible/useFileSizeUtils.js +52 -0
  52. package/free-field/composible/useFreeField.js +143 -0
  53. package/{field-components → free-field}/index.js +3 -3
  54. package/i18n/en-us/index.js +1 -1
  55. package/i18n/zh-cn/index.js +1 -1
  56. package/index.js +1 -4
  57. package/package.json +1 -1
  58. package/router/error/data.js +4 -1
  59. package/view/dict/index.vue +13 -2
  60. package/view/error/list.vue +22 -14
  61. package/view/menu/index.vue +19 -4
  62. package/view/system/index.vue +15 -2
  63. package/field-components/Fields/AgreementCheck.vue +0 -161
  64. package/field-components/Fields/ApiCall.vue +0 -139
  65. package/field-components/Fields/Category.vue +0 -33
  66. package/field-components/Fields/Check.vue +0 -131
  67. package/field-components/Fields/Customize.vue +0 -103
  68. package/field-components/Fields/Date.vue +0 -142
  69. package/field-components/Fields/DateRange.vue +0 -199
  70. package/field-components/Fields/DynamicList.vue +0 -575
  71. package/field-components/Fields/FieldEditor.vue +0 -379
  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/Year.vue +0 -124
  79. package/field-components/Fields/components/FieldTypeOptions.vue +0 -248
  80. package/field-components/components/FieldComponents.vue +0 -246
  81. package/free-fields/AutoHide.js +0 -66
  82. package/free-fields/CenterContent.js +0 -15
  83. package/free-fields/Draggable.js +0 -30
  84. package/free-fields/Droppable.js +0 -114
  85. package/free-fields/EditableString.js +0 -63
  86. package/free-fields/FieldCategory.js +0 -83
  87. package/free-fields/FieldTypeSelect.js +0 -94
  88. package/free-fields/fieldEditors/arrayEditor.js +0 -3
  89. package/free-fields/fieldEditors/boolEditor.js +0 -22
  90. package/free-fields/fieldEditors/dateEditor.js +0 -23
  91. package/free-fields/fieldEditors/datetimeEditor.js +0 -23
  92. package/free-fields/fieldEditors/index.js +0 -21
  93. package/free-fields/fieldEditors/jsonEditor.js +0 -371
  94. package/free-fields/fieldEditors/labeledField.js +0 -74
  95. package/free-fields/fieldEditors/numberEditor.js +0 -51
  96. package/free-fields/fieldEditors/objectEditor.js +0 -3
  97. package/free-fields/fieldEditors/selectEditor.js +0 -0
  98. package/free-fields/fieldEditors/stringEditor.js +0 -49
  99. package/free-fields/fieldEditors/textEditor.js +0 -50
  100. package/free-fields/fieldEditors/timeEditor.js +0 -23
  101. package/free-fields/index.js +0 -402
  102. /package/{field-components → free-field}/Fields/Image.vue +0 -0
  103. /package/{field-components/Display → free-field/Layout}/index.js +0 -0
  104. /package/{field-components → free-field}/style.sass +0 -0
@@ -0,0 +1,52 @@
1
+ export function fileSizeStrToNumber (s) {
2
+ if (!s) return undefined;
3
+
4
+ const sizeMatch = s.match(/^([0-9]*)(k|m|g*)(b*)/);
5
+
6
+ if (sizeMatch) {
7
+ const num = Number(sizeMatch[1] || 0);
8
+ const unit = (sizeMatch[2] || '').toLowerCase();
9
+ if (!num || !(num > -Infinity)) return '';
10
+
11
+ let multi = 1;
12
+ switch (unit) {
13
+ case 'k':
14
+ multi = 1024;
15
+ break;
16
+ case 'm':
17
+ multi = 1024 * 1024;
18
+ break;
19
+ case 'g':
20
+ multi = 1024 * 1024 * 1024;
21
+ break;
22
+ default:
23
+ multi = 1024;
24
+ break;
25
+ }
26
+
27
+ return Number(num) * multi;
28
+ }
29
+
30
+ return undefined;
31
+ }
32
+
33
+ export function fileSizeNumberToStr (s) {
34
+ if (!s) return '0K';
35
+
36
+ let sizeNum = Number(s) || 0;
37
+
38
+ if (!sizeNum || sizeNum <= 0) return '0K';
39
+
40
+ const unitList = ['B', 'K', 'M', 'G', 'T', 'P', 'E'];
41
+ let unit = 'B';
42
+ let unitIndex = 0;
43
+
44
+ while (sizeNum >= 1024) {
45
+ if (unit === 'E') break;
46
+
47
+ unit = unitList[++unitIndex];
48
+ sizeNum /= 1024;
49
+ }
50
+
51
+ return `${sizeNum.toFixed(2)}${unit}`;
52
+ }
@@ -0,0 +1,143 @@
1
+ import { reactive, watch, watchEffect } from "vue";
2
+
3
+ export const freeFieldProps = {
4
+ values: { type: Object },
5
+ Field: { type: Object },
6
+ };
7
+
8
+ export function useFreeField(props) {
9
+ const fieldData = reactive({});
10
+
11
+ watchEffect(() => {
12
+ fieldData.value = Object.nestValue(props.values, props.Field?.Name);
13
+
14
+ // TODO:following is from the old mixins, should we add more logic here accordingly?
15
+ // let realData;
16
+ // if (!this.Field) {
17
+ // // return undefined;
18
+ // } else if (!this.Field.Name) {
19
+ // // this.fieldData = this.Field.Value || this.Field.Default || undefined;
20
+ // realData = this.Field.Value || this.Field.Default || undefined;
21
+ // } else {
22
+ // let isnull = false;
23
+ // if (this.Field && this.Field.Info && this.Field.Info.Dynamic && this.Field.Value) {
24
+ // realData = this.Field.Value;
25
+ // isnull = typeof realData === 'undefined';
26
+ // } else {
27
+ // realData = this.data;
28
+
29
+ // if (this.Field.Name !== '.') {
30
+ // const nameList = this.Field.Name.split('.');
31
+
32
+ // for (let i = 0; i < nameList.length; i += 1) {
33
+ // const name = nameList[i];
34
+
35
+ // // if (!realData) return undefined;
36
+ // if (typeof realData === 'undefined' || realData === null) {
37
+ // isnull = true;
38
+ // break;
39
+ // } else {
40
+ // realData = name ? realData[name] : realData;
41
+ // }
42
+ // }
43
+ // }
44
+ // }
45
+
46
+ // if (!isnull) {
47
+ // // for non-dynamic field, which have refer data, we should save this data into the field
48
+ // if ((typeof realData === 'undefined') && (this.Field.Value || this.Field.Default)) {
49
+ // realData = this.Field.Value || this.Field.Default;
50
+
51
+ // if (this.Field && this.Field.ReferTo && (!this.Field.Info || !this.Field.Info.Dynamic)) {
52
+ // this.$emit('input');
53
+ // }
54
+ // }
55
+
56
+ // // realData = (typeof realData === 'undefined') ? (this.Field.Value || this.Field.Default) : realData;
57
+
58
+ // if (this.Field.Options && this.Field.Options.Filters) {
59
+ // let filters = [];
60
+ // if (typeof this.Field.Options.Filters === 'string') {
61
+ // // only one filter
62
+ // filters.push(this.Field.Options.Filters);
63
+ // } else if (Array.isArray(this.Field.Options.Filters)) {
64
+ // filters = filters.concat(this.Field.Options.Filters);
65
+ // }
66
+
67
+ // for (let i = 0; i < filters.length; i += 1) {
68
+ // const f = filters[i];
69
+ // const filter = this.$options.filters[f];
70
+ // if (filter) {
71
+ // realData = filter(realData);
72
+ // }
73
+ // }
74
+ // }
75
+ // }
76
+ // }
77
+
78
+ // if ((typeof realData === 'undefined' || realData === null || !realData) && this.Field.Info && this.Field.Info.ShowNaN) {
79
+ // return this.ctx.config.nanPlaceholder || '';
80
+ // }
81
+
82
+ // return realData;
83
+ });
84
+
85
+ return {
86
+ fieldData,
87
+ getFieldData: (n) => Object.nestValue(props.values, n),
88
+ setFieldData: (v, emit, evt = 'input') => {
89
+ fieldData.value = v;
90
+ Object.setValue(props.values, props.Field?.Name, v);
91
+
92
+ if (emit) emit(evt, v);
93
+ },
94
+ setData: (n, v) => {
95
+ Object.setValue(props.values, n, v);
96
+ },
97
+ }
98
+ };
99
+
100
+
101
+ // TODO: make function for validating all fields in the current component
102
+ function validate() {
103
+ if (this.shouldHide) return true;
104
+
105
+ // could have customized validate function in component
106
+ if (this.selfValidate && typeof this.selfValidate === 'function' && !this.selfValidate()) {
107
+ return false;
108
+ }
109
+
110
+ const validators = Object.keys(this.$refs).filter((k) => k.startsWith('input_field_validator_'));
111
+ if (!validators || validators.length <= 0) {
112
+ return true;
113
+ }
114
+
115
+ let hasError = false;
116
+ for (let i = 0; i < validators.length; i += 1) {
117
+ const valid = validators[i];
118
+
119
+ if (this.$refs[valid]) {
120
+ if (Array.isArray(this.$refs[valid])) {
121
+ for (let j = 0; j < this.$refs[valid].length; j += 1) {
122
+ const sv = this.$refs[valid][j];
123
+
124
+ if (sv.shouldHide !== true) {
125
+ if (typeof sv.validate === 'function') {
126
+ hasError = !sv.validate() || hasError;
127
+ }
128
+ }
129
+ }
130
+ } else if (typeof this.$refs[valid].validate === 'function') {
131
+ if (this.$refs[valid].shouldHide !== true) {
132
+ hasError = !this.$refs[valid].validate() || hasError;
133
+ }
134
+ }
135
+ }
136
+ }
137
+
138
+ return !hasError;
139
+ };
140
+
141
+ export const useFreeFieldMethods = {
142
+ validate,
143
+ };
@@ -1,6 +1,6 @@
1
1
  import fields from './Fields';
2
- import display from './Display';
3
- import FreeField from './components/FieldComponents.vue';
2
+ import layout from './Layout';
3
+ import FreeField from './composible/fieldWrapper.js';
4
4
 
5
5
  export default {
6
6
  components: {
@@ -8,6 +8,6 @@ export default {
8
8
  },
9
9
  fieldComponents: {
10
10
  ...fields,
11
- ...display,
11
+ ...layout,
12
12
  },
13
13
  };
@@ -39,7 +39,7 @@ export default {
39
39
  validatorOnlyCNUDescription: "",
40
40
  validatorOnlyCNSName: "只能是中文或数字或特殊字符",
41
41
  validatorOnlyCNSDescription:
42
- '只能是中文或数字或("."、"@"、"<"、">"、"_"、"?")',
42
+ `只能是中文或数字或("."、{'@'}、"<"、">"、"_"、"?")`,
43
43
 
44
44
  validatorOnlyIntegerName: "只能是整数",
45
45
  validatorOnlyIntegerDescription: "",
@@ -39,7 +39,7 @@ export default {
39
39
  validatorOnlyCNUDescription: "",
40
40
  validatorOnlyCNSName: "只能是中文或数字或特殊字符",
41
41
  validatorOnlyCNSDescription:
42
- '只能是中文或数字或("."、"@"、"<"、">"、"_"、"?")',
42
+ `只能是中文或数字或("."、{'@'}、"<"、">"、"_"、"?")`,
43
43
 
44
44
  validatorOnlyIntegerName: "只能是整数",
45
45
  validatorOnlyIntegerDescription: "",
package/index.js CHANGED
@@ -15,8 +15,7 @@ import ThemeSwitch from './components/ThemeSwitch/index.vue';
15
15
 
16
16
  import Mourning from './view/mourning/mourning.vue';
17
17
 
18
- import FieldComponents from './field-components';
19
- import FreeFields from './free-fields';
18
+ import FieldComponents from './free-field';
20
19
  import routers from './router';
21
20
 
22
21
  // global filters
@@ -136,7 +135,6 @@ const filters = {
136
135
  };
137
136
 
138
137
  export default (app, root) => {
139
- console.error('register dialog')
140
138
  root.use(MsgDialog);
141
139
 
142
140
  return {
@@ -278,7 +276,6 @@ export default (app, root) => {
278
276
  BreadCrumbs,
279
277
  ThemeSwitch,
280
278
  ...FieldComponents.components,
281
- ...FreeFields,
282
279
  Mourning,
283
280
  },
284
281
  fieldComponents: FieldComponents.fieldComponents,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "free-fe-core-modules",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "main": "index.js",
5
5
  "repository": "git@gitlab.com:eis-base/modules/free-fe-core-modules.git",
6
6
  "author": "zhiquan",
@@ -1,6 +1,9 @@
1
1
  // import Vue from 'vue';
2
2
  import { getErrorCode } from './api';
3
3
 
4
+ import { i18n } from '@/boot/i18n';
5
+ const {global:{t}} = i18n;
6
+
4
7
  // const bus = new Vue();
5
8
 
6
9
  export default {
@@ -19,7 +22,7 @@ export default {
19
22
 
20
23
  d.summary = [
21
24
  {
22
- text: '代码数',
25
+ text: t('代码数'),
23
26
  number: d.total || '0',
24
27
  number_color: 'red',
25
28
  icon: app.config.countIcon || 'fas fa-calculator',
@@ -82,13 +82,13 @@
82
82
  </template>
83
83
 
84
84
  <script>
85
- import mixins from 'free-fe-mixins';
86
85
  import { defineComponent } from 'vue';
86
+ import { useObjectData, objectDataProps } from '../../composible/useObjectData';
87
87
 
88
88
  export default defineComponent({
89
89
  name: 'DictionaryPage',
90
- mixins: [mixins.ObjectDataMixin],
91
90
  props: {
91
+ ...objectDataProps,
92
92
  addDict: { type: Function, default: () => {} },
93
93
  editDict: { type: Function, default: () => {} },
94
94
  deleteDict: { type: Function, default: () => {} },
@@ -100,6 +100,17 @@ export default defineComponent({
100
100
  dictFields: [],
101
101
  };
102
102
  },
103
+ setup(props, ctx) {
104
+ const {
105
+ data,
106
+ refreshData,
107
+ } = useObjectData(props, ctx);
108
+
109
+ return {
110
+ data,
111
+ refreshData,
112
+ };
113
+ },
103
114
  watch: {
104
115
  // eslint-disable-next-line func-names
105
116
  'editingDict.Type': function (v) {
@@ -2,6 +2,8 @@
2
2
  <div class="flow-list">
3
3
  <summary-head :values="data.summary" :Bus="Bus"></summary-head>
4
4
  <q-table
5
+ flat
6
+ bordered
5
7
  :rows="data ? data.docs : []"
6
8
  :columns="columns"
7
9
  row-key="id"
@@ -48,9 +50,9 @@
48
50
  </template>
49
51
 
50
52
  <template v-slot:top-row>
51
- <q-tr class="persistant-top-row full-width">
53
+ <!-- <q-tr class="persistant-top-row full-width">
52
54
  <q-td class="full-width" colspan="100%"></q-td>
53
- </q-tr>
55
+ </q-tr> -->
54
56
  <q-tr v-if="showFilters" class="table-row filter-row">
55
57
  <q-td colspan="100%" class="table-cell filter-cell">
56
58
  <free-field
@@ -87,16 +89,27 @@
87
89
  </template>
88
90
 
89
91
  <script>
90
- import mixins from 'free-fe-mixins';
91
- import { updateErrorCode, updateDescription } from '../../router/error/api';
92
92
  import { defineComponent } from 'vue';
93
+ import { useObjectData, objectDataProps } from '../../composible/useObjectData';
94
+ import { updateErrorCode, updateDescription } from '../../router/error/api';
93
95
 
94
96
  export default defineComponent({
95
97
  name: 'ErrorCodeList',
96
- mixins: [mixins.ObjectDataMixin],
97
98
  props: {
99
+ ...objectDataProps,
98
100
  pagination: { type: Boolean, default: true },
99
101
  },
102
+ setup(props, ctx) {
103
+ const {
104
+ data,
105
+ refreshData,
106
+ } = useObjectData(props, ctx);
107
+
108
+ return {
109
+ data,
110
+ refreshData,
111
+ };
112
+ },
100
113
  data() {
101
114
  return {
102
115
  queryFilter: {},
@@ -113,25 +126,25 @@ export default defineComponent({
113
126
  },
114
127
  {
115
128
  name: 'date',
116
- label: '日期',
129
+ label: this.$t('日期'),
117
130
  field: 'LastUpdateDate',
118
131
  filters: 'normalDate',
119
132
  style: 'max-width: 200px;',
120
133
  },
121
134
  {
122
135
  name: 'code',
123
- label: '代码',
136
+ label: this.$t('代码'),
124
137
  field: 'Code',
125
138
  style: 'max-width: 120px;',
126
139
  },
127
140
  {
128
141
  name: 'message',
129
- label: '信息',
142
+ label: this.$t('信息'),
130
143
  field: 'Message',
131
144
  },
132
145
  {
133
146
  name: 'description',
134
- label: '描述',
147
+ label: this.$t('描述'),
135
148
  field: 'Description',
136
149
  },
137
150
  ],
@@ -190,8 +203,3 @@ export default defineComponent({
190
203
  beforeUnmount() {},
191
204
  });
192
205
  </script>
193
-
194
- <style lang="sass" scoped>
195
- .persistant-top-row
196
- display: none
197
- </style>
@@ -86,17 +86,29 @@
86
86
  </template>
87
87
 
88
88
  <script>
89
- import mixins from 'free-fe-mixins';
90
89
  import { defineComponent } from 'vue';
90
+ import { useObjectData, objectDataProps } from '../../composible/useObjectData';
91
91
 
92
92
  export default defineComponent({
93
93
  name: 'MenuPage',
94
- mixins: [mixins.ObjectDataMixin, mixins.InputFieldValidator],
94
+ mixins: [mixins.InputFieldValidator],
95
95
  props: {
96
+ ...objectDataProps,
96
97
  addMenu: { type: Function, default: () => { } },
97
98
  editMenu: { type: Function, default: () => { } },
98
99
  deleteMenu: { type: Function, default: () => { } },
99
100
  },
101
+ setup(props, ctx) {
102
+ const {
103
+ data,
104
+ refreshData,
105
+ } = useObjectData(props, ctx);
106
+
107
+ return {
108
+ data,
109
+ refreshData,
110
+ };
111
+ },
100
112
  data() {
101
113
  return {
102
114
  selectedMenuNode: {},
@@ -154,12 +166,12 @@ export default defineComponent({
154
166
 
155
167
  // add the customize input option
156
168
  m.Options.push({
157
- Label: '自定义',
169
+ Label: this.$t('自定义'),
158
170
  Value: 'customize',
159
171
  Extra: [
160
172
  {
161
173
  Name: 'CustomizeRoute',
162
- Label: '自定义路径',
174
+ Label: this.$t('自定义路径'),
163
175
  },
164
176
  ],
165
177
  });
@@ -322,6 +334,9 @@ export default defineComponent({
322
334
  this.onCancelClick();
323
335
  }
324
336
  },
337
+ fieldInput(e) {
338
+ console.log(e)
339
+ }
325
340
  },
326
341
  });
327
342
  </script>
@@ -4,6 +4,8 @@
4
4
  class="step-left flow-step system-config-wrapper"
5
5
  v-if="data && data.StepsDefinition && data.StepsDefinition.length"
6
6
  v-model="currentStep"
7
+ flat
8
+ bordered
7
9
  animated
8
10
  header-nav
9
11
  >
@@ -77,16 +79,27 @@
77
79
  </template>
78
80
 
79
81
  <script>
80
- import mixins from 'free-fe-mixins';
81
82
  import { updateConfig } from '../../router/system/api';
82
83
  import { defineComponent } from 'vue';
84
+ import { useObjectData, objectDataProps } from '../../composible/useObjectData';
83
85
 
84
86
  export default defineComponent({
85
87
  name: 'SystemConfigPage',
86
- mixins: [mixins.ObjectDataMixin],
87
88
  props: {
89
+ ...objectDataProps,
88
90
  buttonsVisible: { type: Function, default: () => true },
89
91
  },
92
+ setup(props, ctx) {
93
+ const {
94
+ data,
95
+ refreshData,
96
+ } = useObjectData(props, ctx);
97
+
98
+ return {
99
+ data,
100
+ refreshData,
101
+ };
102
+ },
90
103
  data() {
91
104
  return {
92
105
  currentStep: 1,
@@ -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>