cnhis-design-vue 2.1.21 → 2.1.22

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 (122) hide show
  1. package/CHANGELOG.md +2270 -2270
  2. package/es/affix/index.js +8 -8
  3. package/es/age/index.js +10 -10
  4. package/es/alert/index.js +8 -8
  5. package/es/anchor/index.js +8 -8
  6. package/es/auto-complete/index.js +8 -8
  7. package/es/avatar/index.js +8 -8
  8. package/es/back-top/index.js +8 -8
  9. package/es/badge/index.js +8 -8
  10. package/es/base/index.js +8 -8
  11. package/es/big-table/index.js +205 -195
  12. package/es/big-table/style.css +1 -1
  13. package/es/breadcrumb/index.js +8 -8
  14. package/es/button/index.js +31 -31
  15. package/es/calendar/index.js +8 -8
  16. package/es/captcha/index.js +3 -3
  17. package/es/card/index.js +8 -8
  18. package/es/carousel/index.js +8 -8
  19. package/es/cascader/index.js +8 -8
  20. package/es/checkbox/index.js +9 -9
  21. package/es/col/index.js +8 -8
  22. package/es/collapse/index.js +8 -8
  23. package/es/color-picker/index.js +1 -1
  24. package/es/comment/index.js +8 -8
  25. package/es/config-provider/index.js +8 -8
  26. package/es/date-picker/index.js +8 -8
  27. package/es/descriptions/index.js +8 -8
  28. package/es/divider/index.js +8 -8
  29. package/es/drag-layout/index.js +3 -3
  30. package/es/drawer/index.js +8 -8
  31. package/es/dropdown/index.js +8 -8
  32. package/es/editor/index.js +1 -1
  33. package/es/empty/index.js +8 -8
  34. package/es/fabric-chart/index.js +138 -100
  35. package/es/form/index.js +8 -8
  36. package/es/form-model/index.js +8 -8
  37. package/es/form-table/index.js +62 -62
  38. package/es/index/index.js +787 -739
  39. package/es/index/style.css +1 -1
  40. package/es/input/index.js +9 -9
  41. package/es/input-number/index.js +8 -8
  42. package/es/layout/index.js +8 -8
  43. package/es/list/index.js +8 -8
  44. package/es/locale-provider/index.js +8 -8
  45. package/es/map/index.js +9 -9
  46. package/es/mentions/index.js +8 -8
  47. package/es/menu/index.js +8 -8
  48. package/es/message/index.js +8 -8
  49. package/es/multi-chat/index.js +92 -92
  50. package/es/multi-chat-client/index.js +86 -86
  51. package/es/multi-chat-history/index.js +4 -4
  52. package/es/multi-chat-record/index.js +14 -14
  53. package/es/multi-chat-setting/index.js +27 -27
  54. package/es/multi-chat-sip/index.js +1 -1
  55. package/es/notification/index.js +8 -8
  56. package/es/page-header/index.js +8 -8
  57. package/es/pagination/index.js +8 -8
  58. package/es/popconfirm/index.js +8 -8
  59. package/es/popover/index.js +8 -8
  60. package/es/progress/index.js +8 -8
  61. package/es/radio/index.js +9 -9
  62. package/es/rate/index.js +8 -8
  63. package/es/result/index.js +8 -8
  64. package/es/row/index.js +8 -8
  65. package/es/scale-view/index.js +33 -33
  66. package/es/select/index.js +11 -11
  67. package/es/select-label/index.js +11 -11
  68. package/es/select-person/index.js +20 -20
  69. package/es/skeleton/index.js +8 -8
  70. package/es/slider/index.js +8 -8
  71. package/es/space/index.js +8 -8
  72. package/es/spin/index.js +8 -8
  73. package/es/statistic/index.js +8 -8
  74. package/es/steps/index.js +8 -8
  75. package/es/switch/index.js +8 -8
  76. package/es/table-filter/index.js +142 -142
  77. package/es/tabs/index.js +8 -8
  78. package/es/tag/index.js +9 -9
  79. package/es/time-picker/index.js +8 -8
  80. package/es/timeline/index.js +8 -8
  81. package/es/tooltip/index.js +8 -8
  82. package/es/transfer/index.js +8 -8
  83. package/es/tree/index.js +8 -8
  84. package/es/tree-select/index.js +8 -8
  85. package/es/upload/index.js +8 -8
  86. package/es/verification-code/index.js +2 -2
  87. package/lib/cui.common.js +736 -688
  88. package/lib/cui.umd.js +736 -688
  89. package/lib/cui.umd.min.js +14 -14
  90. package/package.json +107 -107
  91. package/packages/big-table/src/BigTable.vue +3044 -3039
  92. package/packages/big-table/src/assets/style/table-base.less +370 -370
  93. package/packages/big-table/src/components/AutoLayoutButton.vue +270 -270
  94. package/packages/big-table/src/utils/batchEditing.js +610 -610
  95. package/packages/big-table/src/utils/bigTableProps.js +95 -95
  96. package/packages/button/src/ButtonPrint/components/IdentityVerification.vue +181 -181
  97. package/packages/button/src/ButtonPrint/index.vue +728 -728
  98. package/packages/fabric-chart/src/components/TimeScaleValue.vue +113 -113
  99. package/packages/fabric-chart/src/const/defaultVaule.js +59 -59
  100. package/packages/fabric-chart/src/fabric-chart/FabricPolylines.vue +1066 -1055
  101. package/packages/fabric-chart/src/fabric-chart/FabricScaleValue.vue +135 -135
  102. package/packages/fabric-chart/src/fabric-chart/FabricTextGroup.vue +558 -558
  103. package/packages/fabric-chart/src/fabric-chart2/FabricTop.vue +172 -172
  104. package/packages/multi-chat/chat/chatFooter.vue +1594 -1594
  105. package/packages/multi-chat/chat/chatMain.vue +1466 -1466
  106. package/packages/multi-chat/chat/quickReply.vue +439 -439
  107. package/packages/multi-chat/chat/scrollList.vue +1232 -1232
  108. package/packages/multi-chat/setting/baseInfo/index.vue +1316 -1316
  109. package/packages/multi-chat/store/actions.js +448 -448
  110. package/packages/multi-chat/store/state.js +112 -112
  111. package/packages/scale-view/formitem/r-choice.vue +714 -714
  112. package/packages/scale-view/scaleView.vue +2010 -2010
  113. package/packages/select-person/select-person.vue +1658 -1658
  114. package/packages/table-filter/src/base-search-com/BaseSearch.vue +2462 -2462
  115. package/packages/table-filter/src/components/c-tree-select/tree-select.vue +336 -336
  116. package/packages/table-filter/src/components/multi-select/multi-select.vue +219 -219
  117. package/packages/table-filter/src/components/out-quick-search/out-quick-search.vue +340 -340
  118. package/packages/table-filter/src/components/search-condition/SearchCondition.vue +1825 -1825
  119. package/packages/table-filter/src/const/dataOptions.js +43 -43
  120. package/packages/table-filter/src/mixins/mixins.js +695 -695
  121. package/packages/table-filter/src/quick-search/QuickSearch.vue +2109 -2109
  122. package/src/directive/preventReClick.js +12 -12
