assign.vue
5.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<template>
<view class="page">
<scroll-view class="scroll" scroll-y>
<view class="section" v-if="users.length > 0">
<view
v-for="it in users"
:key="it.id"
class="card"
:class="{ 'is-selected': selectedId === it.id }"
@click="onSelect(it)"
>
<view class="card-row">
<text class="card-name">{{ safeText(it.name) }}</text>
<text class="card-check" v-if="selectedId === it.id">✓</text>
</view>
<view class="card-row sub">
<text class="card-label">部门:</text>
<text class="card-value">{{ safeText(it.deptName) }}</text>
</view>
<view class="card-row sub">
<text class="card-label">角色:</text>
<text class="card-value">{{ safeText(it.roleName) }}</text>
</view>
<view class="card-row sub">
<text class="card-label">用户名:</text>
<text class="card-value">{{ safeText(it.username) }}</text>
</view>
</view>
</view>
<view v-else-if="!loading" class="empty">暂无可分配人员</view>
</scroll-view>
<view class="footer">
<button class="btn submit" :disabled="!selectedId" @click="onSubmit">确定分配</button>
</view>
</view>
</template>
<script>
import { supplierQuotationDealAssignUsersApi, supplierQuotationDealAssignApi } from '@/api/procure-manage/supplierQuotationDeal.js'
export default {
name: 'AssignQuoteManage',
data() {
return {
id: '',
purchaseDepartment: '',
loading: false,
users: [],
selectedId: ''
}
},
onLoad(options) {
this.id = (options && options.id) ? options.id : ''
this.purchaseDepartment = (options && options.purchaseDepartment) ? options.purchaseDepartment : ''
if (!this.id) {
uni.showToast({ title: '缺少主键ID', icon: 'none' })
return
}
this.loadUsers()
},
methods: {
safeText(v) {
const s = v == null ? '' : String(v)
return s.trim() ? s : '-'
},
async loadUsers() {
this.loading = true
try {
const res = await supplierQuotationDealAssignUsersApi({ purchaseDepartment: this.purchaseDepartment })
const data = (res && res.data) ? res.data : []
this.users = Array.isArray(data) ? data : []
} catch (e) {
this.users = []
uni.showToast({ title: '加载人员失败', icon: 'none' })
} finally {
this.loading = false
}
},
onSelect(it) {
this.selectedId = it.id
},
async onSubmit() {
if (!this.selectedId) {
uni.showToast({ title: '请选择负责人', icon: 'none' })
return
}
const confirmRes = await new Promise(resolve => {
uni.showModal({ title: '提示', content: '确定分配给该负责人吗?', confirmText: '确定', cancelText: '取消', success: resolve })
})
if (!(confirmRes && confirmRes.confirm)) return
try {
await supplierQuotationDealAssignApi({ id: this.id, principalId: this.selectedId })
uni.showToast({ title: '分配成功', icon: 'none' })
try { uni.setStorageSync('QUOTE_MANAGE_LIST_NEED_REFRESH', '1') } catch (e) {}
setTimeout(() => { uni.navigateBack() }, 400)
} catch (e) {
uni.showToast({ title: e.msg || '分配失败', icon: 'none' })
}
}
}
}
</script>
<style lang="scss" scoped>
.page {
display: flex;
flex-direction: column;
height: 100%;
background: #f3f3f3;
}
.scroll {
flex: 1;
padding: 20rpx 0 200rpx;
}
.section {
padding: 0 24rpx;
}
.card {
background: #fff;
border-radius: 12rpx;
padding: 28rpx 32rpx;
margin-bottom: 20rpx;
border: 2rpx solid transparent;
&.is-selected {
border-color: $theme-primary;
background: rgba($theme-primary, 0.04);
}
.card-row {
display: flex;
align-items: center;
margin-bottom: 12rpx;
&.sub {
margin-bottom: 8rpx;
}
&:last-child {
margin-bottom: 0;
}
}
.card-name {
flex: 1;
font-size: 32rpx;
font-weight: 600;
color: rgba(0, 0, 0, 0.9);
}
.card-check {
color: $theme-primary;
font-size: 36rpx;
font-weight: 700;
}
.card-label {
font-size: 28rpx;
color: rgba(0, 0, 0, 0.6);
}
.card-value {
flex: 1;
font-size: 28rpx;
color: rgba(0, 0, 0, 0.9);
}
}
.empty {
text-align: center;
color: rgba(0, 0, 0, 0.4);
font-size: 28rpx;
padding: 120rpx 0;
}
.footer {
z-index: 2;
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 32rpx;
padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
background: #fff;
box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06);
.btn {
height: 80rpx;
line-height: 80rpx;
border-radius: 12rpx;
font-size: 32rpx;
}
.submit {
background: $theme-primary;
color: #fff;
&[disabled] {
opacity: 0.5;
}
}
}
</style>