Files
hazardousWaste_app/pages/components/ChooseList.vue

253 lines
7.2 KiB
Vue
Raw Normal View History

2026-04-03 08:38:34 +08:00
<!-- 仓库/存储区选择 -->
<template>
2026-04-14 08:46:29 +08:00
<navigation :title="isWarehousing.value ? '仓库选择' : '存储区选择'" :back-url="backUrl"></navigation>
<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">
<uni-list-item v-for="item in infoList" :key="item.id" clickable @click="onChecked(item)">
<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>
<span v-if="item?.remark"></span>
<span v-else class="empty">未填写</span>
</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>
<span v-if="item?.remark">{{ item?.remark }}</span>
<span v-else class="empty">未填写</span>
</p>
</view>
</view>
</template>
</uni-list-item>
</uni-list>
</z-paging>
</view>
</template>
<script setup>
2026-04-14 08:46:29 +08:00
import { computed, 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-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-14 08:46:29 +08:00
const backUrl = ref('')
// stockIn 入库单开单 stockIn_Detail入库单编辑 issueUniqueCode唯一码 issueUniqueCode_inbound入库生成唯一码
const keyType = computed(() => pathParams.value.type || pathParams.value.back)
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;
});
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;
});
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-14 08:46:29 +08:00
switch (keyType) {
2026-04-03 08:38:34 +08:00
case 'stockIn':
// 入库单开单
url = '/pages/warehousing/stockIn/create'
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-14 08:46:29 +08:00
const query = objectToQuery(pathParams.value)
backUrl.value = `${url}${query}`
2026-04-03 08:38:34 +08:00
}
// 选择:仓库/存储区
const onChecked = (val) => {
const flag = isWarehousing.value ? 'app_warehousing' : 'app_storageArea'
let infoChecked = uni.getStorageSync(flag);
if (!Array.isArray(infoChecked)) {
infoChecked = [];
}
if (val) {
infoChecked = [{ ...val }]
uni.setStorageSync(flag, infoChecked);
}
// 返回list
2026-04-14 08:46:29 +08:00
uni.navigateTo({
url: backUrl.value
})
2026-04-03 08:38:34 +08:00
}
2026-04-14 08:46:29 +08:00
// 监听:确保 pathParams 变化时一定执行 toBack()
watch(
() => pathParams.value,
(d) => {
console.log('pathParams 变化:', d);
if (!d) return
const type = d.type || d.back;
console.log(type, 'eeeeeee');
toBack(type)
},
{ deep: true, immediate: true }
)
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>