shelfSet.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  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. setTimeout(()=>{
  310. this.getShelfDetal()
  311. },4000)
  312. }
  313. })
  314. },
  315. // 获取价格显示设置
  316. getShelfPriceShow () {
  317. getShelfPriceShow({ shelfSn: this.shelfSn }).then(res => {
  318. if (res.status == 200) {
  319. this.showPrice = res.data.paramValue
  320. }
  321. })
  322. },
  323. clickAction(index){
  324. uni.showLoading({
  325. mask: true,
  326. title: '正在保存价格显示...'
  327. })
  328. updateShelfPriceShow({
  329. shelfSn: this.shelfSn,
  330. paramValue: index == 0 ? 1 : 0
  331. }).then(res => {
  332. if(res.status == 200){
  333. this.getShelfPriceShow()
  334. this.toashMsg(res.message)
  335. }
  336. uni.hideLoading()
  337. })
  338. },
  339. getShelfDetal(){
  340. shelfDetail({ sn: this.shelfSn }).then(res => {
  341. if (res.status == 200) {
  342. this.detailData = res.data
  343. this.switchVal = res.data.finishFlag == 1
  344. } else {
  345. this.detailData = null
  346. }
  347. })
  348. },
  349. getShelfPlace(flag){
  350. this.loading = true
  351. getProductPlace({ shelfSn: this.shelfSn }).then(res => {
  352. if (res.status == 200 && res.data) {
  353. this.shelfPlaceList = res.data
  354. // 获取层
  355. for(let a in res.data){
  356. this.placeTab.push(a)
  357. }
  358. // 排序
  359. this.placeTab.sort(function(a,b){ return (a+'').localeCompare(b+'');});
  360. console.log(this.placeTab)
  361. if(!flag || !this.curTab){
  362. this.curTab = this.placeTab[0]
  363. }
  364. if(this.placeTab.length == 0){
  365. this.shelfPlaceList = null
  366. }
  367. } else {
  368. this.shelfPlaceList = null
  369. this.placeTab = []
  370. }
  371. // 是否有已录入的产品
  372. this.getHasCartNotEmpty()
  373. this.isLoad = false
  374. this.loading = false
  375. })
  376. },
  377. tabChange(item){
  378. this.curTab = item
  379. },
  380. getHasCartNotEmpty(){
  381. shelfCartNotEmpty({ shelfSn: this.shelfSn }).then(res => {
  382. this.showDot = res.data == 1
  383. })
  384. }
  385. }
  386. }
  387. </script>
  388. <style lang="less">
  389. .content{
  390. width:100%;
  391. .nodata{
  392. padding: 100rpx 50rpx;
  393. text-align: center;
  394. display: flex;
  395. justify-content: center;
  396. > view{
  397. position: relative;
  398. text{
  399. color: #00aaff;
  400. margin-left: 10rpx;
  401. }
  402. }
  403. }
  404. .moreSeting{
  405. text-align: center;
  406. color: #999;
  407. padding: 20upx;
  408. > text{
  409. margin-right: 10rpx;
  410. }
  411. }
  412. }
  413. .card-box{
  414. background-color: #fff;
  415. border-radius: 0.5rem;
  416. box-shadow: 0.1rem 0.2rem 0.3rem #eee;
  417. padding: 0 1rem;
  418. margin: 0.5rem;
  419. .card-row{
  420. border-bottom: 1rpx solid #eee;
  421. padding: 20rpx 0;
  422. min-height: 90rpx;
  423. &:last-child{
  424. border-bottom: 0;
  425. }
  426. .label{
  427. flex: 1;
  428. width: 20%;
  429. }
  430. .text{
  431. width: 80%;
  432. color: #666;
  433. }
  434. }
  435. }
  436. .shelfPlace{
  437. .shelfPlaceHead{
  438. padding: 0.2rem 0.5rem 0.5rem;
  439. justify-content: space-between;
  440. .lt{
  441. font-size: 0.9rem;
  442. color: #999;
  443. text{
  444. color: #ff5500;
  445. font-size: 1rem;
  446. }
  447. }
  448. .search-btn{
  449. border:1rpx solid #eee;
  450. border-radius: 50rpx;
  451. width: 50%;
  452. justify-content: space-between;
  453. padding:0.3rem 0.5rem;
  454. color: #999;
  455. background-color: #fff;
  456. font-size: 0.9rem;
  457. &:active{
  458. opacity: 0.6;
  459. }
  460. }
  461. }
  462. .shelfTabs{
  463. height: calc(100vh - 150rpx);
  464. .leftTabs{
  465. width: 20%;
  466. overflow: auto;
  467. > view{
  468. padding: 0.8rem 0.5rem;
  469. border-left: 0.2rem solid #f8f8f8;
  470. text-align: center;
  471. }
  472. .active{
  473. border-color: rgb(47, 126, 209);
  474. background-color: #fff;
  475. }
  476. }
  477. .rightCons{
  478. width: 80%;
  479. background-color: #fff;
  480. position: relative;
  481. .hwList{
  482. overflow: auto;
  483. padding: 0.5rem;
  484. padding-bottom: 105rpx;
  485. > text{
  486. border: 1rpx solid #eee;
  487. padding: 0.2rem 0.8rem;
  488. border-radius: 0.3rem;
  489. margin: 0.5rem 2%;
  490. float: left;
  491. width: 20%;
  492. text-align: center;
  493. }
  494. .red{
  495. border-color: #ff5500;
  496. }
  497. .add{
  498. border-style: dashed;
  499. border-color: #999;
  500. color: #999;
  501. }
  502. }
  503. .hwAction{
  504. padding: 0.5rem;
  505. position: fixed;
  506. bottom: 0;
  507. right: 0;
  508. width: 80%;
  509. background-color: #fff;
  510. button{
  511. width: 240rpx;
  512. }
  513. .newbtn{
  514. background-color: rgb(51, 95, 182);
  515. color: #fff;
  516. }
  517. }
  518. }
  519. }
  520. }
  521. </style>