shish 4 лет назад
Родитель
Сommit
a80a715925

+ 191 - 0
ghsApp/src/admin/itemClass/addPrice.vue

@@ -0,0 +1,191 @@
+<template>
+	<view>
+		<view v-if="!$util.isEmpty(list.data)" style="padding-bottom:120rpx;">
+			<t-table :headerBackgroundColor="'#F0F2F6'">
+				<t-tr header>
+                    <t-th>名称</t-th>
+					<t-th>散客</t-th>
+					<t-th>普店</t-th>
+					<t-th>银店</t-th>
+					<t-th>金店</t-th>
+				</t-tr>
+				<view v-for="(item, index) in list.data" :key="index">
+					<t-tr>
+                        <t-td align="center" color="info"><view>{{item.name}}</view></t-td>
+						<t-td align="center" color="info">
+                            <view><input v-model="item.skAddPrice" name="skAddPrice" type="digit" style="border:1rpx solid #cccccc;" /></view>
+                        </t-td>
+						<t-td align="center" color="info">
+                            <view><input v-model="item.addPrice" name="price" type="digit" style="border:1rpx solid #cccccc;" /></view>
+                            </t-td>
+						<t-td align="center" color="info">
+                            <view><input v-model="item.hjAddPrice" name="hjAddPrice" type="digit" style="border:1rpx solid #cccccc;" /></view>
+                            </t-td>
+						<t-td align="center" color="info">
+                            <view><input v-model="item.zsAddPrice" name="zsAddPrice" type="digit" style="border:1rpx solid #cccccc;" /></view>
+                            </t-td>
+					</t-tr>
+				</view>
+			</t-table>
+		</view>
+		<view v-else>
+			<AppWrapperEmpty title="暂无数据" :is-empty="$util.isEmpty(list.data)" />
+		</view>
+        <view class="app-footer">
+            <view class="admin-button-com middle blue" @click="showBatchUpdate('add')">整列累加</view>
+            <view style="margin-left:30rpx;" class="admin-button-com middle blue" @click="showBatchUpdate('update')">整列改为</view>
+		    <view style="margin-left:30rpx;" class="admin-button-com middle blue" @click="savePrice">全部保存</view>
+		</view>
+
+		<modal-module :show="batchModel" @cancel="modalCancel" @click="affirmBatch" title="批量操作" color="#333" :size="32" padding="30rpx 30rpx" >
+			<template slot="customContent">
+				<view class="select-cmd_bx">
+					<view class="num_bx" style="margin:60rpx 0 60rpx 0;font-size:35rpx;">
+						<view class="flex">金额:<input v-model="batchPrice" type="digit" focus style="border:1rpx solid #CCCCCC;height:60rpx;" /></view>
+					</view>
+				</view>
+			</template>
+		</modal-module>
+
+	</view>
+</template>
+
+<script>
+import AppWrapperEmpty from "@/components/app-wrapper-empty";
+import { productList,batchChangeAddPrice } from '@/api/product'
+import list from '@/mixins/list'
+import ModalModule from "@/components/plugin/modal";
+export default {
+	name: "addPrice",
+	components: {
+		AppWrapperEmpty,ModalModule
+	},
+	mixins:[list],
+	data() {
+		return {
+            batchModel:false,
+            batchStyle:'add',
+            batchPrice:'',
+            focusOn:false,
+            levelIndex:0
+		};
+	},
+	methods: {
+        showBatchUpdate(styleInfo){
+            if (this.$util.isEmpty(this.list.data)){
+                this.$msg('没有花材')
+                return false
+            }
+
+            this.batchStyle = styleInfo
+			let self = this
+			let levelList = ['请选择列:','散客', '普店', '银店', '金店']
+			uni.showActionSheet({
+				itemList: levelList,
+				success: function (respond) {
+					self.levelIndex = respond.tapIndex
+                    self.batchModel = true
+				}
+			})
+        },
+		affirmBatch(val) {
+            let that = this
+			if (val.index === 0) {
+                this.batchPrice = ''
+				this.batchModel = false;
+			} else {
+                if(this.$util.isMoney(this.batchPrice) == false){
+                    this.$msg('请填写金额')
+                    return false
+                }
+                let currentPrice = Number(this.batchPrice)
+                this.list.data.forEach(function(value,index,array){
+                    if(that.batchStyle =='add'){
+                        if(that.levelIndex == 1){
+                            array[index].skAddPrice =  parseFloat((Number(array[index].skAddPrice) + currentPrice).toFixed(2))
+                        }else if(that.levelIndex == 2){
+                            array[index].addPrice =  parseFloat((Number(array[index].addPrice) + currentPrice).toFixed(2))
+                        }else if(that.levelIndex == 3){
+                            array[index].hjAddPrice =  parseFloat((Number(array[index].hjAddPrice) + currentPrice).toFixed(2))
+                        }else if(that.levelIndex == 4){
+                            array[index].zsAddPrice =  parseFloat((Number(array[index].zsAddPrice) + currentPrice).toFixed(2))
+                        }else{
+
+                        }
+                    }else{
+                        if(that.levelIndex == 1){
+                            array[index].skAddPrice =  parseFloat((currentPrice).toFixed(2))
+                        }else if(that.levelIndex == 2){
+                            array[index].addPrice =  parseFloat((currentPrice).toFixed(2))
+                        }else if(that.levelIndex == 3){
+                            array[index].hjAddPrice =  parseFloat((currentPrice).toFixed(2))
+                        }else if(that.levelIndex == 4){
+                            array[index].zsAddPrice =  parseFloat((currentPrice).toFixed(2))
+                        }else{
+
+                        }
+                    }
+				});
+                this.batchPrice = ''
+                this.batchModel = false;
+			}
+		},
+        savePrice(){
+           let that = this
+           let addData = [];
+           uni.showLoading({mask:true})
+           this.list.data.forEach(function(value,index,array){
+
+               if(that.$util.isMoney(value.skAddPrice) == false){
+                   that.$msg('【'+value.name+'】的散客加价填写错误')
+                   return false
+               }
+               if(that.$util.isMoney(value.addPrice) == false){
+                   that.$msg('【'+value.name+'】的普店加价填写错误')
+                   return false
+               }
+               if(that.$util.isMoney(value.hjAddPrice) == false){
+                   that.$msg('【'+value.name+'】的银店加价填写错误')
+                   return false
+               }
+               if(that.$util.isMoney(value.zsAddPrice) == false){
+                   that.$msg('【'+value.name+'】的金店加价填写错误')
+                   return false
+               }
+                addData.push({id:value.id,skAddPrice:value.skAddPrice,addPrice:value.addPrice,hjAddPrice:value.hjAddPrice,zsAddPrice:value.zsAddPrice})
+           })
+           let addString = JSON.stringify(addData)
+           batchChangeAddPrice({addData:addString}).then(res=>{
+               uni.hideLoading()
+               if(res.code == 1){
+                    setTimeout(function(){
+                        that.$msg(res.msg)
+                    },500)
+               }
+           })
+        },
+		async init(){
+			const res = await productList({
+				page:this.list.page,showPage:1,pageSize:2000,classId:this.option.classId
+			})
+			this.completes(res)
+		}
+	},
+	async onPullDownRefresh() {
+		this.resetList();
+		await this.init()
+		uni.stopPullDownRefresh();
+	},
+	async onReachBottom() {
+		if (!this.list.finished) {
+			await this.init()
+			uni.stopPullDownRefresh();;
+		} else {
+			uni.stopPullDownRefresh();
+		}
+	},
+	
+};
+</script>
+<style lang="scss" scoped>
+</style>

