|
|
|
@ -68,73 +68,191 @@ |
|
|
|
date: '', |
|
|
|
material_list: {}, // 供应商,物资列表,不被渲染,在底层逻辑运作 |
|
|
|
show_material: false, // 是否显示采购清单按钮 |
|
|
|
render_material_list: {} // 渲染出来的物资列表 |
|
|
|
render_material_list: {}, // 渲染出来的物资列表 |
|
|
|
show_count: 0, // 页面显示次数 |
|
|
|
p_sn: '', // 订单号,如果有 |
|
|
|
type: 0 // 类型 |
|
|
|
} |
|
|
|
}, |
|
|
|
onLoad(){ |
|
|
|
onLoad(options){ |
|
|
|
// TODO 采购单编辑时保存 |
|
|
|
// todo 采购单复用ok,还差 编辑 采购单保存 |
|
|
|
|
|
|
|
// 监听MaterialList被操作 |
|
|
|
uni.$on('addMaterialList', res => { |
|
|
|
this.material_list = res; |
|
|
|
}) |
|
|
|
|
|
|
|
// /pages/purchase/launch?p_sn=P162771908650053&enter_type=2 |
|
|
|
if(options){ |
|
|
|
this.p_sn = options.p_sn || ''; |
|
|
|
this.type = options.enter_type || 0; |
|
|
|
if(options.enter_type == 2){ |
|
|
|
this.copyMaterialList(); // 复用采购单 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var test = { |
|
|
|
"2": { |
|
|
|
address: "", |
|
|
|
admin_uid: 2, |
|
|
|
area_id: 0, |
|
|
|
checked: true, |
|
|
|
city_id: 0, |
|
|
|
corporate_account: "", |
|
|
|
corporate_account_name: "", |
|
|
|
corporate_bank: "", |
|
|
|
corporate_bank_sub: "", |
|
|
|
corporate_name: "", |
|
|
|
corporate_phone: "", |
|
|
|
created_at: "2021-07-31 10:23:47", |
|
|
|
created_uid: 1, |
|
|
|
ctl_man: "张大拿", |
|
|
|
ctl_phone: "13177889965", |
|
|
|
deleted_at: null, |
|
|
|
deleted_uid: 0, |
|
|
|
id: 2, |
|
|
|
license_number: "", |
|
|
|
license_pic: "https://gxskyimg.lanzulive.com/", |
|
|
|
logo: "admin_images/89897b012083b738b5792079368e73b9.jpeg", |
|
|
|
material_list: { |
|
|
|
"1": { |
|
|
|
brand: "", |
|
|
|
checked: true, |
|
|
|
item_id: 1, |
|
|
|
m_sn: "M162769768826400", |
|
|
|
material_id: 1, |
|
|
|
material_name: "上林丝苗米", |
|
|
|
non_tax_price: "1.00", |
|
|
|
purchase_limit: 1, |
|
|
|
quality_level: "", |
|
|
|
spec_id: 1, |
|
|
|
spec_name: "-", |
|
|
|
supplier_id: 2, |
|
|
|
supplier_name: "食品类供应商001", |
|
|
|
tax_price: "2.00" |
|
|
|
} |
|
|
|
}, |
|
|
|
private_account: "", |
|
|
|
private_account_name: "", |
|
|
|
private_bank: "", |
|
|
|
private_bank_sub: "", |
|
|
|
province_id: 0, |
|
|
|
qualification_pic: "https://gxskyimg.lanzulive.com/", |
|
|
|
remark: "", |
|
|
|
s_cate_id: 1, |
|
|
|
state: "启用", |
|
|
|
subject_name: "", |
|
|
|
subject_type: "公司", |
|
|
|
supplier_name: "食品类供应商001", |
|
|
|
updated_at: "2021-07-31 10:24:03", |
|
|
|
updated_uid: 1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
console.log("options", options); |
|
|
|
|
|
|
|
}, |
|
|
|
onShow(){ |
|
|
|
let material_list = JSON.stringify(this.material_list); |
|
|
|
material_list = JSON.parse(material_list); |
|
|
|
for(let i in material_list){ |
|
|
|
// table 标题处理 |
|
|
|
material_list[i].headers = [{ |
|
|
|
key: 'material_name', |
|
|
|
label: '物资名称' |
|
|
|
},{ |
|
|
|
key: 'spec_name', |
|
|
|
label: '规格' |
|
|
|
},{ |
|
|
|
key: 'brand', |
|
|
|
label: '品牌' |
|
|
|
},{ |
|
|
|
key: 'quality_level', |
|
|
|
label: '品级' |
|
|
|
},{ |
|
|
|
label: '编号', |
|
|
|
key: 'm_sn' |
|
|
|
},{ |
|
|
|
label: '供应商', |
|
|
|
key: 'supplier_name' |
|
|
|
},{ |
|
|
|
key: 'tax_price', |
|
|
|
label: '含税价' |
|
|
|
},{ |
|
|
|
key: 'non_tax_price', |
|
|
|
label: '不含税价' |
|
|
|
},{ |
|
|
|
key: 'purchase_limit', |
|
|
|
label: '起购数' |
|
|
|
},{ |
|
|
|
key: 'purchase_number', |
|
|
|
label: '采购数量' |
|
|
|
},{ |
|
|
|
key: 'operation', |
|
|
|
label: '操作' |
|
|
|
}]; |
|
|
|
// table 内容处理 |
|
|
|
let list_arr = []; |
|
|
|
for(let j in material_list[i].material_list){ |
|
|
|
material_list[i].material_list[j].purchase_number = {edit: true, value: ''}; |
|
|
|
material_list[i].material_list[j].operation = {button: true, key: 'delete', value: '删除'}; |
|
|
|
material_list[i].material_list[j].supplier_name = material_list[i].supplier_name; |
|
|
|
material_list[i].material_list[j].tax_price = material_list[i].material_list[j].tax_price; |
|
|
|
material_list[i].material_list[j].non_tax_price = material_list[i].material_list[j].non_tax_price; |
|
|
|
// material_list[i].material_list[j].star_num = material_list[i].material_list[j].purchase_limit; |
|
|
|
list_arr.push(material_list[i].material_list[j]); |
|
|
|
} |
|
|
|
material_list[i].material_list = list_arr; |
|
|
|
this.show_count++; |
|
|
|
if(this.show_count > 1){ |
|
|
|
this.transformList(); |
|
|
|
} |
|
|
|
this.render_material_list = material_list; |
|
|
|
this.show_material = Object.keys(this.material_list).length > 0; |
|
|
|
console.log("show..material_list", this.material_list); |
|
|
|
console.log("show...render_material_list", this.render_material_list) |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 物资列表转换成页面可渲染的格式,material_list => render_material_list |
|
|
|
transformList(){ |
|
|
|
let material_list = JSON.stringify(this.material_list); |
|
|
|
material_list = JSON.parse(material_list); |
|
|
|
for(let i in material_list){ |
|
|
|
// table 标题处理 |
|
|
|
material_list[i].headers = [{ |
|
|
|
key: 'material_name', |
|
|
|
label: '物资名称' |
|
|
|
},{ |
|
|
|
key: 'spec_name', |
|
|
|
label: '规格' |
|
|
|
},{ |
|
|
|
key: 'brand', |
|
|
|
label: '品牌' |
|
|
|
},{ |
|
|
|
key: 'quality_level', |
|
|
|
label: '品级' |
|
|
|
},{ |
|
|
|
label: '编号', |
|
|
|
key: 'm_sn' |
|
|
|
},{ |
|
|
|
label: '供应商', |
|
|
|
key: 'supplier_name' |
|
|
|
},{ |
|
|
|
key: 'tax_price', |
|
|
|
label: '含税价' |
|
|
|
},{ |
|
|
|
key: 'non_tax_price', |
|
|
|
label: '不含税价' |
|
|
|
},{ |
|
|
|
key: 'purchase_limit', |
|
|
|
label: '起购数' |
|
|
|
},{ |
|
|
|
key: 'purchase_number', |
|
|
|
label: '采购数量' |
|
|
|
},{ |
|
|
|
key: 'operation', |
|
|
|
label: '操作' |
|
|
|
}]; |
|
|
|
// table 内容处理 |
|
|
|
let list_arr = []; |
|
|
|
for(let j in material_list[i].material_list){ |
|
|
|
material_list[i].material_list[j].purchase_number = {edit: true, value: ''}; |
|
|
|
material_list[i].material_list[j].operation = {button: true, key: 'delete', value: '删除'}; |
|
|
|
material_list[i].material_list[j].supplier_name = material_list[i].supplier_name; |
|
|
|
material_list[i].material_list[j].tax_price = material_list[i].material_list[j].tax_price; |
|
|
|
material_list[i].material_list[j].non_tax_price = material_list[i].material_list[j].non_tax_price; |
|
|
|
list_arr.push(material_list[i].material_list[j]); |
|
|
|
} |
|
|
|
material_list[i].material_list = list_arr; |
|
|
|
} |
|
|
|
this.render_material_list = material_list; |
|
|
|
this.show_material = Object.keys(this.material_list).length > 0; |
|
|
|
console.log("transform..material_list", this.material_list); |
|
|
|
console.log("transform...render_material_list", this.render_material_list) |
|
|
|
}, |
|
|
|
// 复用采购单 |
|
|
|
copyMaterialList(){ |
|
|
|
this.$http(this.API.API_BUYREUSE, { |
|
|
|
p_sn: this.p_sn |
|
|
|
}).then(res => { |
|
|
|
let list = res.data || []; |
|
|
|
let material_list = {}; |
|
|
|
list.map(item => { |
|
|
|
let items = item.purchase[0].items; |
|
|
|
let items_obj = {}; |
|
|
|
items.map(i_item => { |
|
|
|
items_obj[i_item.quotation_item_id] = { |
|
|
|
brand: i_item.material.brand, |
|
|
|
checked: true, |
|
|
|
item_id: i_item.quotation_item_id, |
|
|
|
m_sn: i_item.material.m_sn, |
|
|
|
material_id: i_item.material.id, |
|
|
|
material_name: i_item.material.m_name, |
|
|
|
non_tax_price: i_item.non_tax_price, |
|
|
|
purchase_limit: i_item.p_order_item.purchase_limit, |
|
|
|
quality_level: i_item.material.quality_level, |
|
|
|
spec_id: i_item.spec.id, |
|
|
|
spec_name: i_item.spec.name, |
|
|
|
supplier_id: item.id, |
|
|
|
supplier_name: item.supplier_name, |
|
|
|
tax_price: i_item.tax_price |
|
|
|
}; |
|
|
|
}); |
|
|
|
item.material_list = items_obj; |
|
|
|
material_list[item.id] = item; |
|
|
|
}) |
|
|
|
this.material_list = material_list; |
|
|
|
this.transformList(); |
|
|
|
console.log("yes", material_list); |
|
|
|
}) |
|
|
|
}, |
|
|
|
// table-input值被改变 |
|
|
|
onInputChange(event){ |
|
|
|
console.log("检测到table input被更改", event); |
|
|
|
|