Browse Source

完成对接申请出库页面

master
邓平艺 5 years ago
parent
commit
30ab58d466
  1. 3
      common/api.js
  2. 6
      pages.json
  3. 222
      pages/canteen/classification/warehouse.vue
  4. 70
      pages/canteen/delivery/apply.vue

3
common/api.js

@ -31,4 +31,5 @@ export const API_CANTEEN_PURCHASEORDERLIST = '/api/canteen/purchaseOrderList'; /
export const API_CANTEEN_WAREHOUSEOUT = '/api/canteen/warehouseOut'; // 出库申请 export const API_CANTEEN_WAREHOUSEOUT = '/api/canteen/warehouseOut'; // 出库申请
export const API_CANTEEN_WAREHOUSEOUTLIST = '/api/canteen/warehouseOutList'; // 出库申请列表 export const API_CANTEEN_WAREHOUSEOUTLIST = '/api/canteen/warehouseOutList'; // 出库申请列表
export const API_CANTEEN_PURCHASEDETAIL = '/api/canteen/purchaseDetail'; // 采购单详情 export const API_CANTEEN_PURCHASEDETAIL = '/api/canteen/purchaseDetail'; // 采购单详情
export const API_CANTEEN_SUPPLIERLIST = '/api/canteen/supplierList'; // 供应商列表
export const API_CANTEEN_SUPPLIERLIST = '/api/canteen/supplierList'; // 供应商列表
export const API_CANTEEN_MATERIALLISTBYWAREHOUSE = '/api/canteen/materialListByWarehouse'; // 仓库物资列表

6
pages.json

