secondDialog.vue
3.74 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
<template>
<GLDialog class="second-dialog" title="重要提示" width="576px" :visible.sync="secondVisible" :show-close="true" :hasFooter="!isEditVin" :before-close="handleCancel" :close-on-click-modal="false" @onCancel="handleCancel" @onOk="handleOk">
<div class="modal-wrap">
<div class="tips">
<img class="icon-info" src="@/assets/icon_info.png" />
{{secondInfo.tips}}
</div>
<glsx-combi-form :isInline="false" class="edit-form-container" ref="editFormRefSec" labelWidth="154px" defaultWidth="284px" formRef="editChildRef" :isEdit="true" :formObj="editFormSec" :formData="secondInfo.editFormDataSec" :formRules="formRules">
<template slot="vin">
<div v-if="!isEditVin" class="vin-detail">
<div>{{editFormSec.vin?.replace(/(.{4})/g, "$1 ")}}</div>
<img class="icon-edit" src="@/assets/icon_edit.png" @click="handleChangeVin" />
</div>
<div v-else class="vin-edit">
<el-input placeholder="请输入车架号" v-model.trim="editFormSec.vin" maxlength="17" style="width: 284px; margin-right: 10px;"></el-input>
<el-button class="vin-btn" type="text" @click="handleVinConfirm">确认</el-button>
<el-button class="vin-btn" type="text" style="margin-left: 8px;" @click="handleVinCancel">取消</el-button>
</div>
</template>
</glsx-combi-form>
</div>
</GLDialog>
</template>
<script>
import glsxCombiForm from '@/components/glsx-combi-form'
export default {
name: 'secondDialog',
props: {
secondVisible: {
type: Boolean,
default: false
},
formRules: {
type: Object,
default: () => { }
},
editForm: {
type: Object,
default: () => { }
}
},
components: {
glsxCombiForm
},
data() {
return {
secondInfo: {
tips: '请核对车架号是否正确,如信息有误后期将无法申请补偿服务!',
editFormDataSec: [
{
label: '车架号',
name: 'vin',
addHtml: 'vin'
}
],
},
isEditVin: false,
editFormSec: {
vin: ''
},
tempVin: ''
}
},
mounted() {
this.editFormSec.vin = this.$common.utils.deepClone(this.editForm?.vehicle.vin)
this.tempVin = this.$common.utils.deepClone(this.editForm?.vehicle.vin)
},
methods: {
resetStatus() {
this.isEditVin = false
},
handleChangeVin() {
this.isEditVin = !this.isEditVin
this.$refs?.editFormRefSec?.$refs?.editChildRef?.clearValidate();
},
// 取消后,vin改回原来的值
handleVinCancel() {
this.editFormSec.vin = this.$common.utils.deepClone(this.tempVin)
this.handleChangeVin()
},
handleVinConfirm() {
this.$refs.editFormRefSec.$refs.editChildRef.validate(valid => {
if (valid) {
this.handleChangeVin()
this.tempVin = this.$common.utils.deepClone(this.editFormSec.vin)
}
})
},
handleCancel() {
this.resetStatus()
this.$emit('handleSecondClose')
},
handleOk() {
this.resetStatus()
this.$emit('handleSecondOk', this.editFormSec.vin)
}
}
}
</script>
<style lang="scss" scoped>
.second-dialog .tips {
margin-bottom: 32px;
padding: 0 16px;
height: 40px;
line-height: 40px;
background: #ffefda;
font-size: 14px;
color: #000000a6;
display: flex;
align-items: center;
}
.second-dialog .icon-info {
width: 16px;
height: 16px;
margin-right: 8px;
}
.second-dialog .icon-edit {
width: 16px;
height: 16px;
margin-left: 10px;
cursor: pointer;
}
.second-dialog .vin-detail {
display: flex;
align-items: center;
}
.second-dialog .vin-edit {
display: flex;
}
.second-dialog .vin-edit .vin-btn {
padding: 0;
}
</style>