warehouse.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. <template>
  2. <Theme>
  3. <view class="_wrap">
  4. <Navbar fixed border :navShow="navShow">
  5. <template #center>
  6. <view class="nav_search">
  7. <Search
  8. v-model="searchValue"
  9. @confirm="searchConfirm"
  10. :placeholder="t('名称订单号商品名称')"
  11. >
  12. <template #prefix>
  13. <i class="icon-font icon-search"></i>
  14. </template>
  15. </Search>
  16. </view>
  17. </template>
  18. <template #right>
  19. <navFilter @submit="filterSubmit" isOrderTime />
  20. <navMenu
  21. :options="{ icon: 'icon-home', text: '主页' }"
  22. page="warehouse"
  23. />
  24. </template>
  25. </Navbar>
  26. <view class="contents">
  27. <view class="cont">
  28. <List
  29. url="/shop/stocks/lists"
  30. ref="listRef"
  31. :defaultParams="{ keywords: searchValue, ...params }"
  32. @datas="getList"
  33. >
  34. <template #item="{ item }">
  35. <view class="list_wrapper">
  36. <view class="cart_cont">
  37. <view class="cont_list">
  38. <!-- <view class="checkout">
  39. <up-checkbox-group
  40. activeColor="var(--black)"
  41. shape="circle"
  42. labelSize="14"
  43. labelColor="#676969"
  44. iconSize="16"
  45. :modelValue="ids"
  46. @change="checkedChanges(item.id)"
  47. >
  48. <up-checkbox :name="item.id" />
  49. </up-checkbox-group>
  50. </view> -->
  51. <view class="list_right" @click="listClick(item)">
  52. <view class="img">
  53. <up-lazy-load
  54. :image="item.pic_url"
  55. class="list_icon"
  56. ></up-lazy-load>
  57. </view>
  58. <view class="goods_info">
  59. <view class="info_name">{{ item.goodTitle }}</view>
  60. <view class="info_desc">{{ item.sku_desc }}</view>
  61. <view class="info_price">
  62. <view class="unit_price">
  63. <text>{{ symbol.symbol }}</text>
  64. <rich-text
  65. :nodes="Moneyhtml(item?.price)"
  66. ></rich-text>
  67. </view>
  68. <view class="unit_num">x{{ item.total }}</view>
  69. </view>
  70. <view class="info_action">
  71. <view class="sale_price">
  72. <template v-if="item.seller_goods_status === 1">
  73. <text class="label">销售价:</text>
  74. <view class="unit_price">
  75. <text>{{ symbol.symbol }}</text>
  76. <rich-text
  77. :nodes="Moneyhtml(item?.seller_goods_price)"
  78. ></rich-text>
  79. </view>
  80. </template>
  81. </view>
  82. <view
  83. class="action_btn"
  84. @click.stop="toggleStatus(item)"
  85. >
  86. <text>{{
  87. item.seller_goods_status === 1 ? "下架" : "上架"
  88. }}</text>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. </template>
  97. </List>
  98. </view>
  99. <!-- <view class="footer" :class="!navShow ? 'footer_bottom' : ''">
  100. <view class="footer_left">
  101. <up-checkbox
  102. :label="t('全部')"
  103. activeColor="var(--black)"
  104. shape="circle"
  105. labelSize="14"
  106. labelColor="#676969"
  107. iconSize="16"
  108. name="agree"
  109. usedAlone
  110. v-model:checked="selectAllChecked"
  111. @change="selectAllChange"
  112. >
  113. </up-checkbox>
  114. </view>
  115. <view class="footer_right">
  116. <view
  117. class="total_btn"
  118. @click.stop="submit"
  119. :style="{ opacity: ids.length ? 1 : 0.5 }"
  120. >
  121. <trans _t="上架" />
  122. </view>
  123. </view>
  124. </view> -->
  125. </view>
  126. </view>
  127. <!-- 价格设置弹框 -->
  128. <PricePopup
  129. :show="pricePopupShow"
  130. :item="currentItem"
  131. @close="onPriceClose"
  132. @confirm="onPriceConfirm"
  133. />
  134. </Theme>
  135. </template>
  136. <script setup>
  137. import Navbar from "@/components/navbar";
  138. import navMenu from "@/components/nav_menu";
  139. import navFilter from "@/components/nav_filter";
  140. import Search from "@/components/input";
  141. import List from "@/components/list";
  142. import PricePopup from "./components/PricePopup.vue";
  143. import { ref, onMounted, nextTick, computed } from "vue";
  144. import { t } from "@/locale";
  145. import { useGlobal, Toast, Moneyhtml, Modal } from "@/utils";
  146. import { useSystemStore } from "@/store";
  147. import { onReachBottom } from "@dcloudio/uni-app";
  148. import { onShow } from "@dcloudio/uni-app";
  149. import { SELLER_GOODS_DOWN } from "@/api";
  150. const props = defineProps({
  151. navShow: Boolean,
  152. });
  153. const useSystem = useSystemStore();
  154. const searchValue = ref("");
  155. const listRef = ref(null);
  156. const allList = ref([]);
  157. const ids = ref([]);
  158. const params = ref({});
  159. const allId = ref([]);
  160. const symbol = computed(() => useSystem.getSymbol);
  161. const selectAllChecked = ref(false);
  162. // 价格弹框相关状态
  163. const pricePopupShow = ref(false);
  164. const currentItem = ref(null);
  165. const searchConfirm = () => {
  166. nextTick(() => {
  167. listRef.value && listRef.value.handleRefresh();
  168. });
  169. };
  170. const checkedChanges = (id) => {
  171. let arr = JSON.parse(JSON.stringify(ids.value));
  172. let findIndex = ids.value.findIndex((item) => item == id);
  173. if (findIndex != -1) {
  174. arr = arr.filter((item) => item != id);
  175. } else {
  176. arr.push(id);
  177. }
  178. ids.value = arr;
  179. let flag = allId.value.every((value) => arr.includes(value));
  180. selectAllChecked.value = flag;
  181. };
  182. const selectAllChange = (e) => {
  183. ids.value = e ? allId.value : [];
  184. };
  185. const getList = (list) => {
  186. allList.value = list;
  187. allId.value = list.reduce((acc, item) => {
  188. acc.push(item.id);
  189. return acc;
  190. }, []);
  191. let flag = allId.value.every((value) => ids.value.includes(value));
  192. selectAllChecked.value = list.length === 0 ? false : flag;
  193. };
  194. const listClick = (item) => {
  195. uni.navigateTo({ url: `/pages/dashboard/warehouse_detail?id=${item.id}` });
  196. };
  197. const filterSubmit = (obj) => {
  198. const { status, ...new_obj } = obj;
  199. params.value = new_obj;
  200. nextTick(() => {
  201. listRef.value && listRef.value.handleRefresh();
  202. });
  203. };
  204. const submit = () => {
  205. if (!ids.value.length) return;
  206. uni.navigateTo({ url: `/pages/dashboard/pack?ids=${ids.value.join(",")}` });
  207. };
  208. const toggleStatus = (item) => {
  209. if (item.seller_goods_status === 1) {
  210. Modal({ content: t("确定要下架该商品吗?") }).then(async () => {
  211. try {
  212. const res = await SELLER_GOODS_DOWN(item.id);
  213. Toast(res.msg);
  214. nextTick(() => {
  215. listRef.value && listRef.value.handleRefresh();
  216. });
  217. } catch (error) {
  218. Toast(error.msg);
  219. }
  220. });
  221. } else {
  222. currentItem.value = item;
  223. pricePopupShow.value = true;
  224. }
  225. };
  226. const onPriceClose = () => {
  227. pricePopupShow.value = false;
  228. currentItem.value = null;
  229. };
  230. const onPriceConfirm = () => {
  231. onPriceClose();
  232. listRef.value && listRef.value.getData();
  233. };
  234. onMounted(() => {
  235. listRef.value && listRef.value.getData();
  236. });
  237. onShow(() => {
  238. listRef.value && listRef.value.getData();
  239. });
  240. onReachBottom(() => {
  241. nextTick(() => {
  242. listRef.value && listRef.value.scrolltolower();
  243. });
  244. });
  245. </script>
  246. <style lang="less" scoped>
  247. @import url("@/style.less");
  248. ._wrap {
  249. height: calc(100vh - 104px);
  250. background-color: var(--bg);
  251. .flex();
  252. flex-direction: column;
  253. padding-bottom: 104px;
  254. /deep/ .u-navbar__content {
  255. justify-content: unset;
  256. .u-navbar__content__left,
  257. .u-navbar__content__right {
  258. position: unset;
  259. }
  260. }
  261. .nav_search {
  262. flex: 1;
  263. .icon-search {
  264. color: var(--text);
  265. .size(16px);
  266. }
  267. }
  268. .contents {
  269. flex-grow: 1;
  270. // height: calc(100vh - 44px);
  271. flex-direction: column;
  272. .flex();
  273. /deep/ .wrap_list {
  274. .uni-scroll-view-content {
  275. > uni-view {
  276. .u-list-item {
  277. width: auto !important;
  278. }
  279. }
  280. }
  281. }
  282. .cont {
  283. flex-grow: 1;
  284. overflow: hidden scroll;
  285. padding-bottom: 54px;
  286. background-color: var(--bg);
  287. // padding: 0 24rpx 24rpx;
  288. .list_wrapper {
  289. background-color: var(--light);
  290. .flex();
  291. flex-direction: column;
  292. gap: 24rpx;
  293. margin-bottom: 24rpx;
  294. padding: 24rpx;
  295. .cart_cont {
  296. .flex();
  297. flex-direction: column;
  298. gap: 24rpx;
  299. .cont_list {
  300. .flex();
  301. column-gap: 16rpx;
  302. .list_right {
  303. .flex();
  304. column-gap: 16rpx;
  305. }
  306. .img {
  307. width: 128rpx;
  308. height: 128rpx;
  309. .list_icon {
  310. flex: 0 1 auto;
  311. max-width: 100%;
  312. height: 100%;
  313. border-radius: 16rpx;
  314. }
  315. }
  316. .goods_info {
  317. .size(24rpx);
  318. flex: 1;
  319. .info_name {
  320. .ellipsis(2);
  321. font-weight: 700;
  322. color: var(--text);
  323. line-height: 48rpx;
  324. }
  325. .info_desc {
  326. color: var(--text-01);
  327. font-weight: 400;
  328. line-height: 40rpx;
  329. margin-top: 8rpx;
  330. }
  331. .info_price {
  332. .flex_position(space-between);
  333. margin-top: 16rpx;
  334. .unit_price {
  335. .size(36rpx);
  336. color: var(--red);
  337. font-weight: 700;
  338. line-height: 60rpx;
  339. .ver();
  340. column-gap: 8rpx;
  341. }
  342. .unit_num {
  343. background-color: var(--bg);
  344. border-radius: 8rpx;
  345. color: var(--red);
  346. .size(24rpx);
  347. line-height: 40rpx;
  348. padding: 4rpx 8rpx;
  349. }
  350. }
  351. .info_action {
  352. .flex_position(space-between);
  353. margin-top: 12rpx;
  354. align-items: center;
  355. .sale_price {
  356. .flex();
  357. align-items: center;
  358. column-gap: 8rpx;
  359. line-height: 60rpx;
  360. .label {
  361. .size(24rpx);
  362. color: var(--text-01);
  363. }
  364. .unit_price {
  365. .size(24rpx);
  366. color: var(--red);
  367. font-weight: 700;
  368. .ver();
  369. }
  370. }
  371. .action_btn {
  372. .size(24rpx);
  373. font-weight: 600;
  374. height: 60rpx;
  375. min-width: 80rpx;
  376. background-color: var(--black);
  377. color: var(--light);
  378. border-radius: 12rpx;
  379. padding: 0 16rpx;
  380. text-align: center;
  381. line-height: 60rpx;
  382. }
  383. }
  384. }
  385. }
  386. }
  387. }
  388. }
  389. .footer {
  390. position: fixed;
  391. bottom: calc(45px + constant(safe-area-inset-bottom));
  392. bottom: calc(45px + env(safe-area-inset-bottom));
  393. left: 0;
  394. right: 0;
  395. .flex_position(space-between);
  396. flex-wrap: wrap;
  397. height: 54px;
  398. padding: 0 12px;
  399. background-color: var(--light);
  400. box-shadow: 0 -4px 6px #0000000d;
  401. &.footer_bottom {
  402. bottom: 0;
  403. }
  404. &_right {
  405. .ver();
  406. .total_info {
  407. .total_price {
  408. text-align: right;
  409. color: var(--primary);
  410. .size();
  411. font-weight: 700;
  412. line-height: 48rpx;
  413. }
  414. .total_desc {
  415. color: var(--text-01);
  416. .size(24rpx);
  417. line-height: 40rpx;
  418. text-align: right;
  419. .icon-font {
  420. .size();
  421. }
  422. }
  423. }
  424. .total_btn {
  425. .size(28rpx);
  426. font-weight: 700;
  427. height: 38px;
  428. margin-left: 16rpx;
  429. min-width: 180rpx;
  430. background-color: var(--black);
  431. color: var(--light);
  432. border-radius: 16rpx;
  433. padding: 16rpx 30rpx;
  434. text-align: center;
  435. }
  436. }
  437. }
  438. }
  439. }
  440. </style>