shelfSet.vue 10 KB

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