Browse Source

完成发起采购流程

master
邓平艺 5 years ago
parent
commit
0bb21419cc
  1. 2
      common/mixin.js
  2. 17
      components/wyb-table/wyb-table.vue
  3. 103
      pages/canteen/classification/material.vue
  4. 136
      pages/canteen/purchase/launch.vue

2
common/mixin.js

@ -112,7 +112,7 @@ export default{
let pages = getCurrentPages(); // 当前页 let pages = getCurrentPages(); // 当前页
let beforePage = pages[pages.length - (page + 1)]; // 上个页面 let beforePage = pages[pages.length - (page + 1)]; // 上个页面
if(beforePage && beforePage.route){ if(beforePage && beforePage.route){
uni.navigateBack();
uni.navigateBack({delta: page});
}else{ }else{
let path_url = '/pages/'+ this.$getPageType() +'/index/index'; let path_url = '/pages/'+ this.$getPageType() +'/index/index';
this.$url(path_url, {type: 'launch'}); this.$url(path_url, {type: 'launch'});

17
components/wyb-table/wyb-table.vue

@ -205,7 +205,7 @@
bottomComputed: [], bottomComputed: [],
colorList: [], colorList: [],
bgColorList: [], bgColorList: [],
contentsSort: this.contents.slice(),
contentsSort: this.toArray(),
oContentsSort: [], oContentsSort: [],
sortWay: 0, sortWay: 0,
sortKeys: [], sortKeys: [],
@ -535,7 +535,7 @@
} }
}, },
contents: { contents: {
type: Array,
type: [Array, Object],
default() { default() {
return [{ return [{
name: '张三', name: '张三',
@ -754,6 +754,19 @@
} }
}, },
methods: { methods: {
//
toArray(){
if(Array.isArray(this.contents)){
return this.contents.slice();
}else{
let contents = {...this.$props.contents};
let arr = [];
for(let i in contents){
arr.push(contents[i]);
}
return arr;
}
},
inputBlur(cIndex, hIndex, event){ inputBlur(cIndex, hIndex, event){
let event_obj = {}; let event_obj = {};
let value = event.detail.value; let value = event.detail.value;

103
pages/canteen/classification/material.vue

@ -24,7 +24,8 @@
</view> </view>
<!-- 操作按钮 --> <!-- 操作按钮 -->
<view class="fixed-bottom"> <view class="fixed-bottom">
<button class="btn btn1" @click="prev">上一步</button>
<button class="btn btn1" @click="$toBack()" v-if="type == 1">返回</button>
<button class="btn btn1" @click="prev" v-else>上一步</button>
<button class="btn btn2" @click="submit">确定</button> <button class="btn btn2" @click="submit">确定</button>
</view> </view>
</view> </view>
@ -41,13 +42,18 @@
checked_list: {}, checked_list: {},
is_search_ing: false, // is_search_ing: false, //
request_count: 0, // request_count: 0, //
type: 0
} }
}, },
onLoad(){
onLoad(options){
this.windowHeight = uni.getSystemInfoSync().windowHeight; this.windowHeight = uni.getSystemInfoSync().windowHeight;
let pages = getCurrentPages(); let pages = getCurrentPages();
let prevPage = pages[pages.length - 3]; //
let page_num = 3; //
this.type = options.type || this.type;
if(options.type && options.type == 1){
page_num = 2;
}
let prevPage = pages[pages.length - page_num];
if(!prevPage){ if(!prevPage){
let path_url = '/pages/canteen/index/index'; let path_url = '/pages/canteen/index/index';
this.$msg('页面异常, 即将跳转').then(result => { this.$msg('页面异常, 即将跳转').then(result => {
@ -56,89 +62,6 @@
return; return;
} }
this.checked_list = prevPage.$data.material_list; this.checked_list = prevPage.$data.material_list;
/*
this.checked_list = {
"1": {
address: "广西南宁市青秀区青秀万达店",
admin_uid: 1,
area_id: 2165,
checked: true,
city_id: 2163,
corporate_account: "6214456799861234",
corporate_account_name: "刘淑怡粮油店",
corporate_bank: "招商银行",
corporate_bank_sub: "青秀区支行",
corporate_name: "法人",
corporate_phone: "15699896658",
created_at: "2021-07-17 11:34:50",
created_uid: 1,
ctl_man: "刘淑怡",
ctl_phone: "13397706896",
deleted_at: null,
deleted_uid: 0,
id: 1,
license_number: "11559896646",
license_pic: "admin_images/5bbbc1e4f96bc5566c43bb006d36cc37.jpg",
logo: "admin_images/83e16f0d0c9dd01f1bfd62ddf150607e.jpeg",
material_list: {},
private_account: "",
private_account_name: "",
private_bank: "",
private_bank_sub: "",
province_id: 2162,
qualification_pic: "",
remark: "测试备注,我只改个备注",
s_cate_id: 1,
state: "启用",
subject_name: "主体名称",
subject_type: "公司",
supplier_name: "供应商001",
updated_at: "2021-07-17 16:25:58",
updated_uid: 1
},
"2": {
address: "F座6楼",
admin_uid: 3,
area_id: 2165,
checked: true,
city_id: 2163,
corporate_account: "",
corporate_account_name: "",
corporate_bank: "",
corporate_bank_sub: "",
corporate_name: "",
corporate_phone: "",
created_at: "2021-07-17 20:28:17",
created_uid: 1,
ctl_man: "芳芳",
ctl_phone: "13397706896",
deleted_at: null,
deleted_uid: 0,
id: 2,
license_number: "",
license_pic: "",
logo: "admin_images/skyshareimg.jpeg",
material_list: {},
private_account: "",
private_account_name: "",
private_bank: "",
private_bank_sub: "",
province_id: 2162,
qualification_pic: "",
remark: "",
s_cate_id: 2,
state: "启用",
subject_name: "",
subject_type: "公司",
supplier_name: "供应商002",
updated_at: "2021-07-27 12:00:01",
updated_uid: 1
}
};
*/
this.getData(); this.getData();
}, },
methods: { methods: {
@ -241,7 +164,11 @@
// todo // todo
// this.$url('/pages/canteen/purchase/launch', {type: 'launch'}) // this.$url('/pages/canteen/purchase/launch', {type: 'launch'})
// this.$toBack(2); //
let page_num = 2; //
if(this.type == 1){
page_num = 1;
}
this.$toBack(page_num);
}, },
// //
prev(){ prev(){

136
pages/canteen/purchase/launch.vue

@ -9,10 +9,10 @@
</view> </view>
</view> </view>
</view> </view>
<view class="list">
<view class="list" v-if="show_material">
<view class="lf-row-between"> <view class="lf-row-between">
<view>采购清单</view> <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> <u-icon name="plus-circle" size="42"></u-icon>
</view> </view>
</view> </view>
@ -32,20 +32,19 @@
<!-- 物料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-font-bold">物资明细</view> <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"> <view class="lf-m-b-10 lf-row-between">
<text>我是供应商</text>
<text>删除</text>
<text>{{ value.supplier_name }}</text>
<text @click="removeSupplier(key)">删除</text>
</view> </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> </view>
<!-- 操作按钮 --> <!-- 操作按钮 -->
<view style="height: 100rpx;"></view> <view style="height: 100rpx;"></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>
@ -59,25 +58,15 @@
}, },
data(){ data(){
return { 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'), // date: this.$shared.recordTime(new Date(), '-', 'date'), //
material_list: {} //
material_list: {}, //
show_material: false,
render_material_list: []
} }
}, },
onLoad(){ onLoad(){
// todo table
// todo table
// MaterialList // MaterialList
uni.$on('addMaterialList', res => { uni.$on('addMaterialList', res => {
@ -85,28 +74,34 @@
}) })
}, },
onShow(){ 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: { 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 // table-input todo
onInputChange(event){ onInputChange(event){
console.log("检测到table input被更改", event); console.log("检测到table input被更改", event);
@ -116,24 +111,47 @@
pickerChange(event){ pickerChange(event){
this.date = event.detail.value; 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, { this.$http(this.API.API_CANTEEN_PURCHASEAPPLY, {
data: list
order: list,
state: state
}).then(res => { }).then(res => {
console.log("save", res); console.log("save", res);
this.$msg('操作成功'); this.$msg('操作成功');

Loading…
Cancel
Save