shelfSet.vue 17 KB

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