shelfSet.vue 12 KB

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