|
|
@@ -1,9 +1,6 @@
|
|
1
|
1
|
<template>
|
|
2
|
2
|
<view class="commission-form-list">
|
|
3
|
|
- <!-- 头部按钮组 -->
|
|
4
|
|
- <view class="commission-header">
|
|
5
|
|
- <u-button type="primary" size="mini" icon="plus" @click="handleAdd">新增分成</u-button>
|
|
6
|
|
- </view>
|
|
|
3
|
+
|
|
7
|
4
|
|
|
8
|
5
|
<!-- 分成信息卡片列表 -->
|
|
9
|
6
|
<view v-if="loading" class="loading_wrap">
|
|
|
@@ -13,336 +10,107 @@
|
|
13
|
10
|
<u-empty text="暂无分成数据"></u-empty>
|
|
14
|
11
|
</view>
|
|
15
|
12
|
<view v-else class="card_list">
|
|
16
|
|
- <view class="card_item" v-for="(row, index) in commissionList" :key="row.id">
|
|
17
|
|
- <view class="card_header">
|
|
18
|
|
- <view class="card_title">{{ row.userName || '-' }}</view>
|
|
19
|
|
- <view class="card_actions">
|
|
20
|
|
- <u-button size="mini" type="text" @click="handleEdit(row)">编辑</u-button>
|
|
21
|
|
- <u-button size="mini" type="text" @click="handleDelete(row.id)" style="color: #f56c6c">删除</u-button>
|
|
22
|
|
- </view>
|
|
23
|
|
- </view>
|
|
24
|
|
- <view class="card_body">
|
|
25
|
|
- <view class="info_row">
|
|
26
|
|
- <view class="info_label">公司:</view>
|
|
27
|
|
- <view class="info_value">{{ row.orgName || '-' }}</view>
|
|
28
|
|
- </view>
|
|
29
|
|
- <view class="info_row">
|
|
30
|
|
- <view class="info_label">账户类型:</view>
|
|
31
|
|
- <view class="info_value">{{ row.accountType === '1' ? '前端' : '后端' }}</view>
|
|
32
|
|
- </view>
|
|
33
|
|
- <view class="info_row">
|
|
34
|
|
- <view class="info_label">分成比例:</view>
|
|
35
|
|
- <view class="info_value highlight">{{ row.commissionRate || '0' }}%</view>
|
|
36
|
|
- </view>
|
|
37
|
|
- <view class="info_row">
|
|
38
|
|
- <view class="info_label">创建时间:</view>
|
|
39
|
|
- <view class="info_value">{{ formatTime(row.createTime) }}</view>
|
|
40
|
|
- </view>
|
|
41
|
|
- </view>
|
|
42
|
|
- </view>
|
|
|
13
|
+ <commission-item v-for="(row) in commissionList" :key="row.id" :item="row" :type="'2'" @click.native="handleEdit(row)"></commission-item>
|
|
43
|
14
|
</view>
|
|
44
|
|
-
|
|
45
|
|
- <!-- 分页组件 -->
|
|
46
|
|
- <u-pagination
|
|
47
|
|
- v-if="total > 0"
|
|
48
|
|
- :total="total"
|
|
49
|
|
- :current="queryParams.pageNum"
|
|
50
|
|
- :page-size="queryParams.pageSize"
|
|
51
|
|
- @change="handlePageChange"
|
|
52
|
|
- :page-sizes="[10, 20, 50, 100]"
|
|
53
|
|
- :show-total="true"
|
|
54
|
|
- ></u-pagination>
|
|
55
|
|
-
|
|
56
|
|
- <!-- 新增/编辑对话框 -->
|
|
57
|
|
- <u-popup v-model="dialogVisible" mode="center" width="500rpx" border-radius="16">
|
|
58
|
|
- <view class="dialog_header">{{ dialogTitle }}</view>
|
|
59
|
|
- <view class="dialog_body">
|
|
60
|
|
- <u-form :model="commissionForm" ref="commissionFormRef" label-width="120rpx">
|
|
61
|
|
- <u-form-item label="账户类型" prop="accountType" :required="true">
|
|
62
|
|
- <u-radio-group v-model="commissionForm.accountType" :disabled="!isEdit">
|
|
63
|
|
- <u-radio name="1" label="前端"></u-radio>
|
|
64
|
|
- <u-radio name="2" label="后端"></u-radio>
|
|
65
|
|
- </u-radio-group>
|
|
66
|
|
- </u-form-item>
|
|
67
|
|
- <u-form-item label="分成人" prop="userName" :required="true">
|
|
68
|
|
- <u-input v-model="commissionForm.userName" placeholder="请选择分成人" :disabled="!isEdit" />
|
|
69
|
|
- </u-form-item>
|
|
70
|
|
- <u-form-item label="分成比例(%)" prop="commissionRate" :required="true">
|
|
71
|
|
- <u-input v-model.number="commissionForm.commissionRate" type="number" placeholder="请输入分成比例(0-100)" />
|
|
72
|
|
- </u-form-item>
|
|
73
|
|
- </u-form>
|
|
74
|
|
- </view>
|
|
75
|
|
- <view class="dialog_footer">
|
|
76
|
|
- <u-button @click="handleClose">取消</u-button>
|
|
77
|
|
- <u-button type="primary" @click="handleSubmit">确定</u-button>
|
|
78
|
|
- </view>
|
|
79
|
|
- </u-popup>
|
|
80
|
15
|
</view>
|
|
81
|
16
|
</template>
|
|
82
|
17
|
|
|
83
|
18
|
<script>
|
|
84
|
|
-export default {
|
|
85
|
|
- name: 'CommissionFormList',
|
|
86
|
|
- props: {
|
|
87
|
|
- sendFormId: {
|
|
88
|
|
- type: [Number, String],
|
|
89
|
|
- required: true
|
|
|
19
|
+ import commissionItem from "@/pages/order/components/commission/commissionItem.vue";
|
|
|
20
|
+
|
|
|
21
|
+ export default {
|
|
|
22
|
+ name: 'CommissionFormList',
|
|
|
23
|
+ components: {
|
|
|
24
|
+ commissionItem
|
|
90
|
25
|
},
|
|
91
|
|
- clueId: {
|
|
92
|
|
- type: [Number, String],
|
|
93
|
|
- required: true
|
|
94
|
|
- }
|
|
95
|
|
- },
|
|
96
|
|
- data() {
|
|
97
|
|
- return {
|
|
98
|
|
- commissionList: [],
|
|
99
|
|
- total: 0,
|
|
100
|
|
- loading: false,
|
|
101
|
|
- queryParams: {
|
|
102
|
|
- pageNum: 1,
|
|
103
|
|
- pageSize: 10
|
|
104
|
|
- },
|
|
105
|
|
- dialogVisible: false,
|
|
106
|
|
- dialogTitle: '新增分成',
|
|
107
|
|
- isEdit: true,
|
|
108
|
|
- commissionForm: {
|
|
109
|
|
- id: null,
|
|
110
|
|
- sendFormId: null,
|
|
111
|
|
- clueId: null,
|
|
112
|
|
- accountType: '1',
|
|
113
|
|
- userName: null,
|
|
114
|
|
- userId: null,
|
|
115
|
|
- commissionRate: 0
|
|
|
26
|
+ props: {
|
|
|
27
|
+ sendFormId: {
|
|
|
28
|
+ type: [Number, String],
|
|
|
29
|
+ required: true
|
|
116
|
30
|
},
|
|
117
|
|
- rules: {
|
|
118
|
|
- accountType: [{ required: true, message: '请选择账户类型', trigger: 'change' }],
|
|
119
|
|
- userName: [{ required: true, message: '请选择分成人', trigger: 'blur' }],
|
|
120
|
|
- commissionRate: [
|
|
121
|
|
- { required: true, message: '请输入分成比例', trigger: 'blur' },
|
|
122
|
|
- { type: 'number', min: 0, max: 100, message: '分成比例必须在0-100之间', trigger: 'blur' }
|
|
123
|
|
- ]
|
|
|
31
|
+ clueId: {
|
|
|
32
|
+ type: [Number, String],
|
|
|
33
|
+ required: true
|
|
124
|
34
|
}
|
|
125
|
|
- }
|
|
126
|
|
- },
|
|
127
|
|
- methods: {
|
|
128
|
|
- async getList() {
|
|
|
35
|
+ },
|
|
|
36
|
+ data() {
|
|
|
37
|
+ return {
|
|
|
38
|
+ commissionList: [],
|
|
|
39
|
+ loading: false
|
|
|
40
|
+ }
|
|
|
41
|
+ },
|
|
|
42
|
+ methods: {
|
|
|
43
|
+ async getList() {
|
|
129
|
44
|
this.loading = true
|
|
130
|
45
|
try {
|
|
131
|
|
- const params = {
|
|
132
|
|
- ...this.queryParams,
|
|
|
46
|
+ const data = {
|
|
133
|
47
|
sendFormId: this.sendFormId,
|
|
|
48
|
+ type: '1'
|
|
134
|
49
|
}
|
|
135
|
|
- const res = await uni.$u.api.clueCommissionForm.list(params)
|
|
|
50
|
+ const res = await uni.$u.api.selectCommissionList({}, data);
|
|
136
|
51
|
this.commissionList = res.rows || []
|
|
137
|
|
- this.total = res.total || 0
|
|
138
|
52
|
} catch (error) {
|
|
139
|
53
|
uni.$u.toast('获取分成列表失败')
|
|
140
|
54
|
} finally {
|
|
141
|
55
|
this.loading = false
|
|
142
|
56
|
}
|
|
143
|
57
|
},
|
|
144
|
|
- // 格式化时间
|
|
145
|
|
- formatTime(time) {
|
|
146
|
|
- if (!time) return '-'
|
|
147
|
|
- const date = new Date(time)
|
|
148
|
|
- const year = date.getFullYear()
|
|
149
|
|
- const month = String(date.getMonth() + 1).padStart(2, '0')
|
|
150
|
|
- const day = String(date.getDate()).padStart(2, '0')
|
|
151
|
|
- const hours = String(date.getHours()).padStart(2, '0')
|
|
152
|
|
- const minutes = String(date.getMinutes()).padStart(2, '0')
|
|
153
|
|
- const seconds = String(date.getSeconds()).padStart(2, '0')
|
|
154
|
|
- return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
|
155
|
|
- },
|
|
156
|
|
- handleAdd() {
|
|
157
|
|
- this.dialogTitle = '新增分成'
|
|
158
|
|
- this.commissionForm = {
|
|
159
|
|
- id: null,
|
|
160
|
|
- sendFormId: this.sendFormId,
|
|
161
|
|
- clueId: this.clueId,
|
|
162
|
|
- accountType: '1',
|
|
163
|
|
- userName: null,
|
|
164
|
|
- userId: null,
|
|
165
|
|
- commissionRate: 0
|
|
166
|
|
- }
|
|
167
|
|
- this.$nextTick(() => {
|
|
168
|
|
- if (this.$refs.commissionFormRef) {
|
|
169
|
|
- this.$refs.commissionFormRef.clearValidate()
|
|
170
|
|
- }
|
|
171
|
|
- })
|
|
172
|
|
- this.dialogVisible = true
|
|
173
|
|
- },
|
|
174
|
58
|
handleEdit(row) {
|
|
175
|
|
- this.dialogTitle = '编辑分成'
|
|
176
|
|
- // 深拷贝对象,避免直接修改原数据
|
|
177
|
|
- this.commissionForm = JSON.parse(JSON.stringify(row))
|
|
178
|
|
- this.dialogVisible = true
|
|
179
|
|
- },
|
|
180
|
|
- handleDelete(id) {
|
|
181
|
|
- uni.showModal({
|
|
182
|
|
- title: '警告',
|
|
183
|
|
- content: '确定要删除这条分成记录吗?删除后将无法恢复!',
|
|
184
|
|
- confirmButtonText: '确定删除',
|
|
185
|
|
- cancelButtonText: '取消',
|
|
186
|
|
- success: (res) => {
|
|
187
|
|
- if (res.confirm) {
|
|
188
|
|
- this.deleteRow(id)
|
|
189
|
|
- }
|
|
190
|
|
- }
|
|
|
59
|
+ // 跳转到编辑分成页面
|
|
|
60
|
+ uni.navigateTo({
|
|
|
61
|
+ url: `/pages/commissionForm/index?sendFormId=${this.sendFormId}&clueId=${this.clueId}&id=${row.id}`
|
|
191
|
62
|
})
|
|
192
|
63
|
},
|
|
193
|
|
- async deleteRow(id) {
|
|
194
|
|
- try {
|
|
195
|
|
- await uni.$u.api.clueCommissionForm.remove([id])
|
|
196
|
|
- uni.$u.toast('删除成功')
|
|
197
|
|
- this.getList()
|
|
198
|
|
- } catch (error) {
|
|
199
|
|
- uni.$u.toast('删除失败,请稍后重试')
|
|
200
|
|
- }
|
|
201
|
|
- },
|
|
202
|
|
- handleSubmit() {
|
|
203
|
|
- this.$refs.commissionFormRef.validate(async (valid) => {
|
|
204
|
|
- if (valid) {
|
|
205
|
|
- // 显示加载状态
|
|
206
|
|
- const loading = uni.showLoading({
|
|
207
|
|
- title: this.commissionForm.id ? '编辑中...' : '新增中...',
|
|
208
|
|
- mask: true
|
|
209
|
|
- })
|
|
210
|
|
-
|
|
211
|
|
- try {
|
|
212
|
|
- if (this.commissionForm.id) {
|
|
213
|
|
- await uni.$u.api.clueCommissionForm.update(this.commissionForm)
|
|
214
|
|
- uni.$u.toast('编辑成功')
|
|
215
|
|
- } else {
|
|
216
|
|
- await uni.$u.api.clueCommissionForm.add(this.commissionForm)
|
|
217
|
|
- uni.$u.toast('新增成功')
|
|
|
64
|
+ handleDelete(id) {
|
|
|
65
|
+ uni.showModal({
|
|
|
66
|
+ title: '警告',
|
|
|
67
|
+ content: '确定要删除这条分成记录吗?删除后将无法恢复!',
|
|
|
68
|
+ confirmButtonText: '确定删除',
|
|
|
69
|
+ cancelButtonText: '取消',
|
|
|
70
|
+ success: (res) => {
|
|
|
71
|
+ if (res.confirm) {
|
|
|
72
|
+ this.deleteRow(id)
|
|
218
|
73
|
}
|
|
219
|
|
- this.dialogVisible = false
|
|
220
|
|
- this.getList()
|
|
221
|
|
- } catch (error) {
|
|
222
|
|
- uni.$u.toast('操作失败,请重试')
|
|
223
|
|
- } finally {
|
|
224
|
|
- uni.hideLoading(loading)
|
|
225
|
74
|
}
|
|
|
75
|
+ })
|
|
|
76
|
+ },
|
|
|
77
|
+ async deleteRow(id) {
|
|
|
78
|
+ try {
|
|
|
79
|
+ await uni.$u.api.clueCommissionForm.remove([id])
|
|
|
80
|
+ uni.$u.toast('删除成功')
|
|
|
81
|
+ this.getList()
|
|
|
82
|
+ } catch (error) {
|
|
|
83
|
+ uni.$u.toast('删除失败,请稍后重试')
|
|
226
|
84
|
}
|
|
227
|
|
- })
|
|
228
|
|
- },
|
|
229
|
|
- handleClose() {
|
|
230
|
|
- this.dialogVisible = false
|
|
231
|
|
- // 关闭对话框后重置表单
|
|
232
|
|
- this.$nextTick(() => {
|
|
233
|
|
- if (this.$refs.commissionFormRef) {
|
|
234
|
|
- this.$refs.commissionFormRef.clearValidate()
|
|
235
|
|
- }
|
|
236
|
|
- })
|
|
|
85
|
+ },
|
|
|
86
|
+ // 外部调用获取列表
|
|
|
87
|
+ getListByExternal() {
|
|
|
88
|
+ this.getList()
|
|
|
89
|
+ }
|
|
237
|
90
|
},
|
|
238
|
|
- handlePageChange(page) {
|
|
239
|
|
- this.queryParams.pageNum = page
|
|
|
91
|
+ created() {
|
|
240
|
92
|
this.getList()
|
|
241
|
93
|
},
|
|
242
|
|
- // 外部调用获取列表
|
|
243
|
|
- getListByExternal() {
|
|
|
94
|
+ // 监听页面显示,刷新列表数据
|
|
|
95
|
+ onShow() {
|
|
244
|
96
|
this.getList()
|
|
245
|
97
|
}
|
|
246
|
|
- },
|
|
247
|
|
- created() {
|
|
248
|
|
- this.getList()
|
|
249
|
98
|
}
|
|
250
|
|
-}
|
|
251
|
99
|
</script>
|
|
252
|
100
|
|
|
253
|
101
|
<style lang="scss" scoped>
|
|
254
|
|
-.commission-form-list {
|
|
255
|
|
- padding: 0 20px 20px;
|
|
256
|
|
-}
|
|
257
|
|
-
|
|
258
|
|
-.commission-header {
|
|
259
|
|
- margin-bottom: 16px;
|
|
260
|
|
-}
|
|
261
|
|
-
|
|
262
|
|
-.card_list {
|
|
263
|
|
- display: flex;
|
|
264
|
|
- flex-direction: column;
|
|
265
|
|
- gap: 16px;
|
|
266
|
|
-}
|
|
267
|
|
-
|
|
268
|
|
-.card_item {
|
|
269
|
|
- background-color: #fff;
|
|
270
|
|
- border-radius: 12px;
|
|
271
|
|
- padding: 20px;
|
|
272
|
|
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
|
273
|
|
-}
|
|
274
|
|
-
|
|
275
|
|
-.card_header {
|
|
276
|
|
- display: flex;
|
|
277
|
|
- justify-content: space-between;
|
|
278
|
|
- align-items: center;
|
|
279
|
|
- margin-bottom: 16px;
|
|
280
|
|
- padding-bottom: 12px;
|
|
281
|
|
- border-bottom: 1px solid #f0f0f0;
|
|
282
|
|
-}
|
|
283
|
|
-
|
|
284
|
|
-.card_title {
|
|
285
|
|
- font-size: 18px;
|
|
286
|
|
- font-weight: bold;
|
|
287
|
|
- color: #202020;
|
|
288
|
|
-}
|
|
289
|
|
-
|
|
290
|
|
-.card_actions {
|
|
291
|
|
- display: flex;
|
|
292
|
|
- gap: 8px;
|
|
293
|
|
-}
|
|
294
|
|
-
|
|
295
|
|
-.card_body {
|
|
296
|
|
- display: flex;
|
|
297
|
|
- flex-direction: column;
|
|
298
|
|
- gap: 12px;
|
|
299
|
|
-}
|
|
300
|
|
-
|
|
301
|
|
-.info_row {
|
|
302
|
|
- display: flex;
|
|
303
|
|
- align-items: center;
|
|
304
|
|
- font-size: 14px;
|
|
305
|
|
-}
|
|
306
|
|
-
|
|
307
|
|
-.info_label {
|
|
308
|
|
- color: #666;
|
|
309
|
|
- min-width: 80px;
|
|
310
|
|
- font-weight: 500;
|
|
311
|
|
-}
|
|
312
|
|
-
|
|
313
|
|
-.info_value {
|
|
314
|
|
- color: #202020;
|
|
315
|
|
- flex: 1;
|
|
316
|
|
-
|
|
317
|
|
- &.highlight {
|
|
318
|
|
- color: #108cff;
|
|
319
|
|
- font-weight: bold;
|
|
320
|
|
- font-size: 16px;
|
|
|
102
|
+ .commission-form-list {
|
|
|
103
|
+ padding: 20px 20px 20px;
|
|
|
104
|
+ background: #f5f6f8;
|
|
321
|
105
|
}
|
|
322
|
|
-}
|
|
323
|
|
-
|
|
324
|
|
-.loading_wrap,
|
|
325
|
|
-.empty_wrap {
|
|
326
|
|
- padding: 40px 20px;
|
|
327
|
|
- text-align: center;
|
|
328
|
|
-}
|
|
329
|
|
-
|
|
330
|
|
-.dialog_header {
|
|
331
|
|
- padding: 20px;
|
|
332
|
|
- font-size: 32rpx;
|
|
333
|
|
- font-weight: bold;
|
|
334
|
|
- text-align: center;
|
|
335
|
|
- border-bottom: 1px solid #e9ecef;
|
|
336
|
|
-}
|
|
337
|
106
|
|
|
338
|
|
-.dialog_body {
|
|
339
|
|
- padding: 20px;
|
|
340
|
|
-}
|
|
|
107
|
+ .commission-header {
|
|
|
108
|
+ margin-bottom: 16px;
|
|
|
109
|
+ }
|
|
341
|
110
|
|
|
342
|
|
-.dialog_footer {
|
|
343
|
|
- padding: 20px;
|
|
344
|
|
- display: flex;
|
|
345
|
|
- justify-content: space-around;
|
|
346
|
|
- border-top: 1px solid #e9ecef;
|
|
347
|
|
-}
|
|
|
111
|
+ .loading_wrap,
|
|
|
112
|
+ .empty_wrap {
|
|
|
113
|
+ padding: 40px 20px;
|
|
|
114
|
+ text-align: center;
|
|
|
115
|
+ }
|
|
348
|
116
|
</style>
|