shelfSet.vue 11 KB

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