|
|
@@ -1162,15 +1162,15 @@ export default {
|
|
|
{ required: true, message: "3类器械经营许可证有效期不能为空", trigger: "blur" }
|
|
|
],
|
|
|
foodLicense: [
|
|
|
- {
|
|
|
+ {
|
|
|
validator: (rule, value, callback) => {
|
|
|
if (!value || (Array.isArray(value) && value.length === 0)) {
|
|
|
callback(new Error('请至少上传一张食品经营许可证图片'));
|
|
|
} else {
|
|
|
callback();
|
|
|
}
|
|
|
- },
|
|
|
- trigger: 'change'
|
|
|
+ },
|
|
|
+ trigger: 'change'
|
|
|
}
|
|
|
],
|
|
|
foodCode: [
|
|
|
@@ -1661,7 +1661,7 @@ export default {
|
|
|
}
|
|
|
this.reportFileList = this.urlToFileList(this.form.reportUrl);
|
|
|
this.fileList = this.urlToFileList(this.form.filingUrl);
|
|
|
-
|
|
|
+
|
|
|
// 处理食品经营许可证图片数据,支持逗号分隔的字符串
|
|
|
if (this.form.foodLicense) {
|
|
|
if (typeof this.form.foodLicense === 'string') {
|
|
|
@@ -1677,10 +1677,84 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ // 验证所有执照有效性验证方法
|
|
|
+ validateLicenses() {
|
|
|
+ // 验证营业执照
|
|
|
+ if (!this.validateSingleLicense(!this.switchValue, this.form.businessLicenseExpire, "营业执照")) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // 验证2类医疗器械备案
|
|
|
+ if (!this.validateSingleLicense(!this.medicalDevice2ExpiryValue, this.form.medicalDevice2Expiry, "2类医疗器械备案")) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // 验证食品经营许可证/备案凭证
|
|
|
+ if (!this.validateSingleLicense(!this.foodLicenseExpiryValue, this.form.foodLicenseExpiry, "食品经营许可证/备案凭证")) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // 验证药品经营许可证(无长期有效开关,直接检查有效期)
|
|
|
+ if (!this.validateLicenseWithoutSwitch(this.form.drugLicenseExpiry, "药品经营许可证")) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // 验证3类器械经营许可证(无长期有效开关,直接检查有效期)
|
|
|
+ if (!this.validateLicenseWithoutSwitch(this.form.medicalDevice3Expiry, "3类器械经营许可证")) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+ // 验证单个执照的方法(适用于有长期有效开关的证件)
|
|
|
+ validateSingleLicense(isExpiryRequired, expiryDateRange, licenseName) {
|
|
|
+ // 如果不是长期有效,检查是否过期
|
|
|
+ if (isExpiryRequired) {
|
|
|
+ // 检查是否设置了有效期
|
|
|
+ if (!expiryDateRange || expiryDateRange.length !== 2) {
|
|
|
+ this.$message.warning(`请设置${licenseName}的有效期!`);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // 获取结束日期
|
|
|
+ const endDate = new Date(expiryDateRange[1]);
|
|
|
+ // 获取当前日期
|
|
|
+ const currentDate = new Date();
|
|
|
+ // 比较日期(忽略时间部分)
|
|
|
+ endDate.setHours(0, 0, 0, 0);
|
|
|
+ currentDate.setHours(0, 0, 0, 0);
|
|
|
+ // 如果结束日期早于当前日期,说明已过期
|
|
|
+ if (endDate < currentDate) {
|
|
|
+ this.$message.warning(`${licenseName}已过期,请更新${licenseName}有效期时间或设置为长期有效!`);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+ // 验证无开关控制的证件有效期
|
|
|
+ validateLicenseWithoutSwitch(expiryDateRange, licenseName) {
|
|
|
+ // 检查是否设置了有效期
|
|
|
+ if (!expiryDateRange || expiryDateRange.length !== 2) {
|
|
|
+ this.$message.warning(`请设置${licenseName}的有效期!`);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // 获取结束日期
|
|
|
+ const endDate = new Date(expiryDateRange[1]);
|
|
|
+ // 获取当前日期
|
|
|
+ const currentDate = new Date();
|
|
|
+ // 比较日期(忽略时间部分)
|
|
|
+ endDate.setHours(0, 0, 0, 0);
|
|
|
+ currentDate.setHours(0, 0, 0, 0);
|
|
|
+ // 如果结束日期早于当前日期,说明已过期
|
|
|
+ if (endDate < currentDate) {
|
|
|
+ this.$message.warning(`${licenseName}已过期,请更新${licenseName}有效期时间!`);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+
|
|
|
/** 提交按钮 */
|
|
|
submitForm() {
|
|
|
this.$refs["form"].validate(valid => {
|
|
|
if (valid) {
|
|
|
+ // 添加所有执照有效性检查
|
|
|
+ if (!this.validateLicenses()) {
|
|
|
+ return; // 验证失败,停止提交
|
|
|
+ }
|
|
|
// 处理表单数据
|
|
|
const formData = Object.assign({}, this.form);
|
|
|
// 处理城市ID
|
|
|
@@ -1691,7 +1765,6 @@ export default {
|
|
|
if (formData.shippingType) {
|
|
|
formData.shippingType = formData.shippingType.toString();
|
|
|
}
|
|
|
-
|
|
|
// 处理日期范围字段
|
|
|
const dateRangeFields = [
|
|
|
'drugLicenseExpiry',
|
|
|
@@ -1751,7 +1824,7 @@ export default {
|
|
|
formData.isEffectivePermanent1 = this.medicalLicenseExpiryValue1 ? 1 : 0;
|
|
|
formData.isEffectivePermanent2 = this.medicalLicenseExpiryValue2 ? 1 : 0;
|
|
|
formData.isEffectivePermanent3 = this.medicalLicenseExpiryValue3 ? 1 : 0;
|
|
|
-
|
|
|
+
|
|
|
// 处理食品经营许可证图片数据,转换为逗号分隔的字符串
|
|
|
if (Array.isArray(formData.foodLicense)) {
|
|
|
formData.foodLicense = formData.foodLicense.join(',');
|