wl-design-mobile 0.4.4 → 0.4.6
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/edit/select/lambo-edit-search-single-select.vue +178 -0
- package/package.json +1 -1
- package/util/jssdk.js +57 -27
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div class="edit-box" @click="changeColor">
|
|
4
|
+
<div class="edit-left-box">
|
|
5
|
+
<div class="edit-left-top">
|
|
6
|
+
<div v-if="required" class="edit-red-icon">
|
|
7
|
+
<lambo-required-red-star :required="required"></lambo-required-red-star>
|
|
8
|
+
</div>
|
|
9
|
+
<div class="edit-title">{{ title }}</div>
|
|
10
|
+
</div>
|
|
11
|
+
<van-field v-model="valName" :placeholder="placeholder" :readonly="true"
|
|
12
|
+
class="edit-lambo-input" clear-trigger="focus"></van-field>
|
|
13
|
+
</div>
|
|
14
|
+
<div v-if="icon" class="edit-right-icon">
|
|
15
|
+
<lambo-vector-icon :icon="icon" @click="onOpen"></lambo-vector-icon>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
<div>
|
|
19
|
+
<van-popup v-model:show="showBottom" :style="{ height: '33%' }" position="bottom">
|
|
20
|
+
<van-radio-group v-model="selectItem.K">
|
|
21
|
+
<div class="bottom-div">
|
|
22
|
+
<div class="edit-top-div">
|
|
23
|
+
<van-button class="edit-cancel-btn" size="normal" @click="cancel">取消</van-button>
|
|
24
|
+
<span class="edit-select-title">请选择</span>
|
|
25
|
+
<van-button class="edit-confirm-btn" size="normal" @click="onConfirm">确认</van-button>
|
|
26
|
+
</div>
|
|
27
|
+
<div class="cell-group-div">
|
|
28
|
+
<van-cell-group>
|
|
29
|
+
<van-search v-model="searchField" placeholder="请输入筛选名称" clearable @input="search"/>
|
|
30
|
+
<van-cell v-for="(c, index) in searchData" :key="index" :title="`${c.V}`" clickable @click="radioClick(c)">
|
|
31
|
+
<template #right-icon>
|
|
32
|
+
<van-radio :name="c.K" checked-color="#0070D2"/>
|
|
33
|
+
</template>
|
|
34
|
+
</van-cell>
|
|
35
|
+
</van-cell-group>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</van-radio-group>
|
|
39
|
+
</van-popup>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
43
|
+
<script>
|
|
44
|
+
import requiredIcon from '../../assets/icon/required.png'
|
|
45
|
+
import LamboVectorIcon from '../../icon/lambo-vector-icon.vue'
|
|
46
|
+
import LamboRequiredRedStar from '../../icon/lambo-required-red-star.vue'
|
|
47
|
+
|
|
48
|
+
export default {
|
|
49
|
+
name: 'LamboEditEmployeeSingleSelect',
|
|
50
|
+
components: {LamboRequiredRedStar, LamboVectorIcon},
|
|
51
|
+
props: {
|
|
52
|
+
title: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: '',
|
|
55
|
+
},
|
|
56
|
+
placeholder: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: '请选择',
|
|
59
|
+
},
|
|
60
|
+
required: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: false,
|
|
63
|
+
},
|
|
64
|
+
icon: {
|
|
65
|
+
type: String,
|
|
66
|
+
default: 'arrow-right-big.png',
|
|
67
|
+
},
|
|
68
|
+
data: {
|
|
69
|
+
type: Array,
|
|
70
|
+
default: () => ([]),
|
|
71
|
+
},
|
|
72
|
+
defaultItem: {
|
|
73
|
+
type: Object,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
data() {
|
|
77
|
+
return {
|
|
78
|
+
iconSrc: requiredIcon,
|
|
79
|
+
showBottom: false,
|
|
80
|
+
val: '',
|
|
81
|
+
valName: '',
|
|
82
|
+
selectItem: {
|
|
83
|
+
K: '',
|
|
84
|
+
V: '',
|
|
85
|
+
},
|
|
86
|
+
firstLoad: true,
|
|
87
|
+
searchField:'',
|
|
88
|
+
searchData:this.data
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
watch: {
|
|
92
|
+
defaultItem: {
|
|
93
|
+
handler: function (val, oldVal) {
|
|
94
|
+
console.log('lambo-select -- defaultItem -- val,oldVal,firstLoad:', {
|
|
95
|
+
val,
|
|
96
|
+
oldVal,
|
|
97
|
+
'firstLoad': this.firstLoad,
|
|
98
|
+
})
|
|
99
|
+
if (this.defaultItem && ((this.defaultItem.K && this.firstLoad === true) || !this.firstLoad) ) {
|
|
100
|
+
this.val = this.defaultItem.K || ''
|
|
101
|
+
this.valName = this.defaultItem.V || ''
|
|
102
|
+
this.$set(this.selectItem, 'K', this.defaultItem.K)
|
|
103
|
+
this.$set(this.selectItem, 'V', this.defaultItem.V)
|
|
104
|
+
this.firstLoad = false
|
|
105
|
+
this.$emit('on-ok', this.defaultItem)
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
deep: true,
|
|
109
|
+
immediate: true,
|
|
110
|
+
},
|
|
111
|
+
data:{
|
|
112
|
+
handler: function (val) {
|
|
113
|
+
this.searchData = val
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
methods: {
|
|
118
|
+
onOpen() {
|
|
119
|
+
console.log('this.data:', this.data)
|
|
120
|
+
this.showBottom = true
|
|
121
|
+
},
|
|
122
|
+
cancel() {
|
|
123
|
+
this.showBottom = false
|
|
124
|
+
},
|
|
125
|
+
onConfirm() {
|
|
126
|
+
if (this.selectItem && this.selectItem.K) {
|
|
127
|
+
this.val = this.selectItem.K
|
|
128
|
+
this.valName = this.selectItem.V
|
|
129
|
+
this.$emit('on-ok', this.selectItem)
|
|
130
|
+
} else {
|
|
131
|
+
console.error('lambo-select -- 条件选择失败,this.selectItem:', this.selectItem)
|
|
132
|
+
this.val = ''
|
|
133
|
+
this.valName = ''
|
|
134
|
+
this.$emit('on-ok', {K: '', V: ''})
|
|
135
|
+
}
|
|
136
|
+
this.showBottom = false
|
|
137
|
+
},
|
|
138
|
+
radioClick(data) {
|
|
139
|
+
if (data && data.K) {
|
|
140
|
+
this.selectItem.K = data.K
|
|
141
|
+
this.selectItem.V = data.V
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
changeColor() {
|
|
145
|
+
let searchRows = document.querySelectorAll('.edit-box')
|
|
146
|
+
Array.from(searchRows).forEach(function (row, index) {
|
|
147
|
+
row.addEventListener('click', function () {
|
|
148
|
+
Array.from(searchRows).forEach(function (row) {
|
|
149
|
+
row.style.borderBottom = '1px solid var(--scl-white-2)'
|
|
150
|
+
})
|
|
151
|
+
row.style.borderBottom = '1px solid var(--scl-blue)'
|
|
152
|
+
})
|
|
153
|
+
})
|
|
154
|
+
},
|
|
155
|
+
search(){
|
|
156
|
+
let arr = []
|
|
157
|
+
let searchData = this.data
|
|
158
|
+
for (let i = 0; i < searchData.length; i++) {
|
|
159
|
+
if(searchData[i].V.indexOf(this.searchField)>=0){
|
|
160
|
+
arr.push(searchData[i]);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
this.searchData = arr
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
created() {
|
|
167
|
+
|
|
168
|
+
},
|
|
169
|
+
}
|
|
170
|
+
</script>
|
|
171
|
+
<style scoped>
|
|
172
|
+
@import "../../styles/index.less";
|
|
173
|
+
@import "./styles/css/index.css";
|
|
174
|
+
|
|
175
|
+
/deep/ .edit-left-box .van-cell {
|
|
176
|
+
padding: 0px 0px;
|
|
177
|
+
}
|
|
178
|
+
</style>
|
package/package.json
CHANGED
package/util/jssdk.js
CHANGED
|
@@ -11,6 +11,22 @@ function init({appId:a,agentId:b,corpId:c,appKey:d}){
|
|
|
11
11
|
agentId = b
|
|
12
12
|
corpId = c
|
|
13
13
|
appKey = d
|
|
14
|
+
|
|
15
|
+
if(appId){
|
|
16
|
+
sessionStorage.setItem('JsSdk_appId',appId)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if(agentId){
|
|
20
|
+
sessionStorage.setItem('JsSdk_agentId',agentId)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if(corpId){
|
|
24
|
+
sessionStorage.setItem('JsSdk_corpId',corpId)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if(appKey){
|
|
28
|
+
sessionStorage.setItem('JsSdk_appKey',appKey)
|
|
29
|
+
}
|
|
14
30
|
}
|
|
15
31
|
|
|
16
32
|
|
|
@@ -41,10 +57,10 @@ function getJsConfig(){
|
|
|
41
57
|
return new Promise((resolve, reject)=>{
|
|
42
58
|
axios.post(config.platformServerContext + '/api/weixin/getJsConfig', {
|
|
43
59
|
appType: getAppType(),
|
|
44
|
-
appId:
|
|
45
|
-
agentId:
|
|
46
|
-
corpId:
|
|
47
|
-
appKey:
|
|
60
|
+
appId: sessionStorage.getItem('JsSdk_appId'),
|
|
61
|
+
agentId: sessionStorage.getItem('JsSdk_agentId'),
|
|
62
|
+
corpId: sessionStorage.getItem('JsSdk_corpId'),
|
|
63
|
+
appKey: sessionStorage.getItem('JsSdk_appKey'),
|
|
48
64
|
url: url
|
|
49
65
|
}).then((resp) => {
|
|
50
66
|
resolve(resp.data)
|
|
@@ -59,7 +75,7 @@ function configWx(){
|
|
|
59
75
|
getJsConfig().then((resp)=>{
|
|
60
76
|
wx.config({
|
|
61
77
|
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
|
62
|
-
appId:
|
|
78
|
+
appId: sessionStorage.getItem('JsSdk_appId'), // 必填,公众号的唯一标识
|
|
63
79
|
timestamp: resp.timestamp, // 必填,生成签名的时间戳
|
|
64
80
|
nonceStr: resp.noncestr, // 必填,生成签名的随机串
|
|
65
81
|
signature: resp.signature, // 必填,签名
|
|
@@ -86,10 +102,10 @@ function getConfigSignature(url) {
|
|
|
86
102
|
return new Promise((resolve,reject)=>{
|
|
87
103
|
axios.post(config.platformServerContext + '/api/weixin/getJsConfig', {
|
|
88
104
|
appType: getAppType(),
|
|
89
|
-
appId:
|
|
90
|
-
agentId:
|
|
91
|
-
corpId:
|
|
92
|
-
appKey:
|
|
105
|
+
appId: sessionStorage.getItem('JsSdk_appId'),
|
|
106
|
+
agentId: sessionStorage.getItem('JsSdk_agentId'),
|
|
107
|
+
corpId: sessionStorage.getItem('JsSdk_corpId'),
|
|
108
|
+
appKey: sessionStorage.getItem('JsSdk_appKey'),
|
|
93
109
|
url: url.split('#')[0]
|
|
94
110
|
}).then(resp=>{
|
|
95
111
|
console.log('getConfigSignature',resp)
|
|
@@ -107,7 +123,7 @@ function getConfigSignature(url) {
|
|
|
107
123
|
function configWw(){
|
|
108
124
|
return new Promise((resolve, reject) =>{
|
|
109
125
|
ww.register({
|
|
110
|
-
corpId:
|
|
126
|
+
corpId: sessionStorage.getItem('JsSdk_appId'), // 必填,当前用户企业所属企业ID
|
|
111
127
|
jsApiList: ['chooseImage', 'uploadImage', 'downloadImage', 'getLocalImgData', 'openLocation', 'getLocation', 'scanQRCode', 'chooseWXPay', 'onHistoryBack','invoke','onLocationChange','previewFile'], // 必填,需要使用的JSAPI列表
|
|
112
128
|
getConfigSignature, // 必填,根据url生成企业签名的回调函数
|
|
113
129
|
onConfigSuccess:(res) => {
|
|
@@ -130,8 +146,8 @@ function configDd(){
|
|
|
130
146
|
//钉钉js-api配置
|
|
131
147
|
console.log("当前页面:"+location.href);
|
|
132
148
|
dd.config({
|
|
133
|
-
agentId:
|
|
134
|
-
corpId:
|
|
149
|
+
agentId:sessionStorage.getItem('JsSdk_agentId'),
|
|
150
|
+
corpId: sessionStorage.getItem('JsSdk_corpId'), // 必填,公众号的唯一标识
|
|
135
151
|
timeStamp: resp.timestamp, // 必填,生成签名的时间戳
|
|
136
152
|
nonceStr: resp.noncestr, // 必填,生成签名的随机串
|
|
137
153
|
signature: resp.signature, // 必填,签名
|
|
@@ -206,7 +222,7 @@ let JsSDK = (function () {
|
|
|
206
222
|
}else{
|
|
207
223
|
configWx().then(()=>{
|
|
208
224
|
wx.chooseImage({
|
|
209
|
-
count: 1, // 默认
|
|
225
|
+
count: 1, // 默认1
|
|
210
226
|
sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
|
211
227
|
sourceType: ['camera'], // 可以指定来源是相册还是相机,默认二者都有
|
|
212
228
|
success: function (res) {
|
|
@@ -215,16 +231,20 @@ let JsSDK = (function () {
|
|
|
215
231
|
setTimeout(() => {
|
|
216
232
|
wx.uploadImage({
|
|
217
233
|
localId: localId, // 需要上传的图片的本地ID,由chooseImage接口获得
|
|
218
|
-
isShowProgressTips:
|
|
234
|
+
isShowProgressTips: 1, // 默认为1,显示进度提示
|
|
219
235
|
success: function (res) {
|
|
220
236
|
let serverId = res.serverId; // 返回图片的服务器端ID
|
|
221
|
-
resolve({
|
|
237
|
+
resolve({
|
|
238
|
+
appId:sessionStorage.getItem('JsSdk_appId'),
|
|
239
|
+
agentId:sessionStorage.getItem('JsSdk_agentId'),
|
|
240
|
+
serverId:serverId
|
|
241
|
+
})
|
|
222
242
|
}
|
|
223
243
|
})
|
|
224
244
|
}, 200);
|
|
225
245
|
},
|
|
226
246
|
cancel:function (){
|
|
227
|
-
reject('
|
|
247
|
+
reject('取消拍照')
|
|
228
248
|
}
|
|
229
249
|
})
|
|
230
250
|
}).catch((error)=>{
|
|
@@ -233,27 +253,37 @@ let JsSDK = (function () {
|
|
|
233
253
|
}
|
|
234
254
|
})
|
|
235
255
|
}
|
|
236
|
-
function choosePhoto(){
|
|
256
|
+
function choosePhoto({count = 1} = {}){
|
|
237
257
|
return new Promise((resolve, reject) =>{
|
|
238
258
|
if(getAppType() === '30'){
|
|
239
259
|
reject('钉钉不支持此方式选择照片')
|
|
240
260
|
}else{
|
|
241
261
|
configWx().then(()=>{
|
|
242
262
|
wx.chooseImage({
|
|
243
|
-
count:
|
|
263
|
+
count: count, // 默认1
|
|
244
264
|
sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
|
245
|
-
sourceType: ['album'
|
|
265
|
+
sourceType: ['album'], // 可以指定来源是相册还是相机,默认二者都有
|
|
246
266
|
success: function (res) {
|
|
247
267
|
let localIds = res.localIds; // 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片
|
|
248
|
-
let localId = localIds[0];
|
|
268
|
+
// let localId = localIds[0];
|
|
249
269
|
setTimeout(() => {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
270
|
+
let serverIds = []
|
|
271
|
+
localIds.forEach((localId) =>{
|
|
272
|
+
wx.uploadImage({
|
|
273
|
+
localId: localId, // 需要上传的图片的本地ID,由chooseImage接口获得
|
|
274
|
+
isShowProgressTips: 1, // 默认为1,显示进度提示
|
|
275
|
+
success: function (res) {
|
|
276
|
+
let serverId = res.serverId; // 返回图片的服务器端ID
|
|
277
|
+
serverIds.push(serverId)
|
|
278
|
+
}
|
|
279
|
+
})
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
resolve({
|
|
283
|
+
appId:sessionStorage.getItem('JsSdk_appId'),
|
|
284
|
+
agentId:sessionStorage.getItem('JsSdk_agentId'),
|
|
285
|
+
serverId:serverIds[0],
|
|
286
|
+
serverIds:serverIds
|
|
257
287
|
})
|
|
258
288
|
}, 200);
|
|
259
289
|
},
|