Files
hazardousWaste_app/pages/components/ChooseList.vue

308 lines
9.0 KiB
Vue
Raw Permalink Normal View History

2026-04-03 08:38:34 +08:00
<!-- 仓库/存储区选择 -->
<template>
2026-04-23 14:35:54 +08:00
<navigation :title="title" :back-url="backUrl"></navigation>
2026-04-14 08:46:29 +08:00
<view class="contentBox">
2026-04-03 08:38:34 +08:00
<view class="topSearch">
<uni-easyinput type="text" v-model="queryParams.keyword" prefixIcon="search" :inputBorder="false"
@iconClick="getList" placeholder="请输入搜索内容" />
</view>
<!-- 仓库/存储列表 -->
<z-paging ref="pagingRef" class="containerBox" v-model="infoList" @query="getList">
<uni-list class="listBox">
2026-04-23 14:35:54 +08:00
<uni-list-item v-for="item in infoList" :key="item.id" clickable @tap="onChecked(item)">
2026-04-03 08:38:34 +08:00
<template v-slot:body>
<view style="display: flex; flex-direction: column; width: 100%;" v-if="isWarehousing">
<view class="line title">
<p>仓库名称</p>
<p>{{ item.deptName }}</p>
</view>
<view class="line content">
<p>仓库编码</p>
<p>{{ item.deptId }}</p>
</view>
<!-- todo 以下两个字段pc未维护暂时注释 -->
<!-- <view class=" line content">
<p>仓库类型</p>
<p></p>
</view>
<view class="line content">
<p>仓库位置</p>
<p></p>
</view> -->
<view class="line content">
<p>备注</p>
<p>
2026-04-23 14:35:54 +08:00
<text v-if="item?.remark"></text>
<text v-else class="empty">未填写</text>
2026-04-03 08:38:34 +08:00
</p>
</view>
</view>
<view v-else style="display: flex; flex-direction: column;width: 100%;">
<view class="line title">
<p>{{ item.deptName }} {{ item.deptId }}</p>
</view>
<view class="line content">
<p>
2026-04-23 14:35:54 +08:00
<text v-if="item?.remark">{{ item?.remark }}</text>
<text v-else class="empty">未填写</text>
2026-04-03 08:38:34 +08:00
</p>
</view>
</view>
</template>
</uni-list-item>
</uni-list>
</z-paging>
</view>
</template>
<script setup>
2026-04-23 14:35:54 +08:00
import { ref, toRefs } from 'vue';
2026-04-03 08:38:34 +08:00
import { onShow } from "@dcloudio/uni-app";
2026-04-14 08:46:29 +08:00
import { getWarehousingInfo } from '@/api/system';
2026-04-03 08:38:34 +08:00
import getRepository from "@/api/getRepository";
import { objectToQuery } from '../until';
2026-04-14 08:46:29 +08:00
import Navigation from '../components/Navigation.vue';
import { watch } from 'vue';
2026-04-23 14:35:54 +08:00
const OPERATE_CONFIG = {
materialQuery: {
toCheckUrl: '/pages/warehousing/Declaration/components/materialQueryDetail',
title: '请选择物资查询仓库',
},
inventoryAgeView: {
toCheckUrl: '/pages/warehousing/InventoryInfo/components/inventoryAgeDetail',
title: '请选择物资库龄查询仓库'
},
dailyReport: {
toCheckUrl: '/pages/warehousing/Report/components/dailyDetail',
title: '请选择查看日报表的仓库'
},
monthlyReport: {
toCheckUrl: '/pages/warehousing/Report/components/monthlyDetail',
title: '请选择查看月报表的仓库'
},
warehouseReport: {
toCheckUrl: '/pages/warehousing/Report/components/warehouseDetail',
title: '请选择查看库存的仓库'
},
2026-04-03 08:38:34 +08:00
2026-04-23 14:35:54 +08:00
}
2026-04-03 08:38:34 +08:00
const props = defineProps({
// 是否为仓库查询
isWarehousing: {
type: Boolean,
default: true,
required: true
},
pathParams: {
type: Object,
default: null,
required: false
}
})
2026-04-14 08:46:29 +08:00
const { isWarehousing, pathParams } = toRefs(props)
2026-04-03 08:38:34 +08:00
// 数据:查询关键字
const queryParams = ref({
keyword: ''
})
2026-04-23 14:35:54 +08:00
const title = ref('')
2026-04-14 08:46:29 +08:00
const backUrl = ref('')
2026-04-03 08:38:34 +08:00
// 绑定:加载屏
const pagingRef = ref(null)
// 数据:仓库/存储区
const infoList = ref([])
// 列表判断:获取仓库列表/存储库列表
const getList = () => {
if (isWarehousing.value) {
// 仓库列表
getWarehousing()
} else {
// 存储库列表
getRepositoryInfo()
}
}
// 列表:仓库列表
const getWarehousing = () => {
const userInfo = uni.getStorageSync('app_user')
const params = {
userId: `${userInfo.userId}`,
keyword: queryParams.value.keyword
}
getWarehousingInfo(params).then(res => {
res.data.forEach(e => {
e.showMore = false;
});
2026-04-23 14:35:54 +08:00
infoList.value = res.data
2026-04-03 08:38:34 +08:00
pagingRef.value.complete(res.data)
}).catch(res => {
pagingRef.value.complete(false)
})
}
// 列表:存储区列表
const getRepositoryInfo = async () => {
getRepository({ pageNum: 1, pageSize: 10 }).then(res => {
res.data.forEach(e => {
e.showMore = false;
});
2026-04-23 14:35:54 +08:00
infoList.value = res.data
2026-04-03 08:38:34 +08:00
pagingRef.value.complete(res.data)
}).catch(res => {
pagingRef.value.complete(false)
})
}
// 返回路径
2026-04-14 08:46:29 +08:00
const toBack = (keyType) => {
console.log('监听', keyType);
2026-04-03 08:38:34 +08:00
let url = ''
2026-04-23 14:35:54 +08:00
let query = objectToQuery(pathParams.value)
2026-04-14 08:46:29 +08:00
switch (keyType) {
2026-04-03 08:38:34 +08:00
case 'stockIn':
// 入库单开单
url = '/pages/warehousing/stockIn/create'
2026-04-23 14:35:54 +08:00
2026-04-03 08:38:34 +08:00
break;
case 'stockOut':
// 出库单开单
2026-04-14 08:46:29 +08:00
url = '/pages/warehousing/stockOut/create'
break;
case 'stockOut-outbound':
// 出库单出库
url = '/pages/warehousing/stockOut/components/outAway'
2026-04-03 08:38:34 +08:00
break;
2026-04-23 14:35:54 +08:00
case 'my':
// 出库单出库
url = '/pages/warehousing/stockIn/create'
break;
case 'materialQuery':
// 物资查询
url = 'pages/warehousing/index'
query = ''
break;
case 'inventoryAgeView':
// 库龄
url = 'pages/warehousing/index'
query = ''
break;
case 'dailyReport':
// 日报
query = ''
url = 'pages/warehousing/index'
break;
case 'monthlyReport':
// 月报
query = ''
url = 'pages/warehousing/index'
break;
default:
url = 'pages/warehousing/index';
query = '';
break;
2026-04-03 08:38:34 +08:00
}
2026-04-23 14:35:54 +08:00
backUrl.value = query ? `${url}${query}` : url
2026-04-14 08:46:29 +08:00
2026-04-03 08:38:34 +08:00
}
// 选择:仓库/存储区
const onChecked = (val) => {
2026-04-23 14:35:54 +08:00
const toUrl = OPERATE_CONFIG?.[pathParams.value?.type]?.toCheckUrl;
let params = val.materialId ? { warehouseCode: val.deptId, materialId: val.materialId } : { warehouseCode: val.deptId }
if (pathParams.value.type === 'warehouseReport') {
params.title = val.deptName
}
const query = objectToQuery(params);
if (toUrl) {
uni.navigateTo({ url: toUrl + query });
return;
2026-04-03 08:38:34 +08:00
}
2026-04-23 14:35:54 +08:00
const flag = isWarehousing.value ? "app_warehousing" : "app_storageArea";
let infoChecked = uni.getStorageSync(flag) || [];
if (!Array.isArray(infoChecked)) infoChecked = [];
2026-04-03 08:38:34 +08:00
if (val) {
2026-04-23 14:35:54 +08:00
infoChecked = [{ ...val }];
2026-04-03 08:38:34 +08:00
uni.setStorageSync(flag, infoChecked);
}
2026-04-23 14:35:54 +08:00
uni.navigateTo({ url: backUrl.value });
};
2026-04-14 08:46:29 +08:00
watch(
() => pathParams.value,
(d) => {
2026-04-23 14:35:54 +08:00
if (!d) return;
2026-04-14 08:46:29 +08:00
const type = d.type || d.back;
2026-04-23 14:35:54 +08:00
const titleStr = OPERATE_CONFIG?.[d.type]?.title;
if (titleStr) {
title.value = titleStr;
} else {
title.value = isWarehousing.value ? "仓库选择" : "存储区选择";
}
toBack(type);
2026-04-14 08:46:29 +08:00
},
{ deep: true, immediate: true }
2026-04-23 14:35:54 +08:00
);
2026-04-03 08:38:34 +08:00
onShow(() => {
pagingRef.value?.reload?.()
})
</script>
<style scoped lang="scss">
.topSearch {
position: fixed;
2026-04-14 08:46:29 +08:00
top: 65rpx;
2026-04-03 08:38:34 +08:00
left: 0;
right: 0;
z-index: 999;
padding: 4rpx;
background-color: #fff;
border-bottom: 1px solid #eee;
box-sizing: border-box;
}
.containerBox {
2026-04-14 08:46:29 +08:00
padding-top: 120rpx !important;
2026-04-03 08:38:34 +08:00
width: 100%;
height: 100%;
box-sizing: border-box;
.zp-l-text-rpx {
font-size: 12px;
}
}
::v-deep.listBox {
2026-04-14 08:46:29 +08:00
background-color: #F8F8FF;
2026-04-03 08:38:34 +08:00
.uni-list-item {
2026-04-14 08:46:29 +08:00
margin-bottom: 8rpx;
2026-04-03 08:38:34 +08:00
}
.uni-list-item__container {
padding: 0;
}
.line {
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #eee;
padding: 12rpx;
}
.title {
font-weight: 600;
font-size: 14px;
}
.content {
font-weight: 500;
font-size: 13px;
}
.empty {
color: #D3D3D3;
}
}
</style>