shelfSet.vue 10 KB

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