Parcourir la source

修改单位比和重量等

shish il y a 1 an
Parent
commit
1202d1f479
2 fichiers modifiés avec 141 ajouts et 7 suppressions
  1. 129 7
      ghsApp/src/admin/item/detail.vue
  2. 12 0
      ghsApp/src/api/item/index.js

+ 129 - 7
ghsApp/src/admin/item/detail.vue

@@ -132,25 +132,34 @@
         <tui-list-cell class="line-cell" :arrow="false">
           <view class="tui-title">大单位</view>
           <input v-model="form.bigUnitId" name="bigUnitId" type="text" hidden />
-          <view v-if="form.bigUnitId" @click="$msg('不能修改')" style="width:450upx;color:#CCCCCC;height:45upx;">{{ bigUnitSelectedData.name }}</view>
+          <view v-if="form.bigUnitId" style="width:300upx;color:#CCCCCC;height:45upx;">{{ bigUnitSelectedData.name }}</view>
+          <button v-if="productData.id > 0 && productData.hasRightChange == 1" class="admin-button-com blue middle" @click.stop="showUnitList('big')" style="width:150upx;">修改</button>
+          <button v-else class="admin-button-com default middle" style="width:150upx;">修改</button>
         </tui-list-cell>
 
         <tui-list-cell class="line-cell" :arrow="false">
           <view class="tui-title">小单位</view>
           <input v-model="form.smallUnitId" name="smallUnitId" type="text" hidden />
-          <view v-if="form.smallUnitId" @click="$msg('不能修改')" style="width:450upx;color:#CCCCCC;height:45upx;">{{ smallUnitSelectedData.name }}</view>
+          <view v-if="form.smallUnitId" style="width:300upx;color:#CCCCCC;height:45upx;">{{ smallUnitSelectedData.name }}</view>
+          <button v-if="productData.id > 0 && productData.hasRightChange == 1" class="admin-button-com blue middle" @click.stop="showUnitList('small')" style="width:150upx;">修改</button>
+          <button v-else class="admin-button-com default middle" style="width:150upx;">修改</button>
         </tui-list-cell>
 
         <tui-list-cell class="line-cell" :arrow="false" v-if="form.ratioType == 0">
           <view class="tui-title">单位比</view>
-          <input v-model="form.ratio" disabled="true" placeholder-class="phcolor" @click="$msg('不可修改')" style="width:450upx;color:#CCCCCC;"
+          <input v-model="form.ratio" disabled="true" placeholder-class="phcolor" @click="$msg('不可修改')" style="width:300upx;color:#CCCCCC;"
           class="tui-input" name="ratio" placeholder="1扎=20支,请填写20" maxlength="50" type="number" />
+          <button v-if="productData.id > 0 && productData.hasRightChange == 1" class="admin-button-com blue middle" @click.stop="changeRatio()" style="width:150upx;">修改</button>
+          <button v-else class="admin-button-com default middle" style="width:150upx;">修改</button>
         </tui-list-cell>
 
         <tui-list-cell class="line-cell" :arrow="false">
           <view class="tui-title">每扎重量</view>
-          <input v-model="form.weight" disabled="true" placeholder-class="phcolor" @click="$msg('不可修改')" style="width:450upx;color:#CCCCCC;"
+          <input v-model="form.weight" disabled="true" placeholder-class="phcolor" @click="$msg('不可修改')" style="width:300upx;color:#CCCCCC;"
           class="tui-input" name="weight" placeholder="单位为公斤" maxlength="50" type="digit" />
+
+          <button v-if="productData.id > 0 && productData.hasRightChange == 1" class="admin-button-com blue middle" @click.stop="changeWeight()" style="width:150upx;">修改</button>
+          <button v-else class="admin-button-com default middle" style="width:150upx;">修改</button>
         </tui-list-cell>
 
         <tui-list-cell class="line-cell" :hover="false">
@@ -347,6 +356,42 @@
 			</view>
     </uni-popup>
 
+		<uni-popup ref="unitRef" background-color="#fff" type="center" :animation="false" class="class-popup-style">
+			<view style="max-height:90vh;overflow: scroll;">
+				<view style="margin-left:30upx;margin-top:19upx;font-size:27upx;font-weight:bold;">请选择:</view>
+				<view style="display:flex;padding:20upx;height:auto;justify-content: space-between;align-items:center;flex-wrap:wrap;max-height:100vh;overflow:auto;">
+					<view v-for="(item, index) in unitData" :key="index" @tap.stop="setNewUnit(item)" style="margin-bottom:20upx;margin-left:3upx;">
+						<view style="margin-top:8upx;overflow: hidden;white-space: nowrap;width:120upx;text-align:center;font-weight:bold;font-size:36upx;">{{item.name}}</view>
+					</view>
+				</view>
+				<view style="text-align:center;padding:10upx 0 10upx 0;"><button class="admin-button-com big blue" @click="cancelUnitChange()">取消选择</button></view>
+			</view>
+    </uni-popup>
+
+    <modal-module :show="writeRatioShow" @click="newRatioConfirm" :maskClosable="true" title="修改单位比" padding="30rpx 30rpx" >
+		<template v-slot:content>
+			<view class="app-modal-input-wrap">
+        <view class="inp-list-line">
+          <view class="line-input">
+          <input type="number" ref="input" style="width:62%;text-align:center;" v-model="newRatio" @focus="newRatio=''" :adjust-position="false" class="inp-input" />
+          </view>
+        </view>
+			</view>
+		</template>
+		</modal-module>
+
+    <modal-module :show="writeWeightShow" @click="newWegithConfirm" :maskClosable="true" title="修改重量" padding="30rpx 30rpx" >
+		<template v-slot:content>
+			<view class="app-modal-input-wrap">
+        <view class="inp-list-line">
+          <view class="line-input">
+          <input type="digit" ref="input" style="width:62%;text-align:center;" v-model="newWeight" @focus="newWeight=''" :adjust-position="false" class="inp-input" />
+          </view>
+        </view>
+			</view>
+		</template>
+		</modal-module>
+
   </view>
 </template>
 
