shelfSet.vue 12 KB

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