shelfSet.vue 15 KB

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