widget.qw 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.
- package/README.md +73 -0
- package/build/favicon.ico +0 -0
- package/build/style.css +763 -0
- package/build/widget.qw.es.js +20653 -0
- package/build/widget.qw.umd.js +20660 -0
- package/index.html +17 -0
- package/package.json +47 -0
- package/public/favicon.ico +0 -0
- package/src/App.vue +26 -0
- package/src/api/index.js +126 -0
- package/src/assets/avatar.png +0 -0
- package/src/assets/banner_handle.png +0 -0
- package/src/assets/bg_blue.png +0 -0
- package/src/assets/bg_white.png +0 -0
- package/src/assets/down.png +0 -0
- package/src/assets/home.jpg +0 -0
- package/src/assets/icon_box.png +0 -0
- package/src/assets/icon_dot.png +0 -0
- package/src/assets/icon_draw.png +0 -0
- package/src/assets/icon_file.png +0 -0
- package/src/assets/icon_fold.png +0 -0
- package/src/assets/icon_shield.png +0 -0
- package/src/assets/logo.png +0 -0
- package/src/components/AuditBar.vue +341 -0
- package/src/components/BillCard.vue +156 -0
- package/src/components/CheckGroup.vue +114 -0
- package/src/components/DatetimePicker/DatetimePop.vue +343 -0
- package/src/components/DatetimePicker/index.vue +113 -0
- package/src/components/DayDropdown.vue +57 -0
- package/src/components/FilePicker.vue +114 -0
- package/src/components/Input.vue +72 -0
- package/src/components/MonthDropdown.vue +52 -0
- package/src/components/MultiPicker.vue +124 -0
- package/src/components/ProjectDropdown.vue +62 -0
- package/src/components/ProjectPicker.vue +111 -0
- package/src/components/SecretNotify.js +6 -0
- package/src/components/Sheet.vue +93 -0
- package/src/components/SinglePicker.vue +103 -0
- package/src/components/SingleUserSelector.vue +425 -0
- package/src/components/Switch.vue +65 -0
- package/src/components/TreePicker.vue +113 -0
- package/src/components/UserPicker.vue +107 -0
- package/src/components/UserProfile.vue +128 -0
- package/src/components/UsersPicker.vue +118 -0
- package/src/components/YearDropdown.vue +60 -0
- package/src/components/data_selector.vue +281 -0
- package/src/components/image_picker.vue +115 -0
- package/src/components/images_picker.vue +140 -0
- package/src/components/index.js +157 -0
- package/src/components/mult_list_selector.vue +156 -0
- package/src/components/product_selector.vue +186 -0
- package/src/components/subdepartment_selector.vue +481 -0
- package/src/components/user_selector.vue +639 -0
- package/src/components/widget/DataPop.vue +96 -0
- package/src/components/widget/TreePop.vue +89 -0
- package/src/components/widget/UserPop.vue +347 -0
- package/src/env.d.ts +8 -0
- package/src/main.js +111 -0
- package/src/router/index.ts +165 -0
- package/src/util/array_util.js +32 -0
- package/src/util/auth_util.js +73 -0
- package/src/util/bool_util.js +6 -0
- package/src/util/bus.js +2 -0
- package/src/util/cache_util.js +19 -0
- package/src/util/errer_code.js +7 -0
- package/src/util/eval_util.js +20 -0
- package/src/util/icon_util.js +37 -0
- package/src/util/image_util.js +28 -0
- package/src/util/index.js +56 -0
- package/src/util/num_util.js +71 -0
- package/src/util/obj_util.js +29 -0
- package/src/util/request.js +74 -0
- package/src/util/request_json.js +72 -0
- package/src/util/request_json_mute.js +66 -0
- package/src/util/request_upload.js +79 -0
- package/src/util/route_util.js +32 -0
- package/src/util/str_util.js +144 -0
- package/src/util/time_util.js +407 -0
- package/src/util/toast_util.js +25 -0
- package/src/util/tree_util.js +120 -0
- package/src/util/validate.js +183 -0
- package/src/util/vue_filter.js +223 -0
- package/src/views/auditbar/index.vue +66 -0
- package/src/views/billcard/index.vue +46 -0
- package/src/views/checkgroup/index.vue +36 -0
- package/src/views/dataSelector/index.vue +49 -0
- package/src/views/datetimepicker/index.vue +35 -0
- package/src/views/daydropdown/index.vue +31 -0
- package/src/views/filepicker/index.vue +32 -0
- package/src/views/home/index.vue +64 -0
- package/src/views/imagepicker/index.vue +32 -0
- package/src/views/imagespicker/index.vue +32 -0
- package/src/views/input/index.vue +35 -0
- package/src/views/monthdropdown/index.vue +31 -0
- package/src/views/multListSelector/index.vue +61 -0
- package/src/views/multipicker/index.vue +37 -0
- package/src/views/productSelector/index.vue +35 -0
- package/src/views/projectdropdown/index.vue +31 -0
- package/src/views/projectpicker/index.vue +42 -0
- package/src/views/secretnotify/index.vue +28 -0
- package/src/views/sheet/index.vue +46 -0
- package/src/views/singlepicker/index.vue +36 -0
- package/src/views/subdepartmentSelector/index.vue +41 -0
- package/src/views/switch/index.vue +35 -0
- package/src/views/treepicker/index.vue +42 -0
- package/src/views/userSelector/index.vue +54 -0
- package/src/views/userSelectorNew/index.vue +45 -0
- package/src/views/userpicker/index.vue +43 -0
- package/src/views/userprofile/index.vue +30 -0
- package/src/views/userspicker/index.vue +43 -0
- package/src/views/yeardropdown/index.vue +32 -0
- package/src/vm/index.js +6 -0
- package/tsconfig.json +19 -0
- package/tsconfig.node.json +8 -0
- package/vite.config.ts +73 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<!-- 显示已选数据 -->
|
|
4
|
+
<van-field
|
|
5
|
+
v-if="!isGone"
|
|
6
|
+
type="textarea"
|
|
7
|
+
rows="1"
|
|
8
|
+
autosize
|
|
9
|
+
:modelValue="selectedItems"
|
|
10
|
+
readonly
|
|
11
|
+
clearable
|
|
12
|
+
:required="isRequired"
|
|
13
|
+
:label="label"
|
|
14
|
+
:name="name"
|
|
15
|
+
v-bind="$attrs"
|
|
16
|
+
@click="showPopup"
|
|
17
|
+
:right-icon="isReadonly ? '' : 'arrow'"
|
|
18
|
+
:rules="props.rules"
|
|
19
|
+
:class="{ 'disabled-field': isReadonly }"
|
|
20
|
+
/>
|
|
21
|
+
<!-- 数据选择弹出层 -->
|
|
22
|
+
<van-popup v-model:show="popupVisible" position="bottom" class="popup-style">
|
|
23
|
+
<div>
|
|
24
|
+
<div class="pad10 flex-between showMultipleButton">
|
|
25
|
+
<van-button plain size="normal" @click="cancelSelection">取消</van-button>
|
|
26
|
+
<div class="bold">{{ label }}</div>
|
|
27
|
+
<van-button plain type="primary" size="normal" @click="confirmSelection">确定</van-button>
|
|
28
|
+
</div>
|
|
29
|
+
<!-- 搜索框 -->
|
|
30
|
+
<van-field left-icon="search" v-model.trim="searchKeyword" clearable placeholder="请输入搜索关键字" />
|
|
31
|
+
<!-- 全选 -->
|
|
32
|
+
<div v-if="mode === 'multiple'" class="select-all-container">
|
|
33
|
+
<van-checkbox shape="square" v-model="isAllChecked" @click="toggleAllSelect" label-position="left">全选</van-checkbox>
|
|
34
|
+
</div>
|
|
35
|
+
<!-- 数据列表 -->
|
|
36
|
+
<div class="checkbox-style">
|
|
37
|
+
<van-checkbox-group v-model="checkedValue" v-if="mode === 'multiple'">
|
|
38
|
+
<van-cell-group>
|
|
39
|
+
<van-cell v-for="(item, index) in filteredColumns" :key="index" :title="item.text" clickable
|
|
40
|
+
@click="toggle(index)">
|
|
41
|
+
<template #right-icon>
|
|
42
|
+
<!-- 修改点:添加 shape="square" -->
|
|
43
|
+
<van-checkbox
|
|
44
|
+
:name="item.value"
|
|
45
|
+
:ref="(el) => (checkboxRefs[index] = el)"
|
|
46
|
+
shape="square"
|
|
47
|
+
@click.stop
|
|
48
|
+
/>
|
|
49
|
+
</template>
|
|
50
|
+
</van-cell>
|
|
51
|
+
</van-cell-group>
|
|
52
|
+
</van-checkbox-group>
|
|
53
|
+
<van-radio-group v-model="checkedValue" v-else>
|
|
54
|
+
<van-cell-group>
|
|
55
|
+
<van-cell v-for="(item, index) in filteredColumns" :key="index" :title="item.text" clickable
|
|
56
|
+
@click="radioToggle(item.value)">
|
|
57
|
+
<template #right-icon>
|
|
58
|
+
<!-- 单选保持圆形(默认样式) -->
|
|
59
|
+
<van-radio :name="item.value" />
|
|
60
|
+
</template>
|
|
61
|
+
</van-cell>
|
|
62
|
+
</van-cell-group>
|
|
63
|
+
</van-radio-group>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
</van-popup>
|
|
67
|
+
</div>
|
|
68
|
+
</template>
|
|
69
|
+
|
|
70
|
+
<script setup>
|
|
71
|
+
import { onMounted, ref, onBeforeUpdate, computed, nextTick, watch } from "vue"
|
|
72
|
+
import util from '../util'
|
|
73
|
+
|
|
74
|
+
const props = defineProps({
|
|
75
|
+
mode: {
|
|
76
|
+
type: String,
|
|
77
|
+
default: 'multiple', // 'single' | 'multiple'
|
|
78
|
+
validator: (v) => ['single', 'multiple'].includes(v)
|
|
79
|
+
},
|
|
80
|
+
options: {
|
|
81
|
+
type: Array,
|
|
82
|
+
required: true,
|
|
83
|
+
},
|
|
84
|
+
modelValue: {
|
|
85
|
+
type: [Array, String, Number],
|
|
86
|
+
default: () => [],
|
|
87
|
+
},
|
|
88
|
+
rules: {
|
|
89
|
+
type: Array,
|
|
90
|
+
default: () => []
|
|
91
|
+
},
|
|
92
|
+
required: {
|
|
93
|
+
type: Boolean,
|
|
94
|
+
default: false,
|
|
95
|
+
},
|
|
96
|
+
readonly: {
|
|
97
|
+
type: Boolean,
|
|
98
|
+
default: false,
|
|
99
|
+
},
|
|
100
|
+
auth:{
|
|
101
|
+
type: String,
|
|
102
|
+
default:''
|
|
103
|
+
},
|
|
104
|
+
label: String,
|
|
105
|
+
name: String,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const {isRequired, isReadonly, isGone,isDisabled} = util.props2auth(props)
|
|
109
|
+
const emit = defineEmits(["update:modelValue","select"]);
|
|
110
|
+
|
|
111
|
+
const selectedItems = ref([]);
|
|
112
|
+
const popupVisible = ref(false);
|
|
113
|
+
const searchKeyword = ref(null);
|
|
114
|
+
const checkboxRefs = ref([]);
|
|
115
|
+
const checkedValue = ref([]);
|
|
116
|
+
const isAllChecked = ref(false);
|
|
117
|
+
|
|
118
|
+
const findTextsByValues = (valuesToFind, data) => {
|
|
119
|
+
return valuesToFind.map((value) => {
|
|
120
|
+
const foundItem = data.find((item) => item.value === value);
|
|
121
|
+
return foundItem ? foundItem.text : null;
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const values2items = (values)=>{
|
|
126
|
+
if(!values || values.length<1 || !props.options || props.options.length<1)
|
|
127
|
+
return []
|
|
128
|
+
|
|
129
|
+
let res = props.options.filter(option=>values.includes(option.value))
|
|
130
|
+
return res
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const reShow = () => {
|
|
134
|
+
if (props.modelValue) {
|
|
135
|
+
if (Array.isArray(props.options)) {
|
|
136
|
+
if (props.mode === 'multiple') {
|
|
137
|
+
selectedItems.value = findTextsByValues(props.modelValue, props.options);
|
|
138
|
+
} else {
|
|
139
|
+
const foundItem = props.options.find((item) => item.value === props.modelValue);
|
|
140
|
+
selectedItems.value = foundItem ? [foundItem.text] : [];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
onMounted(() => {
|
|
147
|
+
nextTick(() => {
|
|
148
|
+
reShow();
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const toggle = (index) => {
|
|
153
|
+
checkboxRefs.value[index].toggle();
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
onBeforeUpdate(() => {
|
|
157
|
+
checkboxRefs.value = [];
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const showPopup = () => {
|
|
161
|
+
// 若状态为只读,则不弹出窗口
|
|
162
|
+
if (isReadonly.value) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (props.mode === 'multiple') {
|
|
166
|
+
checkedValue.value = Array.isArray(props.modelValue) ? props.modelValue : [];
|
|
167
|
+
} else {
|
|
168
|
+
checkedValue.value = props.modelValue;
|
|
169
|
+
}
|
|
170
|
+
popupVisible.value = true;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const cancelSelection = () => {
|
|
174
|
+
popupVisible.value = false;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const confirmSelection = () => {
|
|
178
|
+
if (props.mode === 'multiple') {
|
|
179
|
+
selectedItems.value = findTextsByValues(checkedValue.value, props.options);
|
|
180
|
+
emit("update:modelValue", checkedValue.value);
|
|
181
|
+
emit("select",values2items(checkedValue.value))
|
|
182
|
+
} else {
|
|
183
|
+
const foundItem = props.options.find((item) => item.value === checkedValue.value);
|
|
184
|
+
selectedItems.value = foundItem ? [foundItem.text] : [];
|
|
185
|
+
emit("update:modelValue", checkedValue.value);
|
|
186
|
+
emit("select", foundItem)
|
|
187
|
+
}
|
|
188
|
+
popupVisible.value = false;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const toggleAllSelect = () => {
|
|
192
|
+
if (isAllChecked.value) {
|
|
193
|
+
checkedValue.value = filteredColumns.value.map(item => item.value);
|
|
194
|
+
} else {
|
|
195
|
+
checkedValue.value = [];
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const radioToggle = (value) => {
|
|
200
|
+
checkedValue.value = value;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const filteredColumns = computed(() => {
|
|
204
|
+
return props.options.filter((item) => {
|
|
205
|
+
return item.text.includes(searchKeyword.value) || item.value.includes(searchKeyword.value);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
watch(checkedValue, () => {
|
|
210
|
+
if (props.mode === 'multiple') {
|
|
211
|
+
if (filteredColumns.value.length === 0) {
|
|
212
|
+
isAllChecked.value = false;
|
|
213
|
+
} else {
|
|
214
|
+
isAllChecked.value = checkedValue.value.length === filteredColumns.value.length;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}, { deep: true });
|
|
218
|
+
|
|
219
|
+
// 在watch部分新增以下代码
|
|
220
|
+
watch(() => props.modelValue, (newVal) => {
|
|
221
|
+
nextTick(() => {
|
|
222
|
+
reShow();
|
|
223
|
+
});
|
|
224
|
+
}, { deep: true, immediate: true });
|
|
225
|
+
|
|
226
|
+
// 在options变化时也需要更新显示
|
|
227
|
+
watch(() => props.options, () => {
|
|
228
|
+
reShow();
|
|
229
|
+
}, { deep: true });
|
|
230
|
+
</script>
|
|
231
|
+
|
|
232
|
+
<style scoped>
|
|
233
|
+
.popup-style {
|
|
234
|
+
height: 21.25rem;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.showMultipleButton {
|
|
238
|
+
padding-bottom: 0;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.showMultipleButton .van-button {
|
|
242
|
+
border: 0;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.flex-between {
|
|
246
|
+
padding: 10px;
|
|
247
|
+
display: flex;
|
|
248
|
+
justify-content: space-between;
|
|
249
|
+
align-items: center;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.bold {
|
|
253
|
+
font-weight: bold;
|
|
254
|
+
color: #444;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.checkbox-style {
|
|
258
|
+
/* height: 220px; */
|
|
259
|
+
height: calc(220px - 30px);
|
|
260
|
+
overflow-y: auto;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.select-all-container {
|
|
264
|
+
font-size: 14px;
|
|
265
|
+
padding: 0 16px;
|
|
266
|
+
margin: 10px 0;
|
|
267
|
+
display: flex;
|
|
268
|
+
justify-content: flex-end;
|
|
269
|
+
align-items: center;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.select-all-container .van-checkbox {
|
|
273
|
+
margin-left: auto;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/* 新增:调整方形复选框的边距 */
|
|
277
|
+
.van-checkbox--square {
|
|
278
|
+
margin-left: 8px;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
</style>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<van-field v-if="!isGone" name="image" :label="props.label" :required="isRequired" :rules="props.rules"
|
|
3
|
+
label-class="label" :placeholder="props.placeholder">
|
|
4
|
+
<template #input>
|
|
5
|
+
<div class="image-box">
|
|
6
|
+
<van-uploader v-model="files" :max-count="1" accept="image/jpeg,image/png" :afterRead="onAfterRead" :disabled="isDisabled"
|
|
7
|
+
:deletable="!isDisabled"
|
|
8
|
+
:before-delete="onBeforeDelete" />
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
</van-field>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script setup>
|
|
15
|
+
import { ref, computed, onMounted, defineProps, defineEmits, watch } from "vue"
|
|
16
|
+
import util from '../util'
|
|
17
|
+
import { useVModel } from "@vueuse/core"
|
|
18
|
+
|
|
19
|
+
const props = defineProps({
|
|
20
|
+
modelValue: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: ''
|
|
23
|
+
},
|
|
24
|
+
label: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: ''
|
|
27
|
+
},
|
|
28
|
+
required: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: false
|
|
31
|
+
},
|
|
32
|
+
readonly: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: false
|
|
35
|
+
},
|
|
36
|
+
placeholder:{
|
|
37
|
+
type:String,
|
|
38
|
+
default:''
|
|
39
|
+
},
|
|
40
|
+
compress: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: true
|
|
43
|
+
},
|
|
44
|
+
rules: {
|
|
45
|
+
type: Array,
|
|
46
|
+
default: () => []
|
|
47
|
+
},
|
|
48
|
+
auth: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: ''
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const emit = defineEmits(['update:modelValue'])
|
|
55
|
+
const modelValue = useVModel(props, 'modelValue', emit)
|
|
56
|
+
const { isRequired, isReadonly, isGone, isDisabled } = util.props2auth(props)
|
|
57
|
+
|
|
58
|
+
const files = ref([])
|
|
59
|
+
|
|
60
|
+
onMounted(() => {
|
|
61
|
+
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const onAfterRead = async (file) => {
|
|
65
|
+
console.log(file)
|
|
66
|
+
|
|
67
|
+
let compress_file = file.file
|
|
68
|
+
if (props.compress) {
|
|
69
|
+
compress_file = await util.compress_image(file.file)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let params = {
|
|
73
|
+
file: compress_file
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return util.file_upload(params).then(res => {
|
|
77
|
+
modelValue.value = res.data.url
|
|
78
|
+
return Promise.resolve(file)
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const onBeforeDelete = (e) => {
|
|
83
|
+
modelValue.value = ''
|
|
84
|
+
return Promise.resolve(e)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
watch(() => props.modelValue,
|
|
88
|
+
(newVal, oldVal) => {
|
|
89
|
+
if (!props.modelValue) {
|
|
90
|
+
files.value = []
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
files.value = [{
|
|
95
|
+
url: props.modelValue
|
|
96
|
+
}]
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
immediate: true
|
|
100
|
+
}
|
|
101
|
+
)
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
<style lang="scss" scoped>
|
|
105
|
+
:deep(.label) {
|
|
106
|
+
color: #000 !important;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
:deep(.van-field__control:disabled) {
|
|
110
|
+
color: #000 !important;
|
|
111
|
+
cursor: not-allowed;
|
|
112
|
+
opacity: 1;
|
|
113
|
+
-webkit-text-fill-color: #000;
|
|
114
|
+
}
|
|
115
|
+
</style>
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<van-field name="image" :label="props.label" :required="isRequired" :rules="props.rules"
|
|
3
|
+
label-class="label" :placeholder="props.placeholder">
|
|
4
|
+
<template #input>
|
|
5
|
+
<div class="image-box">
|
|
6
|
+
<van-uploader v-model="files" :max-count="props.max" accept="image/jpeg,image/png"
|
|
7
|
+
:disabled="isDisabled"
|
|
8
|
+
:deletable="!isDisabled"
|
|
9
|
+
:afterRead="onAfterRead"
|
|
10
|
+
:before-delete="onBeforeDelete" />
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
</van-field>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup>
|
|
17
|
+
import { ref, computed, onMounted, defineProps, defineEmits, watch } from "vue"
|
|
18
|
+
import util from "@/util"
|
|
19
|
+
import { useVModel } from "@vueuse/core"
|
|
20
|
+
|
|
21
|
+
const props = defineProps({
|
|
22
|
+
modelValue: {
|
|
23
|
+
type: Array,
|
|
24
|
+
default: []
|
|
25
|
+
},
|
|
26
|
+
label: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: ''
|
|
29
|
+
},
|
|
30
|
+
required: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: false
|
|
33
|
+
},
|
|
34
|
+
readonly: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false
|
|
37
|
+
},
|
|
38
|
+
placeholder: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: ''
|
|
41
|
+
},
|
|
42
|
+
compress: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: true
|
|
45
|
+
},
|
|
46
|
+
max:{
|
|
47
|
+
type:Number,
|
|
48
|
+
default: 1000
|
|
49
|
+
},
|
|
50
|
+
rules: {
|
|
51
|
+
type: Array,
|
|
52
|
+
default: () => []
|
|
53
|
+
},
|
|
54
|
+
auth: {
|
|
55
|
+
type: String,
|
|
56
|
+
default: ''
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
const emit = defineEmits(['update:modelValue'])
|
|
60
|
+
const modelValue = useVModel(props, 'modelValue', emit)
|
|
61
|
+
const { isRequired, isReadonly, isGone, isDisabled } = util.props2auth(props)
|
|
62
|
+
const files = ref([])
|
|
63
|
+
|
|
64
|
+
onMounted(() => {
|
|
65
|
+
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const onAfterRead = async(file) => {
|
|
69
|
+
console.log(file)
|
|
70
|
+
|
|
71
|
+
let compress_file = file.file
|
|
72
|
+
if (props.compress) {
|
|
73
|
+
compress_file = await util.compress_image(file.file)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let params = {
|
|
77
|
+
file: compress_file
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return util.file_upload(params).then(res => {
|
|
81
|
+
let newUrls = []
|
|
82
|
+
if (props.modelValue && props.modelValue.length > 0)
|
|
83
|
+
newUrls = [...props.modelValue, res.data.url]
|
|
84
|
+
else
|
|
85
|
+
newUrls = [res.data.url]
|
|
86
|
+
|
|
87
|
+
emit('update:modelValue', newUrls)
|
|
88
|
+
return Promise.resolve(file)
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const onBeforeDelete = (e) => {
|
|
93
|
+
let newUrls = props.modelValue.filter(item => {
|
|
94
|
+
return item != e.url
|
|
95
|
+
})
|
|
96
|
+
emit('update:modelValue', newUrls)
|
|
97
|
+
return Promise.resolve(e)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
watch(() => props.modelValue,
|
|
101
|
+
(newVal, oldVal) => {
|
|
102
|
+
if (!props.modelValue || props.modelValue.length < 1) {
|
|
103
|
+
files.value = []
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
files.value = props.modelValue.map(item => {
|
|
108
|
+
return {
|
|
109
|
+
url: item,
|
|
110
|
+
isImage: true
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
immediate: true
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
</script>
|
|
119
|
+
|
|
120
|
+
<style lang="scss" scoped>
|
|
121
|
+
.widget {
|
|
122
|
+
text-align: center;
|
|
123
|
+
|
|
124
|
+
.btn {
|
|
125
|
+
position: fixed;
|
|
126
|
+
bottom: 1rem;
|
|
127
|
+
left: 0;
|
|
128
|
+
right: 0;
|
|
129
|
+
margin: auto auto;
|
|
130
|
+
color: white;
|
|
131
|
+
font-size: 14px;
|
|
132
|
+
background: rgba(58, 136, 255, 1);
|
|
133
|
+
padding: 8px 35px;
|
|
134
|
+
width: 100px;
|
|
135
|
+
text-align: center;
|
|
136
|
+
display: inline-block;
|
|
137
|
+
border-radius: 2px;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
</style>
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// 引入封装好的组件
|
|
2
|
+
import vm from "../vm";
|
|
3
|
+
import AuditBar from "./AuditBar.vue";
|
|
4
|
+
import Input from "./Input.vue";
|
|
5
|
+
import SinglePicker from "./SinglePicker.vue";
|
|
6
|
+
import MultiPicker from './MultiPicker.vue'
|
|
7
|
+
import CheckGroup from "./CheckGroup.vue";
|
|
8
|
+
import DatetimePicker from "./DatetimePicker/index.vue";
|
|
9
|
+
import DataSelector from "./data_selector.vue";
|
|
10
|
+
import MultListSelector from "./mult_list_selector.vue";
|
|
11
|
+
import ProductSelector from "./product_selector.vue";
|
|
12
|
+
import SubdepartmentSelector from "./subdepartment_selector.vue";
|
|
13
|
+
import UserSelector from "./user_selector.vue";
|
|
14
|
+
import ImagePicker from "./image_picker.vue";
|
|
15
|
+
import ImagesPicker from "./images_picker.vue";
|
|
16
|
+
import FilePicker from "./FilePicker.vue";
|
|
17
|
+
import SingleUserSelector from "./SingleUserSelector.vue";
|
|
18
|
+
import UsersPicker from "./UsersPicker.vue"
|
|
19
|
+
import UserPicker from "./UserPicker.vue"
|
|
20
|
+
import UserProfile from "./UserProfile.vue"
|
|
21
|
+
import ProjectPicker from "./ProjectPicker.vue"
|
|
22
|
+
import BillCard from './BillCard.vue'
|
|
23
|
+
import YearDropdown from "./YearDropdown.vue";
|
|
24
|
+
import MonthDropdown from "./MonthDropdown.vue";
|
|
25
|
+
import DayDropdown from "./DayDropdown.vue";
|
|
26
|
+
import ProjectDropdown from "./ProjectDropdown.vue";
|
|
27
|
+
import Switch from './Switch.vue'
|
|
28
|
+
import Sheet from './Sheet.vue'
|
|
29
|
+
import TreePicker from './TreePicker.vue'
|
|
30
|
+
|
|
31
|
+
const components = [
|
|
32
|
+
{
|
|
33
|
+
name: "UiqwAuditBar",
|
|
34
|
+
widget: AuditBar,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "UiqwInput",
|
|
38
|
+
widget: Input,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "UiqwSinglePicker",
|
|
42
|
+
widget: SinglePicker,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "UiqwMultiPicker",
|
|
46
|
+
widget: MultiPicker,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "UiqwCheckGroup",
|
|
50
|
+
widget: CheckGroup,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "UiqwDatetimePicker",
|
|
54
|
+
widget: DatetimePicker,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "UiqwDataSelector",
|
|
58
|
+
widget: DataSelector,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "UiqwMultListSelector",
|
|
62
|
+
widget: MultListSelector,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "UiqwProductSelector",
|
|
66
|
+
widget: ProductSelector,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "UiqwSubdepartmentSelector",
|
|
70
|
+
widget: SubdepartmentSelector,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "UiqwSingleUserSelector",
|
|
74
|
+
widget: SingleUserSelector,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "UiqwImagePicker",
|
|
78
|
+
widget: ImagePicker,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "UiqwImagesPicker",
|
|
82
|
+
widget: ImagesPicker,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "UiqwFilePicker",
|
|
86
|
+
widget: FilePicker,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'UiqwBillCard',
|
|
90
|
+
widget: BillCard
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'UiqwUserSelector',
|
|
94
|
+
widget: UserSelector
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'UiqwUsersPicker',
|
|
98
|
+
widget: UsersPicker
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'UiqwUserPicker',
|
|
102
|
+
widget: UserPicker
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: 'UiqwProjectPicker',
|
|
106
|
+
widget: ProjectPicker
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: 'UiqwUserProfile',
|
|
110
|
+
widget: UserProfile
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'UiqwYearDropdown',
|
|
114
|
+
widget: YearDropdown
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'UiqwMonthDropdown',
|
|
118
|
+
widget: MonthDropdown
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 'UiqwDayDropdown',
|
|
122
|
+
widget: DayDropdown
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: 'UiqwProjectDropdown',
|
|
126
|
+
widget: ProjectDropdown
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: 'UiqwSwitch',
|
|
130
|
+
widget: Switch
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: 'UiqwSheet',
|
|
134
|
+
widget: Sheet
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: 'UiqwTreePicker',
|
|
138
|
+
widget: TreePicker
|
|
139
|
+
}
|
|
140
|
+
];
|
|
141
|
+
// 导出组件
|
|
142
|
+
export const UIQW = {
|
|
143
|
+
install(app) {
|
|
144
|
+
components.forEach((component) => {
|
|
145
|
+
app.component(component.name, component.widget);
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// 导出初始化方法
|
|
151
|
+
export function setup(params) {
|
|
152
|
+
vm.urlCallback = params.urlCallback;
|
|
153
|
+
(vm.tokenCallback = params.tokenCallback),
|
|
154
|
+
(vm.needLoginCallback = params.needLoginCallback);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export * from "./SecretNotify";
|