Commit f57b897e by 赵永成

specification

parent 2e4a2738
......@@ -17,3 +17,12 @@ export function list_step(query) {
params: query,
});
}
// 保存操作步骤
export function add_spec_step(data) {
return request({
url: '/v1/add/sku/model/risc',
method: 'post',
data: data
})
}
......@@ -9,7 +9,7 @@
<el-row v-for="(step,step_idx) in scope.row.tb_steps" :key=step_idx style="margin-top:5px;" >
<span>{{step.step_lab}}:</span>
<el-cascader :options="steps" v-model="step.step_akv" style="margin-left:10px"></el-cascader>
<el-cascader :options="scope.row.step_opts" v-model="step.step_akv" style="margin-left:10px"></el-cascader>
<el-button @click.prevent="spec_add_step(scope.row)" style="margin-left:10px">增加步骤</el-button>
......@@ -36,7 +36,7 @@
</div>
</template>
<script>
import { list_machine_model,list_step } from "@/api/system/specification.js";
import { list_machine_model,list_step,add_spec_step } from "@/api/system/specification.js";
import { stringify } from "querystring";
export default {
props: {
......@@ -111,18 +111,67 @@ export default {
"tb_steps":[{
"step_lab":"步骤1",
"step_akv":[]
}]
}],
"step_opts":[]
}
//理论上,初始化时根据规格和型号获取可能的步骤会比较靠谱,省的以后步骤不一样用同一个数据源麻烦;
//this.spec_mach_step_list(spec_model.model_id,spec_model.spec_id);
this.spec_mach_step_list(spec_model.model_id,2823);
//this.spec_mach_step_list(spec_model.model_id,2823);
this.special_tb_data.push(spec_model);
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};
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}]
// }
let step_opts = [];
for(let obj in response.data){
//console.log(obj,spec_model.step_list[obj]);
let step_obj = {};
step_obj = response.data[obj];
step_obj.step_key = obj;
step_obj.label = step_obj.risc_desc
step_obj.value = step_obj.risc_id
let children = [];
let childrenObj = {};
let options = JSON.parse(step_obj.options);
for(let opt in options){
childrenObj = {};
childrenObj.label = opt;
childrenObj.value = options[opt];
children.push(childrenObj);
}
step_obj.children = children
step_opts.push(step_obj);
}
spec_model.step_opts = step_opts;
that.special_tb_data.push(spec_model);
console.log(that.special_tb_data);
//异步处理后放到外面去
//this.$nextTick();
that.open = isShow
});
}
}
console.log(this.special_tb_data);
this.open = isShow;
},
specal_opt(pindex,prow,tag){
if(tag == "view_step"){
......@@ -133,11 +182,16 @@ export default {
}
if(tag == "save"){
console.log("special_tb_data",this.special_tb_data);
this.spec_step_save(prow);
}
},
specal_tb_row_click(r,c,e){
console.log(r,c,e);
// this.testPromic(1,2823).then((response) => {
// console.log("xxxx",response);
// console.log("spec_mach_step_list",3)
// });
// console.log("spec_mach_step_list",2)
},
spec_add_step(prow){
let step_i = prow.tb_steps.length+1
......@@ -152,19 +206,59 @@ export default {
if(this.mach_model_list.length==0){
this.queryParams={};
list_machine_model(this.queryParams).then((response) => {
console.log("response",response);
this.mach_model_list = response.data;
});
}
},
/**保存步骤 */
spec_step_save(prow){
// {
// "sku_id": 1,
// "risc_id": 1,
// "risc_code": 1,
// "risc_desc": "取杯",
// "turn": 1,
// "model_id": 1,
// "result": 1
// }
let step_ary = [];
for(let i=0;i<prow.tb_steps.length;i++){
let step_obj = {}
let t_step = prow.tb_steps[i];
//填充对应的值
step_obj.sku_id = prow.spec_id;
step_obj.model_id = prow.model_id;
step_obj = this.findStepById(step_obj,t_step);
step_ary.push(step_obj);
}
//提交到后台
add_spec_step(step_ary);
},
findStepById(step_obj){
//TODO
return step_obj;
},
/**获取可能的步骤 */
spec_mach_step_list(model_id,sku_id){
this.queryParams={model_id:model_id,sku_id:sku_id};
list_step(this.queryParams).then((response) => {
console.log("response",response);
console.log("spec_mach_step_list",1)
});
console.log("spec_mach_step_list",2)
},
testPromic(model_id,sku_id){
var param={model_id:model_id,sku_id:sku_id};
return new Promise(
function(resolve,reject){
list_step(param).then((response) => {
resolve(response);
});
}
).then(function(res){
return res;
}).catch(function(cat){
return cat
})
}
}
......
......@@ -248,8 +248,10 @@ export default {
})
},
setGoodsConfig(prow){
console.log("prow",prow);
this.$refs.Specification.showSpecial(true,prow);
this.$nextTick(
this.$refs.Specification.showSpecial(true,prow)
);
}
},
};
......
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