|
|
@@ -8,18 +8,15 @@
|
|
8
|
8
|
</el-form-item>
|
|
9
|
9
|
</el-col>
|
|
10
|
10
|
<el-col :span="12">
|
|
11
|
|
- <el-form-item label="电话" prop="telphone">
|
|
|
11
|
+ <el-form-item label="客户电话" prop="telphone">
|
|
12
|
12
|
<el-input v-model="ruleForm.telphone" placeholder="请输入客户电话" />
|
|
13
|
13
|
</el-form-item>
|
|
14
|
14
|
</el-col>
|
|
15
|
15
|
</el-row>
|
|
16
|
16
|
<el-row>
|
|
17
|
17
|
<el-col :span="12">
|
|
18
|
|
- <el-form-item label="性别" prop="sex">
|
|
19
|
|
- <el-radio-group v-model="ruleForm.sex">
|
|
20
|
|
- <el-radio label="男">男</el-radio>
|
|
21
|
|
- <el-radio label="女">女</el-radio>
|
|
22
|
|
- </el-radio-group>
|
|
|
18
|
+ <el-form-item label="身份证号" prop="idcard">
|
|
|
19
|
+ <el-input v-model="ruleForm.idcard" placeholder="请输入身份证号" />
|
|
23
|
20
|
</el-form-item>
|
|
24
|
21
|
</el-col>
|
|
25
|
22
|
<el-col :span="12">
|
|
|
@@ -30,16 +27,14 @@
|
|
30
|
27
|
</el-row>
|
|
31
|
28
|
<el-row>
|
|
32
|
29
|
<el-col :span="12">
|
|
33
|
|
- <el-form-item label="身份证号" prop="idcard">
|
|
34
|
|
- <el-input v-model="ruleForm.idcard" placeholder="请输入身份证号" />
|
|
|
30
|
+ <el-form-item label="客户性别" prop="sex">
|
|
|
31
|
+ <el-radio-group v-model="ruleForm.sex">
|
|
|
32
|
+ <el-radio label="男">男</el-radio>
|
|
|
33
|
+ <el-radio label="女">女</el-radio>
|
|
|
34
|
+ </el-radio-group>
|
|
35
|
35
|
</el-form-item>
|
|
36
|
36
|
</el-col>
|
|
37
|
37
|
</el-row>
|
|
38
|
|
- <!-- <el-col :span="18">
|
|
39
|
|
- <el-form-item label="历史信息" prop="historyInfo">
|
|
40
|
|
- <el-input v-model="ruleForm.historyInfo" type="textarea" placeholder="请输入历史信息" />
|
|
41
|
|
- </el-form-item>
|
|
42
|
|
- </el-col> -->
|
|
43
|
38
|
<el-row>
|
|
44
|
39
|
<el-col :span="18">
|
|
45
|
40
|
<el-form-item label="客户住址" prop="adddress">
|
|
|
@@ -62,79 +57,107 @@
|
|
62
|
57
|
</template>
|
|
63
|
58
|
|
|
64
|
59
|
<script>
|
|
65
|
|
-import { addOrEditCustomerList, getCusDetail } from '@/api/customerManagement/customerList'
|
|
66
|
|
-import { validateTel } from '@/utils/validate'
|
|
67
|
|
-export default {
|
|
68
|
|
- name: 'AddOrEdit',
|
|
69
|
|
- props: {
|
|
70
|
|
- rowid: {
|
|
71
|
|
- type: Number,
|
|
72
|
|
- default: 0
|
|
|
60
|
+ import {
|
|
|
61
|
+ addOrEditCustomerList,
|
|
|
62
|
+ getCusDetail
|
|
|
63
|
+ } from '@/api/customerManagement/customerList'
|
|
|
64
|
+ import {
|
|
|
65
|
+ validateTel
|
|
|
66
|
+ } from '@/utils/validate'
|
|
|
67
|
+ export default {
|
|
|
68
|
+ name: 'AddOrEdit',
|
|
|
69
|
+ props: {
|
|
|
70
|
+ rowid: {
|
|
|
71
|
+ type: Number,
|
|
|
72
|
+ default: 0
|
|
|
73
|
+ },
|
|
|
74
|
+ layerid: {
|
|
|
75
|
+ type: String,
|
|
|
76
|
+ default: ''
|
|
|
77
|
+ }
|
|
73
|
78
|
},
|
|
74
|
|
- layerid: {
|
|
75
|
|
- type: String,
|
|
76
|
|
- default: ''
|
|
77
|
|
- }
|
|
78
|
|
- },
|
|
79
|
|
- data() {
|
|
80
|
|
- var phoneNumbersinput = (rule, value, callback) => {
|
|
81
|
|
- if (value !== '') { // 不为空的时候进行验证
|
|
82
|
|
- validateTel(value) ? callback() : callback(new Error('联系电话格式错误'))
|
|
83
|
|
- } else { // 为空的时候就直接放过去(这里一定要写,不然既不报错也不会往下走【应该和router的next()相同】)
|
|
84
|
|
- callback()
|
|
|
79
|
+ data() {
|
|
|
80
|
+ var phoneNumbersinput = (rule, value, callback) => {
|
|
|
81
|
+ if (value !== '') { // 不为空的时候进行验证
|
|
|
82
|
+ validateTel(value) ? callback() : callback(new Error('联系电话格式错误'))
|
|
|
83
|
+ } else { // 为空的时候就直接放过去(这里一定要写,不然既不报错也不会往下走【应该和router的next()相同】)
|
|
|
84
|
+ callback()
|
|
|
85
|
+ }
|
|
85
|
86
|
}
|
|
86
|
|
- }
|
|
87
|
|
- return {
|
|
88
|
|
- ruleForm: {
|
|
89
|
|
- id: '', // 客户id
|
|
90
|
|
- name: '', // 客户名称
|
|
91
|
|
- telphone: '', // 客户电话
|
|
92
|
|
- historyInfo: '', // 历史信息
|
|
93
|
|
- sex: '', // 性别
|
|
94
|
|
- remark: '', // 备注
|
|
95
|
|
- linkman:'',
|
|
96
|
|
- idcard: '', // 身份证号
|
|
97
|
|
- adddress: '' // 客户住址
|
|
98
|
|
- },
|
|
99
|
|
- rules: {
|
|
100
|
|
- name: [
|
|
101
|
|
- {
|
|
|
87
|
+ return {
|
|
|
88
|
+ ruleForm: {
|
|
|
89
|
+ id: '', // 客户id
|
|
|
90
|
+ name: '', // 客户名称
|
|
|
91
|
+ telphone: '', // 客户电话
|
|
|
92
|
+ historyInfo: '', // 历史信息
|
|
|
93
|
+ sex: '', // 性别
|
|
|
94
|
+ remark: '', // 备注
|
|
|
95
|
+ linkman: '',
|
|
|
96
|
+ idcard: '', // 身份证号
|
|
|
97
|
+ adddress: '' // 客户住址
|
|
|
98
|
+ },
|
|
|
99
|
+ rules: {
|
|
|
100
|
+ name: [{
|
|
102
|
101
|
required: true,
|
|
103
|
102
|
trigger: 'blur',
|
|
104
|
103
|
message: '请输入客户名称!'
|
|
105
|
|
- }
|
|
106
|
|
- ]
|
|
107
|
|
- },
|
|
108
|
|
- loading: false
|
|
109
|
|
- }
|
|
110
|
|
- },
|
|
111
|
|
- created() {
|
|
112
|
|
- if (this.rowid) {
|
|
113
|
|
- this.ruleForm.id = this.rowid
|
|
114
|
|
- const data = {
|
|
115
|
|
- id: this.rowid
|
|
|
104
|
+ }]
|
|
|
105
|
+ },
|
|
|
106
|
+ loading: false
|
|
116
|
107
|
}
|
|
117
|
|
- // console.log(data, 'data')
|
|
118
|
|
- this.getDetail(data)
|
|
119
|
|
- }
|
|
120
|
|
- },
|
|
121
|
|
- methods: {
|
|
122
|
|
- submitForm() {
|
|
123
|
|
- this.$refs.ruleForm.validate((valid) => {
|
|
124
|
|
- if (valid) {
|
|
125
|
|
- this.loading = true
|
|
126
|
|
- const data = {
|
|
127
|
|
- id: this.rowid,
|
|
128
|
|
- name: this.ruleForm.name, // 客户名称 string
|
|
129
|
|
- telphone: this.ruleForm.telphone, // 客户电话 string
|
|
130
|
|
- sex: this.ruleForm.sex, // 客户性别 string
|
|
131
|
|
- linkman:this.ruleForm.linkman,
|
|
132
|
|
- idcard: this.ruleForm.idcard, // 身份证号 string
|
|
133
|
|
- adddress: this.ruleForm.adddress ,// 客户住址 string
|
|
134
|
|
- remark:this.ruleForm.remark
|
|
135
|
|
- }
|
|
136
|
|
- // 添加
|
|
137
|
|
- if (!this.rowid) {
|
|
|
108
|
+ },
|
|
|
109
|
+ created() {
|
|
|
110
|
+ if (this.rowid) {
|
|
|
111
|
+ this.ruleForm.id = this.rowid
|
|
|
112
|
+ const data = {
|
|
|
113
|
+ id: this.rowid
|
|
|
114
|
+ }
|
|
|
115
|
+ // console.log(data, 'data')
|
|
|
116
|
+ this.getDetail(data)
|
|
|
117
|
+ }
|
|
|
118
|
+ },
|
|
|
119
|
+ methods: {
|
|
|
120
|
+ submitForm() {
|
|
|
121
|
+ this.$refs.ruleForm.validate((valid) => {
|
|
|
122
|
+ if (valid) {
|
|
|
123
|
+ this.loading = true
|
|
|
124
|
+ const data = {
|
|
|
125
|
+ id: this.rowid,
|
|
|
126
|
+ name: this.ruleForm.name, // 客户名称 string
|
|
|
127
|
+ telphone: this.ruleForm.telphone, // 客户电话 string
|
|
|
128
|
+ sex: this.ruleForm.sex, // 客户性别 string
|
|
|
129
|
+ linkman: this.ruleForm.linkman,
|
|
|
130
|
+ idcard: this.ruleForm.idcard, // 身份证号 string
|
|
|
131
|
+ adddress: this.ruleForm.adddress, // 客户住址 string
|
|
|
132
|
+ remark: this.ruleForm.remark
|
|
|
133
|
+ }
|
|
|
134
|
+ // 添加
|
|
|
135
|
+ if (!this.rowid) {
|
|
|
136
|
+ addOrEditCustomerList(data)
|
|
|
137
|
+ .then((response) => {
|
|
|
138
|
+ this.loading = false
|
|
|
139
|
+ if (response.state.toLowerCase() === 'success') {
|
|
|
140
|
+ this.$parent.$layer.close(this.layerid)
|
|
|
141
|
+ this.$parent.getListTask() // 重新加载父级数据
|
|
|
142
|
+ this.$message({
|
|
|
143
|
+ message: '恭喜你,添加成功!',
|
|
|
144
|
+ type: 'success',
|
|
|
145
|
+ duration: 1000
|
|
|
146
|
+ })
|
|
|
147
|
+ } else {
|
|
|
148
|
+ this.$message({
|
|
|
149
|
+ message: '添加失败,该客户已存在!',
|
|
|
150
|
+ type: 'success',
|
|
|
151
|
+ duration: 1000
|
|
|
152
|
+ })
|
|
|
153
|
+ }
|
|
|
154
|
+ })
|
|
|
155
|
+ .catch((response) => {
|
|
|
156
|
+ this.loading = false
|
|
|
157
|
+ })
|
|
|
158
|
+ return
|
|
|
159
|
+ }
|
|
|
160
|
+ // 编辑
|
|
138
|
161
|
addOrEditCustomerList(data)
|
|
139
|
162
|
.then((response) => {
|
|
140
|
163
|
this.loading = false
|
|
|
@@ -142,74 +165,49 @@ export default {
|
|
142
|
165
|
this.$parent.$layer.close(this.layerid)
|
|
143
|
166
|
this.$parent.getListTask() // 重新加载父级数据
|
|
144
|
167
|
this.$message({
|
|
145
|
|
- message: '恭喜你,添加成功!',
|
|
146
|
|
- type: 'success',
|
|
147
|
|
- duration: 1000
|
|
148
|
|
- })
|
|
149
|
|
- } else {
|
|
150
|
|
- this.$message({
|
|
151
|
|
- message: '添加失败,该客户已存在!',
|
|
|
168
|
+ message: '恭喜你,客户信息编辑成功!',
|
|
152
|
169
|
type: 'success',
|
|
153
|
170
|
duration: 1000
|
|
154
|
171
|
})
|
|
155
|
172
|
}
|
|
156
|
173
|
})
|
|
157
|
|
- .catch((response) => {
|
|
|
174
|
+ .catch(() => {
|
|
158
|
175
|
this.loading = false
|
|
159
|
176
|
})
|
|
160
|
|
- return
|
|
|
177
|
+ } else {
|
|
|
178
|
+ // this.$message.error('请输入有效的必填项信息!')
|
|
|
179
|
+ return false
|
|
161
|
180
|
}
|
|
162
|
|
- // 编辑
|
|
163
|
|
- addOrEditCustomerList(data)
|
|
164
|
|
- .then((response) => {
|
|
165
|
|
- this.loading = false
|
|
166
|
|
- if (response.state.toLowerCase() === 'success') {
|
|
167
|
|
- this.$parent.$layer.close(this.layerid)
|
|
168
|
|
- this.$parent.getListTask() // 重新加载父级数据
|
|
169
|
|
- this.$message({
|
|
170
|
|
- message: '恭喜你,客户信息编辑成功!',
|
|
171
|
|
- type: 'success',
|
|
172
|
|
- duration: 1000
|
|
173
|
|
- })
|
|
174
|
|
- }
|
|
175
|
|
- })
|
|
176
|
|
- .catch(() => {
|
|
177
|
|
- this.loading = false
|
|
178
|
|
- })
|
|
179
|
|
- } else {
|
|
180
|
|
- // this.$message.error('请输入有效的必填项信息!')
|
|
181
|
|
- return false
|
|
182
|
|
- }
|
|
183
|
|
- })
|
|
184
|
|
- },
|
|
185
|
|
- // 获取详情
|
|
186
|
|
- getDetail(data) {
|
|
187
|
|
- getCusDetail(data).then(response => {
|
|
188
|
|
- if (response.state.toLowerCase() === 'success') {
|
|
189
|
|
- const res = response.data
|
|
190
|
|
- this.ruleForm.name = res.F_CustomerName // 客户名称
|
|
191
|
|
- this.ruleForm.telphone = res.F_Telephone // 客户电话
|
|
192
|
|
- this.ruleForm.sex = res.F_Sex // 性别
|
|
193
|
|
- this.ruleForm.idcard = res.F_IdCard // 身份证号
|
|
194
|
|
- this.ruleForm.adddress = res.F_Address // 客户住址
|
|
195
|
|
- this.ruleForm.remark = res.F_Remark
|
|
196
|
|
- this.ruleForm.linkman = res.F_AboutLinkMan
|
|
197
|
|
- }
|
|
198
|
|
- })
|
|
199
|
|
- }
|
|
|
181
|
+ })
|
|
|
182
|
+ },
|
|
|
183
|
+ // 获取详情
|
|
|
184
|
+ getDetail(data) {
|
|
|
185
|
+ getCusDetail(data).then(response => {
|
|
|
186
|
+ if (response.state.toLowerCase() === 'success') {
|
|
|
187
|
+ const res = response.data
|
|
|
188
|
+ this.ruleForm.name = res.F_CustomerName // 客户名称
|
|
|
189
|
+ this.ruleForm.telphone = res.F_Telephone // 客户电话
|
|
|
190
|
+ this.ruleForm.sex = res.F_Sex // 性别
|
|
|
191
|
+ this.ruleForm.idcard = res.F_IdCard // 身份证号
|
|
|
192
|
+ this.ruleForm.adddress = res.F_Address // 客户住址
|
|
|
193
|
+ this.ruleForm.remark = res.F_Remark
|
|
|
194
|
+ this.ruleForm.linkman = res.F_AboutLinkMan
|
|
|
195
|
+ }
|
|
|
196
|
+ })
|
|
|
197
|
+ }
|
|
200
|
198
|
|
|
|
199
|
+ }
|
|
201
|
200
|
}
|
|
202
|
|
-}
|
|
203
|
201
|
</script>
|
|
204
|
202
|
|
|
205
|
203
|
<style rel="stylesheet/scss" lang="scss">
|
|
206
|
|
- .order_form {
|
|
207
|
|
- .form_select {
|
|
208
|
|
- width: 100%;
|
|
209
|
|
- }
|
|
|
204
|
+ .order_form {
|
|
|
205
|
+ .form_select {
|
|
|
206
|
+ width: 100%;
|
|
|
207
|
+ }
|
|
210
|
208
|
|
|
211
|
|
- .form_date {
|
|
212
|
|
- width: 100%;
|
|
213
|
|
- }
|
|
214
|
|
- }
|
|
|
209
|
+ .form_date {
|
|
|
210
|
+ width: 100%;
|
|
|
211
|
+ }
|
|
|
212
|
+ }
|
|
215
|
213
|
</style>
|