| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508 |
- <template>
- <view class="app-content">
- <view v-if="!$util.isEmpty(detailInfo)" class="info-content_box">
- <view class="module-com content-box">
- <view class="commodity-view">
- <view style="text-align:right;margin-right:20upx;padding-top:10upx;" v-if="detailInfo.book == 1 && detailInfo.status == 2 && parseFloat(detailInfo.actPrice) == 0">
- <button class="admin-button-com default middle" @click="usePrice(detailInfo,0)" style="margin-right:20upx;">使用填单价</button>
- <button class="admin-button-com default middle" @click="usePrice(detailInfo,1)" style="margin-right:20upx;">使用自带价</button>
- <button class="admin-button-com blue middle" @click="addItem(detailInfo)">添加花材</button>
- </view>
- <view class="commodity-list">
- <view v-for="(s, idx) in detailInfo.product" :key="idx" class="commodity-item" style="position:relative;">
- <image class="item-icon" :src="s.cover" alt="" @click="pageTo({url:'/admin/item/detail?id='+s.productId})" />
- <!-- <button v-if="detailInfo.book == 1 && detailInfo.status == 2 && parseFloat(detailInfo.actPrice) == 0" style="position:absolute;left:26upx;font-size:22upx;" class="admin-button-com default mini-btn" @click="changeOption(s)">更换</button> -->
- <button v-if="detailInfo.book == 1 && detailInfo.status == 2 && parseFloat(detailInfo.actPrice) == 0" style="position:absolute;top:95upx;left:26upx;font-size:22upx;" class="admin-button-com default mini-btn" @click="delOption(s)">删除</button>
- <text style="position:absolute;left:595upx;top:120upx;color:#CCCCCC;font-size:21upx;width:110upx;">剩 {{ s.stock }}</text>
- <text style="position:absolute;left:442upx;top:120upx;color:#CCCCCC;font-size:21upx;width:110upx;">成本{{ s.cost?parseFloat(s.cost):0 }}</text>
- <view class="item-info">
- <view class="info-line">
- <text class="item-name" @click="pageTo({url:'/admin/item/detail?id='+s.productId})">{{ s.name }}</text>
- <text class="item-price">
- <text class="unit"></text>
- <text class="price"><text>{{s.xhPreNum}}{{s.xhUnitName}}</text></text>
- </text>
- </view>
- <view class="info-line">
- <text class="item-type"></text>
- <view class="item-count" style="width:310upx;">
- <input type="number" class="num" :class="[Number(s.xhNum)>Number(s.stock) ? 'stock-red' : '']" v-model="s.xhNum" placeholder="数量" style="width:100upx;" />
- <input type="digit" class="price" :class="[Number(s.cost)>Number(s.currentHdPrice) ? 'cost-blue' : '']" v-model="s.currentHdPrice" placeholder="价格" style="width:120upx;" />
- <text style="display:inline-block;height:50upx;line-height:50upx;">价格</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="summary-bar">
- <view class="operate-view">合计 ¥{{ itemPrice }},成本 ¥{{ itemCost }},利润 ¥{{ parseFloat((Number(itemPrice)-Number(itemCost)).toFixed(2)) }}</view>
- </view>
- </view>
- </view>
- <view class="content-box price-detail">
- <view class="module-com input-line-wrap">
- <tui-list-cell class="line-cell" :hover="false">
- <view class="tui-title">客户</view>
- <view class="detail-price_box" style="font-size: 28upx;">{{ detailInfo.customName||'' }}</view>
- </tui-list-cell>
- <tui-list-cell class="line-cell" :hover="false">
- <view class="tui-title">商品金额</view>
- <view class="detail-price_box" style="font-size: 28upx;">¥{{itemPrice}}</view>
- </tui-list-cell>
- <tui-list-cell class="line-cell" :hover="false">
- <view class="tui-title">总计</view>
- <view class="detail-price_box red" style="font-size: 28upx;">¥{{allPrice}}</view>
- </tui-list-cell>
- <tui-list-cell class="line-cell" :hover="false">
- <view class="tui-title">预付金额</view>
- <view class="detail-price_box red" style="font-size: 28upx;">¥{{ detailInfo.bookPrice ? parseFloat(detailInfo.bookPrice) : 0}}</view>
- </tui-list-cell>
- <tui-list-cell class="line-cell" :hover="false">
- <view class="tui-title">结账</view>
- <view class="detail-price_box" style="font-size: 28upx;color:green;" v-if="settlePrice > 0">
- 退 ¥{{settlePrice}},确认后自动退款
- </view>
- <view class="detail-price_box" style="font-size: 28upx;color:red;" v-else-if="settlePrice < 0">
- 欠 ¥{{Math.abs(settlePrice)}},确认后变成欠款单
- </view>
- <view class="detail-price_box" style="font-size: 28upx;" v-else>0</view>
- </tui-list-cell>
- <tui-list-cell class="line-cell" :hover="false">
- <div class="tui-title">账单日期</div>
- <view class="detail-price_box">
- <button class="admin-button-com middle" :class="[todayBill == 1 ? 'blue' : 'default']" @click="todayBill=1">今天</button>
- <button class="admin-button-com middle" :class="[todayBill == 0 ? 'blue' : 'default']" @click="todayBill=0" style="margin-left:30upx;">昨天</button>
- </view>
- </tui-list-cell>
- <tui-list-cell class="line-cell" :hover="false">
- <div class="tui-title">允许低于成本</div>
- <view class="detail-price_box">
- <switch style="transform:scale(0.7,0.7)" :checked="lessCostCould == 0 ? false : true" @change="lessChangeFn" />
- </view>
- </tui-list-cell>
- </view>
- </view>
- </view>
- <view class="app-footer">
- <button class="admin-button-com big default" @click="goBack()" style="margin-left:10upx;">取消</button>
- <button class="admin-button-com big default" @click="savePrice()" style="margin:0 10upx 0 10upx;">保存</button>
- <button class="admin-button-com big blue" @click="commitItem()" style="margin-right:10upx;">确认提交</button>
- </view>
- </view>
- </template>
- <script>
- import { mapGetters } from "vuex";
- import TuiListCell from "@/components/plugin/list-cell";
- import { getArrivalDetail,arrival } from "@/api/order/index";
- import { modifyBookItem,delItem } from "@/api/order-item";
- export default {
- name: "arrival",
- components: {
- TuiListCell
- },
- mixins: [],
- data() {
- return {
- detailInfo: {},
- itemPrice:0,
- itemCost:0,
- settlePrice:0,
- sendCost:0,
- packCost:0,
- addSelectItem:1,
- lessCostCould:0,
- todayBill:1
- };
- },
- onLoad(){
- //返回上一页时不需要刷新
- let pages = getCurrentPages();
- let prevPage = pages[ pages.length - 2 ];
- prevPage.$vm.fromDetail = {status:1}
- },
- onShow() {
- if(this.addSelectItem == 1){
- this.init()
- this.addSelectItem = 0
- }
- },
- computed: {
- ...mapGetters({ loginInfo: "getLoginInfo" }),
- allPrice() {
- let price = 0
- this.itemPrice = 0
- this.itemCost = 0
- this.totalWeight = 0
- if (this.detailInfo && this.detailInfo.product) {
- for (const item of this.detailInfo.product) {
- if(item.currentHdPrice){
- let currentPrice = Number(item.xhNum) * Number(item.currentHdPrice)
- currentPrice = currentPrice.toFixed(2)
- this.itemPrice = Number(this.itemPrice) + Number(currentPrice)
- this.itemPrice.toFixed(2)
- let currentCost = Number(item.xhNum)*Number(item.cost)
- currentCost = currentCost.toFixed(2)
- this.itemCost = Number(this.itemCost)+Number(currentCost)
- this.itemCost.toFixed(2)
- }
- }
- }
- this.itemCost = parseFloat(this.itemCost.toFixed(2))
- this.itemPrice = parseFloat(this.itemPrice.toFixed(2))
- price = Number(this.itemPrice)
- if(Number(this.sendCost)>0){
- price = price + Number(this.sendCost)
- }
- if(Number(this.packCost)>0){
- price = price + Number(this.packCost)
- }
- price = parseFloat(price.toFixed(2))
- this.settlePrice = Number(this.detailInfo.bookPrice) - Number(price)
- this.settlePrice = parseFloat(this.settlePrice.toFixed(2))
- return price
- }
- },
- methods: {
- changeBill(e){
- this.todayBill = e.detail.value == true ? 1 : 0;
- },
- lessChangeFn(e){
- this.lessCostCould = e.detail.value == true ? 1 : 0;
- },
- usePrice(info,flag){
- if(info.product && !this.$util.isEmpty(info.product)){
- info.product.forEach((item,idx,array) => {
- if(flag == 0){
- item.currentHdPrice = item.itemModifyPrice
- }else{
- item.currentHdPrice = item.itemSalePrice
- }
- })
- this.$forceUpdate()
- }
- },
- changeOption(info){
- let id = info.id ? info.id : 0
- let orderSn = info.orderSn ? info.orderSn : ''
- this.$util.pageTo({url: '/admin/item/change?id='+id+'&orderSn='+orderSn})
- },
- addItem(info){
- let id = info.id ? info.id : 0
- this.$util.pageTo({url: '/admin/item/select?id='+id})
- },
- delOption(item){
- let that = this
- that.$util.confirmModal({content:'确认删除?'},() => {
- delItem({id:that.detailInfo.id,smallId:item.id}).then(res=>{
- if(res.code == 1){
- that.$msg(res.msg)
- that.init()
- }
- })
- })
- },
- goBack(){
- uni.navigateBack({ delta: 1 })
- },
- async init() {
- const res = await getArrivalDetail({ id: this.option.id })
- this.detailInfo = res.data;
- this.sendCost = res.data.sendCost ? parseFloat(res.data.sendCost) : 0
- this.packCost = res.data.packCost ? parseFloat(res.data.packCost) : 0
- },
- savePrice(){
- if(this.$util.isEmpty(this.detailInfo.product)){
- this.$msg('没有花材信息')
- return false
- }
- this.$util.confirmModal({content:'确认保存?'},() => {
- const data = this.detailInfo.product.map(ele => {
- return { orderSn: ele.orderSn, xhNum:ele.xhNum,xhUnitPrice:ele.currentHdPrice,id:ele.id}
- })
- modifyBookItem({data:data,id:this.detailInfo.id,packCost:this.packCost,sendCost:this.sendCost}).then(res=>{
- if(res.code == 1){
- this.$msg(res.msg)
- }
- })
- })
- },
- commitItem(){
- let product = []
- let hasError = false
- let that = this
- let hasLessCostPrice = false
- if (this.detailInfo && this.detailInfo.product) {
- for (const item of this.detailInfo.product) {
- if(item.currentHdPrice.length <= 0){
- this.$msg('请填写价格,价格要大于0')
- hasError = true;
- break;
- }
- if(this.$util.isEmpty(item.xhNum) || Number(item.xhNum) < 0){
- this.$msg('请填写到货数,没有填0')
- hasError = true;
- break;
- }
- let num = item.xhNum ? Number(item.xhNum) : 0
- let price = item.currentHdPrice ? Number(item.currentHdPrice) : 0
- let productId = item.productId || 0
- product = [...product,{productId,price,num}]
- if(Number(item.cost)>Number(item.currentHdPrice)){
- hasLessCostPrice = true
- }
- }
- }
- if(hasLessCostPrice == true && this.lessCostCould == 0){
- this.$msg('有花材低于成本销售,请允许')
- return false
- }
- if(hasError == true){
- return false
- }
- that.$util.confirmModal({content:'确认提交?'},() => {
- uni.showLoading({mask:true})
- arrival({id:that.option.id,product:JSON.stringify(product),packCost:that.packCost,sendCost:that.sendCost,todayBill:that.todayBill}).then(res=>{
- uni.hideLoading()
- if(res.code == 1){
- let id = res.data.id ? res.data.id : 0
- that.pageTo({url: '/pagesOrder/result?id='+id,type:2})
- }
- })
- })
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .info-content_box {
- padding: 15upx 20upx 120upx;
- & > .title {
- color: #666666;
- font-size: 28upx;
- font-weight: 600;
- padding: 30upx 3upx;
- }
- & .address-des_bx {
- display: flex;
- padding: 20upx 10upx 30upx 20upx;
- & > view:nth-child(1) {
- flex: 1;
- margin-top: 10upx;
- & > view:nth-child(1) {
- color: #333333;
- font-size: 32upx;
- font-weight: bold;
- }
- & > view:nth-child(2) {
- color: #666666;
- font-size: 28upx;
- font-weight: 400;
- margin-top: 20upx;
- }
- }
- & > view:nth-child(2) {
- display: flex;
- & .icondianhua1 {
- font-size: 50upx;
- color: #3385ff;
- margin-left: 0upx;
- }
- }
- }
- .bills-info_box {
- padding: 30upx 20upx 30upx;
- & > .order-info_box {
- display: flex;
- align-items: center;
- font-size: 26upx;
- font-weight: 400;
- margin-bottom: 5upx;
- & > view:nth-child(1) {
- color: #999999;
- width: 135upx;
- text-align: right;
- }
- & > view:nth-child(2) {
- color: #333333;
- }
- & > .price {
- flex: 1;
- font-size: 30upx;
- color: #333333;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- & .iconxiangyou {
- color: #999999;
- font-size: 25upx;
- margin-left: 12upx;
- }
- }
- }
- }
- .content-box {
- background-color: #ffffff;
- border-radius: 10upx;
- }
- .commodity-view {
- display: flex;
- flex-direction: column;
- .commodity-list {
- padding: 20upx;
- .commodity-item {
- display: flex;
- margin-bottom: 20upx;
- .item-icon {
- flex-shrink: 0;
- width: 140upx;
- height: 140upx;
- }
- .item-info {
- display: flex;
- flex-direction: column;
- justify-content: center;
- flex: 1;
- margin-left: 20upx;
- .info-line {
- margin-bottom: 20upx;
- display: flex;
- justify-content: space-between;
- align-items: flex-end;
- .item-name {
- color: black;
- font-size: 30upx;
- font-weight: 700;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- width:360upx;
- }
- .item-price {
- color: #333;
- font-size: 22upx;
- .price {
- font-size:25upx;
- }
- }
- .item-type {
- color: #999;
- font-size: 24upx;
- }
- .item-count {
- color: #666;
- font-size: 24upx;
- width:380upx;
- .price{
- text-align: center;
- width:150upx;
- height:20upx;
- border:2upx solid #cccccc;
- float:right;
- margin-right:30upx;
- }
- .num{
- text-align: center;
- width:150upx;
- height:20upx;
- border:2upx solid #cccccc;
- float:right;
- }
- .stock-red{
- border:4upx solid red;
- color:red;
- font-weight:bold;
- }
- .cost-blue{
- border:4upx solid blue;
- color:blue;
- font-weight:bold;
- }
- }
- }
- }
- }
- }
- .summary-bar {
- padding: 0 20upx;
- height: 90upx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- border-top: 1upx solid #eeeeee;
- .operate-view {
- width:100%;
- text-align: right;
- color: black;
- font-size:28upx;
- font-weight:bold;
- .iconfont {
- margin-right: 20upx;
- font-size: 40upx;
- }
- }
- .describe-view {
- display: flex;
- align-items: center;
- color: #333;
- font-size: 24upx;
- .price {
- font-weight: bold;
- font-size: 28upx;
- }
- }
- }
- }
- .shipping-address {
- display: flex;
- align-items: center;
- margin-top: 20upx;
- & > view:nth-child(1) {
- color: #999999;
- font-size: 28upx;
- font-weight: 400;
- display: inline-block;
- padding: 30upx 0 30upx 20upx;
- flex: 1;
- & > text {
- color: #333333;
- font-weight: 600;
- }
- }
- & > view:nth-child(2) {
- font-size: 60upx;
- color: #d6e7ff;
- margin-right: 10upx;
- }
- }
- .price-detail {
- margin-top: 20upx;
- margin-bottom: 20upx;
- }
- .detail-price_box {
- color: #333333;
- font-size: 22upx;
- text-align: right;
- flex: 1;
- font-weight: 600;
- &.red {
- color: #ff2842;
- }
- }
- }
- .app-footer {
- justify-content: space-evenly;
- z-index: 9999;
- .admin-button-com {
- width: 46%;
- }
- }
- </style>
|