@ -101,6 +101,12 @@
"navigationBarTitleText": "添加物资" "navigationBarTitleText": "添加物资"
} }
}, },
{
"path": "pages/canteen/classification/warehouse",
"style": {
"navigationBarTitleText": "添加物资"
}
},
{ {
"path": "pages/canteen/delivery/apply", "path": "pages/canteen/delivery/apply",
"style": { "style": {

222
pages/canteen/classification/warehouse.vue

@ -0,0 +1,222 @@
<template>
<view>
<view class="head" v-if="tab_list.length">
<uni-search-bar @confirm="search" @cancel="cancelSearch" placeholder="搜索物资" radius="90" bgColor="#f6f6f6" ></uni-search-bar>
</view>
<view class="lf-flex content" v-if="tab_list.length">
<scroll-view :scroll-y="true" class="scroll-left"
v-if="!is_search_ing"
:style="{height: 'calc('+ windowHeight +'px - 222rpx)'}">
<view class="tab-item" :class="{'activa': index == current}" v-for="(item, index) in tab_list" :key="index" @click="switchTab(index)">{{ item.m_cate_name }}</view>
</scroll-view>
<scroll-view :scroll-y="true" class="scroll-right"
:style="{height: 'calc('+ windowHeight +'px - 222rpx)', width:is_search_ing?'100%':'550rpx'}">
<view class="supplier-item" v-for="(item, index) in tab_list[current].list" :key="index">
<label class="lf-row-between" @click="switchChecked(item)">
<view style="height: 40rpx;">{{ item.material_name }}</view>
<u-icon name="checkmark-circle-fill" size="40" color="#11D189" v-if="item.checked"></u-icon>
</label>
</view>
<view class="loading-more">
<lf-nocontent v-if="!tab_list[current].list.length"></lf-nocontent>
</view>
</scroll-view>
</view>
<!-- 操作按钮 -->
<view class="fixed-bottom">
<button class="btn btn1" @click="cancel">取消</button>
<button class="btn btn2" @click="submit">确定</button>
</view>
</view>
</template>
<script>
export default {
data(){
return {
windowHeight: 0,
tab_list: [],
current: 0, // tab
material_name: '', //
checked_list: {},
is_search_ing: false, //
request_count: 0, //
}
},
onLoad(options){
this.windowHeight = uni.getSystemInfoSync().windowHeight;
let pages = getCurrentPages();
let prevPage = pages[pages.length - 2];
if(!prevPage){
let path_url = '/pages/canteen/index/index';
this.$msg('页面异常, 即将跳转').then(result => {
this.$url(path_url, {type: 'launch'});
})
return;
}
this.checked_list = prevPage.$data.warehouse_list;
this.getData();
},
methods: {
//
search(event){
this.is_search_ing = true;
this.material_name = event.value;
this.current = this.tab_list.length; //
this.tab_list.push({m_cate_name: '搜索', list: []});
this.getData({keyword: event.value});
},
//
cancelSearch(){
this.is_search_ing = false;
this.material_name = '';
this.current = 0;
this.tab_list.pop();
},
//
getData(options){
this.request_count++;
this.$http(this.API.API_CANTEEN_MATERIALLISTBYWAREHOUSE, {
...options
}).then(res => {
if(this.request_count <= 1){
let category = res.data.category || [];
let tab_list = category.map(item => {
item.list = [];
return item;
})
let list = res.data.material.map(item => {
if(this.checked_list[item.material_id]){
item.checked = true;
}else{
item.checked = false;
}
return item;
})
tab_list[this.current].list = list;
this.tab_list = tab_list;
}else{
let list = res.data.material.map(item => {
if(this.checked_list[item.material_id]){
item.checked = true;
}else{
item.checked = false;
}
return item;
})
this.tab_list[this.current].list = list;
}
})
},
// tab
switchTab(current){
this.current = current;
let item = this.tab_list[this.current];
if(item && item.list.length <= 0){ //
this.getData({cate_id: item.id});
}
},
//
switchChecked(item){
item.checked = !item.checked;
if(this.is_search_ing){
this.tab_list.forEach(t_item => {
t_item.list.forEach(l_item => {
if(l_item.material_id == item.material_id){
l_item.checked = item.checked;
}
})
})
}
if(item.checked){
this.checked_list[item.material_id] = item;
}else{
delete this.checked_list[item.material_id];
}
uni.$emit('addWarehouseList', this.checked_list);
console.log("checked_list", this.checked_list)
},
//
submit(){
this.$toBack();
},
//
cancel(){
this.checked_list = {};
uni.$emit('addWarehouseList', this.checked_list);
this.$toBack();
}
}
}
</script>
<style lang="scss" scoped="scoped">
/deep/.uni-searchbar__box{
border: none;
}
.head{
padding: 14rpx 16rpx;
}
.scroll-left{
width: 200rpx;
background-color: #F6F6F6;
.tab-item{
height: 90rpx;
width: 100%;
text-align: center;
line-height: 90rpx;
font-size: 28rpx;
color: #555555;
}
.activa{
color: #11D189;
}
}
.scroll-right{
width: 550rpx;
background-color: #FFFFFF;
.supplier-item{
padding: 30rpx 32rpx 30rpx 30rpx;
width: 100%;
height: max-content;
box-sizing: border-box;
border-bottom: 1rpx solid #e5e5e5;
font-size: 28rpx;
color: #222222;
}
}
.fixed-bottom{
position: fixed;
bottom: 0rpx;
left: 0rpx;
z-index: 99;
width: 750rpx;
height: 98rpx;
display: flex;
justify-content: space-between;
align-items: center;
border-top: 1rpx solid #E5E5E5;
background-color: #FFFFFF;
box-sizing: border-box;
padding: 0 32rpx;
.btn{
width: 320rpx;
height: 82rpx;
border-radius: 41rpx;
margin: 0;
padding: 0;
font-size: 32rpx;
display: flex;
justify-content: center;
align-items: center;
}
.btn1{
border: 2rpx solid #555555;
opacity: .5;
}
.btn2{
background: #11D189;
color: #FFFFFF;
}
}
</style>

70
pages/canteen/delivery/apply.vue

@ -3,8 +3,7 @@
<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-p-32 lf-p-t-30 lf-p-b-30 lf-w-100 lf-h-maxcontent lf-border-box">
<view class="lf-font-28 lf-color-black lf-row-between"> <view class="lf-font-28 lf-color-black lf-row-between">
<view>出库清单</view> <view>出库清单</view>
<!-- <view class="lf-icon" @click="$url('/pages/canteen/classification/index?type=3')"> -->
<view class="lf-icon" @click="$url('')">
<view class="lf-icon" @click="$url('/pages/canteen/classification/warehouse')">
<u-icon name="plus-circle" size="42"></u-icon> <u-icon name="plus-circle" size="42"></u-icon>
</view> </view>
</view> </view>
@ -15,12 +14,12 @@
<!-- 物料table --> <!-- 物料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-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-color-black lf-font-bold lf-m-b-20">物资明细</view> <view class="lf-font-32 lf-color-black lf-font-bold lf-m-b-20">物资明细</view>
<wyb-table :headers="headers" contentBgColor="#ecfaf5" :first-line-fixed="true" :contents="contents" @onInputChange="onInputChange" width="max-content" height="800rpx"></wyb-table>
<wyb-table :headers="headers" :contents="contents" contentBgColor="#ecfaf5" :first-line-fixed="true" @onInputChange="onInputChange" width="max-content" height="800rpx"></wyb-table>
</view> </view>
<!-- 操作按钮 --> <!-- 操作按钮 -->
<view class="fixed-bottom"> <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>
</view> </view>
</template> </template>
@ -36,57 +35,56 @@
return { return {
headers: [{ headers: [{
label: '菜品名称', label: '菜品名称',
key: 'name'
key: 'material_name'
},{ },{
label: '规格', label: '规格',
key: 'spec'
key: 'spec_name'
},{ },{
label: '税前价',
key: 'pre_tax_price'
},{
label: '税后价',
key: 'after_tax_price'
label: '批次',
key: 'purchase_id'
}], }],
contents: []
contents: [],
warehouse_list: {}
} }
}, },
onLoad(){ onLoad(){
this.getMaterialList();
// warehouse_list
uni.$on('addWarehouseList', res => {
this.warehouse_list = res;
})
},
onShow(){
let contents = [];
let warehouse_list = this.warehouse_list;
for(let i in warehouse_list){
contents.push(warehouse_list[i]);
}
this.contents = contents;
}, },
methods: { 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;
})
},
// todo table
onInputChange(event){ onInputChange(event){
console.log("检测到table input被更改", event); console.log("检测到table input被更改", event);
this.contents[event.contentIndex][event.key].value = event.detailValue;
// this.contents[event.contentIndex][event.key].value = event.detailValue;
}, },
//
save(_t){ save(_t){
// todo
console.log("dddddd", this.contents) console.log("dddddd", this.contents)
if(this.contents.length <= 0) {
return this.$msg('您未选择物资')
}
let list = this.contents.map(item => { let list = this.contents.map(item => {
return { return {
m_id: item.material_id, m_id: item.material_id,
m_spec_id: item.spec_id, m_spec_id: item.spec_id,
tax_price: item.pre_tax_price.value,
non_tax_price: item.after_tax_price.value
tax_price: '',
non_tax_price: '',
purchase_id: item.purchase_id,
out_number: ''
} }
}); });
// let state = ['', ''][_t]; //
this.$http(this.API.API_CANTEEN_WAREHOUSEOUT, { this.$http(this.API.API_CANTEEN_WAREHOUSEOUT, {
data: list data: list
}).then(res => { }).then(res => {

Loading…
Cancel
Save