shelfSet.vue 15 KB

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