order.vue
10.5 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
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
<!-- 权益订单 -->
<template>
<div>
<report @toSearchOrderDetail="toSearchOrderDetail" ref="reportRef" :isGH="routeInfo.isGH" :pageType="pageType" :editForm.sync="editForm"></report>
<repair ref="repairRef" @changeObjectType="changeObjectType" :isGH="routeInfo.isGH" :pageType="pageType" :serviceItemsList.sync="serviceItemsList" :totalPrice.sync="totalPrice" :accountForm.sync="accountForm"></repair>
<material ref="materialRef" :pageType="pageType" :materialForm.sync="materialForm"></material>
<div class="page-btm-btn" v-if="pageType != 2">
<el-button type="primary" @click="confirmSubmit(1)">提交</el-button>
<el-button type="primary" plain @click="confirmSubmit(2)">草稿</el-button>
</div>
</div>
</template>
<script>
import report from './components/report.vue'
import repair from './components/repair.vue'
import material from './components/material.vue'
import util from '@/util/util'
export default {
name: 'order',
components: {
report,
repair,
material
},
data() {
return {
permitDraft: false,
routeInfo: null,
isGH: false,
editForm: {
contractNo: '',
reportDate: '',
reimbursementDate: '',
reimbursementAddress: '',
reporterName: '',
reporterPhone: '',
writeOffCode: '',
reimbursementAddr: '',
reimbursementProvinceCode: '',
reimbursementCityCode: '',
reimbursementCountiesCode: ''
},
pageType: 1,
accountForm: {
objectType: 0,
accountType: 0,
branchBankCode: '',
accountName: '',
accountNo: '',
bankCity: '',
payeeIDCardType: '',
payeeIDCardNo: '',
payeePhone: '',
handlerName: '',
handlerPhone: ''
},
saveObj: {},
materialForm: {
idCard: [],
idCardBack: [],
billInfo: [],
otherInfo: []
},
serviceItemsList: []
}
},
created() {
this.initSaveObj()
const urlParam = this.$route.params
const urlQuery = JSON.parse(decodeURIComponent(urlParam.id))
this.pageType = urlQuery.editNo
this.routeInfo = urlQuery
this.handleFormInfo(urlQuery.contractNo, urlQuery.isGH)
// if(!this.isGH){
// }
if (this.routeInfo.orderId) {
this.getDetailById()
}
},
computed: {
totalPrice() {
let total = this.serviceItemsList.reduce(function(prev, cur) {
return prev + +(cur.approveAmount * 100).toFixed(0)
}, 0)
return total / 100
}
},
mounted() {
console.log('更新')
},
methods: {
changeObjectType(newVal) {
if (newVal === 1) {
this.saveObj.objectType = newVal
delete this.saveObj.handlerName
delete this.saveObj.handlerPhone
this.accountForm = { ...this.accountForm, ...this.saveObj }
} else {
this.saveObj = { ...this.accountForm }
this.getAccountInfo(this.editForm.contractNo)
}
},
initSaveObj() {
this.saveObj = { ...this.accountForm }
},
//详情
getDetailById() {
this.$apis.claims.getClaimsDetail({ id: this.routeInfo.orderId }).then(res => {
// 以下是report数据
for (let key in this.editForm) {
this.editForm[key] = res[key]
}
this.editForm.reportDate = res.reporterDate
this.editForm.reimbursementAddress = []
const { reimbursementCityCode, reimbursementCountiesCode, reimbursementProvinceCode, serviceItemsList } = res
this.editForm.reimbursementAddress.push(reimbursementProvinceCode, reimbursementCityCode, reimbursementCountiesCode)
// 以下是repair数据
for (let key in this.accountForm) {
this.accountForm[key] = res[key]
}
if (this.accountForm.objectType !== 1) {
this.accountForm.accountType = 0
this.accountForm.objectType = 0
}
if (this.accountForm.accountType !== 1) this.accountForm.accountType = 0
this.serviceItemsList = serviceItemsList
// 以下是文件数据
res.files.forEach(item => {
let obj = { url: item.fileUrl, fileType: item.fileType, name: item.fileName, progress: 100 }
if (item.fileCode == '1') {
if (item.fileName.indexOf('&front&_') === 0) {
this.materialForm.idCard.push(obj)
} else {
this.materialForm.idCardBack.push(obj)
}
} else if (item.fileCode == '31') {
this.materialForm.billInfo.push(obj)
} else if (item.fileCode == '4') {
this.materialForm.otherInfo.push(obj)
}
})
})
},
// 新增的时候,输入合同号,带出信息
toSearchOrderDetail() {
let param = {}
param.contractNo = this.editForm.contractNo
let targetAPI = this.$apis.claims.checkContractNo
if (this.routeInfo.isGH) {
param.writeOffCode = this.editForm.writeOffCode
targetAPI = this.$apis.claims.getDetailByWOCode
}
targetAPI(param).then(res => {
this.permitDraft = true
const { serviceItemsList, contractNo } = res
for (let key in this.editForm) {
this.editForm[key] = res[key] || this.editForm[key]
}
this.serviceItemsList = serviceItemsList
this.getAccountInfo(contractNo)
})
},
// 点击同步,获取收款人信息
getAccountInfo(contractNo) {
if (!contractNo) return
this.$apis.claims.getAccountInfo({ contractNo }).then(res => {
const { accountName, accountCityCode: bankCity, openBankCode: branchBankCode, accountNo, accountType, cardNo: payeeIDCardNo, cardTypeCode: payeeIDCardType, phone: payeePhone } = res || {}
const result = { accountName, bankCity, branchBankCode, accountNo, accountType, payeeIDCardNo, payeeIDCardType, payeePhone }
// for (let key in this.accountForm) {
// this.accountForm[key] = result[key] || this.accountForm[key]
// }
this.accountForm = { ...this.accountForm, ...result }
if (this.accountForm.accountType !== 1) this.accountForm.accountType = 0
if (this.accountForm.objectType !== 1) this.accountForm.accountType = 0
})
},
// 根据页面跳转参数处理表单信息-自动填入
// 步骤流程:拿到核销码/合同号后==》请求接口获取该合同号/核销码下对应的套餐,下发数据到维修信息模块,上传资料模块,报案信息模块
handleFormInfo(contractNo, isGH) {
if (isGH) {
this.editForm.writeOffCode = contractNo
}
this.editForm.contractNo = contractNo
},
// 提交的时候校验,滴加不校验经办人信息
validAccountInfo() {
let valid = false
this.$refs.repairRef.$refs.accountRef.$refs.formRef.validate(aValid => {
this.$refs.reportRef.$refs.editFormRefReport.$refs.formRef.validate(eValid => {
if (aValid && eValid) {
valid = true
}
if (this.routeInfo.isGH) {
this.$refs.repairRef.$refs.handlerRef.$refs.formRef.validate(hValid => {
valid = hValid
})
}
})
})
if (!valid) return valid
let requirePrice = true
this.serviceItemsList.forEach(item => {
if (item.approveAmount > 0) {
requirePrice = false
}
})
if (requirePrice) {
this.$message.error('至少输入一项服务的定损批准金额')
return false
}
let fileTip = false
for (let key in this.materialForm) {
if (this.materialForm[key].length < 1 && !fileTip) {
fileTip = true
}
}
if (fileTip) {
this.$message.error(`请补全资料`)
return false
}
return valid
},
// 提交核赔
confirmSubmit(type) {
if (type == 1 && !this.validAccountInfo()) {
return false
}
let isUpload = false
for (let key in this.materialForm) {
this.materialForm[key].forEach(item => {
if (!item.url) isUpload = true
})
}
if (isUpload) {
this.$message.error(`文件正在上传,请稍后再${type == 1 ? '提交' : '保存草稿'}`)
return false
}
if (!this.routeInfo.orderId && type == 2 && !this.permitDraft) {
this.$message.error('请同步信息之后再保存草稿')
return
}
const params = { ...this.editForm, ...this.accountForm }
if (params.accountType !== 1) {
params.accountType = 0
}
params.operation = type
params.reimbursementDate = params.reimbursementDate ? util.dateFormat(params.reimbursementDate, 'YYYY-MM-DD HH:mm:ss') : ''
params.reportDate = params.reportDate ? util.dateFormat(params.reportDate, 'YYYY-MM-DD HH:mm:ss') : ''
if (params.reimbursementAddress.length == 3) {
params.reimbursementProvinceCode = params.reimbursementAddress[0]
params.reimbursementCityCode = params.reimbursementAddress[1]
params.reimbursementCountiesCode = params.reimbursementAddress[2]
}
params.approveAmounts = ''
let tagetObj = {}
this.serviceItemsList.forEach(item => {
tagetObj[item.serviceItemCode] = item.approveAmount
})
params.approveAmounts = JSON.stringify(tagetObj)
delete params.reimbursementAddress
params.fileList = []
for (let key in this.materialForm) {
this.materialForm[key].forEach((item, index) => {
const obj = {}
obj.fileType = item.fileType
obj.fileUrl = item.url
obj.fileCode = key == 'idCard' || key == 'idCardBack' ? 1 : key == 'billInfo' ? 31 : 4
obj.fileName = item.name
params.fileList.push(obj)
})
}
if (this.routeInfo.orderId) {
params.id = this.routeInfo.orderId
}
const loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.3)'
})
this.$apis.claims.commitClaimsOrder(params).then(res => {
loading.close()
if (res) {
this.$message({
message: type == 1 ? '提交成功' : '保存草稿成功',
type: 'success'
})
this.handleCancel()
}
})
},
handleCancel() {
this.$router.push({ path: '/claims/index' })
}
}
}
</script>
<style lang="scss" scoped>
.footer {
width: 100%;
position: fixed;
bottom: 0;
height: 64px;
left: 0;
text-align: center;
line-height: 64px;
background: #ffffff;
}
</style>