|
|
@@ -0,0 +1,901 @@
|
|
|
+<template>
|
|
|
+ <view class="app-content">
|
|
|
+ <!-- 花材基本信息 -->
|
|
|
+ <form @submit="formSubmit">
|
|
|
+ <view class="module-com input-line-wrap">
|
|
|
+ <block v-if="!$util.isEmpty(productData) && productData.delStatus == 1">
|
|
|
+ <view style="color:red;background-color: yellow;font-size:29upx;font-weight:bold;padding-top:20upx;padding-bottom:20upx;text-align:center;">
|
|
|
+ 已删除
|
|
|
+ </view>
|
|
|
+ </block>
|
|
|
+ <block v-else>
|
|
|
+ <view style="color:red;background-color: yellow;font-size:29upx;font-weight:bold;padding-top:20upx;padding-bottom:20upx;text-align:center;" v-if="productData.repeatId && productData.repeatId>0"
|
|
|
+ @click="pageTo({url: '/admin/item/detail?id='+productData.repeatId})">
|
|
|
+ 存在重复编号花材,点击查看,请删除其中一个
|
|
|
+ </view>
|
|
|
+ </block>
|
|
|
+ <tui-list-cell class="line-cell" :hover="false" v-if="productData.id && productData.id>0">
|
|
|
+ <view class="tui-title">编号</view>
|
|
|
+ <view style="color:#CCCCCC;width:300upx;" @click="getItemId(productData)">{{productData.itemId?productData.itemId:0}}</view>
|
|
|
+ <button v-if="productData.id > 0" class="admin-button-com default mini-btn" @click="delProduct(productData)">删除花材</button>
|
|
|
+ </tui-list-cell>
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">名称</view>
|
|
|
+ <input v-model="form.name" placeholder-class="phcolor" class="tui-input" name="name" placeholder="请填写名称" @input="fillName($event)" maxlength="50" type="text" />
|
|
|
+ </tui-list-cell>
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">初始名称</view>
|
|
|
+ <view style="color:#CCCCCC;width:300upx;height:45upx;display:flex;align-items:center;overflow:hidden;">
|
|
|
+ {{productData.ptItemInfo ? productData.ptItemInfo.name : ''}}
|
|
|
+ <image :src="`${constant.imgUrl}/icon/official8.png`" v-if="productData.auth == 1" mode="widthFix" style="width:38upx;height:38upx;display:inline-block;margin-left:10upx;"></image>
|
|
|
+ </view>
|
|
|
+ <button v-if="productData.id > 0 && productData.auth == 0" class="admin-button-com blue mini-btn" @click="ptAuth(productData)">申请认证</button>
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">拼音缩写</view>
|
|
|
+ <input v-model="form.py" placeholder-class="phcolor" class="tui-input" name="py" placeholder="请填写拼音首字母缩写" maxlength="50" type="text" />
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">价格</view>
|
|
|
+ <input v-model="form.hjPrice" style="width:130upx;border:1upx solid #CCCCCC;text-align:center;height:50upx;" placeholder-class="phcolor"
|
|
|
+ class="tui-input" name="hjPrice" @focus="form.hjPrice=''" placeholder="大客价" type="digit" />
|
|
|
+ <input v-model="form.price" style="width:130upx;border:1upx solid #3385FF;text-align:center;height:50upx;color:#3385FF;margin-left:30upx;" placeholder-class="phcolor"
|
|
|
+ class="tui-input" name="price" @focus="form.price=''" placeholder="批发价" type="digit" @input="priceLinkage()" />
|
|
|
+ <input v-model="form.skPrice" style="width:130upx;border:1upx solid #CCCCCC;text-align:center;height:50upx;margin-left:30upx;" placeholder-class="phcolor"
|
|
|
+ class="tui-input" name="skPrice" @focus="form.skPrice=''" placeholder="零售价" type="digit" />
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">特价</view>
|
|
|
+ <input v-model="form.hjDiscountPrice" style="width:130upx;border:1upx solid #CCCCCC;text-align:center;height:50upx;" placeholder-class="phcolor"
|
|
|
+ class="tui-input" name="hjDiscountPrice" @focus="form.hjDiscountPrice=''" placeholder="会员特价" type="digit" />
|
|
|
+ <input v-model="form.discountPrice" style="width:130upx;border:1upx solid #3385FF;margin-left:30upx;color:#3385FF;text-align:center;height:50upx;" placeholder-class="phcolor" @input="tjLinkage()"
|
|
|
+ class="tui-input" name="discountPrice" @focus="form.discountPrice=''" placeholder="无特价填0" maxlength="50" type="digit" />
|
|
|
+ <input v-model="form.skDiscountPrice" style="width:130upx;border:1upx solid #CCCCCC;text-align:center;height:50upx;margin-left:30upx;" placeholder-class="phcolor"
|
|
|
+ class="tui-input" name="skDiscountPrice" @focus="form.skDiscountPrice=''" placeholder="零售特价" type="digit" />
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">下单满</view>
|
|
|
+ <input v-model="form.reachNum" style="width:130upx;border:1upx solid #CCCCCC;text-align:center;height:50upx;margin-right:8upx;" placeholder-class="phcolor"
|
|
|
+ class="tui-input" name="reachNum" @focus="form.reachNum=''" placeholder="数量" maxlength="50" type="number" />扎 每扎优惠
|
|
|
+ <input v-model="form.reachNumDiscount" style="width:130upx;border:1upx solid #CCCCCC;text-align:center;height:50upx;margin-right:8upx;margin-left:8upx;" placeholder-class="phcolor"
|
|
|
+ class="tui-input" name="reachNumDiscount" @focus="form.reachNumDiscount=''" placeholder="金额" type="digit" />元
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :arrow="false" :hover="false">
|
|
|
+ <view class="tui-title">成本</view>
|
|
|
+ <input v-model="form.cost" style="width:300upx;" placeholder-class="phcolor" @focus="form.cost=''" class="tui-input" name="cost" placeholder="请输入" type="digit"/>
|
|
|
+ <button v-if="productData.id > 0" class="admin-button-com blue middle" @click="goCostDetail(productData)">变动记录</button>
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title" style="color:#3385FF;font-weight:bold;">库存</view>
|
|
|
+ <input v-model="form.stock" style="width:300upx;" placeholder-class="phcolor" @focus="form.stock=''" @input="changeStock($event)" class="tui-input" name="stock" placeholder="请输入" type="digit"/>
|
|
|
+ <button v-if="productData.id > 0" class="admin-button-com blue middle" @click="goStockDetail(productData)">变动记录</button>
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">路上库存</view>
|
|
|
+ <view style="color:#CCCCCC;width:300upx;height:45upx;display:flex;align-items:center;overflow:hidden;">
|
|
|
+ {{form.onStock}}
|
|
|
+ </view>
|
|
|
+ <button v-if="productData.id > 0" class="admin-button-com blue middle" @click="showChangeOnStock(productData)">修改数值</button>
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :arrow="true">
|
|
|
+ <view class="tui-title">分类</view>
|
|
|
+ <picker mode="selector" :value="form.classId" :range="itemClassData" range-key="name" @change="changeItemClassFn" class="tui-input" >
|
|
|
+ <input v-model="form.classId" name="classId" type="text" hidden />
|
|
|
+ <view v-if="form.classId" style="height:45upx;" >{{ itemClassSelectedData.name }}</view>
|
|
|
+ <view class="tui-placeholder" style="height:45upx;" v-else>请选择</view>
|
|
|
+ </picker>
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <div class="tui-title">比例类型</div>
|
|
|
+ <radio-group class="tui-input" @change="ratioTypeChange">
|
|
|
+ <label class="list" for="fixedLink">
|
|
|
+ <radio id="fixedLink" value="0" :checked="form.ratioType == 0" style="transform: scale(0.7,0.7);" />
|
|
|
+ <span class="checkbox-text" style="font-size:30upx;">固定</span>
|
|
|
+ </label>
|
|
|
+ <label class="list" for="dimLink">
|
|
|
+ <radio id="dimLink" value="1" :checked="form.ratioType == 1" style="transform: scale(0.7,0.7);" />
|
|
|
+ <span class="checkbox-text" style="font-size:30upx;">模糊(若干支)</span>
|
|
|
+ </label>
|
|
|
+ </radio-group>
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <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>
|
|
|
+ </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>
|
|
|
+ </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;"
|
|
|
+ class="tui-input" name="ratio" placeholder="1扎=20支,请填写20" maxlength="50" type="number" />
|
|
|
+ </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;"
|
|
|
+ class="tui-input" name="weight" placeholder="单位为公斤" maxlength="50" type="digit" />
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">库存预警</view>
|
|
|
+ <input v-model="form.stockWarning" style="width:300upx;" @focus="form.stockWarning=''" placeholder-class="phcolor" class="tui-input" name="stockWarning" placeholder="请填写" maxlength="50" type="number" />
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">花材状态</view>
|
|
|
+ <view>
|
|
|
+ <block v-if="productData.delStatus && productData.delStatus == 1">
|
|
|
+ <text>已删除</text>
|
|
|
+ </block>
|
|
|
+ <block v-else>
|
|
|
+ <text v-if="form.status == 1">上架</text>
|
|
|
+ <text v-else>下架</text>
|
|
|
+ </block>
|
|
|
+ </view>
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <view class="module-com input-line-wrap goods-wrap">
|
|
|
+ <view class="module-tit">
|
|
|
+ <span>花材图片</span>
|
|
|
+ <span class="app-color-3"></span>
|
|
|
+ </view>
|
|
|
+ <view class="module-det">
|
|
|
+ <htz-image-upload :max="1" :compress="true" v-model="currentImgData" :headers="headers"
|
|
|
+ @uploadSuccess="imgUploadSuccess" @imgDelete="imgDeleteFn" :action="getLoginInfo.imgUploadApi">
|
|
|
+ </htz-image-upload>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <view class="module-com input-line-wrap">
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">大客价加价</view>
|
|
|
+ <input v-model="form.hjAddPrice" placeholder-class="phcolor" class="tui-input" name="hjAddPrice" @focus="form.hjAddPrice=''" placeholder="在成本价基础上多卖的金额" maxlength="50" type="digit" />
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">批发价加价</view>
|
|
|
+ <input v-model="form.addPrice" placeholder-class="phcolor" class="tui-input" name="addPrice" @focus="form.addPrice=''" placeholder="在成本价基础上多卖的金额" maxlength="50" type="digit" />
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">零售价加价</view>
|
|
|
+ <input v-model="form.skMore" placeholder-class="phcolor" class="tui-input" name="skMore" @focus="form.skMore=''" placeholder="在成本价基础上多卖的金额" type="digit" />
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">顺序值</view>
|
|
|
+ <input v-model="form.inTurn" placeholder-class="phcolor" class="tui-input" name="inTurn" @focus="form.inTurn=''" placeholder="请填写金额" type="number" />
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">拆散单价</view>
|
|
|
+ <input v-model="form.smallRatio" @focus="form.smallRatio=''" placeholder-class="phcolor" class="tui-input" name="smallRatio" placeholder="填写数值"
|
|
|
+ type="number" style="width:160upx;border:1upx solid #cccccc;text-align:center;" />
|
|
|
+ <text style="margin-left:12upx;" v-if="Number(form.ratio)>0">X ¥{{parseFloat((Number(form.price)/Number(form.ratio)).toFixed(2))}} = ¥{{parseFloat((Number(form.smallRatio)*((Number(form.price)/Number(form.ratio)).toFixed(2))).toFixed(2))}}</text>
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">商城隐藏</view>
|
|
|
+ <view class="switch_bx">
|
|
|
+ <switch :checked="form.frontHide == 0 ? false : true" @change="frontHideChange" style="transform: scale(0.8,0.8)" />
|
|
|
+ <text v-if="form.frontHide == 0">否</text>
|
|
|
+ <text v-else>是</text>
|
|
|
+ </view>
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">库存类型</view>
|
|
|
+
|
|
|
+ <radio-group class="tui-input" @change="virtualStockChange">
|
|
|
+ <label class="list" for="realLink">
|
|
|
+ <radio id="realLink" value="0" :checked="form.virtualStock == 0" style="transform: scale(0.7,0.7);" />
|
|
|
+ <span class="checkbox-text" style="font-size:30upx;">真实</span>
|
|
|
+ </label>
|
|
|
+ <label class="list" for="virLink">
|
|
|
+ <radio id="virLink" value="1" :checked="form.virtualStock == 1" style="transform: scale(0.7,0.7);" />
|
|
|
+ <span class="checkbox-text" style="font-size:30upx;">虚拟</span>
|
|
|
+ </label>
|
|
|
+ </radio-group>
|
|
|
+
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <view class="app-footer">
|
|
|
+ <button class="admin-button-com big default" @click="goBack()">取消</button>
|
|
|
+ <button v-if="option.ptItemId" class="admin-button-com big blue" formType="submit" @click="status = 1">添加</button>
|
|
|
+ <button v-else class="admin-button-com big blue" formType="submit" @click="status = 1">确认</button>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ </form>
|
|
|
+
|
|
|
+ <modal-module :show="printLabelShow" @click="dialogInputConfirm" :maskClosable="true" title="打印数量" padding="30rpx 30rpx" >
|
|
|
+ <template v-slot:content>
|
|
|
+ <div class="app-modal-input-wrap">
|
|
|
+ <div class="inp-list-line">
|
|
|
+ <div class="line-input">
|
|
|
+ <input type="number" style="width:61.8%;text-align:center;" @focus="focus" @blur="blur" :focus="printFocus" v-model="printNum" :adjust-position="false" class="inp-input" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </modal-module>
|
|
|
+
|
|
|
+ <modal-module :show="onStockShow" @click="onStockConfirm" :maskClosable="true" title="路上库存" padding="30rpx 30rpx" >
|
|
|
+ <template v-slot:content>
|
|
|
+ <div class="app-modal-input-wrap">
|
|
|
+ <div class="inp-list-line">
|
|
|
+ <div class="line-input">
|
|
|
+ <input type="number" ref="input" style="width:62%;text-align:center;" v-model="newOnStock" @focus="newOnStock=''" :adjust-position="false" class="inp-input" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </modal-module>
|
|
|
+
|
|
|
+ </view>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <script>
|
|
|
+ import TuiListCell from "@/components/plugin/list-cell";
|
|
|
+ const form = require("@/utils/formValidation.js");
|
|
|
+ import { getAllItemClass } from "@/api/item-class";
|
|
|
+ import { applyAuth } from '@/api/item';
|
|
|
+ import { getAllUnit } from "@/api/unit";
|
|
|
+ import { addProduct,updateProduct,getProductDetail,py,print,modifyOnStockFn,delStatusUpdate } from "@/api/product";
|
|
|
+ import { getPtItemDetail } from "@/api/pt-item";
|
|
|
+ import { mapGetters } from "vuex"
|
|
|
+ //图片上传插件来源:https://ext.dcloud.net.cn/plugin?id=2922 已改造,不能再升级 shish 20211228
|
|
|
+ import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue'
|
|
|
+ import ModalModule from "@/components/plugin/modal"
|
|
|
+ export default {
|
|
|
+ name: "item-detail",
|
|
|
+ components: {
|
|
|
+ TuiListCell,
|
|
|
+ htzImageUpload,
|
|
|
+ ModalModule
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ onStockShow:false,
|
|
|
+ newOnStock:0,
|
|
|
+ status: 1,
|
|
|
+ currentImgData: [],
|
|
|
+ form: {
|
|
|
+ id:0,
|
|
|
+ name:"",
|
|
|
+ py:"",
|
|
|
+ stock:'',
|
|
|
+ onStock:'',
|
|
|
+ ratio:'',
|
|
|
+ bigUnitId:1,
|
|
|
+ smallUnitId:2,
|
|
|
+ classId:'',
|
|
|
+ price:'',
|
|
|
+ skPrice:'',
|
|
|
+ hjPrice:'',
|
|
|
+ hjAddPrice:2,
|
|
|
+ addPrice:3,
|
|
|
+ discountPrice:0,
|
|
|
+ hjDiscountPrice:0,
|
|
|
+ skDiscountPrice:0,
|
|
|
+ reachNum:0,
|
|
|
+ reachNumDiscount:0,
|
|
|
+ cost:0,
|
|
|
+ skMore:3,
|
|
|
+ weight:'',
|
|
|
+ cover:[],
|
|
|
+ stockWarning:5,
|
|
|
+ status:2,
|
|
|
+ itemId:0,
|
|
|
+ smallRatio:1,
|
|
|
+ frontHide:0,
|
|
|
+ virtualStock:0,
|
|
|
+ ratioType:0,
|
|
|
+ inTurn:100
|
|
|
+ },
|
|
|
+ itemClassSelectedData:{},
|
|
|
+ itemClassData:[],
|
|
|
+ unitData:[],
|
|
|
+ smallUnitSelectedData:{},
|
|
|
+ bigUnitSelectedData:{},
|
|
|
+ hasRequest:0,
|
|
|
+ onShowRefresh:0,
|
|
|
+ productData:{id:0},
|
|
|
+ headers:{token:''},
|
|
|
+ cost:0,
|
|
|
+ printItemId:0,
|
|
|
+ printNum:'',
|
|
|
+ printLabelShow:false,
|
|
|
+ printFocus:false
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed:{
|
|
|
+ ...mapGetters(["getLoginInfo","getDictionariesInfo"])
|
|
|
+ },
|
|
|
+ onLoad(option) {
|
|
|
+ if(option.id){
|
|
|
+ this.form.id = this.option.id
|
|
|
+ }
|
|
|
+ const token = uni.getStorageSync('token')
|
|
|
+ this.headers.token = token
|
|
|
+
|
|
|
+ //重复花材,删除花材之后,返回上一页花材,需要刷新
|
|
|
+ let pages = getCurrentPages();
|
|
|
+ let prevPage = pages[ pages.length - 2 ];
|
|
|
+ prevPage.$vm.onShowRefresh = 1
|
|
|
+ prevPage.$vm.hasRequest = 0
|
|
|
+
|
|
|
+ },
|
|
|
+ onShow(){
|
|
|
+ //重复花材,删除花材之后,返回上一页花材,需要刷新
|
|
|
+ if(this.onShowRefresh == 1){
|
|
|
+ if(this.hasRequest == 0){
|
|
|
+ this.init()
|
|
|
+ this.onShowRefresh = 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ showChangeOnStock(item){
|
|
|
+ let that = this
|
|
|
+ that.$util.confirmModal({content:'了解修改后的影响,确认要修改?'},() => {
|
|
|
+ this.onStockShow = true
|
|
|
+ this.newOnStock = item.onStock
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onStockConfirm(val){
|
|
|
+ let that=this;
|
|
|
+ if (val.index == 0) {
|
|
|
+ that.onStockShow = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ uni.showLoading()
|
|
|
+ modifyOnStockFn({id:that.option.id,onStock:that.newOnStock}).then(res=>{
|
|
|
+ if(res.code == 1){
|
|
|
+ uni.hideLoading()
|
|
|
+ that.form.onStock = that.newOnStock
|
|
|
+ that.onStockShow = false
|
|
|
+ that.$forceUpdate()
|
|
|
+ that.$msg(res.msg)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ delProduct(info){
|
|
|
+ let that = this
|
|
|
+ that.$util.confirmModal({content:'确认删除?'},() => {
|
|
|
+ delStatusUpdate({id:info.id,delStatus:1}).then(res=>{
|
|
|
+ if(res.code == 1){
|
|
|
+ that.hasRequest = 0
|
|
|
+ that.init()
|
|
|
+ that.$msg('删除成功')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getItemId(info){
|
|
|
+ this.$msg('花材编号 '+info.id)
|
|
|
+ },
|
|
|
+ ptAuth(info){
|
|
|
+ let that = this
|
|
|
+ that.$util.confirmModal({content:'确认申请?'},() => {
|
|
|
+ applyAuth({id:info.id}).then(res=>{
|
|
|
+ if(res.code == 1){
|
|
|
+ that.$msg('已提交申请')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ tjLinkage(){
|
|
|
+ if(this.form.discountPrice && Number(this.form.discountPrice)>0){
|
|
|
+ let skMore = this.form.skMore ? Number(this.form.skMore) : 0
|
|
|
+ let hjAddPrice = this.form.hjAddPrice ? Number(this.form.hjAddPrice) : 0
|
|
|
+ let addPrice = this.form.addPrice ? Number(this.form.addPrice) : 0
|
|
|
+
|
|
|
+ let skAddNum = Number(skMore) - Number(addPrice)
|
|
|
+ skAddNum = skAddNum.toFixed(2)
|
|
|
+ let skAmount = Number(skAddNum) + Number(this.form.discountPrice)
|
|
|
+ if(skAmount>0){
|
|
|
+ skAmount = skAmount.toFixed(2)
|
|
|
+ skAmount = parseFloat(skAmount)
|
|
|
+ this.form.skDiscountPrice = skAmount
|
|
|
+ }else{
|
|
|
+ this.form.skDiscountPrice = 0.01
|
|
|
+ }
|
|
|
+
|
|
|
+ let hjSubNum = Number(addPrice) - Number(hjAddPrice)
|
|
|
+ hjSubNum = hjSubNum.toFixed(2)
|
|
|
+ let hjAmount = Number(this.form.discountPrice) - Number(hjSubNum)
|
|
|
+ if(hjAmount > 0){
|
|
|
+ hjAmount = hjAmount.toFixed(2)
|
|
|
+ hjAmount = parseFloat(hjAmount)
|
|
|
+ this.form.hjDiscountPrice = hjAmount
|
|
|
+ }else{
|
|
|
+ this.form.hjDiscountPrice = 0.01
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ this.form.skDiscountPrice = 0
|
|
|
+ this.form.hjDiscountPrice = 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ priceLinkage(){
|
|
|
+ if(this.form.price && Number(this.form.price)>0){
|
|
|
+ let skMore = this.form.skMore ? Number(this.form.skMore) : 0
|
|
|
+ let hjAddPrice = this.form.hjAddPrice ? Number(this.form.hjAddPrice) : 0
|
|
|
+ let addPrice = this.form.addPrice ? Number(this.form.addPrice) : 0
|
|
|
+
|
|
|
+ let skAddNum = Number(skMore) - Number(addPrice)
|
|
|
+ skAddNum = skAddNum.toFixed(2)
|
|
|
+ let skAmount = Number(skAddNum) + Number(this.form.price)
|
|
|
+ if(skAmount>0){
|
|
|
+ skAmount = skAmount.toFixed(2)
|
|
|
+ skAmount = parseFloat(skAmount)
|
|
|
+ this.form.skPrice = skAmount
|
|
|
+ }else{
|
|
|
+ this.form.skPrice = ''
|
|
|
+ }
|
|
|
+
|
|
|
+ let hjSubNum = Number(addPrice) - Number(hjAddPrice)
|
|
|
+ hjSubNum = hjSubNum.toFixed(2)
|
|
|
+ let hjAmount = Number(this.form.price) - Number(hjSubNum)
|
|
|
+ if(hjAmount > 0){
|
|
|
+ hjAmount = hjAmount.toFixed(2)
|
|
|
+ hjAmount = parseFloat(hjAmount)
|
|
|
+ this.form.hjPrice = hjAmount
|
|
|
+ }else{
|
|
|
+ this.form.hjPrice = ''
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ this.form.skPrice = ''
|
|
|
+ this.form.hjPrice = ''
|
|
|
+ this.form.discountPrice = 0
|
|
|
+ this.form.skDiscountPrice = 0
|
|
|
+ this.form.hjDiscountPrice = 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ blur() {
|
|
|
+ this.printFocus = false
|
|
|
+ },
|
|
|
+ doPrintLabel(id){
|
|
|
+ this.printItemId = id
|
|
|
+ this.printLabelShow = true
|
|
|
+ this.printNum = null
|
|
|
+
|
|
|
+ setTimeout(x => {
|
|
|
+ this.$nextTick(() => this.setFocus()); // just watch out with going too fast !!!
|
|
|
+ }, 200);
|
|
|
+ },
|
|
|
+ setFocus() {
|
|
|
+ this.printFocus = true
|
|
|
+ },
|
|
|
+ dialogInputConfirm(val) {
|
|
|
+ let that=this;
|
|
|
+ if (val.index == 0) {
|
|
|
+ that.printLabelShow = false
|
|
|
+ that.printFocus = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let currentNum = this.printNum
|
|
|
+ let itemId = this.printItemId
|
|
|
+ if (currentNum == null) {
|
|
|
+ that.$msg('打印数量未填写')
|
|
|
+ that.printFocus = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (currentNum <= 0) {
|
|
|
+ that.$msg('打印数量不能小于等于0')
|
|
|
+ that.printFocus = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (itemId == 0) {
|
|
|
+ that.$msg('打印的花材id出错')
|
|
|
+ that.printLabelShow = false
|
|
|
+ that.printFocus = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ print({id:itemId,num:currentNum}).then(res=>{
|
|
|
+ if(res.code == 1){
|
|
|
+ that.printLabelShow = false
|
|
|
+ that.$msg(res.msg)
|
|
|
+ } else if(res.code == 0){
|
|
|
+ that.printLabelShow = false
|
|
|
+ that.printFocus = false
|
|
|
+ that.$msg(res.msg)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ ratioTypeChange(e) {
|
|
|
+ this.form.ratioType = e.detail.value;
|
|
|
+ },
|
|
|
+ fastSubmit(){
|
|
|
+ this.dialogInputConfirm({index: 1})
|
|
|
+ },
|
|
|
+ goPriceDetail(item){
|
|
|
+ this.$util.pageTo({url: "/admin/changePrice/changeList?id="+item.id})
|
|
|
+ },
|
|
|
+ goCostDetail(item){
|
|
|
+ this.$util.pageTo({url: "/admin/changePrice/costChangeList?id="+item.id})
|
|
|
+ },
|
|
|
+ goStockDetail(item){
|
|
|
+ this.$util.pageTo({url: "/pagesStorehouse/stockWarn/detailed?id="+item.id+'&name='+item.name})
|
|
|
+ },
|
|
|
+ virtualStockChange(e){
|
|
|
+ this.form.virtualStock = e.detail.value
|
|
|
+ },
|
|
|
+ frontHideChange(e){
|
|
|
+ this.form.frontHide = e.detail.value ? 1 : 0;
|
|
|
+ },
|
|
|
+ statusChange(e){
|
|
|
+ this.form.status = e.detail.value ? 1 : 2;
|
|
|
+ if(this.form.status == 2){
|
|
|
+ this.form.stock = 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ changeStock(event){
|
|
|
+ let num = Number(event.target.value)
|
|
|
+ if(num > 0){
|
|
|
+ this.form.status = 1
|
|
|
+ }else{
|
|
|
+ this.form.status = 2
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //获取拼音首字母 shish 20210707
|
|
|
+ fillName(event){
|
|
|
+ let val = event.target.value
|
|
|
+ py({
|
|
|
+ name:val
|
|
|
+ }).then(res => {
|
|
|
+ if(res.data.py){
|
|
|
+ this.form.py = res.data.py
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ goBack(){
|
|
|
+ uni.navigateBack({ delta: 1 })
|
|
|
+ },
|
|
|
+ changeBigUnitFn(e){
|
|
|
+ this.bigUnitSelectedData = this.unitData[e.detail.value];
|
|
|
+ this.form.bigUnitId = this.bigUnitSelectedData.id;
|
|
|
+ },
|
|
|
+ changeSmallUnitFn(e){
|
|
|
+ this.smallUnitSelectedData = this.unitData[e.detail.value];
|
|
|
+ this.form.smallUnitId = this.smallUnitSelectedData.id;
|
|
|
+ },
|
|
|
+ changeItemClassFn(e) {
|
|
|
+ this.itemClassSelectedData = this.itemClassData[e.detail.value];
|
|
|
+ this.form.classId = this.itemClassSelectedData.id;
|
|
|
+ },
|
|
|
+ //从平台选择花材 shish 20210826
|
|
|
+ getPtItemInfo(ptItemId){
|
|
|
+ getPtItemDetail({id:ptItemId}).then(res=>{
|
|
|
+
|
|
|
+ if (this.$util.isEmpty(res.data)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Object.keys(this.form).forEach((i, index) => {
|
|
|
+ this.form[i] = res.data[i];
|
|
|
+ });
|
|
|
+
|
|
|
+ this.currentImgData.push(res.data.bigCover)
|
|
|
+ this.form.cover = [res.data.shortCover]
|
|
|
+
|
|
|
+ this.form.stock = 0
|
|
|
+ this.form.itemId = ptItemId
|
|
|
+ this.form.classId = ''
|
|
|
+ this.form.status = 1
|
|
|
+ this.form.id = 0
|
|
|
+ this.form.price = ''
|
|
|
+ this.form.skMore = 6
|
|
|
+ this.form.addPrice = 3
|
|
|
+ this.form.hjAddPrice = 3
|
|
|
+ this.form.discountPrice = 0
|
|
|
+ this.form.cost = 0
|
|
|
+ this.form.smallRatio = 1
|
|
|
+ this.form.frontHide = 0
|
|
|
+ this.form.virtualStock = 0
|
|
|
+ this.cost = res.data && res.data.cost ? parseFloat(res.data.cost) : 0
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getDetail() {
|
|
|
+ let source = this.option.source ? this.option.source : ''
|
|
|
+ return getProductDetail({ id: this.option.id,source:source }).then(res => {
|
|
|
+ if (this.$util.isEmpty(res.data)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Object.keys(this.form).forEach((i) => {
|
|
|
+ this.form[i] = res.data[i]
|
|
|
+ });
|
|
|
+
|
|
|
+ this.currentImgData.push(res.data.bigCover)
|
|
|
+
|
|
|
+ this.form.cover = [res.data.shortCover]
|
|
|
+
|
|
|
+ this.form.price = res.data.prePrice
|
|
|
+
|
|
|
+ this.itemClassSelectedData = this.itemClassData.filter(
|
|
|
+ e => this.form.classId == e.id
|
|
|
+ )[0];
|
|
|
+ this.smallUnitSelectedData = this.unitData.filter(
|
|
|
+ e => this.form.smallUnitId == e.id
|
|
|
+ )[0];
|
|
|
+ this.bigUnitSelectedData = this.unitData.filter(
|
|
|
+ e => this.form.bigUnitId == e.id
|
|
|
+ )[0];
|
|
|
+ this.productData = res.data
|
|
|
+ this.cost = res.data.cost || 0
|
|
|
+
|
|
|
+ });
|
|
|
+ },
|
|
|
+ imgUploadSuccess(res) {
|
|
|
+ var _res = JSON.parse(res.data)
|
|
|
+ if(_res.code == 1){
|
|
|
+ this.currentImgData.push(_res.data.bigUrl)
|
|
|
+ this.form.cover.push(_res.data.shortUrl)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ imgDeleteFn(res){
|
|
|
+ const index = res.index
|
|
|
+ this.form.cover.splice(index,1)
|
|
|
+ },
|
|
|
+ init() {
|
|
|
+ //从平台选择花材
|
|
|
+ if(!this.$util.isEmpty(this.option.ptItemId)){
|
|
|
+ uni.setNavigationBarTitle({title: "确认花材信息"})
|
|
|
+ }
|
|
|
+ //onShow不能重新请求数据,不然好像会造成上传图片有问题
|
|
|
+ if(this.hasRequest == 1){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this._getAllUnit().then(res=>{
|
|
|
+ this._getAllItemClass().then(res => {
|
|
|
+ if(this.form.id == 0){
|
|
|
+ this.smallUnitSelectedData = this.unitData.filter(e => 2 == e.id)[0];
|
|
|
+ this.bigUnitSelectedData = this.unitData.filter(e => 1 == e.id)[0];
|
|
|
+ //从平台选择花材
|
|
|
+ if(!this.$util.isEmpty(this.option.ptItemId)){
|
|
|
+ this.getPtItemInfo(this.option.ptItemId)
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ this.getDetail();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+ this.hasRequest = 1
|
|
|
+ },
|
|
|
+ async _getAllUnit() {
|
|
|
+ await getAllUnit().then(res => {
|
|
|
+ if (this.$util.isEmpty(res.data)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ this.unitData = res.data.list;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ async _getAllItemClass() {
|
|
|
+ await getAllItemClass().then(res => {
|
|
|
+ if (this.$util.isEmpty(res.data)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ this.itemClassData = res.data;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 确认
|
|
|
+ confirmFn() {
|
|
|
+ if (this.$util.isEmpty(this.form.cover)) {
|
|
|
+ this.$msg("请上传图片")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ let requestHost = addProduct
|
|
|
+ if(this.form.id && this.form.id != 0){
|
|
|
+ requestHost = updateProduct;
|
|
|
+ }else{
|
|
|
+ if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.stock) == false){
|
|
|
+ uni.showToast({title:"请填写库存,没有请填0",icon:"none"})
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.discountPrice) == false){
|
|
|
+ uni.showToast({title:"请填写特价,没有特价请填0",icon:"none"})
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.cost) == false){
|
|
|
+ uni.showToast({title:"请填写成本",icon:"none"})
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.price) == false){
|
|
|
+ uni.showToast({title:"请填写批发价",icon:"none"})
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.hjAddPrice) == false){
|
|
|
+ uni.showToast({title:"请填写大客价加价",icon:"none"})
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.addPrice) == false){
|
|
|
+ uni.showToast({title:"请填写批发价加价",icon:"none"})
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.skMore) == false){
|
|
|
+ uni.showToast({title:"请填写零售价加价",icon:"none"})
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let form = JSON.parse(JSON.stringify(this.form))
|
|
|
+ uni.showLoading({mask:true,title:'提交中'})
|
|
|
+ requestHost({...form,cover:this.form.cover[0],appVersion:1}).then(res => {
|
|
|
+ uni.hideLoading()
|
|
|
+ if(res.code == 1){
|
|
|
+ this.$msg("操作成功");
|
|
|
+
|
|
|
+ //返回上一页带参数
|
|
|
+ let pages = getCurrentPages();
|
|
|
+ let prevPage = pages[ pages.length - 2 ];
|
|
|
+ let hidden = 0
|
|
|
+ if(this.form.stock > this.form.stockWarning){
|
|
|
+ hidden = 1
|
|
|
+ }
|
|
|
+ prevPage.$vm.modifyStock = {id:this.form.id,stock:this.form.stock,hidden:hidden};
|
|
|
+
|
|
|
+ uni.navigateBack({})
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 表单验证
|
|
|
+ formSubmit(e) {
|
|
|
+ // 表单规则
|
|
|
+ let rules = [
|
|
|
+ {
|
|
|
+ name: "name",
|
|
|
+ rule: ["required"],
|
|
|
+ msg: ["请填写名称"]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "py",
|
|
|
+ rule: ["required"],
|
|
|
+ msg: ["请填写拼音缩写"]
|
|
|
+ },{
|
|
|
+ name: "stock",
|
|
|
+ rule: ["required"],
|
|
|
+ msg: ["请填写库存,没有填0"]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "bigUnitId",
|
|
|
+ rule: ["required"],
|
|
|
+ msg: ["请选择大单位"]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "smallUnitId",
|
|
|
+ rule: ["required"],
|
|
|
+ msg: ["请选择小单位"]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "price",
|
|
|
+ rule: ["required"],
|
|
|
+ msg: ["请填写批发价"]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "skPrice",
|
|
|
+ rule: ["required"],
|
|
|
+ msg: ["请填写零售价"]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "hjPrice",
|
|
|
+ rule: ["required"],
|
|
|
+ msg: ["请填写大客价"]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "hjAddPrice",
|
|
|
+ rule: ["required"],
|
|
|
+ msg: ["请填写大客价加价"]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "addPrice",
|
|
|
+ rule: ["required"],
|
|
|
+ msg: ["请填写批发价加价"]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "discountPrice",
|
|
|
+ rule: ["required"],
|
|
|
+ msg: ["不做特价请填0"]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "cost",
|
|
|
+ rule: ["required"],
|
|
|
+ msg: ["请填写成本"]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "skMore",
|
|
|
+ rule: ["required"],
|
|
|
+ msg: ["请填写零售价加价"]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "weight",
|
|
|
+ rule: ["required"],
|
|
|
+ msg: ["请填写重量"]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "classId",
|
|
|
+ rule: ["required"],
|
|
|
+ msg: ["请选择分类"]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "stockWarning",
|
|
|
+ rule: ["required"],
|
|
|
+ msg: ["请填写库存预警"]
|
|
|
+ }
|
|
|
+ ];
|
|
|
+ // 进行表单检查
|
|
|
+ let formData = e.detail.value;
|
|
|
+ let checkRes = form.validation(formData, rules);
|
|
|
+ // 验证通过!
|
|
|
+ if (!checkRes) {
|
|
|
+ this.confirmFn()
|
|
|
+ } else {
|
|
|
+ this.$msg(checkRes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ </script>
|
|
|
+ <style lang="scss" scoped>
|
|
|
+ .app-content {
|
|
|
+ min-height: calc(100vh - 100upx);
|
|
|
+ padding-bottom: 150upx;
|
|
|
+ }
|
|
|
+ // 公共模块
|
|
|
+ .module-com {
|
|
|
+ margin-bottom: 20upx;
|
|
|
+ background-color: #fff;
|
|
|
+ color: $fontColor2;
|
|
|
+ .module-tit {
|
|
|
+ padding: 20upx 30upx;
|
|
|
+ font-size: 28upx;
|
|
|
+ }
|
|
|
+ .module-det {
|
|
|
+ padding: 0 30upx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .category-wrap {
|
|
|
+ align-items: flex-start;
|
|
|
+ padding-bottom: 0 !important;
|
|
|
+ .tui-input {
|
|
|
+ @include disFlex(center, flex-start);
|
|
|
+ flex-wrap: wrap;
|
|
|
+ .admin-button-com {
|
|
|
+ margin-right: 20upx;
|
|
|
+ margin-bottom: 20upx;
|
|
|
+ position: relative;
|
|
|
+ z-index: 9999;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .summary-wrap {
|
|
|
+ .goods-summary {
|
|
|
+ height: 400upx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .app-footer {
|
|
|
+ justify-content: space-evenly;
|
|
|
+ z-index: 9999;
|
|
|
+ .admin-button-com {
|
|
|
+ width: 46%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ </style>
|