|
|
@@ -181,11 +181,18 @@ export default {
|
|
|
const validatePhone = (rule, value, callback) => {
|
|
|
if (!value) {
|
|
|
callback(new Error('电话号码不能为空'));
|
|
|
- } else if (!/^1[3-9]\d{9}$/.test(value)) {
|
|
|
- callback(new Error('请输入有效的手机号码'));
|
|
|
- } else {
|
|
|
- callback();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const phone = String(value).trim();
|
|
|
+ if (!/^\d{11}$/.test(phone)) {
|
|
|
+ callback(new Error('电话号码必须为11位数字'));
|
|
|
+ return;
|
|
|
}
|
|
|
+ if (!/^1[3-9]\d{9}$/.test(phone)) {
|
|
|
+ callback(new Error('请输入有效的手机号码(1开头,第二位3-9)'));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ callback();
|
|
|
};
|
|
|
const validateAge = (rule, value, callback) => {
|
|
|
if (value === null || value === undefined || value === '') {
|
|
|
@@ -226,6 +233,7 @@ export default {
|
|
|
{ required: true, message: "电话不能为空", trigger: "blur" },
|
|
|
{ validator: validatePhone, trigger: "blur" }
|
|
|
],
|
|
|
+ address: [{ required: true, message: "地址不能为空", trigger: "blur" }],
|
|
|
filingTime: [{ required: true, message: "建档时间不能为空", trigger: "blur" }],
|
|
|
companyUserName: [{ required: true, message: "客服姓名不能为空", trigger: "blur" }],
|
|
|
doctorName: [{ required: true, message: "负责医生不能为空", trigger: "blur" }],
|
|
|
@@ -245,12 +253,23 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
parseTime,
|
|
|
+ // 原生方法生成当前时间字符串 yyyy-MM-dd HH:mm:ss
|
|
|
+ getCurrentDateTime() {
|
|
|
+ const now = new Date();
|
|
|
+ const year = now.getFullYear();
|
|
|
+ const month = String(now.getMonth() + 1).padStart(2, '0');
|
|
|
+ const day = String(now.getDate()).padStart(2, '0');
|
|
|
+ const hours = String(now.getHours()).padStart(2, '0');
|
|
|
+ const minutes = String(now.getMinutes()).padStart(2, '0');
|
|
|
+ const seconds = String(now.getSeconds()).padStart(2, '0');
|
|
|
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
|
+ },
|
|
|
getList() {
|
|
|
this.loading = true;
|
|
|
listCustomer(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
|
|
- const data = response; // 若依 request 解包后直接返回 data 对象
|
|
|
- this.customerList = data.rows; // 数据在 rows 中
|
|
|
- this.total = data.total; // 总记录数
|
|
|
+ const data = response;
|
|
|
+ this.customerList = data.rows;
|
|
|
+ this.total = data.total;
|
|
|
this.loading = false;
|
|
|
}).catch(() => {
|
|
|
this.loading = false;
|
|
|
@@ -299,7 +318,8 @@ export default {
|
|
|
},
|
|
|
handleAdd() {
|
|
|
this.reset();
|
|
|
- //获取回填信息(当前登录销售和绑定的医生)
|
|
|
+ // 设置默认建档时间为当前系统时间(字符串格式)
|
|
|
+ this.form.filingTime = this.getCurrentDateTime();
|
|
|
getCompanyUserAndDoctor().then(response => {
|
|
|
const data = response.data;
|
|
|
if (!data || !data.doctorId) {
|
|
|
@@ -334,24 +354,30 @@ export default {
|
|
|
if (!valid) return;
|
|
|
if (this.form.id != null) {
|
|
|
await updateCustomer(this.form);
|
|
|
- this.$modal.msgSuccess("修改成功");
|
|
|
+ this.$message.success("修改成功");
|
|
|
} else {
|
|
|
await addCustomer(this.form);
|
|
|
- this.$modal.msgSuccess("新增成功");
|
|
|
+ this.$message.success("新增成功");
|
|
|
}
|
|
|
this.open = false;
|
|
|
+ await this.$nextTick();
|
|
|
this.getList();
|
|
|
} catch (e) {
|
|
|
console.warn("提交失败", e);
|
|
|
+ if (e.message) this.$message.error(e.message);
|
|
|
}
|
|
|
},
|
|
|
handleDelete(row) {
|
|
|
const ids = row.id || this.ids.join(",");
|
|
|
- this.$modal.confirm('是否确认删除该客户信息?').then(function() {
|
|
|
+ this.$confirm('是否确认删除该客户信息?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
return delCustomer(ids);
|
|
|
}).then(() => {
|
|
|
this.getList();
|
|
|
- this.$modal.msgSuccess("删除成功");
|
|
|
+ this.$message.success("删除成功");
|
|
|
}).catch(() => {});
|
|
|
},
|
|
|
handleExport() {
|