|
|
@@ -1273,15 +1273,25 @@ export default {
|
|
|
businessArr:function(val) {
|
|
|
this.form.business = val.join(',');
|
|
|
},
|
|
|
- //药品成分
|
|
|
+ // 商品名称监听
|
|
|
+ 'form.productName': {
|
|
|
+ handler(newVal) {
|
|
|
+ if (newVal) {
|
|
|
+ this.checkForbiddenKeywords('productName', newVal);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ immediate: false
|
|
|
+ },
|
|
|
+ // 成分监听
|
|
|
'form.ingredient': {
|
|
|
handler(newVal) {
|
|
|
if (newVal) {
|
|
|
- this.checkForbiddenKeywords(newVal);
|
|
|
+ this.checkForbiddenKeywords('ingredient', newVal);
|
|
|
}
|
|
|
},
|
|
|
immediate: false
|
|
|
},
|
|
|
+ // 商品分类监听
|
|
|
'form.productType': {
|
|
|
handler(newVal) {
|
|
|
// 检查是否为II类或III类器械分类
|
|
|
@@ -1385,11 +1395,12 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ isIngredientValid: true, // 成分是否有效
|
|
|
+ isProductNameValid: true, // 商品名称是否有效
|
|
|
// 溯源码弹窗相关
|
|
|
titleVisible:'溯源管理:',
|
|
|
verifyDialogVisible: false, // 溯源码弹窗显示状态
|
|
|
currentProductId: null, // 当前选中的商品ID
|
|
|
- isIngredientValid: true, // 成分是否有效
|
|
|
isLicenseValid: true, // 许可证是否有效
|
|
|
authVisible:false,
|
|
|
auditLogs:[],
|
|
|
@@ -1703,22 +1714,50 @@ export default {
|
|
|
},
|
|
|
};
|
|
|
},
|
|
|
-
|
|
|
methods: {
|
|
|
- // 检查违禁关键词
|
|
|
- checkForbiddenKeywords(ingredient) {
|
|
|
- selectForbiddenKeywords(ingredient, this.form.productName).then(response => {
|
|
|
+ // 检查违禁关键词(整合商品名称和成分检查)
|
|
|
+ checkForbiddenKeywords(field, value) {
|
|
|
+ // 根据检查的字段类型设置不同的参数和状态变量
|
|
|
+ const isProductNameCheck = field === 'productName';
|
|
|
+ const isIngredientCheck = field === 'ingredient';
|
|
|
+ if (!isProductNameCheck && !isIngredientCheck) {
|
|
|
+ return; // 只处理商品名称和成分字段
|
|
|
+ }
|
|
|
+ // 构造参数 - API只需要keywords参数
|
|
|
+ selectForbiddenKeywords(value).then(response => {
|
|
|
if (response.data === false) {
|
|
|
- this.$message.error(response.msg || '包含违禁词');
|
|
|
- this.isIngredientValid = false;
|
|
|
+ const errorMsg = isProductNameCheck
|
|
|
+ ? (response.msg || '商品名称包含违禁词')
|
|
|
+ : (response.msg || '成分包含违禁词');
|
|
|
+ this.$message.error(errorMsg);
|
|
|
+ // 更新对应的状态变量
|
|
|
+ if (isProductNameCheck) {
|
|
|
+ this.isProductNameValid = false;
|
|
|
+ } else {
|
|
|
+ this.isIngredientValid = false;
|
|
|
+ }
|
|
|
} else {
|
|
|
- this.isIngredientValid = true;
|
|
|
+ // 检查通过,更新状态变量
|
|
|
+ if (isProductNameCheck) {
|
|
|
+ this.isProductNameValid = true;
|
|
|
+ } else {
|
|
|
+ this.isIngredientValid = true;
|
|
|
+ }
|
|
|
}
|
|
|
}).catch(error => {
|
|
|
- this.$message.error('违禁词检查异常');
|
|
|
- this.isIngredientValid = false;
|
|
|
+ const errorMsg = isProductNameCheck
|
|
|
+ ? '商品名称违禁词检查异常'
|
|
|
+ : '成分违禁词检查异常';
|
|
|
+ this.$message.error(errorMsg);
|
|
|
+ // 出现异常时,标记为无效
|
|
|
+ if (isProductNameCheck) {
|
|
|
+ this.isProductNameValid = false;
|
|
|
+ } else {
|
|
|
+ this.isIngredientValid = false;
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
+
|
|
|
// 检查店铺药品许可证
|
|
|
checkStoreDrugLicense(cateId) {
|
|
|
checkStoreDrugLicense({ cateId: cateId }).then(response => {
|
|
|
@@ -2338,6 +2377,11 @@ export default {
|
|
|
},
|
|
|
/** 提交按钮 */
|
|
|
submitForm() {
|
|
|
+ // 检查商品名称是否有效
|
|
|
+ if (!this.isProductNameValid) {
|
|
|
+ this.$message.warning('商品名称包含违禁词,请修改后重新提交');
|
|
|
+ return;
|
|
|
+ }
|
|
|
// 检查成分是否有效
|
|
|
if (!this.isIngredientValid) {
|
|
|
this.$message.warning('成分包含违禁词,请修改后重新提交');
|