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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
<template>
<div class="AllowancePayment">
<div class="searchBox">
<a-select placeholder="津贴类型" :allowClear="true" style="width: 120px;margin-right: 20px;" @change="selectHandType">
<a-select-option value="TRAVEL">交通补助</a-select-option>
<a-select-option value="MEAL">餐补</a-select-option>
</a-select>
<a-select placeholder="经办人" :allowClear="true" style="width: 120px;margin-right: 20px;" @change="selectAgent">
<a-select-option v-for="(item, index) in agentList" :key="index" :value="item.ddUserId">{{ item.name }}</a-select-option>
</a-select>
<a-button type="primary" @click="search()">查询</a-button>
<a-button type="primary" @click="changeModel()" style="margin-left: 20px;"><a-icon type="pay-circle" />发放津贴</a-button>
</div>
<!-- <div class="searchUserMessage" v-if="searchSource.UserMessage.emplId">
<div class="positionDiv"></div>
<div class="clearUserMessage"><a href="javascript:;" @click="clearUserMessage">清除</a></div>
<div style="text-align: center">
<img v-if="searchSource.UserMessage.avatar" :src="searchSource.UserMessage.avatar" :alt="searchSource.UserMessage.name"/>
<img v-else :src="this.avatarCanvasFn(searchSource.UserMessage.name)" :alt="searchSource.UserMessage.name">
<span>{{ searchSource.UserMessage.name }}</span>
</div>
</div> -->
<a-table :columns="columns" :dataSource="recordsList" size="default" rowKey="grantNumber" :pagination="pagination" @change="handleTableChange">
<span slot="recipient">成员</span>
<span slot="money">金额</span>
<span slot="type" slot-scope="type">{{ type === 'TRAVEL' ? '交通补助' : '餐补' }}</span>
<span slot="grantNumber">单号</span>
<span slot="agentId">经办人</span>
<span slot="createTime" slot-scope="createTime">
{{ createTimeToStr(createTime) }}
</span>
<span slot="remark">备注</span>
<span slot="action" slot-scope="text, record, index" class="operationTable">
<a href="javascript:;" @click="toAllowanceDetails(record, text, index)">查看详情</a>
</span>
</a-table>
<a-spin :spinning="spinning" :delay="delayTime">
<a-modal title="发放津贴" v-model="visible" @ok="createSubsidy()">
<a-form :form="form">
<a-form-item
v-bind="formItemLayout"
label="发放类型"
has-feedback
>
<a-select
v-decorator="[
'select',
{rules: [{ required: true, message: ' 津贴类型' }]}
]"
placeholder="请选择津贴类型"
>
<a-select-option value="TRAVEL">
交通补助
</a-select-option>
<a-select-option value="MEAL">
餐补
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="发放金额" v-bind="formItemLayout" >
<a-input
v-decorator="['orderPrice',{rules: [{required: true, message: '充值金额不能为空'}, {validator: rechargeNum}]}]"
/>
</a-form-item>
<a-form-item
v-bind="formItemLayout"
label="截止日期"
>
<a-date-picker
placeholder="请选择截止日期"
:disabledDate="disabledDate"
:showToday="false"
v-decorator="['date-picker', config]"
/>
</a-form-item>
<a-form-item label="选择成员" v-bind="formItemLayout">
<div class="peopleBox" @click="choosePeople()">
{{ peopleListStr() }}
</div>
</a-form-item>
<a-form-item label="备注" v-bind="formItemLayout" >
<a-textarea v-decorator="['remark', {rules: [{ required: true, message: '备注不能为空' }]}]"/>
</a-form-item>
</a-form>
</a-modal>
</a-spin>
</div>
</template>
<script>
import { config } from './../../../api/config.js'
import { $http } from './../../../api/axios.js'
import { MINGPAY_RECORDS_STATUS } from './../../../api/constant'
import moment from 'moment'
export default {
name: 'AllowancePayment',
data () {
return {
spinning: false,
delayTime: 100,
formItemLayout: {
labelCol: {
xs: { span: 24 },
sm: { span: 5 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 }
}
},
columns: [{
title: '成员',
dataIndex: 'recipient',
width: '20%'
}, {
title: '金额',
dataIndex: 'money'
}, {
title: '津贴类型',
dataIndex: 'type',
scopedSlots: { customRender: 'type' }
}, {
title: '单号',
dataIndex: 'grantNumber'
}, {
title: '经办人',
dataIndex: 'agentId'
}, {
title: '备注',
dataIndex: 'remark'
}, {
title: '时间',
dataIndex: 'createTime',
scopedSlots: { customRender: 'createTime' }
}, {
title: '操作',
dataIndex: 'action',
scopedSlots: { customRender: 'action' }
}],
form: this.$form.createForm(this),
visible: false,
searchSource: {
UserMessage: {
avatar: '',
emplId: '',
name: ''
},
type: '',
agentId: ''
},
recordsList: [],
pagination: {
current: 1,
defaultCurrent: 10,
defaultPageSize: 10,
hideOnSinglePage: true,
total: 0
},
config: {
rules: [{ type: 'object', required: true, message: '请选择时间' }]
},
userIdListObj: [],
departmentIdListObj: [],
agentList: []
}
},
created: function () {
this.queryRecordList()
this.getAgentList()
},
methods: {
// 获取收银员列表
getAgentList () {
let AgentData = this.$qs.stringify({
orgId: localStorage.getItem('orgId')
})
$http.get(`/v1/account/query_user_admin_list?${AgentData}`).then((res) => {
this.agentList = res.data.data.recordList
})
},
toAllowanceDetails (record, text, index) {
this.$router.push({ name: 'allowanceDetails', params: { allowanceDetails: record } })
},
selectAgent (value) {
this.searchSource.agentId = value
},
disabledDate (current) {
// Can not select days before today and today
console.log(moment().endOf('day'))
return current < moment(Date.now()).add(-1, 'day')
},
// 获取消费列表
queryRecordList () {
let RecordData = this.$qs.stringify({
currentPage: this.pagination.current,
pageNumber: this.pagination.defaultPageSize,
type: this.searchSource.type,
agentId: this.searchSource.agentId,
orgId: localStorage.getItem('orgId')
})
$http.get(`/v1/account/list_couponRecord?${RecordData}`).then((res) => {
let data = res.data.data
this.recordsList = data.list
this.pagination.total = parseInt(data.total)
})
},
// 校验账户充值金额大小和纯数字
rechargeNum (rule, value, callback) {
const temp = /^\d+\.?\d{0,2}$/
if (!temp.test(value) || parseFloat(value) > 10000) {
callback('请输入正确的金额,最多保留小数点后两位,津贴金额最多为一万元')
return
}
callback()
},
// 表格时间处理
createTimeToStr (time) {
let timeData = new Date(parseInt(time))
let year = timeData.getFullYear()
let month = timeData.getMonth() + 1
let date = timeData.getDate()
let hour = timeData.getHours()
let minute = timeData.getMinutes()
return `${year}年${month}月${date}日 ${hour}:${minute}`
},
// 清理选择帅选人list
clearUserMessage () {
this.searchSource.UserMessage = {
avatar: '',
emplId: '',
name: ''
}
},
// 用户头像处理
avatarCanvasFn (name) {
let canvas = document.createElement('canvas')
let con = canvas.getContext('2d')
let ratio = this.getPixelRatio(con)
canvas.style.width = 40 + 'px'
canvas.style.height = 40 + 'px'
canvas.width = 40 * ratio
canvas.height = 40 * ratio
con.scale(ratio, ratio)
con.fillStyle = '#1890ff'
con.fillRect(0, 0, 40, 40)
con.fillStyle = '#ffffff'
con.font = '12px Arial'
con.textAlign = 'center'
con.fillText(name, 20, 25)
return canvas.toDataURL()
},
// 头像模糊处理
getPixelRatio (context) {
var backingStore = context.backingStorePixelRatio ||
context.webkitBackingStorePixelRatio ||
context.mozBackingStorePixelRatio ||
context.msBackingStorePixelRatio ||
context.oBackingStorePixelRatio ||
context.backingStorePixelRatio || 1
return (window.devicePixelRatio || 1) / backingStore
},
handleTableChange (pagination, filters, sorter) {
this.pagination.current = pagination.current
this.queryRecordList()
},
// 搜索条件津贴类型
selectHandType (value) {
this.searchSource.type = value
},
peopleListStr () {
let str = ''
this.userIdListObj.map((item, index) => {
str = str + item.name + ','
})
this.departmentIdListObj.map((item, index) => {
str = str + item.name + ','
})
return str.substring(0, str.length - 1)
},
createSubsidy () {
this.spinning = true
this.form.validateFields((err, fieldsValue) => {
if (err) {
return
}
// Should format date value before submit.
const values = {
...fieldsValue,
'date-picker': fieldsValue['date-picker'].format('YYYY-MM-DD')
}
let userIdList = []
let departmentIdList = []
this.userIdListObj.map((item, index) => {
userIdList.push(item.emplId)
})
this.departmentIdListObj.map((item, inde) => {
departmentIdList.push(item.id)
})
let RecordData = this.$qs.stringify({
userIds: userIdList,
departmentIds: departmentIdList,
money: values.orderPrice,
endTime: `${values['date-picker']} 23:59:59`,
remark: values.remark,
type: values.select,
orgId: localStorage.getItem('orgId')
})
$http.get(`/v1/account/batch_create_subsidy?${RecordData}`).then((res) => {
if (res.data.resultCode === '0') {
this.visible = false
this.form.resetFields()
this.userIdListObj = []
this.departmentIdListObj = []
this.$message.success(res.data.data)
this.spinning = false
this.queryRecordList()
} else {
this.$message.error(res.data.message)
}
})
})
},
changeModel () {
this.visible = !this.visible
},
choosePeople () {
config.ddready('ddchoose').then((res) => {
this.userIdListObj = res.users
this.departmentIdListObj = res.departments
this.form.getFieldsValue().peopleList = 'ok'
})
},
search () {
this.pagination.current = 1
this.queryRecordList()
}
}
}
</script>
<style lang="less" scoped>
.searchBox{
display: flex;
margin-bottom: 20px;
}
.searchBox > input {
margin-right: 20px;
max-width: 180px;
}
.operationTable a{
margin-right: 8px;
}
.searchUserMessage{
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
font-size: 12px;
padding: 8px 8px;
border: 1px solid #cccccc;
margin-bottom: 15px;
border-radius: 8px;
position: relative;
}
.searchUserMessage img{
width: 32px;
height: 32px;
border-radius: 50%;
margin-bottom: 8px;
}
.positionDiv{
height: 12px;
width: 12px;
transform:rotate(45deg);
border-left: 1px solid #cccccc;
border-top: 1px solid #cccccc;
position: absolute;
top: -7px;
left: 30px;
background: white;
z-index: 99;
}
.clearUserMessage{
position: absolute;
right: 10px;
}
.peopleBox{
width: 100%;
border: 1px solid #d9d9d9;
min-height: 40px;
border-radius: 4px;
padding: 4px 11px;
font-size: 14px;
line-height: 1.5;
cursor: pointer;
}
</style>