| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483 |
- <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="getProductId(productData)">
- {{productData.id?productData.id:0}}-{{productData.itemId?productData.itemId:0}}
- </view>
- <button v-if="productData.id > 0" class="admin-button-com blue middle" @click="moreDo()">更多操作</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="请填写拼音首字母缩写" type="text" style="width:300upx" />
- <button v-if="option.ptItemId" class="admin-button-com big blue" formType="submit" @click="status = 1" style="width:150upx;padding-top:18upx;padding-bottom:18upx;">添加</button>
- <button v-else class="admin-button-com big blue" formType="submit" @click="status = 1" style="width:150upx;padding-top:18upx;padding-bottom:18upx;">确认</button>
- </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?form.onStock:0}}
- </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>
- <input v-model="form.classId" name="classId" type="text" hidden />
- <view style="color:#CCCCCC;width:450upx;height:45upx;" @click.stop="changeClass()" v-if="form.classId == 0">
- 请选择分类
- </view>
- <view @click.stop="changeClass()" style="width:450upx;height:45upx;" v-else>
- {{form.className}}
- </view>
- </tui-list-cell>
- <tui-list-cell class="line-cell" :hover="false">
- <view class="tui-title">比例类型</view>
- <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" :hover="false">
- <view class="tui-title">大单位</view>
- <input v-model="form.bigUnitId" name="bigUnitId" type="text" hidden />
- <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;" @click.stop="notAllowChange()">修改</button>
- </tui-list-cell>
- <tui-list-cell class="line-cell" :arrow="false" :hover="false">
- <view class="tui-title">小单位</view>
- <input v-model="form.smallUnitId" name="smallUnitId" type="text" hidden />
- <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;" @click.stop="notAllowChange()">修改</button>
- </tui-list-cell>
- <tui-list-cell class="line-cell" :arrow="false" v-if="form.ratioType == 0" :hover="false">
- <view class="tui-title">单位比</view>
- <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;" @click.stop="notAllowChange()">修改</button>
- </tui-list-cell>
- <tui-list-cell class="line-cell" :arrow="false" :hover="false">
- <view class="tui-title">每扎重量</view>
- <input v-model="form.weight" disabled="true" placeholder-class="phcolor" @click="$msg('不可修改')" style="width:200upx;color:#CCCCCC;"
- class="tui-input" name="weight" placeholder="公斤" maxlength="50" type="digit" />
- <view class="weight-reminder-icon" @click="showWeightPopup" style="margin-right: 20upx;">
- <text style="color: #999; font-size: 32upx; font-weight: bold;">?</text>
- </view>
- <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;" @click.stop="notAllowChange()">修改</button>
- </tui-list-cell>
- <tui-list-cell class="line-cell" :hover="false">
- <view class="tui-title">每人限购</view>
- <input v-model="form.limitBuy" style="width:300upx;" @focus="form.limitBuy=''" placeholder-class="phcolor" class="tui-input" name="limitBuy" placeholder="请填写,填0不限购" maxlength="50" type="number" />
- <button v-if="productData.id > 0 && form.limitBuy>0" class="admin-button-com blue middle" @click.stop="clearBuyCache()" style="width:150upx;">清已购</button>
- <button v-else class="admin-button-com default middle" style="width:150upx;" @click.stop="">清已购</button>
- </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>
- <tui-list-cell class="line-cell" :arrow="true">
- <view class="tui-title">采购人</view>
- <view @click="changeCgStaff()" style="width:400upx;">{{ productData.cgStaffName?productData.cgStaffName:'未设置' }}</view>
- </tui-list-cell>
- </view>
- <view class="module-com input-line-wrap goods-wrap">
- <view class="module-tit">
- <span>花材图片(最多5张)</span>
- <span class="app-color-3"></span>
- </view>
- <view class="module-det">
- <htz-image-upload :max="5" :compress="true" v-model="currentImgData" :headers="headers"
- @uploadSuccess="imgUploadSuccess" @imgDelete="imgDeleteFn" :action="getLoginInfo.imgUploadApi">
- </htz-image-upload>
- </view>
- <tui-list-cell class="line-cell category-wrap" :hover="false">
- <view class="tui-title">封面</view>
- <view class="tui-input">
- <block v-if="coverImgData.length > 0">
- <button class="admin-button-com" :class="[(form.cover == item) ? '' : 'default']"
- v-for="(item, index) in coverImgData" :key="index"
- @click="selCoverFn(index)" >第{{ index + 1 }}张</button>
- </block>
- <view v-else class="no-img-tip">请先上传图片</view>
- <view v-if="coverImgData.length > 0" class="use-img">选择上面的图片作为封面</view>
- </view>
- </tui-list-cell>
- </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>
- <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>
- <tui-list-cell class="line-cell" :hover="false">
- <view class="tui-title">单独统计</view>
- <radio-group class="tui-input" @change="belongCostChange">
- <label class="list" for="noLink">
- <radio id="noLink" value="0" :checked="belongCost == 0" style="transform: scale(0.7,0.7);" />
- <span class="checkbox-text" style="font-size:30upx;">不要</span>
- </label>
- <label class="list" for="needLink">
- <radio id="needLink" value="1" :checked="belongCost == 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>
- <view class="app-modal-input-wrap">
- <view class="inp-list-line">
- <view class="line-input">
- <input type="number" style="width:61.8%;text-align:center;" @focus="printToFocus" @blur="blur" :focus="printFocus" v-model="printNum" :adjust-position="false" class="inp-input" />
- </view>
- </view>
- </view>
- </template>
- </modal-module>
- <modal-module :show="onStockShow" @click="onStockConfirm" :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="newOnStock" @focus="newOnStock=''" :adjust-position="false" class="inp-input" />
- </view>
- </view>
- </view>
- </template>
- </modal-module>
- <uni-popup ref="classRef" background-color="#fff" type="center" :animation="false" class="class-popup-style">
- <view style="margin-left:30upx;margin-top:19upx;font-size:27upx;font-weight:bold;">请选择分类:</view>
- <view style="display:flex;padding:20upx 20upx 90upx 20upx;height:auto;justify-content: space-between;align-items:center;flex-wrap:wrap;max-height:100vh;overflow:auto;z-index:9999;">
- <view v-for="(item, index) in itemClassData" :key="index" @tap.stop="setThisClass(item)" style="margin-bottom:20upx;margin-left:3upx;">
- <image :src="item.cover" style="width:120upx;height:120upx;border-radius:10upx;"></image>
- <view style="margin-top:5upx;overflow: hidden;white-space: nowrap;width:120upx;text-align:center;">{{item.name}}</view>
- </view>
- </view>
- </uni-popup>
- <uni-popup ref="rightShowMore" background-color="#fff" type="center" :animation="true" class="class-popup-style">
- <view style="display:flex;width:100vw;padding:20upx 20upx 40upx 20upx;height:auto;justify-content: space-between;align-items:center;flex-wrap:wrap;max-height:100vh;overflow:auto;">
- <view style="width:100vw;margin-top:8upx;"><button @click="goWaste(productData)">报损</button></view>
- <view style="width:100vw;margin-top:8upx;"><button @click="goPart(productData)">拆散</button></view>
- <view style="width:100vw;margin-top:8upx;"><button @click="orderRecord(productData)">下单记录</button></view>
- <view style="width:100vw;margin-top:8upx;"><button @click="copyCreate(productData)">复制新建</button></view>
- <view style="width:100vw;margin-top:8upx;"><button @click="onStockChange(productData)">路上库存变动</button></view>
- <view style="width:100vw;margin-top:8upx;" v-if="productData.delStatus == 0"><button @click="changeDelStatus(productData,1)">删除</button></view>
- <view style="width:100vw;margin-top:8upx;" v-if="productData.delStatus == 1"><button @click="changeDelStatus(productData,0)">取消删除</button></view>
- <view style="width:100vw;margin-top:30upx;"><button @click="closeMoreDoPop()">取消</button></view>
- </view>
- </uni-popup>
- <modal-module :show="wasteShow" @click="wasteConfirm" :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:61.8%;text-align:center;" @blur="wasteBlur" :focus="wasteFocus" v-model="wasteNum" :adjust-position="false" class="inp-input" />
- </view>
- </view>
- </view>
- </template>
- </modal-module>
- <modal-module :show="partShow" @click="partConfirm" :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:61.8%;text-align:center;" @blur="partBlur" :focus="partFocus" v-model="partNum" :adjust-position="false" class="inp-input" />
- </view>
- </view>
- </view>
- </template>
- </modal-module>
- <uni-popup ref="staffRef" 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 staffData" :key="index" @tap.stop="getStaff(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:30upx;">{{item.name}}</view>
- </view>
- </view>
- <view style="text-align:center;padding:10upx 0 10upx 0;"><button class="admin-button-com big blue" @click="cancelStaff()">取消选择</button></view>
- </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>
- <uni-popup ref="weightRef" background-color="#fff" type="center" :animation="false" class="weight-popup-style">
- <view class="weight-popup-container">
- <view class="weight-popup-title">花材重量参考</view>
- <view class="weight-popup-content">
- <view class="weight-item" v-for="(item, index) in weightReferenceData" :key="index">
- <text class="weight-name">{{ item.name }}</text>
- <text class="weight-value">{{ item.weight }}</text>
- </view>
- </view>
- <view class="weight-popup-note">以上含纸箱平摊下来的重量,请认真填写,跑腿费会参考这边设置的重量</view>
- <view class="weight-popup-footer">
- <button class="admin-button-com big blue" @click="closeWeightPopup">确定</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>
- <script>
- import TuiListCell from "@/components/plugin/list-cell";
- const form = require("@/utils/formValidation.js");
- import { getAllItemClass } from "@/api/item-class";
- import { applyAuth,modifyCgStaff,setLosing,modifyUnit,modifyRatio,modifyWeight,clearLimitBuy } from '@/api/item';
- import { getAllUnit } from "@/api/unit";
- import { addProduct,updateProduct,getProductDetail,py,print,modifyOnStockFn,delStatusUpdate,changeBelongCost } from "@/api/product";
- import { getPtItemDetail } from "@/api/pt-item";
- import { wastage } from "@/api/order";
- 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"
- import { getAllStaff } from "@/api/shop-admin";
- import { partItem } from "@/api/part";
- export default {
- name: "item-detail",
- components: {
- TuiListCell,
- htzImageUpload,
- ModalModule
- },
- data() {
- return {
- writeRatioShow:false,
- newRatio:'',
- writeWeightShow:false,
- newWeight:'',
- onStockShow:false,
- newOnStock:0,
- status: 1,
- currentImgData: [],
- form: {
- id:0,
- name:"",
- py:"",
- stock:'',
- onStock:'',
- ratio:'',
- bigUnitId:1,
- smallUnitId:2,
- classId:'',
- className:'',
- price:'',
- skPrice:'',
- hjPrice:'',
- hjAddPrice:2,
- addPrice:3,
- discountPrice:0,
- hjDiscountPrice:0,
- skDiscountPrice:0,
- reachNum:0,
- reachNumDiscount:0,
- cost:0,
- skMore:3,
- weight:'',
- cover: "",
- images: [],
- limitBuy:0,
- stockWarning:5,
- status:2,
- itemId:0,
- frontHide:0,
- virtualStock:0,
- ratioType:0,
- inTurn:100,
- cpInfo:[]
- },
- itemClassData:[],
- unitData:[],
- smallUnitSelectedData:{},
- bigUnitSelectedData:{},
- hasRequest:0,
- onShowRefresh:0,
- productData:{id:0},
- headers:{token:''},
- cost:0,
- printItemId:0,
- printNum:'',
- printLabelShow:false,
- backCpInfo:{cpId:0,cpName:'',needUpdate:0},
- wasteNum:'',
- wasteShow:false,
- wasteFocus:false,
- partNum:'',
- partShow:false,
- partFocus:false,
- belongCost:0,
- staffData:[],
- modifyUnitType:'big',
- weightReferenceData:[
- {name: '单头玫瑰', weight: '1.2公斤'},
- {name: '多头玫瑰', weight: '1.2公斤'},
- {name: '百合', weight: '2.7公斤'},
- {name: '康乃馨', weight: '1公斤'},
- {name: '向日葵', weight: '2.7公斤或3公斤'},
- {name: '其他', weight: '0.5公斤或1公斤'}
- ],
- printFocus:false
- };
- },
- computed:{
- ...mapGetters(["getLoginInfo","getDictionariesInfo"]),
- coverImgData() {
- return this.form.images || [];
- }
- },
- 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
- getAllStaff().then(res=>{
- if(res.code == 1){
- this.staffData = res.data.list ? res.data.list : []
- }
- })
- },
- onShow(){
- let that = this
- //重复花材,删除花材之后,返回上一页花材,需要刷新
- if(this.onShowRefresh == 1){
- if(this.hasRequest == 0){
- this.init()
- this.onShowRefresh = 0
- }
- }
- if(this.backCpInfo.needUpdate == 1){
- let needAdd = 1;
- if (!this.$util.isEmpty(this.form.cpInfo)) {
- that.form.cpInfo.forEach((item) => {
- if(item.cpId == that.backCpInfo.cpId){
- needAdd = 0
- }
- })
- }
- if(needAdd == 1){
- that.form.cpInfo.push({cpId:that.backCpInfo.cpId,cpName:that.backCpInfo.cpName})
- that.backCpInfo.needUpdate = 0
- that.$forceUpdate()
- }
- }
- },
- methods: {
- printToFocus(){
- },
- selCoverFn(index) {
- this.form.cover = this.form.images[index];
- },
- showWeightPopup(){
- this.$refs.weightRef.open('center')
- },
- closeWeightPopup(){
- this.$refs.weightRef.close()
- },
- clearBuyCache(){
- let that = this
- that.$util.confirmModal({content:'确认清除已购?清除后客户可再次下单'},() => {
- clearLimitBuy({id:this.productData.id}).then(res=>{
- if(res.code == 1){
- this.$msg('已清除')
- }
- })
- })
- },
- notAllowChange(){
- if(this.productData.hasRightChangeReason!=''){
- this.$msg(this.productData.hasRightChangeReason)
- }else{
- this.$msg('未知原因造成不可修改')
- }
- },
- 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=>{
- if(res.code == 1){
- this.$msg(res.msg)
- this.getDetail()
- }
- })
- },
- cancelStaff(){
- this.$refs.staffRef.close()
- },
- changeCgStaff(){
- this.$refs.staffRef.open('center')
- },
- delOneCp(info,index){
- let that = this
- that.$util.confirmModal({content:'确认删除'+info.cpName+'?'},() => {
- that.form.cpInfo.splice(index,1)
- that.$forceUpdate()
- })
- },
- changeCp(item){
- this.$util.pageTo({url: '/admin/cp/list?skip=1'})
- },
- changeClass(item){
- this.$refs.classRef.open('center')
- },
- setThisClass(info){
- this.$refs.classRef.close()
- this.form.classId = info.id ? info.id : 0
- this.form.className = info.name ? info.name : ''
- this.$forceUpdate()
- },
- onStockChange(info){
- this.closeMoreDoPop()
- this.pageTo({url: '/pagesStorehouse/stockWarn/onStockChange?id='+info.id+'&name='+info.name})
- },
- goPart(){
- this.closeMoreDoPop()
- this.partShow = true
- let that = this
- setTimeout(x => {
- this.$nextTick(() => {
- that.partFocus = true
- })
- }, 300)
- },
- partBlur(){
- this.partFocus = false
- },
- closePartPop(){
- this.partShow = false
- this.partFocus = false
- this.partNum = ''
- },
- partConfirm(val){
- let that = this
- if (val.index == 0) {
- this.closePartPop()
- return
- }
- if(Number(that.partNum)<0){
- that.$msg('请填写数量')
- return false
- }
- let product = [{ productId:that.productData.id,bigNum:that.partNum,smallNum:null,classId:0,itemId:that.productData.itemId,ratio:that.productData.ratio }]
- that.$util.confirmModal({content:'确认拆散?'},() => {
- partItem({product:JSON.stringify(product),remark:''}).then((res) => {
- if(res.code == 1){
- that.closePartPop()
- that.hasRequest = 0
- that.init()
- }
- })
- })
- },
- goWaste(){
- this.closeMoreDoPop()
- this.wasteShow = true
- let that = this
- setTimeout(x => {
- this.$nextTick(() => {
- that.wasteFocus = true
- })
- }, 300)
- },
- wasteBlur(){
- this.wasteFocus = false
- },
- closeWastePop(){
- this.wasteShow = false
- this.wasteFocus = false
- 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
- if (val.index == 0) {
- this.closeWastePop()
- return
- }
- if(Number(that.wasteNum)<0){
- that.$msg('请填写数量')
- return false
- }
- let product = [{ productId:that.productData.id,bigNum:that.wasteNum,smallNum:null,classId:0,itemId:that.productData.itemId,ratio:that.productData.ratio }]
- that.$util.confirmModal({content:'确认报损?'},() => {
- wastage({product:JSON.stringify(product),remark:''}).then((res) => {
- if(res.code == 1){
- that.closeWastePop()
- that.hasRequest = 0
- that.init()
- }
- });
- })
- },
- orderRecord(info){
- this.closeMoreDoPop()
- this.pageTo({url: "/admin/order/itemOrder?productId="+info.id})
- },
- moreDo(){
- this.$refs.rightShowMore.open('top')
- },
- copyCreate(info){
- this.closeMoreDoPop()
- this.pageTo({url: '/admin/item/copy?id='+info.id})
- },
- closeMoreDoPop(){
- this.$refs.rightShowMore.close()
- },
- 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)
- }
- })
- },
- changeDelStatus(info,flag){
- let that = this
- this.closeMoreDoPop()
- let remind = flag == 1 ? '确认删除?' : '确认恢复?'
- that.$util.confirmModal({content:remind},() => {
- delStatusUpdate({id:info.id,delStatus:flag}).then(res=>{
- if(res.code == 1){
- that.hasRequest = 0
- that.init()
- that.$msg(res.msg)
- }
- })
- })
- },
- getProductId(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())
- }, 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
- },
- belongCostChange(e){
- let that = this
- this.belongCost = e.detail.value
- changeBelongCost({id:this.productData.id,belongCost:this.belongCost}).then(res=>{
- if(res.code == 1){
- that.$msg(res.msg)
- }
- })
- },
- 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;
- },
- 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.form.cover = res.data.shortCover
- if(!this.$util.isEmpty(res.data.images)){
- const imageUrls = (res.data.images || '').split(',').filter(i => i);
- this.form.images = imageUrls;
- this.currentImgData = imageUrls.map(url => {
- return this.constant.imgUrl + '/' + url + '?x-oss-process=image/resize,m_fill,h_700,w_700'
- })
- if(this.form.cover==''){
- this.form.cover = this.form.images[0]
- }
- }else{
- this.currentImgData.push(res.data.bigCover)
- this.form.images = [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.frontHide = 0
- this.form.virtualStock = 0
- this.form.limitBuy = 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]
- });
- const imageUrls = (res.data.images || '').split(',').filter(i => i);
- this.form.images = imageUrls;
- this.currentImgData = imageUrls.map(url => {
- return this.constant.imgUrl + '/' + url + '?x-oss-process=image/resize,m_fill,h_700,w_700'
- });
- this.form.cover = res.data.shortCover || '';
- if (!this.form.cover && this.form.images.length > 0) {
- this.form.cover = this.form.images[0];
- }
- this.form.price = res.data.prePrice
- let currentClass = this.itemClassData.filter(
- e => this.form.classId == e.id
- )[0];
- if(currentClass){
- this.form.className = currentClass.name ? currentClass.name : ''
- }
- 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 ? res.data.cost : 0
- this.belongCost = res.data.belongCost ? res.data.belongCost : 0
- });
- },
- imgUploadSuccess(res) {
- var _res = JSON.parse(res.data)
- if(_res.code == 1){
- this.currentImgData.push(_res.data.bigUrl)
- this.form.images.push(_res.data.shortUrl)
- if (!this.form.cover) {
- this.form.cover = _res.data.shortUrl;
- }
- }
- },
- imgDeleteFn(res){
- const index = res.index;
- const deletedUrl = this.form.images[index];
- this.form.images.splice(index, 1);
- if (this.form.cover === deletedUrl) {
- this.form.cover = this.form.images[0] || '';
- }
- },
- 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.images)) {
- this.$msg("请上传图片")
- return false
- }
- if (!this.form.cover && this.form.images.length > 0) {
- this.form.cover = this.form.images[0];
- }
- 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))
- form.images = form.images.join(',')
- uni.showLoading({mask:true,title:'提交中'})
- requestHost({...form,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: ["请填写库存预警"]
- },
- {
- name: "limitBuy",
- rule: ["required"],
- msg: ["请填写限购数,0不限购"]
- },
- ];
- // 进行表单检查
- 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%;
- }
- }
- // 权重提醒图标样式
- .weight-reminder-icon {
- margin-left: 20upx;
- padding: 10upx;
- width: 60upx;
- height: 60upx;
- display: flex;
- align-items: center;
- justify-content: center;
- background-color: #f5f5f5;
- border-radius: 50%;
- border: 1upx solid #ddd;
- }
- // 权重弹窗样式
- .weight-popup-style {
- .weight-popup-container {
- width: 600upx;
- max-height: 80vh;
- padding: 30upx;
- border-radius: 16upx;
- background-color: #fff;
- z-index:9999;
- .weight-popup-title {
- font-size: 32upx;
- font-weight: bold;
- color: #333;
- text-align: center;
- margin-bottom: 30upx;
- }
-
- .weight-popup-content {
- .weight-item {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 20upx 0;
- border-bottom: 1upx solid #f0f0f0;
-
- &:last-child {
- border-bottom: none;
- }
-
- .weight-name {
- font-size: 28upx;
- color: #333;
- font-weight: 500;
- }
-
- .weight-value {
- font-size: 28upx;
- color: #666;
- }
- }
- }
-
- .weight-popup-note {
- margin-top: 30upx;
- padding: 20upx;
- background-color: #f8f8f8;
- border-radius: 8upx;
- font-size: 28upx;
- color: #999;
- line-height: 1.5;
- }
-
- .weight-popup-footer {
- margin-top: 30upx;
- display: flex;
- justify-content: center;
- }
- }
- }
- .use-img{
- font-size: 22rpx;
- color: #999999;
- padding: 4rpx 8rpx;
- line-height: 1.5;
- }
- .no-img-tip {
- font-size: 26rpx;
- color: #cccccc;
- padding: 12rpx 0;
- }
- </style>
|