123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375 |
- <template>
- <view class="inventory-page">
- <u-navbar
- height="40px"
- title="存货查询"
- bgColor="#fff"
- autoBack
- placeholder
- >
- </u-navbar>
- <view class="container_main">
- <view class="head-box">
- <view class="search-box">
- <u-search
- placeholder="请输入单据编号"
- shape="square"
- :showAction="false"
- @search="handleSearch"
- @clear="handleSearch"
- v-model="queryParams.keyword"
- ></u-search>
- <view class="scan-icon flex_box flex_row_center">
- <image src="@/static/image/scan-icon-2.png" mode=""></image>
- </view>
- </view>
- <view class="type-box">
- <u-tabs
- :list="tabList"
- :inactiveStyle="{ color: '#000', fontSize: '24rpx' }"
- :activeStyle="{ color: '#000', fontSize: '24rpx' }"
- lineColor="#0256FF"
- lineWidth="66rpx"
- :scrollable="false"
- @click="tabClick"
- >
- </u-tabs>
- </view>
- </view>
- <view class="goods-box">
- <view class="goods-type" @click="typeClick">
- <view class="goods-type-text">{{ typeName }}</view>
- <u-icon name="arrow-down-fill" color="#999999" size="10"></u-icon>
- </view>
- <view class="goods-cont">
- <view class="goods-cont-left">
- <scroll-view
- scroll-y
- :style="{
- height: `calc(100vh - ${scrollH}px - 40px - 24rpx - 102rpx)`,
- }"
- >
- <leo-tree
- v-if="typeName === '按库位展示'"
- :data="treeData"
- :defaultProps="defaultProps"
- @node-click="nodeClick"
- v-model="queryParams.position"
- ></leo-tree>
- <leo-tree
- v-if="typeName === '按分类展示'"
- :data="treeData2"
- :defaultProps="defaultProps2"
- @node-click="nodeClick2"
- v-model="queryParams.categoryId"
- ></leo-tree>
- </scroll-view>
- </view>
- <view class="goods-cont-right">
- <scroll-view
- scroll-y
- :style="{
- height: `calc(100vh - ${scrollH}px - 40px - 24rpx - 102rpx)`,
- }"
- @scrolltolower="onLoadMore"
- >
- <block v-for="(item, i) in goodsList" :key="i">
- <good-item :item="item"></good-item>
- </block>
- <!-- 加载更多 -->
- <u-loadmore :status="loadStatus" @loadmore="onLoadMore" />
- </scroll-view>
- </view>
- </view>
- </view>
- </view>
- <u-picker
- :show="typeShow"
- :defaultIndex="defaultIndex"
- :columns="columnsList"
- @confirm="pickerConfirm"
- @cancel="typeShow = false"
- ></u-picker>
- </view>
- </template>
- <script>
- import leoTree from "@/components/leo-tree/leo-tree.vue";
- import {
- inventoryInquiry,
- inventoryPositionTree,
- materialCategoryTree,
- } from "@/common/request/apis/inventoryInquiry";
- import goodItem from "@/components/good-item/good-item.vue";
- export default {
- components: {
- goodItem,
- leoTree,
- },
- data() {
- return {
- offsetTop: 0,
- current: 0,
- typeShow: false,
- defaultIndex: [],
- typeName: "按分类展示",
- scrollH: 0,
- columnsList: [["按分类展示", "按库位展示"]],
- treeData: [],
- treeData2: [],
- tabList: [
- {
- value: "have",
- name: "有库存",
- },
- {
- value: "none",
- name: "无库存",
- },
- {
- value: "all",
- name: "全部",
- },
- ],
- defaultProps: {
- id: "value",
- children: "children",
- label: "label",
- },
- defaultProps2: {
- id: "id",
- children: "children",
- label: "title",
- },
- loadStatus: "loadmore", //加载前值为loadmore,加载中为loading,没有数据为nomore
- goodsList: [],
- pageSize: 10,
- pageNum: 1,
- queryParams: {
- type: "have",
- categoryId: "",
- position: "",
- keyword: "",
- },
- };
- },
- mounted() {
- let systemInfo = uni.getSystemInfoSync();
- let statusBarHeight = systemInfo.statusBarHeight;
- let headH = 0;
- const query = uni.createSelectorQuery().in(this);
- query
- .select(".head-box")
- .boundingClientRect((rect) => {
- headH = rect.height;
- this.scrollH = statusBarHeight + headH;
- })
- .exec();
- },
- onLoad() {
- // let systemInfo = uni.getSystemInfoSync();
- // let statusBarHeight = systemInfo.statusBarHeight;
- // this.offsetTop = statusBarHeight + 40
- this.getTreeData();
- this.getMaterialCategoryTree();
- this.loadData();
- },
- onShow() {
- uni.$on("scanFinish", (data) => {
- this.params.keyword = data;
- this.onRefresh();
- });
- },
- onHide() {
- uni.$off("scanFinish");
- },
- onUnload() {
- uni.$off("scanFinish");
- },
- methods: {
- async getTreeData() {
- try {
- const res = await inventoryPositionTree();
- console.log("res=====", res);
- this.treeData = res.data;
- } catch (error) {}
- },
- async getMaterialCategoryTree() {
- try {
- const res = await materialCategoryTree();
- console.log("res=====", res);
- this.treeData2 = res.data;
- } catch (error) {}
- },
- async onRefresh() {
- try {
- await this.loadData(true);
- } finally {
- }
- },
- async onLoadMore() {
- if (this.loadStatus !== "loadmore") return;
- this.loadStatus = "loading";
- try {
- await this.loadData();
- } catch (e) {
- this.loadStatus = "loadmore";
- }
- },
- async loadData(isRefresh = false) {
- if (isRefresh) {
- this.pageNum = 1;
- this.goodsList = [];
- }
- try {
- this.loadStatus = "loading";
- const pageNum = this.pageNum;
- const pageSize = this.pageSize;
- const params = {
- pageNum,
- pageSize,
- ...this.queryParams,
- };
- const res = await inventoryInquiry(params);
- console.log("res====", res);
- const { rows, total } = res.data;
- const list = rows.map((item) => {
- return {
- ...item,
- src: item.imgName,
- };
- });
- this.goodsList = [...this.goodsList, ...list];
- if (pageNum * pageSize < Number(total)) {
- this.pageNum++;
- this.loadStatus = "loadmore";
- } else {
- this.loadStatus = "nomore";
- }
- } catch (error) {}
- },
- handleSearch() {
- this.loadData(true);
- },
- nodeClick(e) {
- console.log("nodeClick======", e);
- this.queryParams.position = e.value;
- this.loadData(true);
- },
- nodeClick2(e) {
- console.log("nodeClick======", e);
- this.queryParams.categoryId = e.id;
- this.loadData(true);
- },
- tabClick(e) {
- console.log(e);
- this.queryParams.type = e.value;
- this.loadData(true);
- },
- typeClick() {
- let index = this.columnsList[0].findIndex(
- (item) => item == this.typeName
- );
- this.defaultIndex = [index];
- this.typeShow = true;
- },
- pickerConfirm(val) {
- console.log("val===========", val);
- this.typeName = val.value[0];
- if (this.typeName === "按分类展示") {
- this.queryParams.position = "";
- }
- if (this.typeName === "按库位展示") {
- this.queryParams.categoryId = "";
- }
- this.typeShow = false;
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .inventory-page {
- min-height: 100vh;
- background: #f0f6fb;
- .container_main {
- .head-box {
- background-color: #fff;
- }
- .search-box {
- background-color: rgba(191, 200, 219, 0.2);
- margin: 0 32rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- border-radius: 8rpx;
- ::v-deep .u-search__content {
- background-color: transparent !important;
- .u-search__content__input {
- background-color: transparent !important;
- }
- }
- .scan-icon {
- width: 100rpx;
- height: 100%;
- image {
- width: 40rpx;
- height: 40rpx;
- }
- }
- }
- .goods-box {
- margin-top: 24rpx;
- .goods-type {
- display: flex;
- align-items: center;
- padding-left: 24rpx;
- height: 102rpx;
- background-color: #fff;
- &-text {
- color: #0256ff;
- font-size: 28rpx;
- font-weight: bold;
- margin-right: 10rpx;
- }
- }
- .goods-cont {
- display: flex;
- .goods-cont-left {
- width: 160rpx;
- background-color: #f0f6fb;
- .type-item {
- width: 100%;
- height: 84rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- color: #666;
- font-family: "PingFang SC";
- font-size: 28rpx;
- font-weight: 400;
- }
- .active-item {
- background-color: #fff;
- color: #333;
- font-weight: bold;
- }
- }
- .goods-cont-right {
- flex: 1;
- background-color: #fff;
- }
- }
- }
- }
- }
- </style>
|