shelfSet.vue 14 KB

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