shelfSet.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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. if(e.val == 1){
  103. uni.navigateTo({
  104. url: "/pages/latePlay/chooseProduct?shelfSn="+this.shelfSn+'&shelfName='+this.detailData.shelfName
  105. })
  106. }
  107. // 快速补货
  108. if(e.val == 0){
  109. }
  110. },
  111. showTip(){
  112. uni.showModal({
  113. showCancel:false,
  114. confirmText:"好的",
  115. title: "提示",
  116. content: "只有当数字货架的“是否设置完成”为“是”,系统才会自动对该货架生成补货单,修理厂才能正常下单。"
  117. })
  118. },
  119. // 设置完成是否
  120. switchChange(v){
  121. const params = {
  122. shelfSn: this.shelfSn,
  123. finishFlag: v ? '1' : '0'
  124. }
  125. modifFinishFlag(params).then(res => {
  126. if (res.status == 200) {
  127. uni.showToast({
  128. icon: 'none',
  129. title: res.message
  130. })
  131. }
  132. })
  133. },
  134. // 关联客户
  135. customeSet(){
  136. uni.navigateTo({
  137. url: "/pages/sales/chooseCustomer?backPage=shelfEdit&shelfName="+this.detailData.shelfName
  138. })
  139. },
  140. // 修改货架名称
  141. editShelf(){
  142. uni.navigateTo({
  143. url: "/pages/shelfSetting/editShelf?shelfName="+this.detailData.shelfName
  144. })
  145. },
  146. // 按照产品搜索货位
  147. toSearchHw(){
  148. uni.navigateTo({
  149. url: "/pages/shelfSetting/searchShelfHw?shelfName="+this.detailData.shelfName+"&shelfSn="+this.shelfSn
  150. })
  151. },
  152. // 编辑货位
  153. editHw(item){
  154. const hasProduct = item.shelfProductApiEntity && item.shelfProductApiEntity.productSn
  155. const type = hasProduct ? 'edit':'bind'
  156. const params = Object.assign(this.detailData,item)
  157. uni.navigateTo({
  158. url: "/pages/shelfSetting/editShelfHw?detailData="+encodeURIComponent(JSON.stringify(params))+"&type=" + type
  159. })
  160. },
  161. // 新增货位
  162. addHw(type,flag){
  163. let shelfPlaceCode = ''
  164. if(type=='edit'){
  165. shelfPlaceCode = flag
  166. }
  167. if(type=='add'&&flag==1){
  168. const row = this.shelfPlaceList[this.curTab]
  169. const num = row[row.length-1].shelfPlaceCode.replace(this.curTab,'')
  170. shelfPlaceCode = this.curTab + (Number(num) + 1)
  171. }
  172. uni.navigateTo({
  173. url: "/pages/shelfSetting/addShelfHw?detailData="+encodeURIComponent(JSON.stringify(this.detailData))+"&type="+type+"&shelfPlaceCode="+shelfPlaceCode
  174. })
  175. },
  176. // 保存数字货架基本信息
  177. saveShelf(data,type){
  178. const params = {
  179. shelfSn: this.shelfSn
  180. }
  181. if(type == 1){
  182. params.customerSn = this.detailData.customerSn
  183. params.shelfName = data.shelfName
  184. }else{
  185. params.customerSn = data.customerSn
  186. }
  187. shelfSave(params).then(res => {
  188. if (res.status == 200) {
  189. uni.showToast({
  190. icon: 'none',
  191. title: res.message
  192. })
  193. this.getShelfDetal()
  194. }
  195. })
  196. },
  197. getShelfDetal(){
  198. shelfDetail({ sn: this.shelfSn }).then(res => {
  199. if (res.status == 200) {
  200. this.detailData = res.data
  201. this.switchVal = res.data.finishFlag == 1
  202. } else {
  203. this.detailData = null
  204. }
  205. })
  206. },
  207. getShelfPlace(flag){
  208. getProductPlace({ shelfSn: this.shelfSn }).then(res => {
  209. if (res.status == 200) {
  210. this.shelfPlaceList = res.data
  211. for(let a in res.data){
  212. this.placeTab.push(a)
  213. }
  214. if(!flag){
  215. this.curTab = this.placeTab[0]
  216. }
  217. } else {
  218. this.shelfPlaceList = null
  219. }
  220. })
  221. },
  222. tabChange(item){
  223. this.curTab = item
  224. }
  225. }
  226. }
  227. </script>
  228. <style lang="less">
  229. .content{
  230. width:100%;
  231. }
  232. .card-box{
  233. background-color: #fff;
  234. border-radius: 0.5rem;
  235. box-shadow: 0.1rem 0.2rem 0.3rem #eee;
  236. padding: 0 1rem;
  237. margin: 0.5rem;
  238. .card-row{
  239. border-bottom: 0.1rpx solid #eee;
  240. padding: 20rpx 0;
  241. min-height: 90rpx;
  242. &:last-child{
  243. border-bottom: 0;
  244. }
  245. .label{
  246. flex: 1;
  247. width: 20%;
  248. }
  249. .text{
  250. width: 80%;
  251. color: #666;
  252. }
  253. }
  254. }
  255. .shelfPlace{
  256. .shelfPlaceHead{
  257. padding: 0.2rem 0.5rem 0.5rem;
  258. justify-content: space-between;
  259. .lt{
  260. font-size: 0.9rem;
  261. color: #999;
  262. text{
  263. color: #ff5500;
  264. font-size: 1rem;
  265. }
  266. }
  267. .search-btn{
  268. border:0.1rpx solid #eee;
  269. border-radius: 50rpx;
  270. width: 50%;
  271. justify-content: space-between;
  272. padding:0.3rem 0.5rem;
  273. color: #999;
  274. background-color: #fff;
  275. font-size: 0.9rem;
  276. &:active{
  277. opacity: 0.6;
  278. }
  279. }
  280. }
  281. .shelfTabs{
  282. height: calc(100vh - 150rpx);
  283. .leftTabs{
  284. width: 20%;
  285. overflow: auto;
  286. > view{
  287. padding: 0.8rem 0.5rem;
  288. border-left: 0.2rem solid #f8f8f8;
  289. text-align: center;
  290. }
  291. .active{
  292. border-color: rgb(47, 126, 209);
  293. background-color: #fff;
  294. }
  295. }
  296. .rightCons{
  297. width: 80%;
  298. background-color: #fff;
  299. position: relative;
  300. .hwList{
  301. overflow: auto;
  302. padding: 0.5rem;
  303. padding-bottom: 105rpx;
  304. > text{
  305. border: 0.1rpx solid #eee;
  306. padding: 0.2rem 0.8rem;
  307. border-radius: 0.3rem;
  308. margin: 0.5rem 2%;
  309. float: left;
  310. width: 20%;
  311. text-align: center;
  312. }
  313. .red{
  314. border-color: orangered;
  315. }
  316. .add{
  317. border-style: dashed;
  318. border-color: #999;
  319. color: #999;
  320. }
  321. }
  322. .hwAction{
  323. padding: 0.5rem;
  324. position: fixed;
  325. bottom: 0;
  326. right: 0;
  327. width: 80%;
  328. background-color: #fff;
  329. button{
  330. width: 240rpx;
  331. }
  332. .newbtn{
  333. background-color: rgb(51, 95, 182);
  334. color: #fff;
  335. }
  336. }
  337. }
  338. }
  339. }
  340. </style>