@@ -354,7 +399,7 @@
 import TuiListCell from "@/components/plugin/list-cell";
 const form = require("@/utils/formValidation.js");
 import { getAllItemClass } from "@/api/item-class";
-import { applyAuth,modifyCgStaff,setLosing } from '@/api/item';
+import { applyAuth,modifyCgStaff,setLosing,modifyUnit,modifyRatio,modifyWeight } from '@/api/item';
 import { delCpItem,addCpItem } from '@/api/cp'
 import { getAllUnit } from "@/api/unit";
 import { addProduct,updateProduct,getProductDetail,py,print,modifyOnStockFn,delStatusUpdate,changeBelongCost } from "@/api/product";
@@ -374,6 +419,10 @@ export default {
   },
   data() {
     return {
+      writeRatioShow:false,
+      newRatio:'',
+      writeWeightShow:false,
+      newWeight:'',
       onStockShow:false,
       newOnStock:0,
       status: 1,
@@ -430,7 +479,8 @@ export default {
       wasteShow:false,
       wasteFocus:false,
       belongCost:0,
-      staffData:[]
+      staffData:[],
+      modifyUnitType:'big'
     };
   },
 	computed:{
@@ -482,6 +532,22 @@ export default {
     }
   },
   methods: {
+    setNewUnit(item){
+      modifyUnit({type:this.modifyUnitType,unitId:item.id,id:this.productData.id}).then(res=>{
+        if(res.code == 1){
+          this.cancelUnitChange()
+          this.getDetail()
+          this.$msg('修改成功')
+        }
+      })
+    },
+		showUnitList(type){
+      this.modifyUnitType = type
+			this.$refs.unitRef.open('center')
+		},
+		cancelUnitChange(){
+			this.$refs.unitRef.close()
+		},
     getStaff(staff){
       this.$refs.staffRef.close()
       modifyCgStaff({id:this.productData.id,staffId:staff.id}).then(res=>{
@@ -536,7 +602,63 @@ export default {
     closeWastePop(){
       this.wasteShow = false
       this.wasteFocus = false
-      this.wasteNum = ''      
+      this.wasteNum = ''    
+    },
+    closeNewRatio(){
+      this.writeRatioShow = false
+      this.newRatio = ''
+    },
+    changeRatio(){
+      this.writeRatioShow = true
+      this.newRatio = this.productData.ratio?parseFloat(this.productData.ratio):0
+    },
+    newRatioConfirm(val){
+			let that = this
+			if (val.index == 0) {
+        this.closeNewRatio()
+				return
+			}
+      if(Number(that.newRatio)<0){
+        that.$msg('请填写数量')
+        return false
+      }
+      that.$util.confirmModal({content:'确认修改?'},() => {
+        modifyRatio({id:this.productData.id,ratio:that.newRatio}).then((res) => {
+            if(res.code == 1){
+              that.getDetail()
+              that.closeNewRatio()
+              that.$msg('修改成功')
+            }
+          });
+      })
+    },
+    closeNewWeight(){
+      this.writeWeightShow = false
+      this.newWeight = ''
+    },
+    changeWeight(){
+      this.writeWeightShow = true
+      this.newWeight = this.productData.weight?parseFloat(this.productData.weight):0
+    },
+    newWegithConfirm(val){
+			let that = this
+			if (val.index == 0) {
+        this.closeNewWeight()
+				return
+			}
+      if(Number(that.newWeight)<0){
+        that.$msg('请填写数量')
+        return false
+      }
+      that.$util.confirmModal({content:'确认修改?'},() => {
+        modifyWeight({id:this.productData.id,weight:that.newWeight}).then((res) => {
+            if(res.code == 1){
+              that.getDetail()
+              that.closeNewWeight()
+              that.$msg('修改成功')
+            }
+          });
+      })
     },
     wasteConfirm(val){
 			let that = this

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

@@ -1,5 +1,17 @@
 import https from '@/plugins/luch-request_0.0.7/request'
 
+export const modifyWeight = data => {
+	return https.get('/item/modify-weight', data)
+}
+
+export const modifyRatio = data => {
+	return https.get('/item/modify-ratio', data)
+}
+
+export const modifyUnit = data => {
+	return https.get('/item/modify-unit', data)
+}
+
 export const moveToLosing = data => {
 	return https.get('/item/move-to-losing', data)
 }