shelfSet.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. <template>
  2. <view class="content">
  3. <u-navbar back-text="货架设置">
  4. <view slot='right' style="padding: 0 30upx;color: #00aaff;" @click="toPlRacking">
  5. <u-icon name="piliangshangjia" custom-prefix="iscm-icon"></u-icon>
  6. <text style="margin-left: 6rpx;">批量上架</text>
  7. <u-badge v-if="showDot" :is-dot="true" size="mini" type="error"></u-badge>
  8. </view>
  9. </u-navbar>
  10. <view class="card-box" v-if="detailData">
  11. <view class="card-row flex align_center justify_between">
  12. <view class="label">货架名称</view>
  13. <view class="text flex align_center" @click="editShelf">
  14. <text style="width: 80%;flex: 1;">{{detailData.shelfName}}</text>
  15. <u-icon name="arrow-right" color="#969da3" size="28"></u-icon>
  16. </view>
  17. </view>
  18. <view class="card-row flex align_center justify_between">
  19. <view class="label">关联客户</view>
  20. <view class="text flex align_center" @click="customeSet">
  21. <text style="width: 80%;flex: 1;">{{ (detailData&&detailData.customerEntity&&detailData.customerEntity.customerName) || '--' }}</text>
  22. <u-icon name="arrow-right" color="#969da3" size="28"></u-icon>
  23. </view>
  24. </view>
  25. <view class="card-row align_center flex justify_between">
  26. <view class="label" style="width: 50%;" @click="showTip(1)">是否设置完成 <u-icon color="#ffaa00" name="question-circle"></u-icon></view>
  27. <view class="text" style="width: 50%;text-align: right;"><u-switch v-model="switchVal" @change="switchChange"></u-switch></view>
  28. </view>
  29. <view class="card-row align_center flex justify_between">
  30. <view class="label" style="width: 40%;" @click="showTip(0)">价格显示 <u-icon color="#ffaa00" name="question-circle"></u-icon></view>
  31. <view class="text flex align_center" style="width: 60%;text-align: right;" @click="updateShowPrice = true">
  32. <text style="width: 80%;flex: 1;">非铺货产品——{{ showPrice == '1' ? '显示': '不显示' }}价格</text>
  33. <u-icon name="arrow-right" color="#969da3" size="28"></u-icon>
  34. </view>
  35. </view>
  36. <u-action-sheet :list="actionList" @click="clickAction" v-model="updateShowPrice"></u-action-sheet>
  37. </view>
  38. <!-- 货位信息 -->
  39. <view class="shelfPlace" v-if="shelfPlaceList">
  40. <view class="flex align_center shelfPlaceHead">
  41. <view class="lt"><text>□</text>表示没有绑定产品</view>
  42. <view class="search-btn flex align_center" @click="toSearchHw">
  43. <view><u-icon name="search"></u-icon><text>按产品搜索</text></view>
  44. <u-icon name="scan"></u-icon>
  45. </view>
  46. </view>
  47. <view class="flex shelfTabs">
  48. <view class="leftTabs">
  49. <view v-for="item in placeTab" :key="item" :class="curTab==item?'active':''" @click="tabChange(item)">{{item}}层</view>
  50. </view>
  51. <view class="rightCons flex flex_column">
  52. <view class="hwList flex_1">
  53. <text @click="editHw(item)" v-for="item in shelfPlaceList[curTab]" :key="item.shelfPlaceCode" :class="item.shelfProductApiEntity && item.shelfProductApiEntity.productSn?'':'red'">
  54. {{item.shelfPlaceCode}}
  55. </text>
  56. <text class="add" @click="addHw('add',1)"><u-icon name="plus"></u-icon></text>
  57. </view>
  58. <view class="hwAction flex justify_between">
  59. <u-button shape="circle" @click="tapPopup(1)" size="medium">打印贴签</u-button>
  60. <u-button class="newbtn" @click="tapPopup(2)" type='primary' shape="circle" size="medium">快速补货</u-button>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. <view v-else>
  66. <view class="nodata">暂无货位信息,请点击 <text @click="toPlRacking">批量上架</text></view>
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. import { shelfDetail, shelfSave, modifFinishFlag, getProductPlace, getShelfPriceShow, updateShelfPriceShow } from '@/api/shelf'
  72. import { shelfCartNotEmpty } from '@/api/shelfCart'
  73. import { createShelfReplenishBill } from '@/api/shelfReplenish'
  74. export default {
  75. components:{
  76. },
  77. data() {
  78. return {
  79. shelfSn: null,
  80. detailData: null,
  81. switchVal: false,
  82. showMenus:false,
  83. popData:[{title:'快速补货',val:'0'},{title:'打印贴签',val:'1'}],
  84. pleft:0,
  85. ptop:0,
  86. shelfPlaceList: null,
  87. placeTab: [],
  88. curTab: '',
  89. isLoad: false,
  90. webView: null,
  91. showDot: false,
  92. showPrice: '',
  93. updateShowPrice: false,
  94. actionList:[
  95. {
  96. text: '非铺货产品——显示价格',
  97. fontSize: 32
  98. },
  99. {
  100. text: '非铺货产品——不显示价格',
  101. fontSize: 32
  102. }
  103. ]
  104. }
  105. },
  106. onLoad(option) {
  107. this.shelfSn = option.shelfSn
  108. // 获取货架详情
  109. this.getShelfDetal()
  110. this.getShelfPriceShow()
  111. // 获取货物
  112. this.getShelfPlace()
  113. this.isLoad = true
  114. this.webView = this.$mp.page.$getAppWebview();
  115. uni.$on("editCustome",(data)=>{
  116. this.saveShelf(data,0)
  117. })
  118. uni.$on("editShelfName",(data)=>{
  119. this.saveShelf(data,1)
  120. })
  121. const win = uni.getWindowInfo()
  122. this.pleft = Math.floor(win.windowWidth * 0.3)
  123. this.ptop = Math.floor(win.windowHeight - 70)
  124. console.log(this.shelfSn)
  125. },
  126. onUnload() {
  127. uni.$off("editCustome")
  128. uni.$off("editShelfName")
  129. },
  130. onShow() {
  131. if(!this.isLoad){
  132. this.updateHw()
  133. }
  134. },
  135. methods: {
  136. // 刷新货位
  137. updateHw(){
  138. this.placeTab = []
  139. this.getShelfPlace(true)
  140. },
  141. // 批量上架
  142. toPlRacking(){
  143. const url = this.showDot ? '/pages/batchShelves/cartList' : '/pages/batchShelves/index'
  144. uni.navigateTo({
  145. url: url+"?shelfSn="+this.shelfSn+'&shelfName='+this.detailData.shelfName+'&customerSn='+this.detailData.customerSn
  146. })
  147. },
  148. // 更多操作
  149. tapPopup(e){
  150. // 打印贴签
  151. if(e == 1){
  152. if(this.hasNoBindPro()){
  153. uni.navigateTo({
  154. url: "/pages/latePlay/chooseProduct?shelfSn="+this.shelfSn+'&shelfName='+this.detailData.shelfName
  155. })
  156. }else{
  157. uni.showModal({
  158. showCancel:false,
  159. confirmText:"好的",
  160. title: "提示",
  161. content: "所有货位都没有绑定产品,无法打印贴签!"
  162. })
  163. }
  164. }
  165. // 快速补货
  166. if(e == 2){
  167. createShelfReplenishBill({shelfSn: this.shelfSn}).then(res => {
  168. console.log(res.data)
  169. if(res.data&&res.data.length){
  170. const params = Object.assign(this.detailData,{list:res.data})
  171. this.$store.state.vuex_tempData = params
  172. uni.navigateTo({
  173. url: "/pages/shelfSetting/quickReplenish"
  174. })
  175. }else{
  176. uni.showModal({
  177. showCancel:false,
  178. confirmText:"好的",
  179. title: "提示",
  180. content: "没有需要补货的产品"
  181. })
  182. }
  183. })
  184. }
  185. },
  186. showTip(type){
  187. uni.showModal({
  188. showCancel:false,
  189. confirmText:"好的",
  190. title: "提示",
  191. content: type ? "只有当数字货架的“是否设置完成”为“是”,系统才会自动对该货架生成补货单,修理厂才能正常下单。":"1、非铺货产品,是指不是货架上的产品\n2、终端会员价,对于汽修厂来说,即进货价\n3、如果该产品在销售单里有销售记录,则使用最近一次销售价,如果没有销售记录,则使用箭冠总公司的终端会员价"
  192. })
  193. },
  194. // 设置完成是否
  195. switchChange(v){
  196. const params = {
  197. shelfSn: this.shelfSn,
  198. finishFlag: v ? '1' : '0'
  199. }
  200. modifFinishFlag(params).then(res => {
  201. if (res.status == 200) {
  202. uni.showToast({
  203. icon: 'none',
  204. title: res.message
  205. })
  206. }
  207. })
  208. },
  209. // 关联客户
  210. customeSet(){
  211. uni.navigateTo({
  212. url: "/pages/sales/chooseCustomer?backPage=shelfEdit&shelfName="+this.detailData.shelfName
  213. })
  214. },
  215. // 修改货架名称
  216. editShelf(){
  217. uni.navigateTo({
  218. url: "/pages/shelfSetting/editShelf?shelfName="+this.detailData.shelfName
  219. })
  220. },
  221. // 是否没有绑定任何产品
  222. hasNoBindPro(){
  223. let noBindPro = null;
  224. for(let i=0;i<this.placeTab.length;i++){
  225. noBindPro = this.shelfPlaceList[this.placeTab[i]].find(item => item.shelfProductApiEntity && item.shelfProductApiEntity.productSn);
  226. if(!!noBindPro){
  227. break
  228. }
  229. }
  230. return !!noBindPro
  231. },
  232. // 按照产品搜索货位
  233. toSearchHw(){
  234. if(this.hasNoBindPro()){
  235. uni.navigateTo({
  236. url: "/pages/shelfSetting/searchShelfHw?shelfName="+this.detailData.shelfName+"&shelfSn="+this.shelfSn
  237. })
  238. }else{
  239. uni.showModal({
  240. showCancel:false,
  241. confirmText:"好的",
  242. title: "提示",
  243. content: "所有货位都没有绑定产品,无法搜索!"
  244. })
  245. }
  246. },
  247. // 编辑货位
  248. editHw(item){
  249. const hasProduct = item.shelfProductApiEntity && item.shelfProductApiEntity.productSn
  250. const type = hasProduct ? 'edit':'bind'
  251. const params = Object.assign(this.detailData,item)
  252. this.$store.state.vuex_tempData = params
  253. uni.navigateTo({
  254. url: "/pages/shelfSetting/editShelfHw?type=" + type
  255. })
  256. },
  257. // 新增货位
  258. addHw(type,flag){
  259. let shelfPlaceCode = ''
  260. if(type=='edit'){
  261. shelfPlaceCode = flag
  262. }
  263. if(type=='add'&&flag==1){
  264. const row = this.shelfPlaceList[this.curTab]
  265. const num = row[row.length-1].shelfPlaceCode.replace(this.curTab,'')
  266. const nextNum = Number(num) + 1
  267. shelfPlaceCode = this.curTab + (nextNum<10?'0':'') + nextNum
  268. }
  269. const params={
  270. customerSn: this.detailData.customerSn,
  271. shelfSn: this.detailData.shelfSn,
  272. id: this.detailData.id
  273. }
  274. uni.navigateTo({
  275. url: "/pages/shelfSetting/addShelfHw?detailData="+encodeURIComponent(JSON.stringify(params))+"&type="+type+"&shelfPlaceCode="+shelfPlaceCode
  276. })
  277. },
  278. // 保存数字货架基本信息
  279. saveShelf(data,type){
  280. const params = {
  281. shelfSn: this.shelfSn
  282. }
  283. if(type == 1){
  284. params.customerSn = this.detailData.customerSn
  285. params.shelfName = data.shelfName
  286. }else{
  287. params.customerSn = data.customerSn
  288. }
  289. shelfSave(params).then(res => {
  290. if (res.status == 200) {
  291. uni.showToast({
  292. icon: 'none',
  293. title: res.message
  294. })
  295. this.getShelfDetal()
  296. }
  297. })
  298. },
  299. // 获取价格显示设置
  300. getShelfPriceShow () {
  301. getShelfPriceShow({ shelfSn: this.shelfSn }).then(res => {
  302. if (res.status == 200) {
  303. this.showPrice = res.data.paramValue
  304. }
  305. })
  306. },
  307. clickAction(index){
  308. uni.showLoading({
  309. mask: true,
  310. title: '正在保存价格显示...'
  311. })
  312. updateShelfPriceShow({
  313. shelfSn: this.shelfSn,
  314. paramValue: index == 0 ? 1 : 0
  315. }).then(res => {
  316. if(res.status == 200){
  317. this.getShelfPriceShow()
  318. uni.showToast({
  319. icon: 'none',
  320. title: res.message
  321. })
  322. }
  323. uni.hideLoading()
  324. })
  325. },
  326. getShelfDetal(){
  327. shelfDetail({ sn: this.shelfSn }).then(res => {
  328. if (res.status == 200) {
  329. this.detailData = res.data
  330. this.switchVal = res.data.finishFlag == 1
  331. } else {
  332. this.detailData = null
  333. }
  334. })
  335. },
  336. getShelfPlace(flag){
  337. uni.showLoading({
  338. mask: true,
  339. title: '正在查询...'
  340. })
  341. getProductPlace({ shelfSn: this.shelfSn }).then(res => {
  342. uni.hideLoading()
  343. if (res.status == 200 && res.data) {
  344. this.shelfPlaceList = res.data
  345. // 获取层
  346. for(let a in res.data){
  347. this.placeTab.push(a)
  348. }
  349. // 排序
  350. this.placeTab.sort(function(a,b){ return (a+'').localeCompare(b+'');});
  351. console.log(this.placeTab)
  352. if(!flag || !this.curTab){
  353. this.curTab = this.placeTab[0]
  354. }
  355. if(this.placeTab.length == 0){
  356. this.shelfPlaceList = null
  357. }
  358. } else {
  359. this.shelfPlaceList = null
  360. this.placeTab = []
  361. }
  362. // 是否有已录入的产品
  363. this.getHasCartNotEmpty()
  364. this.isLoad = false
  365. })
  366. },
  367. tabChange(item){
  368. this.curTab = item
  369. },
  370. getHasCartNotEmpty(){
  371. shelfCartNotEmpty({ shelfSn: this.shelfSn }).then(res => {
  372. this.showDot = res.data == 1
  373. })
  374. }
  375. }
  376. }
  377. </script>
  378. <style lang="less">
  379. .content{
  380. width:100%;
  381. .nodata{
  382. padding: 100rpx 50rpx;
  383. text-align: center;
  384. > text{
  385. color: #00aaff;
  386. margin-left: 10rpx;
  387. }
  388. }
  389. }
  390. .card-box{
  391. background-color: #fff;
  392. border-radius: 0.5rem;
  393. box-shadow: 0.1rem 0.2rem 0.3rem #eee;
  394. padding: 0 1rem;
  395. margin: 0.5rem;
  396. .card-row{
  397. border-bottom: 1rpx solid #eee;
  398. padding: 20rpx 0;
  399. min-height: 90rpx;
  400. &:last-child{
  401. border-bottom: 0;
  402. }
  403. .label{
  404. flex: 1;
  405. width: 20%;
  406. }
  407. .text{
  408. width: 80%;
  409. color: #666;
  410. }
  411. }
  412. }
  413. .shelfPlace{
  414. .shelfPlaceHead{
  415. padding: 0.2rem 0.5rem 0.5rem;
  416. justify-content: space-between;
  417. .lt{
  418. font-size: 0.9rem;
  419. color: #999;
  420. text{
  421. color: #ff5500;
  422. font-size: 1rem;
  423. }
  424. }
  425. .search-btn{
  426. border:1rpx solid #eee;
  427. border-radius: 50rpx;
  428. width: 50%;
  429. justify-content: space-between;
  430. padding:0.3rem 0.5rem;
  431. color: #999;
  432. background-color: #fff;
  433. font-size: 0.9rem;
  434. &:active{
  435. opacity: 0.6;
  436. }
  437. }
  438. }
  439. .shelfTabs{
  440. height: calc(100vh - 150rpx);
  441. .leftTabs{
  442. width: 20%;
  443. overflow: auto;
  444. > view{
  445. padding: 0.8rem 0.5rem;
  446. border-left: 0.2rem solid #f8f8f8;
  447. text-align: center;
  448. }
  449. .active{
  450. border-color: rgb(47, 126, 209);
  451. background-color: #fff;
  452. }
  453. }
  454. .rightCons{
  455. width: 80%;
  456. background-color: #fff;
  457. position: relative;
  458. .hwList{
  459. overflow: auto;
  460. padding: 0.5rem;
  461. padding-bottom: 105rpx;
  462. > text{
  463. border: 1rpx solid #eee;
  464. padding: 0.2rem 0.8rem;
  465. border-radius: 0.3rem;
  466. margin: 0.5rem 2%;
  467. float: left;
  468. width: 20%;
  469. text-align: center;
  470. }
  471. .red{
  472. border-color: #ff5500;
  473. }
  474. .add{
  475. border-style: dashed;
  476. border-color: #999;
  477. color: #999;
  478. }
  479. }
  480. .hwAction{
  481. padding: 0.5rem;
  482. position: fixed;
  483. bottom: 0;
  484. right: 0;
  485. width: 80%;
  486. background-color: #fff;
  487. button{
  488. width: 240rpx;
  489. }
  490. .newbtn{
  491. background-color: rgb(51, 95, 182);
  492. color: #fff;
  493. }
  494. }
  495. }
  496. }
  497. }
  498. </style>