shelfSet.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. <template>
  2. <view class="content">
  3. <u-navbar back-text="货架设置" :border-bottom="false" :background="{backgroundColor: $config('primaryColor')}"
  4. back-icon-color="#fff" :back-text-style="{ color: '#fff' }">
  5. <view slot='right' style="padding: 0 30upx;color: #ffffff;" @click="toPlRacking" v-if="shelfPlaceList">
  6. <u-icon name="piliangshangjia" custom-prefix="iscm-icon"></u-icon>
  7. <text style="margin-left: 6rpx;">批量上架</text>
  8. <u-badge v-if="showDot" :is-dot="true" size="mini" type="error"></u-badge>
  9. </view>
  10. </u-navbar>
  11. <view class="body-content flex flex_column">
  12. <view class="card-box" v-if="detailData">
  13. <view class="card-row flex align_center justify_between">
  14. <view class="label">货架名称</view>
  15. <view class="text flex align_center" @click="editShelf">
  16. <text style="width: 80%;flex: 1;">{{detailData.shelfName}}</text>
  17. <u-icon name="arrow-right" color="#969da3" size="28"></u-icon>
  18. </view>
  19. </view>
  20. <view class="card-row flex align_center justify_between">
  21. <view class="label">关联客户</view>
  22. <view class="text flex align_center" @click="customeSet">
  23. <text
  24. style="width: 80%;flex: 1;">{{ (detailData&&detailData.customerEntity&&detailData.customerEntity.customerName) || '--' }}</text>
  25. <u-icon name="arrow-right" color="#969da3" size="28"></u-icon>
  26. </view>
  27. </view>
  28. <view class="card-row align_center flex justify_between">
  29. <view class="label" style="width: 40%;" @click="showTip(0)">价格权限设置 <u-icon color="#ffaa00"
  30. name="question-circle"></u-icon></view>
  31. <view class="text flex align_center" style="width: 60%;text-align: right;"
  32. @click="updateShowPrice = true">
  33. <text style="width: 80%;flex: 1;">{{showPriceStr.length ? showPriceStr.join("/") : '--'}}</text>
  34. <u-icon name="arrow-right" color="#969da3" size="28"></u-icon>
  35. </view>
  36. </view>
  37. <view class="card-row align_center flex justify_between" v-if="showMore">
  38. <view class="label" style="width: 50%;" @click="showTip(1)">是否设置完成 <u-icon color="#ffaa00"
  39. name="question-circle"></u-icon></view>
  40. <view class="text" style="width: 50%;text-align: right;"><u-switch v-model="switchVal"
  41. @change="switchChange"></u-switch></view>
  42. </view>
  43. <view class="moreSeting" @click="showMore=!showMore">
  44. <text>{{!showMore?'更多设置':'收起'}}</text> <u-icon :name="showMore?'arrow-up':'arrow-down'"></u-icon>
  45. </view>
  46. </view>
  47. <!-- 货位信息 -->
  48. <view class="shelfPlace" :style="{height: scrollH+'px'}" v-if="shelfPlaceList">
  49. <view class="flex align_center shelfPlaceHead">
  50. <view class="lt"><text>□</text>表示没有绑定产品</view>
  51. <view class="search-btn flex align_center" @click="toSearchHw">
  52. <view><u-icon name="search"></u-icon><text>按产品搜索</text></view>
  53. <u-icon name="scan"></u-icon>
  54. </view>
  55. </view>
  56. <view class="flex shelfTabs">
  57. <view class="leftTabs">
  58. <view v-for="item in placeTab" :key="item" :class="curTab==item?'active':''"
  59. @click="tabChange(item)">{{item}}层</view>
  60. </view>
  61. <view class="rightCons flex flex_column">
  62. <view class="hwList flex_1">
  63. <text @click="editHw(item)" v-for="item in shelfPlaceList[curTab]"
  64. :key="item.shelfPlaceCode"
  65. :class="item.shelfProductApiEntity && item.shelfProductApiEntity.productSn?'':'red'">
  66. {{item.shelfPlaceCode}}
  67. </text>
  68. <text class="add" @click="addHw('add',1)"><u-icon name="plus"></u-icon></text>
  69. </view>
  70. <view class="hwAction flex justify_between">
  71. <u-button shape="circle" @click="tapPopup(1)" size="medium">打印贴签</u-button>
  72. <u-button class="newbtn" @click="tapPopup(2)" type='primary' shape="circle"
  73. size="medium">快速补货</u-button>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. <view style="width: 100%;" v-else>
  79. <view class="nodata" v-if="!loading">
  80. <view>
  81. <u-image :src="`../../static/${$config('themePath')}/def_no_data@3x.png`" width="180"
  82. height="180" border-radius="10"></u-image>
  83. </view>
  84. <view class="flex">
  85. 暂无货位信息,请点击
  86. <view>
  87. <text @click="toPlRacking">批量上架</text>
  88. <u-badge :offset="[-6,-10]" v-if="showDot" :is-dot="true" size="mini"
  89. type="error"></u-badge>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="nodata" v-else>
  94. <u-loadmore :load-text="$config('loadText')" status="loading" />
  95. </view>
  96. </view>
  97. </view>
  98. <!-- 设置价格显示弹框 -->
  99. <u-modal v-model="updateShowPrice" :show-cancel-button="true" title="价格权限设置" @confirm="savePriceSet">
  100. <view class="slot-content" style="padding: 1.5rem 1rem;text-align: center;">
  101. <view style="color: #999;font-size: 0.8rem;margin-bottom: 1rem;">提示:不勾选则不显示价格</view>
  102. <u-checkbox-group @change="priceSetChange">
  103. <u-checkbox v-for="item in showPrice" :key="item.paramCode" v-model="item.checked"
  104. :name="item.paramCode">{{item.text}}</u-checkbox>
  105. </u-checkbox-group>
  106. </view>
  107. </u-modal>
  108. </view>
  109. </template>
  110. <script>
  111. import {
  112. shelfDetail,
  113. shelfSave,
  114. modifFinishFlag,
  115. getProductPlace,
  116. getShelfPriceShow,
  117. updateShelfPriceShow
  118. } from '@/api/shelf'
  119. import {
  120. shelfCartNotEmpty
  121. } from '@/api/shelfCart'
  122. import {
  123. createShelfReplenishBill
  124. } from '@/api/shelfReplenish'
  125. export default {
  126. components: {},
  127. data() {
  128. return {
  129. loading: false,
  130. shelfSn: null,
  131. detailData: null,
  132. switchVal: false,
  133. showMenus: false,
  134. scrollH: 400,
  135. popData: [{
  136. title: '快速补货',
  137. val: '0'
  138. }, {
  139. title: '打印贴签',
  140. val: '1'
  141. }],
  142. pleft: 0,
  143. ptop: 0,
  144. shelfPlaceList: null,
  145. placeTab: [],
  146. curTab: '',
  147. isLoad: false,
  148. webView: null,
  149. showDot: false,
  150. showPrice: [],
  151. showPriceStr: [],
  152. updateShowPrice: false,
  153. showMore: false
  154. }
  155. },
  156. watch: {
  157. showMore(a, b) {
  158. this.getScrollHeight(a)
  159. },
  160. },
  161. onLoad(option) {
  162. this.shelfSn = option.shelfSn
  163. // 获取货架详情
  164. this.getShelfDetal()
  165. // 获取货物
  166. this.getShelfPlace()
  167. this.isLoad = true
  168. // this.webView = this.$mp.page.$getAppWebview();
  169. uni.$on("editCustome", (data) => {
  170. this.isLoad = true
  171. this.saveShelf(data, 0)
  172. })
  173. uni.$on("editShelfName", (data) => {
  174. this.isLoad = true
  175. this.saveShelf(data, 1)
  176. })
  177. // const win = uni.getWindowInfo()
  178. // this.pleft = Math.floor(win.windowWidth * 0.3)
  179. // this.ptop = Math.floor(win.windowHeight - 70)
  180. this.getScrollHeight(this.showMore)
  181. console.log(this.shelfSn)
  182. },
  183. onUnload() {
  184. uni.$off("editCustome")
  185. uni.$off("editShelfName")
  186. },
  187. onShow() {
  188. if (!this.isLoad) {
  189. this.updateHw()
  190. }
  191. },
  192. methods: {
  193. getScrollHeight(a) {
  194. const sys = uni.getSystemInfoSync()
  195. const h = a ? 290 : 250
  196. if (sys.platform == 'android') {
  197. this.scrollH = sys.windowHeight - h
  198. } else {
  199. if (sys.safeArea.top) {
  200. this.scrollH = sys.windowHeight - h + sys.statusBarHeight - 34
  201. } else {
  202. this.scrollH = sys.windowHeight - h - 14
  203. }
  204. }
  205. },
  206. // 刷新货位
  207. updateHw() {
  208. this.placeTab = []
  209. this.shelfPlaceList = null
  210. this.getShelfPlace(true)
  211. },
  212. // 批量上架
  213. toPlRacking() {
  214. const url = this.showDot ? '/pages/batchShelves/cartList' : '/pages/batchShelves/index'
  215. uni.navigateTo({
  216. url: url + "?shelfSn=" + this.shelfSn + '&shelfName=' + this.detailData.shelfName +
  217. '&customerSn=' + this.detailData.customerSn
  218. })
  219. },
  220. // 更多操作
  221. tapPopup(e) {
  222. // 打印贴签
  223. if (e == 1) {
  224. if (this.hasNoBindPro()) {
  225. uni.navigateTo({
  226. url: "/pages/latePlay/chooseProduct?shelfSn=" + this.shelfSn + '&shelfName=' + this
  227. .detailData.shelfName
  228. })
  229. } else {
  230. uni.showModal({
  231. showCancel: false,
  232. confirmText: "好的",
  233. title: "提示",
  234. content: "所有货位都没有绑定产品,无法打印贴签!"
  235. })
  236. }
  237. }
  238. // 快速补货
  239. if (e == 2) {
  240. createShelfReplenishBill({
  241. shelfSn: this.shelfSn,
  242. enableFlag: 1
  243. }).then(res => {
  244. console.log(res.data)
  245. if (res.data && res.data.length) {
  246. const params = Object.assign(this.detailData, {
  247. list: res.data
  248. })
  249. this.$store.state.vuex_tempData = params
  250. uni.navigateTo({
  251. url: "/pages/shelfSetting/quickReplenish"
  252. })
  253. } else {
  254. uni.showModal({
  255. showCancel: false,
  256. confirmText: "好的",
  257. title: "提示",
  258. content: "没有需要补货的产品"
  259. })
  260. }
  261. })
  262. }
  263. },
  264. showTip(type) {
  265. uni.showModal({
  266. showCancel: false,
  267. confirmText: "好的",
  268. title: "提示",
  269. content: type ? "只有当数字货架的“是否设置完成”为“是”,系统才会自动对该货架生成补货单,修理厂才能正常下单。" :
  270. "1、不勾选则不显示价格,非货架产品只显示车主价,不选择车主价时,非货架产品不显示价格\n2、结算价:即易码通进货价"
  271. })
  272. },
  273. // 设置完成是否
  274. switchChange(v) {
  275. const params = {
  276. shelfSn: this.shelfSn,
  277. finishFlag: v ? '1' : '0'
  278. }
  279. modifFinishFlag(params).then(res => {
  280. if (res.status == 200) {
  281. uni.showToast({
  282. icon: 'none',
  283. title: res.message
  284. })
  285. }
  286. })
  287. },
  288. // 关联客户
  289. customeSet() {
  290. uni.navigateTo({
  291. url: "/pages/sales/chooseCustomer?backPage=shelfEdit&shelfName=" + this.detailData.shelfName
  292. })
  293. },
  294. // 修改货架名称
  295. editShelf() {
  296. uni.navigateTo({
  297. url: "/pages/shelfSetting/editShelf?shelfName=" + this.detailData.shelfName
  298. })
  299. },
  300. // 是否没有绑定任何产品
  301. hasNoBindPro() {
  302. let noBindPro = null;
  303. for (let i = 0; i < this.placeTab.length; i++) {
  304. noBindPro = this.shelfPlaceList[this.placeTab[i]].find(item => item.shelfProductApiEntity && item
  305. .shelfProductApiEntity.productSn);
  306. if (!!noBindPro) {
  307. break
  308. }
  309. }
  310. return !!noBindPro
  311. },
  312. // 按照产品搜索货位
  313. toSearchHw() {
  314. if (this.hasNoBindPro()) {
  315. uni.navigateTo({
  316. url: "/pages/shelfSetting/searchShelfHw?shelfName=" + this.detailData.shelfName +
  317. "&shelfSn=" + this.shelfSn
  318. })
  319. } else {
  320. uni.showModal({
  321. showCancel: false,
  322. confirmText: "好的",
  323. title: "提示",
  324. content: "所有货位都没有绑定产品,无法搜索!"
  325. })
  326. }
  327. },
  328. // 编辑货位
  329. editHw(item) {
  330. const hasProduct = item.shelfProductApiEntity && item.shelfProductApiEntity.productSn
  331. const type = hasProduct ? 'edit' : 'bind'
  332. const params = Object.assign(this.detailData, item)
  333. this.$store.state.vuex_tempData = params
  334. uni.navigateTo({
  335. url: "/pages/shelfSetting/editShelfHw?type=" + type
  336. })
  337. },
  338. // 新增货位
  339. addHw(type, flag) {
  340. let shelfPlaceCode = ''
  341. if (type == 'edit') {
  342. shelfPlaceCode = flag
  343. }
  344. if (type == 'add' && flag == 1) {
  345. const row = this.shelfPlaceList[this.curTab]
  346. const num = row[row.length - 1].shelfPlaceCode.replace(this.curTab, '')
  347. const nextNum = Number(num) + 1
  348. shelfPlaceCode = this.curTab + (nextNum < 10 ? '0' : '') + nextNum
  349. }
  350. const params = {
  351. customerSn: this.detailData.customerSn,
  352. shelfSn: this.detailData.shelfSn,
  353. id: this.detailData.id
  354. }
  355. uni.navigateTo({
  356. url: "/pages/shelfSetting/addShelfHw?detailData=" + encodeURIComponent(JSON.stringify(
  357. params)) + "&type=" + type + "&shelfPlaceCode=" + shelfPlaceCode
  358. })
  359. },
  360. // 保存数字货架基本信息
  361. saveShelf(data, type) {
  362. const params = {
  363. shelfSn: this.shelfSn
  364. }
  365. if (type == 1) {
  366. params.customerSn = this.detailData.customerSn
  367. params.shelfName = data.shelfName
  368. } else {
  369. params.customerSn = data.customerSn
  370. }
  371. shelfSave(params).then(res => {
  372. if (res.status == 200) {
  373. this.toashMsg(res.message)
  374. this.getShelfDetal()
  375. }
  376. })
  377. },
  378. // 获取价格显示设置
  379. getShelfPriceShow() {
  380. this.showPrice = []
  381. this.showPriceStr = []
  382. getShelfPriceShow({
  383. shelfSn: this.shelfSn
  384. }).then(res => {
  385. if (res.status == 200) {
  386. const ret = res.data && res.data
  387. ret.map(item => {
  388. if (item.paramCode == 'shelf_price_show' && item.paramValue == 1) {
  389. this.showPriceStr.push("车主价")
  390. }
  391. if (item.paramCode == 'shelf_cost_show' && item.paramValue == 1) {
  392. this.showPriceStr.push("结算价")
  393. }
  394. this.showPrice.push({
  395. paramCode: item.paramCode,
  396. paramValue: item.paramValue,
  397. text: item.paramCode == 'shelf_price_show' ? '车主价' : '结算价',
  398. checked: item.paramValue == 1
  399. })
  400. })
  401. }
  402. })
  403. },
  404. // 选择价格显示
  405. priceSetChange(e) {
  406. console.log(e)
  407. this.showPrice.map(item => {
  408. item.paramValue = e.includes(item.paramCode) ? 1 : 0
  409. })
  410. },
  411. // 价格显示保存
  412. savePriceSet() {
  413. uni.showLoading({
  414. mask: true,
  415. title: '正在保存价格设置...'
  416. })
  417. // 更新价格显示
  418. updateShelfPriceShow({
  419. shelfSn: this.shelfSn,
  420. paramValue: this.showPrice
  421. }).then(res => {
  422. if (res.status == 200) {
  423. this.getShelfPriceShow()
  424. this.toashMsg(res.message)
  425. }
  426. uni.hideLoading()
  427. })
  428. },
  429. getShelfDetal() {
  430. shelfDetail({
  431. sn: this.shelfSn
  432. }).then(res => {
  433. if (res.status == 200) {
  434. this.detailData = res.data
  435. this.switchVal = res.data.finishFlag == 1
  436. // 价格设置
  437. this.getShelfPriceShow()
  438. } else {
  439. this.detailData = null
  440. }
  441. })
  442. },
  443. getShelfPlace(flag) {
  444. this.loading = true
  445. getProductPlace({
  446. shelfSn: this.shelfSn
  447. }).then(res => {
  448. if (res.status == 200 && res.data) {
  449. this.shelfPlaceList = res.data
  450. // 获取层
  451. for (let a in res.data) {
  452. this.placeTab.push(a)
  453. }
  454. // 排序
  455. this.placeTab.sort(function(a, b) {
  456. return (a + '').localeCompare(b + '');
  457. });
  458. console.log(this.placeTab)
  459. if (!flag || !this.curTab) {
  460. this.curTab = this.placeTab[0]
  461. }
  462. if (this.placeTab.length == 0) {
  463. this.shelfPlaceList = null
  464. }
  465. } else {
  466. this.shelfPlaceList = null
  467. this.placeTab = []
  468. }
  469. // 是否有已录入的产品
  470. this.getHasCartNotEmpty()
  471. this.isLoad = false
  472. this.loading = false
  473. })
  474. },
  475. tabChange(item) {
  476. this.curTab = item
  477. },
  478. getHasCartNotEmpty() {
  479. shelfCartNotEmpty({
  480. shelfSn: this.shelfSn
  481. }).then(res => {
  482. this.showDot = res.data == 1
  483. })
  484. }
  485. }
  486. }
  487. </script>
  488. <style lang="less">
  489. .content {
  490. width: 100%;
  491. .nodata {
  492. padding: 100rpx 50rpx;
  493. text-align: center;
  494. display: flex;
  495. flex-direction: column;
  496. justify-content: center;
  497. align-items: center;
  498. >view {
  499. position: relative;
  500. padding: 10upx 0;
  501. text {
  502. color: #00aaff;
  503. margin-left: 10rpx;
  504. }
  505. }
  506. }
  507. .body-content {
  508. width: 100%;
  509. }
  510. .card-box {
  511. background-color: #fff;
  512. border-radius: 0.5rem;
  513. box-shadow: 0.1rem 0.2rem 0.3rem #eee;
  514. padding: 0 1rem;
  515. margin: 0.5rem;
  516. .card-row {
  517. border-bottom: 1rpx solid #eee;
  518. padding: 20rpx 0;
  519. min-height: 90rpx;
  520. &:last-child {
  521. border-bottom: 0;
  522. }
  523. .label {
  524. flex: 1;
  525. width: 20%;
  526. }
  527. .text {
  528. width: 80%;
  529. color: #666;
  530. }
  531. }
  532. .moreSeting {
  533. text-align: center;
  534. color: #999;
  535. padding: 20upx;
  536. >text {
  537. margin-right: 10rpx;
  538. }
  539. }
  540. }
  541. .shelfPlace {
  542. height: calc(100% - 300rpx);
  543. .shelfPlaceHead {
  544. padding: 0.2rem 0.5rem 0.5rem;
  545. justify-content: space-between;
  546. .lt {
  547. font-size: 0.9rem;
  548. color: #999;
  549. text {
  550. color: #ff5500;
  551. font-size: 1rem;
  552. }
  553. }
  554. .search-btn {
  555. border: 1rpx solid #eee;
  556. border-radius: 50rpx;
  557. width: 50%;
  558. justify-content: space-between;
  559. padding: 0.3rem 0.5rem;
  560. color: #999;
  561. background-color: #fff;
  562. font-size: 0.9rem;
  563. &:active {
  564. opacity: 0.6;
  565. }
  566. }
  567. }
  568. .shelfTabs {
  569. height: calc(100% - 85rpx);
  570. .leftTabs {
  571. width: 20%;
  572. overflow: auto;
  573. >view {
  574. padding: 0.8rem 0.5rem;
  575. border-left: 0.2rem solid #f8f8f8;
  576. text-align: center;
  577. }
  578. .active {
  579. border-color: rgb(47, 126, 209);
  580. background-color: #fff;
  581. }
  582. }
  583. .rightCons {
  584. width: 80%;
  585. background-color: #fff;
  586. position: relative;
  587. .hwList {
  588. overflow: auto;
  589. padding: 0.5rem;
  590. padding-bottom: 105rpx;
  591. >text {
  592. border: 1rpx solid #eee;
  593. padding: 0.2rem 0.8rem;
  594. border-radius: 0.3rem;
  595. margin: 0.5rem 2%;
  596. float: left;
  597. width: 20%;
  598. text-align: center;
  599. }
  600. .red {
  601. border-color: #ff5500;
  602. }
  603. .add {
  604. border-style: dashed;
  605. border-color: #999;
  606. color: #999;
  607. }
  608. }
  609. .hwAction {
  610. padding: 0.5rem;
  611. position: fixed;
  612. bottom: 0;
  613. right: 0;
  614. width: 80%;
  615. background-color: #fff;
  616. button {
  617. width: 240rpx;
  618. }
  619. .newbtn {
  620. background-color: rgb(51, 95, 182);
  621. color: #fff;
  622. }
  623. }
  624. }
  625. }
  626. }
  627. }
  628. </style>