product.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <template>
  2. <!-- #ifdef H5 -->
  3. <zj-page-layout :hasFooter="true">
  4. <template slot="header">
  5. <view class="search-container">
  6. <u-search
  7. shape="round"
  8. :showAction="false"
  9. placeholder="输入分类名称进行搜索"
  10. v-model="keyword"
  11. @search="searchData"
  12. @clear="searchData"
  13. >
  14. </u-search>
  15. </view>
  16. </template>
  17. <view class="main-container">
  18. <view class="left-list" v-if="type == 'M'">
  19. <block v-for="(item, index) in leftList" :key="index">
  20. <view
  21. class="item ellipsis"
  22. :class="leftCurrent == item.categoryId ? 'current' : ''"
  23. @tap="changeLeft(item.categoryId)"
  24. >{{ item.categoryName }}</view
  25. >
  26. </block>
  27. </view>
  28. <view class="right-list">
  29. <scroll-view scroll-y style="height: 100%">
  30. <view class="item" v-for="(item, index) in rightList" :key="index" @click="selectId = item.goodsCode">
  31. <view class="name">{{ item.goodsName }}</view>
  32. <view class="text">代码:{{ item.goodsCode }}</view>
  33. <view class="bottom">
  34. <view class="price"
  35. >¥{{ item.goodsAmount | priceFilter }}<text>/{{ item.goodsUnit }}</text></view
  36. >
  37. <view
  38. :style="`width: 50rpx; height: 50rpx; border-radius: 50%;background: ${
  39. selectId == item.goodsCode ? '#0379FF' : '#ebebeb'
  40. };display: flex;justify-content: center;align-items: center;color:#fff`"
  41. ><text>✔</text></view
  42. >
  43. </view>
  44. </view>
  45. <Loading :type="2" :loadStatus="loadStatus" :dataList="rightList" v-if="type == 'M'" />
  46. <view class="empty-container" v-if="type == 'P' && rightList.length < 1">
  47. <image src="@/packageMaterial/static/empty.jpg" mode="widthFix"></image>
  48. <view class="title">该产品大类下暂无可售配件商品</view>
  49. <view class="text">请联系网点在后台“辅材配件”-“配件资料管理”维护配件商品收费标准,再操作!</view>
  50. </view>
  51. </scroll-view>
  52. </view>
  53. </view>
  54. <template slot="footer">
  55. <view class="bottom-container">
  56. <u-button type="primary" text="保存" @click="submitData"></u-button>
  57. </view>
  58. </template>
  59. </zj-page-layout>
  60. <!-- #endif -->
  61. <!-- #ifndef H5 -->
  62. <web-view
  63. :src="webViewHref(`/packageMaterial/pages/sale/product`, pam, crossPagePam)"
  64. @message="crossPage.$listener"
  65. ></web-view>
  66. <!-- #endif -->
  67. </template>
  68. <script>
  69. // #ifdef H5
  70. export default {
  71. data() {
  72. return {
  73. type: 'M',
  74. userMobile: '',
  75. orderNo: '',
  76. salesType: 'OUT',
  77. brandId: null,
  78. brandName: null,
  79. categoryId: null,
  80. categoryName: null,
  81. wbId: null, // 维保工单
  82. wbIsAllFee: null, // 维保工单是否包含全部费用
  83. wbPayType: null, // 维保工单费用支付方式
  84. keyword: '',
  85. leftList: [],
  86. leftCurrent: 0,
  87. rightList: [],
  88. loadStatus: 0,
  89. cartList: [],
  90. selectId: "",
  91. dijiIndex: 0
  92. }
  93. },
  94. onLoad({dijiIndex, type, userMobile, orderNo, salesType, brandId, brandName, categoryId, categoryName, websitId, websitName, wbId, wbIsAllFee, wbPayType}) {
  95. this.dijiIndex = dijiIndex;
  96. this.type = type;
  97. this.userMobile = userMobile;
  98. this.orderNo = orderNo;
  99. // this.salesType = salesType;
  100. // this.brandId = brandId;
  101. // this.brandName = brandName;
  102. this.categoryId = categoryId;
  103. this.categoryName = categoryName;
  104. this.websitId = websitId;
  105. this.websitName = websitName;
  106. this.wbId = wbId;
  107. this.wbIsAllFee = wbIsAllFee;
  108. this.wbPayType = wbPayType;
  109. uni.setNavigationBarTitle({
  110.  title: type == 'M' ? '选择辅材' : '选择配件'
  111. })
  112. if(type === 'M') {
  113. this.getLeftList();
  114. }else {
  115. this.getRightList();
  116. }
  117. },
  118. methods: {
  119. // 获取左侧分类
  120. getLeftList() {
  121. this.$api.post('/pay/websitCategoryList', {
  122. pageNum: 1,
  123. pageSize: -1,
  124. }).then(res => {
  125. this.leftList = res.data.records;
  126. this.leftCurrent = res.data.records.length > 0 ? res.data.records[0].categoryId : 0;
  127. this.getRightList();
  128. })
  129. },
  130. // 获取右侧产品
  131. getRightList() {
  132. this.loadStatus = 1;
  133. let url = '', params = {};
  134. if(this.type === 'M') {
  135. url = '/pay/chargeList';
  136. params = {
  137. categoryId: this.leftCurrent,
  138. orderId: this.orderNo,
  139. }
  140. }else {
  141. url = '/pay/websitGoodsList';
  142. params = {
  143. categoryName: this.categoryName,
  144. brand: this.brandName,
  145. orderId: this.orderNo,
  146. // normType: 'M'
  147. }
  148. }
  149. this.$api.post(url, {
  150. pageNum: 1,
  151. pageSize: -1,
  152. name: this.keyword,
  153. ...params
  154. }).then(res => {
  155. this.loadStatus = 0;
  156. let list = res.data.records.map(item => {
  157. return this.type === 'M' ? {
  158. goodsId: item.normId,
  159. goodsName: item.normName,
  160. goodsCode: item.normCode,
  161. goodsUnit: item.unit,
  162. goodsAmount: item.normAmount,
  163. num: 0
  164. } : {
  165. goodsId: item.goodsId,
  166. goodsName: item.goodsName,
  167. goodsCode: item.goodsCode,
  168. goodsUnit: item.goodsSalesUnit,
  169. goodsAmount: item.normAmount,
  170. normType: item.normType,
  171. num: 0
  172. }
  173. });
  174. for(let i = 0; i < list.length; i++) {
  175. for(let j = 0; j < this.cartList.length; j++) {
  176. if(list[i].goodsId == this.cartList[j].goodsId) {
  177. list[i].num = this.cartList[j].num;
  178. }
  179. }
  180. }
  181. if(list.length < 1){
  182. this.loadStatus = 2;
  183. }
  184. this.rightList = list;
  185. }).catch(() => {
  186. this.loadStatus = 2;
  187. })
  188. },
  189. // 切换一级菜单
  190. changeLeft(pid) {
  191. this.leftCurrent = pid;
  192. this.getRightList();
  193. },
  194. // 搜索
  195. searchData() {
  196. this.getRightList();
  197. },
  198. changeNum(e) {
  199. let obj = this.rightList.find((item) => item.goodsId === e.name);
  200. if(e.unit && e.unit != '米') {
  201. e.value = Math.floor(e.value);
  202. obj.num = Math.floor(obj.num);
  203. }
  204. // 判断对象数组中是否存在该对象
  205. let index = this.cartList.findIndex((item) => item.goodsId === obj.goodsId);
  206. // 如果是0,就删除
  207. if(index !== -1 && e.value == 0) {
  208. this.cartList.splice(index, 1);
  209. }
  210. // 如果有就替换,没有就添加
  211. else if (index !== -1) {
  212. this.cartList.splice(index, 1, obj);
  213. }
  214. else {
  215. if(e.value > 0) {
  216. this.cartList.push(obj);
  217. }
  218. }
  219. },
  220. changeCartNum(e) {
  221. let obj = this.cartList.find((item) => item.goodsId === e.name);
  222. if(e.unit && e.unit != '米') {
  223. e.value = Math.floor(e.value);
  224. obj.num = Math.floor(obj.num);
  225. }
  226. let index = this.cartList.findIndex((item) => item.goodsId === obj.goodsId);
  227. this.cartList.splice(index, 1, obj);
  228. this.getRightList();
  229. },
  230. overlimitFun(index) {
  231. this.$modal({
  232. content: '把该产品从购物车移除?'
  233. }).then(() => {
  234. this.cartList.splice(index, 1);
  235. this.getRightList();
  236. }).catch(() => {})
  237. },
  238. clearCart() {
  239. this.$modal({
  240. content: '确定清空购物车?'
  241. }).then(() => {
  242. this.cartList = [];
  243. this.getRightList();
  244. }).catch(() => {})
  245. },
  246. submitData() {
  247. var data = this.rightList.find(item => item.goodsCode == this.selectId)
  248. if (data) {
  249. this.$setStorage('materialSaleData', {...data, dijiIndex: this.dijiIndex});
  250. this.$navToPage({
  251. delta: 1
  252. },"navigateBack")
  253. } else {
  254. this.$toast('请选择');
  255. }
  256. },
  257. },
  258. }
  259. // #endif
  260. // #ifndef H5
  261. export default {
  262. data() {
  263. return {
  264. pam: {},
  265. }
  266. },
  267. onLoad(pam) {
  268. this.pam = pam;
  269. }
  270. }
  271. // #endif
  272. </script>
  273. <style lang="scss" scoped>
  274. .search-container {
  275. background: #ffffff;
  276. padding: 0 20rpx 20rpx;
  277. ::v-deep .u-search {
  278. height: 60rpx;
  279. input {
  280. background: #f7f8ff !important;
  281. }
  282. .u-search__content {
  283. background: #f7f8ff !important;
  284. height: 60rpx;
  285. }
  286. }
  287. }
  288. .empty-container {
  289. height: 100%;
  290. background: #ffffff;
  291. display: flex;
  292. flex-direction: column;
  293. align-items: center;
  294. padding: 0 100rpx;
  295. image {
  296. width: 300rpx;
  297. margin-top: 100rpx;
  298. }
  299. .title {
  300. font-size: 32rpx;
  301. }
  302. .text {
  303. margin-top: 20rpx;
  304. font-size: 28rpx;
  305. line-height: 32rpx;
  306. color: $sec-font;
  307. text-align: center;
  308. }
  309. }
  310. .main-container {
  311. display: flex;
  312. height: 100%;
  313. .left-list {
  314. width: 220rpx;
  315. height: 100%;
  316. overflow-y: scroll;
  317. box-sizing: border-box;
  318. flex-shrink: 0;
  319. .item {
  320. font-size: 28rpx;
  321. color: #333333;
  322. height: 88rpx;
  323. display: flex;
  324. align-items: center;
  325. padding: 0 20rpx;
  326. &.current {
  327. color: #ffffff;
  328. background: $theme-color;
  329. }
  330. }
  331. }
  332. .right-list {
  333. flex: 1;
  334. background: #ffffff;
  335. background: #ffffff;
  336. height: 100%;
  337. box-sizing: border-box;
  338. .item {
  339. padding: 20rpx;
  340. border-bottom: 1px solid #f5f5f5;
  341. .name {
  342. font-size: 32rpx;
  343. font-weight: 500;
  344. }
  345. .text {
  346. font-size: 28rpx;
  347. color: $sec-font;
  348. margin-top: 12rpx;
  349. }
  350. .bottom {
  351. display: flex;
  352. align-items: center;
  353. justify-content: space-between;
  354. margin-top: 12rpx;
  355. .price {
  356. font-size: 28rpx;
  357. font-weight: 500;
  358. color: $minor-color;
  359. text {
  360. font-weight: normal;
  361. color: $sec-font;
  362. margin-left: 8rpx;
  363. }
  364. }
  365. .input {
  366. width: 50rpx;
  367. text-align: center;
  368. padding: 0 10px;
  369. }
  370. .ctrl {
  371. width: 40rpx;
  372. height: 40rpx;
  373. background-color: $theme-color;
  374. border-radius: 50%;
  375. display: flex;
  376. justify-content: center;
  377. align-items: center;
  378. }
  379. }
  380. }
  381. }
  382. }
  383. .bottom-container {
  384. display: flex;
  385. align-items: center;
  386. padding: 20rpx;
  387. .cart {
  388. flex-shrink: 0;
  389. width: 110rpx;
  390. height: 110rpx;
  391. border-radius: 50%;
  392. background: $theme-color;
  393. position: relative;
  394. display: flex;
  395. align-items: center;
  396. justify-content: center;
  397. margin-top: -40rpx;
  398. .iconfont {
  399. font-size: 52rpx;
  400. color: #ffffff;
  401. font-weight: 600;
  402. }
  403. }
  404. .price {
  405. margin-left: 20rpx;
  406. flex: 1;
  407. font-size: 32rpx;
  408. color: $minor-color;
  409. font-weight: 500;
  410. text {
  411. font-weight: normal;
  412. color: $sec-font;
  413. }
  414. }
  415. .btn {
  416. width: 180rpx;
  417. // ::v-deep .u-button {
  418. // height: 60rpx;
  419. // }
  420. }
  421. }
  422. .dialog-mark {
  423. position: fixed;
  424. top: 0;
  425. left: 0;
  426. width: 100%;
  427. height: 100%;
  428. background: rgba($color: #000000, $alpha: 0.6);
  429. }
  430. .dialog-container {
  431. width: 100%;
  432. box-sizing: border-box;
  433. background: #ffffff;
  434. position: fixed;
  435. bottom: 100rpx;
  436. left: 0;
  437. padding: 30rpx;
  438. .top {
  439. display: flex;
  440. align-items: center;
  441. justify-content: space-between;
  442. .left {
  443. font-size: 32rpx;
  444. font-weight: 500;
  445. }
  446. .right {
  447. display: flex;
  448. align-items: center;
  449. font-size: 28rpx;
  450. color: $sec-font;
  451. text {
  452. font-size: 32rpx;
  453. margin-right: 8rpx;
  454. }
  455. }
  456. }
  457. .list {
  458. max-height: 400rpx;
  459. overflow-y: scroll;
  460. margin-top: 20rpx;
  461. .item {
  462. padding: 20rpx 0;
  463. border-bottom: 1px solid #f5f5f5;
  464. &:last-child {
  465. border: none;
  466. }
  467. .name {
  468. font-size: 32rpx;
  469. font-weight: 500;
  470. }
  471. .text {
  472. font-size: 28rpx;
  473. color: $sec-font;
  474. margin-top: 12rpx;
  475. }
  476. .bottom {
  477. display: flex;
  478. align-items: center;
  479. justify-content: space-between;
  480. margin-top: 12rpx;
  481. .price {
  482. font-size: 28rpx;
  483. font-weight: 500;
  484. color: $minor-color;
  485. text {
  486. font-weight: normal;
  487. color: $sec-font;
  488. margin-left: 8rpx;
  489. }
  490. }
  491. .input {
  492. width: 50rpx;
  493. text-align: center;
  494. padding: 0 10px;
  495. }
  496. .ctrl {
  497. width: 40rpx;
  498. height: 40rpx;
  499. background-color: $theme-color;
  500. border-radius: 50%;
  501. display: flex;
  502. justify-content: center;
  503. align-items: center;
  504. }
  505. }
  506. }
  507. }
  508. }
  509. </style>