index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <template>
  2. <view class="inventory-page">
  3. <u-navbar
  4. height="40px"
  5. title="存货查询"
  6. bgColor="#fff"
  7. autoBack
  8. placeholder
  9. >
  10. </u-navbar>
  11. <view class="container_main">
  12. <view class="head-box">
  13. <view class="search-box">
  14. <u-search
  15. placeholder="请输入单据编号"
  16. shape="square"
  17. v-model="searchKey"
  18. :showAction="false"
  19. ></u-search>
  20. <view class="scan-icon flex_box flex_row_center">
  21. <image src="@/static/image/scan-icon-2.png" mode=""></image>
  22. </view>
  23. </view>
  24. <view class="type-box">
  25. <u-tabs
  26. :list="tabList"
  27. :inactiveStyle="{ color: '#000', fontSize: '24rpx' }"
  28. :activeStyle="{ color: '#000', fontSize: '24rpx' }"
  29. lineColor="#0256FF"
  30. lineWidth="66rpx"
  31. :scrollable="false"
  32. @click="tabClick"
  33. >
  34. </u-tabs>
  35. </view>
  36. </view>
  37. <view class="goods-box">
  38. <view class="goods-type" @click="typeClick">
  39. <view class="goods-type-text">{{ typeName }}</view>
  40. <u-icon name="arrow-down-fill" color="#999999" size="10"></u-icon>
  41. </view>
  42. <view class="goods-cont">
  43. <view class="goods-cont-left">
  44. <scroll-view
  45. scroll-y
  46. :style="{
  47. height: `calc(100vh - ${scrollH}px - 40px - 24rpx - 102rpx)`,
  48. }"
  49. >
  50. <leo-tree
  51. :data="treeData"
  52. @node-click="nodeClick"
  53. v-model="typeId"
  54. ></leo-tree>
  55. <!-- <view
  56. class="type-item"
  57. :class="item.id == typeId ? 'active-item' : ''"
  58. v-for="(item, i) in typeList"
  59. :key="i"
  60. @click="chooseType(item)"
  61. >
  62. {{ item.name }}
  63. </view> -->
  64. </scroll-view>
  65. </view>
  66. <view class="goods-cont-right">
  67. <scroll-view
  68. scroll-y
  69. :style="{
  70. height: `calc(100vh - ${scrollH}px - 40px - 24rpx - 102rpx)`,
  71. }"
  72. @scrolltolower="onLoadMore"
  73. >
  74. <block v-for="(item, i) in goodsList" :key="i">
  75. <good-item :item="item"></good-item>
  76. </block>
  77. <!-- 加载更多 -->
  78. <u-loadmore :status="loadStatus" @loadmore="onLoadMore" />
  79. </scroll-view>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. <u-picker
  85. :show="typeShow"
  86. :defaultIndex="defaultIndex"
  87. :columns="columnsList"
  88. @confirm="pickerConfirm"
  89. @cancel="typeShow = false"
  90. ></u-picker>
  91. </view>
  92. </template>
  93. <script>
  94. import leoTree from "@/components/leo-tree/leo-tree.vue";
  95. import { inventoryInquiry } from "@/common/request/apis/inventoryInquiry";
  96. import goodItem from "@/components/good-item/good-item.vue";
  97. export default {
  98. components: {
  99. goodItem,
  100. leoTree,
  101. },
  102. data() {
  103. return {
  104. offsetTop: 0,
  105. searchKey: "",
  106. current: 0,
  107. typeShow: false,
  108. defaultIndex: [],
  109. typeName: "按分类展示",
  110. scrollH: 0,
  111. columnsList: [["按分类展示", "按库位展示"]],
  112. typeId: "",
  113. treeData: [
  114. {
  115. id: "1",
  116. label: "1",
  117. children: [
  118. {
  119. id: "1-1",
  120. label: "1-1",
  121. children: [
  122. {
  123. id: "1-1-1",
  124. label: "哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈",
  125. },
  126. {
  127. id: "1-1-2",
  128. label: "1-1-2",
  129. },
  130. {
  131. id: "1-1-3",
  132. label: "1-1-3",
  133. },
  134. {
  135. id: "1-1-4",
  136. label: "1-1-4",
  137. },
  138. ],
  139. },
  140. {
  141. id: "1-2",
  142. label: "1-2",
  143. children: [
  144. {
  145. id: "1-2-1",
  146. label: "1-2-1",
  147. },
  148. {
  149. id: "1-2-2",
  150. label: "1-2-2",
  151. },
  152. {
  153. id: "1-2-3",
  154. label: "1-2-3",
  155. },
  156. {
  157. id: "1-2-4",
  158. label: "1-2-4",
  159. },
  160. ],
  161. },
  162. ],
  163. },
  164. {
  165. id: "2",
  166. label: "2",
  167. children: [
  168. {
  169. id: "2-1",
  170. label: "2-1",
  171. children: [
  172. {
  173. id: "2-1-1",
  174. label: "2-1-1",
  175. },
  176. {
  177. id: "2-1-2",
  178. label: "2-1-2",
  179. },
  180. {
  181. id: "2-1-3",
  182. label: "2-1-3",
  183. },
  184. {
  185. id: "2-1-4",
  186. label: "2-1-4",
  187. },
  188. ],
  189. },
  190. ],
  191. },
  192. ],
  193. tabList: [
  194. {
  195. index: 0,
  196. name: "有库存",
  197. },
  198. {
  199. index: 1,
  200. name: "无库存",
  201. },
  202. {
  203. index: 2,
  204. name: "全部",
  205. },
  206. ],
  207. loadStatus: "loadmore", //加载前值为loadmore,加载中为loading,没有数据为nomore
  208. goodsList: [],
  209. pageSize: 10,
  210. pageNum: 1,
  211. query: {},
  212. };
  213. },
  214. mounted() {
  215. let systemInfo = uni.getSystemInfoSync();
  216. let statusBarHeight = systemInfo.statusBarHeight;
  217. let headH = 0;
  218. const query = uni.createSelectorQuery().in(this);
  219. query
  220. .select(".head-box")
  221. .boundingClientRect((rect) => {
  222. headH = rect.height;
  223. this.scrollH = statusBarHeight + headH;
  224. })
  225. .exec();
  226. },
  227. onLoad() {
  228. // let systemInfo = uni.getSystemInfoSync();
  229. // let statusBarHeight = systemInfo.statusBarHeight;
  230. // this.offsetTop = statusBarHeight + 40
  231. this.loadData();
  232. },
  233. methods: {
  234. async onRefresh() {
  235. try {
  236. await this.loadData(true);
  237. } finally {
  238. }
  239. },
  240. async onLoadMore() {
  241. if (this.loadStatus !== "loadmore") return;
  242. this.loadStatus = "loading";
  243. try {
  244. await this.loadData();
  245. } catch (e) {
  246. this.loadStatus = "loadmore";
  247. }
  248. },
  249. async loadData(isRefresh = false) {
  250. if (isRefresh) {
  251. this.pageNum = 1;
  252. this.goodsList = [];
  253. }
  254. try {
  255. this.loadStatus = "loading";
  256. const pageNum = this.pageNum;
  257. const pageSize = this.pageSize;
  258. const params = {
  259. pageNum,
  260. pageSize,
  261. ...this.query,
  262. };
  263. const res = await inventoryInquiry(params);
  264. console.log("res====", res);
  265. const { rows, total } = res.data;
  266. const list = rows.map((item) => {
  267. return {
  268. ...item,
  269. src: item.imgName,
  270. };
  271. });
  272. this.goodsList = [...this.goodsList, ...list];
  273. if (pageNum * pageSize < Number(total)) {
  274. this.pageNum++;
  275. this.loadStatus = "loadmore";
  276. } else {
  277. this.loadStatus = "nomore";
  278. }
  279. } catch (error) {}
  280. },
  281. nodeClick(e) {
  282. console.log("nodeClick======", e);
  283. console.log("this.typeId======", this.typeId);
  284. // this.typeId = e.id;
  285. },
  286. tabClick() {},
  287. typeClick() {
  288. let index = this.columnsList[0].findIndex(
  289. (item) => item == this.typeName
  290. );
  291. this.defaultIndex = [index];
  292. this.typeShow = true;
  293. },
  294. pickerConfirm(val) {
  295. this.typeName = val.value[0];
  296. this.typeShow = false;
  297. },
  298. chooseType(item) {
  299. this.typeId = item.id;
  300. },
  301. },
  302. };
  303. </script>
  304. <style lang="scss" scoped>
  305. .inventory-page {
  306. min-height: 100vh;
  307. background: #f0f6fb;
  308. .container_main {
  309. .head-box {
  310. background-color: #fff;
  311. }
  312. .search-box {
  313. background-color: rgba(191, 200, 219, 0.2);
  314. margin: 0 32rpx;
  315. display: flex;
  316. align-items: center;
  317. justify-content: space-between;
  318. border-radius: 8rpx;
  319. ::v-deep .u-search__content {
  320. background-color: transparent !important;
  321. .u-search__content__input {
  322. background-color: transparent !important;
  323. }
  324. }
  325. .scan-icon {
  326. width: 100rpx;
  327. height: 100%;
  328. image {
  329. width: 40rpx;
  330. height: 40rpx;
  331. }
  332. }
  333. }
  334. .goods-box {
  335. margin-top: 24rpx;
  336. .goods-type {
  337. display: flex;
  338. align-items: center;
  339. padding-left: 24rpx;
  340. height: 102rpx;
  341. background-color: #fff;
  342. &-text {
  343. color: #0256ff;
  344. font-size: 28rpx;
  345. font-weight: bold;
  346. margin-right: 10rpx;
  347. }
  348. }
  349. .goods-cont {
  350. display: flex;
  351. .goods-cont-left {
  352. width: 160rpx;
  353. background-color: #f0f6fb;
  354. .type-item {
  355. width: 100%;
  356. height: 84rpx;
  357. display: flex;
  358. align-items: center;
  359. justify-content: center;
  360. color: #666;
  361. font-family: "PingFang SC";
  362. font-size: 28rpx;
  363. font-weight: 400;
  364. }
  365. .active-item {
  366. background-color: #fff;
  367. color: #333;
  368. font-weight: bold;
  369. }
  370. }
  371. .goods-cont-right {
  372. flex: 1;
  373. background-color: #fff;
  374. }
  375. }
  376. }
  377. }
  378. }
  379. </style>