Commit 670c4d03 by 赵永成

spec

parent e36da6cc
...@@ -59,4 +59,18 @@ export function getSpu(id) { ...@@ -59,4 +59,18 @@ export function getSpu(id) {
url: "/system/goods/" + id, url: "/system/goods/" + id,
method: "get", method: "get",
}); });
}
// 删除指定sku
export function del_sku_bySkuId(id) {
return request({
url: '/system/goods/sku/delete/'+id,
method: 'get'
})
}
// 恢复指定sku
export function rec_sku_bySkuId(id) {
return request({
url: '/system/goods/sku/recover/'+id,
method: 'get'
})
} }
\ No newline at end of file
...@@ -25,14 +25,9 @@ ...@@ -25,14 +25,9 @@
</el-table-column> </el-table-column>
<el-table-column label="操作" > <el-table-column label="操作" >
<template slot-scope="scope"> <template slot-scope="scope">
<el-button @click="specal_opt(scope.$index,scope.row,'view_step')" type="text" size="small"> 查看步骤 </el-button> <el-button v-if="spec_ShowBtn('set_sku',scope.row)" @click="specal_set(scope.$index,scope.row,'view_step')" type="text" size="small"> 配置制作步骤 </el-button>
<el-button @click.native.prevent="specal_opt(scope.$index,scope.row,'save')" type="text" size="small"> 保存 </el-button> <el-button v-if="spec_ShowBtn('del_sku',scope.row)" @click.native.prevent="sku_del(scope.row)" type="text" size="small"> 删除当前sku </el-button>
<el-button @click.native.prevent="specal_opt(scope.$index,scope.row,'del')" type="text" size="small"> 删除 </el-button> <el-button v-if="spec_ShowBtn('rec_sku',scope.row)" @click.native.prevent="sku_rec(scope.row)" type="text" size="small"> 恢复当前sku </el-button>
<el-button @click.native.prevent="specal_opt(scope.$index,scope.row,'restore')" type="text" size="small"> 恢复 </el-button>
<el-button @click="specal_set(scope.$index,scope.row,'view_step')" type="text" size="small"> 配置制作步骤 </el-button>
<el-button @click.native.prevent="sku_del(scope.$index,scope.row,'save')" type="text" size="small"> 删除当前sku </el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -44,7 +39,7 @@ ...@@ -44,7 +39,7 @@
</div> </div>
</template> </template>
<script> <script>
import { list_machine_model,list_step,add_spec_step,list_data_spec_step,del_spec_step,list_sku_byGoodsId } from "@/api/system/specification.js"; import { list_machine_model,list_step,add_spec_step,list_data_spec_step,del_spec_step,list_sku_byGoodsId,del_sku_bySkuId,rec_sku_bySkuId } from "@/api/system/specification.js";
import { stringify } from "querystring"; import { stringify } from "querystring";
export default { export default {
props: { props: {
...@@ -100,7 +95,11 @@ export default { ...@@ -100,7 +95,11 @@ export default {
console.log("getSkuByGoodsId response 123",res); console.log("getSkuByGoodsId response 123",res);
let t_skuList = []; let t_skuList = [];
for(let i=0;i<res.data.length;i++){ for(let i=0;i<res.data.length;i++){
let sku = res.data[i]; let sku = res.data[i];
//现在的sku状态字段为isDeleted 有两个值:0-未删除 1-已删除,2-手动删除
//如果状态是(1-已删除)的这里暂不显示
if(sku.isDeleted==1) continue;
let skuObj_ary = []; let skuObj_ary = [];
let ruleList = JSON.parse(sku.ruleList); let ruleList = JSON.parse(sku.ruleList);
for(let j=0;j<ruleList.length;j++){ for(let j=0;j<ruleList.length;j++){
...@@ -114,6 +113,7 @@ export default { ...@@ -114,6 +113,7 @@ export default {
} }
let skuObj = {}; let skuObj = {};
skuObj.sku_id=sku.id; skuObj.sku_id=sku.id;
skuObj.isDeleted = sku.isDeleted;
skuObj.skuAry = skuObj_ary; skuObj.skuAry = skuObj_ary;
t_skuList.push(skuObj); t_skuList.push(skuObj);
} }
...@@ -140,6 +140,7 @@ export default { ...@@ -140,6 +140,7 @@ export default {
"sku_spec_name":strName, "sku_spec_name":strName,
"model_name":mach_mode.model_name, "model_name":mach_mode.model_name,
"model_id":mach_mode.id, "model_id":mach_mode.id,
"sku_isDeleted":skuObj.isDeleted,
"tb_steps":[{ "tb_steps":[{
"step_lab":"步骤1", "step_lab":"步骤1",
"step_akv":[] "step_akv":[]
...@@ -218,8 +219,7 @@ export default { ...@@ -218,8 +219,7 @@ export default {
}, },
openSpecial(tag){ openSpecial(tag){
this.open = true; this.open = true;
}, },
/**获取商品对应的sku list 组装数据结构供页面显示,使用同步加载,避免数据回显不正常*/ /**获取商品对应的sku list 组装数据结构供页面显示,使用同步加载,避免数据回显不正常*/
getSkuByGoodsId(goodsId){ getSkuByGoodsId(goodsId){
return new Promise((resolve,reject)=>{ return new Promise((resolve,reject)=>{
...@@ -233,7 +233,6 @@ export default { ...@@ -233,7 +233,6 @@ export default {
}); });
}); });
}, },
/**可选制作步骤 list 组装数据结构供页面显示,使用同步加载,避免数据回显不正常*/ /**可选制作步骤 list 组装数据结构供页面显示,使用同步加载,避免数据回显不正常*/
getStepListByMidAndSkuId(p_queryParams){ getStepListByMidAndSkuId(p_queryParams){
return new Promise((resolve,reject)=>{ return new Promise((resolve,reject)=>{
...@@ -246,8 +245,6 @@ export default { ...@@ -246,8 +245,6 @@ export default {
}); });
}); });
}, },
/**获取已保存的步骤数据 */ /**获取已保存的步骤数据 */
get_step_data(){ get_step_data(){
this.queryParams={goods_id:this.goods.id}; this.queryParams={goods_id:this.goods.id};
...@@ -255,9 +252,7 @@ export default { ...@@ -255,9 +252,7 @@ export default {
this.initStepData(response); this.initStepData(response);
}).catch((response) => { }).catch((response) => {
console.log("get_step_data error",response); console.log("get_step_data error",response);
}); });
}, },
findSkuById(p_skuid,p_modelid){ findSkuById(p_skuid,p_modelid){
let tb_data = null; let tb_data = null;
...@@ -294,8 +289,7 @@ export default { ...@@ -294,8 +289,7 @@ export default {
step_akv.push(step_item.risc_code); step_akv.push(step_item.risc_code);
step_akv.push(step_item.result); step_akv.push(step_item.result);
tb_steps.push({'step_lab':step_num,'step_akv':step_akv}) tb_steps.push({'step_lab':step_num,'step_akv':step_akv})
} }
}else{ }else{
tb_steps = [{ tb_steps = [{
"step_lab":"步骤1", "step_lab":"步骤1",
...@@ -304,8 +298,7 @@ export default { ...@@ -304,8 +298,7 @@ export default {
} }
tb_data.tb_steps = tb_steps; tb_data.tb_steps = tb_steps;
console.log("initStepData tb_data.tb_steps 2",tb_data.tb_steps); console.log("initStepData tb_data.tb_steps 2",tb_data.tb_steps);
} }
}, },
/**列表操作 */ /**列表操作 */
specal_opt(pindex,prow,tag){ specal_opt(pindex,prow,tag){
...@@ -322,8 +315,7 @@ export default { ...@@ -322,8 +315,7 @@ export default {
if(tag == "del"){ if(tag == "del"){
this.spec_step_del(prow); this.spec_step_del(prow);
} }
}, },
specal_tb_row_click(r,c,e){ specal_tb_row_click(r,c,e){
// this.testPromic(1,2823).then((response) => { // this.testPromic(1,2823).then((response) => {
...@@ -391,7 +383,6 @@ export default { ...@@ -391,7 +383,6 @@ export default {
}).catch((response) => { }).catch((response) => {
console.log("error del_spec_step",response); console.log("error del_spec_step",response);
}); });
}, },
fillStepById(step_obj,t_step,prow){ fillStepById(step_obj,t_step,prow){
...@@ -445,11 +436,77 @@ export default { ...@@ -445,11 +436,77 @@ export default {
specal_set(){ specal_set(){
}, },
sku_del(){ /**删除sku*/
sku_del(skuRow){
console.log("sku_del skuRow",skuRow);
this.$modal.confirm('是否确认删除当前SKU?商品上架后对应SKU将不可用').then(function () {
return del_sku_bySkuId(skuRow.sku_id);
}).then(() => {
this.showSpecial(true,this.goods)
this.$modal.msgSuccess("删除成功");
}).catch(() => { });
// del_sku_bySkuId(skuRow.sku_id).then((response) => {
// console.log("sku_del",response);
// this.showSpecial(true,this.goods)
// }).catch((response) => {
// console.log("del_sku_bySkuId error",response);
// reject(response);
// });
},
/**恢复sku*/
sku_rec(skuRow){
console.log("sku_del skuRow",skuRow);
this.$modal.confirm('是否确认恢复当前SKU?').then(function () {
return rec_sku_bySkuId(skuRow.sku_id);
}).then(() => {
this.showSpecial(true,this.goods)
this.$modal.msgSuccess("恢复成功");
}).catch(() => { });
// rec_sku_bySkuId(skuRow.sku_id).then((response) => {
// console.log("sku_rec",response);
// this.showSpecial(true,this.goods)
// }).catch((response) => {
// console.log("sku_rec error",response);
// reject(response);
// });
},
spec_ShowBtn(btnTag,skuRow){
if(btnTag == 'del_sku'){
//只有下架的商品 sku才能删除
if(this.goods.state == 4 ){
//如果sku状态是正常的显示删除按钮
if(skuRow.sku_isDeleted==0){
return true;
}
}
return false;
}
else if(btnTag == 'rec_sku'){
//只有下架的商品 sku才能恢复
if(this.goods.state == 4 ){
//如果sku状态是手动删除的显示恢复按钮
if(skuRow.sku_isDeleted==2){
return true;
}
}
return false;
}
else if(btnTag == 'set_sku'){
//如果sku状态是手动删除的显示恢复按钮
// if(skuRow.sku_isDeleted==0){
// return true;
// }
// return false;
return true;
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment