warehouse.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </template>
  76. </List>
  77. </view>
  78. <view class="footer" :class="!navShow ? 'footer_bottom' : ''">
  79. <view class="footer_left">
  80. <up-checkbox
  81. :label="t('全部')"
  82. activeColor="var(--black)"
  83. shape="circle"
  84. labelSize="14"
  85. labelColor="#676969"
  86. iconSize="16"
  87. name="agree"
  88. usedAlone
  89. v-model:checked="selectAllChecked"
  90. @change="selectAllChange"
  91. >
  92. </up-checkbox>
  93. </view>
  94. <view class="footer_right">
  95. <view
  96. class="total_btn"
  97. @click.stop="submit"
  98. :style="{ opacity: ids.length ? 1 : 0.5 }"
  99. >
  100. <trans _t="打包" />
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. </view>
  106. </Theme>
  107. </template>
  108. <script setup>
  109. import Navbar from "@/components/navbar";
  110. import navMenu from "@/components/nav_menu";
  111. import navFilter from "@/components/nav_filter";
  112. import Search from "@/components/input";
  113. import List from "@/components/list";
  114. import { ref, onMounted, nextTick, computed } from "vue";
  115. import { t } from "@/locale";
  116. import { useGlobal, Toast, Moneyhtml } from "@/utils";
  117. import { useSystemStore } from "@/store";
  118. import { onReachBottom } from "@dcloudio/uni-app";
  119. import { onShow } from "@dcloudio/uni-app";
  120. const props = defineProps({
  121. navShow: Boolean,
  122. });
  123. const useSystem = useSystemStore();
  124. const searchValue = ref("");
  125. const listRef = ref(null);
  126. const allList = ref([]);
  127. const ids = ref([]);
  128. const params = ref({});
  129. const allId = ref([]);
  130. const symbol = computed(() => useSystem.getSymbol);
  131. const selectAllChecked = ref(false);
  132. const searchConfirm = () => {
  133. nextTick(() => {
  134. listRef.value && listRef.value.handleRefresh();
  135. });
  136. };
  137. const checkedChanges = (id) => {
  138. let arr = JSON.parse(JSON.stringify(ids.value));
  139. let findIndex = ids.value.findIndex((item) => item == id);
  140. if (findIndex != -1) {
  141. arr = arr.filter((item) => item != id);
  142. } else {
  143. arr.push(id);
  144. }
  145. ids.value = arr;
  146. let flag = allId.value.every((value) => arr.includes(value));
  147. selectAllChecked.value = flag;
  148. };
  149. const selectAllChange = (e) => {
  150. ids.value = e ? allId.value : [];
  151. };
  152. const getList = (list) => {
  153. allList.value = list;
  154. allId.value = list.reduce((acc, item) => {
  155. acc.push(item.id);
  156. return acc;
  157. }, []);
  158. let flag = allId.value.every((value) => ids.value.includes(value));
  159. selectAllChecked.value = list.length === 0 ? false : flag;
  160. };
  161. const listClick = (item) => {
  162. uni.navigateTo({ url: `/pages/dashboard/warehouse_detail?id=${item.id}` });
  163. };
  164. const filterSubmit = (obj) => {
  165. const { status, ...new_obj } = obj;
  166. params.value = new_obj;
  167. nextTick(() => {
  168. listRef.value && listRef.value.handleRefresh();
  169. });
  170. };
  171. const submit = () => {
  172. if (!ids.value.length) return;
  173. uni.navigateTo({ url: `/pages/dashboard/pack?ids=${ids.value.join(",")}` });
  174. };
  175. onMounted(() => {
  176. listRef.value && listRef.value.getData();
  177. });
  178. onShow(() => {
  179. listRef.value && listRef.value.getData();
  180. });
  181. onReachBottom(() => {
  182. nextTick(() => {
  183. listRef.value && listRef.value.scrolltolower();
  184. });
  185. });
  186. </script>
  187. <style lang="less" scoped>
  188. @import url("@/style.less");
  189. ._wrap {
  190. height: calc(100vh - 104px);
  191. background-color: var(--bg);
  192. .flex();
  193. flex-direction: column;
  194. padding-bottom: 104px;
  195. /deep/ .u-navbar__content {
  196. justify-content: unset;
  197. .u-navbar__content__left,
  198. .u-navbar__content__right {
  199. position: unset;
  200. }
  201. }
  202. .nav_search {
  203. flex: 1;
  204. .icon-search {
  205. color: var(--text);
  206. .size(16px);
  207. }
  208. }
  209. .contents {
  210. flex-grow: 1;
  211. // height: calc(100vh - 44px);
  212. flex-direction: column;
  213. .flex();
  214. /deep/ .wrap_list {
  215. .uni-scroll-view-content {
  216. > uni-view {
  217. .u-list-item {
  218. width: auto !important;
  219. }
  220. }
  221. }
  222. }
  223. .cont {
  224. flex-grow: 1;
  225. overflow: hidden scroll;
  226. padding-bottom: 54px;
  227. background-color: var(--bg);
  228. // padding: 0 24rpx 24rpx;
  229. .list_wrapper {
  230. background-color: var(--light);
  231. .flex();
  232. flex-direction: column;
  233. gap: 24rpx;
  234. margin-bottom: 24rpx;
  235. padding: 24rpx;
  236. .cart_cont {
  237. .flex();
  238. flex-direction: column;
  239. gap: 24rpx;
  240. .cont_list {
  241. .flex();
  242. column-gap: 16rpx;
  243. .list_right {
  244. .flex();
  245. column-gap: 16rpx;
  246. }
  247. .img {
  248. width: 128rpx;
  249. height: 128rpx;
  250. .list_icon {
  251. flex: 0 1 auto;
  252. max-width: 100%;
  253. height: 100%;
  254. border-radius: 16rpx;
  255. }
  256. }
  257. .goods_info {
  258. .size(24rpx);
  259. flex: 1;
  260. .info_name {
  261. font-weight: 700;
  262. color: var(--text);
  263. line-height: 48rpx;
  264. }
  265. .info_desc {
  266. color: var(--text-01);
  267. font-weight: 400;
  268. line-height: 40rpx;
  269. margin-top: 8rpx;
  270. }
  271. .info_price {
  272. .flex_position(space-between);
  273. margin-top: 16rpx;
  274. .unit_price {
  275. .size(36rpx);
  276. color: var(--red);
  277. font-weight: 700;
  278. line-height: 60rpx;
  279. .ver();
  280. column-gap: 8rpx;
  281. }
  282. .unit_num {
  283. background-color: var(--bg);
  284. border-radius: 8rpx;
  285. color: var(--red);
  286. .size(24rpx);
  287. line-height: 40rpx;
  288. padding: 4rpx 8rpx;
  289. }
  290. }
  291. }
  292. }
  293. }
  294. }
  295. }
  296. .footer {
  297. position: fixed;
  298. bottom: calc(45px + constant(safe-area-inset-bottom));
  299. bottom: calc(45px + env(safe-area-inset-bottom));
  300. left: 0;
  301. right: 0;
  302. .flex_position(space-between);
  303. flex-wrap: wrap;
  304. height: 54px;
  305. padding: 0 12px;
  306. background-color: var(--light);
  307. box-shadow: 0 -4px 6px #0000000d;
  308. &.footer_bottom {
  309. bottom: 0;
  310. }
  311. &_left {
  312. }
  313. &_right {
  314. .ver();
  315. .total_info {
  316. .total_price {
  317. text-align: right;
  318. color: var(--primary);
  319. .size();
  320. font-weight: 700;
  321. line-height: 48rpx;
  322. }
  323. .total_desc {
  324. color: var(--text-01);
  325. .size(24rpx);
  326. line-height: 40rpx;
  327. text-align: right;
  328. .icon-font {
  329. .size();
  330. }
  331. }
  332. }
  333. .total_btn {
  334. .size(28rpx);
  335. font-weight: 700;
  336. height: 38px;
  337. margin-left: 16rpx;
  338. min-width: 180rpx;
  339. background-color: var(--black);
  340. color: var(--light);
  341. border-radius: 16rpx;
  342. padding: 16rpx 30rpx;
  343. text-align: center;
  344. }
  345. }
  346. }
  347. }
  348. }
  349. </style>