Commit 10bb6221 by 赵永成

Specification

parent f57b897e
......@@ -26,3 +26,22 @@ export function add_spec_step(data) {
data: data
})
}
// 获取机型规格已保存的操作步骤列表
export function list_data_spec_step(query) {
return request({
url: '/v1/sku/model/risc/list',
method: 'get',
params: query
})
}
// 获取机型规格已保存的操作步骤列表
export function del_spec_step(query) {
return request({
url: '/v1/del/sku/model/risc',
method: 'get',
params: query
})
}
......@@ -32,11 +32,15 @@
</template>
</el-table-column>
</el-table>
<div slot="footer" class="dialog-footer">
<el-button @click="closeSpecial('cancel');">取 消</el-button>
<el-button type="primary" @click="closeSpecial('confim');">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { list_machine_model,list_step,add_spec_step } from "@/api/system/specification.js";
import { list_machine_model,list_step,add_spec_step,list_data_spec_step,del_spec_step } from "@/api/system/specification.js";
import { stringify } from "querystring";
export default {
props: {
......@@ -45,6 +49,7 @@ export default {
return{
open:false,
goods:{},
crowext:false,
special_tb_data:[],
steps:[{
......@@ -80,7 +85,11 @@ export default {
this.spec_mach_model_list();
},
methods: {
/**打卡规格详情配置,并初始化显示内容 */
/**提前将商品信息传入 */
setSpecGoods(pgoods){
this.goods = pgoods;
},
/**打开规格详情配置,并初始化显示内容 */
showSpecial(isShow,pgoods){
// 样例
// {
......@@ -97,7 +106,6 @@ export default {
//商品规格,和机器型号组合
let spec_str = pgoods.spec;
let spec = JSON.parse(spec_str);
console.log("spec.length",spec.length);
for(let i=0;i<spec.length;i++){
for(let j=0;j<this.mach_model_list.length;j++){
let spec_model = {
......@@ -114,31 +122,31 @@ export default {
}],
"step_opts":[]
}
let that =this;
//理论上,初始化时根据规格和型号获取可能的步骤会比较靠谱,省的以后步骤不一样用同一个数据源麻烦;
//this.spec_mach_step_list(spec_model.model_id,spec_model.spec_id);
//this.spec_mach_step_list(spec_model.model_id,2823);
let that =this;
//this.queryParams={model_id:spec_model.model_id,sku_id:spec_model.spec_id};
this.queryParams={model_id:spec_model.model_id,sku_id:2823};
this.queryParams={model_id:spec_model.model_id,sku_id:2823};//2823 测试数据,有数据。。。
///获取可能的步骤
list_step(this.queryParams).then((response) => {
//将步骤list转换为下拉框能识别的数组;
//样例
// {
// "step_key": 1,
// "risc_id": 1,
// "risc_code": 1,
// "risc_desc": "取杯",
// label:"取杯",
// value: 1,
// "turn": 1,
// "model_id": 1,
// "check": "radio",
// "options": {"冷杯":1,"热杯":2},
// "children":[ {label:"冷杯",value:1},{label:"热杯",value:2}]
// }
// "step_key": 1,
// "risc_id": 1,
// "risc_code": 1,
// "risc_desc": "取杯",
// label:"取杯",
// value: 1,
// "turn": 1,
// "model_id": 1,
// "check": "radio",
// "options": {"冷杯":1,"热杯":2},
// "children":[ {label:"冷杯",value:1},{label:"热杯",value:2}]
// }
let step_opts = [];
for(let obj in response.data){
......@@ -163,16 +171,64 @@ export default {
}
spec_model.step_opts = step_opts;
that.special_tb_data.push(spec_model);
console.log(that.special_tb_data);
//异步处理后放到外面去
//this.$nextTick();
that.open = isShow
//显示窗体
//that.open = isShow
//this.initStepData();
});
}
}
},
closeSpecial(tag){
//检查有需要保存的项未提交,则提示是否确定关闭
//TODO
this.open = false;
},
openSpecial(tag){
this.open = true;
},
/** 规格详情配置窗体初始化数据,如果已经有配置数据则获取*/
initAll(){
this.get_step_data();
},
/**获取已保存的步骤数据 */
get_step_data(){
console.log("get_step_data goods",this.goods);
this.queryParams={goods_id:this.goods.id};
//测试数据也不好使
// this.queryParams={goods_id:152};
list_data_spec_step(this.queryParams).then((response) => {
console.log("get_step_data response",response);
}).catch((response) => {
console.log("get_step_data error",response);
});
//数据返回后调用下面的方法
this.initStepData();
},
/**初始化已保存的步骤数据 */
initStepData(pata){
//将后台返回的已保存的步骤数据初始化到数据结构里
console.log("this.special_tb_data",this.special_tb_data);
//tb_steps,将数据填充到tb_steps,如果没值则填充默认值
let tb_steps = this.special_tb_data.tb_steps;
if(true){
tb_steps = [];
tb_steps.push({step_lab:"步骤1",step_akv:[1,1]})
tb_steps.push({step_lab:"步骤2",step_akv:[3,84]})
}else{
tb_steps = [{
"step_lab":"步骤1",
"step_akv":[]
}]
}
this.special_tb_data.tb_steps = tb_steps
this.open = true;
//
},
/**列表操作 */
specal_opt(pindex,prow,tag){
if(tag == "view_step"){
this.crowext = !this.crowext;
......@@ -184,6 +240,10 @@ export default {
console.log("special_tb_data",this.special_tb_data);
this.spec_step_save(prow);
}
if(tag == "del"){
this.spec_step_del(prow);
}
},
specal_tb_row_click(r,c,e){
......@@ -229,14 +289,56 @@ export default {
//填充对应的值
step_obj.sku_id = prow.spec_id;
step_obj.model_id = prow.model_id;
step_obj = this.findStepById(step_obj,t_step);
step_obj = this.fillStepById(step_obj,t_step,prow);
step_ary.push(step_obj);
}
//提交到后台
add_spec_step(step_ary);
add_spec_step(step_ary).then((response) => {
console.log("response ",response);
}).catch((response) => {
console.log("error ",response);
});
},
findStepById(step_obj){
/**删除步骤 */
spec_step_del(prow){
console.log("prow ",prow);
this.queryParams={sku_id:prow.spec_id,model_id:prow.model_id};
//提交到后台
del_spec_step(this.queryParams).then((response) => {
console.log("response del_spec_step",response);
}).catch((response) => {
console.log("error del_spec_step",response);
});
},
fillStepById(step_obj,t_step,prow){
//TODO
console.log("step_obj",step_obj);
console.log("t_step",t_step);
console.log("prow",prow);
let step_ak = t_step.step_akv[0];
let step_av = t_step.step_akv[1];
step_obj.result=step_av;
for(let i=0;i<prow.step_opts.length;i++){
let step_opt = prow.step_opts[i];
if(step_opt.value == step_ak){
step_obj.risc_id = step_opt.risc_id
step_obj.risc_code =step_opt.risc_code
step_obj.risc_desc=step_opt.risc_desc
step_obj.turn=step_opt.turn
// for(let j=0;j<step_opt.children.length;j++){
// if(step_opt.children[j].value == step_av){
// step_obj.result=step_av
// break;
// }
// }
break;
}
}
return step_obj;
},
/**获取可能的步骤 */
......
......@@ -249,9 +249,14 @@ export default {
},
setGoodsConfig(prow){
this.$refs.Specification.setSpecGoods(prow);
this.$nextTick(
this.$refs.Specification.showSpecial(true,prow)
);
this.$refs.Specification.initAll();
}
},
};
......
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