预制组件列表
This commit is contained in:
+512
-210
@@ -1,111 +1,125 @@
|
||||
<template>
|
||||
<view class="page-detail">
|
||||
<!-- 信息表单 -->
|
||||
<!-- 基本信息 -->
|
||||
<view class="info-group">
|
||||
<!-- 车次 -->
|
||||
<view class="info-item">
|
||||
<text class="info-label" v-if="isEdit"><text class="required">*</text>车次</text>
|
||||
<text class="info-label" v-else>车次</text>
|
||||
<u-input v-if="isEdit" v-model="form.TrainNumber" placeholder="请输入车次" />
|
||||
<text class="info-label"><text class="required">*</text>车次</text>
|
||||
<view class="info-input-wrap" v-if="!form.State || form.State === 0">
|
||||
<u-input v-model="form.TrainNumber" placeholder="请输入车次" />
|
||||
</view>
|
||||
<text class="info-value" v-else>{{ form.TrainNumber || '--' }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 单位名称 -->
|
||||
<view class="info-item">
|
||||
<text class="info-label" v-if="isEdit"><text class="required">*</text>单位名称</text>
|
||||
<text class="info-label" v-else>单位名称</text>
|
||||
<u-input v-if="isEdit" v-model="form.UnitName" :clearable="false" type="select" placeholder="请选择单位" @click="handleShowUnit" />
|
||||
<text class="info-label"><text class="required">*</text>单位名称</text>
|
||||
<view class="info-input-wrap" v-if="!form.State || form.State === 0">
|
||||
<u-input v-model="form.UnitName" :clearable="false" type="select" placeholder="请选择单位"
|
||||
@click="handleShowUnit" />
|
||||
</view>
|
||||
<text class="info-value" v-else>{{ form.UnitName || '--' }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 驾驶员姓名 -->
|
||||
<view class="info-item">
|
||||
<text class="info-label" v-if="isEdit"><text class="required">*</text>驾驶员姓名</text>
|
||||
<text class="info-label" v-else>驾驶员姓名</text>
|
||||
<u-input v-if="isEdit" v-model="form.DriverName" placeholder="请输入驾驶员姓名" />
|
||||
<text class="info-label"><text class="required">*</text>驾驶员姓名</text>
|
||||
<view class="info-input-wrap" v-if="!form.State || form.State === 0">
|
||||
<u-input v-model="form.DriverName" placeholder="请输入驾驶员姓名" />
|
||||
</view>
|
||||
<text class="info-value" v-else>{{ form.DriverName || '--' }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 驾驶员电话 -->
|
||||
<view class="info-item">
|
||||
<text class="info-label" v-if="isEdit"><text class="required">*</text>驾驶员电话</text>
|
||||
<text class="info-label" v-else>驾驶员电话</text>
|
||||
<u-input v-if="isEdit" v-model="form.DriverPhone" placeholder="请输入驾驶员电话" type="number" />
|
||||
<text class="info-label"><text class="required">*</text>驾驶员电话</text>
|
||||
<view class="info-input-wrap" v-if="!form.State || form.State === 0">
|
||||
<u-input v-model="form.DriverPhone" placeholder="请输入驾驶员电话" type="number" />
|
||||
</view>
|
||||
<text class="info-value" v-else>{{ form.DriverPhone || '--' }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 车牌号 -->
|
||||
<view class="info-item">
|
||||
<text class="info-label" v-if="isEdit"><text class="required">*</text>车牌号</text>
|
||||
<text class="info-label" v-else>车牌号</text>
|
||||
<u-input v-if="isEdit" v-model="form.LicensePlateNumber" placeholder="请输入车牌号" />
|
||||
<text class="info-label"><text class="required">*</text>车牌号</text>
|
||||
<view class="info-input-wrap" v-if="!form.State || form.State === 0">
|
||||
<u-input v-model="form.LicensePlateNumber" placeholder="请输入车牌号" />
|
||||
</view>
|
||||
<text class="info-value" v-else>{{ form.LicensePlateNumber || '--' }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 联系人姓名 -->
|
||||
<view class="info-item">
|
||||
<text class="info-label" v-if="isEdit"><text class="required">*</text>联系人姓名</text>
|
||||
<text class="info-label" v-else>联系人姓名</text>
|
||||
<u-input v-if="isEdit" v-model="form.ContactName" placeholder="请输入联系人姓名" />
|
||||
<text class="info-label"><text class="required">*</text>联系人姓名</text>
|
||||
<view class="info-input-wrap" v-if="!form.State || form.State === 0">
|
||||
<u-input v-model="form.ContactName" placeholder="请输入联系人姓名" />
|
||||
</view>
|
||||
<text class="info-value" v-else>{{ form.ContactName || '--' }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 联系人电话 -->
|
||||
<view class="info-item">
|
||||
<text class="info-label" v-if="isEdit"><text class="required">*</text>联系人电话</text>
|
||||
<text class="info-label" v-else>联系人电话</text>
|
||||
<u-input v-if="isEdit" v-model="form.ContactPhone" placeholder="请输入联系人电话" type="number" />
|
||||
<text class="info-label"><text class="required">*</text>联系人电话</text>
|
||||
<view class="info-input-wrap" v-if="!form.State || form.State === 0">
|
||||
<u-input v-model="form.ContactPhone" placeholder="请输入联系人电话" type="number" />
|
||||
</view>
|
||||
<text class="info-value" v-else>{{ form.ContactPhone || '--' }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 备注 -->
|
||||
<view class="info-item">
|
||||
<view class="info-item info-textarea">
|
||||
<text class="info-label">备注</text>
|
||||
<u-input v-if="isEdit" v-model="form.Remark" placeholder="请输入备注" type="textarea" />
|
||||
<view class="info-input-wrap" v-if="!form.State || form.State === 0">
|
||||
<u-input v-model="form.Remark" placeholder="请输入备注" type="textarea" />
|
||||
</view>
|
||||
<text class="info-value" v-else>{{ form.Remark || '--' }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 状态 -->
|
||||
<view class="info-item">
|
||||
<text class="info-label">状态</text>
|
||||
<text class="info-value">{{ form.StateName || '--' }}</text>
|
||||
<text class="card-tag" :class="'status-' + form.State">{{ getStatus(form.State) }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 扫码添加(编辑状态有Id且未发货) -->
|
||||
<view class="scan-row" v-if="form.TrainNumberId && isEdit">
|
||||
<text class="scan-text">扫码添加</text>
|
||||
<view class="scan-btn" @click="handleScan">
|
||||
<u-icon name="scan" :size="40" color="#2979ff"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 包装列表 -->
|
||||
<view class="package-section" v-if="form.TrainNumberId">
|
||||
<text class="section-title">包装列表</text>
|
||||
<view class="package-table">
|
||||
<view class="table-hd">
|
||||
<text class="table-td">包装编号</text>
|
||||
<text class="table-td">预制工作包</text>
|
||||
<text class="table-td td-operate" v-if="isEdit">操作</text>
|
||||
</view>
|
||||
<view v-for="(item, index) in BZList" :key="index" class="table-tr">
|
||||
<text class="table-td">{{ item.PackagingCode }}</text>
|
||||
<text class="table-td">{{ item.StackingPosition || '--' }}</text>
|
||||
<text class="table-td td-operate" v-if="isEdit" @click="handleDeletePackage(item)">
|
||||
<u-icon name="trash" :size="20" color="#fa3534"></u-icon>
|
||||
</text>
|
||||
</view>
|
||||
<view v-if="BZList.length === 0" class="table-empty">
|
||||
<u-empty text="暂无数据" mode="list"></u-empty>
|
||||
</view>
|
||||
<!-- 扫码添加 -->
|
||||
<view class="info-item info-link" v-if="form.Id && (!form.State || form.State === 0)" @click="handleScan">
|
||||
<text class="info-label">扫码添加</text>
|
||||
<view class="scan-icon">
|
||||
<u-icon name="scan" :size="36" color="#3577FF"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 包装列表 -->
|
||||
<view class="package-group" v-if="form.Id">
|
||||
<view class="section-title">
|
||||
<text>包装列表</text>
|
||||
<text class="section-count">({{ BZList.length }})</text>
|
||||
</view>
|
||||
<view v-for="(item, index) in BZList" :key="index" class="package-card">
|
||||
<view class="card-header">
|
||||
<text class="card-title">{{ item.PackagingCode || '--' }}</text>
|
||||
<view class="del-btn" @click="handleDeletePackage(item)" v-if="!form.State || form.State === 0">
|
||||
<u-icon name="trash" :size="36" color="#ffffff"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="card-body">
|
||||
<view class="card-row">
|
||||
<text class="row-label">预制工作包</text>
|
||||
<text class="row-value">{{ item.StackingPosition || '--' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="BZList.length === 0" class="package-empty">
|
||||
<u-empty text="暂无数据" mode="list"></u-empty>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部按钮 -->
|
||||
<view class="bottom-btns" v-if="isEdit">
|
||||
<view class="bottom-btns" v-if="!form.State || form.State === 0">
|
||||
<u-button size="medium" type="primary" :disabled="disabledBtn" @click="handleSave(0)">保存</u-button>
|
||||
<u-button size="medium" type="success" :disabled="disabledBtn" @click="handleSave(1)">发货</u-button>
|
||||
<u-button v-if="form.Id" size="medium" type="success" :disabled="disabledBtn"
|
||||
@click="handleSave(1)">发货</u-button>
|
||||
</view>
|
||||
<view class="bottom-btns" v-if="form.State === 1">
|
||||
<u-button size="medium" type="warning" :disabled="disabledBtn" @click="handleSign">签收</u-button>
|
||||
@@ -114,22 +128,105 @@
|
||||
<!-- 单位选择弹窗 -->
|
||||
<nbd-select v-model="showUnitSelect" v-model:model="selectedUnit" :show-search="true" title="选择单位"
|
||||
:list="unitList" label-key="UnitName" value-key="UnitId" @confirm="handleUnitConfirm" />
|
||||
|
||||
<!-- 包装详情弹窗 -->
|
||||
<u-popup v-model="showBZDetail" mode="center" :closeable="true" @close="closeBZDetail">
|
||||
<view class="bz-detail-modal">
|
||||
<view class="modal-header">
|
||||
<text class="modal-title">包装详情</text>
|
||||
</view>
|
||||
<view class="modal-body" v-if="currentBZInfo">
|
||||
<view class="detail-row">
|
||||
<text class="detail-label">包装编号</text>
|
||||
<text class="detail-value">{{ currentBZInfo.PackagingCode || '--' }}</text>
|
||||
</view>
|
||||
<view class="detail-row">
|
||||
<text class="detail-label">最早安装时间</text>
|
||||
<text class="detail-value">{{ currentBZInfo.EarliestInstallTime || '--' }}</text>
|
||||
</view>
|
||||
<view class="detail-row">
|
||||
<text class="detail-label">堆放位置</text>
|
||||
<text class="detail-value">{{ currentBZInfo.StackingPosition || '--' }}</text>
|
||||
</view>
|
||||
<view class="detail-row">
|
||||
<text class="detail-label">到场状态</text>
|
||||
<text class="detail-value">{{ getBZStatus(currentBZInfo.State) }}</text>
|
||||
</view>
|
||||
<view class="detail-row">
|
||||
<text class="detail-label">联系人及电话</text>
|
||||
<text class="detail-value">{{ currentBZInfo.ContactName || '' }}/{{ currentBZInfo.ContactPhone
|
||||
|| '' }}</text>
|
||||
</view>
|
||||
<view class="detail-row">
|
||||
<text class="detail-label">收货人</text>
|
||||
<text class="detail-value">{{ currentBZInfo.ReceiveMan || '--' }}</text>
|
||||
</view>
|
||||
<view class="detail-row">
|
||||
<text class="detail-label">收货日期</text>
|
||||
<text class="detail-value">{{ currentBZInfo.ReceiveDate || '--' }}</text>
|
||||
</view>
|
||||
<!-- 预制组件列表 -->
|
||||
<view class="prepipe-section" v-if="currentBZItems && currentBZItems.length > 0">
|
||||
<view class="prepipe-title">预制组件列表({{ currentBZItems.length }})</view>
|
||||
<view class="prepipe-list">
|
||||
<view class="prepipe-card" v-for="(item, index) in currentBZItems" :key="index">
|
||||
<view class="card-header">
|
||||
<text class="card-code">{{ item.PipelineComponentCode || '--' }}</text>
|
||||
</view>
|
||||
<view class="card-body">
|
||||
<view class="card-row">
|
||||
<text class="card-label">数量/单位</text>
|
||||
<text class="card-value">{{ item.PreUnit || '--' }}</text>
|
||||
</view>
|
||||
<view class="card-row">
|
||||
<text class="card-label">所属主项</text>
|
||||
<text class="card-value">{{ item.UnitWorkName || '--' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="modal-footer">
|
||||
<view class="cancel-btn" @click="closeBZDetail">取消</view>
|
||||
<view class="confirm-btn" @click="confirmAddBZ">确认添加</view>
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||
import { useUserStore } from '@/store'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { reqUnitByProjectIdUnitType } from '@/api/base'
|
||||
import { reqTrainNumberById, reqSaveTrainNumber, reqSignTrainNumber, reqDeletePackagingFromTrain, reqPackagingListByTrain } from '@/api/hj'
|
||||
|
||||
// 是否编辑状态
|
||||
const isEdit = computed(() => !form.value.State || form.value.State === 0)
|
||||
import {
|
||||
ref
|
||||
} from 'vue'
|
||||
import {
|
||||
onLoad
|
||||
} from '@dcloudio/uni-app'
|
||||
import {
|
||||
useUserStore
|
||||
} from '@/store'
|
||||
import {
|
||||
storeToRefs
|
||||
} from 'pinia'
|
||||
import {
|
||||
reqUnitByProjectIdUnitType
|
||||
} from '@/api/base'
|
||||
import {
|
||||
reqTrainNumberDetail,
|
||||
reqPackagingByTrain,
|
||||
reqPackagingInformationById,
|
||||
reqSavePackagingToTrain,
|
||||
reqSaveTrainNumber,
|
||||
reqTrainInfoConfirmArrival,
|
||||
reqDeletePackagingFromTrain
|
||||
} from '@/api/hj'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const { currentProject } = storeToRefs(userStore)
|
||||
const {
|
||||
currentProject,
|
||||
userInfo
|
||||
} = storeToRefs(userStore)
|
||||
|
||||
// ===== 页面状态 =====
|
||||
const trainNumberId = ref('')
|
||||
@@ -153,17 +250,26 @@
|
||||
|
||||
// ===== 单位选择 =====
|
||||
const showUnitSelect = ref(false)
|
||||
const unitList = ref([{ UnitId: '', UnitName: '全部单位' }])
|
||||
const selectedUnit = ref({ UnitId: '', UnitName: '全部单位' })
|
||||
const unitList = ref([])
|
||||
const selectedUnit = ref()
|
||||
|
||||
// ===== 包装列表 =====
|
||||
const BZList = ref([])
|
||||
|
||||
// ===== 包装详情弹窗 =====
|
||||
const showBZDetail = ref(false)
|
||||
const currentBZInfo = ref(null)
|
||||
const currentBZItems = ref([])
|
||||
|
||||
// ===== 获取单位列表 =====
|
||||
const getUnitList = async () => {
|
||||
try {
|
||||
if (!currentProject.value?.ProjectId) {
|
||||
console.warn('currentProject 未初始化,无法获取单位列表')
|
||||
return
|
||||
}
|
||||
const res = await reqUnitByProjectIdUnitType(currentProject.value?.ProjectId || '')
|
||||
unitList.value = [{ UnitId: '', UnitName: '全部单位' }, ...(res.data || [])]
|
||||
unitList.value = [...(res.data || [])]
|
||||
} catch (error) {
|
||||
console.error('获取单位列表失败:', error)
|
||||
}
|
||||
@@ -171,165 +277,329 @@
|
||||
|
||||
// ===== 显示单位选择 =====
|
||||
const handleShowUnit = () => {
|
||||
if (form.value.UnitId) {
|
||||
selectedUnit.value = {
|
||||
UnitId: form.value.UnitId,
|
||||
UnitName: form.value.UnitName
|
||||
}
|
||||
if (!form.value.State || form.value.State === 0) {
|
||||
showUnitSelect.value = true
|
||||
}
|
||||
showUnitSelect.value = true
|
||||
}
|
||||
|
||||
// ===== 单位选择确认 =====
|
||||
const handleUnitConfirm = (item) => {
|
||||
form.value.UnitId = item.UnitId
|
||||
form.value.UnitName = item.UnitName
|
||||
selectedUnit.value = item
|
||||
const handleUnitConfirm = () => {
|
||||
form.value.UnitId = selectedUnit.value.UnitId
|
||||
form.value.UnitName = selectedUnit.value.UnitName
|
||||
showUnitSelect.value = false
|
||||
}
|
||||
|
||||
// ===== 获取车次详情 =====
|
||||
const getTrainNumberDetail = async () => {
|
||||
if (!trainNumberId.value) return
|
||||
// ===== 获取状态文本 =====
|
||||
const getStatus = (val) => {
|
||||
const map = {
|
||||
'0': '待发货',
|
||||
'1': '已发货',
|
||||
'2': '已签收'
|
||||
}
|
||||
return form.value.Id && map[String(val)] || '--'
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await reqTrainNumberById(trainNumberId.value)
|
||||
if (res.data) {
|
||||
form.value = { ...form.value, ...res.data }
|
||||
selectedUnit.value = {
|
||||
UnitId: res.data.UnitId,
|
||||
UnitName: res.data.UnitName
|
||||
// ===== 扫码添加 =====
|
||||
const handleScan = () => {
|
||||
uni.scanCode({
|
||||
success(res) {
|
||||
let result = res.result
|
||||
console.log('扫码结果:', result)
|
||||
if (!result.includes('PackagingManage$')) {
|
||||
uni.showToast({
|
||||
title: '非包装二维码',
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
})
|
||||
return
|
||||
}
|
||||
let bzId = result.split('$')[1]
|
||||
if (bzId) {
|
||||
getBZInfo(bzId)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '二维码格式错误',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
fail(err) {
|
||||
console.error('扫码失败:', err)
|
||||
if (err.errMsg && err.errMsg.includes('cancel')) {
|
||||
// 用户取消扫码
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '扫码失败,请重试',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
// 获取包装列表
|
||||
getPackagingList()
|
||||
} catch (error) {
|
||||
console.error('获取车次详情失败:', error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// ===== 获取包装列表 =====
|
||||
const getPackagingList = async () => {
|
||||
if (!trainNumberId.value) return
|
||||
|
||||
// ===== 获取包装信息 =====
|
||||
const getBZInfo = async (bzId) => {
|
||||
try {
|
||||
const res = await reqPackagingListByTrain(trainNumberId.value)
|
||||
BZList.value = res.data || []
|
||||
} catch (error) {
|
||||
console.error('获取包装列表失败:', error)
|
||||
}
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true
|
||||
})
|
||||
|
||||
// ===== 删除包装 =====
|
||||
const handleDeletePackage = async (item) => {
|
||||
try {
|
||||
await reqDeletePackagingFromTrain({
|
||||
trainNumberId: trainNumberId.value,
|
||||
packagingManageId: item.PackagingManageId || item.PackagingId
|
||||
})
|
||||
uni.showToast({
|
||||
title: '删除成功',
|
||||
icon: 'success'
|
||||
})
|
||||
getPackagingList()
|
||||
let params = {
|
||||
projectId: currentProject.value?.ProjectId,
|
||||
personId: userInfo.value?.PersonId,
|
||||
packagingManageId: bzId
|
||||
}
|
||||
|
||||
let res = await reqPackagingInformationById(params)
|
||||
if (res.code == 1) {
|
||||
const BZInfo = res.data.packagingManageDetailItem
|
||||
const BZItem = res.data.packagingPrepipeItems
|
||||
|
||||
// 检查是否已存在
|
||||
if (BZList.value.some(item => item.PackagingId === bzId)) {
|
||||
uni.hideLoading()
|
||||
return uni.showToast({
|
||||
title: '该包装已存在',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
// 保存当前包装信息用于弹窗显示
|
||||
currentBZInfo.value = BZInfo
|
||||
currentBZItems.value = BZItem || []
|
||||
|
||||
uni.hideLoading()
|
||||
// 显示包装详情弹窗
|
||||
showBZDetail.value = true
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: res.msg || '获取包装信息失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('删除包装失败:', error)
|
||||
console.error('获取包装信息失败:', error)
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '删除失败',
|
||||
title: '获取包装信息失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// ===== 扫码 =====
|
||||
const handleScan = () => {
|
||||
// #ifdef MP-WEIXIN
|
||||
wx.scanCode({
|
||||
// ===== 删除包装 =====
|
||||
const handleDeletePackage = (item) => {
|
||||
uni.showModal({
|
||||
title: '确认删除',
|
||||
content: '确定要删除该包装吗?',
|
||||
success: (res) => {
|
||||
console.log('扫码结果:', res)
|
||||
uni.showToast({
|
||||
title: '扫码成功',
|
||||
icon: 'success'
|
||||
})
|
||||
// TODO: 根据扫码结果处理
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('扫码失败:', err)
|
||||
uni.showToast({
|
||||
title: '扫码失败',
|
||||
if (res.confirm) {
|
||||
// TODO: 调用删除接口
|
||||
reqDeletePackagingFromTrain(item.PackagingManageId).then(
|
||||
(res) => {
|
||||
if (res.code === 1) {
|
||||
uni.showToast({
|
||||
title: '删除成功',
|
||||
icon: 'none'
|
||||
})
|
||||
getPackagingList(form.value.Id)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '删除成功',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
).catch((err) => {
|
||||
uni.showToast({
|
||||
title: '删除失败',
|
||||
icon: 'none'
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// ===== 关闭包装详情弹窗 =====
|
||||
const closeBZDetail = () => {
|
||||
showBZDetail.value = false
|
||||
currentBZInfo.value = null
|
||||
currentBZItems.value = []
|
||||
}
|
||||
|
||||
// ===== 确认添加包装 =====
|
||||
const confirmAddBZ = () => {
|
||||
if (currentBZInfo.value) {
|
||||
reqSavePackagingToTrain({
|
||||
packagingManageId: currentBZInfo.value.PackagingManageId,
|
||||
trainNumberId: trainNumberId.value
|
||||
}).then(
|
||||
(res) => {
|
||||
if (res.code === 1) {
|
||||
uni.showToast({
|
||||
title: '添加成功',
|
||||
})
|
||||
closeBZDetail()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg || '添加失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// ===== 车次详情 =====
|
||||
const getInfo = async (id) => {
|
||||
try {
|
||||
const res = await reqTrainNumberDetail(id)
|
||||
if (res.code === 1) {
|
||||
form.value = res.data?.getDataList?.[0] || {}
|
||||
// 直接使用接口返回的 UnitName,避免依赖 unitList
|
||||
if (form.value.UnitId && unitList.value.length > 0) {
|
||||
selectedUnit.value = unitList.value.find(e => e.UnitId === form.value.UnitId) || {}
|
||||
if (selectedUnit.value.UnitName) {
|
||||
form.value.UnitName = selectedUnit.value.UnitName
|
||||
}
|
||||
}
|
||||
getPackagingList(form.value.Id)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取车次详情失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取包装列表
|
||||
const getPackagingList = async (id) => {
|
||||
try {
|
||||
const res = await reqPackagingByTrain(id)
|
||||
if (res.code === 1) {
|
||||
BZList.value = res.data || []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取包装列表失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// ===== 保存 =====
|
||||
const handleSave = (type) => {
|
||||
if (!form.value.TrainNumber) {
|
||||
return uni.showToast({
|
||||
title: '请输入车次',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
if (!form.value.UnitId) {
|
||||
return uni.showToast({
|
||||
title: '请选择单位',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
if (!form.value.DriverName) {
|
||||
return uni.showToast({
|
||||
title: '请输入驾驶员姓名',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
if (!form.value.DriverPhone) {
|
||||
return uni.showToast({
|
||||
title: '请输入驾驶员电话',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
if (!form.value.LicensePlateNumber) {
|
||||
return uni.showToast({
|
||||
title: '请输入车牌号',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
if (!form.value.ContactName) {
|
||||
return uni.showToast({
|
||||
title: '请输入联系人姓名',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
if (!form.value.ContactPhone) {
|
||||
return uni.showToast({
|
||||
title: '请输入联系人电话',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
const params = {
|
||||
Id: form.value.Id || '',
|
||||
TrainNumber: form.value.TrainNumber,
|
||||
UnitId: form.value.UnitId,
|
||||
ProjectId: userInfo.value?.ProjectId || '',
|
||||
State: type,
|
||||
DriverName: form.value.DriverName,
|
||||
DriverPhone: form.value.DriverPhone,
|
||||
LicensePlateNumber: form.value.LicensePlateNumber,
|
||||
ContactName: form.value.ContactName,
|
||||
ContactPhone: form.value.ContactPhone,
|
||||
Remark: form.value.Remark || ''
|
||||
}
|
||||
|
||||
if (type === 1) {
|
||||
// 检查是否已添加包装
|
||||
if (!BZList.value.length) {
|
||||
return uni.showToast({
|
||||
title: '请添加包装',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
// 发货需要确认
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '是否确认发货',
|
||||
showCancel: true,
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
saveTrainNumber(params)
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// 保存直接调用
|
||||
saveTrainNumber(params)
|
||||
}
|
||||
}
|
||||
|
||||
// ===== 保存/发货 =====
|
||||
const handleSave = async (state) => {
|
||||
// 验证必填项
|
||||
if (!form.value.TrainNumber) {
|
||||
uni.showToast({ title: '请输入车次', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!form.value.UnitId) {
|
||||
uni.showToast({ title: '请选择单位', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!form.value.DriverName) {
|
||||
uni.showToast({ title: '请输入驾驶员姓名', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!form.value.DriverPhone) {
|
||||
uni.showToast({ title: '请输入驾驶员电话', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!form.value.LicensePlateNumber) {
|
||||
uni.showToast({ title: '请输入车牌号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!form.value.ContactName) {
|
||||
uni.showToast({ title: '请输入联系人姓名', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!form.value.ContactPhone) {
|
||||
uni.showToast({ title: '请输入联系人电话', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
disabledBtn.value = true
|
||||
|
||||
// 保存车次信息
|
||||
const saveTrainNumber = async (params) => {
|
||||
try {
|
||||
const res = await reqSaveTrainNumber({
|
||||
trainNumberId: trainNumberId.value || '',
|
||||
projectId: currentProject.value?.ProjectId || '',
|
||||
unitId: form.value.UnitId,
|
||||
trainNumber: form.value.TrainNumber,
|
||||
driverName: form.value.DriverName,
|
||||
driverPhone: form.value.DriverPhone,
|
||||
licensePlateNumber: form.value.LicensePlateNumber,
|
||||
contactName: form.value.ContactName,
|
||||
contactPhone: form.value.ContactPhone,
|
||||
remark: form.value.Remark,
|
||||
state: state
|
||||
})
|
||||
disabledBtn.value = true
|
||||
const res = await reqSaveTrainNumber(params)
|
||||
if (res.code === 1) {
|
||||
// 更新表单状态
|
||||
form.value.Id = res.data?.id || form.value.Id
|
||||
form.value.State = params.State
|
||||
|
||||
if (res.code === 1 || res.data) {
|
||||
uni.showToast({
|
||||
title: state === 1 ? '发货成功' : '保存成功',
|
||||
icon: 'success'
|
||||
title: params.State === 1 ? '发货成功' : '保存成功',
|
||||
icon: 'none'
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
const newId = res.data?.trainNumberId || trainNumberId.value
|
||||
uni.redirectTo({
|
||||
url: `/pipe/deliver/add?id=${newId}&from=1`
|
||||
uni.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
}, 1500)
|
||||
}, 900)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg || '操作失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('保存失败:', error)
|
||||
uni.showToast({
|
||||
title: '保存失败,请重试',
|
||||
title: '操作失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
@@ -338,47 +608,79 @@
|
||||
}
|
||||
|
||||
// ===== 签收 =====
|
||||
const handleSign = async () => {
|
||||
disabledBtn.value = true
|
||||
|
||||
try {
|
||||
const res = await reqSignTrainNumber({
|
||||
trainNumberId: trainNumberId.value,
|
||||
personId: currentProject.value?.PersonId || ''
|
||||
const handleSign = () => {
|
||||
// 检查是否已添加包装
|
||||
if (!BZList.value.length) {
|
||||
return uni.showToast({
|
||||
title: '请添加包装',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '是否确认签收',
|
||||
showCancel: true,
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
signTrainNumber()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 签收车次
|
||||
const signTrainNumber = async () => {
|
||||
try {
|
||||
const res = await reqTrainInfoConfirmArrival(userInfo.value?.UserId || '', form.value.Id)
|
||||
if (res.code === 1) {
|
||||
uni.showToast({
|
||||
title: '签收成功',
|
||||
icon: 'success'
|
||||
icon: 'none'
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
uni.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
}, 900)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg || '签收失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('签收失败:', error)
|
||||
uni.showToast({
|
||||
title: '签收失败,请重试',
|
||||
title: '签收失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
disabledBtn.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ===== 生命周期 =====
|
||||
onLoad((options) => {
|
||||
if (options.id) {
|
||||
trainNumberId.value = options.id
|
||||
// ===== 包装到场状态 =====
|
||||
const getBZStatus = (state) => {
|
||||
const statusMap = {
|
||||
0: '待发货',
|
||||
1: '已发货',
|
||||
2: '已签收',
|
||||
3: '已到场'
|
||||
}
|
||||
})
|
||||
return statusMap[state] || '--'
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
getUnitList()
|
||||
// ===== 生命周期 =====
|
||||
onLoad(async (options) => {
|
||||
trainNumberId.value = options?.id || ''
|
||||
// 并行加载单位列表和车次详情
|
||||
if (trainNumberId.value) {
|
||||
getTrainNumberDetail()
|
||||
await Promise.all([
|
||||
getUnitList(),
|
||||
getInfo(trainNumberId.value)
|
||||
])
|
||||
} else {
|
||||
await getUnitList()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</script>
|
||||
@@ -211,7 +211,7 @@ import { reqTrainNumberList } from '@/api/hj'
|
||||
|
||||
const clickTap = (item) => {
|
||||
uni.navigateTo({
|
||||
url: `/pipe/deliver/detail?id=${item.TrainNumberId}&from=1`
|
||||
url: `/pipe/deliver/detail?id=${item.Id}&from=1`
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user