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,165 +1,165 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="widget">
|
|
3
|
-
<van-cell-group inset class="card-box">
|
|
4
|
-
<div class="card-header">
|
|
5
|
-
<div class="card-sum">
|
|
6
|
-
<div class="card-type">{{ props.category }}</div>
|
|
7
|
-
<div class="card-no">{{ props.no }}</div>
|
|
8
|
-
</div>
|
|
9
|
-
<van-tag class="user-state" size="large" :color="userState2color(props.userState)">{{
|
|
10
|
-
userState2title(props.userState)
|
|
11
|
-
}}</van-tag>
|
|
12
|
-
<van-tag class="process-state" mark plain size="large"
|
|
13
|
-
:color="processState2color(props.processState)">{{
|
|
14
|
-
processState2title(props.processState)
|
|
15
|
-
}}</van-tag>
|
|
16
|
-
</div>
|
|
17
|
-
|
|
18
|
-
<van-cell :title="item.title" :value="item.value" :border="false" v-for="(item, i) in props.fields"
|
|
19
|
-
:key="i" />
|
|
20
|
-
|
|
21
|
-
<slot name="foot"></slot>
|
|
22
|
-
</van-cell-group>
|
|
23
|
-
</div>
|
|
24
|
-
</template>
|
|
25
|
-
|
|
26
|
-
<script setup>
|
|
27
|
-
import { reactive, ref, onMounted, watch, computed } from "vue"
|
|
28
|
-
import util from '@/util'
|
|
29
|
-
|
|
30
|
-
const props = defineProps({
|
|
31
|
-
// 单据类型
|
|
32
|
-
category: {
|
|
33
|
-
type: String,
|
|
34
|
-
default: ''
|
|
35
|
-
},
|
|
36
|
-
// 单号
|
|
37
|
-
no: {
|
|
38
|
-
type: String,
|
|
39
|
-
default: ''
|
|
40
|
-
},
|
|
41
|
-
// 流程状态
|
|
42
|
-
processState: {
|
|
43
|
-
type: String,
|
|
44
|
-
default: ''
|
|
45
|
-
},
|
|
46
|
-
// 用户状态
|
|
47
|
-
userState: {
|
|
48
|
-
type: String,
|
|
49
|
-
default: ''
|
|
50
|
-
},
|
|
51
|
-
// 摘要字段
|
|
52
|
-
fields: {
|
|
53
|
-
type: Array,
|
|
54
|
-
default: []
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
const data = reactive({
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
onMounted(() => {
|
|
61
|
-
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
const processState2color = (state) => {
|
|
65
|
-
if (state == 'finish_pass') {
|
|
66
|
-
return '#ACACAC'
|
|
67
|
-
} else if (state == 'finish_refuse') {
|
|
68
|
-
return '#ACACAC'
|
|
69
|
-
} else if (state == 'started') {
|
|
70
|
-
return '#338CDE'
|
|
71
|
-
} else {
|
|
72
|
-
return '#ACACAC'
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const processState2title = (state) => {
|
|
77
|
-
if (state == 'finish_pass') {
|
|
78
|
-
return '已完成'
|
|
79
|
-
} else if (state == 'finish_refuse') {
|
|
80
|
-
return '已撤销'
|
|
81
|
-
} else if (state == 'started') {
|
|
82
|
-
return '进行中'
|
|
83
|
-
} else {
|
|
84
|
-
return '未知'
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const userState2color = (state) => {
|
|
89
|
-
if (state == 'unstart') {
|
|
90
|
-
return '#9A9A9A'
|
|
91
|
-
} else if (state == 'started') {
|
|
92
|
-
return '#EE0A25'
|
|
93
|
-
} else if (state == 'pass') {
|
|
94
|
-
return '#07C062'
|
|
95
|
-
} else if (state == 'refuse') {
|
|
96
|
-
return '#EE0A25'
|
|
97
|
-
} else {
|
|
98
|
-
return '#9A9A9A'
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const userState2title = (state) => {
|
|
103
|
-
if (state == 'unstart') {
|
|
104
|
-
return '未启动'
|
|
105
|
-
} else if (state == 'started') {
|
|
106
|
-
return '待审核'
|
|
107
|
-
} else if (state == 'pass') {
|
|
108
|
-
return '已审核'
|
|
109
|
-
} else if (state == 'refuse') {
|
|
110
|
-
return '已驳回'
|
|
111
|
-
} else {
|
|
112
|
-
return '未知'
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
</script>
|
|
116
|
-
|
|
117
|
-
<style lang='scss' scoped>
|
|
118
|
-
.widget {
|
|
119
|
-
background-color: white;
|
|
120
|
-
border-radius: 8px;
|
|
121
|
-
box-shadow: var(--van-dropdown-menu-shadow);
|
|
122
|
-
color: 14px;
|
|
123
|
-
|
|
124
|
-
.card-box {
|
|
125
|
-
padding-bottom: 8px;
|
|
126
|
-
|
|
127
|
-
.card-header {
|
|
128
|
-
display: flex;
|
|
129
|
-
align-items: center;
|
|
130
|
-
justify-content: space-between;
|
|
131
|
-
padding: 15px 10px;
|
|
132
|
-
border-bottom: 1px solid #eee;
|
|
133
|
-
|
|
134
|
-
.card-sum {
|
|
135
|
-
flex: 1;
|
|
136
|
-
font-size: 14px;
|
|
137
|
-
text-align: left;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.user-state {
|
|
141
|
-
margin-right: 1px;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
:deep(.van-cell__value) {
|
|
148
|
-
flex: 2 !important;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
:deep(.van-cell__title) {
|
|
152
|
-
font-size: 12px !important;
|
|
153
|
-
color: #666 !important;
|
|
154
|
-
text-align: left !important;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
:deep(.van-cell__value) {
|
|
158
|
-
font-size: 12px !important;
|
|
159
|
-
color: #888 !important;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
:deep(.van-cell) {
|
|
163
|
-
padding: 2px 10px !important;
|
|
164
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<div class="widget">
|
|
3
|
+
<van-cell-group inset class="card-box">
|
|
4
|
+
<div class="card-header">
|
|
5
|
+
<div class="card-sum">
|
|
6
|
+
<div class="card-type">{{ props.category }}</div>
|
|
7
|
+
<div class="card-no">{{ props.no }}</div>
|
|
8
|
+
</div>
|
|
9
|
+
<van-tag class="user-state" size="large" :color="userState2color(props.userState)">{{
|
|
10
|
+
userState2title(props.userState)
|
|
11
|
+
}}</van-tag>
|
|
12
|
+
<van-tag class="process-state" mark plain size="large"
|
|
13
|
+
:color="processState2color(props.processState)">{{
|
|
14
|
+
processState2title(props.processState)
|
|
15
|
+
}}</van-tag>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<van-cell :title="item.title" :value="item.value" :border="false" v-for="(item, i) in props.fields"
|
|
19
|
+
:key="i" />
|
|
20
|
+
|
|
21
|
+
<slot name="foot"></slot>
|
|
22
|
+
</van-cell-group>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script setup>
|
|
27
|
+
import { reactive, ref, onMounted, watch, computed } from "vue"
|
|
28
|
+
import util from '@/util'
|
|
29
|
+
|
|
30
|
+
const props = defineProps({
|
|
31
|
+
// 单据类型
|
|
32
|
+
category: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: ''
|
|
35
|
+
},
|
|
36
|
+
// 单号
|
|
37
|
+
no: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: ''
|
|
40
|
+
},
|
|
41
|
+
// 流程状态
|
|
42
|
+
processState: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: ''
|
|
45
|
+
},
|
|
46
|
+
// 用户状态
|
|
47
|
+
userState: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: ''
|
|
50
|
+
},
|
|
51
|
+
// 摘要字段
|
|
52
|
+
fields: {
|
|
53
|
+
type: Array,
|
|
54
|
+
default: []
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
const data = reactive({
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
onMounted(() => {
|
|
61
|
+
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const processState2color = (state) => {
|
|
65
|
+
if (state == 'finish_pass') {
|
|
66
|
+
return '#ACACAC'
|
|
67
|
+
} else if (state == 'finish_refuse') {
|
|
68
|
+
return '#ACACAC'
|
|
69
|
+
} else if (state == 'started') {
|
|
70
|
+
return '#338CDE'
|
|
71
|
+
} else {
|
|
72
|
+
return '#ACACAC'
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const processState2title = (state) => {
|
|
77
|
+
if (state == 'finish_pass') {
|
|
78
|
+
return '已完成'
|
|
79
|
+
} else if (state == 'finish_refuse') {
|
|
80
|
+
return '已撤销'
|
|
81
|
+
} else if (state == 'started') {
|
|
82
|
+
return '进行中'
|
|
83
|
+
} else {
|
|
84
|
+
return '未知'
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const userState2color = (state) => {
|
|
89
|
+
if (state == 'unstart') {
|
|
90
|
+
return '#9A9A9A'
|
|
91
|
+
} else if (state == 'started') {
|
|
92
|
+
return '#EE0A25'
|
|
93
|
+
} else if (state == 'pass') {
|
|
94
|
+
return '#07C062'
|
|
95
|
+
} else if (state == 'refuse') {
|
|
96
|
+
return '#EE0A25'
|
|
97
|
+
} else {
|
|
98
|
+
return '#9A9A9A'
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const userState2title = (state) => {
|
|
103
|
+
if (state == 'unstart') {
|
|
104
|
+
return '未启动'
|
|
105
|
+
} else if (state == 'started') {
|
|
106
|
+
return '待审核'
|
|
107
|
+
} else if (state == 'pass') {
|
|
108
|
+
return '已审核'
|
|
109
|
+
} else if (state == 'refuse') {
|
|
110
|
+
return '已驳回'
|
|
111
|
+
} else {
|
|
112
|
+
return '未知'
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
</script>
|
|
116
|
+
|
|
117
|
+
<style lang='scss' scoped>
|
|
118
|
+
.widget {
|
|
119
|
+
background-color: white;
|
|
120
|
+
border-radius: 8px;
|
|
121
|
+
box-shadow: var(--van-dropdown-menu-shadow);
|
|
122
|
+
color: 14px;
|
|
123
|
+
|
|
124
|
+
.card-box {
|
|
125
|
+
padding-bottom: 8px;
|
|
126
|
+
|
|
127
|
+
.card-header {
|
|
128
|
+
display: flex;
|
|
129
|
+
align-items: center;
|
|
130
|
+
justify-content: space-between;
|
|
131
|
+
padding: 15px 10px;
|
|
132
|
+
border-bottom: 1px solid #eee;
|
|
133
|
+
|
|
134
|
+
.card-sum {
|
|
135
|
+
flex: 1;
|
|
136
|
+
font-size: 14px;
|
|
137
|
+
text-align: left;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.user-state {
|
|
141
|
+
margin-right: 1px;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
:deep(.van-cell__value) {
|
|
148
|
+
flex: 2 !important;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
:deep(.van-cell__title) {
|
|
152
|
+
font-size: 12px !important;
|
|
153
|
+
color: #666 !important;
|
|
154
|
+
text-align: left !important;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
:deep(.van-cell__value) {
|
|
158
|
+
font-size: 12px !important;
|
|
159
|
+
color: #888 !important;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
:deep(.van-cell) {
|
|
163
|
+
padding: 2px 10px !important;
|
|
164
|
+
}
|
|
165
165
|
</style>
|
|
@@ -1,133 +1,133 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<van-field v-if="!isGone" :label="props.label" readonly :required="isRequired" :rules="props.rules"
|
|
3
|
-
:disabled="isDisabled" :placeholder="props.placeholder" :is-link="isReadonly ? false : true"
|
|
4
|
-
@click="data.isShowPop = !isReadonly" label-class="label">
|
|
5
|
-
<template #input v-if="modelValue">
|
|
6
|
-
<div style="display: flex; align-items: center; flex-wrap: wrap;">
|
|
7
|
-
<van-tag class="selected-node" v-if="!props.multiple" :closeable="!isDisabled" color="#fff"
|
|
8
|
-
text-color="#333" size="medium" @close.stop="onDelete">
|
|
9
|
-
{{ data.selectedNodes[0]?.path }}
|
|
10
|
-
</van-tag>
|
|
11
|
-
<van-tag class="selected-node" v-if="props.multiple" v-for="(item, i) in data.selectedNodes" :key="i"
|
|
12
|
-
:closeable="!isDisabled" color="#fff" text-color="#333" size="medium" @close.stop="onDelete(i)">
|
|
13
|
-
{{ item.path }}
|
|
14
|
-
</van-tag>
|
|
15
|
-
</div>
|
|
16
|
-
</template>
|
|
17
|
-
</van-field>
|
|
18
|
-
|
|
19
|
-
<CascaderPop v-model:show="data.isShowPop" v-model="data.selectedNodeId" :placeholder="props.placeholder"
|
|
20
|
-
@select="onSelect" :keywordQueryNode="props.keywordQueryNode" :idQueryNode="props.idQueryNode" />
|
|
21
|
-
</template>
|
|
22
|
-
|
|
23
|
-
<script setup>
|
|
24
|
-
import { reactive, onMounted, watch } from "vue";
|
|
25
|
-
import util from "@/util"
|
|
26
|
-
import { useVModel } from '@vueuse/core'
|
|
27
|
-
import CascaderPop from './CascaderPop.vue'
|
|
28
|
-
|
|
29
|
-
const props = defineProps({
|
|
30
|
-
modelValue: {
|
|
31
|
-
type: [String, Array, Number],
|
|
32
|
-
default: null,
|
|
33
|
-
},
|
|
34
|
-
multiple: {
|
|
35
|
-
type: Boolean,
|
|
36
|
-
default: false
|
|
37
|
-
},
|
|
38
|
-
label: {
|
|
39
|
-
type: String,
|
|
40
|
-
default: "",
|
|
41
|
-
},
|
|
42
|
-
placeholder: {
|
|
43
|
-
type: String,
|
|
44
|
-
default: "",
|
|
45
|
-
},
|
|
46
|
-
required: {
|
|
47
|
-
type: Boolean,
|
|
48
|
-
default: false,
|
|
49
|
-
},
|
|
50
|
-
readonly: {
|
|
51
|
-
type: Boolean,
|
|
52
|
-
default: true,
|
|
53
|
-
},
|
|
54
|
-
rules: {
|
|
55
|
-
type: Array,
|
|
56
|
-
default: [],
|
|
57
|
-
},
|
|
58
|
-
auth: {
|
|
59
|
-
type: String,
|
|
60
|
-
default: "",
|
|
61
|
-
},
|
|
62
|
-
keywordQueryNode: {
|
|
63
|
-
type: Function,
|
|
64
|
-
default: () => { }
|
|
65
|
-
},
|
|
66
|
-
idQueryNode: {
|
|
67
|
-
type: Function,
|
|
68
|
-
default: () => { }
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// 弹出层
|
|
73
|
-
const data = reactive({
|
|
74
|
-
isShowPop: false,
|
|
75
|
-
selectedNodes: [],
|
|
76
|
-
selectedNodeId: null
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
// 定义emit
|
|
80
|
-
const emit = defineEmits(["update:modelValue", "select"]);
|
|
81
|
-
const modelValue = useVModel(props, 'modelValue', emit)
|
|
82
|
-
const { isRequired, isReadonly, isGone, isDisabled } = util.props2auth(props);
|
|
83
|
-
|
|
84
|
-
//首页加载
|
|
85
|
-
onMounted(() => {
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
const onSelect = (node) => {
|
|
89
|
-
if (!props.multiple) {
|
|
90
|
-
data.selectedNodes = [node]
|
|
91
|
-
emit('select', data.selectedNodes[0])
|
|
92
|
-
modelValue.value = node.id
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
let one = data.selectedNodes.find(item => item.id === node.id)
|
|
96
|
-
if (!one)
|
|
97
|
-
data.selectedNodes = [...data.selectedNodes, node]
|
|
98
|
-
emit('select', data.selectedNodes)
|
|
99
|
-
modelValue.value = data.selectedNodes.map(item => item.id)
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const onDelete = (idx) => {
|
|
104
|
-
if (!props.multiple) {
|
|
105
|
-
modelValue.value = null
|
|
106
|
-
} else {
|
|
107
|
-
modelValue.value.splice(idx, 1)
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
watch(() => JSON.stringify(modelValue.value), async (n, o) => {
|
|
112
|
-
if (!props.multiple) {
|
|
113
|
-
data.selectedNodeId = modelValue.value
|
|
114
|
-
} else {
|
|
115
|
-
data.selectedNodes = []
|
|
116
|
-
let ids = modelValue.value || []
|
|
117
|
-
ids.forEach(async (id) => {
|
|
118
|
-
let params = {}
|
|
119
|
-
params.id = id
|
|
120
|
-
params.isReturnParent = false
|
|
121
|
-
params.hasChildren = false
|
|
122
|
-
params.hasPaths= true
|
|
123
|
-
await props.idQueryNode(params, (node) => {
|
|
124
|
-
data.selectedNodes = [...data.selectedNodes, node]
|
|
125
|
-
})
|
|
126
|
-
})
|
|
127
|
-
}
|
|
128
|
-
}, {
|
|
129
|
-
immediate: true
|
|
130
|
-
})
|
|
131
|
-
</script>
|
|
132
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<van-field v-if="!isGone" :label="props.label" readonly :required="isRequired" :rules="props.rules"
|
|
3
|
+
:disabled="isDisabled" :placeholder="props.placeholder" :is-link="isReadonly ? false : true"
|
|
4
|
+
@click="data.isShowPop = !isReadonly" label-class="label">
|
|
5
|
+
<template #input v-if="modelValue">
|
|
6
|
+
<div style="display: flex; align-items: center; flex-wrap: wrap;">
|
|
7
|
+
<van-tag class="selected-node" v-if="!props.multiple" :closeable="!isDisabled" color="#fff"
|
|
8
|
+
text-color="#333" size="medium" @close.stop="onDelete">
|
|
9
|
+
{{ data.selectedNodes[0]?.path }}
|
|
10
|
+
</van-tag>
|
|
11
|
+
<van-tag class="selected-node" v-if="props.multiple" v-for="(item, i) in data.selectedNodes" :key="i"
|
|
12
|
+
:closeable="!isDisabled" color="#fff" text-color="#333" size="medium" @close.stop="onDelete(i)">
|
|
13
|
+
{{ item.path }}
|
|
14
|
+
</van-tag>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
</van-field>
|
|
18
|
+
|
|
19
|
+
<CascaderPop v-model:show="data.isShowPop" v-model="data.selectedNodeId" :placeholder="props.placeholder"
|
|
20
|
+
@select="onSelect" :keywordQueryNode="props.keywordQueryNode" :idQueryNode="props.idQueryNode" />
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script setup>
|
|
24
|
+
import { reactive, onMounted, watch } from "vue";
|
|
25
|
+
import util from "@/util"
|
|
26
|
+
import { useVModel } from '@vueuse/core'
|
|
27
|
+
import CascaderPop from './CascaderPop.vue'
|
|
28
|
+
|
|
29
|
+
const props = defineProps({
|
|
30
|
+
modelValue: {
|
|
31
|
+
type: [String, Array, Number],
|
|
32
|
+
default: null,
|
|
33
|
+
},
|
|
34
|
+
multiple: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false
|
|
37
|
+
},
|
|
38
|
+
label: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: "",
|
|
41
|
+
},
|
|
42
|
+
placeholder: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: "",
|
|
45
|
+
},
|
|
46
|
+
required: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: false,
|
|
49
|
+
},
|
|
50
|
+
readonly: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: true,
|
|
53
|
+
},
|
|
54
|
+
rules: {
|
|
55
|
+
type: Array,
|
|
56
|
+
default: [],
|
|
57
|
+
},
|
|
58
|
+
auth: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: "",
|
|
61
|
+
},
|
|
62
|
+
keywordQueryNode: {
|
|
63
|
+
type: Function,
|
|
64
|
+
default: () => { }
|
|
65
|
+
},
|
|
66
|
+
idQueryNode: {
|
|
67
|
+
type: Function,
|
|
68
|
+
default: () => { }
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// 弹出层
|
|
73
|
+
const data = reactive({
|
|
74
|
+
isShowPop: false,
|
|
75
|
+
selectedNodes: [],
|
|
76
|
+
selectedNodeId: null
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
// 定义emit
|
|
80
|
+
const emit = defineEmits(["update:modelValue", "select"]);
|
|
81
|
+
const modelValue = useVModel(props, 'modelValue', emit)
|
|
82
|
+
const { isRequired, isReadonly, isGone, isDisabled } = util.props2auth(props);
|
|
83
|
+
|
|
84
|
+
//首页加载
|
|
85
|
+
onMounted(() => {
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
const onSelect = (node) => {
|
|
89
|
+
if (!props.multiple) {
|
|
90
|
+
data.selectedNodes = [node]
|
|
91
|
+
emit('select', data.selectedNodes[0])
|
|
92
|
+
modelValue.value = node.id
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
let one = data.selectedNodes.find(item => item.id === node.id)
|
|
96
|
+
if (!one)
|
|
97
|
+
data.selectedNodes = [...data.selectedNodes, node]
|
|
98
|
+
emit('select', data.selectedNodes)
|
|
99
|
+
modelValue.value = data.selectedNodes.map(item => item.id)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const onDelete = (idx) => {
|
|
104
|
+
if (!props.multiple) {
|
|
105
|
+
modelValue.value = null
|
|
106
|
+
} else {
|
|
107
|
+
modelValue.value.splice(idx, 1)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
watch(() => JSON.stringify(modelValue.value), async (n, o) => {
|
|
112
|
+
if (!props.multiple) {
|
|
113
|
+
data.selectedNodeId = modelValue.value
|
|
114
|
+
} else {
|
|
115
|
+
data.selectedNodes = []
|
|
116
|
+
let ids = modelValue.value || []
|
|
117
|
+
ids.forEach(async (id) => {
|
|
118
|
+
let params = {}
|
|
119
|
+
params.id = id
|
|
120
|
+
params.isReturnParent = false
|
|
121
|
+
params.hasChildren = false
|
|
122
|
+
params.hasPaths= true
|
|
123
|
+
await props.idQueryNode(params, (node) => {
|
|
124
|
+
data.selectedNodes = [...data.selectedNodes, node]
|
|
125
|
+
})
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
immediate: true
|
|
130
|
+
})
|
|
131
|
+
</script>
|
|
132
|
+
|
|
133
133
|
<style scoped></style>
|