detail.vue 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483
  1. <template>
  2. <view class="app-content">
  3. <!-- 花材基本信息 -->
  4. <form @submit="formSubmit">
  5. <view class="module-com input-line-wrap">
  6. <block v-if="!$util.isEmpty(productData) && productData.delStatus == 1">
  7. <view style="color:red;background-color: yellow;font-size:29upx;font-weight:bold;padding-top:20upx;padding-bottom:20upx;text-align:center;">
  8. 已删除
  9. </view>
  10. </block>
  11. <block v-else>
  12. <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"
  13. @click="pageTo({url: '/admin/item/detail?id='+productData.repeatId})">
  14. 存在重复编号花材,点击查看,请删除其中一个
  15. </view>
  16. </block>
  17. <tui-list-cell class="line-cell" :hover="false" v-if="productData.id && productData.id>0">
  18. <view class="tui-title">编号</view>
  19. <view style="color:#CCCCCC;width:300upx;" @click="getProductId(productData)">
  20. {{productData.id?productData.id:0}}-{{productData.itemId?productData.itemId:0}}
  21. </view>
  22. <button v-if="productData.id > 0" class="admin-button-com blue middle" @click="moreDo()">更多操作</button>
  23. </tui-list-cell>
  24. <tui-list-cell class="line-cell" :hover="false">
  25. <view class="tui-title">名称</view>
  26. <input v-model="form.name" placeholder-class="phcolor" class="tui-input" name="name" placeholder="请填写名称" @input="fillName($event)" maxlength="50" type="text" />
  27. </tui-list-cell>
  28. <tui-list-cell class="line-cell" :hover="false">
  29. <view class="tui-title">初始名称</view>
  30. <view style="color:#CCCCCC;width:300upx;height:45upx;display:flex;align-items:center;overflow:hidden;">
  31. {{productData.ptItemInfo ? productData.ptItemInfo.name : ''}}
  32. <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>
  33. </view>
  34. <button v-if="productData.id > 0 && productData.auth == 0" class="admin-button-com blue mini-btn" @click="ptAuth(productData)">申请认证</button>
  35. </tui-list-cell>
  36. <tui-list-cell class="line-cell" :hover="false">
  37. <view class="tui-title">拼音缩写</view>
  38. <input v-model="form.py" placeholder-class="phcolor" class="tui-input" name="py" placeholder="请填写拼音首字母缩写" type="text" style="width:300upx" />
  39. <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>
  40. <button v-else class="admin-button-com big blue" formType="submit" @click="status = 1" style="width:150upx;padding-top:18upx;padding-bottom:18upx;">确认</button>
  41. </tui-list-cell>
  42. <tui-list-cell class="line-cell" :hover="false">
  43. <view class="tui-title">价格</view>
  44. <input v-model="form.hjPrice" style="width:130upx;border:1upx solid #CCCCCC;text-align:center;height:50upx;" placeholder-class="phcolor"
  45. class="tui-input" name="hjPrice" @focus="form.hjPrice=''" placeholder="大客价" type="digit" />
  46. <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"
  47. class="tui-input" name="price" @focus="form.price=''" placeholder="批发价" type="digit" @input="priceLinkage()" />
  48. <input v-model="form.skPrice" style="width:130upx;border:1upx solid #CCCCCC;text-align:center;height:50upx;margin-left:30upx;" placeholder-class="phcolor"
  49. class="tui-input" name="skPrice" @focus="form.skPrice=''" placeholder="零售价" type="digit" />
  50. </tui-list-cell>
  51. <tui-list-cell class="line-cell" :hover="false">
  52. <view class="tui-title">特价</view>
  53. <input v-model="form.hjDiscountPrice" style="width:130upx;border:1upx solid #CCCCCC;text-align:center;height:50upx;" placeholder-class="phcolor"
  54. class="tui-input" name="hjDiscountPrice" @focus="form.hjDiscountPrice=''" placeholder="会员特价" type="digit" />
  55. <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()"
  56. class="tui-input" name="discountPrice" @focus="form.discountPrice=''" placeholder="无特价填0" maxlength="50" type="digit" />
  57. <input v-model="form.skDiscountPrice" style="width:130upx;border:1upx solid #CCCCCC;text-align:center;height:50upx;margin-left:30upx;" placeholder-class="phcolor"
  58. class="tui-input" name="skDiscountPrice" @focus="form.skDiscountPrice=''" placeholder="零售特价" type="digit" />
  59. </tui-list-cell>
  60. <tui-list-cell class="line-cell" :hover="false">
  61. <view class="tui-title">下单满</view>
  62. <input v-model="form.reachNum" style="width:130upx;border:1upx solid #CCCCCC;text-align:center;height:50upx;margin-right:8upx;" placeholder-class="phcolor"
  63. class="tui-input" name="reachNum" @focus="form.reachNum=''" placeholder="数量" maxlength="50" type="number" />扎 每扎优惠
  64. <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"
  65. class="tui-input" name="reachNumDiscount" @focus="form.reachNumDiscount=''" placeholder="金额" type="digit" />元
  66. </tui-list-cell>
  67. <tui-list-cell class="line-cell" :arrow="false" :hover="false">
  68. <view class="tui-title">成本</view>
  69. <input v-model="form.cost" style="width:300upx;" placeholder-class="phcolor" @focus="form.cost=''" class="tui-input" name="cost" placeholder="请输入" type="digit"/>
  70. <button v-if="productData.id > 0" class="admin-button-com blue middle" @click="goCostDetail(productData)">成本记录</button>
  71. </tui-list-cell>
  72. <tui-list-cell class="line-cell" :hover="false">
  73. <view class="tui-title" style="color:#3385FF;font-weight:bold;">库存</view>
  74. <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"/>
  75. <button v-if="productData.id > 0" class="admin-button-com blue middle" @click="goStockDetail(productData)">库存记录</button>
  76. </tui-list-cell>
  77. <tui-list-cell class="line-cell" :hover="false">
  78. <view class="tui-title">路上库存</view>
  79. <view style="color:#CCCCCC;width:300upx;height:45upx;display:flex;align-items:center;overflow:hidden;">
  80. {{form.onStock?form.onStock:0}}
  81. </view>
  82. <button v-if="productData.id > 0" class="admin-button-com blue middle" @click="showChangeOnStock(productData)">修改数值</button>
  83. </tui-list-cell>
  84. <tui-list-cell class="line-cell" :arrow="true">
  85. <view class="tui-title">分类</view>
  86. <input v-model="form.classId" name="classId" type="text" hidden />
  87. <view style="color:#CCCCCC;width:450upx;height:45upx;" @click.stop="changeClass()" v-if="form.classId == 0">
  88. 请选择分类
  89. </view>
  90. <view @click.stop="changeClass()" style="width:450upx;height:45upx;" v-else>
  91. {{form.className}}
  92. </view>
  93. </tui-list-cell>
  94. <tui-list-cell class="line-cell" :hover="false">
  95. <view class="tui-title">比例类型</view>
  96. <radio-group class="tui-input" @change="ratioTypeChange">
  97. <label class="list" for="fixedLink">
  98. <radio id="fixedLink" value="0" :checked="form.ratioType == 0" style="transform: scale(0.7,0.7);" />
  99. <span class="checkbox-text" style="font-size:30upx;">固定</span>
  100. </label>
  101. <label class="list" for="dimLink">
  102. <radio id="dimLink" value="1" :checked="form.ratioType == 1" style="transform: scale(0.7,0.7);" />
  103. <span class="checkbox-text" style="font-size:30upx;">模糊(若干)</span>
  104. </label>
  105. </radio-group>
  106. </tui-list-cell>
  107. <tui-list-cell class="line-cell" :arrow="false" :hover="false">
  108. <view class="tui-title">大单位</view>
  109. <input v-model="form.bigUnitId" name="bigUnitId" type="text" hidden />
  110. <view v-if="form.bigUnitId" style="width:300upx;color:#CCCCCC;height:45upx;">{{ bigUnitSelectedData.name }}</view>
  111. <button v-if="productData.id > 0 && productData.hasRightChange == 1" class="admin-button-com blue middle" @click.stop="showUnitList('big')" style="width:150upx;">修改</button>
  112. <button v-else class="admin-button-com default middle" style="width:150upx;" @click.stop="notAllowChange()">修改</button>
  113. </tui-list-cell>
  114. <tui-list-cell class="line-cell" :arrow="false" :hover="false">
  115. <view class="tui-title">小单位</view>
  116. <input v-model="form.smallUnitId" name="smallUnitId" type="text" hidden />
  117. <view v-if="form.smallUnitId" style="width:300upx;color:#CCCCCC;height:45upx;">{{ smallUnitSelectedData.name }}</view>
  118. <button v-if="productData.id > 0 && productData.hasRightChange == 1" class="admin-button-com blue middle" @click.stop="showUnitList('small')" style="width:150upx;">修改</button>
  119. <button v-else class="admin-button-com default middle" style="width:150upx;" @click.stop="notAllowChange()">修改</button>
  120. </tui-list-cell>
  121. <tui-list-cell class="line-cell" :arrow="false" v-if="form.ratioType == 0" :hover="false">
  122. <view class="tui-title">单位比</view>
  123. <input v-model="form.ratio" disabled="true" placeholder-class="phcolor" @click="$msg('不可修改')" style="width:300upx;color:#CCCCCC;"
  124. class="tui-input" name="ratio" placeholder="1扎=20支,请填写20" maxlength="50" type="number" />
  125. <button v-if="productData.id > 0 && productData.hasRightChange == 1" class="admin-button-com blue middle" @click.stop="changeRatio()" style="width:150upx;">修改</button>
  126. <button v-else class="admin-button-com default middle" style="width:150upx;" @click.stop="notAllowChange()">修改</button>
  127. </tui-list-cell>
  128. <tui-list-cell class="line-cell" :arrow="false" :hover="false">
  129. <view class="tui-title">每扎重量</view>
  130. <input v-model="form.weight" disabled="true" placeholder-class="phcolor" @click="$msg('不可修改')" style="width:200upx;color:#CCCCCC;"
  131. class="tui-input" name="weight" placeholder="公斤" maxlength="50" type="digit" />
  132. <view class="weight-reminder-icon" @click="showWeightPopup" style="margin-right: 20upx;">
  133. <text style="color: #999; font-size: 32upx; font-weight: bold;">?</text>
  134. </view>
  135. <button v-if="productData.id > 0 && productData.hasRightChange == 1" class="admin-button-com blue middle" @click.stop="changeWeight()" style="width:150upx;">修改</button>
  136. <button v-else class="admin-button-com default middle" style="width:150upx;" @click.stop="notAllowChange()">修改</button>
  137. </tui-list-cell>
  138. <tui-list-cell class="line-cell" :hover="false">
  139. <view class="tui-title">每人限购</view>
  140. <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" />
  141. <button v-if="productData.id > 0 && form.limitBuy>0" class="admin-button-com blue middle" @click.stop="clearBuyCache()" style="width:150upx;">清已购</button>
  142. <button v-else class="admin-button-com default middle" style="width:150upx;" @click.stop="">清已购</button>
  143. </tui-list-cell>
  144. <tui-list-cell class="line-cell" :hover="false">
  145. <view class="tui-title">库存预警</view>
  146. <input v-model="form.stockWarning" style="width:300upx;" @focus="form.stockWarning=''" placeholder-class="phcolor" class="tui-input" name="stockWarning" placeholder="请填写" maxlength="50" type="number" />
  147. </tui-list-cell>
  148. <tui-list-cell class="line-cell" :hover="false">
  149. <view class="tui-title">花材状态</view>
  150. <view>
  151. <block v-if="productData.delStatus && productData.delStatus == 1">
  152. <text>已删除</text>
  153. </block>
  154. <block v-else>
  155. <text v-if="form.status == 1">上架</text>
  156. <text v-else>下架</text>
  157. </block>
  158. </view>
  159. </tui-list-cell>
  160. <tui-list-cell class="line-cell" :arrow="true">
  161. <view class="tui-title">采购人</view>
  162. <view @click="changeCgStaff()" style="width:400upx;">{{ productData.cgStaffName?productData.cgStaffName:'未设置' }}</view>
  163. </tui-list-cell>
  164. </view>
  165. <view class="module-com input-line-wrap goods-wrap">
  166. <view class="module-tit">
  167. <span>花材图片(最多5张)</span>
  168. <span class="app-color-3"></span>
  169. </view>
  170. <view class="module-det">
  171. <htz-image-upload :max="5" :compress="true" v-model="currentImgData" :headers="headers"
  172. @uploadSuccess="imgUploadSuccess" @imgDelete="imgDeleteFn" :action="getLoginInfo.imgUploadApi">
  173. </htz-image-upload>
  174. </view>
  175. <tui-list-cell class="line-cell category-wrap" :hover="false">
  176. <view class="tui-title">封面</view>
  177. <view class="tui-input">
  178. <block v-if="coverImgData.length > 0">
  179. <button class="admin-button-com" :class="[(form.cover == item) ? '' : 'default']"
  180. v-for="(item, index) in coverImgData" :key="index"
  181. @click="selCoverFn(index)" >第{{ index + 1 }}张</button>
  182. </block>
  183. <view v-else class="no-img-tip">请先上传图片</view>
  184. <view v-if="coverImgData.length > 0" class="use-img">选择上面的图片作为封面</view>
  185. </view>
  186. </tui-list-cell>
  187. </view>
  188. <view class="module-com input-line-wrap">
  189. <tui-list-cell class="line-cell" :hover="false">
  190. <view class="tui-title">大客价加价</view>
  191. <input v-model="form.hjAddPrice" placeholder-class="phcolor" class="tui-input" name="hjAddPrice" @focus="form.hjAddPrice=''" placeholder="在成本价基础上多卖的金额" maxlength="50" type="digit" />
  192. </tui-list-cell>
  193. <tui-list-cell class="line-cell" :hover="false">
  194. <view class="tui-title">批发价加价</view>
  195. <input v-model="form.addPrice" placeholder-class="phcolor" class="tui-input" name="addPrice" @focus="form.addPrice=''" placeholder="在成本价基础上多卖的金额" maxlength="50" type="digit" />
  196. </tui-list-cell>
  197. <tui-list-cell class="line-cell" :hover="false">
  198. <view class="tui-title">零售价加价</view>
  199. <input v-model="form.skMore" placeholder-class="phcolor" class="tui-input" name="skMore" @focus="form.skMore=''" placeholder="在成本价基础上多卖的金额" type="digit" />
  200. </tui-list-cell>
  201. <tui-list-cell class="line-cell" :hover="false">
  202. <view class="tui-title">顺序值</view>
  203. <input v-model="form.inTurn" placeholder-class="phcolor" class="tui-input" name="inTurn" @focus="form.inTurn=''" placeholder="请填写数字" type="number" />
  204. </tui-list-cell>
  205. <tui-list-cell class="line-cell" :hover="false">
  206. <view class="tui-title">商城端隐藏</view>
  207. <view class="switch_bx">
  208. <switch :checked="form.frontHide == 0 ? false : true" @change="frontHideChange" style="transform: scale(0.8,0.8)" />
  209. <text v-if="form.frontHide == 0">否</text>
  210. <text v-else>是</text>
  211. </view>
  212. </tui-list-cell>
  213. <tui-list-cell class="line-cell" :hover="false">
  214. <view class="tui-title">库存类型</view>
  215. <radio-group class="tui-input" @change="virtualStockChange">
  216. <label class="list" for="realLink">
  217. <radio id="realLink" value="0" :checked="form.virtualStock == 0" style="transform: scale(0.7,0.7);" />
  218. <span class="checkbox-text" style="font-size:30upx;">真实</span>
  219. </label>
  220. <label class="list" for="virLink">
  221. <radio id="virLink" value="1" :checked="form.virtualStock == 1" style="transform: scale(0.7,0.7);" />
  222. <span class="checkbox-text" style="font-size:30upx;">虚拟</span>
  223. </label>
  224. </radio-group>
  225. </tui-list-cell>
  226. <tui-list-cell class="line-cell" :hover="false">
  227. <view class="tui-title">单独统计</view>
  228. <radio-group class="tui-input" @change="belongCostChange">
  229. <label class="list" for="noLink">
  230. <radio id="noLink" value="0" :checked="belongCost == 0" style="transform: scale(0.7,0.7);" />
  231. <span class="checkbox-text" style="font-size:30upx;">不要</span>
  232. </label>
  233. <label class="list" for="needLink">
  234. <radio id="needLink" value="1" :checked="belongCost == 1" style="transform: scale(0.7,0.7);" />
  235. <span class="checkbox-text" style="font-size:30upx;">需要</span>
  236. </label>
  237. </radio-group>
  238. </tui-list-cell>
  239. </view>
  240. <view class="app-footer">
  241. <button class="admin-button-com big default" @click="goBack()">取消</button>
  242. <button v-if="option.ptItemId" class="admin-button-com big blue" formType="submit" @click="status = 1">添加</button>
  243. <button v-else class="admin-button-com big blue" formType="submit" @click="status = 1">确认</button>
  244. </view>
  245. </form>
  246. <modal-module :show="printLabelShow" @click="dialogInputConfirm" :maskClosable="true" title="打印数量" padding="30rpx 30rpx" >
  247. <template v-slot:content>
  248. <view class="app-modal-input-wrap">
  249. <view class="inp-list-line">
  250. <view class="line-input">
  251. <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" />
  252. </view>
  253. </view>
  254. </view>
  255. </template>
  256. </modal-module>
  257. <modal-module :show="onStockShow" @click="onStockConfirm" :maskClosable="true" title="路上库存" padding="30rpx 30rpx" >
  258. <template v-slot:content>
  259. <view class="app-modal-input-wrap">
  260. <view class="inp-list-line">
  261. <view class="line-input">
  262. <input type="number" ref="input" style="width:62%;text-align:center;" v-model="newOnStock" @focus="newOnStock=''" :adjust-position="false" class="inp-input" />
  263. </view>
  264. </view>
  265. </view>
  266. </template>
  267. </modal-module>
  268. <uni-popup ref="classRef" background-color="#fff" type="center" :animation="false" class="class-popup-style">
  269. <view style="margin-left:30upx;margin-top:19upx;font-size:27upx;font-weight:bold;">请选择分类:</view>
  270. <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;">
  271. <view v-for="(item, index) in itemClassData" :key="index" @tap.stop="setThisClass(item)" style="margin-bottom:20upx;margin-left:3upx;">
  272. <image :src="item.cover" style="width:120upx;height:120upx;border-radius:10upx;"></image>
  273. <view style="margin-top:5upx;overflow: hidden;white-space: nowrap;width:120upx;text-align:center;">{{item.name}}</view>
  274. </view>
  275. </view>
  276. </uni-popup>
  277. <uni-popup ref="rightShowMore" background-color="#fff" type="center" :animation="true" class="class-popup-style">
  278. <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;">
  279. <view style="width:100vw;margin-top:8upx;"><button @click="goWaste(productData)">报损</button></view>
  280. <view style="width:100vw;margin-top:8upx;"><button @click="goPart(productData)">拆散</button></view>
  281. <view style="width:100vw;margin-top:8upx;"><button @click="orderRecord(productData)">下单记录</button></view>
  282. <view style="width:100vw;margin-top:8upx;"><button @click="copyCreate(productData)">复制新建</button></view>
  283. <view style="width:100vw;margin-top:8upx;"><button @click="onStockChange(productData)">路上库存变动</button></view>
  284. <view style="width:100vw;margin-top:8upx;" v-if="productData.delStatus == 0"><button @click="changeDelStatus(productData,1)">删除</button></view>
  285. <view style="width:100vw;margin-top:8upx;" v-if="productData.delStatus == 1"><button @click="changeDelStatus(productData,0)">取消删除</button></view>
  286. <view style="width:100vw;margin-top:30upx;"><button @click="closeMoreDoPop()">取消</button></view>
  287. </view>
  288. </uni-popup>
  289. <modal-module :show="wasteShow" @click="wasteConfirm" :maskClosable="true" title="报损数量" padding="30rpx 30rpx" >
  290. <template v-slot:content>
  291. <view class="app-modal-input-wrap">
  292. <view class="inp-list-line">
  293. <view class="line-input">
  294. <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" />
  295. </view>
  296. </view>
  297. </view>
  298. </template>
  299. </modal-module>
  300. <modal-module :show="partShow" @click="partConfirm" :maskClosable="true" title="拆散数量" padding="30rpx 30rpx" >
  301. <template v-slot:content>
  302. <view class="app-modal-input-wrap">
  303. <view class="inp-list-line">
  304. <view class="line-input">
  305. <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" />
  306. </view>
  307. </view>
  308. </view>
  309. </template>
  310. </modal-module>
  311. <uni-popup ref="staffRef" background-color="#fff" type="center" :animation="false" class="class-popup-style">
  312. <view style="max-height:90vh;overflow: scroll;">
  313. <view style="margin-left:30upx;margin-top:19upx;font-size:27upx;font-weight:bold;">请选择:</view>
  314. <view style="display:flex;padding:20upx;height:auto;justify-content: space-between;align-items:center;flex-wrap:wrap;max-height:100vh;overflow:auto;">
  315. <view v-for="(item, index) in staffData" :key="index" @tap.stop="getStaff(item)" style="margin-bottom:20upx;margin-left:3upx;">
  316. <view style="margin-top:8upx;overflow: hidden;white-space: nowrap;width:120upx;text-align:center;font-weight:bold;font-size:30upx;">{{item.name}}</view>
  317. </view>
  318. </view>
  319. <view style="text-align:center;padding:10upx 0 10upx 0;"><button class="admin-button-com big blue" @click="cancelStaff()">取消选择</button></view>
  320. </view>
  321. </uni-popup>
  322. <uni-popup ref="unitRef" background-color="#fff" type="center" :animation="false" class="class-popup-style">
  323. <view style="max-height:90vh;overflow: scroll;">
  324. <view style="margin-left:30upx;margin-top:19upx;font-size:27upx;font-weight:bold;">请选择:</view>
  325. <view style="display:flex;padding:20upx;height:auto;justify-content: space-between;align-items:center;flex-wrap:wrap;max-height:100vh;overflow:auto;">
  326. <view v-for="(item, index) in unitData" :key="index" @tap.stop="setNewUnit(item)" style="margin-bottom:20upx;margin-left:3upx;">
  327. <view style="margin-top:8upx;overflow: hidden;white-space: nowrap;width:120upx;text-align:center;font-weight:bold;font-size:36upx;">{{item.name}}</view>
  328. </view>
  329. </view>
  330. <view style="text-align:center;padding:10upx 0 10upx 0;"><button class="admin-button-com big blue" @click="cancelUnitChange()">取消选择</button></view>
  331. </view>
  332. </uni-popup>
  333. <uni-popup ref="weightRef" background-color="#fff" type="center" :animation="false" class="weight-popup-style">
  334. <view class="weight-popup-container">
  335. <view class="weight-popup-title">花材重量参考</view>
  336. <view class="weight-popup-content">
  337. <view class="weight-item" v-for="(item, index) in weightReferenceData" :key="index">
  338. <text class="weight-name">{{ item.name }}</text>
  339. <text class="weight-value">{{ item.weight }}</text>
  340. </view>
  341. </view>
  342. <view class="weight-popup-note">以上含纸箱平摊下来的重量,请认真填写,跑腿费会参考这边设置的重量</view>
  343. <view class="weight-popup-footer">
  344. <button class="admin-button-com big blue" @click="closeWeightPopup">确定</button>
  345. </view>
  346. </view>
  347. </uni-popup>
  348. <modal-module :show="writeRatioShow" @click="newRatioConfirm" :maskClosable="true" title="修改单位比" padding="30rpx 30rpx" >
  349. <template v-slot:content>
  350. <view class="app-modal-input-wrap">
  351. <view class="inp-list-line">
  352. <view class="line-input">
  353. <input type="number" ref="input" style="width:62%;text-align:center;" v-model="newRatio" @focus="newRatio=''" :adjust-position="false" class="inp-input" />
  354. </view>
  355. </view>
  356. </view>
  357. </template>
  358. </modal-module>
  359. <modal-module :show="writeWeightShow" @click="newWegithConfirm" :maskClosable="true" title="修改重量" padding="30rpx 30rpx" >
  360. <template v-slot:content>
  361. <view class="app-modal-input-wrap">
  362. <view class="inp-list-line">
  363. <view class="line-input">
  364. <input type="digit" ref="input" style="width:62%;text-align:center;" v-model="newWeight" @focus="newWeight=''" :adjust-position="false" class="inp-input" />
  365. </view>
  366. </view>
  367. </view>
  368. </template>
  369. </modal-module>
  370. </view>
  371. </template>
  372. <script>
  373. import TuiListCell from "@/components/plugin/list-cell";
  374. const form = require("@/utils/formValidation.js");
  375. import { getAllItemClass } from "@/api/item-class";
  376. import { applyAuth,modifyCgStaff,setLosing,modifyUnit,modifyRatio,modifyWeight,clearLimitBuy } from '@/api/item';
  377. import { getAllUnit } from "@/api/unit";
  378. import { addProduct,updateProduct,getProductDetail,py,print,modifyOnStockFn,delStatusUpdate,changeBelongCost } from "@/api/product";
  379. import { getPtItemDetail } from "@/api/pt-item";
  380. import { wastage } from "@/api/order";
  381. import { mapGetters } from "vuex"
  382. //图片上传插件来源:https://ext.dcloud.net.cn/plugin?id=2922 已改造,不能再升级 shish 20211228
  383. import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue'
  384. import ModalModule from "@/components/plugin/modal"
  385. import { getAllStaff } from "@/api/shop-admin";
  386. import { partItem } from "@/api/part";
  387. export default {
  388. name: "item-detail",
  389. components: {
  390. TuiListCell,
  391. htzImageUpload,
  392. ModalModule
  393. },
  394. data() {
  395. return {
  396. writeRatioShow:false,
  397. newRatio:'',
  398. writeWeightShow:false,
  399. newWeight:'',
  400. onStockShow:false,
  401. newOnStock:0,
  402. status: 1,
  403. currentImgData: [],
  404. form: {
  405. id:0,
  406. name:"",
  407. py:"",
  408. stock:'',
  409. onStock:'',
  410. ratio:'',
  411. bigUnitId:1,
  412. smallUnitId:2,
  413. classId:'',
  414. className:'',
  415. price:'',
  416. skPrice:'',
  417. hjPrice:'',
  418. hjAddPrice:2,
  419. addPrice:3,
  420. discountPrice:0,
  421. hjDiscountPrice:0,
  422. skDiscountPrice:0,
  423. reachNum:0,
  424. reachNumDiscount:0,
  425. cost:0,
  426. skMore:3,
  427. weight:'',
  428. cover: "",
  429. images: [],
  430. limitBuy:0,
  431. stockWarning:5,
  432. status:2,
  433. itemId:0,
  434. frontHide:0,
  435. virtualStock:0,
  436. ratioType:0,
  437. inTurn:100,
  438. cpInfo:[]
  439. },
  440. itemClassData:[],
  441. unitData:[],
  442. smallUnitSelectedData:{},
  443. bigUnitSelectedData:{},
  444. hasRequest:0,
  445. onShowRefresh:0,
  446. productData:{id:0},
  447. headers:{token:''},
  448. cost:0,
  449. printItemId:0,
  450. printNum:'',
  451. printLabelShow:false,
  452. backCpInfo:{cpId:0,cpName:'',needUpdate:0},
  453. wasteNum:'',
  454. wasteShow:false,
  455. wasteFocus:false,
  456. partNum:'',
  457. partShow:false,
  458. partFocus:false,
  459. belongCost:0,
  460. staffData:[],
  461. modifyUnitType:'big',
  462. weightReferenceData:[
  463. {name: '单头玫瑰', weight: '1.2公斤'},
  464. {name: '多头玫瑰', weight: '1.2公斤'},
  465. {name: '百合', weight: '2.7公斤'},
  466. {name: '康乃馨', weight: '1公斤'},
  467. {name: '向日葵', weight: '2.7公斤或3公斤'},
  468. {name: '其他', weight: '0.5公斤或1公斤'}
  469. ],
  470. printFocus:false
  471. };
  472. },
  473. computed:{
  474. ...mapGetters(["getLoginInfo","getDictionariesInfo"]),
  475. coverImgData() {
  476. return this.form.images || [];
  477. }
  478. },
  479. onLoad(option) {
  480. if(option.id){
  481. this.form.id = this.option.id
  482. }
  483. const token = uni.getStorageSync('token')
  484. this.headers.token = token
  485. //重复花材,删除花材之后,返回上一页花材,需要刷新
  486. let pages = getCurrentPages();
  487. let prevPage = pages[ pages.length - 2 ];
  488. prevPage.$vm.onShowRefresh = 1
  489. prevPage.$vm.hasRequest = 0
  490. getAllStaff().then(res=>{
  491. if(res.code == 1){
  492. this.staffData = res.data.list ? res.data.list : []
  493. }
  494. })
  495. },
  496. onShow(){
  497. let that = this
  498. //重复花材,删除花材之后,返回上一页花材,需要刷新
  499. if(this.onShowRefresh == 1){
  500. if(this.hasRequest == 0){
  501. this.init()
  502. this.onShowRefresh = 0
  503. }
  504. }
  505. if(this.backCpInfo.needUpdate == 1){
  506. let needAdd = 1;
  507. if (!this.$util.isEmpty(this.form.cpInfo)) {
  508. that.form.cpInfo.forEach((item) => {
  509. if(item.cpId == that.backCpInfo.cpId){
  510. needAdd = 0
  511. }
  512. })
  513. }
  514. if(needAdd == 1){
  515. that.form.cpInfo.push({cpId:that.backCpInfo.cpId,cpName:that.backCpInfo.cpName})
  516. that.backCpInfo.needUpdate = 0
  517. that.$forceUpdate()
  518. }
  519. }
  520. },
  521. methods: {
  522. printToFocus(){
  523. },
  524. selCoverFn(index) {
  525. this.form.cover = this.form.images[index];
  526. },
  527. showWeightPopup(){
  528. this.$refs.weightRef.open('center')
  529. },
  530. closeWeightPopup(){
  531. this.$refs.weightRef.close()
  532. },
  533. clearBuyCache(){
  534. let that = this
  535. that.$util.confirmModal({content:'确认清除已购?清除后客户可再次下单'},() => {
  536. clearLimitBuy({id:this.productData.id}).then(res=>{
  537. if(res.code == 1){
  538. this.$msg('已清除')
  539. }
  540. })
  541. })
  542. },
  543. notAllowChange(){
  544. if(this.productData.hasRightChangeReason!=''){
  545. this.$msg(this.productData.hasRightChangeReason)
  546. }else{
  547. this.$msg('未知原因造成不可修改')
  548. }
  549. },
  550. setNewUnit(item){
  551. modifyUnit({type:this.modifyUnitType,unitId:item.id,id:this.productData.id}).then(res=>{
  552. if(res.code == 1){
  553. this.cancelUnitChange()
  554. this.getDetail()
  555. this.$msg('修改成功')
  556. }
  557. })
  558. },
  559. showUnitList(type){
  560. this.modifyUnitType = type
  561. this.$refs.unitRef.open('center')
  562. },
  563. cancelUnitChange(){
  564. this.$refs.unitRef.close()
  565. },
  566. getStaff(staff){
  567. this.$refs.staffRef.close()
  568. modifyCgStaff({id:this.productData.id,staffId:staff.id}).then(res=>{
  569. if(res.code == 1){
  570. this.$msg(res.msg)
  571. this.getDetail()
  572. }
  573. })
  574. },
  575. cancelStaff(){
  576. this.$refs.staffRef.close()
  577. },
  578. changeCgStaff(){
  579. this.$refs.staffRef.open('center')
  580. },
  581. delOneCp(info,index){
  582. let that = this
  583. that.$util.confirmModal({content:'确认删除'+info.cpName+'?'},() => {
  584. that.form.cpInfo.splice(index,1)
  585. that.$forceUpdate()
  586. })
  587. },
  588. changeCp(item){
  589. this.$util.pageTo({url: '/admin/cp/list?skip=1'})
  590. },
  591. changeClass(item){
  592. this.$refs.classRef.open('center')
  593. },
  594. setThisClass(info){
  595. this.$refs.classRef.close()
  596. this.form.classId = info.id ? info.id : 0
  597. this.form.className = info.name ? info.name : ''
  598. this.$forceUpdate()
  599. },
  600. onStockChange(info){
  601. this.closeMoreDoPop()
  602. this.pageTo({url: '/pagesStorehouse/stockWarn/onStockChange?id='+info.id+'&name='+info.name})
  603. },
  604. goPart(){
  605. this.closeMoreDoPop()
  606. this.partShow = true
  607. let that = this
  608. setTimeout(x => {
  609. this.$nextTick(() => {
  610. that.partFocus = true
  611. })
  612. }, 300)
  613. },
  614. partBlur(){
  615. this.partFocus = false
  616. },
  617. closePartPop(){
  618. this.partShow = false
  619. this.partFocus = false
  620. this.partNum = ''
  621. },
  622. partConfirm(val){
  623. let that = this
  624. if (val.index == 0) {
  625. this.closePartPop()
  626. return
  627. }
  628. if(Number(that.partNum)<0){
  629. that.$msg('请填写数量')
  630. return false
  631. }
  632. let product = [{ productId:that.productData.id,bigNum:that.partNum,smallNum:null,classId:0,itemId:that.productData.itemId,ratio:that.productData.ratio }]
  633. that.$util.confirmModal({content:'确认拆散?'},() => {
  634. partItem({product:JSON.stringify(product),remark:''}).then((res) => {
  635. if(res.code == 1){
  636. that.closePartPop()
  637. that.hasRequest = 0
  638. that.init()
  639. }
  640. })
  641. })
  642. },
  643. goWaste(){
  644. this.closeMoreDoPop()
  645. this.wasteShow = true
  646. let that = this
  647. setTimeout(x => {
  648. this.$nextTick(() => {
  649. that.wasteFocus = true
  650. })
  651. }, 300)
  652. },
  653. wasteBlur(){
  654. this.wasteFocus = false
  655. },
  656. closeWastePop(){
  657. this.wasteShow = false
  658. this.wasteFocus = false
  659. this.wasteNum = ''
  660. },
  661. closeNewRatio(){
  662. this.writeRatioShow = false
  663. this.newRatio = ''
  664. },
  665. changeRatio(){
  666. this.writeRatioShow = true
  667. this.newRatio = this.productData.ratio?parseFloat(this.productData.ratio):0
  668. },
  669. newRatioConfirm(val){
  670. let that = this
  671. if (val.index == 0) {
  672. this.closeNewRatio()
  673. return
  674. }
  675. if(Number(that.newRatio)<0){
  676. that.$msg('请填写数量')
  677. return false
  678. }
  679. that.$util.confirmModal({content:'确认修改?'},() => {
  680. modifyRatio({id:this.productData.id,ratio:that.newRatio}).then((res) => {
  681. if(res.code == 1){
  682. that.getDetail()
  683. that.closeNewRatio()
  684. that.$msg('修改成功')
  685. }
  686. });
  687. })
  688. },
  689. closeNewWeight(){
  690. this.writeWeightShow = false
  691. this.newWeight = ''
  692. },
  693. changeWeight(){
  694. this.writeWeightShow = true
  695. this.newWeight = this.productData.weight?parseFloat(this.productData.weight):0
  696. },
  697. newWegithConfirm(val){
  698. let that = this
  699. if (val.index == 0) {
  700. this.closeNewWeight()
  701. return
  702. }
  703. if(Number(that.newWeight)<0){
  704. that.$msg('请填写数量')
  705. return false
  706. }
  707. that.$util.confirmModal({content:'确认修改?'},() => {
  708. modifyWeight({id:this.productData.id,weight:that.newWeight}).then((res) => {
  709. if(res.code == 1){
  710. that.getDetail()
  711. that.closeNewWeight()
  712. that.$msg('修改成功')
  713. }
  714. });
  715. })
  716. },
  717. wasteConfirm(val){
  718. let that = this
  719. if (val.index == 0) {
  720. this.closeWastePop()
  721. return
  722. }
  723. if(Number(that.wasteNum)<0){
  724. that.$msg('请填写数量')
  725. return false
  726. }
  727. let product = [{ productId:that.productData.id,bigNum:that.wasteNum,smallNum:null,classId:0,itemId:that.productData.itemId,ratio:that.productData.ratio }]
  728. that.$util.confirmModal({content:'确认报损?'},() => {
  729. wastage({product:JSON.stringify(product),remark:''}).then((res) => {
  730. if(res.code == 1){
  731. that.closeWastePop()
  732. that.hasRequest = 0
  733. that.init()
  734. }
  735. });
  736. })
  737. },
  738. orderRecord(info){
  739. this.closeMoreDoPop()
  740. this.pageTo({url: "/admin/order/itemOrder?productId="+info.id})
  741. },
  742. moreDo(){
  743. this.$refs.rightShowMore.open('top')
  744. },
  745. copyCreate(info){
  746. this.closeMoreDoPop()
  747. this.pageTo({url: '/admin/item/copy?id='+info.id})
  748. },
  749. closeMoreDoPop(){
  750. this.$refs.rightShowMore.close()
  751. },
  752. showChangeOnStock(item){
  753. let that = this
  754. that.$util.confirmModal({content:'确认了解修改后的影响,确认要修改?'},() => {
  755. this.onStockShow = true
  756. this.newOnStock = item.onStock
  757. })
  758. },
  759. onStockConfirm(val){
  760. let that=this;
  761. if (val.index == 0) {
  762. that.onStockShow = false
  763. return
  764. }
  765. uni.showLoading()
  766. modifyOnStockFn({id:that.option.id,onStock:that.newOnStock}).then(res=>{
  767. if(res.code == 1){
  768. uni.hideLoading()
  769. that.form.onStock = that.newOnStock
  770. that.onStockShow = false
  771. that.$forceUpdate()
  772. that.$msg(res.msg)
  773. }
  774. })
  775. },
  776. changeDelStatus(info,flag){
  777. let that = this
  778. this.closeMoreDoPop()
  779. let remind = flag == 1 ? '确认删除?' : '确认恢复?'
  780. that.$util.confirmModal({content:remind},() => {
  781. delStatusUpdate({id:info.id,delStatus:flag}).then(res=>{
  782. if(res.code == 1){
  783. that.hasRequest = 0
  784. that.init()
  785. that.$msg(res.msg)
  786. }
  787. })
  788. })
  789. },
  790. getProductId(info){
  791. this.$msg('花材唯一编号 '+info.id)
  792. },
  793. ptAuth(info){
  794. let that = this
  795. that.$util.confirmModal({content:'确认申请?'},() => {
  796. applyAuth({id:info.id}).then(res=>{
  797. if(res.code == 1){
  798. that.$msg('已提交申请')
  799. }
  800. })
  801. })
  802. },
  803. tjLinkage(){
  804. if(this.form.discountPrice && Number(this.form.discountPrice)>0){
  805. let skMore = this.form.skMore ? Number(this.form.skMore) : 0
  806. let hjAddPrice = this.form.hjAddPrice ? Number(this.form.hjAddPrice) : 0
  807. let addPrice = this.form.addPrice ? Number(this.form.addPrice) : 0
  808. let skAddNum = Number(skMore) - Number(addPrice)
  809. skAddNum = skAddNum.toFixed(2)
  810. let skAmount = Number(skAddNum) + Number(this.form.discountPrice)
  811. if(skAmount>0){
  812. skAmount = skAmount.toFixed(2)
  813. skAmount = parseFloat(skAmount)
  814. this.form.skDiscountPrice = skAmount
  815. }else{
  816. this.form.skDiscountPrice = 0.01
  817. }
  818. let hjSubNum = Number(addPrice) - Number(hjAddPrice)
  819. hjSubNum = hjSubNum.toFixed(2)
  820. let hjAmount = Number(this.form.discountPrice) - Number(hjSubNum)
  821. if(hjAmount > 0){
  822. hjAmount = hjAmount.toFixed(2)
  823. hjAmount = parseFloat(hjAmount)
  824. this.form.hjDiscountPrice = hjAmount
  825. }else{
  826. this.form.hjDiscountPrice = 0.01
  827. }
  828. }else{
  829. this.form.skDiscountPrice = 0
  830. this.form.hjDiscountPrice = 0
  831. }
  832. },
  833. priceLinkage(){
  834. if(this.form.price && Number(this.form.price)>0){
  835. let skMore = this.form.skMore ? Number(this.form.skMore) : 0
  836. let hjAddPrice = this.form.hjAddPrice ? Number(this.form.hjAddPrice) : 0
  837. let addPrice = this.form.addPrice ? Number(this.form.addPrice) : 0
  838. let skAddNum = Number(skMore) - Number(addPrice)
  839. skAddNum = skAddNum.toFixed(2)
  840. let skAmount = Number(skAddNum) + Number(this.form.price)
  841. if(skAmount>0){
  842. skAmount = skAmount.toFixed(2)
  843. skAmount = parseFloat(skAmount)
  844. this.form.skPrice = skAmount
  845. }else{
  846. this.form.skPrice = ''
  847. }
  848. let hjSubNum = Number(addPrice) - Number(hjAddPrice)
  849. hjSubNum = hjSubNum.toFixed(2)
  850. let hjAmount = Number(this.form.price) - Number(hjSubNum)
  851. if(hjAmount > 0){
  852. hjAmount = hjAmount.toFixed(2)
  853. hjAmount = parseFloat(hjAmount)
  854. this.form.hjPrice = hjAmount
  855. }else{
  856. this.form.hjPrice = ''
  857. }
  858. }else{
  859. this.form.skPrice = ''
  860. this.form.hjPrice = ''
  861. this.form.discountPrice = 0
  862. this.form.skDiscountPrice = 0
  863. this.form.hjDiscountPrice = 0
  864. }
  865. },
  866. blur() {
  867. this.printFocus = false
  868. },
  869. doPrintLabel(id){
  870. this.printItemId = id
  871. this.printLabelShow = true
  872. this.printNum = null
  873. setTimeout(x => {
  874. this.$nextTick(() => this.setFocus())
  875. }, 200);
  876. },
  877. setFocus() {
  878. this.printFocus = true
  879. },
  880. dialogInputConfirm(val) {
  881. let that=this;
  882. if (val.index == 0) {
  883. that.printLabelShow = false
  884. that.printFocus = false
  885. return
  886. }
  887. let currentNum = this.printNum
  888. let itemId = this.printItemId
  889. if (currentNum == null) {
  890. that.$msg('打印数量未填写')
  891. that.printFocus = true
  892. return
  893. }
  894. if (currentNum <= 0) {
  895. that.$msg('打印数量不能小于等于0')
  896. that.printFocus = true
  897. return
  898. }
  899. if (itemId == 0) {
  900. that.$msg('打印的花材id出错')
  901. that.printLabelShow = false
  902. that.printFocus = false
  903. return
  904. }
  905. print({id:itemId,num:currentNum}).then(res=>{
  906. if(res.code == 1){
  907. that.printLabelShow = false
  908. that.$msg(res.msg)
  909. } else if(res.code == 0){
  910. that.printLabelShow = false
  911. that.printFocus = false
  912. that.$msg(res.msg)
  913. }
  914. })
  915. },
  916. ratioTypeChange(e) {
  917. this.form.ratioType = e.detail.value;
  918. },
  919. fastSubmit(){
  920. this.dialogInputConfirm({index: 1})
  921. },
  922. goPriceDetail(item){
  923. this.$util.pageTo({url: "/admin/changePrice/changeList?id="+item.id})
  924. },
  925. goCostDetail(item){
  926. this.$util.pageTo({url: "/admin/changePrice/costChangeList?id="+item.id})
  927. },
  928. goStockDetail(item){
  929. this.$util.pageTo({url: "/pagesStorehouse/stockWarn/detailed?id="+item.id+'&name='+item.name})
  930. },
  931. virtualStockChange(e){
  932. this.form.virtualStock = e.detail.value
  933. },
  934. belongCostChange(e){
  935. let that = this
  936. this.belongCost = e.detail.value
  937. changeBelongCost({id:this.productData.id,belongCost:this.belongCost}).then(res=>{
  938. if(res.code == 1){
  939. that.$msg(res.msg)
  940. }
  941. })
  942. },
  943. frontHideChange(e){
  944. this.form.frontHide = e.detail.value ? 1 : 0;
  945. },
  946. statusChange(e){
  947. this.form.status = e.detail.value ? 1 : 2;
  948. if(this.form.status == 2){
  949. this.form.stock = 0
  950. }
  951. },
  952. changeStock(event){
  953. let num = Number(event.target.value)
  954. if(num > 0){
  955. this.form.status = 1
  956. }else{
  957. this.form.status = 2
  958. }
  959. },
  960. //获取拼音首字母 shish 20210707
  961. fillName(event){
  962. let val = event.target.value
  963. py({
  964. name:val
  965. }).then(res => {
  966. if(res.data.py){
  967. this.form.py = res.data.py
  968. }
  969. });
  970. },
  971. goBack(){
  972. uni.navigateBack({ delta: 1 })
  973. },
  974. changeBigUnitFn(e){
  975. this.bigUnitSelectedData = this.unitData[e.detail.value];
  976. this.form.bigUnitId = this.bigUnitSelectedData.id;
  977. },
  978. changeSmallUnitFn(e){
  979. this.smallUnitSelectedData = this.unitData[e.detail.value];
  980. this.form.smallUnitId = this.smallUnitSelectedData.id;
  981. },
  982. getPtItemInfo(ptItemId){
  983. getPtItemDetail({id:ptItemId}).then(res=>{
  984. if (this.$util.isEmpty(res.data)) {
  985. return;
  986. }
  987. Object.keys(this.form).forEach((i, index) => {
  988. this.form[i] = res.data[i];
  989. });
  990. this.form.cover = res.data.shortCover
  991. if(!this.$util.isEmpty(res.data.images)){
  992. const imageUrls = (res.data.images || '').split(',').filter(i => i);
  993. this.form.images = imageUrls;
  994. this.currentImgData = imageUrls.map(url => {
  995. return this.constant.imgUrl + '/' + url + '?x-oss-process=image/resize,m_fill,h_700,w_700'
  996. })
  997. if(this.form.cover==''){
  998. this.form.cover = this.form.images[0]
  999. }
  1000. }else{
  1001. this.currentImgData.push(res.data.bigCover)
  1002. this.form.images = [res.data.shortCover]
  1003. }
  1004. this.form.stock = 0
  1005. this.form.itemId = ptItemId
  1006. this.form.classId = ''
  1007. this.form.status = 1
  1008. this.form.id = 0
  1009. this.form.price = ''
  1010. this.form.skMore = 6
  1011. this.form.addPrice = 3
  1012. this.form.hjAddPrice = 3
  1013. this.form.discountPrice = 0
  1014. this.form.cost = 0
  1015. this.form.frontHide = 0
  1016. this.form.virtualStock = 0
  1017. this.form.limitBuy = 0
  1018. this.cost = res.data && res.data.cost ? parseFloat(res.data.cost) : 0
  1019. })
  1020. },
  1021. getDetail() {
  1022. let source = this.option.source ? this.option.source : ''
  1023. return getProductDetail({ id: this.option.id,source:source }).then(res => {
  1024. if (this.$util.isEmpty(res.data)) {
  1025. return;
  1026. }
  1027. Object.keys(this.form).forEach((i) => {
  1028. this.form[i] = res.data[i]
  1029. });
  1030. const imageUrls = (res.data.images || '').split(',').filter(i => i);
  1031. this.form.images = imageUrls;
  1032. this.currentImgData = imageUrls.map(url => {
  1033. return this.constant.imgUrl + '/' + url + '?x-oss-process=image/resize,m_fill,h_700,w_700'
  1034. });
  1035. this.form.cover = res.data.shortCover || '';
  1036. if (!this.form.cover && this.form.images.length > 0) {
  1037. this.form.cover = this.form.images[0];
  1038. }
  1039. this.form.price = res.data.prePrice
  1040. let currentClass = this.itemClassData.filter(
  1041. e => this.form.classId == e.id
  1042. )[0];
  1043. if(currentClass){
  1044. this.form.className = currentClass.name ? currentClass.name : ''
  1045. }
  1046. this.smallUnitSelectedData = this.unitData.filter(
  1047. e => this.form.smallUnitId == e.id
  1048. )[0];
  1049. this.bigUnitSelectedData = this.unitData.filter(
  1050. e => this.form.bigUnitId == e.id
  1051. )[0];
  1052. this.productData = res.data
  1053. this.cost = res.data.cost ? res.data.cost : 0
  1054. this.belongCost = res.data.belongCost ? res.data.belongCost : 0
  1055. });
  1056. },
  1057. imgUploadSuccess(res) {
  1058. var _res = JSON.parse(res.data)
  1059. if(_res.code == 1){
  1060. this.currentImgData.push(_res.data.bigUrl)
  1061. this.form.images.push(_res.data.shortUrl)
  1062. if (!this.form.cover) {
  1063. this.form.cover = _res.data.shortUrl;
  1064. }
  1065. }
  1066. },
  1067. imgDeleteFn(res){
  1068. const index = res.index;
  1069. const deletedUrl = this.form.images[index];
  1070. this.form.images.splice(index, 1);
  1071. if (this.form.cover === deletedUrl) {
  1072. this.form.cover = this.form.images[0] || '';
  1073. }
  1074. },
  1075. init() {
  1076. //从平台选择花材
  1077. if(!this.$util.isEmpty(this.option.ptItemId)){
  1078. uni.setNavigationBarTitle({title: "确认花材信息"})
  1079. }
  1080. //onShow不能重新请求数据,不然好像会造成上传图片有问题
  1081. if(this.hasRequest == 1){
  1082. return
  1083. }
  1084. this._getAllUnit().then(res=>{
  1085. this._getAllItemClass().then(res => {
  1086. if(this.form.id == 0){
  1087. this.smallUnitSelectedData = this.unitData.filter(e => 2 == e.id)[0];
  1088. this.bigUnitSelectedData = this.unitData.filter(e => 1 == e.id)[0];
  1089. //从平台选择花材
  1090. if(!this.$util.isEmpty(this.option.ptItemId)){
  1091. this.getPtItemInfo(this.option.ptItemId)
  1092. }
  1093. }else{
  1094. this.getDetail();
  1095. }
  1096. });
  1097. })
  1098. this.hasRequest = 1
  1099. },
  1100. async _getAllUnit() {
  1101. await getAllUnit().then(res => {
  1102. if (this.$util.isEmpty(res.data)){
  1103. return false;
  1104. }
  1105. this.unitData = res.data.list;
  1106. });
  1107. },
  1108. async _getAllItemClass() {
  1109. await getAllItemClass().then(res => {
  1110. if (this.$util.isEmpty(res.data)){
  1111. return false;
  1112. }
  1113. this.itemClassData = res.data;
  1114. });
  1115. },
  1116. // 确认
  1117. confirmFn() {
  1118. if (this.$util.isEmpty(this.form.images)) {
  1119. this.$msg("请上传图片")
  1120. return false
  1121. }
  1122. if (!this.form.cover && this.form.images.length > 0) {
  1123. this.form.cover = this.form.images[0];
  1124. }
  1125. let requestHost = addProduct
  1126. if(this.form.id && this.form.id != 0){
  1127. requestHost = updateProduct;
  1128. }else{
  1129. if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.stock) == false){
  1130. uni.showToast({title:"请填写库存,没有请填0",icon:"none"})
  1131. return;
  1132. }
  1133. if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.discountPrice) == false){
  1134. uni.showToast({title:"请填写特价,没有特价请填0",icon:"none"})
  1135. return;
  1136. }
  1137. if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.cost) == false){
  1138. uni.showToast({title:"请填写成本",icon:"none"})
  1139. return;
  1140. }
  1141. if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.price) == false){
  1142. uni.showToast({title:"请填写批发价",icon:"none"})
  1143. return;
  1144. }
  1145. if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.hjAddPrice) == false){
  1146. uni.showToast({title:"请填写大客价加价",icon:"none"})
  1147. return;
  1148. }
  1149. if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.addPrice) == false){
  1150. uni.showToast({title:"请填写批发价加价",icon:"none"})
  1151. return;
  1152. }
  1153. if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.skMore) == false){
  1154. uni.showToast({title:"请填写零售价加价",icon:"none"})
  1155. return;
  1156. }
  1157. }
  1158. let form = JSON.parse(JSON.stringify(this.form))
  1159. form.images = form.images.join(',')
  1160. uni.showLoading({mask:true,title:'提交中'})
  1161. requestHost({...form,appVersion:1}).then(res => {
  1162. uni.hideLoading()
  1163. if(res.code == 1){
  1164. this.$msg("操作成功");
  1165. //返回上一页带参数
  1166. let pages = getCurrentPages();
  1167. let prevPage = pages[ pages.length - 2 ];
  1168. let hidden = 0
  1169. if(this.form.stock > this.form.stockWarning){
  1170. hidden = 1
  1171. }
  1172. prevPage.$vm.modifyStock = {id:this.form.id,stock:this.form.stock,hidden:hidden};
  1173. uni.navigateBack({})
  1174. }
  1175. });
  1176. },
  1177. // 表单验证
  1178. formSubmit(e) {
  1179. // 表单规则
  1180. let rules = [
  1181. {
  1182. name: "name",
  1183. rule: ["required"],
  1184. msg: ["请填写名称"]
  1185. },
  1186. {
  1187. name: "py",
  1188. rule: ["required"],
  1189. msg: ["请填写拼音缩写"]
  1190. },{
  1191. name: "stock",
  1192. rule: ["required"],
  1193. msg: ["请填写库存,没有填0"]
  1194. },
  1195. {
  1196. name: "bigUnitId",
  1197. rule: ["required"],
  1198. msg: ["请选择大单位"]
  1199. },
  1200. {
  1201. name: "smallUnitId",
  1202. rule: ["required"],
  1203. msg: ["请选择小单位"]
  1204. },
  1205. {
  1206. name: "price",
  1207. rule: ["required"],
  1208. msg: ["请填写批发价"]
  1209. },
  1210. {
  1211. name: "skPrice",
  1212. rule: ["required"],
  1213. msg: ["请填写零售价"]
  1214. },
  1215. {
  1216. name: "hjPrice",
  1217. rule: ["required"],
  1218. msg: ["请填写大客价"]
  1219. },
  1220. {
  1221. name: "hjAddPrice",
  1222. rule: ["required"],
  1223. msg: ["请填写大客价加价"]
  1224. },
  1225. {
  1226. name: "addPrice",
  1227. rule: ["required"],
  1228. msg: ["请填写批发价加价"]
  1229. },
  1230. {
  1231. name: "discountPrice",
  1232. rule: ["required"],
  1233. msg: ["不做特价请填0"]
  1234. },
  1235. {
  1236. name: "cost",
  1237. rule: ["required"],
  1238. msg: ["请填写成本"]
  1239. },
  1240. {
  1241. name: "skMore",
  1242. rule: ["required"],
  1243. msg: ["请填写零售价加价"]
  1244. },
  1245. {
  1246. name: "weight",
  1247. rule: ["required"],
  1248. msg: ["请填写重量"]
  1249. },
  1250. {
  1251. name: "classId",
  1252. rule: ["required"],
  1253. msg: ["请选择分类"]
  1254. },
  1255. {
  1256. name: "stockWarning",
  1257. rule: ["required"],
  1258. msg: ["请填写库存预警"]
  1259. },
  1260. {
  1261. name: "limitBuy",
  1262. rule: ["required"],
  1263. msg: ["请填写限购数,0不限购"]
  1264. },
  1265. ];
  1266. // 进行表单检查
  1267. let formData = e.detail.value;
  1268. let checkRes = form.validation(formData, rules);
  1269. // 验证通过!
  1270. if (!checkRes) {
  1271. this.confirmFn()
  1272. } else {
  1273. this.$msg(checkRes);
  1274. }
  1275. }
  1276. }
  1277. };
  1278. </script>
  1279. <style lang="scss" scoped>
  1280. .app-content {
  1281. min-height: calc(100vh - 100upx);
  1282. padding-bottom: 150upx;
  1283. }
  1284. // 公共模块
  1285. .module-com {
  1286. margin-bottom: 20upx;
  1287. background-color: #fff;
  1288. color: $fontColor2;
  1289. .module-tit {
  1290. padding: 20upx 30upx;
  1291. font-size: 28upx;
  1292. }
  1293. .module-det {
  1294. padding: 0 30upx;
  1295. }
  1296. }
  1297. .category-wrap {
  1298. align-items: flex-start;
  1299. padding-bottom: 0 !important;
  1300. .tui-input {
  1301. @include disFlex(center, flex-start);
  1302. flex-wrap: wrap;
  1303. .admin-button-com {
  1304. margin-right: 20upx;
  1305. margin-bottom: 20upx;
  1306. position: relative;
  1307. z-index: 9999;
  1308. }
  1309. }
  1310. }
  1311. .summary-wrap {
  1312. .goods-summary {
  1313. height: 400upx;
  1314. }
  1315. }
  1316. .app-footer {
  1317. justify-content: space-evenly;
  1318. z-index: 9999;
  1319. .admin-button-com {
  1320. width: 46%;
  1321. }
  1322. }
  1323. // 权重提醒图标样式
  1324. .weight-reminder-icon {
  1325. margin-left: 20upx;
  1326. padding: 10upx;
  1327. width: 60upx;
  1328. height: 60upx;
  1329. display: flex;
  1330. align-items: center;
  1331. justify-content: center;
  1332. background-color: #f5f5f5;
  1333. border-radius: 50%;
  1334. border: 1upx solid #ddd;
  1335. }
  1336. // 权重弹窗样式
  1337. .weight-popup-style {
  1338. .weight-popup-container {
  1339. width: 600upx;
  1340. max-height: 80vh;
  1341. padding: 30upx;
  1342. border-radius: 16upx;
  1343. background-color: #fff;
  1344. z-index:9999;
  1345. .weight-popup-title {
  1346. font-size: 32upx;
  1347. font-weight: bold;
  1348. color: #333;
  1349. text-align: center;
  1350. margin-bottom: 30upx;
  1351. }
  1352. .weight-popup-content {
  1353. .weight-item {
  1354. display: flex;
  1355. justify-content: space-between;
  1356. align-items: center;
  1357. padding: 20upx 0;
  1358. border-bottom: 1upx solid #f0f0f0;
  1359. &:last-child {
  1360. border-bottom: none;
  1361. }
  1362. .weight-name {
  1363. font-size: 28upx;
  1364. color: #333;
  1365. font-weight: 500;
  1366. }
  1367. .weight-value {
  1368. font-size: 28upx;
  1369. color: #666;
  1370. }
  1371. }
  1372. }
  1373. .weight-popup-note {
  1374. margin-top: 30upx;
  1375. padding: 20upx;
  1376. background-color: #f8f8f8;
  1377. border-radius: 8upx;
  1378. font-size: 28upx;
  1379. color: #999;
  1380. line-height: 1.5;
  1381. }
  1382. .weight-popup-footer {
  1383. margin-top: 30upx;
  1384. display: flex;
  1385. justify-content: center;
  1386. }
  1387. }
  1388. }
  1389. .use-img{
  1390. font-size: 22rpx;
  1391. color: #999999;
  1392. padding: 4rpx 8rpx;
  1393. line-height: 1.5;
  1394. }
  1395. .no-img-tip {
  1396. font-size: 26rpx;
  1397. color: #cccccc;
  1398. padding: 12rpx 0;
  1399. }
  1400. </style>