free-fe-core-modules 0.0.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.
Files changed (112) hide show
  1. package/README.md +7 -0
  2. package/components/.gitkeep +0 -0
  3. package/components/Basic/BreadCrumbs.vue +87 -0
  4. package/components/Basic/EIcon.vue +84 -0
  5. package/components/Basic/LeveledMenus.vue +92 -0
  6. package/components/Basic/SummaryHead.vue +312 -0
  7. package/components/Dialog/BasicDialog.vue +442 -0
  8. package/components/Dialog/index.js +38 -0
  9. package/components/Dialog/index1.js +49 -0
  10. package/components/FloatingWindow/index.vue +140 -0
  11. package/components/SelectLocales/index.vue +47 -0
  12. package/components/SlidingCarousel/index.vue +86 -0
  13. package/components/SlidingNews/index.vue +138 -0
  14. package/components/StickyButtons/index.vue +98 -0
  15. package/components/ThemeSwitch/index.vue +77 -0
  16. package/field-components/Display/index.js +3 -0
  17. package/field-components/Fields/AgreementCheck.vue +161 -0
  18. package/field-components/Fields/ApiCall.vue +139 -0
  19. package/field-components/Fields/Boolean.vue +112 -0
  20. package/field-components/Fields/Category.vue +33 -0
  21. package/field-components/Fields/Check.vue +131 -0
  22. package/field-components/Fields/Customize.vue +103 -0
  23. package/field-components/Fields/Date.vue +142 -0
  24. package/field-components/Fields/DateRange.vue +199 -0
  25. package/field-components/Fields/DynamicList.vue +575 -0
  26. package/field-components/Fields/FieldEditor.vue +379 -0
  27. package/field-components/Fields/File.vue +382 -0
  28. package/field-components/Fields/FileList.vue +405 -0
  29. package/field-components/Fields/FileListCombined.vue +142 -0
  30. package/field-components/Fields/FixedList.vue +372 -0
  31. package/field-components/Fields/Image.vue +328 -0
  32. package/field-components/Fields/ImageList.vue +285 -0
  33. package/field-components/Fields/ImageListCombined.vue +76 -0
  34. package/field-components/Fields/InputFieldList.vue +299 -0
  35. package/field-components/Fields/Labels.vue +182 -0
  36. package/field-components/Fields/MixedTable.vue +367 -0
  37. package/field-components/Fields/Number.vue +247 -0
  38. package/field-components/Fields/Password.vue +79 -0
  39. package/field-components/Fields/Permission.vue +83 -0
  40. package/field-components/Fields/PermissionEditor.vue +205 -0
  41. package/field-components/Fields/QueryFilters.vue +162 -0
  42. package/field-components/Fields/RadioList.vue +81 -0
  43. package/field-components/Fields/Rich.vue +369 -0
  44. package/field-components/Fields/Search.vue +499 -0
  45. package/field-components/Fields/Select.vue +376 -0
  46. package/field-components/Fields/SelectionChain.vue +198 -0
  47. package/field-components/Fields/Separator.vue +26 -0
  48. package/field-components/Fields/SingleList.vue +125 -0
  49. package/field-components/Fields/Static.vue +22 -0
  50. package/field-components/Fields/String.vue +185 -0
  51. package/field-components/Fields/Text.vue +89 -0
  52. package/field-components/Fields/Time.vue +160 -0
  53. package/field-components/Fields/TimeRange.vue +348 -0
  54. package/field-components/Fields/UltimateFile.vue +100 -0
  55. package/field-components/Fields/Year.vue +124 -0
  56. package/field-components/Fields/YearRange.vue +188 -0
  57. package/field-components/Fields/components/FieldTypeOptions.vue +248 -0
  58. package/field-components/Fields/index.js +117 -0
  59. package/field-components/components/FieldComponents.vue +246 -0
  60. package/field-components/index.js +13 -0
  61. package/field-components/style.sass +11 -0
  62. package/free-fields/AutoHide.js +66 -0
  63. package/free-fields/CenterContent.js +15 -0
  64. package/free-fields/Draggable.js +30 -0
  65. package/free-fields/Droppable.js +114 -0
  66. package/free-fields/EditableString.js +63 -0
  67. package/free-fields/FieldCategory.js +83 -0
  68. package/free-fields/FieldTypeSelect.js +94 -0
  69. package/free-fields/fieldEditors/arrayEditor.js +3 -0
  70. package/free-fields/fieldEditors/boolEditor.js +22 -0
  71. package/free-fields/fieldEditors/dateEditor.js +23 -0
  72. package/free-fields/fieldEditors/datetimeEditor.js +23 -0
  73. package/free-fields/fieldEditors/index.js +21 -0
  74. package/free-fields/fieldEditors/jsonEditor.js +371 -0
  75. package/free-fields/fieldEditors/labeledField.js +74 -0
  76. package/free-fields/fieldEditors/numberEditor.js +51 -0
  77. package/free-fields/fieldEditors/objectEditor.js +3 -0
  78. package/free-fields/fieldEditors/selectEditor.js +0 -0
  79. package/free-fields/fieldEditors/stringEditor.js +49 -0
  80. package/free-fields/fieldEditors/textEditor.js +50 -0
  81. package/free-fields/fieldEditors/timeEditor.js +23 -0
  82. package/free-fields/index.js +402 -0
  83. package/i18n/en-us/index.js +73 -0
  84. package/i18n/fields/en-us/index.js +9 -0
  85. package/i18n/fields/zh-cn/index.js +9 -0
  86. package/i18n/zh-cn/index.js +73 -0
  87. package/index.js +367 -0
  88. package/package.json +11 -0
  89. package/router/dict/api.js +18 -0
  90. package/router/dict/data.js +48 -0
  91. package/router/dict/index.js +7 -0
  92. package/router/error/api.js +14 -0
  93. package/router/error/data.js +33 -0
  94. package/router/error/index.js +9 -0
  95. package/router/index.js +13 -0
  96. package/router/menu/api.js +24 -0
  97. package/router/menu/data.js +85 -0
  98. package/router/menu/index.js +7 -0
  99. package/router/system/api.js +10 -0
  100. package/router/system/data.js +46 -0
  101. package/router/system/index.js +7 -0
  102. package/stores/index.js +17 -0
  103. package/stores/module-mourning/actions.js +3 -0
  104. package/stores/module-mourning/getters.js +1 -0
  105. package/stores/module-mourning/index.js +11 -0
  106. package/stores/module-mourning/state.js +3 -0
  107. package/stores/mourning.js +3 -0
  108. package/view/dict/index.vue +284 -0
  109. package/view/error/list.vue +197 -0
  110. package/view/menu/index.vue +332 -0
  111. package/view/mourning/mourning.vue +45 -0
  112. package/view/system/index.vue +149 -0
