@zscreate/zhxy-app-component 1.0.78 → 1.0.79
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.
|
@@ -417,6 +417,24 @@
|
|
|
417
417
|
</view>
|
|
418
418
|
</view>
|
|
419
419
|
|
|
420
|
+
<!-- userSelectorByRole -->
|
|
421
|
+
<view v-else-if="widget.type ==='userSelectorByRole'" @click.native="isClickByUser = true"
|
|
422
|
+
class="evan-form-item-container" :class="'evan-form-item-container--' + labelPosition"
|
|
423
|
+
:style="{borderWidth:border?'1upx':0}">
|
|
424
|
+
<view class="evan-form-item-container__label"
|
|
425
|
+
:class="{showAsteriskRect:hasRequiredAsterisk,isRequired:showRequiredAsterisk}" :style="mLabelStyle">
|
|
426
|
+
{{ widget.name }}
|
|
427
|
+
</view>
|
|
428
|
+
<view class="evan-form-item-container__main" :style="mContentStyle"
|
|
429
|
+
@click.stop="selectUserByRole(widget.options.multiple)">
|
|
430
|
+
<user-select-by-role ref="userSelectByRole" @ok="handleSelectRoleUserOk"/>
|
|
431
|
+
<!-- <input class="form-input" placeholder-class="form-input-placeholder" v-model="dataModelShow"
|
|
432
|
+
:placeholder="widget.options.placeholder" :disabled="widget.options.disabled" /> -->
|
|
433
|
+
<view class="form-input">{{ dataModelShow ? dataModelShow : widget.options.placeholder }}</view>
|
|
434
|
+
</view>
|
|
435
|
+
</view>
|
|
436
|
+
|
|
437
|
+
|
|
420
438
|
<!-- deptSelector -->
|
|
421
439
|
<view v-else-if="widget.type ==='deptSelector'" class="evan-form-item-container"
|
|
422
440
|
:class="'evan-form-item-container--' + labelPosition" :style="{borderWidth:border?'1upx':0}">
|
|
@@ -478,10 +496,12 @@ import {
|
|
|
478
496
|
import {
|
|
479
497
|
getMode
|
|
480
498
|
} from './utilForForm'
|
|
499
|
+
import UserSelectByRole from "../userSelectByRole/userSelectByRole";
|
|
481
500
|
|
|
482
501
|
export default {
|
|
483
502
|
mixins: [computedMixin, validateFormMixin, pubSubMixin, valueChangeMixin],
|
|
484
503
|
components: {
|
|
504
|
+
UserSelectByRole,
|
|
485
505
|
UniRate,
|
|
486
506
|
tColorPicker,
|
|
487
507
|
unploadFile,
|
|
@@ -775,7 +795,7 @@ export default {
|
|
|
775
795
|
},
|
|
776
796
|
//rate value chage
|
|
777
797
|
showFormData() {
|
|
778
|
-
if (
|
|
798
|
+
if (['userSelector', 'relateSub', 'userSelectorByRole'].includes(this.widget.type)) {
|
|
779
799
|
this.updateUserSelectorModal()
|
|
780
800
|
}
|
|
781
801
|
if (this.widget.type === 'deptSelector') {
|
|
@@ -1099,6 +1119,25 @@ export default {
|
|
|
1099
1119
|
.stringify(this.dataModel ? this.dataModel : [])
|
|
1100
1120
|
});
|
|
1101
1121
|
},
|
|
1122
|
+
|
|
1123
|
+
selectUserByRole() {
|
|
1124
|
+
if (this.widget.options.disabled) return
|
|
1125
|
+
this.isClickByUser = true
|
|
1126
|
+
this.$refs.userSelectByRole.init(this.widget, this.dataModel)
|
|
1127
|
+
},
|
|
1128
|
+
handleSelectRoleUserOk(value) {
|
|
1129
|
+
this.dataModelShow = ""
|
|
1130
|
+
if (value && value.length > 0) {
|
|
1131
|
+
value.forEach((item, index) => {
|
|
1132
|
+
this.dataModelShow += "," + item.realname;
|
|
1133
|
+
});
|
|
1134
|
+
this.dataModelShow = this.dataModelShow.substring(1);
|
|
1135
|
+
this.dataModel = value;
|
|
1136
|
+
} else {
|
|
1137
|
+
this.dataModelShow = "";
|
|
1138
|
+
this.dataModel = [];
|
|
1139
|
+
}
|
|
1140
|
+
},
|
|
1102
1141
|
// select报修人员
|
|
1103
1142
|
handleSeclet(flag) {
|
|
1104
1143
|
// uni.hideKeyboard()
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<u-popup v-model="roleSelectShow" width="100%">
|
|
3
|
+
<view style="padding: 20rpx">
|
|
4
|
+
<view>角色选择</view>
|
|
5
|
+
<u-radio-group v-model="roleChecked" >
|
|
6
|
+
<u-radio
|
|
7
|
+
@change="roleChange"
|
|
8
|
+
v-for="(item, index) in rolesList" :key="index"
|
|
9
|
+
:name="item.id"
|
|
10
|
+
>
|
|
11
|
+
{{item.roleName}}
|
|
12
|
+
</u-radio>
|
|
13
|
+
</u-radio-group>
|
|
14
|
+
<view style="margin-top: 20rpx; display: flex; flex-wrap: wrap">
|
|
15
|
+
<view>已选:</view>
|
|
16
|
+
<u-tag style="margin-right: 5px" v-for="val in currValue" :text="val.realname" closeable @close="removeClick(val)" :key="val.id" />
|
|
17
|
+
</view>
|
|
18
|
+
<view style="margin-top: 20rpx">
|
|
19
|
+
<u-table>
|
|
20
|
+
<u-tr>
|
|
21
|
+
<u-th width="50px" style="box-sizing: border-box">
|
|
22
|
+
<view v-if="multiple">
|
|
23
|
+
<u-checkbox :value="isAllCheck" @change="roleCheckAll">
|
|
24
|
+
</u-checkbox>
|
|
25
|
+
</view>
|
|
26
|
+
</u-th>
|
|
27
|
+
<u-th>姓名</u-th>
|
|
28
|
+
<u-th>所属部门</u-th>
|
|
29
|
+
</u-tr>
|
|
30
|
+
<u-tr v-for="user in roleUserList" :key="user.id">
|
|
31
|
+
<u-td width="50px" >
|
|
32
|
+
<view>
|
|
33
|
+
<u-checkbox v-model="user.checked" @change="handleCheck" :name="user.id">
|
|
34
|
+
</u-checkbox>
|
|
35
|
+
</view>
|
|
36
|
+
</u-td>
|
|
37
|
+
<u-td><view>{{ user.realname }}</view></u-td>
|
|
38
|
+
<u-td style="word-break: break-all; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"><view>{{ user.departName }}</view></u-td>
|
|
39
|
+
</u-tr>
|
|
40
|
+
</u-table>
|
|
41
|
+
|
|
42
|
+
</view>
|
|
43
|
+
|
|
44
|
+
<view style="display: flex; justify-content: space-between; margin-top: 20rpx">
|
|
45
|
+
<u-button type="primary" size="medium" @click="handleSelectRoleUserOk">确定</u-button>
|
|
46
|
+
<u-button size="medium" @click="roleSelectShow = false">取消</u-button>
|
|
47
|
+
</view>
|
|
48
|
+
</view>
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
</u-popup>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<script>
|
|
55
|
+
import {cloneObj} from "../../utils/util";
|
|
56
|
+
|
|
57
|
+
export default {
|
|
58
|
+
name: "userSelectByRole",
|
|
59
|
+
props: {
|
|
60
|
+
|
|
61
|
+
},
|
|
62
|
+
data() {
|
|
63
|
+
return {
|
|
64
|
+
roleSelectShow: false,
|
|
65
|
+
rolesList: [],
|
|
66
|
+
roleUserList: [],
|
|
67
|
+
currValue: [],
|
|
68
|
+
role: '',
|
|
69
|
+
multiple: false,
|
|
70
|
+
depId: '',
|
|
71
|
+
roleChecked: '',
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
computed: {
|
|
75
|
+
checkIds() {
|
|
76
|
+
return this.currValue.map(item => item.id)
|
|
77
|
+
},
|
|
78
|
+
isAllCheck() {
|
|
79
|
+
if (this.roleUserList.length === 0) return false
|
|
80
|
+
return this.roleUserList.every(item => item.checked)
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
methods: {
|
|
84
|
+
init(widget, value) {
|
|
85
|
+
this.roleSelectShow = true
|
|
86
|
+
|
|
87
|
+
if (widget.options.departRelation) {
|
|
88
|
+
const userInfo = uni.getStorageSync('userinfo')
|
|
89
|
+
console.log("userInfo: ", userInfo)
|
|
90
|
+
this.depId = userInfo.departId || userInfo.depart_id
|
|
91
|
+
}
|
|
92
|
+
this.role = widget.options.role
|
|
93
|
+
this.multiple = widget.options.multiple
|
|
94
|
+
this.currValue = value || []
|
|
95
|
+
this.$u.get('/sys/role/list', {
|
|
96
|
+
pageNo: 1,
|
|
97
|
+
pageSize: 100000,
|
|
98
|
+
}).then(res => {
|
|
99
|
+
this.rolesList = res.result.records.filter((item) => {
|
|
100
|
+
return this.role.includes(item.id);
|
|
101
|
+
});
|
|
102
|
+
})
|
|
103
|
+
this.currValue = cloneObj(value)
|
|
104
|
+
},
|
|
105
|
+
removeClick(val) {
|
|
106
|
+
this.currValue = this.currValue.filter(item => item.id !== val.id)
|
|
107
|
+
const len = this.roleUserList
|
|
108
|
+
this.roleUserList.checked = this.roleUserList.filter((item, idx) => {
|
|
109
|
+
if (val.id === item.id) this.$set(item, 'checked', false )
|
|
110
|
+
return item.checked
|
|
111
|
+
}).length === len
|
|
112
|
+
},
|
|
113
|
+
handleCheck({value , name}) {
|
|
114
|
+
console.log(value, name)
|
|
115
|
+
if (!this.multiple) {
|
|
116
|
+
this.currValue = []
|
|
117
|
+
this.roleUserList = this.roleUserList.map((item, idx) => {
|
|
118
|
+
item.checked = false
|
|
119
|
+
return item
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
if (!value) {
|
|
123
|
+
this.currValue = this.currValue.filter(item => item.id != name)
|
|
124
|
+
}
|
|
125
|
+
const len = this.roleUserList
|
|
126
|
+
this.roleUserList.checked = this.roleUserList.filter((item, idx) => {
|
|
127
|
+
if (item.id === name) {
|
|
128
|
+
if (value && !this.checkIds.includes(item.id)) {
|
|
129
|
+
this.currValue.push(item)
|
|
130
|
+
}
|
|
131
|
+
this.$set(item, 'checked', value)
|
|
132
|
+
return value
|
|
133
|
+
}
|
|
134
|
+
return item.checked
|
|
135
|
+
}).length === len
|
|
136
|
+
console.log(this.currValue)
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
handleSelectRoleUserOk() {
|
|
140
|
+
this.roleSelectShow = false
|
|
141
|
+
// let checked = this.roleUserList.filter(item => {
|
|
142
|
+
// if (item.checked) return item
|
|
143
|
+
// })
|
|
144
|
+
//
|
|
145
|
+
// let ids = []
|
|
146
|
+
// checked = checked.concat(this.currValue).filter(item => {
|
|
147
|
+
// if (ids[item.id]) return false
|
|
148
|
+
// ids[item.id] = true
|
|
149
|
+
// return item
|
|
150
|
+
// })
|
|
151
|
+
|
|
152
|
+
this.$emit("ok", this.currValue)
|
|
153
|
+
},
|
|
154
|
+
roleCheckAll({value}) {
|
|
155
|
+
this.roleUserList.checked != this.roleUserList.checked
|
|
156
|
+
if (value) {
|
|
157
|
+
this.roleUserList.forEach(item => {
|
|
158
|
+
if (!this.checkIds.includes(item.id)) {
|
|
159
|
+
this.currValue.push(item)
|
|
160
|
+
}
|
|
161
|
+
this.$set(item, 'checked', value)
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
if (!value) {
|
|
165
|
+
this.roleUserList.forEach(item => {
|
|
166
|
+
this.currValue = this.currValue.filter(curr => curr.id !== item.id)
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
roleChange(roleId) {
|
|
171
|
+
this.$u.get('/formApi/listFormUserByRole', {
|
|
172
|
+
pageNo: 1,
|
|
173
|
+
pageSize: 100000,
|
|
174
|
+
depId: this.depId,
|
|
175
|
+
roleId
|
|
176
|
+
}).then(res => {
|
|
177
|
+
this.roleUserList = res.result.records.filter(item => {
|
|
178
|
+
item.checked = this.checkIds.includes(item.id)
|
|
179
|
+
return item
|
|
180
|
+
})
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
},
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
</script>
|
|
187
|
+
|
|
188
|
+
<style scoped>
|
|
189
|
+
|
|
190
|
+
</style>
|