提交 c931b43e 编写于 作者: M Mr Fan

订单出入库

上级 12dfc58c
{"type":"module"}
\ No newline at end of file
const BASE_URL = '服务器'
let http = {
get(url) {
uni.request({
url: BASE_URL + options.url,
method: options.method || 'GET',
data: options.data || {},
//带token发送请求
header: {
'x-token': uni.getStorageSync('token')
},
success: (res) => {
resolve(res)
},
timeout: 50000,
complete: options.complete ?? function() {
console.log('接口调用完成')
},
fail: (err) => {
reject(err)
}
})
},
post(url, data) {
uni.request({
url: BASE_URL + url,
method: 'POST',
header: {
'Content-Type': 'application/json',
token: uni.getStorageSync("TOKEN")
},
data: {
phone: this.phone
},
success: res => {
console.log(res);
return res
},
fail: () => {},
complete: () => {}
});
}
}
export {
http
}
import App from './App'
import http from '@/utils/http'
function getFristChar(str) {
let shouzi = ""
if (str.indexOf('') !== -1) {
shouzi = ''
} else if (str.indexOf('') !== -1) {
shouzi = ''
} else if (str.indexOf('') !== -1) {
shouzi = ''
} else if (str.indexOf('') !== -1) {
shouzi = ''
} else if (str.indexOf('') !== -1) {
shouzi = ''
} else if (str.indexOf('如本') !== -1) {
shouzi = ''
} else {
shouzi = str.length > 0 ? str.substr(0, 1) : ""
}
return shouzi
}
// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
...App
})
})
app.$mount()
// #endif
// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
const app = createSSRApp(App)
app.config.globalProperties.$http=http
app.config.globalProperties.$getFristChar = getFristChar
return {
app
}
......
......@@ -5,7 +5,31 @@
"style": {
"navigationBarTitleText": "本然ERP"
}
}
},
{
"path": "pages/erp/ruku",
"style": {
"navigationBarTitleText": "入库"
}
},
{
"path": "pages/erp/chuku",
"style": {
"navigationBarTitleText": "出库"
}
},
{
"path": "pages/erp/goods",
"style": {
"navigationBarTitleText": "库存"
}
},
{
"path": "pages/erp/goods_order",
"style": {
"navigationBarTitleText": ""
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
......
<template>
<view class="container" style="overflow: auto;">
<!-- <cu-custom bgColor="bg-gradual-blue" :isBack="true">
<block slot="content">入库单</block>
</cu-custom> -->
<view>
<view v-if="order_goods_list && order_goods_list.length>0">
<view class="cu-list menu-avatar no-padding text-center">
<view class="bg-white text-sm flex margin-top-xs text-center"
style="padding-right: 5px;border-bottom: 1px solid #f1f1f1;">
<view style="flex:1">商品</view>
<view style="width:50px;">数量</view>
<view style="width:40px;">折扣</view>
<view style="width:60px;">价格</view>
</view>
<view class="cu-item" v-for="(item, i) in order_goods_list" :key="i">
<view class="cu-avatar radius lg">{{item.shouzi}}</view>
<view class="content text-left">
<view class="text-grey">{{item.goodsName}}
</view>
<view class="text-gray">
<text class="text-green text-bold padding-right" v-if="item.goodsSpec">{{item.goodsSpec}}</text>
<text>¥ {{item.goodsPrice}}</text>
</view>
</view>
<view class="action" style="width:50px;">
<input placeholder="0" name="input" v-model="item.goodsNumber" @input="doUpdateOrderItemAmount" />
</view>
<view class="action" style="width:40px;">
<input name="input" v-model="item.discount" @input="doUpdateOrderItemAmount" />
</view>
<view class="action text-center" style="width:60px;">
¥ {{item.goodsAmount}}
</view>
</view>
</view>
<view class="bg-white margin-top">
<view class="cu-list menu text-left solid-top">
<view class="cu-item">
<view class="content">
总体折扣
</view>
<view class="action text-right">
<input placeholder="折扣" name="input" v-model="order_discount" />
</view>
<view class="action padding-left">
<button class='cu-btn bg-blue shadow' style="width: 100%;" @tap="doUpdateOrderItemDiscount">更新</button>
</view>
</view>
</view>
</view>
<view class="bg-white">
<view class="cu-list menu text-left solid-top">
<view class="cu-item">
<view class="content">
商品数量
</view>
<view class="action text-red text-bold text-lg">
{{order_info.goods_count}}
</view>
</view>
<view class="cu-item">
<view class="content">
总价
</view>
<view class="action text-red ">
<text class="padding-right-xs">¥</text> <text
class="text-bold text-lg">{{order_info.goodsAmount}}</text>
</view>
</view>
</view>
</view>
<view class="bg-white">
<view class="cu-list menu text-left solid-top">
<view class="cu-item">
<view class="content">
收货人
</view>
<view class="action text-red text-bold text-lg">
<input placeholder="收货人姓名" name="input" v-model="order_info.name" />
</view>
</view>
<view class="cu-item">
<view class="content">
收货电话
</view>
<view class="action text-red text-bold text-lg">
<input placeholder="收货电话" name="input" v-model="order_info.phone" />
</view>
</view>
<view class="cu-item">
<view class="content">
收货地址
</view>
<view class="action text-red text-bold text-lg">
<input placeholder="收货地址" name="input" v-model="order_info.addr" />
</view>
</view>
<view class="cu-item">
<view class="content">
快递名
</view>
<view class="action text-red text-bold text-lg">
<input placeholder="请输入快递名" name="input" v-model="order_info.kd_name" />
</view>
</view>
<view class="cu-item">
<view class="content">
快递单号
</view>
<view class="action text-red text-bold text-lg">
<input placeholder="请输入快递单号" name="input" v-model="order_info.kd_sn" />
</view>
</view>
</view>
</view>
</view>
<!-- <view class="margin-top bg-white padding arrow">
选择收货人
</view> -->
<view class="padding">
<view class="flex ">
<button class='cu-btn bg-blue shadow' style="width: 100%;" @tap="doShowGoodsModal">+ 加商品</button>
<!-- <button class='cu-btn bg-brown shadow' style="width: 50%;" @tap="doShowGoodsModal">选择收货人</button> -->
</view>
<view class="padding-top" v-if="order_goods_list && order_goods_list.length>0">
<button class='cu-btn lg bg-green shadow' style="width: 100%;" @tap="doSaveOrder">保存单据</button>
</view>
</view>
<view style="height: 100px;"></view>
</view>
<view class="cu-modal bottom-modal" :class="modalName=='goods_select_modal'?'show':''">
<view class="cu-dialog" @tap.stop="">
<view class="cu-bar bg-white">
<view class="action text-blue" @tap="hideModal">取消</view>
<view class="action text-green" @tap="doUpdateCard">确定</view>
</view>
<view class="grid col-4">
<view v-for="(item,index) in erpGoodsResult.records" class="padding-xs" :key="index">
<button class="cu-btn orange block" style="padding: 0;" :class="item.checked?'bg-orange':''"
@tap="doSelectGoods(item)" :data-value="item.value">
<text>{{item.goodsName}}</text>
<text class="padding-left-sm">
<text v-if="item.spec" class="text-sm">
<text v-if="item.spec == '大'" class="text-green text-bold">{{item.spec}}</text>
<text v-else-if="item.spec == '小'" class="text-blue text-bold">{{item.spec}}</text>
<text v-else>{{item.spec}}</text>
</text>
</text>
<view class="cu-tag sm round" :class="item.checked?'bg-white text-orange':'bg-orange'" v-if="item.hot">HOT
</view>
</button>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
search: {},
screen_show: 0,
list: [{
name: ''
}],
order_goods_list: [],
scrollLeft: 0,
cateList: [{
id: 1,
cate_name: '食用菌'
}, {
id: 2,
cate_name: '神马商城'
}],
kw: '',
modalName: 'goods_select_modal1',
merName: '',
phone: '',
page: 1,
currentDate: '',
loadding: true,
erpGoodsResult: {
records: []
},
categoryName: "食用菌",
goods_list: [{
value: 0,
name: '10元',
checked: false,
hot: false,
}],
order_discount: 100,
order_info: {
goods_count: 0,
goodsAmount: 0.00,
},
selected_goods_ids: [],
goods_list_by_key: {},
orderId: '',
}
},
onLoad(opt) {
this.orderId = opt.id
this.loadData();
if (this.orderId) {
this.loadOrderData()
}
},
onNavigationBarButtonTap() {
this.showModal()
},
methods: {
doShowGoodsModal() {
this.modalName = 'goods_select_modal'
},
doSelectGoods(item) {
item.checked = !item.checked
},
doUpdateCard() {
let that = this
// 取出选择的商品
let selected_goods_ids = []
this.erpGoodsResult.records.forEach(function(item) {
if (item.checked) {
selected_goods_ids.push(item.id)
}
})
// 先删除没有选择的订单商品
let i = that.order_goods_list.length
while (i--) {
let _item = that.order_goods_list[i]
let id_index = selected_goods_ids.indexOf(_item.id)
if (id_index == -1) {
that.order_goods_list.splice(i, 1)
} else {
selected_goods_ids.splice(id_index, 1)
}
}
// 处理新选择的商品
selected_goods_ids.forEach((item, i) => {
that.order_goods_list.push(that.goods_list_by_key[item])
})
this.hideModal()
this.doUpdateOrderItemAmount()
},
doUpdateOrderItemDiscount() {
this.order_discount = parseInt(this.order_discount)
if (this.order_discount > 100 || this.order_discount < 1) {
this.order_discount = 100
}
this.order_goods_list.forEach(item => {
item.discount = this.order_discount
})
this.doUpdateOrderItemAmount()
},
doUpdateOrderItemAmount() {
let that = this
this.order_goods_list.forEach(item => {
item.goodsNumber = parseInt(item.goodsNumber)
let discount = item.discount ? parseInt(item.discount) : 100
item.goodsAmount = item.goodsPrice * item.goodsNumber * discount / 100
})
// 计算总价格总数量
let order_cnt = 0
let order_amount = 0
this.order_goods_list.forEach(function(item, i) {
let discount = item.discount ? parseInt(item.discount) : 100
// console.log(item)
order_cnt += parseInt(item.goodsNumber)
let goodsAmount = item.goodsPrice * parseInt(item.goodsNumber) * discount / 100
that.order_goods_list[i]['goods_amount'] = goodsAmount
order_amount += goodsAmount
})
this.order_info.goods_count = order_cnt
this.order_info.goodsAmount = order_amount.toFixed(2)
},
doSaveOrder() {
let that = this
let url = '/erp/erpOrder/add';
let orderData = {
"amount": parseFloat(this.order_info.goodsAmount),
"erpOrderItemsList": [],
"orderType": "出库",
"goodsCnt": this.order_info.goods_count,
"orderSn": this.genOrderSn(),
"name": this.order_info.name,
"phone": this.order_info.phone,
"addr": this.order_info.addr,
"kd_name": this.order_info.kd_name,
"kd_sn": this.order_info.kd_sn,
}
orderData.erpOrderItemsList = that.order_goods_list
this.$http.post(url, orderData).then(res => {
if (res.statusCode == 200 && res.data.status == 'ok') {
uni.showToast({
title: '添加成功',
success() {
uni.redirectTo({
url: "/pages/erp/goods_order?type=ruku"
})
}
})
} else {
uni.showToast({
icon: 'error',
title: '出错了,请稍后再试',
})
}
})
},
loadOrderData() {
let that = this
let url = '/erp/erpOrder/queryById?id=' + this.orderId;
this.$http.get(url).then(res => {
if (res.data.result) {
that.order_info = {
goods_count: res.data.result.goodsCnt,
goodsAmount: res.data.result.amount,
name: res.data.result.name,
phone: res.data.result.phone,
addr: res.data.result.addr,
kd_name: res.data.result.kd_name,
kd_sn: res.data.result.kd_sn,
}
that.order_goods_list = res.data.result.erpOrderItemsList
that.order_goods_list.forEach(item => {
item.shouzi = that.$getFristChar(item.goodsName)
})
}
})
// url = '/erp/erpOrder/queryErpOrderItemsByMainId?id=' + this.orderId;
// this.$http.get(url).then(res => {
// that.order_goods_list = res.data.result
// that.order_goods_list.forEach(item => {
// item.shouzi = that.$getFristChar(item.goodsName)
// })
// })
},
reset() {
this.search.name = "";
this.search.phone = "";
this.search.start_time = this.getDate({
format: true
});
this.search.end_time = this.getDate({
format: true
});
},
searchResult() {
this.page = 1;
this.cate_id = 1
this.hideModal()
this.loadData()
},
hideModal() {
this.modalName = ""
},
getDate(type) {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
month = month > 9 ? month : '0' + month;;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
},
genOrderSn() {
let orderSn = this.getNowDate()
orderSn = orderSn.replace(/[- :]/g, '') + parseInt(Math.random(1000, 9999) * 1000)
return orderSn
},
getNowDate() {
var myDate = new Date;
var year = myDate.getFullYear(); //获取当前年
var mon = myDate.getMonth() + 1; //获取当前月
if (mon < 10) {
mon = "0" + mon;
}
var date = myDate.getDate(); //获取当前日
if (date < 10) {
date = "0" + date;
}
var hours = myDate.getHours(); //获取当前小时
if (hours < 10) {
hours = "0" + hours;
}
var minutes = myDate.getMinutes(); //获取当前分钟
if (minutes < 10) {
minutes = "0" + minutes;
}
var seconds = myDate.getSeconds(); //获取当前秒
if (seconds < 10) {
seconds = "0" + seconds;
}
var now = year + "-" + mon + "-" + date + " " + hours + ":" + minutes + ":" + seconds;
return now;
},
tabSelect(categoryName) {
this.categoryName = categoryName;
this.loadData()
},
loadData() {
let that = this
this.loadding = true
let url = '/erp/erpGoods/list';
this.$http.post(url, {
params: {
pageSize: 100,
categoryName: that.categoryName
}
}).then(res => {
this.loadding = false
let result = res.data.result;
let tmp_result = {
records: []
}
result.records.forEach(_row => {
_row.showzi = ""
if (_row.goodsName.indexOf('') !== -1) {
_row.shouzi = ''
} else if (_row.goodsName.indexOf('') !== -1) {
_row.shouzi = ''
} else if (_row.goodsName.indexOf('') !== -1) {
_row.shouzi = ''
} else if (_row.goodsName.indexOf('') !== -1) {
_row.shouzi = ''
} else if (_row.goodsName.indexOf('') !== -1) {
_row.shouzi = ''
} else if (_row.goodsName.indexOf('如本') !== -1) {
_row.shouzi = ''
} else {
_row.shouzi = _row.goodsName.length > 0 ? _row.goodsName.substr(0, 1) : ""
}
_row.checked = false
})
if (res.data.success) {
this.erpGoodsResult = res.data.result
}
this.erpGoodsResult.records.forEach(item => {
let discount = parseInt(item.sellingDiscount)
if (!discount) {
discount = 100
}
that.$set(this.goods_list_by_key, item.id, {
"createBy": "",
"createTime": "",
"goodsId": item.id,
"goodsName": item.goodsName,
"goodsNumber": 1,
"goodsPrice": item.sellingPrice,
"goodsAmount": item.sellingPrice,
"goodsSn": item.goodsSn,
"goodsSpec": item.spec,
"orderId": "",
shouzi: item.shouzi,
discount: 100,
})
})
}).catch(e => {
this.loadding = false
console.log(e)
})
},
}
}
</script>
<style lang="scss">
</style>
<template>
<view class="container" style="position: relative;">
<!-- <cu-custom bgColor="bg-gradual-blue" :isBack="true">
<block slot="content">库存商品</block>
</cu-custom> -->
<scroll-view scroll-y class="DrawerPage" :class="modalName=='viewModal'?'show':''">
<scroll-view class="bg-white nav fixed" style="top:40px" scroll-x scroll-with-animation :scroll-left="scrollLeft">
<view class="flex text-center ">
<view class="cu-item flex-sub" :class="item.cate_name==categoryName?'text-orange cur':''"
v-for="(item,index) in cateList" :key="index" @tap="tabSelect(item.cate_name)"
:data-categoryName="item.cate_name">
{{item.cate_name}}
</view>
</view>
</scroll-view>
<view style="height: 45px;"></view>
<view class="cu-list menu-avatar no-padding" v-if="erpGoodsResult.records && erpGoodsResult.records.length>0">
<view class="cu-item" v-for="(item, i) in erpGoodsResult.records" :key="i">
<view class="cu-avatar round lg">{{item.shouzi}}</view>
<view class="content">
<view class="text-grey text-xsl">{{item.goodsName}}</view>
<!-- <view class="text-gray text-sm">
{{item.goodsName}}
</view> -->
</view>
<view v-if="item.spec=='大'" class="action" style="font-size: 18px; font-weight: bold;">
{{item.spec}}
</view>
<view v-else-if="item.spec=='小'" class="action" style="font-size: 14px; font-weight: bold;">
{{item.spec}}
</view>
<view v-else class="action">
{{item.spec}}
</view>
<view class="action text-red text-lg text-bold">
{{item.goodsNumber}}
</view>
</view>
<view style="height: 80px;"></view>
</view>
<view v-else style="padding: 40px 10px 10px; text-align:center;">
<span v-if="loadding">数据加载中。。。</span>
<span v-else>无数据</span>
</view>
</scroll-view>
</view>
</template>
<script>
export default {
data() {
return {
search: {},
screen_show: 0,
list: [{
name: ''
}],
scrollLeft: 0,
cateList: [{
id: 1,
cate_name: '食用菌'
}, {
id: 2,
cate_name: '神马商城'
}],
kw: '',
modalName: '',
merName: '',
phone: '',
page: 1,
currentDate: '',
loadding: true,
erpGoodsResult: {},
categoryName: "食用菌"
}
},
onLoad(opt) {
this.cate_id = opt.cate_id
this.loadData();
// this.getCateList()
// 主页数据u
},
// onNavigationBarButtonTap() {
// // this.screen();
// this.showModal()
// },
methods: {
reset() {
this.search.name = "";
this.search.phone = "";
this.search.start_time = this.getDate({
format: true
});
this.search.end_time = this.getDate({
format: true
});
},
searchResult() {
// this.page = 1;
// this.productList = [];
// this.search.status = 1;
this.page = 1;
this.cate_id = 1
this.hideModal()
this.loadData()
// this.channel_list();
// this.screen();
},
tabSelect(categoryName) {
this.categoryName = categoryName;
this.loadData()
},
loadData() {
let that = this
this.loadding = true
let url = '/erp/erpGoods/list';
this.$http.post(url, {
params: {
pageSize: 100,
categoryName: that.categoryName
}
}).then(res => {
this.loadding = false
let result = res.data.result;
let tmp_result = {
records: []
}
// console.log(result.records)
result.records.forEach(_row => {
_row.shouzi = that.$getFristChar(_row.goodsName)
})
if (res.data.success) {
this.erpGoodsResult = res.data.result
}
}).catch(e => {
this.loadding = false
console.log(e)
})
},
// getCateList() {
// this.httpGet("merchant/listCate?page=").then(resp => {
// if (resp.data.status == "ok" && resp.data.result.list && resp.data.result.list.length > 0) {
// this.cateList = resp.data.result.list
// }
// });
// },
}
}
</script>
<style lang="scss">
</style>
<template>
<view>
<!-- <cu-custom bgColor="bg-gradual-blue" :isBack="true">
<block slot="content" v-if="type=='ruku'">入库单</block>
<block slot="content" v-else-if="type=='chuku'">出库单</block>
</cu-custom> -->
<scroll-view class="bg-white nav fixed" style="top:40px" scroll-x scroll-with-animation>
<view class="flex text-center ">
<view class="cu-item flex-sub" :class="item.type==type?'text-orange cur':''" v-for="(item,index) in cateList"
:key="index" @tap="tabSelect(item.type)" :data-categoryName="item.cate_name">
{{item.cate_name}}
</view>
</view>
</scroll-view>
<view style="height: 45px;"></view>
<view class="cu-list menu-avatar no-padding" v-if="erpOrderResult.records && erpOrderResult.records.length>0">
<view class="cu-item" v-for="(item, i) in erpOrderResult.records" :key="i" @tap="doViewOrder(item)">
<view class="cu-avatar round lg" v-if="type=='ruku'"></view>
<view class="cu-avatar round lg" v-else-if="type=='chuku'"></view>
<view class="content">
<view class="text-grey text-xsl">{{item.orderSn}}</view>
<view class="text-gray text-sm">
{{item.createTime}}
</view>
</view>
<view class="action">
<view class="text-red text-bold">{{item.goodsCnt}}</view>
<view class="text-gray text-sm">数量</view>
</view>
<view class="action">
<view class="text-red text-bold">{{item.amount}}</view>
<view class="text-gray text-sm">金额</view>
</view>
</view>
<view style="height: 80px;"></view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
type: '',
cateList: [{
type: 'ruku',
cate_name: '入库单'
}, {
type: 'chuku',
cate_name: '出库单'
}],
erpOrderResult: {
records: []
}
}
},
onLoad(opt) {
this.type = opt.type ? opt.type : 'ruku'
console.log("------")
console.log(opt)
this.loadData()
},
methods: {
tabSelect(type) {
this.type = type;
this.loadData()
},
loadData() {
let that = this
this.loadding = true
let url = '/erp/erpOrder/list';
this.$http.post(url, {
params: {
pageSize: 100,
orderType: this.type == 'ruku' ? '入库' : '出库'
}
}).then(res => {
this.loadding = false
let result = res.data.result;
let tmp_result = {
records: []
}
result.records.forEach(_row => {
// _row.showzi = ""
// if (_row.goodsName.indexOf('卫') !== -1) {
// _row.shouzi = '卫'
// } else if (_row.goodsName.indexOf('响') !== -1) {
// _row.shouzi = '响'
// } else if (_row.goodsName.indexOf('韵') !== -1) {
// _row.shouzi = '韵'
// } else if (_row.goodsName.indexOf('响') !== -1) {
// _row.shouzi = '响'
// } else if (_row.goodsName.indexOf('阳') !== -1) {
// _row.shouzi = '阳'
// } else if (_row.goodsName.indexOf('本') !== -1) {
// _row.shouzi = '本'
// } else {
// _row.shouzi = _row.goodsName.length > 0 ? _row.goodsName.substr(0, 1) : ""
// }
// tmp_result.records.forEach(__row => {
// })
// console.log(_row.shouzi)
})
if (res.data.success) {
this.erpOrderResult = res.data.result
}
}).catch(e => {
this.loadding = false
console.log(e)
})
},
doViewOrder(item) {
let url = "";
if (item.orderType == '入库') {
url = "/pages/erp/ruku?id=" + item.id
} else {
url = "/pages/erp/chuku?id=" + item.id
}
uni.navigateTo({
url: url
})
}
}
}
</script>
<style>
</style>
<template>
<view class="container" style="overflow: auto;">
<!-- <cu-custom bgColor="bg-gradual-blue" :isBack="true">
<block slot="content">入库单</block>
</cu-custom> -->
<view>
<view v-if="order_goods_list && order_goods_list.length>0">
<view class="cu-list menu-avatar no-padding text-center">
<view class="bg-white text-sm flex margin-top-xs text-center"
style="padding-right: 5px;border-bottom: 1px solid #f1f1f1;">
<view style="flex:1">商品</view>
<view style="width:50px;">数量</view>
<view style="width:60px;">价格</view>
</view>
<view class="cu-item" v-for="(item, i) in order_goods_list" :key="i">
<view class="cu-avatar radius lg">{{item.shouzi}}</view>
<view class="content text-left">
<view class="text-grey">{{item.goodsName}}
</view>
<view class="text-gray">
<text class="text-green text-bold padding-right" v-if="item.goodsSpec">{{item.goodsSpec}}</text>
<text>¥ {{item.goodsPrice}}</text>
</view>
</view>
<view class="action" style="width:50px;">
<input placeholder="0" name="input" v-model="item.goodsNumber" @input="doUpdateOrderItemAmount" />
</view>
<view class="action text-center" style="width:60px;">
¥ {{item.goodsAmount}}
</view>
</view>
</view>
<view class="bg-white">
<view class="cu-list menu text-left solid-top">
<view class="cu-item">
<view class="content">
商品数量
</view>
<view class="action text-red text-bold text-lg">
{{order_info.goods_count}}
</view>
</view>
<view class="cu-item">
<view class="content">
总价
</view>
<view class="action text-red ">
<text class="padding-right-xs">¥</text> <text
class="text-bold text-lg">{{order_info.goodsAmount}}</text>
</view>
</view>
</view>
</view>
</view>
<!-- <view class="margin-top bg-white padding arrow">
选择收货人
</view> -->
<view class="padding">
<view class="flex ">
<button class='cu-btn bg-blue shadow' style="width: 100%;" @tap="doShowGoodsModal">+ 加商品</button>
<!-- <button class='cu-btn bg-brown shadow' style="width: 50%;" @tap="doShowGoodsModal">选择收货人</button> -->
</view>
<view class="padding-top" v-if="order_goods_list && order_goods_list.length>0">
<button class='cu-btn lg bg-green shadow' style="width: 100%;" @tap="doSaveOrder">保存单据</button>
</view>
</view>
</view>
<view class="cu-modal bottom-modal" :class="modalName=='goods_select_modal'?'show':''">
<view class="cu-dialog" @tap.stop="">
<view class="cu-bar bg-white">
<view class="action text-blue" @tap="hideModal">取消</view>
<view class="action text-green" @tap="doUpdateCard">确定</view>
</view>
<view class="grid col-4">
<view v-for="(item,index) in erpGoodsResult.records" class="padding-xs" :key="index">
<button class="cu-btn orange block" style="padding: 0;" :class="item.checked?'bg-orange':''"
@tap="doSelectGoods(item)" :data-value="item.value">
<text>{{item.goodsName}}</text>
<text class="padding-left-sm">
<text v-if="item.spec" class="text-sm">
<text v-if="item.spec == '大'" class="text-green text-bold">{{item.spec}}</text>
<text v-else-if="item.spec == '小'" class="text-blue text-bold">{{item.spec}}</text>
<text v-else>{{item.spec}}</text>
</text>
</text>
<view class="cu-tag sm round" :class="item.checked?'bg-white text-orange':'bg-orange'" v-if="item.hot">HOT
</view>
</button>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
search: {},
screen_show: 0,
list: [{
name: ''
}],
order_goods_list: [],
scrollLeft: 0,
cateList: [{
id: 1,
cate_name: '食用菌'
}, {
id: 2,
cate_name: '神马商城'
}],
kw: '',
modalName: 'goods_select_modal1',
merName: '',
phone: '',
page: 1,
currentDate: '',
loadding: true,
erpGoodsResult: {
records: []
},
categoryName: "食用菌",
goods_list: [{
value: 0,
name: '10元',
checked: false,
hot: false,
}],
order_discount: 100,
order_info: {
goods_count: 0,
goodsAmount: 0.00,
},
selected_goods_ids: [],
goods_list_by_key: {},
orderId: '',
}
},
onLoad(opt) {
this.orderId = opt.id
this.loadData();
if (this.orderId) {
this.loadOrderData()
}
},
onNavigationBarButtonTap() {
this.showModal()
},
methods: {
doShowGoodsModal() {
this.modalName = 'goods_select_modal'
},
doSelectGoods(item) {
item.checked = !item.checked
},
doUpdateCard() {
let that = this
// 取出选择的商品
let selected_goods_ids = []
this.erpGoodsResult.records.forEach(function(item) {
if (item.checked) {
selected_goods_ids.push(item.id)
}
})
// 先删除没有选择的订单商品
let i = that.order_goods_list.length
while (i--) {
let _item = that.order_goods_list[i]
let id_index = selected_goods_ids.indexOf(_item.id)
if (id_index == -1) {
that.order_goods_list.splice(i, 1)
} else {
selected_goods_ids.splice(id_index, 1)
}
}
// 处理新选择的商品
selected_goods_ids.forEach((item, i) => {
that.order_goods_list.push(that.goods_list_by_key[item])
})
this.hideModal()
this.doUpdateOrderItemAmount()
},
doUpdateOrderItemDiscount() {
this.order_discount = parseInt(this.order_discount)
if (this.order_discount > 100 || this.order_discount < 1) {
this.order_discount = 100
}
this.order_goods_list.forEach(item => {
item.discount = this.order_discount
})
this.doUpdateOrderItemAmount()
},
doUpdateOrderItemAmount() {
let that = this
this.order_goods_list.forEach(item => {
item.goodsNumber = parseInt(item.goodsNumber)
let discount = item.discount ? parseInt(item.discount) : 100
item.goodsAmount = item.goodsPrice * item.goodsNumber * discount / 100
})
// 计算总价格总数量
let order_cnt = 0
let order_amount = 0
this.order_goods_list.forEach(function(item, i) {
let discount = item.discount ? parseInt(item.discount) : 100
// console.log(item)
order_cnt += parseInt(item.goodsNumber)
let goodsAmount = item.goodsPrice * parseInt(item.goodsNumber) * discount / 100
that.order_goods_list[i]['goods_amount'] = goodsAmount
order_amount += goodsAmount
})
this.order_info.goods_count = order_cnt
this.order_info.goodsAmount = order_amount.toFixed(2)
},
doSaveOrder() {
let that = this
let url = '/erp/erpOrder/add';
let orderData = {
"amount": parseFloat(this.order_info.goodsAmount),
"erpOrderItemsList": [],
"orderType": "入库",
"goodsCnt": this.order_info.goods_count,
"orderSn": this.genOrderSn(),
}
orderData.erpOrderItemsList = that.order_goods_list
this.$http.post(url, orderData).then(res => {
if (res.statusCode == 200 && res.data.status == 'ok') {
uni.showToast({
title: '添加成功',
success() {
uni.redirectTo({
url: "/pages/erp/goods_order?type=ruku"
})
}
})
} else {
uni.showToast({
icon: 'error',
title: '出错了,请稍后再试',
})
}
})
},
loadOrderData() {
let that = this
let url = '/erp/erpOrder/queryById?id=' + this.orderId;
this.$http.get(url).then(res => {
if (res.data.result) {
that.order_info = {
goods_count: res.data.result.goodsCnt,
goodsAmount: res.data.result.amount,
name: res.data.result.name,
phone: res.data.result.phone,
addr: res.data.result.addr,
kd_name: res.data.result.kd_name,
kd_sn: res.data.result.kd_sn,
}
that.order_goods_list = res.data.result.erpOrderItemsList
that.order_goods_list.forEach(item => {
item.shouzi = that.$getFristChar(item.goodsName)
})
}
})
},
reset() {
this.search.name = "";
this.search.phone = "";
this.search.start_time = this.getDate({
format: true
});
this.search.end_time = this.getDate({
format: true
});
},
searchResult() {
this.page = 1;
this.cate_id = 1
this.hideModal()
this.loadData()
},
hideModal() {
this.modalName = ""
},
getDate(type) {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
month = month > 9 ? month : '0' + month;;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
},
genOrderSn() {
let orderSn = this.getNowDate()
orderSn = orderSn.replace(/[- :]/g, '') + parseInt(Math.random(1000, 9999) * 1000)
return orderSn
},
getNowDate() {
var myDate = new Date;
var year = myDate.getFullYear(); //获取当前年
var mon = myDate.getMonth() + 1; //获取当前月
if (mon < 10) {
mon = "0" + mon;
}
var date = myDate.getDate(); //获取当前日
if (date < 10) {
date = "0" + date;
}
var hours = myDate.getHours(); //获取当前小时
if (hours < 10) {
hours = "0" + hours;
}
var minutes = myDate.getMinutes(); //获取当前分钟
if (minutes < 10) {
minutes = "0" + minutes;
}
var seconds = myDate.getSeconds(); //获取当前秒
if (seconds < 10) {
seconds = "0" + seconds;
}
var now = year + "-" + mon + "-" + date + " " + hours + ":" + minutes + ":" + seconds;
return now;
},
tabSelect(categoryName) {
this.categoryName = categoryName;
this.loadData()
},
loadData() {
let that = this
this.loadding = true
let url = '/erp/erpGoods/list';
this.$http.post(url, {
params: {
pageSize: 100,
categoryName: that.categoryName
}
}).then(res => {
this.loadding = false
let result = res.data.result;
let tmp_result = {
records: []
}
result.records.forEach(_row => {
_row.showzi = ""
if (_row.goodsName.indexOf('') !== -1) {
_row.shouzi = ''
} else if (_row.goodsName.indexOf('') !== -1) {
_row.shouzi = ''
} else if (_row.goodsName.indexOf('') !== -1) {
_row.shouzi = ''
} else if (_row.goodsName.indexOf('') !== -1) {
_row.shouzi = ''
} else if (_row.goodsName.indexOf('') !== -1) {
_row.shouzi = ''
} else if (_row.goodsName.indexOf('如本') !== -1) {
_row.shouzi = ''
} else {
_row.shouzi = _row.goodsName.length > 0 ? _row.goodsName.substr(0, 1) : ""
}
_row.checked = false
})
if (res.data.success) {
this.erpGoodsResult = res.data.result
}
this.erpGoodsResult.records.forEach(item => {
let discount = parseInt(item.sellingDiscount)
if (!discount) {
discount = 100
}
that.$set(this.goods_list_by_key, item.id, {
"createBy": "",
"createTime": "",
"goodsId": item.id,
"goodsName": item.goodsName,
"goodsNumber": 1,
"goodsPrice": item.sellingPrice,
"goodsAmount": item.sellingPrice,
"goodsSn": item.goodsSn,
"goodsSpec": item.spec,
"orderId": "",
shouzi: item.shouzi,
discount: 100,
})
})
}).catch(e => {
this.loadding = false
console.log(e)
})
},
}
}
</script>
<style lang="scss">
</style>
......@@ -8,7 +8,7 @@
</view>
<view class="cu-list grid col-4 text-sm">
<view class="cu-item animation-slide-bottom" :style="[{animationDelay: (index + 1)*0.05 + 's'}]"
v-for="(item,index) in erp_funcs" :key="index" @tap="goPage(item.page)">
v-for="(item,index) in erp_funcs" :key="index" @tap="goPage(item.url)">
<view class="text-center">
<i :class="item.icon"></i>
<view class="">{{item.title}}</view>
......@@ -23,7 +23,7 @@
</view>
<view class="cu-list grid col-4 text-sm">
<view class="cu-item animation-slide-bottom" :style="[{animationDelay: (index + 1)*0.05 + 's'}]"
v-for="(item,index) in erp_funcs1" :key="index" @tap="goPage(item.page)">
v-for="(item,index) in erp_funcs1" :key="index" @tap="goPage(item.url)">
<view class="text-center">
<i class=" cuIcon-file"></i>
<view class="">{{item.title}}</view>
......@@ -72,7 +72,8 @@
},
methods: {
goPage(page) {
goPage(page) {
console.log(page)
if (!page) {
return false;
}
......
let BASE_URL = 'http://localhost:8084';
const http = {
request(
url,
data,
method,
header = {},
) {
let token = uni.getStorageSync('token') || '';
if (!url) return;
return new Promise((resolve, reject) => {
uni.request({
url: BASE_URL + url,
method,
data,
header: {
token,
...header
},
success: (res) => {
resolve(res)
},
fail: (err) => {
reject(err);
}
});
})
},
get(url, param) {
let header = {}
let method = "GET"
return new Promise((resolve, reject) => {
this.request(url, param, method, header).then(res => {
resolve(res)
}).catch(e => {
reject(e)
})
})
},
post(url, param) {
console.log("迫使t")
let header = {}
let method = "POST"
return new Promise((resolve, reject) => {
this.request(url, param, method, header).then(res => {
resolve(res)
}).catch(e => {
reject(e)
})
})
}
}
export default http;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册