shelfSet.vue 8.7 KB

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