Browse Source

对接采购单复用

master
邓平艺 5 years ago
parent
commit
5b37d97546
  1. 1
      canteen/common/api.js
  2. 230
      canteen/pages/purchase/launch.vue

1
canteen/common/api.js

@ -25,5 +25,6 @@ export const API_SUPPLIER_PURCHASEUPLOADVOUCHER = '/api/canteen/purchaseSaveVouc
export const API_CONFIRM = '/api/canteen/purchaseConfirm'; // 食堂采购详情确认收货
export const API_BUYREUSE= '/api/canteen/purchaseReuse'; // 食堂采购复用订单
export const API_CANTEEN_PURCHASESAVE = '/api/canteen/purchaseSave'; // 采购单编辑时保存

230
canteen/pages/purchase/launch.vue

@ -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);

Loading…
Cancel
Save