Commit 10bb6221 by 赵永成

Specification

parent f57b897e
...@@ -26,3 +26,22 @@ export function add_spec_step(data) { ...@@ -26,3 +26,22 @@ export function add_spec_step(data) {
data: 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 @@ ...@@ -32,11 +32,15 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </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> </el-dialog>
</div> </div>
</template> </template>
<script> <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"; import { stringify } from "querystring";
export default { export default {
props: { props: {
...@@ -45,6 +49,7 @@ export default { ...@@ -45,6 +49,7 @@ export default {
return{ return{
open:false, open:false,
goods:{},
crowext:false, crowext:false,
special_tb_data:[], special_tb_data:[],
steps:[{ steps:[{
...@@ -80,7 +85,11 @@ export default { ...@@ -80,7 +85,11 @@ export default {
this.spec_mach_model_list(); this.spec_mach_model_list();
}, },
methods: { methods: {
/**打卡规格详情配置,并初始化显示内容 */ /**提前将商品信息传入 */
setSpecGoods(pgoods){
this.goods = pgoods;
},
/**打开规格详情配置,并初始化显示内容 */
showSpecial(isShow,pgoods){ showSpecial(isShow,pgoods){
// 样例 // 样例
// { // {
...@@ -97,7 +106,6 @@ export default { ...@@ -97,7 +106,6 @@ export default {
//商品规格,和机器型号组合 //商品规格,和机器型号组合
let spec_str = pgoods.spec; let spec_str = pgoods.spec;
let spec = JSON.parse(spec_str); let spec = JSON.parse(spec_str);
console.log("spec.length",spec.length);
for(let i=0;i<spec.length;i++){ for(let i=0;i<spec.length;i++){
for(let j=0;j<this.mach_model_list.length;j++){ for(let j=0;j<this.mach_model_list.length;j++){
let spec_model = { let spec_model = {
...@@ -114,15 +122,15 @@ export default { ...@@ -114,15 +122,15 @@ export default {
}], }],
"step_opts":[] "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);
let that =this; 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);
//this.queryParams={model_id:spec_model.model_id,sku_id:spec_model.spec_id}; //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(this.queryParams).then((response) => {
//将步骤list转换为下拉框能识别的数组; //将步骤list转换为下拉框能识别的数组;
//样例 //样例
...@@ -163,16 +171,64 @@ export default { ...@@ -163,16 +171,64 @@ export default {
} }
spec_model.step_opts = step_opts; spec_model.step_opts = step_opts;
that.special_tb_data.push(spec_model); 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){ specal_opt(pindex,prow,tag){
if(tag == "view_step"){ if(tag == "view_step"){
this.crowext = !this.crowext; this.crowext = !this.crowext;
...@@ -185,6 +241,10 @@ export default { ...@@ -185,6 +241,10 @@ export default {
this.spec_step_save(prow); this.spec_step_save(prow);
} }
if(tag == "del"){
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) => {
...@@ -229,14 +289,56 @@ export default { ...@@ -229,14 +289,56 @@ export default {
//填充对应的值 //填充对应的值
step_obj.sku_id = prow.spec_id; step_obj.sku_id = prow.spec_id;
step_obj.model_id = prow.model_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); 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);
});
},
/**删除步骤 */
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);
});
}, },
findStepById(step_obj){
fillStepById(step_obj,t_step,prow){
//TODO //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; return step_obj;
}, },
/**获取可能的步骤 */ /**获取可能的步骤 */
......
...@@ -249,9 +249,14 @@ export default { ...@@ -249,9 +249,14 @@ export default {
}, },
setGoodsConfig(prow){ setGoodsConfig(prow){
this.$refs.Specification.setSpecGoods(prow);
this.$nextTick( this.$nextTick(
this.$refs.Specification.showSpecial(true,prow) 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