goodslist.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. <template>
  2. <base-page>
  3. <view class="goodslist">
  4. <view class="screen-warp common-form">
  5. <view class="common-form-item">
  6. <view class="form-inline">
  7. <label class="form-label">商品名称</label>
  8. <view class="form-input-inline"><input type="text" v-model="option.search_text" placeholder="请输入商品名称" class="form-input" /></view>
  9. </view>
  10. <view class="form-inline">
  11. <label class="form-label">商品编码</label>
  12. <view class="form-input-inline"><input type="text" v-model="option.sku_no" placeholder="请输入商品编码" class="form-input" /></view>
  13. </view>
  14. <view class="form-inline">
  15. <label class="form-label">商品类型</label>
  16. <view class="form-input-inline">
  17. <select-lay :zindex="10" :value="goods_class" name="names" placeholder="请选择商品类型" :options="goodsClass" @selectitem="selectClass"></select-lay>
  18. </view>
  19. </view>
  20. <view class="form-inline">
  21. <label class="form-label">商品状态</label>
  22. <view class="form-input-inline">
  23. <select-lay :zindex="10" :value="status" name="names" placeholder="请选择商品状态" :options="statusList" @selectitem="selectStatus"></select-lay>
  24. </view>
  25. </view>
  26. <view class="form-inline">
  27. <label class="form-label">商品价格</label>
  28. <view class="form-input-inline input-append">
  29. <input type="text" v-model="option.start_price" placeholder="最低价格" class="form-input" />
  30. <view class="unit">元</view>
  31. </view>
  32. <view class="form-input-inline split-wrap">-</view>
  33. <view class="form-input-inline input-append">
  34. <input type="text" v-model="option.end_price" placeholder="最高价格" class="form-input" />
  35. <view class="unit">元</view>
  36. </view>
  37. </view>
  38. <view class="form-inline common-btn-wrap">
  39. <button type="default" class="screen-btn" @click="searchFn()">筛选</button>
  40. <button type="default" @click="resetFn()">重置</button>
  41. </view>
  42. </view>
  43. </view>
  44. <uniDataTable url="/cashier/storeapi/goods/page" :option="option" :cols="cols" ref="goodsListTable">
  45. <template v-slot:action="dataTable">
  46. <view class="action-btn-wrap">
  47. <text class="action-item" @click="getDetail(dataTable.value.goods_id)">详情</text>
  48. <text
  49. class="action-item"
  50. v-if="dataTable.value.store_status == 0 || dataTable.value.store_status == null"
  51. @click="goodsStatus(dataTable.value.goods_id, 1)"
  52. >
  53. 上架
  54. </text>
  55. <text class="action-item" v-else @click="goodsStatus(dataTable.value.goods_id, 0)">下架</text>
  56. <text
  57. class="action-item"
  58. @click="goodsSku(dataTable.value.goods_id)"
  59. v-if="(storeInfo && storeInfo.stock_type == 'store') || dataTable.value.is_unify_price != 1"
  60. >
  61. 价格库存
  62. </text>
  63. <text
  64. class="action-item"
  65. @click="recordopen(dataTable.value.goods_id)"
  66. v-if="dataTable.value.is_virtual != 1 && storeInfo && storeInfo.stock_type == 'store'"
  67. >
  68. 库存记录
  69. </text>
  70. </view>
  71. </template>
  72. <template v-slot:batchaction="dataTable">
  73. <text class="batch-item" @click="goodsStatus(dataTable, 1)">批量上架</text>
  74. <text class="batch-item" @click="goodsStatus(dataTable, 0)">批量下架</text>
  75. </template>
  76. </uniDataTable>
  77. <unipopup ref="goodsDetail" type="center">
  78. <view class="goods-detail-wrap">
  79. <view class="detail-head">
  80. 商品详情
  81. <text class="iconfont iconguanbi1" @click="$refs.goodsDetail.close()"></text>
  82. </view>
  83. <view class="detail-body">
  84. <block v-if="JSON.stringify(goods_detail) != '{}'">
  85. <view class="title">基本信息</view>
  86. <view class="information-box">
  87. <view class="box-left">
  88. <view class="information">
  89. <view>商品名称:</view>
  90. <view>{{ goods_detail.goods_name }}</view>
  91. </view>
  92. <view class="information" v-if="goods_detail.introduction">
  93. <view>促销语:</view>
  94. <view>{{ goods_detail.introduction }}</view>
  95. </view>
  96. <view class="information">
  97. <view>商品类型:</view>
  98. <view>{{ goods_detail.goods_class_name }}</view>
  99. </view>
  100. <view class="information" v-if="goods_detail.brand_name">
  101. <view>商品品牌:</view>
  102. <view>{{ goods_detail.brand_name }}</view>
  103. </view>
  104. <view class="information" v-if="goods_detail.unit">
  105. <view>单位:</view>
  106. <view>{{ goods_detail.unit }}</view>
  107. </view>
  108. <view class="information">
  109. <view>商品状态:</view>
  110. <view>{{ goods_detail.store_status == 0 || goods_detail.store_status == null ? '仓库中' : '已上架' }}</view>
  111. </view>
  112. </view>
  113. <!-- <image class="goods-img" :src="$util.img(goods_detail.goods_image.split(',')[0], {'size':'big'})" mode="aspectFit" @error="goodsImageError(goods_detail)"></image> -->
  114. </view>
  115. <block v-if="goods_detail.sku_list.length > 1">
  116. <view class="title title2">价格库存</view>
  117. <view class="table">
  118. <view class="table-th table-all">
  119. <view class="table-td" style="width:25%">商品规格</view>
  120. <block v-if="goods_detail.is_unify_price"><view class="table-td" style="width:30%">销售价格</view></block>
  121. <block v-else>
  122. <view class="table-td" style="width:15%">统一价格</view>
  123. <view class="table-td" style="width:15%">独立价格</view>
  124. </block>
  125. <view class="table-td" style="width:20%;">商品编码</view>
  126. <view class="table-td" style="width:10%;">商品库存</view>
  127. </view>
  128. <scroll-view class="table-tb" scroll-y="true">
  129. <view class="table-tr table-all" v-for="(item, index) in goods_detail.sku_list" :key="index">
  130. <view class="table-td" style="width:25%">{{ item.spec_name }}</view>
  131. <block v-if="goods_detail.is_unify_price">
  132. <view class="table-td" style="width:30%">¥{{ item.discount_price }}</view>
  133. </block>
  134. <block v-else>
  135. <view class="table-td" style="width:15%">¥{{ item.discount_price }}</view>
  136. <view class="table-td" style="width:15%">¥{{ item.store_price }}</view>
  137. </block>
  138. <view class="table-td" style="width:20%;">{{ item.sku_no }}</view>
  139. <view class="table-td" style="width:10%;">{{ item.stock }}</view>
  140. </view>
  141. </scroll-view>
  142. </view>
  143. </block>
  144. <block v-else>
  145. <view class="title title2">规格详情</view>
  146. <view class="table">
  147. <view class="single-specification">
  148. <view class="item">
  149. <view class="name">商品售价:</view>
  150. <view class="message" v-if="goods_detail.is_unify_price == 1 || goods_detail.sku_list[0].store_price == null">
  151. ¥{{ goods_detail.sku_list[0].discount_price }}
  152. </view>
  153. <view class="message" v-else>{{ goods_detail.sku_list[0].store_price }}</view>
  154. </view>
  155. <view class="item">
  156. <view class="name">商品编码:</view>
  157. <view class="message">{{ goods_detail.sku_list[0].sku_no ? goods_detail.sku_list[0].sku_no : '无' }}</view>
  158. </view>
  159. <view class="item">
  160. <view class="name">商品库存:</view>
  161. <view class="message">{{ goods_detail.sku_list[0].stock || 0 }}</view>
  162. </view>
  163. </view>
  164. </view>
  165. </block>
  166. </block>
  167. <block v-else><image class="cart-empty" :src="$util.img('public/uniapp/cashier/cart_empty.png')" mode="widthFix"></image></block>
  168. </view>
  169. </view>
  170. </unipopup>
  171. <unipopup ref="goodssku" type="center">
  172. <view class="record-body">
  173. <nsgoodssku
  174. v-if="sku_list.length"
  175. @close="close('goodssku')"
  176. :goods_id="goodsId"
  177. :is_unify_price="goods_detail.is_unify_price"
  178. :sku_list="sku_list"
  179. ></nsgoodssku>
  180. </view>
  181. </unipopup>
  182. <unipopup ref="record" type="center">
  183. <view class="record-body"><nsrecord @close="close" :goods_id="goodsId" :sku_list="sku_list"></nsrecord></view>
  184. </unipopup>
  185. </view>
  186. </base-page>
  187. </template>
  188. <script>
  189. import nsExwarehouse from '@/components/ns-exwarehouse/ns-exwarehouse.vue';
  190. import nsrecord from '@/components/ns-record/ns-record.vue';
  191. import nsgoodssku from '@/components/ns-goods-sku/ns-goods-sku.vue';
  192. import uniDataTable from '@/components/uni-data-table/uni-data-table.vue';
  193. import unipopup from '@/components/uni-popup/uni-popup.vue';
  194. export default {
  195. components: { nsExwarehouse, unipopup, nsrecord, nsgoodssku, uniDataTable },
  196. data() {
  197. return {
  198. //选中的商品下标
  199. selectGoodsKeys: 0,
  200. // 初始是请求第几页
  201. page: 1,
  202. // 每次返回数据数
  203. page_size: 20,
  204. //商品列表数据
  205. goods_list: [],
  206. // 第一次请求列表做详情渲染判断
  207. one_judge: true,
  208. //商品详情数据
  209. goods_detail: {},
  210. //获取文档数据
  211. documentTypeList: [],
  212. // 弹窗中所需要获取到的sku列表数据
  213. sku_list: [],
  214. //入库出库
  215. keys: 'input',
  216. goodsClass: [
  217. {
  218. value: 1,
  219. label: '实物商品'
  220. },
  221. {
  222. value: 4,
  223. label: '服务项目'
  224. },
  225. {
  226. value: 5,
  227. label: '卡项套餐'
  228. }
  229. ],
  230. statusList: [
  231. {
  232. value: 1,
  233. label: '仓库中'
  234. },
  235. {
  236. value: 2,
  237. label: '销售中'
  238. }
  239. ],
  240. currGoodsClass: 'all',
  241. store: null,
  242. timeout: '', //节流,关闭定时器
  243. cols: [
  244. {
  245. width: 6,
  246. align: 'center',
  247. checkbox: true
  248. },
  249. {
  250. field: 'account_data',
  251. width: 20,
  252. title: '商品信息',
  253. align: 'left',
  254. templet: data => {
  255. let img = this.$util.img(data.goods_image);
  256. let html = `
  257. <view class="goods-content">
  258. <image class="goods-img" src="${img}" mode="aspectFit"></image>
  259. <text class="goods-name multi-hidden">${data.goods_name}</text>
  260. </view>
  261. `;
  262. return html;
  263. }
  264. },
  265. {
  266. width: 14,
  267. title: '商品类型',
  268. align: 'center',
  269. field: 'goods_class_name'
  270. },
  271. {
  272. width: 10,
  273. title: '价格',
  274. align: 'center',
  275. templet: function(data) {
  276. return '¥' + data.discount_price;
  277. }
  278. },
  279. {
  280. field: 'stock',
  281. width: 15,
  282. title: '库存',
  283. align: 'center'
  284. },
  285. {
  286. width: 15,
  287. title: '售卖模式',
  288. templet: data => {
  289. return (this.storeInfo.stock_type == 'store' ? '独立库存' : '统一库存') + ' | ' + (data.is_unify_price ? '统一设价' : '独立设价');
  290. }
  291. },
  292. {
  293. width: 15,
  294. title: '状态',
  295. align: 'center',
  296. templet: function(data) {
  297. var str = '';
  298. if (data.store_status == 1) {
  299. str = '销售中';
  300. } else if (data.store_status == 0) {
  301. str = '仓库中';
  302. }
  303. return str;
  304. }
  305. },
  306. {
  307. width: 20,
  308. title: '操作',
  309. align: 'left',
  310. action: true
  311. }
  312. ],
  313. option: {
  314. page_size: 9,
  315. search_text: '',
  316. sku_no: '',
  317. goods_class: 'all',
  318. status: 'all',
  319. start_price: '',
  320. end_price: ''
  321. },
  322. status: '',
  323. goods_class: '',
  324. goodsId: ''
  325. };
  326. },
  327. onLoad() {
  328. this.store = uni.getStorageSync('store_info');
  329. },
  330. methods: {
  331. selectClass(index) {
  332. this.goods_class = index == -1 ? '' : this.goodsClass[index].value.toString();
  333. },
  334. selectStatus(index) {
  335. this.status = index == -1 ? '' : this.statusList[index].value.toString();
  336. },
  337. // 搜索商品
  338. searchFn() {
  339. this.option.status = (this.status == 1 && 0) || (this.status == 2 && 1) || (!this.status ? 'all' : '');
  340. this.option.goods_class = this.goods_class ? this.goods_class : 'all';
  341. this.$refs.goodsListTable.load({ page: 1 });
  342. },
  343. resetFn() {
  344. this.status = '';
  345. this.goods_class = '';
  346. this.option.status = 'all';
  347. this.option.goods_class = 'all';
  348. this.option.search_text = '';
  349. this.option.sku_no = '';
  350. this.option.start_price = '';
  351. this.option.end_price = '';
  352. this.$refs.goodsListTable.load({ page: 1 });
  353. },
  354. // 查询商品详情
  355. getDetail(id, type = '') {
  356. uni.showLoading({
  357. title: '加载中'
  358. });
  359. this.goods_detail = {};
  360. this.$api.sendRequest({
  361. url: '/cashier/storeapi/goods/detail',
  362. data: {
  363. goods_id: id
  364. },
  365. success: res => {
  366. if (res.code >= 0) {
  367. this.goods_detail = res.data;
  368. this.goods_detail.sku_list[0].goods_name = this.goods_detail.goods_name;
  369. this.sku_list = this.goods_detail.sku_list;
  370. if (!type) this.$refs.goodsDetail.open();
  371. }
  372. uni.hideLoading();
  373. }
  374. });
  375. },
  376. goodsStatus(id, status) {
  377. let arr;
  378. if (typeof id == 'object') {
  379. arr = [];
  380. id.value.length &&
  381. id.value.forEach((item, index) => {
  382. arr.push(item.goods_id);
  383. });
  384. if (!arr.length) {
  385. this.$util.showToast({
  386. title: '请选择要操作的数据'
  387. });
  388. return false;
  389. }
  390. } else arr = id;
  391. this.$api.sendRequest({
  392. url: '/cashier/storeapi/goods/setstatus',
  393. data: {
  394. goods_id: arr.toString(),
  395. status: status
  396. },
  397. success: res => {
  398. this.$util.showToast({
  399. title: res.message
  400. });
  401. if (res.code >= 0) {
  402. this.$refs.goodsListTable.load();
  403. }
  404. }
  405. });
  406. },
  407. goodsSku(id) {
  408. this.goodsId = id;
  409. this.getDetail(id, 'goodsSku');
  410. this.$refs.goodssku.open();
  411. },
  412. getDocumentType(type = '') {
  413. this.$api.sendRequest({
  414. url: '/stock/storeapi/manage/records',
  415. data: {
  416. goods_id: this.goods_detail.goods_id
  417. },
  418. success: res => {
  419. if (res.code >= 0) {
  420. this.documentTypeList = res.data.list;
  421. }
  422. }
  423. });
  424. },
  425. // 日志记录弹窗
  426. recordopen(id) {
  427. this.goodsId = id;
  428. this.$refs.record.open();
  429. },
  430. // 弹窗关闭
  431. close(type) {
  432. this.$refs[type].close();
  433. },
  434. goodsImageError(item) {
  435. item.goods_image = 'public/uniapp/default_img/goods.png';
  436. }
  437. }
  438. };
  439. </script>
  440. <style scoped lang="scss">
  441. @import './public/css/goods.scss';
  442. // 筛选面板
  443. .screen-warp {
  444. padding: 0.15rem 0.15rem 0;
  445. background-color: #f2f3f5;
  446. margin-bottom: 0.15rem;
  447. .common-form-item .form-label {
  448. width: 1.2rem;
  449. }
  450. .common-btn-wrap {
  451. margin-left: 1.2rem;
  452. }
  453. .goods-category .form-input-inline {
  454. width: 2.8rem;
  455. }
  456. .form-inline {
  457. margin-bottom: 0.15rem;
  458. }
  459. .common-form-item {
  460. margin-bottom: 0;
  461. }
  462. .input-append {
  463. position: relative;
  464. .form-input {
  465. padding-right: 0.3rem;
  466. }
  467. .unit {
  468. position: absolute;
  469. top: 0;
  470. right: 0.1rem;
  471. height: 0.35rem;
  472. line-height: 0.35rem;
  473. }
  474. }
  475. .form-input-inline.split-wrap {
  476. width: initial;
  477. background: none;
  478. border: none;
  479. }
  480. }
  481. .goodslist {
  482. display: block;
  483. width: 100%;
  484. @extend %body-overhide;
  485. padding: 0.15rem 0.15rem 0;
  486. background-color: #fff;
  487. /deep/ .goods-content {
  488. display: flex;
  489. .goods-img {
  490. margin-right: 0.1rem;
  491. width: 0.5rem;
  492. height: 0.5rem;
  493. }
  494. .goods-name {
  495. white-space: pre-wrap;
  496. align-self: baseline;
  497. }
  498. }
  499. .action-btn-wrap {
  500. .action-item {
  501. margin-left: 0.1rem;
  502. color: $primary-color;
  503. &:first-of-type {
  504. margin-left: 0;
  505. }
  506. }
  507. }
  508. /deep/ .batch-action {
  509. .batch-item {
  510. margin-right: 0.15rem;
  511. border: 0.01rem solid rgba(0, 0, 0, 0.2);
  512. padding: 0.05rem;
  513. border-radius: 0.03rem;
  514. }
  515. }
  516. }
  517. // 商品详情
  518. .goods-detail-wrap {
  519. background-color: #fff;
  520. border-radius: 0.05rem;
  521. padding-bottom: 0.15rem;
  522. .detail-head {
  523. padding: 0 0.15rem;
  524. display: flex;
  525. align-items: center;
  526. justify-content: space-between;
  527. font-size: 0.15rem;
  528. height: 0.45rem;
  529. border-bottom: 0.01rem solid #e8eaec;
  530. .iconguanbi1 {
  531. font-size: $uni-font-size-lg;
  532. }
  533. }
  534. .detail-body {
  535. width: 9rem;
  536. height: 4.9rem;
  537. padding: 0.2rem 0.2rem 0 0.2rem;
  538. box-sizing: border-box;
  539. overflow-y: auto;
  540. position: relative;
  541. .title {
  542. font-size: 0.15rem;
  543. margin-bottom: 0.2rem;
  544. }
  545. .information-box {
  546. display: flex;
  547. justify-content: space-between;
  548. .box-left {
  549. width: 5rem;
  550. .information {
  551. width: 100%;
  552. padding-left: 0.1rem;
  553. box-sizing: border-box;
  554. display: flex;
  555. align-items: center;
  556. margin-bottom: 0.15rem;
  557. view {
  558. color: #303133;
  559. font-size: 0.14rem;
  560. }
  561. view:nth-child(1) {
  562. width: 0.7rem;
  563. margin-right: 0.16rem;
  564. text-align: right;
  565. }
  566. view:nth-child(2) {
  567. flex: 1;
  568. margin-right: 0.23rem;
  569. text-overflow: ellipsis;
  570. overflow: hidden;
  571. white-space: nowrap;
  572. }
  573. }
  574. .information:last-child {
  575. margin-bottom: 0.35rem;
  576. }
  577. }
  578. .goods-img {
  579. width: 2rem;
  580. height: 2rem;
  581. }
  582. }
  583. .table {
  584. width: 100%;
  585. max-height: 2.7rem;
  586. box-sizing: border-box;
  587. .single-specification {
  588. width: 100%;
  589. max-height: 100%;
  590. padding-left: 0.1rem;
  591. box-sizing: border-box;
  592. .item {
  593. width: 100%;
  594. margin-bottom: 0.15rem;
  595. display: flex;
  596. align-items: center;
  597. image {
  598. width: 0.5rem;
  599. }
  600. .name {
  601. display: flex;
  602. align-items: center;
  603. margin-right: 0.16rem;
  604. width: 0.7rem;
  605. text-align: right;
  606. }
  607. .message {
  608. width: 74%;
  609. text-overflow: ellipsis;
  610. overflow: hidden;
  611. white-space: nowrap;
  612. }
  613. }
  614. }
  615. .table-all {
  616. width: 100%;
  617. display: flex;
  618. align-items: center;
  619. justify-content: space-between;
  620. padding: 0 0.38rem;
  621. box-sizing: border-box;
  622. .table-td {
  623. font-size: 0.14rem;
  624. text-align: left;
  625. text-overflow: ellipsis;
  626. overflow: hidden;
  627. white-space: nowrap;
  628. }
  629. }
  630. .table-th {
  631. height: 0.56rem;
  632. background: #f7f8fa;
  633. }
  634. .table-tb {
  635. width: 100%;
  636. height: calc(100% - 0.56rem);
  637. .table-tr {
  638. height: 0.7rem;
  639. border-bottom: 0.01rem solid #e6e6e6;
  640. box-sizing: border-box;
  641. .table-td {
  642. image {
  643. width: 0.5rem;
  644. height: 0.5rem;
  645. }
  646. text-overflow: -o-ellipsis-lastline;
  647. overflow: hidden;
  648. text-overflow: ellipsis;
  649. display: -webkit-box;
  650. -webkit-line-clamp: 2;
  651. line-clamp: 2;
  652. -webkit-box-orient: vertical;
  653. }
  654. }
  655. }
  656. }
  657. }
  658. }
  659. </style>