check.vue
3.41 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
<!-- 核价与意见 -->
<template>
<div class="edit-assess">
<div class="title">
核价与意见
</div>
<div class="edit-form-wrapper">
<glsx-combi-form ref="editFormRef"
class="edit-form-container"
:form-data="checkFormData"
:form-obj="assessForm"
:form-ref="editChildRef"
:form-rules="assessRules"
:is-block="true"
label-width="150px">
</glsx-combi-form>
</div>
</div>
</template>
<script>
export default {
props: {
detailInfo: {
type: Object,
default() {
return {};
},
},
},
data() {
return {
editChildRef: "editChildRef",
assessForm: {
checkPrice: "",
checkOpinion: "",
},
checkFormData: [
{
label: "核价",
name: "checkPrice",
type: "input",
isClear: true,
maxlength: 7,
width: "570px",
placeholder: "请输入",
append: "元",
},
{
label: "核价意见",
name: "checkOpinion",
type: "input",
maxlength: 200,
inputType: "textarea",
// showLimit: true,
rows: 4,
width: "570px",
placeholder: "请输入",
},
],
assessRules: {
checkPrice: [
{
required: true,
message: "请输入",
trigger: "blur",
},
{
validator: (rule, value, callback) => {
if (!value) {
callback();
return;
}
// 校验是否为整数
if (!/^\d+$/.test(value)) {
callback(new Error("只能输入整数"));
} else {
callback();
}
},
trigger: "blur",
},
{
validator: (rule, value, callback) => {
if (!value) {
callback();
return;
}
const numValue = Number.parseInt(value, 10);
if (isNaN(numValue)) {
callback(new Error("请输入有效整数"));
} else if (numValue <= 0) {
callback(new Error("评估价必须大于0"));
} else if (numValue > 9999999) {
callback(new Error("评估价必须小于9999999"));
} else {
callback();
}
},
trigger: "blur",
},
],
checkOpinion: [
{
required: true,
message: "请输入",
trigger: "blur",
},
],
},
};
},
watch: {
detailInfo(val) {
console.log(val, "detailInfo");
this.assessForm = {
checkPrice: val.checkPrice,
checkOpinion: val.checkOpinion,
};
},
},
methods: {
async confirm() {
try {
const formRef = this.$refs.editFormRef;
if (!formRef || !formRef.$refs || !formRef.$refs[this.editChildRef]) {
console.error("Form reference not found");
return false;
}
const isValid = await formRef.$refs[this.editChildRef].validate();
console.log(isValid, "isValid");
return isValid;
} catch (error) {
console.error("Validation failed:", error);
return false;
}
},
},
};
</script>
<style lang="scss" scoped>
.edit-assess {
background: #fff;
margin: 20px;
.title {
color: #333333;
font-size: 16px;
font-weight: bold;
padding: 13.5px 20px;
border-bottom: 1px solid #e5e5e5;
line-height: 23px;
box-sizing: border-box;
}
.edit-form-wrapper {
padding: 20px;
::v-deep .el-input__suffix-inner {
color: #333333;
font-size: 14px;
}
}
}
</style>