Browse Source

完善发起采购页面逻辑

master
邓平艺 5 years ago
parent
commit
bb60c0d417
  1. 5
      common/http.interceptor.js
  2. 11
      common/mixin.js
  3. 31
      components/wyb-table/wyb-table.vue
  4. 1
      pages/canteen/index/index.vue
  5. 22
      pages/canteen/login/index.vue
  6. 112
      pages/canteen/purchase/launch.vue
  7. 1
      pages/supply/index/index.vue
  8. 20
      pages/supply/login/index.vue

5
common/http.interceptor.js

@ -32,7 +32,10 @@ const install = (Vue, vm) => {
Vue.prototype.$u.http.interceptor.response = res => {
if(res.code == 0) {
return res;
} else {
} else if (res.code == 9999) {
vm.$redirectToLogin('登录超时, 请重新登录');
return false;
}else {
vm.$msg(res.msg);
return false;
}

11
common/mixin.js

@ -9,8 +9,6 @@ export default{
this.pageScrollTop = res.scrollTop;
},
onLoad(){
let pages = getCurrentPages(); // 获取页面栈
this.currentPage = pages[pages.length - 1].route; // 当前页面
let key_name = this.$getPageType() +'_token';
let user_token = uni.getStorageSync(key_name);
if(!user_token){
@ -19,10 +17,13 @@ export default{
},
methods: {
$getPageType(){
let pages = getCurrentPages(); // 获取页面栈
let currentPage = pages[pages.length - 1].route; // 当前页面
this.currentPage = currentPage;
// 获取当前页面是属于供应端还是食堂端
if(this.currentPage.indexOf('pages/supply') == 0){
if(currentPage.indexOf('pages/supply') == 0){
return 'supply';
}else if(this.currentPage.indexOf('pages/canteen') == 0){
}else if(currentPage.indexOf('pages/canteen') == 0){
return 'canteen';
}
},
@ -125,7 +126,7 @@ export default{
'pages/empty/index',
'/preview-image'
];
if(intercept_route.includes(this.currentPage)){
if(intercept_route.includes(this.$getPageType())){
return; // 忽略提示跳转的路由
}
let path_url = '/pages/'+ this.$getPageType() +'/login/index';

31
components/wyb-table/wyb-table.vue

@ -205,7 +205,7 @@
bottomComputed: [],
colorList: [],
bgColorList: [],
contentsSort: this.toArray(),
contentsSort: this.contents.slice(),
oContentsSort: [],
sortWay: 0,
sortKeys: [],
@ -535,7 +535,7 @@
}
},
contents: {
type: [Array, Object],
type: Array,
default() {
return [{
name: '张三',
@ -755,18 +755,19 @@
},
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;
}
},
// toArray(val){
// if(Array.isArray(val)){
// console.log("ssssss=======")
// return val.slice();
// }else{
// let contents = {...val};
// let arr = [];
// for(let i in contents){
// arr.push(contents[i]);
// }
// return arr;
// }
// },
inputBlur(cIndex, hIndex, event){
let event_obj = {};
let value = event.detail.value;
@ -911,7 +912,7 @@
}
}
if (content[header.key]) {
if (content && content[header.key]) {
if (keys.includes(header.key)) {
//
switch(this.urlCol[keys.indexOf(header.key)].type) {

1
pages/canteen/index/index.vue

@ -34,6 +34,7 @@
}
},
onLoad(){
// todo
this.getHomeData();
},
onReady(){

22
pages/canteen/login/index.vue

@ -8,13 +8,29 @@
<u-icon name="account-fill"></u-icon>
<text class="lf-m-l-10 lf-font-28 lf-color-333">登录账号</text>
</view>
<input class="input" v-model="user_key" :adjust-position="false" :auto-blur="true" placeholder="请输入账号" @focus="inputFocus(170)" @blur="inputBlur" />
<input class="input"
maxlength="11"
v-model="user_key"
:adjust-position="false"
:auto-blur="true"
placeholder="请输入账号"
@focus="inputFocus(170)"
@blur="inputBlur" />
<!-- 密码 -->
<view class="lf-flex lf-m-b-10 lf-m-t-60">
<u-icon name="lock-fill"></u-icon>
<text class="lf-m-l-10 lf-font-28 lf-color-333">登录密码</text>
</view>
<input class="input" v-model="user_pw" :adjust-position="false" :auto-blur="true" placeholder="请输入密码" :password="true" @focus="inputFocus(220)" @blur="inputBlur" />
<input class="input"
maxlength="20"
v-model="user_pw"
:adjust-position="false"
:auto-blur="true"
placeholder="请输入密码"
:password="true"
@focus="inputFocus(220)"
@blur="inputBlur"
@confirm="login" />
</view>
<view>
<!-- 登录按钮 -->
@ -37,7 +53,7 @@
}
},
onLoad(options){
// todo inputclear
},
onReady(){
// #ifndef MP

112
pages/canteen/purchase/launch.vue

@ -32,12 +32,18 @@
<!-- 物料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>
<view v-for="(value, key) in material_list" :key="key" class="lf-m-t-20">
<view v-for="(value, key) in render_material_list" :key="key" class="lf-m-t-20">
<view class="lf-m-b-10 lf-row-between">
<text>{{ value.supplier_name }}</text>
<text @click="removeSupplier(key)">删除</text>
</view>
<wyb-table :headers="value.headers" :contents="value.material_list" 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"
@onButtonClick="onButtonClick"></wyb-table>
</view>
</view>
<!-- 操作按钮 -->
@ -59,22 +65,20 @@
data(){
return {
date: this.$shared.recordTime(new Date(), '-', 'date'), //
material_list: {}, //
show_material: false,
render_material_list: []
material_list: {}, //
show_material: false, //
render_material_list: {} //
}
},
onLoad(){
// todo table
// todo table
// MaterialList
uni.$on('addMaterialList', res => {
this.material_list = res;
})
},
onShow(){
let material_list = this.material_list;
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 = [{
@ -84,28 +88,60 @@
key: 'spec_name',
label: '规格'
},{
key: 'purchase_number',
label: '采购数量'
key: 'unit',
label: '单位'
},{
key: 'brand',
label: '品牌'
},{
key: 'tax_price',
label: '税前价'
label: '税价'
},{
key: 'non_tax_price',
label: '税后价'
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: '删除'};
list_arr.push(material_list[i].material_list[j]);
}
material_list[i].material_list = list_arr;
}
this.material_list = material_list;
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: {
// table-input todo
// table-input
onInputChange(event){
console.log("检测到table input被更改", event);
// this.contents[event.contentIndex][event.key].value = event.detailValue;
let supplier_id = event.lineData.supplier_id; // id
let material_index = event.contentIndex; //
let detailValue = event.detailValue; // table input
let supplier_item = this.render_material_list[supplier_id]; //
let material_item = supplier_item.material_list[material_index]; //
material_item.purchase_number.value = detailValue; //
console.log("render_material_list_change", this.render_material_list);
},
// table
onButtonClick(event){
console.log("event", event);
if(event.content.key == 'delete'){
let supplier_id = event.lineData.supplier_id; // id
let material_id = event.lineData.material_id; // id
let material_index = event.lineData.contentIndex; //
this.render_material_list[supplier_id].material_list.splice(material_index, 1);
delete this.material_list[supplier_id].material_list[material_id];
}
},
//
pickerChange(event){
@ -113,29 +149,45 @@
},
//
removeSupplier(key){
let material_list = {...this.material_list};
delete material_list[key];
this.material_list = material_list;
// render_material_list
let render_material_list = {...this.render_material_list};
delete render_material_list[key];
this.render_material_list = render_material_list;
// material_list
delete this.material_list[key];
//
this.show_material = Object.keys(this.material_list).length > 0;
},
//
save(_t){
let material_list = this.material_list;
let material_list = this.render_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
});
}
//
let arr = material.map(item => {
return {
m_id: item.material_id,
m_spec_id: item.spec_id,
tax_price: item.tax_price,
non_tax_price: item.non_tax_price,
purchase_number: item.purchase_number.value || 0
}
});
// :
// 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

1
pages/supply/index/index.vue

@ -33,6 +33,7 @@
}
},
onLoad(){
// todo
this.getData();
},
onReady(){

20
pages/supply/login/index.vue

@ -8,13 +8,29 @@
<u-icon name="account-fill"></u-icon>
<text class="lf-m-l-10 lf-font-28 lf-color-333">登录账号</text>
</view>
<input class="input" v-model="user_key" :adjust-position="false" :auto-blur="true" placeholder="请输入账号" @focus="inputFocus(170)" @blur="inputBlur" />
<input class="input"
maxlength="11"
v-model="user_key"
:adjust-position="false"
:auto-blur="true"
placeholder="请输入账号"
@focus="inputFocus(170)"
@blur="inputBlur" />
<!-- 密码 -->
<view class="lf-flex lf-m-b-10 lf-m-t-60">
<u-icon name="lock-fill"></u-icon>
<text class="lf-m-l-10 lf-font-28 lf-color-333">登录密码</text>
</view>
<input class="input" v-model="user_pw" :adjust-position="false" :auto-blur="true" placeholder="请输入密码" :password="true" @focus="inputFocus(220)" @blur="inputBlur" />
<input class="input"
maxlength="11"
v-model="user_pw"
:adjust-position="false"
:auto-blur="true"
placeholder="请输入密码"
:password="true"
@focus="inputFocus(220)"
@blur="inputBlur"
@confirm="login" />
</view>
<view>
<!-- 登录按钮 -->

Loading…
Cancel
Save