| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593 |
- <template>
- <view class="page">
- <view class="page-container">
- <u-navbar class="nav-bar" title="库存管理" :autoBack="true" :placeholder="true" v-hideNav></u-navbar>
- <!-- 总资产成本区域 -->
- <view class="asset-header">
- <view class="asset-text-wrap">
- <view class="asset-title-con">
- <view class="asset-title">总资产成本(元)</view>
- <u-icon name="question-circle" size="14" color="#999999"></u-icon>
- </view>
- <text class="asset-value">{{ wareHouseCard.totalCost }}</text>
- </view>
- <view class="btn-group">
- <u-button v-if="isAdmin" type="primary" shape="circle" plain size="mini"
- @click="navigateToFieldPermissions">字段权限</u-button>
- <u-button type="success" shape="circle" plain size="mini" @click="openOrderList">开单记录</u-button>
- <order-list ref="orderListRef"></order-list>
- <u-button type="primary" shape="circle" plain size="mini"
- @click="navigateToFakeRegistration">假货登记</u-button>
- </view>
- </view>
- <view class="data-cards">
- <view class="card-item">
- <text class="card-label">今日上传</text>
- <text class="card-value">{{ wareHouseCard.uploadCostToday }}</text>
- </view>
- <view class="card-item">
- <text class="card-label">今日下架</text>
- <text class="card-value green">{{ wareHouseCard.outStockToday }}</text>
- </view>
- <view class="card-item">
- <text class="card-label">商品总数</text>
- <text class="card-value">{{ wareHouseCard.totalNum }}</text>
- </view>
- </view>
- <view class="search-wrapper">
- <u-search placeholder="搜索编号、名称、品牌..." v-model="searchString" bg-color="#f9fafb" border-radius="4rpx"
- :show-action="false" class="search-input-wrap" showAction @clear="handleSearch"
- @custom="handleSearch"></u-search>
- </view>
- <view class="category-tabs-wrap">
- <u-tabs :list="tabList" :is-scroll="true" active-color="#007aff" inactive-color="#666666"
- font-size="28rpx" keyName="dictLabel" border-bottom="none" @change="switchTab"
- class="u-tabs-custom"></u-tabs>
- </view>
- <view class="filter-bar">
- <view class="sort-btn" @click="sortPickerShow = true">
- <text class="sort-text">{{ curSortType.label }}</text>
- <u-icon name="arrow-down" size="12" color="#666666" class="sort-icon"></u-icon>
- <u-picker :show="sortPickerShow" :columns="sortColumns" keyName="label" @confirm="handleSortChange"
- @cancel="sortPickerShow = false"></u-picker>
- </view>
- <view class="price-layout-btn">
- <view class="price-btn" type="text" @click="priceVisibleChange">
- <u-icon :name="priceVisible ? 'eye' : 'eye-off'" size="18" color="#1890ff"
- class="price-icon"></u-icon>
- <text class="price-text">价格可见</text>
- </view>
- <view class="dept-btn" @click="recycleDeptClick">
- <view class="dept-name" v-if="deptName">
- {{ deptName }}
- </view>
- <image src="/static/icons/dept.png" mode="aspectFill"></image>
- </view>
- <ba-tree-picker :selectParent="true" ref="recycleDeptRef" :multiple='false'
- @select-change="deptSeletchang" border title="机构部门" :localdata="deptList" valueKey="deptId"
- textKey="deptName" childrenKey="children" :selectedValues="deptId" :personNames="deptName" />
- <view class="layout-btn" type="text" size="mini" @click="openSearchFilter">
- <image class="filter-icon" src="/static/icons/select.png" mode="aspectFill"></image>
- 筛选
- <!-- <u-icon name="grid" size="20" color="#666666"></u-icon> -->
- <!-- 筛选列 品牌、价格范围、位置、回收时间、回收人员、鉴定人员、商品属性 -->
- </view>
- <searchFilter ref="searchFilter" @confirm="handleSearch"></searchFilter>
- </view>
- </view>
- <u-notice-bar class="custom-notice-bar" icon="" :text="selectText" mode="closable"
- speed="40"></u-notice-bar>
- <scroll-view ref="scrollView" class="goods-list" scroll-y @scrolltolower="handleLoadMore"
- @scroll="handleScroll" enable-back-to-top>
- <view @click.stop="clickItem(goods)" class="goods-item" v-for="(goods, goodsIndex) in goodsList"
- :key="`goods-${goodsIndex}`">
- <u-swipe-action ref="swipeRef">
- <u-swipe-action-item :options="swipeOptions"
- @click="(e) => handleSwipeClick(e, goods, goodsIndex)">
- <view class="goods-info">
- <view class="goods-img-container"
- v-if="getWarehouseFieldPermissions('goodPicFileList', 'read')">
- <image class="goods-img" :src="goods.imgUrl ? goods.imgUrl : '/static/no-img.png'"
- mode="aspectFill" lazy-load></image>
- <!-- <image class="goods-img" src="/static/no-img.png" mode="aspectFill" lazy-load></image> -->
- <view
- :class="['stock-indicator', goods.downStatus == '1' ? 'up-indicator' : 'down-indicator']">
- </view>
- </view>
- <view class="info-content">
- <view class="goods-brand">
- <view v-if="getWarehouseFieldPermissions('dictLabel', 'read')">
- {{ goods.dictLabel || '-' }}
- </view>
- <!-- <image v-if="goods.indentifyCode" src="../../static/icons/code.png"
- class="code-icon" mode="aspectFill" lazy-load></image>
- <view>
- {{ goods.indentifyCode || '' }}
- </view> -->
- </view>
- <text class="goods-name" v-if="getWarehouseFieldPermissions('model', 'read')">型号:{{
- goods.model || '-' }}</text>
- <text class="goods-name"
- v-if="getWarehouseFieldPermissions('indentifyCode', 'read')">编码:{{
- goods.indentifyCode || '-' }}</text>
- <view class="price-group">
- <view class="price-item"
- v-if="getWarehouseFieldPermissions('costPrice', 'read')">
- <text class="price-type">成本价</text>
- <text class="price">¥{{ priceVisible ? goods.costPrice || '-' : '****'
- }}</text>
- </view>
- <view class="price-item"
- v-if="getWarehouseFieldPermissions('salePrice', 'read')">
- <text class="price-type">销售价</text>
- <text class="price sales">¥{{ priceVisible ? goods.salePrice || '-' : '****'
- }}</text>
- </view>
- <view class="price-item"
- v-if="getWarehouseFieldPermissions('peerPrice', 'read')">
- <text class="price-type">同行价</text>
- <text class="price">¥{{ priceVisible ? goods.peerPrice || '-' : '****'
- }}</text>
- </view>
- <view class="price-item"
- v-if="getWarehouseFieldPermissions('agentPrice', 'read')">
- <text class="price-type">代理价</text>
- <text class="price">¥{{ priceVisible ? goods.agentPrice || '-' : '****'
- }}</text>
- </view>
- <view class="price-item"
- v-if="getWarehouseFieldPermissions('actualPrice', 'read')">
- <text class="price-type">实价</text>
- <text class="price">¥{{ priceVisible ? goods.actualPrice || '-' : '****'
- }}</text>
- </view>
- <view class="price-item" v-if="getWarehouseFieldPermissions('price', 'read')">
- <text class="price-type">指导价</text>
- <text class="price">¥{{ priceVisible ? goods.price || '-' : '****' }}</text>
- </view>
- </view>
- <!-- <view class="others">
- <view class="other-item stock" >得</view>
- <view class="other-item">得</view>
- <view class="other-item">得</view>
- </view> -->
- </view>
- <view class="more">
- <view @click.stop="showMoreOptions(goods)">
- <u-icon name="more-dot-fill" size="16" color="#666666"></u-icon>
- </view>
- <text class="goods-stock" v-if="getWarehouseFieldPermissions('stock', 'read')">数量:{{
- goods.stock || 0 }}</text>
- </view>
- </view>
- <!-- 更多信息区域 -->
- <view class="more-info-container">
- <view class="more-info-header" @click.stop="toggleMoreInfo(goods)">
- <text class="more-info-title">更多信息</text>
- <u-icon :name="goods.showMoreInfo ? 'arrow-up' : 'arrow-down'" size="14"
- color="#666666"></u-icon>
- </view>
- <transition name="more-info">
- <view class="more-info-content" v-if="goods.showMoreInfo">
- <view class="info-row"
- v-if="getWarehouseFieldPermissions('recycleTime', 'read')">
- <text class="info-label">回收时间:</text>
- <text class="info-value">{{ formatterTime(goods.recycleTime) }}</text>
- </view>
- <view class="info-row"
- v-if="getWarehouseFieldPermissions('warehouseDate', 'read')">
- <text class="info-label">入库时间:</text>
- <text class="info-value">{{ formatterTime(goods.warehouseDate) }}</text>
- </view>
- <view class="info-row"
- v-if="getWarehouseFieldPermissions('productPosition', 'read')">
- <text class="info-label">商品位置:</text>
- <text class="info-value">{{ goods.productPosition || '-' }}</text>
- </view>
- <view class="info-row"
- v-if="getWarehouseFieldPermissions('identifyingPerson', 'read')">
- <text class="info-label">鉴定人员:</text>
- <text class="info-value">{{ goods.identifyingPerson || '-' }}</text>
- </view>
- <view class="info-row"
- v-if="getWarehouseFieldPermissions('recyclePerson', 'read')">
- <text class="info-label">回收人员:</text>
- <text class="info-value">{{ goods.recyclePerson || '-' }}</text>
- </view>
- <view class="info-row"
- v-if="getWarehouseFieldPermissions('stockStatus', 'read')">
- <text class="info-label">是否入库:</text>
- <text class="info-value">{{ goods.stockStatus == '1' ? '已入库' : '未入库'
- }}</text>
- </view>
- <view class="info-row" v-if="getWarehouseFieldPermissions('payType', 'read')">
- <text class="info-label">付款方式:</text>
- <text class="info-value">{{ payFormatter(goods.payType) }}</text>
- </view>
- </view>
- </transition>
- </view>
- </u-swipe-action-item>
- </u-swipe-action>
- </view>
- </scroll-view>
- </view>
- <!-- 添加按钮 -->
- <view class="add-button" @click="handleEdit">
- <u-icon name="plus" size="36" color="#ffffff"></u-icon>
- </view>
- <moreInfo ref="moreInfoRef" :moreOptions="moreOptions" @confirm="handleMoreInfoConfirm"></moreInfo>
- </view>
- </template>
- <script>
- import searchFilter from './components/searchFilter.vue'
- import moreInfo from './components/moreInfo.vue'
- import { getWarehouseButtonPermissions, getWarehouseFieldPermissions,getRoles } from '../../utils/util.js'
- import orderList from './components/orderList/index.vue'
- import { paymentTabList,productAttributeList } from './js/public.js'
- import jtimePickerPopup from '@/uni_modules/jtime-picker-popup/components/JTimePicker/JTimePicker.vue';
- export default {
- components: {
- searchFilter,
- moreInfo,
- orderList,
- jtimePickerPopup
- },
- computed: {
- isAdmin() {
- return getRoles().some(v => v.includes('admin' || 'ADMIN'))
- }
- },
- data() {
- return {
- searchString: '',//搜索编号、名称、品牌...
- type: '',
- searchInfo: {},
- pageNum: 1,
- pageSize: 10,
- curSortType: {
- id: 4,
- label: '按入库最新',
- },
- wareHouseCard: {
- totalCost: '-',
- uploadCostToday: '-',
- outStockToday: '-',
- totalNum: '-'
- },
- tabList: [],
- goodsList: [
- // {
- // id:'123456754',//商品库存id
- // name:'Rolex',//商品名称
- // model:'Submariner Date 126610LN',//型号
- // costPrice:'12345',//成本价格
- // salesPrice:'12345',//销售价格
- // peerPrice:'12345',//同行价格
- // agentPrice:'12345',//代理价格
- // stock:'12345',//库存数量
- // imgUrl:'https://xiaohulu-crm.oss-cn-shanghai.aliyuncs.com/crm/2026/01/06/1767677335839-1767677330379.jpg',//商品图片
- // platform:[]//同步平台,此功能暂时不做,先定义一个字段
- // }
- ],
- sortPickerShow: false,
- sortColumns: [[
- {
- label: '按最久未下载',
- id: 1
- },
- {
- label: '按最近更新',
- id: 2
- },
- {
- label: '按最久更新',
- id: 3
- },
- {
- label: '按入库最新',
- id: 4
- },
- {
- label: '按入库最久',
- id: 5
- },
- {
- label: '按价格最高',
- id: 6
- },
- {
- label: '按价格最低',
- id: 7
- },
- ]],
- priceVisible: true,
- searchPopShow: false,
- total: 0,
- moreOptions: {},
- moreOptionsShow: false,
- swipeOptions: [
- {
- text: '删除',
- style: {
- backgroundColor: '#f56c6c'
- }
- },
- ],
- isSwipeClick: false,
- deptList: [],
- deptId: '',
- deptName: '',
- // 保存页面状态
- pageState: {
- pageNum: 1,
- goodsList: [],
- total: 0,
- scrollTop: 0
- },
- paymentTabList: paymentTabList,
- productAttributeList: productAttributeList,
- selectText: '暂无筛选条件'
- };
- },
- onLoad() {
- this.getTypeList();
- },
- methods: {
- toggleMoreInfo(goods) {
- this.$set(goods, 'showMoreInfo', !goods.showMoreInfo);
- },
- formatterTime(time) {
- if (!time) {
- return '-'
- }
- return this.$dayjs(time).format('YYYY-MM-DD')
- },
- payFormatter(payType) {
- return paymentTabList.find(item => item.value == payType)?.name || '-'
- },
- getDeptListAll() {
- const params = {
- isDept: 2
- }
- uni.$u.api.getDeptListAll(params).then(res => {
- if (res.data.length > 0) {
- this.deptList = res.data;
- } else {
- uni.$u.toast('暂无机构部门');
- }
- })
- },
- deptSeletchang(ids, names) {
- this.deptId = ids[0] || '';
- this.deptName = names[0] || '';
- this.handleSearch();
- },
- recycleDeptClick() {
- this.getDeptListAll();
- this.$refs.recycleDeptRef._show();
- },
- showMoreOptions(goods) {
- this.moreOptions = goods;
- this.$refs.moreInfoRef.showMoreInfo();
- },
- getWarehouseFieldPermissions,
- getWarehouseButtonPermissions,
- handleMoreInfoConfirm() {
- this.$refs.moreInfoRef.closeModal();
- },
- getTypeList() {
- this.$getDicts("crm_form_category").then(res => {
- this.tabList = [...res]
- this.tabList.unshift({ dictLabel: "全部", dictValue: '' })
- })
- },
- getList() {
- uni.$u.api.wareHouseList({
- pageNum: this.pageNum,
- pageSize: this.pageSize,
- },
- {
- searchString: this.searchString,
- sortType: this.curSortType.id,
- type: this.type,
- deptId: this.deptId,
- deptName: this.deptName,
- ...this.searchInfo
- }).then(res => {
- if (this.pageNum == 1) {
- this.goodsList = res.rows;
- } else {
- this.goodsList = this.goodsList.concat(res.rows);
- }
- this.total = res.total;
- });
- },
- // 加载更多
- handleLoadMore() {
- console.log("加载更多");
- if (this.goodsList.length >= this.total) {
- uni.$u.toast("没有更多了");
- return;
- }
- this.pageNum++;
- this.getList();
- },
- handleSearch(info) {
- this.pageNum = 1;
- this.searchInfo = info;
- this.goodsList = [];
- this.selectText = `品牌:${this.searchInfo?.dictLabel || '暂无'}、实价范围:${this.searchInfo?.minPrice || '暂无'} - ${this.searchInfo?.maxPrice || '暂无'}、位置:${this.searchInfo?.location || '暂无'}、开始回收时间:${this.searchInfo?.startTime || '暂无'}、结束回收时间:${this.searchInfo?.endTime || '暂无'}、回收人员:${this.searchInfo?.recyclePerson || '暂无'}、鉴定人员:${this.searchInfo?.identifyingPerson || '暂无'}、商品属性:${this.formatterProductAttribute(this.searchInfo?.productAttribute) || '暂无'}、是否入库:${this.formatterStockStatus(this.searchInfo?.stockStatus)}`
- this.getList();
- },
- formatterProductAttribute(attr) {
- if (!attr || attr.length == 0) {
- return '暂无'
- }
- return attr.map(a => this.productAttributeList.find(b => b.value == a))?.map(item => item.name).join(' ') || '暂无'
- },
- formatterStockStatus(status) {
- if (!status) {
- return '全部'
- }
- return status == '0' ? '待入库' : '已入库'
- },
- switchTab(item) {
- this.type = item.dictValue;
- this.handleSearch();
- },
- clickItem(item) {
- if (this.isSwipeClick) {
- this.isSwipeClick = false;
- return;
- }
- // 如果是待入库商品,点击后跳转到添加页面补全信息
- if (item.stockStatus == '0') {
- this.handleEdit(item)
- } else {
- this.handleToDetail(item);
- }
- },
- handleSwipeClick(e, item, goodsIndex) {
- if (e.index == 0) {//删除
- this.isSwipeClick = true;
- if (!this.getWarehouseButtonPermissions('delete')) return false
- uni.$u.api.wareHouseDelete({
- id: item.id
- }).then(() => {
- this.$refs.swipeRef[goodsIndex].closeOther()
- uni.$u.toast("删除成功");
- this.handleSearch();
- }).catch((err) => {
- uni.$u.toast(err);
- });
- }
- },
- handleToDetail(item) {
- uni.navigateTo({
- url: `/pages/wareHouse/components/detail?id=${item.id}`,
- });
- },
- handleEdit(item) {
- if (item.id) {
- uni.navigateTo({
- url: `/pages/wareHouse/components/edit?formType=edit&id=${item.id}`
- });
- } else {
- uni.navigateTo({
- url: `/pages/wareHouse/components/edit?formType=add`
- });
- }
- },
- // 获取仓库卡片数据
- getCard() {
- uni.$u.api.getWareHouseCard({ userId: this.$store.state.user.userInfo.userId }).then(res => {
- if (res.code === 200) {
- this.wareHouseCard = res.data;
- }
- });
- },
- handleSortChange(e) {
- this.curSortType = e.value[0];
- this.sortPickerShow = false;
- this.handleSearch();
- },
- priceVisibleChange() {
- this.priceVisible = !this.priceVisible;
- },
- openSearchFilter() {
- this.$refs.searchFilter.open();
- },
- navigateToFakeRegistration() {
- uni.navigateTo({
- url: '/pages/wareHouse/components/fakeRegistration',
- });
- },
- openOrderList() {
- this.$refs.orderListRef.openList();
- },
- navigateToFieldPermissions() {
- uni.navigateTo({
- url: '/pages/wareHouse/components/fieldPermissions',
- });
- },
- handleScroll(e) {
- this.pageState.scrollTop = e.detail.scrollTop;
- },
- // 保存当前页面状态
- savePageState() {
- this.pageState.pageNum = this.pageNum;
- this.pageState.goodsList = [...this.goodsList];
- this.pageState.total = this.total;
- },
- // 恢复页面状态
- restorePageState() {
- if (this.pageState.goodsList.length > 0) {
- this.pageNum = this.pageState.pageNum;
- this.goodsList = [...this.pageState.goodsList];
- this.total = this.pageState.total;
- this.$nextTick(() => {
- if (this.pageState.scrollTop > 0) {
- if (this.$refs.scrollView) {
- setTimeout(() => {
- try {
- this.$refs.scrollView.$el.scrollTop = this.pageState.scrollTop;
- } catch (e) {
- console.log('设置滚动位置失败:', e);
- }
- }, 100);
- }
- }
- });
- return true;
- }
- return false;
- },
- },
- onShow() {
- // 尝试恢复页面状态
- if (!this.restorePageState()) {
- // 如果没有保存的状态,重新加载第一页
- this.pageNum = 1;
- this.getList();
- }
- this.getCard();
- // 监听数据更新事件
- this.updateListener = uni.$on('warehouse-data-updated', () => {
- // 重新加载数据
- this.pageNum = 1;
- this.getList();
- this.getCard();
- });
- },
- onHide() {
- // 页面隐藏时保存状态
- this.savePageState();
- // 移除事件监听器
- if (this.updateListener) {
- uni.$off('warehouse-data-updated', null);
- }
- },
- onPullDownRefresh() {
- this.pageNum = 1;
- this.getList();
- this.getCard();
- uni.stopPullDownRefresh();
- },
- };
- </script>
- <style lang="scss" scoped>
- @import "./styles/index.scss";
- </style>
|