@@ -1,714 +1,714 @@
1
- <template>
2
- <div class="r-choice">
3
- <a-radio-group
4
- v-model="curvalue"
5
- v-if="item.type == 'RADIO_BLOCK' || item.type === 'EVALUATE_RADIO_BLOCK'"
6
- @change="radioChange"
7
- class="choice-wrap"
8
- :class="['choice-wrap-' + (item.setting.chooseStyleSetting || 1)]"
9
- >
10
- <a-radio
11
- v-for="(o, i) in curOptions"
12
- class="choice-radio"
13
- :value="o[choiceUseKey]"
14
- :key="o.key + i + o.label"
15
- :class="{ 'block-radio': !item.setting.isHorizontal }"
16
- :disabled="isLock"
17
- :style="{ color: choiceColor(o) }"
18
- >
19
- <template v-if="showImgWrap(o)">
20
- <span class="scale-choice-img-wrap">
21
- <img class="show-picture" :src="o.imageUrl" />
22
- <div class="scale-preview-wrap">
23
- <a-icon type="zoom-in" @click.stop.prevent="handlePreview(o.imageUrl, i)" />
24
- </div>
25
- </span>
26
- </template>
27
- <template>
28
- <template v-if="isRadioItem && showPreSuffix(o)">
29
- <span
30
- v-if="o.prefix"
31
- class="prefix-span"
32
- :style="{ color: choiceColor(o) }"
33
- >{{ o.prefix }}</span>
34
- <a-input
35
- v-model="optionsPreSuffixObj[o.key]"
36
- :disabled="isLock || inputLock"
37
- @change="inputPreSuffixChange(o, i)"
38
- :style="{ color: choiceColor(o) }"
39
- placeholder="请输入"
40
- />
41
- <span
42
- v-if="o.suffix"
43
- class="suffix-span"
44
- :style="{ color: choiceColor(o) }"
45
- >{{ o.suffix }}</span>
46
- </template>
47
- <span v-else :style="{ color: choiceColor(o) }">{{ o.label }}</span>
48
- <a-input
49
- v-if="o.importability"
50
- v-model="othersText"
51
- :disabled="isLock || inputLock"
52
- :style="{ color: choiceColor(o) }"
53
- placeholder="请输入"
54
- @change="inputChange"
55
- />
56
- </template>
57
- </a-radio>
58
- </a-radio-group>
59
- <a-checkbox-group
60
- v-else-if="item.type == 'CHECKBOX_BLOCK' || item.type === 'EVALUATE_CHECKBOX_BLOCK'"
61
- @change="checkboxChange"
62
- v-model="curCheckboxValue"
63
- class="choice-wrap"
64
- :class="['choice-wrap-' + (item.setting.chooseStyleSetting || 1)]"
65
- >
66
- <a-checkbox
67
- class="choice-checkbox"
68
- v-for="(o, i) in curOptions"
69
- :key="o.key + i + o.label"
70
- :value="o[choiceUseKey]"
71
- :class="{ 'block-checkbox': !item.setting.isHorizontal }"
72
- :disabled="isLock"
73
- :style="{ color: choiceColor(o) }"
74
- >
75
- <template v-if="showImgWrap(o)">
76
- <span class="scale-choice-img-wrap">
77
- <img class="show-picture" :src="o.imageUrl" />
78
- <div class="scale-preview-wrap">
79
- <a-icon type="zoom-in" @click.stop.prevent="handlePreview(o.imageUrl, i)" />
80
- </div>
81
- </span>
82
- </template>
83
- <template>
84
- <template v-if="isCheckboxItem && showPreSuffix(o)">
85
- <span
86
- v-if="o.prefix"
87
- class="prefix-span"
88
- :style="{ color: choiceColor(o) }"
89
- >{{ o.prefix }}</span>
90
- <a-input
91
- v-model="optionsPreSuffixObj[o.key]"
92
- :disabled="isLock || inputLock"
93
- @change="inputPreSuffixCheckboxChange(o, i)"
94
- :style="{ color: choiceColor(o) }"
95
- placeholder="请输入"
96
- />
97
- <span
98
- v-if="o.suffix"
99
- class="suffix-span"
100
- :style="{ color: choiceColor(o) }"
101
- >{{ o.suffix }}</span>
102
- </template>
103
- <span
104
- v-else
105
- style="white-space: initial;"
106
- :style="{ color: choiceColor(o) }"
107
- >{{ o.label }}</span>
108
- <a-input
109
- v-if="o.importability"
110
- v-model="othersText"
111
- :disabled="isLock || inputLock"
112
- :style="{ color: choiceColor(o) }"
113
- @change="inputCheckboxChange"
114
- placeholder="请输入"
115
- />
116
- </template>
117
- </a-checkbox>
118
- </a-checkbox-group>
119
- <a-select
120
- v-else-if="cloneItem.type == 'SELECT' || item.type === 'EVALUATE_SELECT'"
121
- v-model="choiceValue"
122
- placeholder="请选择"
123
- show-search
124
- :mode="showMulti"
125
- :disabled="isLock"
126
- @search="handleSearch"
127
- @change="handleSelectChange"
128
- :getPopupContainer="getPopupContainer"
129
- :filterOption="filterOption"
130
- :notFoundContent="fetching ? undefined : '暂无数据'"
131
- >
132
- <a-spin v-if="fetching" slot="notFoundContent" size="small" />
133
- <a-select-option v-for="(v, i) in curOptions" :key="i" :value="v[columnKey]">{{ v[labelKey] }}</a-select-option>
134
- </a-select>
135
- <a-cascader
136
- v-else-if="cloneItem.type == 'SEARCH_CASCADE'"
137
- v-model="choiceValue"
138
- class="m-cascader"
139
- placeholder="请选择"
140
- :options="curOptions"
141
- :disabled="isLock"
142
- change-on-select
143
- />
144
-
145
- <!-- 图片预览 -->
146
- <viewer
147
- class="viewer"
148
- ref="viewer"
149
- :images="previewImages"
150
- @inited="inited"
151
- style="display: none"
152
- >
153
- <template slot-scope="scope">
154
- <img v-for="src in scope.images" :src="src" :key="src" />
155
- </template>
156
- </viewer>
157
- </div>
158
- </template>
159
-
160
- <script>
161
- /**
162
- * getSelectOptions 获取下拉框数据的 function
163
- * getSearchOptions 关键字检索的 function
164
- * getCascadeOptions 获取级联数据的 furnction
165
- */
166
- import { Select, Input, Radio, Checkbox, Cascader } from 'ant-design-vue';
167
- import { judgeTypes } from '../mixin/judgeTypes';
168
- // import format from "@/components/table/mixins/format";
169
- // import TextOverTooltip from "./text-over-tooltip/TextOverTooltip.vue";
170
- import utils from '@/utils/utils-map';
171
- import axios from 'axios';
172
- import 'viewerjs/dist/viewer.css';
173
- import { component as Viewer } from 'v-viewer';
174
- export default {
175
- mixins: [judgeTypes],
176
- props: {
177
- value: { default: undefined, type: [String, Array, Number] },
178
- item: { type: Object, default: () => {} },
179
- isLock: { type: Boolean, default: false },
180
- inputLock: { type: Boolean, default: false },
181
- curIndex: Number,
182
- getSelectOptions: {
183
- type: Function,
184
- default: () => Promise.resolve([])
185
- },
186
- getSearchOptions: {
187
- type: Function,
188
- default: () => Promise.resolve([])
189
- },
190
- getCascadeOptions: {
191
- type: Function,
192
- default: () => Promise.resolve([])
193
- },
194
- openType: { type: String, default: '' }
195
- },
196
- components: {
197
- Viewer,
198
- [Input.name]: Input,
199
- [Cascader.name]: Cascader,
200
- [Checkbox.name]: Checkbox,
201
- [Checkbox.Group.name]: Checkbox.Group,
202
- [Radio.name]: Radio,
203
- [Radio.Group.name]: Radio.Group,
204
- [Select.name]: Select,
205
- [Select.Option.name]: Select.Option
206
- },
207
- computed: {
208
- choiceValue: {
209
- get() {
210
- return this.value ? this.value : undefined;
211
- },
212
- set(val) {
213
- this.$emit('input', val);
214
- }
215
- },
216
- choiceUseKey() {
217
- if (this.item.type === 'RADIO_BLOCK' || this.item.type === 'CHECKBOX_BLOCK') return 'key';
218
- return 'value';
219
- },
220
- choiceColor() {
221
- return function (p) {
222
- let color = p.color || 'rgba(0, 0, 0, 0.65)';
223
- return `${color} !important`;
224
- };
225
- },
226
- showImgWrap() {
227
- return function (o) {
228
- return !o.prefix && !o.suffix && o.imageUrl;
229
- };
230
- },
231
- isRadioItem() {
232
- return this.item.type === 'RADIO_BLOCK';
233
- },
234
- isCheckboxItem() {
235
- return this.item.type === 'CHECKBOX_BLOCK';
236
- },
237
- showPreSuffix() {
238
- return function (o) {
239
- return o.prefix || o.suffix;
240
- };
241
- },
242
- isDynamic2Static() {
243
- // 分享链接的量表用 optionType 1:静态,2:动态,3:动态转静态
244
- let { targetSource = {}, options = [], optionType } = this.item || {};
245
- if (targetSource.target_id && (options.length || optionType == 3)) return true;
246
- return false;
247
- },
248
- isMultiple() {
249
- return this.item?.setting?.isMultiple;
250
- },
251
- showMulti() {
252
- return this.isMultiple ? 'multiple' : 'default';
253
- },
254
- // 取值字段
255
- columnKey() {
256
- let { target_id, values } = this.item?.targetSource || {};
257
- if (!target_id || !values) return 'value';
258
- if (this.isDynamic2Static) return values || 'value';
259
- return values;
260
- },
261
- // 显示字段
262
- labelKey() {
263
- let { target_id, showField } = this.item?.targetSource || {};
264
- if (!target_id || !showField) return 'label';
265
- if (this.isDynamic2Static) return showField || 'label';
266
- return showField;
267
- }
268
- },
269
- watch: {
270
- item: {
271
- immediate: true,
272
- deep: true,
273
- handler(value) {
274
- if (!value || !Object.keys(value).length) return;
275
- this.init(JSON.parse(JSON.stringify(value)));
276
- }
277
- }
278
- },
279
- data() {
280
- return {
281
- selectParams: { tableType: 'TABLE_LIST', pageSize: 20, page: 1 },
282
- cascaderParams: { tableType: 'TABLE_LIST' },
283
- cloneItem: {},
284
- curvalue: '',
285
- curCheckboxValue: [],
286
- othersText: '',
287
- curOptions: [],
288
- fieldList: [],
289
- buttonList: [],
290
- source: 'guageChoice',
291
- fetching: false,
292
- previewImages: [],
293
- optionsPreSuffixObj: {}
294
- };
295
- },
296
- methods: {
297
- init(value) {
298
- let options = value.options || [];
299
- if (this.isEvaluation(value.type)) {
300
- options = value.scoreConfigs?.scoreRules || [];
301
- }
302
- if (value.type === 'RADIO_BLOCK' || value.type === 'EVALUATE_RADIO_BLOCK') {
303
- const defVal = value.dbValue || value.setting.defaultValue || this.value;
304
- this.handleRadioDef(value, defVal, options);
305
- return;
306
- }
307
- if (value.type === 'CHECKBOX_BLOCK' || value.type === 'EVALUATE_CHECKBOX_BLOCK') {
308
- let defVal = [];
309
- if (utils.isJSON(value.setting.defaultValue)) {
310
- defVal = JSON.parse(value.setting.defaultValue);
311
- } else {
312
- defVal = this.value;
313
- }
314
- this.handleCheckboxDef(value, value.dbValue || defVal, options);
315
- return;
316
- }
317
- if (value.type == 'SELECT' || value.type == 'SEARCH_CASCADE' || value.type === 'EVALUATE_SELECT') {
318
- this.cloneItem = JSON.parse(JSON.stringify(value));
319
- let options = this.cloneItem.options || [];
320
- if (this.isEvaluation(value.type)) {
321
- options = this.cloneItem.scoreConfigs?.scoreRules || [];
322
- }
323
- this.curOptions = options;
324
- this.initSelectOptions();
325
- }
326
- },
327
- handleRadioDef(item, curValue, options) {
328
- this.curOptions = this.handleOptions(options, item.type);
329
- if (!options.length || !curValue) return;
330
- // 测评单选回显
331
- if (item.type === 'EVALUATE_RADIO_BLOCK') {
332
- this.curvalue = curValue;
333
- this.radioChange();
334
- return;
335
- }
336
- // 普通单选回显 普通选项/其它/前后缀 所以用key标识
337
- let hasOther = options.find(v => v.value === curValue);
338
- if (hasOther) {
339
- this.curvalue = hasOther.key;
340
- this.radioChange();
341
- return;
342
- }
343
- let preSuffixItem = options.find((v, i) => {
344
- let res = this.handleDefPreSuffix(v, i, curValue);
345
- if (res) {
346
- this.curvalue = res;
347
- }
348
- return !!res || false;
349
- });
350
- if (!preSuffixItem) {
351
- this.othersText = curValue;
352
- this.curvalue = 'other';
353
- }
354
- this.radioChange();
355
- },
356
- handleDefPreSuffix(v, i, curValue, isCheckbox, hasOther) {
357
- if (v.prefix || v.suffix) {
358
- let value = v.value;
359
- // 有前后缀的option input为必填, 如果直接相等则为other
360
- if (value === curValue) return false;
361
- if (v.prefix) {
362
- if (curValue.indexOf(v.prefix) === 0) {
363
- let inputValue = curValue.substring(v.prefix.length);
364
- this.$set(this.optionsPreSuffixObj, v.key, inputValue);
365
- return v.key;
366
- }
367
- }
368
- if (v.suffix) {
369
- let lastIndexOf = curValue.lastIndexOf(v.suffix);
370
- lastIndexOf + v.suffix.length;
371
- if (curValue.length === lastIndexOf + v.suffix.length) {
372
- let index = curValue.lastIndexOf(v.suffix);
373
- let inputValue = curValue.substring(0, index);
374
- this.$set(this.optionsPreSuffixObj, v.key, inputValue);
375
- return v.key;
376
- }
377
- }
378
- }
379
- if (curValue === v.value) return v.key;
380
- if (isCheckbox && hasOther) {
381
- this.othersText = curValue;
382
- return 'other';
383
- }
384
- },
385
- async handleCheckboxDef(item, curValue, options) {
386
- this.curOptions = this.handleOptions(options, item.type);
387
- if (!options.length || !curValue || !curValue.length) return;
388
- // 测评多选回显
389
- if (item.type === 'EVALUATE_CHECKBOX_BLOCK') {
390
- this.curCheckboxValue = curValue;
391
- this.handleCheckboxOther();
392
- return;
393
- }
394
- // 普通多选回显 普通选项/其它/前后缀 所以用key标识
395
- let resArr = [],
396
- i = 0,
397
- x,
398
- len = curValue.length;
399
- let hasOther = options.some(v => v.importability || v.key === 'other');
400
- for (; i < len; i++) {
401
- x = curValue[i];
402
- if (x === '其他') {
403
- this.othersText = x;
404
- this.curvalue = 'other';
405
- !resArr.includes('other') && resArr.push('other');
406
- continue;
407
- }
408
- let matchIndex = options.findIndex(v => v.value === x);
409
- if (matchIndex > 0) {
410
- let res = options[matchIndex]?.key;
411
- !resArr.includes(res) && resArr.push(res);
412
- continue;
413
- }
414
- options.map(v => {
415
- let res = this.handleDefPreSuffix(v, i, x, true, hasOther);
416
- res && !resArr.includes(res) && resArr.push(res);
417
- });
418
- }
419
- this.curCheckboxValue = resArr;
420
- this.handleCheckboxOther();
421
- },
422
- handleOptions(options, type) {
423
- return (
424
- options
425
- .map((v, i) => {
426
- if (v.prefix || v.suffix) {
427
- this.$set(this.optionsPreSuffixObj, v.key, undefined);
428
- return v;
429
- }
430
- if (v.label) return v;
431
- return null;
432
- })
433
- .filter(Boolean) || []
434
- );
435
- },
436
- radioChange() {
437
- let choiceObj = {
438
- othersText: this.othersText,
439
- optionsPreSuffixObj: this.optionsPreSuffixObj
440
- };
441
- this.$emit('radioChange', this.curvalue, this.item, choiceObj);
442
- },
443
- checkboxChange() {
444
- this.handleCheckboxOther();
445
- },
446
- inputChange() {
447
- let choiceObj = {
448
- othersText: this.othersText,
449
- optionsPreSuffixObj: this.optionsPreSuffixObj
450
- };
451
- this.curvalue = 'other';
452
- this.$emit('radioChange', 'other', this.item, choiceObj);
453
- },
454
- inputPreSuffixChange(o, i) {
455
- this.curvalue = o.key;
456
- let choiceObj = {
457
- othersText: this.othersText,
458
- optionsPreSuffixObj: this.optionsPreSuffixObj
459
- };
460
- this.$emit('radioChange', this.curvalue, this.item, choiceObj);
461
- },
462
- inputPreSuffixCheckboxChange(o, i) {
463
- let choiceObj = {
464
- othersText: this.othersText,
465
- optionsPreSuffixObj: this.optionsPreSuffixObj
466
- };
467
- if (!this.curCheckboxValue.includes(o.key)) {
468
- this.curCheckboxValue.push(o.key);
469
- }
470
- let curCheckboxValue = JSON.parse(JSON.stringify(this.curCheckboxValue));
471
- this.$emit('checkboxChange', curCheckboxValue, this.item, choiceObj);
472
- },
473
- inputCheckboxChange() {
474
- this.handleCheckboxOther(true);
475
- },
476
- handleCheckboxOther(isOtherInput) {
477
- let choiceObj = {
478
- othersText: this.othersText,
479
- optionsPreSuffixObj: this.optionsPreSuffixObj
480
- };
481
- if (isOtherInput && !this.curCheckboxValue.includes('other')) {
482
- this.curCheckboxValue.push('other');
483
- }
484
- let curCheckboxValue = JSON.parse(JSON.stringify(this.curCheckboxValue));
485
- this.$emit('checkboxChange', curCheckboxValue, this.item, choiceObj);
486
- },
487
- async initSelectOptions() {
488
- // 分享链接的量表用 optionType 1:静态,2:动态,3:动态转静态
489
- const { targetSource, type, options = [], optionType = 1 } = this.cloneItem;
490
- if (!targetSource?.target_id) return;
491
- // 动态数据源转静态数据
492
- if (type == 'SELECT' && this.isDynamic2Static) {
493
- this.curOptions = this.handleDynamic2StaticOptions(options);
494
- return;
495
- }
496
- if (type === 'SELECT') {
497
- this.fetching = true;
498
- this.curOptions = await this.getSelectOptions(this.cloneItem);
499
- this.fetching = false;
500
- } else {
501
- this.curOptions = await this.getCascadeOptions(this.cloneItem);
502
- }
503
- },
504
- handleDynamic2StaticOptions(options) {
505
- if (!options || !options.length) return [];
506
- return options.map(item => {
507
- if ('cascadeData' in item) {
508
- Object.assign(item, {
509
- ...item.cascadeData
510
- });
511
- }
512
- // 容错 没有配置的key 添加一个
513
- if (!(this.columnKey in item)) {
514
- item[this.columnKey] = item.value || item.label;
515
- }
516
- if (!(this.labelKey in item)) {
517
- item[this.labelKey] = item.label;
518
- }
519
- return item;
520
- });
521
- },
522
- // 下拉组件搜索
523
- async handleSearch(value) {
524
- try {
525
- this.curOptions = await this.getSearchOptions(
526
- {
527
- values: this.columnKey,
528
- showField: this.labelKey,
529
- keyword: value
530
- },
531
- this.cloneItem
532
- );
533
- console.log(this.curOptions, 'curOptions');
534
- } catch (error) {
535
- console.log(error);
536
- }
537
- },
538
- // 下拉组件选值
539
- handleSelectChange(value) {
540
- let res = {
541
- value: '',
542
- list: []
543
- };
544
- let matchItem;
545
- if (Array.isArray(value)) {
546
- res.value = value;
547
- if (!value.length) {
548
- res.list = [];
549
- } else {
550
- value.forEach(item => {
551
- matchItem = this.curOptions.find(v => v.value === item);
552
- if (matchItem) {
553
- res.list.push(matchItem);
554
- }
555
- });
556
- }
557
- } else {
558
- res.value = value;
559
- matchItem = this.curOptions.find(v => v.value === value);
560
- if (matchItem) {
561
- res.list.push(matchItem);
562
- }
563
- }
564
- this.$emit('change', res);
565
- },
566
- filterOption(input, option) {
567
- return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0;
568
- },
569
- getPopupContainer(triggerNode) {
570
- if (this.openType == 'formIframe') {
571
- return document.body;
572
- }
573
- return triggerNode.parentNode;
574
- },
575
- inited(viewer) {
576
- this.$viewer = viewer;
577
- },
578
- handlePreview(url, i) {
579
- let imgs = this.curOptions.map(v => v.imageUrl);
580
- if (!imgs.length) return;
581
- this.previewImages = imgs;
582
- this.$viewer.index = i;
583
- this.$viewer.show();
584
- }
585
- }
586
- };
587
- </script>
588
-
589
- <style lang="less" scoped>
590
- .r-choice {
591
- /deep/ .ant-radio-group {
592
- width: 100%;
593
- }
594
- /deep/ .choice-radio,
595
- /deep/ .choice-checkbox {
596
- display: inline-flex;
597
- align-items: center;
598
- margin-bottom: 5px;
599
- margin-right: 8px;
600
- margin-left: 0px;
601
- > span:last-child {
602
- flex: 1;
603
- display: inline-flex;
604
- align-items: center;
605
- word-break: break-all;
606
- }
607
- input {
608
- height: 100%;
609
- flex: 1;
610
- background: transparent;
611
- border-radius: 0;
612
- border-color: transparent !important;
613
- border-bottom: 1px solid #d9d9d9 !important;
614
- }
615
- .prefix-span {
616
- padding-right: 8px;
617
- }
618
- .suffix-span {
619
- padding-left: 8px;
620
- }
621
- }
622
-
623
- /deep/ .block-radio,
624
- /deep/ .block-checkbox {
625
- display: flex;
626
- margin-left: 8px;
627
- }
628
- /deep/ .ant-select {
629
- min-width: 160px;
630
- }
631
- /deep/ .ant-select ~ div {
632
- position: relative !important;
633
- }
634
- /deep/.ant-select-dropdown {
635
- top: 0px !important;
636
- left: 1px !important;
637
- }
638
- .choice-wrap {
639
- display: flex;
640
- flex-wrap: wrap;
641
- .scale-choice-img-wrap {
642
- position: relative;
643
- width: 74px;
644
- min-width: 74px;
645
- height: 62px;
646
- background: #ffffff;
647
- border-radius: 4px;
648
- border: 1px solid #d5d5d5;
649
- margin-right: 16px;
650
- &:hover {
651
- .scale-preview-wrap {
652
- display: flex;
653
- }
654
- }
655
- > img {
656
- width: 100%;
657
- height: 100%;
658
- object-fit: cover;
659
- }
660
- .scale-preview-wrap {
661
- position: absolute;
662
- top: 0;
663
- left: 0;
664
- right: 0;
665
- bottom: 0;
666
- display: none;
667
- justify-content: center;
668
- align-items: center;
669
- background: rgba(0, 0, 0, 0.75);
670
- border-radius: 8px;
671
- font-size: 20px;
672
- i.anticon {
673
- color: #fff;
674
- margin: 0px;
675
- }
676
- }
677
- }
678
- /deep/ .choose-value .el-tooltip.ellipsis {
679
- color: rgba(0, 0, 0, 0.65);
680
- font-size: 14px;
681
- }
682
- label {
683
- margin: 4px 0;
684
- }
685
- /deep/.ant-radio-wrapper span.ant-radio + * {
686
- display: inline-flex;
687
- align-items: center;
688
- white-space: initial;
689
- }
690
- &.choice-wrap-1 label {
691
- width: 100%;
692
- /deep/ input {
693
- max-width: 300px;
694
- }
695
- }
696
- &.choice-wrap-2 label {
697
- width: 50%;
698
- }
699
- &.choice-wrap-3 label {
700
- width: 33%;
701
- }
702
- &.choice-wrap-4 label {
703
- width: 25%;
704
- }
705
- /deep/ .ant-checkbox {
706
- // margin-top: -0.2em;
707
- margin-top: 5px;
708
- }
709
- /deep/ .ant-checkbox-inner {
710
- vertical-align: top;
711
- }
712
- }
713
- }
714
- </style>
1
+ <template>
2
+ <div class="r-choice">
3
+ <a-radio-group
4
+ v-model="curvalue"
5
+ v-if="item.type == 'RADIO_BLOCK' || item.type === 'EVALUATE_RADIO_BLOCK'"
6
+ @change="radioChange"
7
+ class="choice-wrap"
8
+ :class="['choice-wrap-' + (item.setting.chooseStyleSetting || 1)]"
9
+ >
10
+ <a-radio
11
+ v-for="(o, i) in curOptions"
12
+ class="choice-radio"
13
+ :value="o[choiceUseKey]"
14
+ :key="o.key + i + o.label"
15
+ :class="{ 'block-radio': !item.setting.isHorizontal }"
16
+ :disabled="isLock"
17
+ :style="{ color: choiceColor(o) }"
18
+ >
19
+ <template v-if="showImgWrap(o)">
20
+ <span class="scale-choice-img-wrap">
21
+ <img class="show-picture" :src="o.imageUrl" />
22
+ <div class="scale-preview-wrap">
23
+ <a-icon type="zoom-in" @click.stop.prevent="handlePreview(o.imageUrl, i)" />
24
+ </div>
25
+ </span>
26
+ </template>
27
+ <template>
28
+ <template v-if="isRadioItem && showPreSuffix(o)">
29
+ <span
30
+ v-if="o.prefix"
31
+ class="prefix-span"
32
+ :style="{ color: choiceColor(o) }"
33
+ >{{ o.prefix }}</span>
34
+ <a-input
35
+ v-model="optionsPreSuffixObj[o.key]"
36
+ :disabled="isLock || inputLock"
37
+ @change="inputPreSuffixChange(o, i)"
38
+ :style="{ color: choiceColor(o) }"
39
+ placeholder="请输入"
40
+ />
41
+ <span
42
+ v-if="o.suffix"
43
+ class="suffix-span"
44
+ :style="{ color: choiceColor(o) }"
45
+ >{{ o.suffix }}</span>
46
+ </template>
47
+ <span v-else :style="{ color: choiceColor(o) }">{{ o.label }}</span>
48
+ <a-input
49
+ v-if="o.importability"
50
+ v-model="othersText"
51
+ :disabled="isLock || inputLock"
52
+ :style="{ color: choiceColor(o) }"
53
+ placeholder="请输入"
54
+ @change="inputChange"
55
+ />
56
+ </template>
57
+ </a-radio>
58
+ </a-radio-group>
59
+ <a-checkbox-group
60
+ v-else-if="item.type == 'CHECKBOX_BLOCK' || item.type === 'EVALUATE_CHECKBOX_BLOCK'"
61
+ @change="checkboxChange"
62
+ v-model="curCheckboxValue"
63
+ class="choice-wrap"
64
+ :class="['choice-wrap-' + (item.setting.chooseStyleSetting || 1)]"
65
+ >
66
+ <a-checkbox
67
+ class="choice-checkbox"
68
+ v-for="(o, i) in curOptions"
69
+ :key="o.key + i + o.label"
70
+ :value="o[choiceUseKey]"
71
+ :class="{ 'block-checkbox': !item.setting.isHorizontal }"
72
+ :disabled="isLock"
73
+ :style="{ color: choiceColor(o) }"
74
+ >
75
+ <template v-if="showImgWrap(o)">
76
+ <span class="scale-choice-img-wrap">
77
+ <img class="show-picture" :src="o.imageUrl" />
78
+ <div class="scale-preview-wrap">
79
+ <a-icon type="zoom-in" @click.stop.prevent="handlePreview(o.imageUrl, i)" />
80
+ </div>
81
+ </span>
82
+ </template>
83
+ <template>
84
+ <template v-if="isCheckboxItem && showPreSuffix(o)">
85
+ <span
86
+ v-if="o.prefix"
87
+ class="prefix-span"
88
+ :style="{ color: choiceColor(o) }"
89
+ >{{ o.prefix }}</span>
90
+ <a-input
91
+ v-model="optionsPreSuffixObj[o.key]"
92
+ :disabled="isLock || inputLock"
93
+ @change="inputPreSuffixCheckboxChange(o, i)"
94
+ :style="{ color: choiceColor(o) }"
95
+ placeholder="请输入"
96
+ />
97
+ <span
98
+ v-if="o.suffix"
99
+ class="suffix-span"
100
+ :style="{ color: choiceColor(o) }"
101
+ >{{ o.suffix }}</span>
102
+ </template>
103
+ <span
104
+ v-else
105
+ style="white-space: initial;"
106
+ :style="{ color: choiceColor(o) }"
107
+ >{{ o.label }}</span>
108
+ <a-input
109
+ v-if="o.importability"
110
+ v-model="othersText"
111
+ :disabled="isLock || inputLock"
112
+ :style="{ color: choiceColor(o) }"
113
+ @change="inputCheckboxChange"
114
+ placeholder="请输入"
115
+ />
116
+ </template>
117
+ </a-checkbox>
118
+ </a-checkbox-group>
119
+ <a-select
120
+ v-else-if="cloneItem.type == 'SELECT' || item.type === 'EVALUATE_SELECT'"
121
+ v-model="choiceValue"
122
+ placeholder="请选择"
123
+ show-search
124
+ :mode="showMulti"
125
+ :disabled="isLock"
126
+ @search="handleSearch"
127
+ @change="handleSelectChange"
128
+ :getPopupContainer="getPopupContainer"
129
+ :filterOption="filterOption"
130
+ :notFoundContent="fetching ? undefined : '暂无数据'"
131
+ >
132
+ <a-spin v-if="fetching" slot="notFoundContent" size="small" />
133
+ <a-select-option v-for="(v, i) in curOptions" :key="i" :value="v[columnKey]">{{ v[labelKey] }}</a-select-option>
134
+ </a-select>
135
+ <a-cascader
136
+ v-else-if="cloneItem.type == 'SEARCH_CASCADE'"
137
+ v-model="choiceValue"
138
+ class="m-cascader"
139
+ placeholder="请选择"
140
+ :options="curOptions"
141
+ :disabled="isLock"
142
+ change-on-select
143
+ />
144
+
145
+ <!-- 图片预览 -->
146
+ <viewer
147
+ class="viewer"
148
+ ref="viewer"
149
+ :images="previewImages"
150
+ @inited="inited"
151
+ style="display: none"
152
+ >
153
+ <template slot-scope="scope">
154
+ <img v-for="src in scope.images" :src="src" :key="src" />
155
+ </template>
156
+ </viewer>
157
+ </div>
158
+ </template>
159
+
160
+ <script>
161
+ /**
162
+ * getSelectOptions 获取下拉框数据的 function
163
+ * getSearchOptions 关键字检索的 function
164
+ * getCascadeOptions 获取级联数据的 furnction
165
+ */
166
+ import { Select, Input, Radio, Checkbox, Cascader } from 'ant-design-vue';
167
+ import { judgeTypes } from '../mixin/judgeTypes';
168
+ // import format from "@/components/table/mixins/format";
169
+ // import TextOverTooltip from "./text-over-tooltip/TextOverTooltip.vue";
170
+ import utils from '@/utils/utils-map';
171
+ import axios from 'axios';
172
+ import 'viewerjs/dist/viewer.css';
173
+ import { component as Viewer } from 'v-viewer';
174
+ export default {
175
+ mixins: [judgeTypes],
176
+ props: {
177
+ value: { default: undefined, type: [String, Array, Number] },
178
+ item: { type: Object, default: () => {} },
179
+ isLock: { type: Boolean, default: false },
180
+ inputLock: { type: Boolean, default: false },
181
+ curIndex: Number,
182
+ getSelectOptions: {
183
+ type: Function,
184
+ default: () => Promise.resolve([])
185
+ },
186
+ getSearchOptions: {
187
+ type: Function,
188
+ default: () => Promise.resolve([])
189
+ },
190
+ getCascadeOptions: {
191
+ type: Function,
192
+ default: () => Promise.resolve([])
193
+ },
194
+ openType: { type: String, default: '' }
195
+ },
196
+ components: {
197
+ Viewer,
198
+ [Input.name]: Input,
199
+ [Cascader.name]: Cascader,
200
+ [Checkbox.name]: Checkbox,
201
+ [Checkbox.Group.name]: Checkbox.Group,
202
+ [Radio.name]: Radio,
203
+ [Radio.Group.name]: Radio.Group,
204
+ [Select.name]: Select,
205
+ [Select.Option.name]: Select.Option
206
+ },
207
+ computed: {
208
+ choiceValue: {
209
+ get() {
210
+ return this.value ? this.value : undefined;
211
+ },
212
+ set(val) {
213
+ this.$emit('input', val);
214
+ }
215
+ },
216
+ choiceUseKey() {
217
+ if (this.item.type === 'RADIO_BLOCK' || this.item.type === 'CHECKBOX_BLOCK') return 'key';
218
+ return 'value';
219
+ },
220
+ choiceColor() {
221
+ return function (p) {
222
+ let color = p.color || 'rgba(0, 0, 0, 0.65)';
223
+ return `${color} !important`;
224
+ };
225
+ },
226
+ showImgWrap() {
227
+ return function (o) {
228
+ return !o.prefix && !o.suffix && o.imageUrl;
229
+ };
230
+ },
231
+ isRadioItem() {
232
+ return this.item.type === 'RADIO_BLOCK';
233
+ },
234
+ isCheckboxItem() {
235
+ return this.item.type === 'CHECKBOX_BLOCK';
236
+ },
237
+ showPreSuffix() {
238
+ return function (o) {
239
+ return o.prefix || o.suffix;
240
+ };
241
+ },
242
+ isDynamic2Static() {
243
+ // 分享链接的量表用 optionType 1:静态,2:动态,3:动态转静态
244
+ let { targetSource = {}, options = [], optionType } = this.item || {};
245
+ if (targetSource.target_id && (options.length || optionType == 3)) return true;
246
+ return false;
247
+ },
248
+ isMultiple() {
249
+ return this.item?.setting?.isMultiple;
250
+ },
251
+ showMulti() {
252
+ return this.isMultiple ? 'multiple' : 'default';
253
+ },
254
+ // 取值字段
255
+ columnKey() {
256
+ let { target_id, values } = this.item?.targetSource || {};
257
+ if (!target_id || !values) return 'value';
258
+ if (this.isDynamic2Static) return values || 'value';
259
+ return values;
260
+ },
261
+ // 显示字段
262
+ labelKey() {
263
+ let { target_id, showField } = this.item?.targetSource || {};
264
+ if (!target_id || !showField) return 'label';
265
+ if (this.isDynamic2Static) return showField || 'label';
266
+ return showField;
267
+ }
268
+ },
269
+ watch: {
270
+ item: {
271
+ immediate: true,
272
+ deep: true,
273
+ handler(value) {
274
+ if (!value || !Object.keys(value).length) return;
275
+ this.init(JSON.parse(JSON.stringify(value)));
276
+ }
277
+ }
278
+ },
279
+ data() {
280
+ return {
281
+ selectParams: { tableType: 'TABLE_LIST', pageSize: 20, page: 1 },
282
+ cascaderParams: { tableType: 'TABLE_LIST' },
283
+ cloneItem: {},
284
+ curvalue: '',
285
+ curCheckboxValue: [],
286
+ othersText: '',
287
+ curOptions: [],
288
+ fieldList: [],
289
+ buttonList: [],
290
+ source: 'guageChoice',
291
+ fetching: false,
292
+ previewImages: [],
293
+ optionsPreSuffixObj: {}
294
+ };
295
+ },
296
+ methods: {
297
+ init(value) {
298
+ let options = value.options || [];
299
+ if (this.isEvaluation(value.type)) {
300
+ options = value.scoreConfigs?.scoreRules || [];
301
+ }
302
+ if (value.type === 'RADIO_BLOCK' || value.type === 'EVALUATE_RADIO_BLOCK') {
303
+ const defVal = value.dbValue || value.setting.defaultValue || this.value;
304
+ this.handleRadioDef(value, defVal, options);
305
+ return;
306
+ }
307
+ if (value.type === 'CHECKBOX_BLOCK' || value.type === 'EVALUATE_CHECKBOX_BLOCK') {
308
+ let defVal = [];
309
+ if (utils.isJSON(value.setting.defaultValue)) {
310
+ defVal = JSON.parse(value.setting.defaultValue);
311
+ } else {
312
+ defVal = this.value;
313
+ }
314
+ this.handleCheckboxDef(value, value.dbValue || defVal, options);
315
+ return;
316
+ }
317
+ if (value.type == 'SELECT' || value.type == 'SEARCH_CASCADE' || value.type === 'EVALUATE_SELECT') {
318
+ this.cloneItem = JSON.parse(JSON.stringify(value));
319
+ let options = this.cloneItem.options || [];
320
+ if (this.isEvaluation(value.type)) {
321
+ options = this.cloneItem.scoreConfigs?.scoreRules || [];
322
+ }
323
+ this.curOptions = options;
324
+ this.initSelectOptions();
325
+ }
326
+ },
327
+ handleRadioDef(item, curValue, options) {
328
+ this.curOptions = this.handleOptions(options, item.type);
329
+ if (!options.length || !curValue) return;
330
+ // 测评单选回显
331
+ if (item.type === 'EVALUATE_RADIO_BLOCK') {
332
+ this.curvalue = curValue;
333
+ this.radioChange();
334
+ return;
335
+ }
336
+ // 普通单选回显 普通选项/其它/前后缀 所以用key标识
337
+ let hasOther = options.find(v => v.value === curValue);
338
+ if (hasOther) {
339
+ this.curvalue = hasOther.key;
340
+ this.radioChange();
341
+ return;
342
+ }
343
+ let preSuffixItem = options.find((v, i) => {
344
+ let res = this.handleDefPreSuffix(v, i, curValue);
345
+ if (res) {
346
+ this.curvalue = res;
347
+ }
348
+ return !!res || false;
349
+ });
350
+ if (!preSuffixItem) {
351
+ this.othersText = curValue;
352
+ this.curvalue = 'other';
353
+ }
354
+ this.radioChange();
355
+ },
356
+ handleDefPreSuffix(v, i, curValue, isCheckbox, hasOther) {
357
+ if (v.prefix || v.suffix) {
358
+ let value = v.value;
359
+ // 有前后缀的option input为必填, 如果直接相等则为other
360
+ if (value === curValue) return false;
361
+ if (v.prefix) {
362
+ if (curValue.indexOf(v.prefix) === 0) {
363
+ let inputValue = curValue.substring(v.prefix.length);
364
+ this.$set(this.optionsPreSuffixObj, v.key, inputValue);
365
+ return v.key;
366
+ }
367
+ }
368
+ if (v.suffix) {
369
+ let lastIndexOf = curValue.lastIndexOf(v.suffix);
370
+ lastIndexOf + v.suffix.length;
371
+ if (curValue.length === lastIndexOf + v.suffix.length) {
372
+ let index = curValue.lastIndexOf(v.suffix);
373
+ let inputValue = curValue.substring(0, index);
374
+ this.$set(this.optionsPreSuffixObj, v.key, inputValue);
375
+ return v.key;
376
+ }
377
+ }
378
+ }
379
+ if (curValue === v.value) return v.key;
380
+ if (isCheckbox && hasOther) {
381
+ this.othersText = curValue;
382
+ return 'other';
383
+ }
384
+ },
385
+ async handleCheckboxDef(item, curValue, options) {
386
+ this.curOptions = this.handleOptions(options, item.type);
387
+ if (!options.length || !curValue || !curValue.length) return;
388
+ // 测评多选回显
389
+ if (item.type === 'EVALUATE_CHECKBOX_BLOCK') {
390
+ this.curCheckboxValue = curValue;
391
+ this.handleCheckboxOther();
392
+ return;
393
+ }
394
+ // 普通多选回显 普通选项/其它/前后缀 所以用key标识
395
+ let resArr = [],
396
+ i = 0,
397
+ x,
398
+ len = curValue.length;
399
+ let hasOther = options.some(v => v.importability || v.key === 'other');
400
+ for (; i < len; i++) {
401
+ x = curValue[i];
402
+ if (x === '其他') {
403
+ this.othersText = x;
404
+ this.curvalue = 'other';
405
+ !resArr.includes('other') && resArr.push('other');
406
+ continue;
407
+ }
408
+ let matchIndex = options.findIndex(v => v.value === x);
409
+ if (matchIndex > 0) {
410
+ let res = options[matchIndex]?.key;
411
+ !resArr.includes(res) && resArr.push(res);
412
+ continue;
413
+ }
414
+ options.map(v => {
415
+ let res = this.handleDefPreSuffix(v, i, x, true, hasOther);
416
+ res && !resArr.includes(res) && resArr.push(res);
417
+ });
418
+ }
419
+ this.curCheckboxValue = resArr;
420
+ this.handleCheckboxOther();
421
+ },
422
+ handleOptions(options, type) {
423
+ return (
424
+ options
425
+ .map((v, i) => {
426
+ if (v.prefix || v.suffix) {
427
+ this.$set(this.optionsPreSuffixObj, v.key, undefined);
428
+ return v;
429
+ }
430
+ if (v.label) return v;
431
+ return null;
432
+ })
433
+ .filter(Boolean) || []
434
+ );
435
+ },
436
+ radioChange() {
437
+ let choiceObj = {
438
+ othersText: this.othersText,
439
+ optionsPreSuffixObj: this.optionsPreSuffixObj
440
+ };
441
+ this.$emit('radioChange', this.curvalue, this.item, choiceObj);
442
+ },
443
+ checkboxChange() {
444
+ this.handleCheckboxOther();
445
+ },
446
+ inputChange() {
447
+ let choiceObj = {
448
+ othersText: this.othersText,
449
+ optionsPreSuffixObj: this.optionsPreSuffixObj
450
+ };
451
+ this.curvalue = 'other';
452
+ this.$emit('radioChange', 'other', this.item, choiceObj);
453
+ },
454
+ inputPreSuffixChange(o, i) {
455
+ this.curvalue = o.key;
456
+ let choiceObj = {
457
+ othersText: this.othersText,
458
+ optionsPreSuffixObj: this.optionsPreSuffixObj
459
+ };
460
+ this.$emit('radioChange', this.curvalue, this.item, choiceObj);
461
+ },
462
+ inputPreSuffixCheckboxChange(o, i) {
463
+ let choiceObj = {
464
+ othersText: this.othersText,
465
+ optionsPreSuffixObj: this.optionsPreSuffixObj
466
+ };
467
+ if (!this.curCheckboxValue.includes(o.key)) {
468
+ this.curCheckboxValue.push(o.key);
469
+ }
470
+ let curCheckboxValue = JSON.parse(JSON.stringify(this.curCheckboxValue));
471
+ this.$emit('checkboxChange', curCheckboxValue, this.item, choiceObj);
472
+ },
473
+ inputCheckboxChange() {
474
+ this.handleCheckboxOther(true);
475
+ },
476
+ handleCheckboxOther(isOtherInput) {
477
+ let choiceObj = {
478
+ othersText: this.othersText,
479
+ optionsPreSuffixObj: this.optionsPreSuffixObj
480
+ };
481
+ if (isOtherInput && !this.curCheckboxValue.includes('other')) {
482
+ this.curCheckboxValue.push('other');
483
+ }
484
+ let curCheckboxValue = JSON.parse(JSON.stringify(this.curCheckboxValue));
485
+ this.$emit('checkboxChange', curCheckboxValue, this.item, choiceObj);
486
+ },
487
+ async initSelectOptions() {
488
+ // 分享链接的量表用 optionType 1:静态,2:动态,3:动态转静态
489
+ const { targetSource, type, options = [], optionType = 1 } = this.cloneItem;
490
+ if (!targetSource?.target_id) return;
491
+ // 动态数据源转静态数据
492
+ if (type == 'SELECT' && this.isDynamic2Static) {
493
+ this.curOptions = this.handleDynamic2StaticOptions(options);
494
+ return;
495
+ }
496
+ if (type === 'SELECT') {
497
+ this.fetching = true;
498
+ this.curOptions = await this.getSelectOptions(this.cloneItem);
499
+ this.fetching = false;
500
+ } else {
501
+ this.curOptions = await this.getCascadeOptions(this.cloneItem);
502
+ }
503
+ },
504
+ handleDynamic2StaticOptions(options) {
505
+ if (!options || !options.length) return [];
506
+ return options.map(item => {
507
+ if ('cascadeData' in item) {
508
+ Object.assign(item, {
509
+ ...item.cascadeData
510
+ });
511
+ }
512
+ // 容错 没有配置的key 添加一个
513
+ if (!(this.columnKey in item)) {
514
+ item[this.columnKey] = item.value || item.label;
515
+ }
516
+ if (!(this.labelKey in item)) {
517
+ item[this.labelKey] = item.label;
518
+ }
519
+ return item;
520
+ });
521
+ },
522
+ // 下拉组件搜索
523
+ async handleSearch(value) {
524
+ try {
525
+ this.curOptions = await this.getSearchOptions(
526
+ {
527
+ values: this.columnKey,
528
+ showField: this.labelKey,
529
+ keyword: value
530
+ },
531
+ this.cloneItem
532
+ );
533
+ console.log(this.curOptions, 'curOptions');
534
+ } catch (error) {
535
+ console.log(error);
536
+ }
537
+ },
538
+ // 下拉组件选值
539
+ handleSelectChange(value) {
540
+ let res = {
541
+ value: '',
542
+ list: []
543
+ };
544
+ let matchItem;
545
+ if (Array.isArray(value)) {
546
+ res.value = value;
547
+ if (!value.length) {
548
+ res.list = [];
549
+ } else {
550
+ value.forEach(item => {
551
+ matchItem = this.curOptions.find(v => v.value === item);
552
+ if (matchItem) {
553
+ res.list.push(matchItem);
554
+ }
555
+ });
556
+ }
557
+ } else {
558
+ res.value = value;
559
+ matchItem = this.curOptions.find(v => v.value === value);
560
+ if (matchItem) {
561
+ res.list.push(matchItem);
562
+ }
563
+ }
564
+ this.$emit('change', res);
565
+ },
566
+ filterOption(input, option) {
567
+ return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0;
568
+ },
569
+ getPopupContainer(triggerNode) {
570
+ if (this.openType == 'formIframe') {
571
+ return document.body;
572
+ }
573
+ return triggerNode.parentNode;
574
+ },
575
+ inited(viewer) {
576
+ this.$viewer = viewer;
577
+ },
578
+ handlePreview(url, i) {
579
+ let imgs = this.curOptions.map(v => v.imageUrl);
580
+ if (!imgs.length) return;
581
+ this.previewImages = imgs;
582
+ this.$viewer.index = i;
583
+ this.$viewer.show();
584
+ }
585
+ }
586
+ };
587
+ </script>
588
+
589
+ <style lang="less" scoped>
590
+ .r-choice {
591
+ /deep/ .ant-radio-group {
592
+ width: 100%;
593
+ }
594
+ /deep/ .choice-radio,
595
+ /deep/ .choice-checkbox {
596
+ display: inline-flex;
597
+ align-items: center;
598
+ margin-bottom: 5px;
599
+ margin-right: 8px;
600
+ margin-left: 0px;
601
+ > span:last-child {
602
+ flex: 1;
603
+ display: inline-flex;
604
+ align-items: center;
605
+ word-break: break-all;
606
+ }
607
+ input {
608
+ height: 100%;
609
+ flex: 1;
610
+ background: transparent;
611
+ border-radius: 0;
612
+ border-color: transparent !important;
613
+ border-bottom: 1px solid #d9d9d9 !important;
614
+ }
615
+ .prefix-span {
616
+ padding-right: 8px;
617
+ }
618
+ .suffix-span {
619
+ padding-left: 8px;
620
+ }
621
+ }
622
+
623
+ /deep/ .block-radio,
624
+ /deep/ .block-checkbox {
625
+ display: flex;
626
+ margin-left: 8px;
627
+ }
628
+ /deep/ .ant-select {
629
+ min-width: 160px;
630
+ }
631
+ /deep/ .ant-select ~ div {
632
+ position: relative !important;
633
+ }
634
+ /deep/.ant-select-dropdown {
635
+ top: 0px !important;
636
+ left: 1px !important;
637
+ }
638
+ .choice-wrap {
639
+ display: flex;
640
+ flex-wrap: wrap;
641
+ .scale-choice-img-wrap {
642
+ position: relative;
643
+ width: 74px;
644
+ min-width: 74px;
645
+ height: 62px;
646
+ background: #ffffff;
647
+ border-radius: 4px;
648
+ border: 1px solid #d5d5d5;
649
+ margin-right: 16px;
650
+ &:hover {
651
+ .scale-preview-wrap {
652
+ display: flex;
653
+ }
654
+ }
655
+ > img {
656
+ width: 100%;
657
+ height: 100%;
658
+ object-fit: cover;
659
+ }
660
+ .scale-preview-wrap {
661
+ position: absolute;
662
+ top: 0;
663
+ left: 0;
664
+ right: 0;
665
+ bottom: 0;
666
+ display: none;
667
+ justify-content: center;
668
+ align-items: center;
669
+ background: rgba(0, 0, 0, 0.75);
670
+ border-radius: 8px;
671
+ font-size: 20px;
672
+ i.anticon {
673
+ color: #fff;
674
+ margin: 0px;
675
+ }
676
+ }
677
+ }
678
+ /deep/ .choose-value .el-tooltip.ellipsis {
679
+ color: rgba(0, 0, 0, 0.65);
680
+ font-size: 14px;
681
+ }
682
+ label {
683
+ margin: 4px 0;
684
+ }
685
+ /deep/.ant-radio-wrapper span.ant-radio + * {
686
+ display: inline-flex;
687
+ align-items: center;
688
+ white-space: initial;
689
+ }
690
+ &.choice-wrap-1 label {
691
+ width: 100%;
692
+ /deep/ input {
693
+ max-width: 300px;
694
+ }
695
+ }
696
+ &.choice-wrap-2 label {
697
+ width: 50%;
698
+ }
699
+ &.choice-wrap-3 label {
700
+ width: 33%;
701
+ }
702
+ &.choice-wrap-4 label {
703
+ width: 25%;
704
+ }
705
+ /deep/ .ant-checkbox {
706
+ // margin-top: -0.2em;
707
+ margin-top: 5px;
708
+ }
709
+ /deep/ .ant-checkbox-inner {
710
+ vertical-align: top;
711
+ }
712
+ }
713
+ }
714
+ </style>