shelfSet.vue 14 KB

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