init: import production code mss.nahaichuan.com (exclude Runtime/Uploads/backups/logs)
这个提交包含在:
113
Public/Retail/js/goods-state.js
可执行文件
113
Public/Retail/js/goods-state.js
可执行文件
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* 药品状态管理类
|
||||
*/
|
||||
class GoodsStateManager {
|
||||
constructor(vueInstance) {
|
||||
this.vue = vueInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用状态切换方法
|
||||
*/
|
||||
async updateGoodsState(url, params, index, field, originalValue) {
|
||||
try {
|
||||
const res = await GoodsUtils.apiRequest(url, params);
|
||||
if (res.status == 1) {
|
||||
this.vue.$message.success(res.msg);
|
||||
} else {
|
||||
this.vue.$message.error(res.msg);
|
||||
// 失败时恢复原值
|
||||
this.vue.goodsList[index][field] = originalValue;
|
||||
}
|
||||
} catch (error) {
|
||||
this.vue.$message.error('操作失败');
|
||||
this.vue.goodsList[index][field] = originalValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改药品上下架状态
|
||||
*/
|
||||
changeStatus(index, status, id) {
|
||||
const originalStatus = status == 1 ? '0' : '1';
|
||||
this.updateGoodsState(
|
||||
"/index.php/Retail/Goods/changestatus",
|
||||
{ status, id },
|
||||
index,
|
||||
'status',
|
||||
originalStatus
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改商城出售状态
|
||||
*/
|
||||
changeOnline(index, status, id, goods_class_id) {
|
||||
const originalStatus = status == 1 ? '0' : '1';
|
||||
this.updateGoodsState(
|
||||
"/index.php/Retail/Goods/changeissellonline",
|
||||
{ online_state: status, id, goods_class_id },
|
||||
index,
|
||||
'online_state',
|
||||
originalStatus
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改店内出售状态
|
||||
*/
|
||||
changeRetailState(index, status, id, goods_class_id) {
|
||||
const originalStatus = status == 1 ? '0' : '1';
|
||||
this.updateGoodsState(
|
||||
"/index.php/Retail/Goods/changeRetailState",
|
||||
{ retail_state: status, id, goods_class_id },
|
||||
index,
|
||||
'retail_state',
|
||||
originalStatus
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改线上打折状态
|
||||
*/
|
||||
changeOnlineDis(index, status, id) {
|
||||
const originalStatus = status == 1 ? '0' : '1';
|
||||
this.updateGoodsState(
|
||||
"/index.php/Retail/Goods/changevip_online_state",
|
||||
{ vip_online_state: status, id },
|
||||
index,
|
||||
'vip_online_state',
|
||||
originalStatus
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改线下打折状态
|
||||
*/
|
||||
changeRetailDis(index, status, id) {
|
||||
const originalStatus = status == 1 ? '0' : '1';
|
||||
this.updateGoodsState(
|
||||
"/index.php/Retail/Goods/changevip_retail_state",
|
||||
{ vip_retail_state: status, id },
|
||||
index,
|
||||
'vip_retail_state',
|
||||
originalStatus
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改常用状态
|
||||
*/
|
||||
changeUsual(index, status, id) {
|
||||
const originalStatus = status == 1 ? '0' : '1';
|
||||
this.updateGoodsState(
|
||||
"/index.php/Retail/Goods/changeusualDemo",
|
||||
{ usual_state: status, id },
|
||||
index,
|
||||
'usual_state',
|
||||
originalStatus
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
window.GoodsStateManager = GoodsStateManager;
|
||||
在新工单中引用
屏蔽一个用户