|
|
|
|
@ -0,0 +1,711 @@
|
|
|
|
|
<template>
|
|
|
|
|
<view class="page-container">
|
|
|
|
|
<NavBar :title="t('sparepartOutbound.createTitle')" />
|
|
|
|
|
|
|
|
|
|
<!-- 操作按钮区 -->
|
|
|
|
|
<view class="action-row">
|
|
|
|
|
<view class="action-btn scan-btn" @click="handleScan">
|
|
|
|
|
<view class="btn-icon-wrap">
|
|
|
|
|
<text class="iconfont icon-scan btn-icon"></text>
|
|
|
|
|
</view>
|
|
|
|
|
<text class="btn-text">扫备件码</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="action-btn select-btn" @click="handleSelectSparepart">
|
|
|
|
|
<view class="btn-icon-wrap">
|
|
|
|
|
<text class="iconfont icon-device btn-icon"></text>
|
|
|
|
|
</view>
|
|
|
|
|
<text class="btn-text">选择备件</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 已选备件 -->
|
|
|
|
|
<view v-if="selectedSparepart.id" class="sparepart-section">
|
|
|
|
|
<view class="section-title-bar">
|
|
|
|
|
<view class="section-bar-line"></view>
|
|
|
|
|
<text class="section-title">已选备件</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="sparepart-card">
|
|
|
|
|
<view class="card-top">
|
|
|
|
|
<view class="card-image-wrap">
|
|
|
|
|
<image
|
|
|
|
|
v-if="sparepartImage"
|
|
|
|
|
:src="sparepartImage"
|
|
|
|
|
class="card-image"
|
|
|
|
|
mode="aspectFill"
|
|
|
|
|
/>
|
|
|
|
|
<view v-else class="card-image-empty">
|
|
|
|
|
<text class="empty-img-icon">📦</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="card-info-right">
|
|
|
|
|
<view class="info-item">
|
|
|
|
|
<text class="info-label">备件名称:</text>
|
|
|
|
|
<text class="info-name">{{ textValue(selectedSparepart.name) }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="info-item">
|
|
|
|
|
<text class="info-label">规格:</text>
|
|
|
|
|
<text class="info-value">{{ textValue(selectedSparepart.standard || selectedSparepart.deviceSpec) }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="info-item">
|
|
|
|
|
<text class="info-label">当前库存:</text>
|
|
|
|
|
<text class="info-value stock-highlight">{{ textValue(selectedSparepart.stock) }}{{ textUnit(selectedSparepart.minStockUnitName) }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="card-bottom">
|
|
|
|
|
<view class="detail-row two-col">
|
|
|
|
|
<view class="detail-col">
|
|
|
|
|
<text class="detail-label">采购单位:</text>
|
|
|
|
|
<text class="detail-value">{{ textValue(selectedSparepart.purchaseUnitName) }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="detail-col">
|
|
|
|
|
<text class="detail-label">库存单位:</text>
|
|
|
|
|
<text class="detail-value">{{ textValue(selectedSparepart.unitName || selectedSparepart.minStockUnitName) }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="detail-row">
|
|
|
|
|
<text class="detail-label">换算关系:</text>
|
|
|
|
|
<text class="detail-value">1{{ textValue(selectedSparepart.purchaseUnitName) }}={{ textValue(selectedSparepart.purchaseUnitConvertQuantity) }}{{ stockUnitLabel(selectedSparepart) }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 出库用途 -->
|
|
|
|
|
<view class="section-title-bar" style="padding-top: 24rpx;">
|
|
|
|
|
<view class="section-bar-line"></view>
|
|
|
|
|
<text class="section-title">出库用途</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="purpose-card">
|
|
|
|
|
<view
|
|
|
|
|
class="purpose-item"
|
|
|
|
|
:class="{ active: selectedPurpose === 'repair' }"
|
|
|
|
|
@click="setPurpose('repair')"
|
|
|
|
|
>
|
|
|
|
|
<text class="iconfont icon-repair purpose-icon"></text>
|
|
|
|
|
<text class="purpose-text">维修领用</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view
|
|
|
|
|
class="purpose-item"
|
|
|
|
|
:class="{ active: selectedPurpose === 'maintain' }"
|
|
|
|
|
@click="setPurpose('maintain')"
|
|
|
|
|
>
|
|
|
|
|
<text class="iconfont icon-shield purpose-icon"></text>
|
|
|
|
|
<text class="purpose-text">保养领用</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 关联信息(维修领用/保养领用) -->
|
|
|
|
|
<view v-if="selectedPurpose === 'repair' || selectedPurpose === 'maintain'" class="section-title-bar" style="padding-top: 24rpx;">
|
|
|
|
|
<view class="section-bar-line"></view>
|
|
|
|
|
<text class="section-title">关联信息</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view v-if="selectedPurpose === 'repair' || selectedPurpose === 'maintain'" class="select-row-card warehouse-area-card">
|
|
|
|
|
<view class="warehouse-area-rows">
|
|
|
|
|
<view class="warehouse-area-row">
|
|
|
|
|
<text class="warehouse-area-label">关联设备</text>
|
|
|
|
|
<view class="warehouse-area-dropdown" @click="toggleDeviceDropdown">
|
|
|
|
|
<view class="dropdown-input">
|
|
|
|
|
<text :class="['dropdown-value', { placeholder: !selectedDevice }]">{{ selectedDevice ? selectedDevice.label : '请选择' }}</text>
|
|
|
|
|
<text class="dropdown-arrow">▼</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view v-if="showDeviceDropdown" class="dropdown-panel">
|
|
|
|
|
<scroll-view scroll-y class="dropdown-scroll">
|
|
|
|
|
<view v-for="item in deviceOptions" :key="item.value" class="dropdown-item" :class="{ active: selectedDevice?.value === item.value }" @click.stop="handleSelectDevice(item)">
|
|
|
|
|
<text class="dropdown-item-text">{{ item.label }}</text>
|
|
|
|
|
<text v-if="selectedDevice?.value === item.value" class="dropdown-check">✓</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view v-if="!deviceOptions.length" class="dropdown-empty">暂无设备数据</view>
|
|
|
|
|
</scroll-view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="warehouse-area-row">
|
|
|
|
|
<text class="warehouse-area-label">{{ selectedPurpose === 'repair' ? '维修单号' : '保养单号' }}</text>
|
|
|
|
|
<view class="warehouse-area-dropdown" @click="toggleOrderDropdown">
|
|
|
|
|
<view class="dropdown-input">
|
|
|
|
|
<text :class="['dropdown-value', { placeholder: !currentOrder }]">{{ currentOrder ? currentOrder.label : '请选择' }}</text>
|
|
|
|
|
<text class="dropdown-arrow">▼</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view v-if="showOrderDropdown" class="dropdown-panel">
|
|
|
|
|
<scroll-view scroll-y class="dropdown-scroll">
|
|
|
|
|
<view v-for="item in currentOrderOptions" :key="item.value" class="dropdown-item" :class="{ active: currentOrder?.value === item.value }" @click.stop="handleSelectOrder(item)">
|
|
|
|
|
<text class="dropdown-item-text">{{ item.label }}</text>
|
|
|
|
|
<text v-if="currentOrder?.value === item.value" class="dropdown-check">✓</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view v-if="!currentOrderOptions.length" class="dropdown-empty">{{ selectedPurpose === 'repair' ? '暂无维修单' : '暂无保养单' }}</view>
|
|
|
|
|
</scroll-view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 出库数量 -->
|
|
|
|
|
<view class="qty-section">
|
|
|
|
|
<view class="section-title-bar">
|
|
|
|
|
<view class="section-bar-line"></view>
|
|
|
|
|
<text class="section-title">出库数量</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="qty-input-card">
|
|
|
|
|
<view class="form-field">
|
|
|
|
|
<text class="form-label">出库数量</text>
|
|
|
|
|
<input
|
|
|
|
|
v-model="outboundQty"
|
|
|
|
|
class="form-input"
|
|
|
|
|
placeholder="请输入"
|
|
|
|
|
confirm-type="done"
|
|
|
|
|
/>
|
|
|
|
|
<text class="form-suffix-text">单位:{{ textValue(selectedSparepart.purchaseUnitName) }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="convert-row">
|
|
|
|
|
<text class="convert-label-inline">折算后库存数量:</text>
|
|
|
|
|
<text class="convert-value-inline">{{ calculatedStock }}</text>
|
|
|
|
|
<text class="convert-unit-inline">{{ stockUnitLabel(selectedSparepart) }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="convert-formula-inline">
|
|
|
|
|
{{ outboundQty || 0 }}{{ textValue(selectedSparepart.purchaseUnitName) }} × {{ textValue(selectedSparepart.purchaseUnitConvertQuantity) }}{{ stockUnitLabel(selectedSparepart) }} = {{ calculatedStock }}{{ stockUnitLabel(selectedSparepart) }}
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 经办人 -->
|
|
|
|
|
<view class="section-title-bar" style="padding-top: 24rpx;">
|
|
|
|
|
<view class="section-bar-line"></view>
|
|
|
|
|
<text class="section-title">经办人</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="select-row-card" @click="toggleOperatorDropdown">
|
|
|
|
|
<view class="full-dropdown">
|
|
|
|
|
<text :class="{ placeholder: !selectedOperator }">
|
|
|
|
|
{{ selectedOperator ? selectedOperator.label : '请选择经办人' }}
|
|
|
|
|
</text>
|
|
|
|
|
<text class="dropdown-arrow">▼</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view v-if="showOperatorDropdown" class="dropdown-panel">
|
|
|
|
|
<scroll-view scroll-y class="dropdown-scroll">
|
|
|
|
|
<view
|
|
|
|
|
v-for="item in operatorOptions"
|
|
|
|
|
:key="item.value"
|
|
|
|
|
class="dropdown-item"
|
|
|
|
|
:class="{ active: selectedOperator?.value === item.value }"
|
|
|
|
|
@click.stop="handleSelectOperator(item)"
|
|
|
|
|
>
|
|
|
|
|
<text class="dropdown-item-text">{{ item.label }}</text>
|
|
|
|
|
<text v-if="selectedOperator?.value === item.value" class="dropdown-check">✓</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view v-if="!operatorOptions.length" class="dropdown-empty">暂无数据</view>
|
|
|
|
|
</scroll-view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 空状态 -->
|
|
|
|
|
<view v-else class="empty-wrap">
|
|
|
|
|
<text class="empty-text">请扫码或选择备件</text>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 底部操作栏 -->
|
|
|
|
|
<view class="bottom-actions">
|
|
|
|
|
<view class="bottom-btn cancel-btn" @click="handleCancel">取消</view>
|
|
|
|
|
<view class="bottom-btn confirm-btn" @click="handleSubmit">确认出库</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { ref, computed } from 'vue'
|
|
|
|
|
import { onShow, onHide } from '@dcloudio/uni-app'
|
|
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
|
import NavBar from '@/components/common/NavBar.vue'
|
|
|
|
|
import { getSimpleUserList } from '@/api/mes/moldget'
|
|
|
|
|
import { getDeviceLedgerList } from '@/api/mes/moldoperate'
|
|
|
|
|
import { getEquipmentRepairListByDeviceId, getEquipmentMaintenanceByDeviceId } from '@/api/mes/equipment'
|
|
|
|
|
import { getDvRepairPage } from '@/api/mes/dvrepair'
|
|
|
|
|
import { getSparepartDetail } from '@/api/mes/sparepart'
|
|
|
|
|
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
|
|
|
|
const selectedSparepart = ref({})
|
|
|
|
|
const outboundQty = ref(null)
|
|
|
|
|
const selectedPurpose = ref('repair')
|
|
|
|
|
|
|
|
|
|
function setPurpose(value) {
|
|
|
|
|
selectedPurpose.value = value
|
|
|
|
|
// 切换用途时清空关联信息
|
|
|
|
|
selectedDevice.value = null
|
|
|
|
|
selectedRepairOrder.value = null
|
|
|
|
|
selectedMaintainOrder.value = null
|
|
|
|
|
repairOrderOptions.value = []
|
|
|
|
|
maintainOrderOptions.value = []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 关联信息 - 设备下拉
|
|
|
|
|
const deviceOptions = ref([])
|
|
|
|
|
const selectedDevice = ref(null)
|
|
|
|
|
const showDeviceDropdown = ref(false)
|
|
|
|
|
|
|
|
|
|
// 维修单下拉
|
|
|
|
|
const repairOrderOptions = ref([])
|
|
|
|
|
const selectedRepairOrder = ref(null)
|
|
|
|
|
|
|
|
|
|
// 保养单下拉
|
|
|
|
|
const maintainOrderOptions = ref([])
|
|
|
|
|
const selectedMaintainOrder = ref(null)
|
|
|
|
|
|
|
|
|
|
// 通用的订单下拉显示状态(根据当前用途自动切换)
|
|
|
|
|
const showOrderDropdown = ref(false)
|
|
|
|
|
const currentOrder = computed(() =>
|
|
|
|
|
selectedPurpose.value === 'repair' ? selectedRepairOrder.value : selectedMaintainOrder.value
|
|
|
|
|
)
|
|
|
|
|
const currentOrderOptions = computed(() =>
|
|
|
|
|
selectedPurpose.value === 'repair' ? repairOrderOptions.value : maintainOrderOptions.value
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 经办人下拉
|
|
|
|
|
const operatorOptions = ref([])
|
|
|
|
|
const selectedOperator = ref(null)
|
|
|
|
|
const showOperatorDropdown = ref(false)
|
|
|
|
|
|
|
|
|
|
// 备件图片(后端返回 images 字段,逗号分隔多图 URL,取第一张)
|
|
|
|
|
const sparepartImage = computed(() => {
|
|
|
|
|
const images = selectedSparepart.value.images
|
|
|
|
|
if (!images) return ''
|
|
|
|
|
if (Array.isArray(images)) return String(images[0] || '')
|
|
|
|
|
return String(images).split(',')[0]?.trim() || ''
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 折算后库存数量
|
|
|
|
|
const calculatedStock = computed(() => {
|
|
|
|
|
const qty = Number(outboundQty.value) || 0
|
|
|
|
|
const ratio = Number(selectedSparepart.value.purchaseUnitConvertQuantity) || 0
|
|
|
|
|
return qty * ratio
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function textValue(v) {
|
|
|
|
|
if (v === 0) return '0'
|
|
|
|
|
if (v == null) return '-'
|
|
|
|
|
const s = String(v).trim()
|
|
|
|
|
return s || '-'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function textUnit(v) {
|
|
|
|
|
if (v === 0) return '0'
|
|
|
|
|
if (v == null) return ''
|
|
|
|
|
return String(v).trim()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function stockUnitLabel(item) {
|
|
|
|
|
return item.unitName || item.minStockUnitName || '个'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleScan() {
|
|
|
|
|
uni.scanCode({
|
|
|
|
|
onlyFromCamera: true,
|
|
|
|
|
scanType: ['barCode', 'qrCode'],
|
|
|
|
|
success: (res) => {
|
|
|
|
|
console.log('扫码结果:', res.result)
|
|
|
|
|
uni.showToast({ title: '扫码成功: ' + res.result, icon: 'none' })
|
|
|
|
|
},
|
|
|
|
|
fail: () => {
|
|
|
|
|
uni.showToast({ title: '扫码失败', icon: 'none' })
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleCancel() {
|
|
|
|
|
uni.navigateBack()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleSelectSparepart() {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages_function/pages/sparepartInbound/sparepartSelect'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设备下拉
|
|
|
|
|
function toggleDeviceDropdown() {
|
|
|
|
|
showDeviceDropdown.value = !showDeviceDropdown.value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function handleSelectDevice(item) {
|
|
|
|
|
selectedDevice.value = item
|
|
|
|
|
showDeviceDropdown.value = false
|
|
|
|
|
// 切换设备时清空之前的订单选择
|
|
|
|
|
selectedRepairOrder.value = null
|
|
|
|
|
selectedMaintainOrder.value = null
|
|
|
|
|
repairOrderOptions.value = []
|
|
|
|
|
maintainOrderOptions.value = []
|
|
|
|
|
// 根据当前用途加载对应订单
|
|
|
|
|
if (selectedPurpose.value === 'repair') {
|
|
|
|
|
loadRepairOrders(item.deviceCode)
|
|
|
|
|
} else {
|
|
|
|
|
loadMaintainOrders(item.deviceCode)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function loadDevices() {
|
|
|
|
|
try {
|
|
|
|
|
const res = await getDeviceLedgerList({ pageNo: 1, pageSize: 100 })
|
|
|
|
|
const data = res && res.data !== undefined ? res.data : res
|
|
|
|
|
let list = []
|
|
|
|
|
if (Array.isArray(data)) { list = data }
|
|
|
|
|
else if (data && Array.isArray(data.data)) { list = data.data }
|
|
|
|
|
else if (data && data.data && Array.isArray(data.data.list)) { list = data.data.list }
|
|
|
|
|
else if (data && data.data && Array.isArray(data.data.rows)) { list = data.data.rows }
|
|
|
|
|
else if (data && data.data && Array.isArray(data.data.records)) { list = data.data.records }
|
|
|
|
|
else if (data && Array.isArray(data.list)) { list = data.list }
|
|
|
|
|
else if (data && Array.isArray(data.rows)) { list = data.rows }
|
|
|
|
|
else if (data && Array.isArray(data.records)) { list = data.records }
|
|
|
|
|
deviceOptions.value = list.map((d) => ({
|
|
|
|
|
value: d.id,
|
|
|
|
|
label: d.name || d.deviceName || d.deviceCode || String(d.id || ''),
|
|
|
|
|
deviceCode: d.deviceCode || d.code || '', // 用于查询维修单
|
|
|
|
|
deviceName: d.name || d.deviceName || ''
|
|
|
|
|
}))
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('loadDevices error', e)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 订单下拉(维修单/保养单)——根据当前用途自动切换
|
|
|
|
|
function toggleOrderDropdown() {
|
|
|
|
|
if (!selectedDevice.value) return
|
|
|
|
|
showOrderDropdown.value = !showOrderDropdown.value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleSelectOrder(item) {
|
|
|
|
|
if (selectedPurpose.value === 'repair') {
|
|
|
|
|
selectedRepairOrder.value = item
|
|
|
|
|
} else {
|
|
|
|
|
selectedMaintainOrder.value = item
|
|
|
|
|
}
|
|
|
|
|
showOrderDropdown.value = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 保养单列表(根据设备编码加载)
|
|
|
|
|
async function loadMaintainOrders(deviceCode) {
|
|
|
|
|
if (!deviceCode) {
|
|
|
|
|
const deviceId = selectedDevice.value?.value
|
|
|
|
|
if (deviceId) await loadMaintainOrdersById(deviceId)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
// 保养单用设备ID接口,暂不支持设备编码
|
|
|
|
|
const deviceId = selectedDevice.value?.value
|
|
|
|
|
if (deviceId) await loadMaintainOrdersById(deviceId)
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('loadMaintainOrders error', e)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function loadMaintainOrdersById(deviceId) {
|
|
|
|
|
if (!deviceId) return
|
|
|
|
|
try {
|
|
|
|
|
const res = await getEquipmentMaintenanceByDeviceId(deviceId)
|
|
|
|
|
const data = res && res.data !== undefined ? res.data : res
|
|
|
|
|
let list = []
|
|
|
|
|
if (Array.isArray(data)) { list = data }
|
|
|
|
|
else if (data && Array.isArray(data.data)) { list = data.data }
|
|
|
|
|
else if (data && data.data && Array.isArray(data.data.list)) { list = data.data.list }
|
|
|
|
|
else if (data && data.data && Array.isArray(data.data.rows)) { list = data.data.rows }
|
|
|
|
|
else if (data && data.data && Array.isArray(data.data.records)) { list = data.data.records }
|
|
|
|
|
else if (data && Array.isArray(data.list)) { list = data.list }
|
|
|
|
|
else if (data && Array.isArray(data.rows)) { list = data.rows }
|
|
|
|
|
else if (data && Array.isArray(data.records)) { list = data.records }
|
|
|
|
|
maintainOrderOptions.value = list.map((m) => ({
|
|
|
|
|
value: m.id,
|
|
|
|
|
label: m.maintenanceCode || m.code || m.maintenanceNo || m.no || String(m.id || '')
|
|
|
|
|
}))
|
|
|
|
|
console.log('保养单列表:', JSON.stringify(maintainOrderOptions.value))
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('loadMaintainOrdersById error', e)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 维修单列表(用分页接口获取所有状态的维修单)
|
|
|
|
|
async function loadRepairOrders(deviceCode) {
|
|
|
|
|
if (!deviceCode) {
|
|
|
|
|
// 如果没有设备编码,尝试用设备ID调用旧接口
|
|
|
|
|
const deviceId = selectedDevice.value?.value
|
|
|
|
|
if (deviceId) await loadRepairOrdersById(deviceId)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
const res = await getDvRepairPage({ machineryCode: deviceCode, pageNo: 1, pageSize: 100 })
|
|
|
|
|
const root = res && res.data !== undefined ? res.data : res
|
|
|
|
|
let list = []
|
|
|
|
|
if (Array.isArray(root)) { list = root }
|
|
|
|
|
else if (root && Array.isArray(root.data)) { list = root.data }
|
|
|
|
|
else if (root && root.data && Array.isArray(root.data.list)) { list = root.data.list }
|
|
|
|
|
else if (root && root.data && Array.isArray(root.data.rows)) { list = root.data.rows }
|
|
|
|
|
else if (root && root.data && Array.isArray(root.data.records)) { list = root.data.records }
|
|
|
|
|
else if (root && Array.isArray(root.list)) { list = root.list }
|
|
|
|
|
else if (root && Array.isArray(root.rows)) { list = root.rows }
|
|
|
|
|
repairOrderOptions.value = list.map((r) => ({
|
|
|
|
|
value: r.id,
|
|
|
|
|
label: r.repairCode || r.repairName || r.subjectName || String(r.id || '')
|
|
|
|
|
}))
|
|
|
|
|
console.log('维修单列表(分页):', JSON.stringify(repairOrderOptions.value))
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('loadRepairOrdersByDeviceCode error', e)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 兜底:用设备ID查(如果设备编码不存在)
|
|
|
|
|
async function loadRepairOrdersById(deviceId) {
|
|
|
|
|
if (!deviceId) return
|
|
|
|
|
try {
|
|
|
|
|
const res = await getEquipmentRepairListByDeviceId(deviceId)
|
|
|
|
|
const data = res && res.data !== undefined ? res.data : res
|
|
|
|
|
let list = []
|
|
|
|
|
if (Array.isArray(data)) { list = data }
|
|
|
|
|
else if (data && Array.isArray(data.data)) { list = data.data }
|
|
|
|
|
else if (data && data.data && Array.isArray(data.data.list)) { list = data.data.list }
|
|
|
|
|
else if (data && data.data && Array.isArray(data.data.rows)) { list = data.data.rows }
|
|
|
|
|
else if (data && data.data && Array.isArray(data.data.records)) { list = data.data.records }
|
|
|
|
|
else if (data && Array.isArray(data.list)) { list = data.list }
|
|
|
|
|
else if (data && Array.isArray(data.rows)) { list = data.rows }
|
|
|
|
|
else if (data && Array.isArray(data.records)) { list = data.records }
|
|
|
|
|
repairOrderOptions.value = list.map((r) => ({
|
|
|
|
|
value: r.id,
|
|
|
|
|
label: r.repairName || r.repairCode || r.subjectName || String(r.id || '')
|
|
|
|
|
}))
|
|
|
|
|
console.log('维修单列表(设备ID):', JSON.stringify(repairOrderOptions.value))
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('loadRepairOrdersById error', e)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleOperatorDropdown() {
|
|
|
|
|
showOperatorDropdown.value = !showOperatorDropdown.value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleSelectOperator(item) {
|
|
|
|
|
selectedOperator.value = item
|
|
|
|
|
showOperatorDropdown.value = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function loadOperators() {
|
|
|
|
|
try {
|
|
|
|
|
const res = await getSimpleUserList()
|
|
|
|
|
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
|
|
|
|
|
operatorOptions.value = data.map((u) => ({
|
|
|
|
|
value: u.id || u.userId,
|
|
|
|
|
label: u.nickname || u.userName || u.name || String(u.id || '')
|
|
|
|
|
}))
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('loadOperators error', e)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function handleSubmit() {
|
|
|
|
|
if (!selectedSparepart.value.id) {
|
|
|
|
|
uni.showToast({ title: '请先选择备件', icon: 'none' })
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (!outboundQty.value || Number(outboundQty.value) <= 0) {
|
|
|
|
|
uni.showToast({ title: '请输入出库数量', icon: 'none' })
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (!selectedOperator.value) {
|
|
|
|
|
uni.showToast({ title: '请选择经办人', icon: 'none' })
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (!selectedPurpose.value) {
|
|
|
|
|
uni.showToast({ title: '请选择出库用途', icon: 'none' })
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// TODO: 调用出库提交接口(后续补充)
|
|
|
|
|
uni.showToast({ title: t('functionCommon.createSuccess'), icon: 'success' })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onShow(async () => {
|
|
|
|
|
const selectResult = getApp().globalData?._sparepartSelectResult
|
|
|
|
|
if (selectResult) {
|
|
|
|
|
selectedSparepart.value = selectResult
|
|
|
|
|
// 补充获取备件详情(含供应商、图片等)
|
|
|
|
|
if (selectResult.id) {
|
|
|
|
|
try {
|
|
|
|
|
const res = await getSparepartDetail(selectResult.id)
|
|
|
|
|
const detail = res?.data || res
|
|
|
|
|
if (detail && detail.suppliers) {
|
|
|
|
|
selectedSparepart.value = { ...selectedSparepart.value, ...detail }
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('获取备件详情失败:', e)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
outboundQty.value = null
|
|
|
|
|
getApp().globalData._sparepartSelectResult = null
|
|
|
|
|
}
|
|
|
|
|
loadOperators()
|
|
|
|
|
loadDevices()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onHide(() => {
|
|
|
|
|
showOperatorDropdown.value = false
|
|
|
|
|
showDeviceDropdown.value = false
|
|
|
|
|
showOrderDropdown.value = false
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.page-container {
|
|
|
|
|
min-height: 100vh;
|
|
|
|
|
background: #f5f6f8;
|
|
|
|
|
padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.action-row {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 20rpx;
|
|
|
|
|
padding: 20rpx 24rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.action-btn {
|
|
|
|
|
flex: 1;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
gap: 12rpx;
|
|
|
|
|
height: 96rpx;
|
|
|
|
|
border-radius: 12rpx;
|
|
|
|
|
background: #1f4b79;
|
|
|
|
|
color: #fff;
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
|
|
|
|
.btn-icon-wrap { width: 44rpx; height: 44rpx; display: flex; align-items: center; justify-content: center; }
|
|
|
|
|
.btn-icon { font-size: 36rpx; color: #fff; }
|
|
|
|
|
.btn-text { font-size: 28rpx; font-weight: 600; color: #fff; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.sparepart-section { padding: 0; }
|
|
|
|
|
.section-title-bar { display: flex; align-items: center; gap: 10rpx; padding: 24rpx 24rpx 18rpx; }
|
|
|
|
|
.section-bar-line { width: 6rpx; height: 32rpx; border-radius: 3rpx; background: #2563eb; flex-shrink: 0; }
|
|
|
|
|
.section-title { font-size: 30rpx; font-weight: 700; color: #1a1a1a; }
|
|
|
|
|
|
|
|
|
|
.sparepart-card {
|
|
|
|
|
background: #fff; border-radius: 16rpx; padding: 24rpx; margin: 0 24rpx 20rpx;
|
|
|
|
|
box-shadow: 0 4rpx 16rpx rgba(15, 23, 42, 0.04);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.card-top { display: flex; position: relative; }
|
|
|
|
|
.card-image-wrap {
|
|
|
|
|
width: 160rpx; height: 160rpx; border-radius: 12rpx; overflow: hidden;
|
|
|
|
|
background: #f8fafc; border: 1rpx solid #f0f0f0; flex-shrink: 0; margin-right: 20rpx;
|
|
|
|
|
}
|
|
|
|
|
.card-image { width: 100%; height: 100%; }
|
|
|
|
|
.card-image-empty { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: #f8fafc; }
|
|
|
|
|
.empty-img-icon { font-size: 56rpx; opacity: 0.3; }
|
|
|
|
|
|
|
|
|
|
.card-info-right { flex: 1; min-width: 0; }
|
|
|
|
|
.info-item { display: flex; align-items: center; margin-bottom: 8rpx; }
|
|
|
|
|
.info-label { font-size: 26rpx; color: #6b7280; flex-shrink: 0; }
|
|
|
|
|
.info-name { font-size: 30rpx; font-weight: 700; color: #0f172a; }
|
|
|
|
|
.info-value { font-size: 26rpx; color: #374151; &.stock-highlight { color: #2563eb; font-weight: 500; } }
|
|
|
|
|
|
|
|
|
|
.card-bottom { margin-top: 20rpx; padding-top: 20rpx; border-top: 1rpx solid #f0f0f0; }
|
|
|
|
|
.detail-row { display: flex; align-items: center; margin-bottom: 14rpx;
|
|
|
|
|
&:last-child { margin-bottom: 0; }
|
|
|
|
|
&.two-col { justify-content: space-between; }
|
|
|
|
|
}
|
|
|
|
|
.detail-col { display: flex; align-items: center; flex: 1; }
|
|
|
|
|
.detail-label { font-size: 24rpx; color: #9ca3af; flex-shrink: 0; }
|
|
|
|
|
.detail-value { font-size: 24rpx; color: #4b5563; }
|
|
|
|
|
|
|
|
|
|
/* ====== 出库用途 ====== */
|
|
|
|
|
.purpose-card {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 20rpx;
|
|
|
|
|
margin: 0 24rpx 20rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.purpose-item {
|
|
|
|
|
flex: 1;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
gap: 12rpx;
|
|
|
|
|
height: 92rpx;
|
|
|
|
|
background: #fff;
|
|
|
|
|
border: 2rpx solid #e5e7eb;
|
|
|
|
|
border-radius: 14rpx;
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
color: #6b7280;
|
|
|
|
|
transition: all 0.2s;
|
|
|
|
|
|
|
|
|
|
&.active {
|
|
|
|
|
border-color: #2563eb;
|
|
|
|
|
background: #eff6ff;
|
|
|
|
|
color: #2563eb;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.purpose-icon {
|
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.qty-section { margin-top: 4rpx; }
|
|
|
|
|
.qty-input-card {
|
|
|
|
|
background: #fff; border-radius: 16rpx; padding: 24rpx; margin: 0 24rpx;
|
|
|
|
|
box-shadow: 0 4rpx 16rpx rgba(15, 23, 42, 0.04);
|
|
|
|
|
}
|
|
|
|
|
.form-field { display: flex; flex-direction: column; gap: 12rpx; }
|
|
|
|
|
.form-label { font-size: 26rpx; color: #4b5563; font-weight: 500; }
|
|
|
|
|
.form-input { width: 100%; height: 88rpx; padding: 0 24rpx; font-size: 28rpx; color: #374151; background: #f8fafc; border-radius: 14rpx; box-sizing: border-box; }
|
|
|
|
|
.form-suffix-text { display: block; margin-top: 10rpx; font-size: 24rpx; color: #9ca3af; }
|
|
|
|
|
|
|
|
|
|
.convert-row { margin-top: 20rpx; padding-top: 20rpx; border-top: 1rpx solid #f0f0f0; display: flex; align-items: center; }
|
|
|
|
|
.convert-label-inline { font-size: 26rpx; color: #6b7280; }
|
|
|
|
|
.convert-value-inline { font-size: 36rpx; font-weight: 700; color: #1f2937; margin-left: auto; }
|
|
|
|
|
.convert-unit-inline { font-size: 24rpx; color: #64748b; margin-left: 8rpx; }
|
|
|
|
|
.convert-formula-inline { margin-top: 10rpx; font-size: 22rpx; color: #9ca3af; }
|
|
|
|
|
|
|
|
|
|
.select-row-card {
|
|
|
|
|
position: relative; display: flex; align-items: center; justify-content: space-between;
|
|
|
|
|
background: #fff; border-radius: 16rpx; padding: 24rpx; margin: 0 24rpx 20rpx;
|
|
|
|
|
box-shadow: 0 4rpx 16rpx rgba(15, 23, 42, 0.04);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.warehouse-area-rows { width: 100%; display: flex; flex-direction: column; gap: 16rpx; }
|
|
|
|
|
.warehouse-area-row { display: flex; align-items: center; }
|
|
|
|
|
.warehouse-area-label { width: 120rpx; font-size: 26rpx; color: #6b7280; flex-shrink: 0; }
|
|
|
|
|
.warehouse-area-dropdown { flex: 1; min-width: 0; position: relative;
|
|
|
|
|
.dropdown-panel { position: absolute; top: 100%; left: 0; right: 0; z-index: 200; margin-top: 4rpx; background: #fff; border: 1rpx solid #e0e0e0; border-radius: 12rpx; box-shadow: 0 8rpx 30rpx rgba(0, 0, 0, 0.15); overflow: hidden; }
|
|
|
|
|
}
|
|
|
|
|
.warehouse-area-card { align-items: flex-start; }
|
|
|
|
|
|
|
|
|
|
.full-dropdown {
|
|
|
|
|
display: flex; align-items: center; justify-content: space-between;
|
|
|
|
|
width: 100%; font-size: 28rpx; color: #374151;
|
|
|
|
|
.placeholder { color: #9ca3af; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.dropdown-input { display: flex; align-items: center; height: 64rpx; padding: 0 20rpx; border: 1rpx solid #e0e0e0; border-radius: 10rpx; background: #f9fafb; }
|
|
|
|
|
.dropdown-value { flex: 1; font-size: 27rpx; color: #333; &.placeholder { color: #bbb; } }
|
|
|
|
|
.dropdown-arrow { font-size: 20rpx; color: #999; flex-shrink: 0; }
|
|
|
|
|
.dropdown-panel { position: absolute; top: 68rpx; left: 0; right: 0; z-index: 99; background: #fff; border: 1rpx solid #e0e0e0; border-radius: 12rpx; box-shadow: 0 8rpx 30rpx rgba(0, 0, 0, 0.1); overflow: hidden; }
|
|
|
|
|
.dropdown-scroll { max-height: 360rpx; }
|
|
|
|
|
.dropdown-item { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 24rpx; border-bottom: 1rpx solid #f0f0f0;
|
|
|
|
|
&:last-child { border-bottom: 0; }
|
|
|
|
|
&.active { background: #f0f5ff; }
|
|
|
|
|
}
|
|
|
|
|
.dropdown-item-text { font-size: 27rpx; color: #333; }
|
|
|
|
|
.dropdown-check { font-size: 28rpx; color: #2563eb; font-weight: 700; }
|
|
|
|
|
.dropdown-empty { padding: 32rpx; text-align: center; color: #999; font-size: 26rpx; }
|
|
|
|
|
|
|
|
|
|
.empty-wrap { padding: 160rpx 24rpx; text-align: center; }
|
|
|
|
|
.empty-text { font-size: 28rpx; color: #94a3b8; }
|
|
|
|
|
|
|
|
|
|
.bottom-actions {
|
|
|
|
|
position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 18rpx;
|
|
|
|
|
padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom));
|
|
|
|
|
background: #ffffff; box-shadow: 0 -8rpx 24rpx rgba(15, 23, 42, 0.06); z-index: 99;
|
|
|
|
|
}
|
|
|
|
|
.bottom-btn { flex: 1; height: 84rpx; line-height: 84rpx; text-align: center; border-radius: 16rpx; font-size: 30rpx; font-weight: 600;
|
|
|
|
|
&:active { opacity: 0.85; }
|
|
|
|
|
}
|
|
|
|
|
.cancel-btn { background: #eef2f7; color: #475569; }
|
|
|
|
|
.confirm-btn { background: #1f4b79; color: #ffffff; }
|
|
|
|
|
</style>
|