widget.qw 1.0.83 → 1.0.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.development +10 -10
- package/.env.production +8 -8
- package/README.md +75 -75
- package/build/style.css +521 -471
- package/build/widget.qw.es.js +253 -84
- package/build/widget.qw.umd.js +252 -83
- package/index.html +17 -17
- package/package.json +47 -47
- package/src/App.vue +26 -26
- package/src/api/index.js +173 -165
- package/src/components/AuditBar.vue +396 -396
- package/src/components/BillCard.vue +164 -164
- package/src/components/CascaderPicker.vue +132 -132
- package/src/components/CascaderPop.vue +375 -371
- package/src/components/CheckGroup.vue +113 -113
- package/src/components/DatetimeDropdown.vue +62 -0
- package/src/components/{DatetimePicker/index.vue → DatetimePicker.vue} +124 -124
- package/src/components/DayDropdown.vue +56 -56
- package/src/components/FilePicker.vue +169 -169
- package/src/components/HeadBar.vue +130 -0
- package/src/components/Input.vue +80 -80
- package/src/components/MonthDropdown.vue +51 -51
- package/src/components/MultiPicker.vue +123 -123
- package/src/components/ObjsEditor.vue +334 -334
- package/src/components/SecretNotify.js +5 -5
- package/src/components/Sheet.vue +92 -92
- package/src/components/SingleApiPicker.vue +108 -108
- package/src/components/SinglePicker.vue +102 -102
- package/src/components/SingleUserSelector.vue +425 -425
- package/src/components/Switch.vue +64 -64
- package/src/components/TreePicker.vue +113 -113
- package/src/components/UserPicker.vue +106 -106
- package/src/components/UserProfile.vue +129 -129
- package/src/components/UsersPicker.vue +118 -118
- package/src/components/YearDropdown.vue +59 -59
- package/src/components/data_selector.vue +303 -303
- package/src/components/image_picker.vue +123 -123
- package/src/components/images_picker.vue +195 -195
- package/src/components/index.js +172 -162
- package/src/components/mult_list_selector.vue +155 -155
- package/src/components/subdepartment_selector.vue +481 -481
- package/src/components/user_selector.vue +639 -639
- package/src/components/widget/DataPop.vue +95 -95
- package/src/components/{DatetimePicker → widget}/DatetimePop.vue +342 -342
- package/src/components/widget/TreePop.vue +88 -88
- package/src/components/widget/UserPop.vue +347 -347
- package/src/main.js +117 -117
- package/src/router/index.ts +183 -173
- package/src/util/array_util.js +32 -32
- package/src/util/auth_util.js +72 -72
- package/src/util/bool_util.js +5 -5
- package/src/util/bus.js +1 -1
- package/src/util/cache_util.js +18 -18
- package/src/util/errer_code.js +6 -6
- package/src/util/eval_util.js +19 -19
- package/src/util/icon_util.js +36 -36
- package/src/util/image_util.js +27 -27
- package/src/util/index.js +57 -57
- package/src/util/num_util.js +70 -70
- package/src/util/obj_util.js +28 -28
- package/src/util/request.js +73 -73
- package/src/util/request_json.js +71 -71
- package/src/util/request_json_mute.js +65 -65
- package/src/util/request_upload.js +79 -79
- package/src/util/route_util.js +31 -31
- package/src/util/str_util.js +143 -143
- package/src/util/time_util.js +406 -406
- package/src/util/toast_util.js +24 -24
- package/src/util/tree_util.js +153 -153
- package/src/util/uuid_util.js +9 -9
- package/src/util/validate.js +182 -182
- package/src/util/vue_filter.js +223 -223
- package/src/views/auditbar/index.vue +78 -78
- package/src/views/billcard/index.vue +48 -48
- package/src/views/cascaderpicker/index.vue +0 -0
- package/src/views/cascaderpicker/userpicker.vue +183 -0
- package/src/views/cascaderpop/index.vue +90 -90
- package/src/views/checkgroup/index.vue +35 -35
- package/src/views/dataSelector/index.vue +48 -48
- package/src/views/datetimedropdown/index.vue +34 -0
- package/src/views/datetimepicker/index.vue +34 -34
- package/src/views/daydropdown/index.vue +31 -31
- package/src/views/filepicker/index.vue +32 -32
- package/src/views/headbar/index.vue +28 -0
- package/src/views/home/index.vue +0 -0
- package/src/views/imagepicker/index.vue +31 -31
- package/src/views/imagespicker/index.vue +37 -37
- package/src/views/input/index.vue +35 -35
- package/src/views/monthdropdown/index.vue +31 -31
- package/src/views/multListSelector/index.vue +61 -61
- package/src/views/multipicker/index.vue +36 -36
- package/src/views/objseditor/index.vue +277 -277
- package/src/views/productSelector/index.vue +35 -35
- package/src/views/projectpicker/index.vue +41 -41
- package/src/views/secretnotify/index.vue +27 -27
- package/src/views/sheet/index.vue +45 -45
- package/src/views/singlepicker/index.vue +35 -35
- package/src/views/subdepartmentSelector/index.vue +40 -40
- package/src/views/switch/index.vue +34 -34
- package/src/views/treepicker/index.vue +41 -41
- package/src/views/userSelector/index.vue +54 -54
- package/src/views/userSelectorNew/index.vue +45 -45
- package/src/views/userpicker/index.vue +43 -43
- package/src/views/userprofile/index.vue +30 -30
- package/src/views/userspicker/index.vue +43 -43
- package/src/views/yeardropdown/index.vue +32 -32
- package/src/vm/index.js +1 -1
- package/vite.config.ts +122 -122
|
@@ -1,304 +1,304 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<!-- 显示已选数据 -->
|
|
4
|
-
<van-field v-if="!isGone" type="textarea" rows="1" autosize :modelValue="selectdItemsLabel" clearable
|
|
5
|
-
:required="isRequired" :label="label" :name="name" v-bind="$attrs" @click-right-icon="showPopup" @clear="onClear"
|
|
6
|
-
:right-icon="rightIcon" :rules="props.rules" :class="{ 'disabled-field': isReadonly }" />
|
|
7
|
-
<!-- 数据选择弹出层 -->
|
|
8
|
-
<van-popup v-model:show="popupVisible" position="bottom" class="popup-style">
|
|
9
|
-
<div>
|
|
10
|
-
<div class="pad10 flex-between showMultipleButton">
|
|
11
|
-
<van-button plain size="normal" @click="cancelSelection">取消</van-button>
|
|
12
|
-
<div class="bold">{{ label }}</div>
|
|
13
|
-
<van-button plain type="primary" size="normal" @click="confirmSelection">确定</van-button>
|
|
14
|
-
</div>
|
|
15
|
-
<!-- 搜索框 -->
|
|
16
|
-
<van-field left-icon="search" v-model.trim="searchKeyword" clearable placeholder="请输入搜索关键字" />
|
|
17
|
-
<!-- 全选 -->
|
|
18
|
-
<div v-if="props.multiple" class="select-all-container">
|
|
19
|
-
<van-checkbox shape="square" v-model="isAllChecked" @click="toggleAllSelect"
|
|
20
|
-
label-position="left">全选</van-checkbox>
|
|
21
|
-
</div>
|
|
22
|
-
<!-- 数据列表 -->
|
|
23
|
-
<div class="checkbox-style">
|
|
24
|
-
<van-checkbox-group v-model="checkedValue" v-if="props.multiple">
|
|
25
|
-
<van-cell-group>
|
|
26
|
-
<van-cell v-for="(item, index) in filteredColumns" :key="index" :title="item.text" clickable
|
|
27
|
-
@click="toggle(index)">
|
|
28
|
-
<template #right-icon>
|
|
29
|
-
<!-- 修改点:添加 shape="square" -->
|
|
30
|
-
<van-checkbox :name="item.value" :ref="(el) => (checkboxRefs[index] = el)" shape="square"
|
|
31
|
-
@click.stop />
|
|
32
|
-
</template>
|
|
33
|
-
</van-cell>
|
|
34
|
-
</van-cell-group>
|
|
35
|
-
</van-checkbox-group>
|
|
36
|
-
<van-radio-group v-model="checkedValue" v-else>
|
|
37
|
-
<van-cell-group>
|
|
38
|
-
<van-cell v-for="(item, index) in filteredColumns" :key="index" :title="item.text" clickable
|
|
39
|
-
@click="radioToggle(item.value)">
|
|
40
|
-
<template #right-icon>
|
|
41
|
-
<!-- 单选保持圆形(默认样式) -->
|
|
42
|
-
<van-radio :name="item.value" />
|
|
43
|
-
</template>
|
|
44
|
-
</van-cell>
|
|
45
|
-
</van-cell-group>
|
|
46
|
-
</van-radio-group>
|
|
47
|
-
</div>
|
|
48
|
-
</div>
|
|
49
|
-
</van-popup>
|
|
50
|
-
</div>
|
|
51
|
-
</template>
|
|
52
|
-
|
|
53
|
-
<script setup>
|
|
54
|
-
import { onMounted, ref, onBeforeUpdate, computed, nextTick, watch } from "vue"
|
|
55
|
-
import util from '../util'
|
|
56
|
-
|
|
57
|
-
const props = defineProps({
|
|
58
|
-
multiple: {
|
|
59
|
-
type: Boolean,
|
|
60
|
-
default: false
|
|
61
|
-
},
|
|
62
|
-
options: {
|
|
63
|
-
type: Array,
|
|
64
|
-
required: true,
|
|
65
|
-
},
|
|
66
|
-
modelValue: {
|
|
67
|
-
type: [Array, String, Number]
|
|
68
|
-
},
|
|
69
|
-
columnsFieldNames: {
|
|
70
|
-
type: Object,
|
|
71
|
-
default: {
|
|
72
|
-
text: 'text',
|
|
73
|
-
value: 'value'
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
rules: {
|
|
77
|
-
type: Array,
|
|
78
|
-
default: () => []
|
|
79
|
-
},
|
|
80
|
-
required: {
|
|
81
|
-
type: Boolean,
|
|
82
|
-
default: false,
|
|
83
|
-
},
|
|
84
|
-
readonly: {
|
|
85
|
-
type: Boolean,
|
|
86
|
-
default: false,
|
|
87
|
-
},
|
|
88
|
-
auth: {
|
|
89
|
-
type: String,
|
|
90
|
-
default: ''
|
|
91
|
-
},
|
|
92
|
-
label: String,
|
|
93
|
-
name: String,
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
const { isRequired, isReadonly, isGone, isDisabled } = util.props2auth(props)
|
|
97
|
-
const emit = defineEmits(["update:modelValue", "select"]);
|
|
98
|
-
|
|
99
|
-
const rightIcon = computed(() => {
|
|
100
|
-
if (isReadonly.value || isDisabled.value)
|
|
101
|
-
return ''
|
|
102
|
-
|
|
103
|
-
return 'arrow'
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
const selectedItems = ref([]);
|
|
107
|
-
const selectdItemsLabel = computed(() => {
|
|
108
|
-
if (!selectedItems.value)
|
|
109
|
-
return ''
|
|
110
|
-
|
|
111
|
-
return selectedItems.value.join(',')
|
|
112
|
-
})
|
|
113
|
-
const popupVisible = ref(false);
|
|
114
|
-
const searchKeyword = ref(null);
|
|
115
|
-
const checkboxRefs = ref([]);
|
|
116
|
-
const checkedValue = ref([]);
|
|
117
|
-
const isAllChecked = ref(false);
|
|
118
|
-
const formatOptions = computed(() => {
|
|
119
|
-
if (!props.options)
|
|
120
|
-
return []
|
|
121
|
-
|
|
122
|
-
return props.options.map(item => {
|
|
123
|
-
return {
|
|
124
|
-
...item,
|
|
125
|
-
text: item[props.columnsFieldNames.text],
|
|
126
|
-
value: item[props.columnsFieldNames.value]
|
|
127
|
-
}
|
|
128
|
-
})
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
const findTextsByValues = (valuesToFind, data) => {
|
|
132
|
-
return valuesToFind.map((value) => {
|
|
133
|
-
const foundItem = data.find((item) => item.value === value);
|
|
134
|
-
return foundItem ? foundItem.text : null;
|
|
135
|
-
});
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const values2items = (values) => {
|
|
139
|
-
if (!values || values.length < 1 || !formatOptions.value || formatOptions.value.length < 1)
|
|
140
|
-
return []
|
|
141
|
-
|
|
142
|
-
let res = formatOptions.value.filter(option => values.includes(option.value))
|
|
143
|
-
return res
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const reShow = () => {
|
|
147
|
-
if (props.modelValue) {
|
|
148
|
-
if (Array.isArray(formatOptions.value)) {
|
|
149
|
-
if (props.multiple) {
|
|
150
|
-
selectedItems.value = findTextsByValues(props.modelValue, formatOptions.value);
|
|
151
|
-
} else {
|
|
152
|
-
const foundItem = formatOptions.value.find((item) => item.value === props.modelValue);
|
|
153
|
-
selectedItems.value = foundItem ? [foundItem.text] : [];
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
onMounted(() => {
|
|
160
|
-
nextTick(() => {
|
|
161
|
-
reShow();
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
const onClear = () => {
|
|
166
|
-
console.log('11111111111111')
|
|
167
|
-
selectedItems.value = []
|
|
168
|
-
if (props.multiple) {
|
|
169
|
-
emit("update:modelValue", [])
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
emit("update:modelValue", null)
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const toggle = (index) => {
|
|
177
|
-
checkboxRefs.value[index].toggle();
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
onBeforeUpdate(() => {
|
|
181
|
-
checkboxRefs.value = [];
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
const showPopup = () => {
|
|
185
|
-
// 若状态为只读,则不弹出窗口
|
|
186
|
-
if (isReadonly.value) {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
if (props.multiple) {
|
|
190
|
-
checkedValue.value = Array.isArray(props.modelValue) ? props.modelValue : [];
|
|
191
|
-
} else {
|
|
192
|
-
checkedValue.value = props.modelValue;
|
|
193
|
-
}
|
|
194
|
-
popupVisible.value = true;
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const cancelSelection = () => {
|
|
198
|
-
popupVisible.value = false;
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
const confirmSelection = () => {
|
|
202
|
-
if (props.multiple) {
|
|
203
|
-
selectedItems.value = findTextsByValues(checkedValue.value, formatOptions.value);
|
|
204
|
-
emit("update:modelValue", checkedValue.value);
|
|
205
|
-
emit("select", values2items(checkedValue.value))
|
|
206
|
-
} else {
|
|
207
|
-
const foundItem = formatOptions.value.find((item) => item.value === checkedValue.value);
|
|
208
|
-
selectedItems.value = foundItem ? [foundItem.text] : [];
|
|
209
|
-
emit("update:modelValue", checkedValue.value);
|
|
210
|
-
emit("select", foundItem)
|
|
211
|
-
}
|
|
212
|
-
popupVisible.value = false;
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
const toggleAllSelect = () => {
|
|
216
|
-
if (isAllChecked.value) {
|
|
217
|
-
checkedValue.value = filteredColumns.value.map(item => item.value);
|
|
218
|
-
} else {
|
|
219
|
-
checkedValue.value = [];
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
const radioToggle = (value) => {
|
|
224
|
-
checkedValue.value = value;
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
const filteredColumns = computed(() => {
|
|
228
|
-
return formatOptions.value.filter((item) => {
|
|
229
|
-
return item.text.includes(searchKeyword.value) || item.value.includes(searchKeyword.value);
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
watch(checkedValue, () => {
|
|
234
|
-
if (props.multiple) {
|
|
235
|
-
if (filteredColumns.value.length === 0) {
|
|
236
|
-
isAllChecked.value = false;
|
|
237
|
-
} else {
|
|
238
|
-
isAllChecked.value = checkedValue.value.length === filteredColumns.value.length;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}, { deep: true });
|
|
242
|
-
|
|
243
|
-
// 在watch部分新增以下代码
|
|
244
|
-
watch(() => props.modelValue, (newVal) => {
|
|
245
|
-
nextTick(() => {
|
|
246
|
-
reShow();
|
|
247
|
-
});
|
|
248
|
-
}, { deep: true, immediate: true });
|
|
249
|
-
|
|
250
|
-
// 在options变化时也需要更新显示
|
|
251
|
-
watch(() => formatOptions.value, () => {
|
|
252
|
-
reShow();
|
|
253
|
-
}, { deep: true });
|
|
254
|
-
</script>
|
|
255
|
-
|
|
256
|
-
<style scoped>
|
|
257
|
-
.popup-style {
|
|
258
|
-
height: 21.25rem;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
.showMultipleButton {
|
|
262
|
-
padding-bottom: 0;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
.showMultipleButton .van-button {
|
|
266
|
-
border: 0;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
.flex-between {
|
|
270
|
-
padding: 10px;
|
|
271
|
-
display: flex;
|
|
272
|
-
justify-content: space-between;
|
|
273
|
-
align-items: center;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
.bold {
|
|
277
|
-
font-weight: bold;
|
|
278
|
-
color: #444;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
.checkbox-style {
|
|
282
|
-
/* height: 220px; */
|
|
283
|
-
height: calc(220px - 30px);
|
|
284
|
-
overflow-y: auto;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
.select-all-container {
|
|
288
|
-
font-size: 14px;
|
|
289
|
-
padding: 0 16px;
|
|
290
|
-
margin: 10px 0;
|
|
291
|
-
display: flex;
|
|
292
|
-
justify-content: flex-end;
|
|
293
|
-
align-items: center;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
.select-all-container .van-checkbox {
|
|
297
|
-
margin-left: auto;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/* 新增:调整方形复选框的边距 */
|
|
301
|
-
.van-checkbox--square {
|
|
302
|
-
margin-left: 8px;
|
|
303
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<!-- 显示已选数据 -->
|
|
4
|
+
<van-field v-if="!isGone" type="textarea" rows="1" autosize :modelValue="selectdItemsLabel" clearable
|
|
5
|
+
:required="isRequired" :label="label" :name="name" v-bind="$attrs" @click-right-icon="showPopup" @clear="onClear"
|
|
6
|
+
:right-icon="rightIcon" :rules="props.rules" :class="{ 'disabled-field': isReadonly }" />
|
|
7
|
+
<!-- 数据选择弹出层 -->
|
|
8
|
+
<van-popup v-model:show="popupVisible" position="bottom" class="popup-style">
|
|
9
|
+
<div>
|
|
10
|
+
<div class="pad10 flex-between showMultipleButton">
|
|
11
|
+
<van-button plain size="normal" @click="cancelSelection">取消</van-button>
|
|
12
|
+
<div class="bold">{{ label }}</div>
|
|
13
|
+
<van-button plain type="primary" size="normal" @click="confirmSelection">确定</van-button>
|
|
14
|
+
</div>
|
|
15
|
+
<!-- 搜索框 -->
|
|
16
|
+
<van-field left-icon="search" v-model.trim="searchKeyword" clearable placeholder="请输入搜索关键字" />
|
|
17
|
+
<!-- 全选 -->
|
|
18
|
+
<div v-if="props.multiple" class="select-all-container">
|
|
19
|
+
<van-checkbox shape="square" v-model="isAllChecked" @click="toggleAllSelect"
|
|
20
|
+
label-position="left">全选</van-checkbox>
|
|
21
|
+
</div>
|
|
22
|
+
<!-- 数据列表 -->
|
|
23
|
+
<div class="checkbox-style">
|
|
24
|
+
<van-checkbox-group v-model="checkedValue" v-if="props.multiple">
|
|
25
|
+
<van-cell-group>
|
|
26
|
+
<van-cell v-for="(item, index) in filteredColumns" :key="index" :title="item.text" clickable
|
|
27
|
+
@click="toggle(index)">
|
|
28
|
+
<template #right-icon>
|
|
29
|
+
<!-- 修改点:添加 shape="square" -->
|
|
30
|
+
<van-checkbox :name="item.value" :ref="(el) => (checkboxRefs[index] = el)" shape="square"
|
|
31
|
+
@click.stop />
|
|
32
|
+
</template>
|
|
33
|
+
</van-cell>
|
|
34
|
+
</van-cell-group>
|
|
35
|
+
</van-checkbox-group>
|
|
36
|
+
<van-radio-group v-model="checkedValue" v-else>
|
|
37
|
+
<van-cell-group>
|
|
38
|
+
<van-cell v-for="(item, index) in filteredColumns" :key="index" :title="item.text" clickable
|
|
39
|
+
@click="radioToggle(item.value)">
|
|
40
|
+
<template #right-icon>
|
|
41
|
+
<!-- 单选保持圆形(默认样式) -->
|
|
42
|
+
<van-radio :name="item.value" />
|
|
43
|
+
</template>
|
|
44
|
+
</van-cell>
|
|
45
|
+
</van-cell-group>
|
|
46
|
+
</van-radio-group>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</van-popup>
|
|
50
|
+
</div>
|
|
51
|
+
</template>
|
|
52
|
+
|
|
53
|
+
<script setup>
|
|
54
|
+
import { onMounted, ref, onBeforeUpdate, computed, nextTick, watch } from "vue"
|
|
55
|
+
import util from '../util'
|
|
56
|
+
|
|
57
|
+
const props = defineProps({
|
|
58
|
+
multiple: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: false
|
|
61
|
+
},
|
|
62
|
+
options: {
|
|
63
|
+
type: Array,
|
|
64
|
+
required: true,
|
|
65
|
+
},
|
|
66
|
+
modelValue: {
|
|
67
|
+
type: [Array, String, Number]
|
|
68
|
+
},
|
|
69
|
+
columnsFieldNames: {
|
|
70
|
+
type: Object,
|
|
71
|
+
default: {
|
|
72
|
+
text: 'text',
|
|
73
|
+
value: 'value'
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
rules: {
|
|
77
|
+
type: Array,
|
|
78
|
+
default: () => []
|
|
79
|
+
},
|
|
80
|
+
required: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: false,
|
|
83
|
+
},
|
|
84
|
+
readonly: {
|
|
85
|
+
type: Boolean,
|
|
86
|
+
default: false,
|
|
87
|
+
},
|
|
88
|
+
auth: {
|
|
89
|
+
type: String,
|
|
90
|
+
default: ''
|
|
91
|
+
},
|
|
92
|
+
label: String,
|
|
93
|
+
name: String,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const { isRequired, isReadonly, isGone, isDisabled } = util.props2auth(props)
|
|
97
|
+
const emit = defineEmits(["update:modelValue", "select"]);
|
|
98
|
+
|
|
99
|
+
const rightIcon = computed(() => {
|
|
100
|
+
if (isReadonly.value || isDisabled.value)
|
|
101
|
+
return ''
|
|
102
|
+
|
|
103
|
+
return 'arrow'
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
const selectedItems = ref([]);
|
|
107
|
+
const selectdItemsLabel = computed(() => {
|
|
108
|
+
if (!selectedItems.value)
|
|
109
|
+
return ''
|
|
110
|
+
|
|
111
|
+
return selectedItems.value.join(',')
|
|
112
|
+
})
|
|
113
|
+
const popupVisible = ref(false);
|
|
114
|
+
const searchKeyword = ref(null);
|
|
115
|
+
const checkboxRefs = ref([]);
|
|
116
|
+
const checkedValue = ref([]);
|
|
117
|
+
const isAllChecked = ref(false);
|
|
118
|
+
const formatOptions = computed(() => {
|
|
119
|
+
if (!props.options)
|
|
120
|
+
return []
|
|
121
|
+
|
|
122
|
+
return props.options.map(item => {
|
|
123
|
+
return {
|
|
124
|
+
...item,
|
|
125
|
+
text: item[props.columnsFieldNames.text],
|
|
126
|
+
value: item[props.columnsFieldNames.value]
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
const findTextsByValues = (valuesToFind, data) => {
|
|
132
|
+
return valuesToFind.map((value) => {
|
|
133
|
+
const foundItem = data.find((item) => item.value === value);
|
|
134
|
+
return foundItem ? foundItem.text : null;
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const values2items = (values) => {
|
|
139
|
+
if (!values || values.length < 1 || !formatOptions.value || formatOptions.value.length < 1)
|
|
140
|
+
return []
|
|
141
|
+
|
|
142
|
+
let res = formatOptions.value.filter(option => values.includes(option.value))
|
|
143
|
+
return res
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const reShow = () => {
|
|
147
|
+
if (props.modelValue) {
|
|
148
|
+
if (Array.isArray(formatOptions.value)) {
|
|
149
|
+
if (props.multiple) {
|
|
150
|
+
selectedItems.value = findTextsByValues(props.modelValue, formatOptions.value);
|
|
151
|
+
} else {
|
|
152
|
+
const foundItem = formatOptions.value.find((item) => item.value === props.modelValue);
|
|
153
|
+
selectedItems.value = foundItem ? [foundItem.text] : [];
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
onMounted(() => {
|
|
160
|
+
nextTick(() => {
|
|
161
|
+
reShow();
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const onClear = () => {
|
|
166
|
+
console.log('11111111111111')
|
|
167
|
+
selectedItems.value = []
|
|
168
|
+
if (props.multiple) {
|
|
169
|
+
emit("update:modelValue", [])
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
emit("update:modelValue", null)
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const toggle = (index) => {
|
|
177
|
+
checkboxRefs.value[index].toggle();
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
onBeforeUpdate(() => {
|
|
181
|
+
checkboxRefs.value = [];
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const showPopup = () => {
|
|
185
|
+
// 若状态为只读,则不弹出窗口
|
|
186
|
+
if (isReadonly.value) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (props.multiple) {
|
|
190
|
+
checkedValue.value = Array.isArray(props.modelValue) ? props.modelValue : [];
|
|
191
|
+
} else {
|
|
192
|
+
checkedValue.value = props.modelValue;
|
|
193
|
+
}
|
|
194
|
+
popupVisible.value = true;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const cancelSelection = () => {
|
|
198
|
+
popupVisible.value = false;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const confirmSelection = () => {
|
|
202
|
+
if (props.multiple) {
|
|
203
|
+
selectedItems.value = findTextsByValues(checkedValue.value, formatOptions.value);
|
|
204
|
+
emit("update:modelValue", checkedValue.value);
|
|
205
|
+
emit("select", values2items(checkedValue.value))
|
|
206
|
+
} else {
|
|
207
|
+
const foundItem = formatOptions.value.find((item) => item.value === checkedValue.value);
|
|
208
|
+
selectedItems.value = foundItem ? [foundItem.text] : [];
|
|
209
|
+
emit("update:modelValue", checkedValue.value);
|
|
210
|
+
emit("select", foundItem)
|
|
211
|
+
}
|
|
212
|
+
popupVisible.value = false;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const toggleAllSelect = () => {
|
|
216
|
+
if (isAllChecked.value) {
|
|
217
|
+
checkedValue.value = filteredColumns.value.map(item => item.value);
|
|
218
|
+
} else {
|
|
219
|
+
checkedValue.value = [];
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const radioToggle = (value) => {
|
|
224
|
+
checkedValue.value = value;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
const filteredColumns = computed(() => {
|
|
228
|
+
return formatOptions.value.filter((item) => {
|
|
229
|
+
return item.text.includes(searchKeyword.value) || item.value.includes(searchKeyword.value);
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
watch(checkedValue, () => {
|
|
234
|
+
if (props.multiple) {
|
|
235
|
+
if (filteredColumns.value.length === 0) {
|
|
236
|
+
isAllChecked.value = false;
|
|
237
|
+
} else {
|
|
238
|
+
isAllChecked.value = checkedValue.value.length === filteredColumns.value.length;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}, { deep: true });
|
|
242
|
+
|
|
243
|
+
// 在watch部分新增以下代码
|
|
244
|
+
watch(() => props.modelValue, (newVal) => {
|
|
245
|
+
nextTick(() => {
|
|
246
|
+
reShow();
|
|
247
|
+
});
|
|
248
|
+
}, { deep: true, immediate: true });
|
|
249
|
+
|
|
250
|
+
// 在options变化时也需要更新显示
|
|
251
|
+
watch(() => formatOptions.value, () => {
|
|
252
|
+
reShow();
|
|
253
|
+
}, { deep: true });
|
|
254
|
+
</script>
|
|
255
|
+
|
|
256
|
+
<style scoped>
|
|
257
|
+
.popup-style {
|
|
258
|
+
height: 21.25rem;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.showMultipleButton {
|
|
262
|
+
padding-bottom: 0;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.showMultipleButton .van-button {
|
|
266
|
+
border: 0;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.flex-between {
|
|
270
|
+
padding: 10px;
|
|
271
|
+
display: flex;
|
|
272
|
+
justify-content: space-between;
|
|
273
|
+
align-items: center;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.bold {
|
|
277
|
+
font-weight: bold;
|
|
278
|
+
color: #444;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.checkbox-style {
|
|
282
|
+
/* height: 220px; */
|
|
283
|
+
height: calc(220px - 30px);
|
|
284
|
+
overflow-y: auto;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.select-all-container {
|
|
288
|
+
font-size: 14px;
|
|
289
|
+
padding: 0 16px;
|
|
290
|
+
margin: 10px 0;
|
|
291
|
+
display: flex;
|
|
292
|
+
justify-content: flex-end;
|
|
293
|
+
align-items: center;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.select-all-container .van-checkbox {
|
|
297
|
+
margin-left: auto;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/* 新增:调整方形复选框的边距 */
|
|
301
|
+
.van-checkbox--square {
|
|
302
|
+
margin-left: 8px;
|
|
303
|
+
}
|
|
304
304
|
</style>
|