|
|
|
@ -9,10 +9,10 @@ |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="list"> |
|
|
|
<view class="list" v-if="show_material"> |
|
|
|
<view class="lf-row-between"> |
|
|
|
<view>采购清单</view> |
|
|
|
<view class="lf-icon" @click="$url('/pages/canteen/classification/index?type=2')"> |
|
|
|
<view class="lf-icon" @click="$url('/pages/canteen/classification/material?type=1')"> |
|
|
|
<u-icon name="plus-circle" size="42"></u-icon> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
@ -32,20 +32,19 @@ |
|
|
|
<!-- 物料table --> |
|
|
|
<view class="lf-p-32 lf-p-t-30 lf-p-b-30 lf-w-100 lf-h-maxcontent lf-border-box"> |
|
|
|
<view class="lf-font-32 lf-font-bold">物资明细</view> |
|
|
|
<!-- 多个供应商多个table :headers="headers" :contents="contents" --> |
|
|
|
<view v-for="(item,index) in 2" class="lf-m-t-20"> |
|
|
|
<view v-for="(value, key) in material_list" :key="key" class="lf-m-t-20"> |
|
|
|
<view class="lf-m-b-10 lf-row-between"> |
|
|
|
<text>我是供应商</text> |
|
|
|
<text>删除</text> |
|
|
|
<text>{{ value.supplier_name }}</text> |
|
|
|
<text @click="removeSupplier(key)">删除</text> |
|
|
|
</view> |
|
|
|
<wyb-table contentBgColor="#ecfaf5" :first-line-fixed="true" @onInputChange="onInputChange" width="max-content" height="800rpx"></wyb-table> |
|
|
|
<wyb-table :headers="value.headers" :contents="value.material_list" contentBgColor="#ecfaf5" :first-line-fixed="true" @onInputChange="onInputChange" width="max-content" height="800rpx"></wyb-table> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<!-- 操作按钮 --> |
|
|
|
<view style="height: 100rpx;"></view> |
|
|
|
<view class="fixed-bottom"> |
|
|
|
<button class="btn btn1" @click="save(1)">临时保存</button> |
|
|
|
<button class="btn btn2" @click="save(2)">保存并发单</button> |
|
|
|
<button class="btn btn1" @click="save(0)">临时保存</button> |
|
|
|
<button class="btn btn2" @click="save(1)">保存并发单</button> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
@ -59,25 +58,15 @@ |
|
|
|
}, |
|
|
|
data(){ |
|
|
|
return { |
|
|
|
headers: [{ |
|
|
|
label: '菜品名称', |
|
|
|
key: 'name' |
|
|
|
},{ |
|
|
|
label: '规格', |
|
|
|
key: 'spec' |
|
|
|
},{ |
|
|
|
label: '税前价', |
|
|
|
key: 'pre_tax_price' |
|
|
|
},{ |
|
|
|
label: '税后价', |
|
|
|
key: 'after_tax_price' |
|
|
|
}], |
|
|
|
contents: [], |
|
|
|
date: this.$shared.recordTime(new Date(), '-', 'date'), // 选择时间 |
|
|
|
material_list: {} // 供应商,物资列表 |
|
|
|
material_list: {}, // 供应商,物资列表 |
|
|
|
show_material: false, |
|
|
|
render_material_list: [] |
|
|
|
} |
|
|
|
}, |
|
|
|
onLoad(){ |
|
|
|
// todo 验证table有没有问题,因为它是从对象转为数组的 |
|
|
|
// todo 选择供应商但未选择物资,点进去选择物资,选完回到当前页面,table没有显示 |
|
|
|
|
|
|
|
// 监听MaterialList被操作 |
|
|
|
uni.$on('addMaterialList', res => { |
|
|
|
@ -85,28 +74,34 @@ |
|
|
|
}) |
|
|
|
}, |
|
|
|
onShow(){ |
|
|
|
console.log("material_list", this.material_list) |
|
|
|
let material_list = this.material_list; |
|
|
|
for(let i in material_list){ |
|
|
|
// table 标题处理 |
|
|
|
material_list[i].headers = [{ |
|
|
|
key: 'material_name', |
|
|
|
label: '菜品名称' |
|
|
|
},{ |
|
|
|
key: 'spec_name', |
|
|
|
label: '规格' |
|
|
|
},{ |
|
|
|
key: 'purchase_number', |
|
|
|
label: '采购数量' |
|
|
|
},{ |
|
|
|
key: 'tax_price', |
|
|
|
label: '税前价' |
|
|
|
},{ |
|
|
|
key: 'non_tax_price', |
|
|
|
label: '税后价' |
|
|
|
}]; |
|
|
|
// table 内容处理 |
|
|
|
for(let j in material_list[i].material_list){ |
|
|
|
material_list[i].material_list[j].purchase_number = {edit: true, value: ''}; |
|
|
|
} |
|
|
|
} |
|
|
|
this.material_list = material_list; |
|
|
|
this.show_material = Object.keys(this.material_list).length > 0; |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 改接口废弃 |
|
|
|
getMaterialList(){ |
|
|
|
this.$http(this.API.API_CANTEEN_MATERIALLIST, { |
|
|
|
// category_id: 1 // 分类id 不传则显示默认分类 |
|
|
|
}).then(res => { |
|
|
|
let list = res.data.material || []; |
|
|
|
let contents = list.map(item => { |
|
|
|
return { |
|
|
|
name: item.material.m_name, |
|
|
|
spec: item.name, |
|
|
|
pre_tax_price: {edit: true, value: item.tax_standard_price}, |
|
|
|
after_tax_price: {edit: true, value: item.non_tax_standard_price}, |
|
|
|
spec_id: item.id, |
|
|
|
material_id: item.material.id |
|
|
|
} |
|
|
|
}) |
|
|
|
this.contents = contents; |
|
|
|
}) |
|
|
|
}, |
|
|
|
// table-input值被改变 todo |
|
|
|
onInputChange(event){ |
|
|
|
console.log("检测到table input被更改", event); |
|
|
|
@ -116,24 +111,47 @@ |
|
|
|
pickerChange(event){ |
|
|
|
this.date = event.detail.value; |
|
|
|
}, |
|
|
|
// 移除供应商 |
|
|
|
removeSupplier(key){ |
|
|
|
let material_list = {...this.material_list}; |
|
|
|
delete material_list[key]; |
|
|
|
this.material_list = material_list; |
|
|
|
}, |
|
|
|
// 保存并发单 |
|
|
|
save(){ |
|
|
|
// todo |
|
|
|
console.log("dddddd", this.contents) |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
let list = this.contents.map(item => { |
|
|
|
return { |
|
|
|
m_id: item.material_id, |
|
|
|
m_spec_id: item.spec_id, |
|
|
|
tax_price: item.pre_tax_price.value, |
|
|
|
non_tax_price: item.after_tax_price.value |
|
|
|
save(_t){ |
|
|
|
let material_list = this.material_list; |
|
|
|
let list = []; |
|
|
|
let is_empty = true; // 物资数据是否为空 |
|
|
|
for(let i in material_list){ |
|
|
|
if(Object.keys(material_list[i].material_list).length){ |
|
|
|
is_empty = false; |
|
|
|
let material = material_list[i].material_list; |
|
|
|
let arr = []; |
|
|
|
for(let j in material){ |
|
|
|
arr.push({ |
|
|
|
m_id: material[j].material_id, |
|
|
|
m_spec_id: material[j].spec_id, |
|
|
|
tax_price: material[j].tax_price, |
|
|
|
non_tax_price: material[j].non_tax_price, |
|
|
|
purchase_number: material[j].purchase_number.value || 0 |
|
|
|
}); |
|
|
|
} |
|
|
|
list.push({ |
|
|
|
supplier_id: material_list[i].id, |
|
|
|
material: arr |
|
|
|
}) |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
console.log("list", list) |
|
|
|
if(is_empty){ |
|
|
|
this.$msg('您未选择物资'); |
|
|
|
return; |
|
|
|
} |
|
|
|
let state = ['待发单', '待审核'][_t]; |
|
|
|
this.$http(this.API.API_CANTEEN_PURCHASEAPPLY, { |
|
|
|
data: list |
|
|
|
order: list, |
|
|
|
state: state |
|
|
|
}).then(res => { |
|
|
|
console.log("save", res); |
|
|
|
this.$msg('操作成功'); |
|
|
|
|