shish il y a 2 ans
Parent
commit
d3ead7b63e

+ 2 - 0
ghs/src/cool/request/index.js

@@ -38,12 +38,14 @@ import statBook from '@/service/stat-book/index';
 import ghs from '@/service/ghs/index';
 import cg from '@/service/cg/index';
 import purchaseOrder from '@/service/purchase-order/index';
+import purchaseOrderItem from '@/service/purchase-order-item/index';
 
 export function SET_SERVICE({ store }) {
 	// const files = require.context('@/service/', true, /\.js$/);
 	// const ignore = ['./request.js'];
 
 	let modules = {
+		purchaseOrderItem,
 		cg,
 		purchaseOrder,
 		common,

+ 1 - 0
ghs/src/mock/userInfo.js

@@ -155,6 +155,7 @@ let menu = {
 		{id: '1400',parentId: null,name: '采购',type: 0,icon: 'icondingdanguanli',orderNum: 3,router: '/in/list',viewPath: 'views/in/list.vue',keepAlive: 1},
 		{id: '1405',parentId: 1400,name: '采购记录',type: 1,icon: 'icondingdanguanli',orderNum: 3,router: '/in/list',viewPath: 'views/in/list.vue',keepAlive: 1},
 		{id: '1410',parentId: 1400,name: '新增采购',type: 1,icon: 'icondingdanguanli',orderNum: 3,router: '/in/add',viewPath: 'views/in/add.vue',keepAlive: 1},
+		{id: '1415',parentId: 1400,name: '改价入库',type: 1,icon: 'icondingdanguanli',orderNum: 3,router: '/in/change',viewPath: 'views/in/change.vue',keepAlive: 1},
 		{id: '4',parentId: null,name: '花材',type: 0,icon: 'iconshangpinguanli',orderNum: 4,router: '/item/list',viewPath: 'views/item/list.vue',keepAlive: 1},
 		{id: '405',	parentId: '4',name: '花材列表',type: 1,icon: 'icon-user',orderNum: 4,router: '/item/list',viewPath: 'views/item/list.vue',keepAlive: 1},
 		{id: '401',parentId: '4',name: '花材分类',type: 1,icon: 'icon-user',orderNum: 4,router: '/item-class/list',viewPath: 'views/item-class/list.vue',keepAlive: 1},

+ 8 - 0
ghs/src/service/product/index.js

@@ -28,6 +28,14 @@ list(data) {
   });
  }
 
+ batchChangePrice(data) {
+  return this.request({
+    url: '/batch-change-price',
+    method: 'POST',
+    data: data
+  });
+ }
+
   // 新增花材  姜枫2021.06.22
   addProduct(data) {
       return this.request({

+ 21 - 0
ghs/src/service/purchase-order-item/index.js

@@ -0,0 +1,21 @@
+import { BaseService, Service } from '@/cool';
+@Service('purchase-order-item')
+export class PurchaseOrderService extends BaseService {
+
+	getItemList(data) {
+		return this.request({
+			url: '/get-item-list',
+			params: data
+		});
+	}
+
+    saveCgPrice(data) {
+		return this.request({
+			url: '/save-cg-price',
+			method: 'POST',
+			data: data
+		});
+	}
+
+}
+export default new PurchaseOrderService();

+ 7 - 0
ghs/src/service/purchase-order/index.js

@@ -17,5 +17,12 @@ export class PurchaseOrderService extends BaseService {
 		});
 	}
 
+	confirmPutIn(data) {
+		return this.request({
+			url: '/confirm-put-in',
+			params: data
+		});
+	}
+
 }
 export default new PurchaseOrderService();

+ 6 - 1
ghs/src/utils/util.js

@@ -121,6 +121,10 @@ const isFunction = obj => {
 	return typeof obj == 'object' && obj.constructor == Function;
 };
 
+const isMoney = money =>{
+	return /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(money)
+}
+
 /** *
  * 对象参数转为url参数
  * @parmas query 拼接得参数对象
@@ -216,5 +220,6 @@ export default {
 	$checkName,
 	$formatDate,
 	getShortUrl,
-    checkPhone
+    checkPhone,
+	isMoney
 };

+ 248 - 0
ghs/src/views/in/change.vue

@@ -0,0 +1,248 @@
+<template>
+	<div>
+        <div v-if="id == 0">
+            <div style="width:35vw;margin:0 auto;margin-top:10px;text-align:center;font-size:25px;">请选择订单</div>
+        </div>
+        <div style="width:62vw;margin:0 auto;margin-top:10px;" v-else>
+            <el-table :data="flowersList" style="width:100%">
+                <el-table-column prop="name" label="名称">
+                    
+                </el-table-column>
+                <el-table-column prop="suggestHjPrice" label="大客价">
+                    <template slot-scope="scope">
+                        <el-input placeholder="请填写大客价" @focus="scope.row.suggestHjPrice=''" v-model="scope.row.suggestHjPrice" size="small"></el-input>
+                    </template>
+                </el-table-column>
+                <el-table-column prop="suggestPrice" label="批发价">
+                    <template slot-scope="scope">
+                        <el-input placeholder="请填写批发价" @focus="scope.row.suggestPrice=''" v-model="scope.row.suggestPrice" size="small" @input="linkChange(scope.$index)"
+                        style="border:1px solid #CCCCCC;border-radius: 5px;"></el-input>
+                    </template>
+                </el-table-column>
+                <el-table-column prop="suggestSkPrice" label="零售价">
+                    <template slot-scope="scope">
+                        <el-input placeholder="请填写零售价" @focus="scope.row.suggestSkPrice=''" v-model="scope.row.suggestSkPrice" size="small"></el-input>
+                    </template>
+                </el-table-column>
+                <el-table-column prop="bigPrice" label="进货价">
+                    <template slot-scope="scope">
+                        {{ scope.row.bigPrice?parseFloat(scope.row.bigPrice):0 }}
+                    </template>
+                </el-table-column>
+                <el-table-column prop="cost" label="成本价">
+                    <template slot-scope="scope">
+                        {{ scope.row.cost?parseFloat(scope.row.cost):0 }}
+                    </template>
+                </el-table-column>
+                <el-table-column prop="beforeModifyPrice" label="旧批发价">
+                    <template slot-scope="scope">
+                        {{ scope.row.beforeModifyPrice?parseFloat(scope.row.beforeModifyPrice):0 }}
+                    </template>
+                </el-table-column>
+                <el-table-column prop="itemNum" label="入库数">
+                    <template slot-scope="scope">
+                        {{ scope.row.itemNum?parseFloat(scope.row.itemNum):0 }}
+                    </template>
+                </el-table-column>
+                <el-table-column prop="beforeModifyStock" label="入库前库存">
+                    <template slot-scope="scope">
+                        {{ scope.row.beforeModifyStock?parseFloat(scope.row.beforeModifyStock):0 }}
+                    </template>
+                </el-table-column>
+            </el-table>
+            <div style="text-align:left;margin-top:18px;">
+                <el-button @click="goBackFn" plain>稍后入库</el-button>
+                <el-button v-if="info.status == 3" type="success" @click="savePrice">保存价格,稍后入库</el-button>
+                <el-button v-if="info.status == 3" type="danger" @click="confirmIn">仅入库不改价</el-button>
+                <el-button v-if="info.status != 3" type="primary" @click="commitChange(2)">确认改价</el-button>
+                <el-button v-if="info.status == 3" type="primary" @click="commitChange(1)">改价并入库</el-button>
+            </div>
+        </div>
+	</div>
+</template>
+<script>
+import { mapGetters } from 'vuex';
+export default {
+    name: 'change',
+    components: {
+    },
+    data() {
+        return {
+            flowersList:[],
+            info:{},
+            id:0,
+            orderSn:''
+        };
+    },
+    computed: {
+        ...mapGetters(['shopInfo', 'userInfo'])
+    },
+    created() {
+        if(this.$route.query.id){
+            this.id = this.$route.query.id
+            this.getItemList()
+        }
+        if(this.$route.query.orderSn){
+            this.orderSn = this.$route.query.orderSn
+            this.getDetail()
+        }
+    },
+    methods: {
+		confirmIn(){
+			let that = this
+            this.$confirm('确认只入库不改价?', '提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning' }).then(() => {
+				//uni.showLoading({mask:true})
+                confirmPutIn
+                this.$service.purchaseOrder.confirmPutIn({id:that.id}).then(data => {
+					//uni.hideLoading()
+                    if(data.status == 4){
+                        that.$notify({ title: '成功', message: '操作成功', type: 'success'})
+                        setTimeout(function(){
+                            //that.pageTo({url: '/pagesPurchase/info?orderSn='+that.info.orderSn,type:2})
+                        },1100)
+                    }
+				})
+			})
+		},
+		savePrice(){
+			let that = this
+			let hasError = false
+			let errorHint = ''
+			this.flowersList.forEach(function(item){
+				if(that.$util.isMoney(item.suggestPrice) == false){
+					let name = item.name
+					errorHint = '请填写 '+name+' 批发价'
+					hasError = true
+				}
+				if(that.$util.isMoney(item.suggestSkPrice) == false){
+					let name = item.name
+					errorHint = '请填写 '+name+' 零售价'
+					hasError = true
+				}
+				if(that.$util.isMoney(item.suggestHjPrice) == false){
+					let name = item.name
+					errorHint = '请填写 '+name+' 大客价'
+					hasError = true
+				}
+			})
+			if(hasError){
+				this.$msg(errorHint)
+				return false
+			}
+			this.$confirm('确认保存?', '提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning' }).then(() => {
+				let targetId = this.id ? this.id : 0
+				let newProduct = this.flowersList.map((ele) => {
+					return {id:ele.id,savePrice:ele.suggestPrice,saveSkPrice:ele.suggestSkPrice,saveHjPrice:ele.suggestHjPrice}
+				})
+				//uni.showLoading({mask:true})
+                this.$service.purchaseOrderItem.saveCgPrice({data:JSON.stringify(newProduct),cgId:targetId}).then(data => {
+					//uni.hideLoading()
+                    that.$notify({ title: '成功', message: '操作成功', type: 'success'})
+                    setTimeout(function(){
+                        //uni.navigateBack()
+                    },1300)
+				})
+			})
+		},
+		goBackFn() {
+			//uni.navigateBack({})
+		},
+		commitChange(type){
+			let that = this
+			let hasError = false
+			let errorHint = ''
+			this.flowersList.forEach(function(item){
+				if(that.$util.isMoney(item.suggestPrice) == false){
+					let name = item.name
+					errorHint = '请填写 '+name+' 批发价'
+					hasError = true
+				}
+				if(that.$util.isMoney(item.suggestSkPrice) == false){
+					let name = item.name
+					errorHint = '请填写 '+name+' 零售价'
+					hasError = true
+				}
+				if(that.$util.isMoney(item.suggestHjPrice) == false){
+					let name = item.name
+					errorHint = '请填写 '+name+' 大客价'
+					hasError = true
+				}
+			})
+			if(hasError){
+				this.$msg(errorHint)
+				return false
+			}
+			let hint = '确认提交?'
+			if(type == 1){
+				hint = '确认改价并入库?'
+			}
+			if(type == 2){
+				hint = '确认改价?'
+			}
+			this.$confirm(hint, '提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning' }).then(() => {
+				that.commitModify()
+			})
+		},
+		commitModify(){
+			let that = this
+			let targetId = this.id ||0
+			let newProduct = this.flowersList.map((ele) => {
+				return {id:ele.productId,price:ele.suggestPrice,skPrice:ele.suggestSkPrice,hjPrice:ele.suggestHjPrice}
+			})
+			//uni.showLoading({mask:true})
+            that.$service.product.batchChangePrice({data:JSON.stringify(newProduct),changeType:'cg',targetId:targetId,appVersion:1}).then(data => {
+				//uni.hideLoading()
+                that.$notify({ title: '成功', message: '操作成功', type: 'success'})
+                setTimeout(function(){
+                    //that.pageTo({url: '/pagesPurchase/info?orderSn='+that.info.orderSn,type:2})
+                },1100)
+			})
+		},
+		linkChange(i){
+			if(this.flowersList[i].suggestPrice && Number(this.flowersList[i].suggestPrice)>0){
+				let skMore = this.flowersList[i].skMore ? Number(this.flowersList[i].skMore) : 0
+				let hjAddPrice = this.flowersList[i].hjAddPrice ? Number(this.flowersList[i].hjAddPrice) : 0
+				let addPrice = this.flowersList[i].addPrice ? Number(this.flowersList[i].addPrice) : 0
+
+				let skAddNum = Number(skMore) - Number(addPrice)
+				skAddNum = skAddNum.toFixed(2)
+				let skAmount = Number(skAddNum) + Number(this.flowersList[i].suggestPrice)
+				if(skAmount>0){
+					skAmount = skAmount.toFixed(2)
+					skAmount = parseFloat(skAmount)
+					this.flowersList[i].suggestSkPrice = skAmount
+				}else{
+					this.flowersList[i].suggestSkPrice = ''
+				}
+
+				let hjSubNum = Number(addPrice) - Number(hjAddPrice)
+				hjSubNum = hjSubNum.toFixed(2)
+				let hjAmount = Number(this.flowersList[i].suggestPrice) - Number(hjSubNum)
+				if(hjAmount > 0){
+					hjAmount = hjAmount.toFixed(2)
+					hjAmount = parseFloat(hjAmount)
+					this.flowersList[i].suggestHjPrice = hjAmount
+				}else{
+					this.flowersList[i].suggestHjPrice = ''	
+				}
+			}else{
+				this.flowersList[i].suggestSkPrice = ''
+				this.flowersList[i].suggestHjPrice = ''
+			}
+		},
+        getItemList(){
+            this.$service.purchaseOrderItem.getItemList({id:this.id}).then(data => {
+                this.flowersList = data.list
+            })
+        },
+        getDetail(){
+            this.$service.purchaseOrder.detail({orderSn:this.orderSn}).then(data => {
+                this.info = data
+            })
+        }
+    }
+};
+</script>
+
+<style lang="scss" scoped>
+</style>

+ 12 - 6
ghs/src/views/in/list.vue

@@ -55,7 +55,7 @@
       </template>
 
       <template #slot-column-option="{scope}">
-        <el-button @click.stop="printOrder(scope.row)" size="small" type="primary">改价入库</el-button>
+        <el-button @click.stop="changePrice(scope.row)" size="small" type="primary">改价入库</el-button>
         <el-button @click.stop="detailShowFn(scope.row)" size="small" type="success">详情</el-button>
         <el-button @click.stop="detailShowFn(scope.row)" size="small" type="primary">取消</el-button>
       </template>
@@ -128,6 +128,12 @@ export default {
     selfGetCancel(id) {
       this.$refs[`popover-` + id][1].doClose();
     },
+    changePrice(info){
+      let query = {};
+			query.orderSn = info.orderSn
+			query.id = info.id
+      this.$router.push({path: '/in/change',query})
+    },
     detailShowFn(item) {
       this.optionData = item;
       setTimeout(() => {
@@ -253,11 +259,11 @@ export default {
           ])
           .on('refresh', async (params, { next }) => {
             let  asset  = await next(params);
-            this.tabsData[0].val = asset.shop && asset.shop.totalOrder ? asset.shop.totalOrder : 0;
-            this.tabsData[1].val = asset.shop && asset.shop.unPayOrder?asset.shop.unPayOrder:0;
-            this.tabsData[2].val = asset.shop && asset.shop.unSendOrder?asset.shop.unSendOrder:0;
-            this.tabsData[3].val = asset.shop && asset.shop.sendingOrder?asset.shop.sendingOrder:0;
-            this.tabsData[4].val = asset.shop && asset.shop.finishOrder?asset.shop.finishOrder:0;
+            // this.tabsData[0].val = asset.shop && asset.shop.totalOrder ? asset.shop.totalOrder : 0;
+            // this.tabsData[1].val = asset.shop && asset.shop.unPayOrder?asset.shop.unPayOrder:0;
+            // this.tabsData[2].val = asset.shop && asset.shop.unSendOrder?asset.shop.unSendOrder:0;
+            // this.tabsData[3].val = asset.shop && asset.shop.sendingOrder?asset.shop.sendingOrder:0;
+            // this.tabsData[4].val = asset.shop && asset.shop.finishOrder?asset.shop.finishOrder:0;
           })
           .done();
           app.refresh({ status: this.tabIndex})