expenseList.vue
6.95 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
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
<!-- 激励池 - 支出 -->
<template>
<div class="expense-list">
<d2-table ref="expenseTable"
:has-num="false"
:search-form="searchFormSearch"
:table-params="tableParams"
:get-list-api="getListApi"
:before-search-fn="beforeSearchFn">
<template slot="remark" slot-scope="scope">
<template v-if="scope.scope.remark.length > 20">
<el-popover placement="top" width="300" trigger="hover">
<div class="merchant-name-box">
{{ remarkFilter(scope.scope) }}
</div>
<div slot="reference">
{{ remarkFilter(scope.scope, 20) }}
</div>
</el-popover>
</template>
<span v-else>{{ scope.scope.remark || '-' }}</span>
</template>
<template slot="auth-button" slot-scope="scope">
<auth-button :data="scope.scope" :show-btn-ids="['9121208']" />
</template>
</d2-table>
<add-expense-dialog :expense-visible="expenseVisible" v-if="expenseVisible" :expense-pool-info="staticData" @expenseClose="expenseClose"></add-expense-dialog>
<d2-dialog title="修改备注"
:is-visible="remarkVisible"
width="720px"
@confirmDialog="handleConfirm"
@closeDialog="handleClose">
<div class="form-content">
<el-form ref="remarkForm" :model="remarkForm" :rules="rules" label-width="154px">
<el-form-item label="备注:" prop="remark">
<el-input type="textarea" v-model="remarkForm.remark" :rows="4" maxlength="100" class="wid_432" show-word-limit placeholder="请输入备注"></el-input>
</el-form-item>
<el-form-item label="历史备注:">
<div v-for="item in remarkForm.historyRemark" :key="item.id" class="history-remark">
<el-input type="textarea" v-model="item.remark" :rows="4" maxlength="500" class="wid_432" show-word-limit disabled></el-input>
<div class="time">{{ item.createTimeStr }}</div>
</div>
</el-form-item>
</el-form>
</div>
</d2-dialog>
</div>
</template>
<script>
import { mapActions } from 'vuex'
import { Util, deepClone } from '@/common/util'
import addExpenseDialog from './addExpenseDialog.vue'
import { staffLevelList } from '@/common/constants.js'
import { editIncentivePoolRemarkApi, getIncentivePoolExpendListApi, getIncentivePoolRemarkRecordApi } from '@api/resident'
import { filterStr } from '../../inStoreManage/util.js'
export default {
name: 'ExpenseList',
components: {
addExpenseDialog
},
data() {
return {
searchFormSearch: {},
getListApi: getIncentivePoolExpendListApi,
// 表格参数
tableParams: {
needUnique: true,
mutiSelectUniqueKey: 'uniqueVal',
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableOption: {
width: '100'
},
tableColumns: [{
label: '序号',
prop: 'ownSerialNum',
type: 'ownSerialNum',
width: '60'
}, {
label: '员工姓名',
prop: 'staffName'
}, {
label: '职级',
prop: 'jobType',
formatter: (cellValue) => {
return filterStr(cellValue.jobType, this.baseData.jobTypeList, cellValue.hireType)
}
}, {
label: '支出时间',
prop: 'createdDate',
formatter: (cellValue) => {
return cellValue.createdDate ? Util.dateFormate(cellValue.createdDate, 'YYYY-MM-DD HH:mm:ss') : '-'
}
}, {
label: '金额',
prop: 'expensePrice',
formatter: (cellValue) => {
return cellValue.expensePrice ? `¥${cellValue.expensePrice}` : '-'
}
}, {
label: '操作人',
prop: 'updatedBy'
}, {
label: '备注',
prop: 'remark',
width: '300',
addHtml: 'remark'
}]
},
expenseVisible: false,
baseData: {
jobTypeList: deepClone(staffLevelList)
},
remarkForm: {historyRemark: []},
remarkVisible: false,
rules: {
remark: [
{ required: true, message: '请输入备注', trigger: 'blur' }
]
}
}
},
props: {
parentSearchForm: {
type: Object,
default: () => { }
},
staticData: {
type: Object,
default: () => { }
}
},
mounted() {
},
methods: {
...mapActions({
get: 'd2admin/base/get'
}),
remarkFilter(ele, lenght) {
if (ele.remark) {
return lenght ? (ele.remark?.length > lenght ? ele.remark.substring(0, lenght) + '\u2026' : ele.remark.substring(0, lenght)) : ele.remark
} else {
return '-'
}
},
keyDowmGetList() {
this.$refs.expenseTable.refreshTable(true, true)
},
beforeSearchFn() {
return new Promise(resolve => {
if (this.parentSearchForm.time && this.parentSearchForm.time?.length) {
this.parentSearchForm.startTime = Util.dateFormate(
this.parentSearchForm.time[0],
"YYYY-MM-DD HH:mm:ss"
)
this.parentSearchForm.endTime =
Util.dateFormate(this.parentSearchForm.time[1], "YYYY-MM-DD") + " 23:59:59"
}
delete this.parentSearchForm.time
this.searchFormSearch = {
...this.parentSearchForm
}
resolve()
})
},
// 编辑备注
handleToNote(row) {
this.remarkRow = row
getIncentivePoolRemarkRecordApi({ id: row.id }).then(res => {
res?.remarkRecordList?.forEach(v => {
v.createTimeStr = Util.dateFormate(v.createdDate, 'YYYY-MM-DD HH:mm:ss')
})
this.remarkForm.historyRemark = res?.remarkRecordList || []
this.handleClose()
})
},
handleConfirm() {
this.$refs.remarkForm.validate((valid) => {
if (valid) {
editIncentivePoolRemarkApi({ id: this.remarkRow.id, remark: this.remarkForm.remark }).then(res => {
this.$message.success('备注成功')
this.handleClose()
this.$refs.expenseTable.refreshTable(true, true)
})
}
})
},
handleClose() {
this.remarkVisible = !this.remarkVisible
this.$nextTick(() => {
this.$set(this.remarkForm, 'remark', '')
})
},
// 新增支出
handleAddExpenditure() {
this.expenseClose()
},
expenseClose(confirm) {
if (confirm) {
this.expenseVisible = !this.expenseVisible
// 刷新列表数据
this.$refs.expenseTable.refreshTable(true, true)
// 刷新统计数据
this.$emit('refreshStatic')
} else {
this.expenseVisible = !this.expenseVisible
}
}
}
}
</script>
<style lang="scss" scoped>
.wid_432{
width: 432px;
}
.time{
font-size: 14px;
color: #999999;
}
.form-content{
max-height: calc(65vh - 60px);
overflow: auto;
}
</style>