shelfSet.vue 14 KB

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