+ 7 - 7
ghsApp/src/admin/itemClass/list.vue

@@ -1,21 +1,21 @@
 <template>
 	<div class="app-content" @click="globalClick">
-		<!-- list -->
 		<div class="list-wrap">
 			<block v-if="!$util.isEmpty(list.data)">
-				<div class="list" v-for="(item, index) in list.data" :key="index" @click="editItem(item)">
+				<div class="list" v-for="(item, index) in list.data" :key="index">
 					<div class="list-index">{{ item.id }}</div>
 					<div class="list-img">
 						<img :src="`${constant.imgUrl}/hhb_small.png`" alt="" mode="widthFix" style="width:90rpx"/>
 					</div>
 					<div class="list-det">
 						<div class="app-size-28 app-color-0">{{ item.name || '' }}</div>
-						
 						<div class="list-operate">
 							<div class="operate-det">
 								<span>序号:{{ item.inTurn }}</span>
 							</div>
-							<div class="operate-icon-wrap">
+							<text class="add-price" @click.stop="pageTo('/admin/itemClass/addPrice?classId='+item.id)">加价</text>
+							<text class="add-price" @click.stop="pageTo('/admin/itemClass/more?classId='+item.id)">更多</text>
+							<div class="operate-icon-wrap" @click="editItem(item)">
 								<div class="operate-icon">
 									<i class="iconfont" :class="[ index == operateIndex ? 'iconbianji' : 'iconbianji']" style="font-size:38rpx;"></i>
 								</div>