@@ -0,0 +1,86 @@
1
+ <template>
2
+ <q-carousel
3
+ animated
4
+ v-model="slide"
5
+ ref="carousel"
6
+ infinite
7
+ :transition-prev="transitionPrev"
8
+ :transition-next="transitionNext"
9
+ v-bind="$attrs"
10
+ :height="heightString"
11
+ :autoplay="interval"
12
+ :arrows="data && data.length > 0"
13
+ :swipeable="swipeable"
14
+ :thumbnails="thumbnails"
15
+ >
16
+ <q-carousel-slide
17
+ v-for="(carouse, index) in data"
18
+ :key="index"
19
+ :name="index"
20
+ :img-src="`${ctx.config.imageUrlBase}${carouse.img}`"
21
+ @click="clicked(carouse)"
22
+ />
23
+ <q-carousel-slide v-if="!data || !data.length" :name="0">
24
+ <div class="no-images-label flex full-height full-width">{{noImageText}}</div>
25
+ </q-carousel-slide>
26
+ </q-carousel>
27
+ </template>
28
+
29
+ <script>
30
+ import mixins from 'free-fe-mixins';
31
+ import { defineComponent } from 'vue';
32
+
33
+ export default defineComponent({
34
+ name: 'SlidingCarousel',
35
+ mixins: [mixins.ArrayDataMixin],
36
+ props: {
37
+ interval: { type: Number, default: 3000 },
38
+ height: { type: String, default: '220px' },
39
+ width: { type: String, default: '100%' },
40
+ noImageText: { type: String, default: '暂无图片' },
41
+ transitionPrev: { type: String, default: 'slide-right' },
42
+ transitionNext: { type: String, default: 'slide-left' },
43
+ swipeable: { type: Boolean, default: true },
44
+ thumbnails: { type: Boolean, default: true },
45
+ },
46
+ data() {
47
+ return {
48
+ slide: 0,
49
+ };
50
+ },
51
+ computed: {
52
+ heightString() {
53
+ if (!this.height) return '220px';
54
+
55
+ const num = this.height.match(/^[0-9]*/g);
56
+ if (!num || num.length <= 0) return '220px';
57
+
58
+ if (num[0] === this.height) return `${this.height}px`;
59
+
60
+ return this.height;
61
+ },
62
+ },
63
+ methods: {
64
+ clicked(carouse) {
65
+ if (carouse && carouse.url) {
66
+ if (/^(http|https):\/\/.*/.test(carouse.url)) {
67
+ // window.location.href = l;
68
+ window.open(carouse.url);
69
+ } else {
70
+ this.$router.push(carouse.url);
71
+ }
72
+ }
73
+ },
74
+ },
75
+ });
76
+ </script>
77
+
78
+ <style lang="sass" scoped>
79
+ .no-images-label
80
+ font-size: 18px
81
+ font-weight: bold
82
+ justify-content: center
83
+ align-items: center
84
+ background: $grey-5
85
+ color: $background
86
+ </style>
@@ -0,0 +1,138 @@
1
+ <template>
2
+ <div
3
+ v-if="visible"
4
+ class="row full-width sliding-news justify-center"
5
+ :class="(data && data.length) ? '' : 'empty'"
6
+ >
7
+ <span class="sliding-news-label row items-center">
8
+ <e-icon
9
+ :name="icon"
10
+ class="sliding-news-label-icon"
11
+ ></e-icon>
12
+ <span>{{label}}</span>
13
+ </span>
14
+ <q-carousel
15
+ v-model="slide"
16
+ ref="carousel"
17
+ :transition-prev="transitionPrev"
18
+ :transition-next="transitionNext"
19
+ class="col"
20
+ :height="heightString"
21
+ :autoplay="interval"
22
+ :navigation="false"
23
+ v-bind="$attrs"
24
+ animated
25
+ infinite
26
+ padding
27
+ vertical
28
+ >
29
+ <q-carousel-slide
30
+ v-for="(carouse, index) in data"
31
+ :key="index"
32
+ :name="index"
33
+ @click="newsClicked(carouse)"
34
+ style="cursor: pointer; padding: 0; margin: 0;"
35
+ >
36
+ <div class="row items-center justify-center full-height">
37
+ <span class="sliding-news-title">{{carouse.Title}}</span>
38
+ <q-space />
39
+ <span class="float-right sliding-news-right">
40
+ <span
41
+ class="sliding-news-date"
42
+ :style="`line-height: ${heightString}`"
43
+ >
44
+ {{filter('normalDate',(carouse.PublishDate || carouse.LastUpdateDate))}}
45
+ </span>
46
+ </span>
47
+ </div>
48
+ </q-carousel-slide>
49
+ </q-carousel>
50
+ <q-space />
51
+ <span
52
+ class="float-right sliding-news-right full-height"
53
+ style="margin: auto 0"
54
+ >
55
+ <q-btn
56
+ v-if="closable"
57
+ icon="close"
58
+ flat
59
+ dense
60
+ round
61
+ @click.stop="visible=false"
62
+ class="sliding-news-close-btn"
63
+ ></q-btn>
64
+ </span>
65
+ </div>
66
+ </template>
67
+
68
+ <script>
69
+ import mixins from 'free-fe-mixins';
70
+ import { defineComponent } from 'vue';
71
+
72
+ export default defineComponent({
73
+ name: 'SlidingNews',
74
+ mixins: [mixins.ArrayDataMixin],
75
+ props: {
76
+ interval: { type: Number, default: 3000 },
77
+ height: { type: String, default: '40px' },
78
+ width: { type: String, default: '100%' },
79
+ lines: { type: Number, default: 1 },
80
+ icon: { type: String, default: 'menu' },
81
+ label: { type: String, default: 'News: ' },
82
+ closable: { type: Boolean, default: true },
83
+ url: { type: String, default: '' },
84
+ transitionPrev: { type: String, default: 'slide-up' },
85
+ transitionNext: { type: String, default: 'slide-down' },
86
+ },
87
+ data() {
88
+ return {
89
+ visible: true,
90
+ slide: 0,
91
+ timer: undefined,
92
+ };
93
+ },
94
+ computed: {
95
+ heightString() {
96
+ if (!this.height) return '40px';
97
+
98
+ const num = this.height.match(/^[0-9]*/g);
99
+ if (!num || num.length <= 0) return '40px';
100
+
101
+ if (num[0] === this.height) return `${this.height}px`;
102
+
103
+ return this.height;
104
+ },
105
+ },
106
+ // watch: {
107
+ // visible() {
108
+ // if (!this.visible) {
109
+ // clearInterval(this.timer);
110
+ // }
111
+ // },
112
+ // },
113
+ // created() {
114
+ // this.timer = setInterval(this.carouselNext, this.interval);
115
+ // },
116
+ methods: {
117
+ newsClicked(news) {
118
+ let url = '';
119
+ if (news.url) url += news.url;
120
+ else if (this.url) url += `${this.url}${news.id || ''}`;
121
+
122
+ if (url && this.$route.fullPath !== url) {
123
+ this.$router.push({ path: url });
124
+ }
125
+ },
126
+ // carouselNext() {
127
+ // if (!this.data || this.data.length < 2 || !this.$refs.carousel) {
128
+ // return;
129
+ // }
130
+
131
+ // this.$refs.carousel.next();
132
+ // },
133
+ },
134
+ // beforeUnmount() {
135
+ // clearInterval(this.timer);
136
+ // },
137
+ });
138
+ </script>
@@ -0,0 +1,98 @@
1
+ <template>
2
+ <q-page-sticky
3
+ class="print-hide sticky-button"
4
+ :position="position"
5
+ :offset="stickyOffset"
6
+ v-if="visibleActions && visibleActions.length > 0"
7
+ >
8
+ <div v-if="!fab" class="column">
9
+ <q-btn
10
+ v-for="(action, index) in visibleActions"
11
+ :key="index"
12
+ fab
13
+ :icon="action.icon || ''"
14
+ :class="[action.class || '', `sticky-button-${action.Action}`]"
15
+ @click="$emit('click', action)"
16
+ :disable="draggingSticky"
17
+ v-touch-pan.prevent.mouse="moveSticky"
18
+ :label="showLabel ? action.Label : ''"
19
+ />
20
+ </div>
21
+ <q-fab
22
+ v-else
23
+ :icon="fabIcon"
24
+ :direction="direction"
25
+ :color="stickyColor"
26
+ :disable="draggingSticky"
27
+ v-touch-pan.prevent.mouse="moveSticky"
28
+ >
29
+ <q-fab-action
30
+ v-for="(action, index) in visibleActions"
31
+ :key="index"
32
+ @click="$emit('click', action)"
33
+ :class="[action.class || '', `sticky-button-${action.Action}`]"
34
+ :icon="action.icon || ''"
35
+ :disable="draggingSticky"
36
+ :label="showLabel ? action.Label : ''"
37
+ />
38
+ </q-fab>
39
+ </q-page-sticky>
40
+ </template>
41
+
42
+ <script>
43
+ import { defineComponent } from 'vue';
44
+
45
+ export default defineComponent({
46
+ name: 'StickyButtons',
47
+ emits: ['click'],
48
+ props: {
49
+ position: { type: String, default: 'bottom-right' },
50
+ offset: { type: Array, default: () => [36, 128, 0, 0] },
51
+ fab: { type: Boolean, default: true },
52
+ fabIcon: { type: String, default: 'add' },
53
+ fabColor: { type: String, default: '' },
54
+ direction: { type: String, default: 'up' },
55
+ actions: { type: Array, default: () => [] },
56
+ showLabel: { type: Boolean, default: true },
57
+ buttonsVisible: { type: Function, default: () => true },
58
+ },
59
+ data() {
60
+ return {
61
+ stickyOffset: [36, 128, 0, 0],
62
+ draggingSticky: false,
63
+ };
64
+ },
65
+ created() {
66
+ if (this.offset) {
67
+ this.stickyOffset = this.offset;
68
+ }
69
+ },
70
+ computed: {
71
+ stickyColor() {
72
+ return this.fabColor || this.ctx.config.stickyColor;
73
+ },
74
+ visibleActions() {
75
+ let actions = [];
76
+ (this.actions || []).filter(act => this.buttonsVisible(act)).forEach((action) => {
77
+ if (Array.isArray(action)) {
78
+ actions = actions.concat(action);
79
+ } else {
80
+ actions.push(action);
81
+ }
82
+ });
83
+
84
+ return actions;
85
+ },
86
+ },
87
+ methods: {
88
+ moveSticky(ev) {
89
+ this.draggingSticky = ev.isFirst !== true && ev.isFinal !== true;
90
+
91
+ this.stickyOffset = [
92
+ this.stickyOffset[0] - ev.delta.x,
93
+ this.stickyOffset[1] - ev.delta.y,
94
+ ];
95
+ },
96
+ },
97
+ });
98
+ </script>
@@ -0,0 +1,77 @@
1
+ <template>
2
+ <div>
3
+ <component v-if="theme" :is="themeComponents[theme]"></component>
4
+ <q-btn
5
+ flat
6
+ :icon="icon"
7
+ v-if="themes && themes[1]"
8
+ :label="dense ? '' : $t('SwitchTheme')">
9
+ <q-menu>
10
+ <q-list>
11
+ <q-item
12
+ v-for="(tm, index) in themes"
13
+ :key="index"
14
+ clickable
15
+ v-close-popup
16
+ @click="theme = tm"
17
+ >
18
+ <q-item-section>{{$t(tm)}}</q-item-section>
19
+ </q-item>
20
+ </q-list>
21
+ </q-menu>
22
+ </q-btn>
23
+ </div>
24
+ </template>
25
+
26
+ <script>
27
+ import { defineComponent } from 'vue';
28
+
29
+ export default defineComponent({
30
+ name: 'ThemeSwitch',
31
+ props: {
32
+ icon: { type: String, default: 'fas fa-palette' },
33
+ dense: { type: Boolean, default: true },
34
+ },
35
+ data() {
36
+ return {
37
+ theme: '',
38
+ };
39
+ },
40
+ computed: {
41
+ themeComponents() {
42
+ const components = {};
43
+
44
+ Object.keys(this.ctx.modules)
45
+ .filter((m) => this.ctx.modules[m].IsTheme)
46
+ .forEach((m) => {
47
+ Object.assign(components, this.ctx.modules[m].components || {});
48
+ });
49
+
50
+ return components;
51
+ },
52
+ themes() {
53
+ return Object.keys(this.themeComponents);
54
+ },
55
+ },
56
+ watch: {
57
+ theme(v) {
58
+ if (v) {
59
+ const appEle = document.getElementById('q-app');
60
+
61
+ let arr = appEle.className.split(' ');
62
+
63
+ arr = arr.filter(cl => !cl.startsWith('theme-'));
64
+
65
+ arr.push(`theme-${v}`);
66
+
67
+ appEle.className = arr.join(' ');
68
+ }
69
+ },
70
+ },
71
+ created() {
72
+ if (this.themes && this.themes.length > 0) {
73
+ this.theme = this.themes[0];
74
+ }
75
+ },
76
+ });
77
+ </script>
@@ -0,0 +1,3 @@
1
+ export default {
2
+
3
+ };
@@ -0,0 +1,161 @@
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>
@@ -0,0 +1,139 @@
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>