651 lines
14 KiB
Vue
Raw Normal View History

2025-04-14 10:57:27 +08:00
<template>
2025-07-08 10:04:47 +08:00
<z-paging
ref="paging"
v-model="listdata"
@query="loadMoreData"
:default-page-no="1"
2025-08-20 10:49:57 +08:00
:default-page-size="10"
2025-07-08 10:04:47 +08:00
:auto-show-back-to-top="true"
2025-07-10 14:43:10 +08:00
:paging-style="{
2025-10-10 11:24:23 +08:00
'background-color': '#f3f4f6',
2025-07-10 14:43:10 +08:00
}"
2025-07-08 10:04:47 +08:00
>
2025-10-10 11:24:23 +08:00
<!-- 顶部 -->
2025-07-08 10:04:47 +08:00
<template #top>
2025-07-10 14:43:10 +08:00
<view class="flex" style="background-color: white">
2025-07-08 10:04:47 +08:00
<view class="search">
<uni-search-bar
radius="5"
placeholder="输入车辆编号查询"
v-model="bikeCodeValue"
@blur="searchInfo"
@confirm="searchInfo"
@clear="searchInfo"
/>
</view>
<view class="searchmore" @click="showDrawer('showRight')">
<image :src="`${imgPath}static/image/更多.png`" alt="" />
</view>
</view>
2025-10-10 11:24:23 +08:00
<z-tabs ref="tabs" :list="tabList" @change="tabChange" />
2025-07-08 10:04:47 +08:00
</template>
2025-10-10 11:24:23 +08:00
2025-07-08 10:04:47 +08:00
<view class="container">
<checkbox-group @change="checkboxGroupChange">
<view v-for="(item, index) in listdata" :key="index" class="list-item">
<view class="flex list-title" @click="opendetail(item.bikeId)">
2025-10-10 11:24:23 +08:00
<checkbox
:value="item.bikeCode"
@click.stop
:checked="item.checked"
></checkbox>
2025-07-08 10:04:47 +08:00
<view
v-if="item.state == 1 && item.stateName == '待投放'"
class="title-xz"
>
</view>
<view class="title-wz">
{{ item.bikeCode }}
</view>
<view v-if="item.state == 1" class="title-zt">
2025-10-10 11:24:23 +08:00
<view v-if="item.stateName == '投放中'" class="cu-tag bg-blue sm">
{{ item.stateName }}
</view>
<view v-else class="cu-tag bg-orange sm">
{{ item.stateName }}
</view>
2025-07-08 10:04:47 +08:00
</view>
<view v-else class="title-zt">
<view class="cu-tag bg-green sm">{{ item.stateName }}</view>
</view>
</view>
<view class="flex row">
<view class="list-name"> 车辆编号 </view>
<view class="list-value">
{{ item.bikeCode }}
</view>
</view>
<view class="flex row">
<view class="list-name"> 车辆型号 </view>
<view class="list-value">
{{ item.bikeModel }}
</view>
</view>
<view class="flex row">
<view class="list-name"> 入库时间 </view>
<view class="list-value">
{{ item.enterTime }}
</view>
</view>
</view>
</checkbox-group>
2025-10-10 11:24:23 +08:00
<view style="width: 100%; height: 100rpx"></view>
2025-07-08 10:04:47 +08:00
</view>
2025-10-10 11:24:23 +08:00
<!-- 底部 -->
2025-07-08 10:04:47 +08:00
<template #bottom>
<view class="nav-panel">
2025-10-10 11:24:23 +08:00
<button
v-if="statevalue === '1'"
class="fancy-btn"
@click="
handleBtn({
tip: '请选择需要批量投放的车辆',
status: 2,
})
"
>
批量投放
</button>
<button
v-if="statevalue === '2'"
class="fancy-btn"
@click="
handleBtn({
tip: '请选择需要批量下架的车辆',
status: 0,
})
"
>
批量下架
</button>
2025-07-08 10:04:47 +08:00
</view>
</template>
</z-paging>
2025-10-10 11:24:23 +08:00
<!-- 筛选 -->
<uni-drawer ref="showRight" mode="right" :mask-click="false" :width="320">
<uni-nav-bar
left-icon="left"
leftText="返回"
title="筛选"
@clickLeft="closeDrawer('showRight')"
/>
<uni-section title="入库时间" type="line">
<view style="width: 100%; padding: 0 20px">
<uni-datetime-picker type="date" v-model="enterTime" />
</view>
</uni-section>
2025-07-08 10:04:47 +08:00
</uni-drawer>
2025-10-10 11:24:23 +08:00
<!-- 普通弹窗 -->
<uni-popup ref="popup" background-color="#fff" @change="changepopup">
<view
class="popup-content"
:class="{
'popup-height': typepopup === 'left' || typepopup === 'right',
}"
>
<view class="padding plcrk">
<uni-forms
ref="customForm"
:rules="customRules"
:modelValue="customFormData"
>
<uni-section v-if="statusZT == 2" title="站点" type="line">
<uni-forms-item required name="reginvalue">
<uni-data-select
v-model="customFormData.reginvalue"
:localdata="regindata"
@change="changeZT"
></uni-data-select>
</uni-forms-item>
</uni-section>
<uni-section title="请添加设备" type="line">
<uni-forms-item required name="deviceValues">
<uni-easyinput
type="textarea"
v-model="customFormData.deviceValues"
placeholder="请输入车辆编号,用逗号()隔开一次最多添加1000个"
/>
</uni-forms-item>
</uni-section>
</uni-forms>
<button
style="width: 100%"
@click="submit"
:disabled="isSubmit"
:loading="isSubmit"
size="mini"
>
提交
</button>
2025-07-08 10:04:47 +08:00
</view>
2025-10-10 11:24:23 +08:00
</view>
</uni-popup>
2025-04-14 10:57:27 +08:00
</template>
<script setup>
2025-07-08 10:04:47 +08:00
import { ref, onMounted } from "vue";
import * as api from "@/utils/api.js";
import config from "@/utils/config";
import { stringToArray } from "@/utils/tools";
2025-10-10 11:24:23 +08:00
import { onShow, onUnload } from "@dcloudio/uni-app";
const paging = ref(null);
const tabs = ref(null);
2025-07-08 10:04:47 +08:00
const imgPath = config.imgPath;
2025-10-10 11:24:23 +08:00
const tabList = ref([
{ name: "待投放", value: "1" },
{ name: "投放中", value: "2" },
]);
2025-07-08 10:04:47 +08:00
const listdata = ref([]);
2025-10-10 11:24:23 +08:00
// 查询条件定义
const bikeCodeValue = ref(""); //车辆编号
const statevalue = ref("1"); //状态
const enterTime = ref(""); //入库时间
// 创建 drawer 的 ref 引用
const showRight = ref(null);
// 多选框选中值
const checkboxValue = ref([]);
// 处理 popup
2025-07-08 10:04:47 +08:00
const popup = ref(null);
const typepopup = ref("center");
//提交表单相关信息
const customForm = ref(null);
const customFormData = ref({
reginvalue: "",
deviceValues: "",
});
// 校验规则
const customRules = ref({
reginvalue: {
rules: [
{
required: true,
errorMessage: "站点信息不能为空",
trigger: "blur",
},
],
},
deviceValues: {
rules: [
{
required: true,
errorMessage: "车辆编号不能为空!",
trigger: "blur",
},
],
},
});
2025-10-10 11:24:23 +08:00
const statusZT = ref(1);
2025-07-08 10:04:47 +08:00
2025-10-10 11:24:23 +08:00
//运营区域下拉值 和列表
const regindata = ref([]);
// 提交按钮状态
const isSubmit = ref(false);
// 数据加载
function loadMoreData(pageNo, pageSize) {
uni.showLoading({
title: "加载中...",
mask: true,
});
const params = {
bikeCode: bikeCodeValue.value, //车辆编号
enterTime: enterTime.value, //入库时间 例2025-03-21
state: statevalue.value,
pageParam: {
pageNum: pageNo,
pageSize: pageSize,
},
};
2025-07-08 10:04:47 +08:00
api
2025-10-10 11:24:23 +08:00
.callEbikeInfo("getOperationalBikeList", params)
2025-07-08 10:04:47 +08:00
.then((res) => {
2025-10-10 11:24:23 +08:00
uni.hideLoading();
if (res.code === 200) {
let records = res.data.records;
records = records.map((item) => {
item.checked = checkboxValue.value.includes(item.bikeCode);
return item;
2025-07-08 10:04:47 +08:00
});
2025-10-10 11:24:23 +08:00
paging.value.complete(records);
} else {
paging.value.complete(false);
2025-07-08 10:04:47 +08:00
}
2025-10-10 11:24:23 +08:00
})
.catch((err) => {
uni.hideLoading();
console.error("加载数据失败:", err);
paging.value.complete(false);
2025-07-08 10:04:47 +08:00
});
2025-10-10 11:24:23 +08:00
}
2025-07-08 10:04:47 +08:00
2025-10-10 11:24:23 +08:00
//搜索
const searchInfo = () => {
paging.value.reload();
};
// tab切换
const tabChange = (index) => {
statevalue.value = tabList.value[index].value;
checkboxValue.value = [];
listdata.value = []; // 清空数据
paging.value.refresh();
2025-07-08 10:04:47 +08:00
};
2025-10-10 11:24:23 +08:00
2025-07-08 10:04:47 +08:00
const checkboxGroupChange = (e) => {
2025-10-10 11:24:23 +08:00
const { value } = e.detail;
checkboxValue.value = value;
};
// 打开窗口
const showDrawer = (e) => {
const drawer = showRight.value;
drawer.open();
};
// 关闭窗口
const closeDrawer = (e) => {
const drawer = showRight.value;
drawer.close();
searchInfo();
2025-07-08 10:04:47 +08:00
};
2025-10-10 11:24:23 +08:00
// 打开详情
2025-07-08 10:04:47 +08:00
const opendetail = (id) => {
setTimeout(() => {
uni.navigateTo({
url: `/pages/warehouse/ebikehouse/vehicleoperation_view?ebikeId_zcck=${id}`, //
});
}, 200); // 延迟100毫秒后执行
};
2025-10-10 11:24:23 +08:00
// 处理弹窗关闭事件
const changepopup = (e) => {
const { show } = e;
if (!show) {
customFormData.value = {
reginvalue: "",
deviceValues: "",
};
}
2025-07-08 10:04:47 +08:00
};
2025-10-10 11:24:23 +08:00
// 处理按钮点击事件
const handleBtn = ({ tip, status }) => {
if (checkboxValue.value.length === 0) {
uni.showToast({
title: tip,
icon: "none",
2025-07-08 10:04:47 +08:00
});
2025-10-10 11:24:23 +08:00
return;
}
customFormData.value.deviceValues = checkboxValue.value.join(",");
statusZT.value = status;
popup.value.open("center");
};
const changeZT = (e) => {
console.log("e:", e);
2025-07-08 10:04:47 +08:00
};
// 处理下架逻辑
const handleLeaveWarehouse = () => {
2025-08-08 09:22:47 +08:00
isSubmit.value = true; // 设置提交状态为加载中
2025-07-08 10:04:47 +08:00
const params = {
2025-08-20 10:49:57 +08:00
bikeCode: stringToArray(customFormData.value.deviceValues, ""), // 车辆编号
2025-07-08 10:04:47 +08:00
status: statusZT.value,
reginId: "",
};
2025-08-12 11:45:30 +08:00
console.log(params);
2025-07-08 10:04:47 +08:00
api.callEbikeInfo("vehicleLeaveWarehouse", params).then((res) => {
2025-08-08 09:22:47 +08:00
isSubmit.value = false;
2025-07-08 10:04:47 +08:00
if (res.code == 200) {
popup.value.close("center");
uni.showToast({
title: "操作成功",
icon: "success",
duration: 2000,
});
searchInfo();
} else {
uni.showToast({
2025-08-12 11:45:30 +08:00
title: res.message || "操作失败",
icon: "none",
2025-07-08 10:04:47 +08:00
duration: 2000,
});
}
});
};
// 处理投放逻辑
const handleLaunch = () => {
// 在这里编写投放的具体逻辑
console.log("投放逻辑执行");
2025-08-08 09:22:47 +08:00
isSubmit.value = true;
2025-07-08 10:04:47 +08:00
const params = {
bikeCodes: stringToArray(customFormData.value.deviceValues, ""), // 车辆编号
status: statusZT.value,
siteId: customFormData.value.reginvalue,
dispatchType: "仓库车调度",
};
console.log(params);
// 例如调用API处理投放
api.callEbikeInfo("createWorkOrderDispatch", params).then((res) => {
2025-08-08 09:22:47 +08:00
isSubmit.value = false;
2025-07-08 10:04:47 +08:00
if (res.code == 200) {
popup.value.close("center");
2025-07-30 17:29:08 +08:00
// 显示成功提示
2025-07-08 10:04:47 +08:00
uni.showToast({
title: "操作成功",
icon: "success",
duration: 1000,
});
// 延时跳转,确保提示完毕后再跳转
setTimeout(() => {
uni.navigateTo({
url: `/pages/warehouse/vehicledispatch/vehicledispatch?orderId=${res.data}`,
});
}, 1000); // 跳转延迟与提示时长一致
} else {
uni.showToast({
2025-08-12 11:45:30 +08:00
title: res.message || "操作失败",
icon: "none",
2025-07-08 10:04:47 +08:00
duration: 2000,
});
}
});
};
2025-10-10 11:24:23 +08:00
// 提交表单
const submit = () => {
customForm.value
.validate()
.then((res) => {
if (statusZT.value == 0) {
// 下架
handleLeaveWarehouse();
} else {
// 投放
handleLaunch();
}
})
.catch((err) => {
console.log("err", err);
});
2025-07-08 10:04:47 +08:00
};
2025-10-10 11:24:23 +08:00
onMounted(() => {
let userDefultOperation = uni.getStorageSync("userDefultOperation");
//获取站点信息
api
.callOperateApi(
"ebikeRegion/getRegion?regionId=" + userDefultOperation.operationRegionId,
{},
"get"
)
.then((res) => {
if (res.code == 200) {
res.data.forEach((res) => {
let quyuemap = {
text: res.siteName,
value: res.siteRegionId,
};
regindata.value.push(quyuemap);
});
}
});
});
2025-07-08 10:04:47 +08:00
2025-10-10 11:24:23 +08:00
onShow(() => {
uni.$on("refreshData", (data) => {
const { isRefresh } = data;
if (isRefresh) {
paging.value.refresh();
}
});
});
2025-07-08 10:04:47 +08:00
2025-10-10 11:24:23 +08:00
onUnload(() => {
uni.$off("refreshData");
});
2025-04-14 10:57:27 +08:00
</script>
2025-10-10 11:24:23 +08:00
<style scoped lang="scss">
2025-07-08 10:04:47 +08:00
.container {
padding: 10px 0px 0px 0px;
}
.list-title {
margin: 5px 0px;
border-bottom: 1px solid #f0f0f0;
}
.list-title .title-xz {
margin: 5px;
}
.list-title .title-wz {
margin-left: 5px;
font-size: 14px;
line-height: 35px;
font-weight: bold;
}
.list-title .title-zt {
margin-left: 8px;
margin-top: 5px;
}
.list-item {
background: #fff;
padding: 10px;
2025-10-10 11:24:23 +08:00
margin: 13px 10px;
2025-07-08 10:04:47 +08:00
border-radius: 5px;
2025-10-10 11:24:23 +08:00
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
2025-07-08 10:04:47 +08:00
}
button {
margin-top: 20px;
2025-08-08 09:22:47 +08:00
padding: 15rpx;
2025-07-08 10:04:47 +08:00
background-color: #007aff;
color: white;
2025-08-08 09:22:47 +08:00
border-radius: 10rpx;
2025-07-08 10:04:47 +08:00
}
.list-name {
color: #999999;
2025-10-10 11:24:23 +08:00
font-size: 14px;
2025-07-08 10:04:47 +08:00
width: 30%;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
}
.list-value {
width: 70%;
color: #4f4f53;
2025-10-10 11:24:23 +08:00
font-size: 14px;
2025-07-08 10:04:47 +08:00
font-weight: 400;
}
.row {
margin: 8px 5px;
}
.scroll-view {
height: 100%;
}
.example-body {
padding: 10px;
}
.scroll-view {
/* #ifndef APP-NVUE */
width: 100%;
height: 100%;
/* #endif */
flex: 1;
}
.scroll-view-box {
flex: 1;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.info {
padding: 15px;
color: #666;
}
.info-text {
font-size: 14px;
color: #666;
}
.info-content {
padding: 5px 15px;
}
.close {
padding: 10px;
}
.search {
width: 90%;
}
.searchmore {
width: 10%;
padding-top: 15px;
}
.searchmore image {
width: 25px;
height: 25px;
}
.searchlist {
padding: 15px;
}
.nav-panel {
position: fixed;
bottom: 0rpx;
width: 100%;
padding-bottom: 20px;
z-index: 999;
background-color: #fff;
2025-10-10 11:24:23 +08:00
padding-left: 20px;
padding-right: 20px;
2025-07-08 10:04:47 +08:00
}
.plcrk {
2025-08-08 09:22:47 +08:00
width: 80vw;
2025-07-08 10:04:47 +08:00
height: 360px;
}
2025-10-10 11:24:23 +08:00
.fancy-btn {
background-color: #0078d4; /* 主色 */
color: #fff; /* 白色文字 */
border: none;
padding: 5px 24px; /* 舒服的内边距 */
font-weight: 600;
border-radius: 10px; /* 圆角 */
cursor: pointer;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: all 0.25s ease; /* 平滑过渡 */
font-size: 30rpx;
}
/* active 点击时 */
.fancy-btn:active {
background-color: #0078d4bd;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}
radio::before,
checkbox::before {
font-family: "cuIcon";
content: "\e645";
position: absolute;
color: #ffffff !important;
top: 41%;
margin-top: -8px;
right: 5px;
font-size: 32rpx;
line-height: 16px;
pointer-events: none;
transform: scale(1, 1);
transition: all 0.3s ease-in-out 0s;
z-index: 9;
}
2025-07-08 10:04:47 +08:00
</style>