@@ -35,11 +35,9 @@
 				<app-wrapper-empty title="暂无数据" :is-empty="$util.isEmpty(list.data)" />
 			</block>
 		</div>
-		<!-- button -->
 		<div class="app-footer">
 			<button class="admin-button-com middle blue" @click="addCategoryFn">添加分类</button>
 		</div>
-		<!-- modify -->
 		<modal-module :show="modifyModal" :maskClosable="false" @cancel="modalCancel" @click="replaceModalClick" width="92%" :title="modifyTitle" padding="30rpx 30rpx">
 			<template v-slot:content>
 				<div class="app-modal-input-wrap modify-modal">
@@ -58,7 +56,6 @@
 				</div>
 			</template>
 		</modal-module>
-		<!-- 删除提示 -->
 		<modal-module :show="delModal" :maskClosable="false" @cancel="modalCancel" @click="delModalClick" content="确定删除?" color="#333" :size="32" padding="30rpx 30rpx"></modal-module>
 	</div>
 </template>
@@ -291,6 +288,9 @@ export default {
 							}
 						}
 					}
+					.add-price{
+						text-decoration:underline;
+					}
 				}
 			}
 		}

+ 178 - 0
ghsApp/src/admin/itemClass/more.vue

@@ -0,0 +1,178 @@
+<template>
+	<view>
+		<view v-if="!$util.isEmpty(list.data)" style="padding-bottom:120rpx;">
+			<t-table :headerBackgroundColor="'#F0F2F6'">
+				<t-tr header>
+                    <t-th>名称</t-th>
+					<t-th>排序</t-th>
+					<t-th>重量(公斤)</t-th>
+					<t-th>保持期(天)</t-th>
+				</t-tr>
+				<view v-for="(item, index) in list.data" :key="index">
+					<t-tr>
+                        <t-td align="center" color="info"><view>{{item.name}}</view></t-td>
+						<t-td align="center" color="info">
+                            <view><input v-model="item.inTurn" name="inTurn" type="number" style="border:1rpx solid #cccccc;" /></view>
+                        </t-td>
+						<t-td align="center" color="info">
+                            <view><input v-model="item.weight" name="weight" type="digit" style="border:1rpx solid #cccccc;" /></view>
+                            </t-td>
+						<t-td align="center" color="info">
+                            <view><input v-model="item.shelfLife" name="shelfLife" type="digit" style="border:1rpx solid #cccccc;" /></view>
+                            </t-td>
+					</t-tr>
+				</view>
+			</t-table>
+		</view>
+		<view v-else>
+			<AppWrapperEmpty title="暂无数据" :is-empty="$util.isEmpty(list.data)" />
+		</view>
+        <view class="app-footer">
+            <view class="admin-button-com middle blue" @click="showBatchUpdate('add')">整列累加</view>
+            <view style="margin-left:30rpx;" class="admin-button-com middle blue" @click="showBatchUpdate('update')">整列改为</view>
+		    <view style="margin-left:30rpx;" class="admin-button-com middle blue" @click="savePrice">全部保存</view>
+		</view>
+
+		<modal-module :show="batchModel" @cancel="modalCancel" @click="affirmBatch" title="批量操作" color="#333" :size="32" padding="30rpx 30rpx" >
+			<template slot="customContent">
+				<view class="select-cmd_bx">
+					<view class="num_bx" style="margin:60rpx 0 60rpx 0;font-size:35rpx;">
+						<view class="flex">数值:<input v-model="batchNum" type="digit" focus style="border:1rpx solid #CCCCCC;height:60rpx;" /></view>
+					</view>
+				</view>
+			</template>
+		</modal-module>
+
+	</view>
+</template>
+
+<script>
+import AppWrapperEmpty from "@/components/app-wrapper-empty";
+import { productList,batchChangeMore } from '@/api/product'
+import list from '@/mixins/list'
+import ModalModule from "@/components/plugin/modal";
+export default {
+	name: "more",
+	components: {
+		AppWrapperEmpty,ModalModule
+	},
+	mixins:[list],
+	data() {
+		return {
+            batchModel:false,
+            batchStyle:'add',
+            batchNum:'',
+            focusOn:false,
+            levelIndex:0
+		};
+	},
+	methods: {
+        showBatchUpdate(styleInfo){
+            if (this.$util.isEmpty(this.list.data)){
+                this.$msg('没有花材')
+                return false
+            }
+
+            this.batchStyle = styleInfo
+			let self = this
+			let levelList = ['请选择列:','排序', '重量', '保持期']
+			uni.showActionSheet({
+				itemList: levelList,
+				success: function (respond) {
+					self.levelIndex = respond.tapIndex
+                    self.batchModel = true
+				}
+			})
+        },
+		affirmBatch(val) {
+            let that = this
+			if (val.index === 0) {
+                this.batchNum = ''
+				this.batchModel = false;
+			} else {
+                if(this.$util.isMoney(this.batchNum) == false){
+                    this.$msg('请填写数值')
+                    return false
+                }
+                let currentNum = Number(this.batchNum)
+                this.list.data.forEach(function(value,index,array){
+                    if(that.batchStyle =='add'){
+                        if(that.levelIndex == 1){
+                            array[index].inTurn =  parseFloat((Number(array[index].inTurn) + currentNum).toFixed(2))
+                        }else if(that.levelIndex == 2){
+                            array[index].weight =  parseFloat((Number(array[index].weight) + currentNum).toFixed(2))
+                        }else if(that.levelIndex == 3){
+                            array[index].shelfLife =  parseFloat((Number(array[index].shelfLife) + currentNum).toFixed(2))
+                        }else{
+
+                        }
+                    }else{
+                        if(that.levelIndex == 1){
+                            array[index].inTurn =  parseFloat((currentNum).toFixed(2))
+                        }else if(that.levelIndex == 2){
+                            array[index].weight =  parseFloat((currentNum).toFixed(2))
+                        }else if(that.levelIndex == 3){
+                            array[index].shelfLife =  parseFloat((currentNum).toFixed(2))
+                        }else{
+
+                        }
+                    }
+				});
+                this.batchNum = ''
+                this.batchModel = false;
+			}
+		},
+        savePrice(){
+           let that = this
+           let addData = [];
+           uni.showLoading({mask:true})
+           this.list.data.forEach(function(value,index,array){
+               if(that.$util.isMoney(value.inTurn) == false){
+                   that.$msg('【'+value.name+'】的排序值填写错误')
+                   return false
+               }
+               if(that.$util.isMoney(value.weight) == false){
+                   that.$msg('【'+value.name+'】的重量填写错误')
+                   return false
+               }
+               if(that.$util.isMoney(value.shelfLife) == false){
+                   that.$msg('【'+value.name+'】的保持期填写错误')
+                   return false
+               }
+                addData.push({id:value.id,inTurn:value.inTurn,weight:value.weight,shelfLife:value.shelfLife})
+           })
+           let addString = JSON.stringify(addData)
+           batchChangeMore({addData:addString}).then(res=>{
+               uni.hideLoading()
+               if(res.code == 1){
+                    setTimeout(function(){
+                        that.$msg(res.msg)
+                    },500)
+               }
+           })
+        },
+		async init(){
+			const res = await productList({
+				page:this.list.page,showPage:1,pageSize:2000,classId:this.option.classId
+			})
+			this.completes(res)
+		}
+	},
+	async onPullDownRefresh() {
+		this.resetList();
+		await this.init()
+		uni.stopPullDownRefresh();
+	},
+	async onReachBottom() {
+		if (!this.list.finished) {
+			await this.init()
+			uni.stopPullDownRefresh();;
+		} else {
+			uni.stopPullDownRefresh();
+		}
+	},
+	
+};
+</script>
+<style lang="scss" scoped>
+</style>

+ 12 - 0
ghsApp/src/api/product/index.js

@@ -17,6 +17,10 @@ export const getAllProductDataApi = data => {
 	return https.get("/product/list", data);
 };
 
+export const productList = data => {
+	return https.get("/product/list", data);
+};
+
 /**
  * 自动调价
  * productId
@@ -54,6 +58,14 @@ export const getProductDetail = data => {
 	return https.get("/product/detail", data);
 };
 
+export const batchChangeAddPrice = data => {
+	return https.post("/product/batch-change-add-price", data);
+};
+
+export const batchChangeMore = data => {
+	return https.post("/product/batch-change-more", data);
+};
+
 //获取拼音首字母缩写 shish 20210707
 export const py = data => {
 	return https.get("/product/py", data);

+ 3 - 1
ghsApp/src/pages.json

@@ -529,7 +529,9 @@
 		{
 			"root": "admin/itemClass",
 			"pages": [
-				{"path": "list","style": {"navigationBarTitleText": "花材分类"}}
+				{"path": "list","style": {"navigationBarTitleText": "花材分类"}},
+				{"path": "addPrice","style": {"navigationBarTitleText": "加价设置"}},
+				{"path": "more","style": {"navigationBarTitleText": "更多"}}
 			]
 		},
 		{