shelfSet.vue 12 KB

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