shelfSet.vue 17 KB

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