style:模具模块-手动输入编码方式传参改用code

master
黄伟杰 4 weeks ago
parent a3c8c7e412
commit bf62c5df31

@ -1,11 +1,11 @@
import upload from '@/utils/upload' import upload from '@/utils/upload'
import request from '@/utils/request' import request from '@/utils/request'
export function getMoldDetail(id) { export function getMoldDetail(id, params = {}) {
return request({ return request({
url: '/admin-api/erp/mold-brand/mold/get', url: '/admin-api/erp/mold-brand/mold/get',
method: 'get', method: 'get',
params: { id } params: { id, ...params }
}) })
} }

@ -207,6 +207,8 @@ import { DICT_TYPE, getDictLabel, initAllDict } from '@/utils/dict'
const loading = ref(false) const loading = ref(false)
const moldId = ref(undefined) const moldId = ref(undefined)
const moldCode = ref(undefined)
const moldType = ref(undefined)
const detailData = ref(null) const detailData = ref(null)
const inspectionList = ref([]) const inspectionList = ref([])
const maintainList = ref([]) const maintainList = ref([])
@ -312,24 +314,30 @@ function handleTabChange(e) {
} }
onLoad((query) => { onLoad((query) => {
const rawId = query && (query.id !== undefined ? query.id : query.code) const rawId = query && query.id
const decoded = rawId ? decodeURIComponent(String(rawId)) : '' const decoded = rawId ? decodeURIComponent(String(rawId)) : ''
moldId.value = decoded ? decoded : undefined moldId.value = decoded ? decoded : undefined
moldType.value = query && query.type
moldCode.value = query && query.code
fetchAll() fetchAll()
}) })
async function fetchAll() { async function fetchAll() {
if (!moldId.value) { if (!moldId.value && !moldCode.value) {
uni.showToast({ title: '缺少模具ID', icon: 'none' }) uni.showToast({ title: '缺少模具ID', icon: 'none' })
return return
} }
loading.value = true loading.value = true
try { try {
const isScan = moldType.value === 'scan'
const idParam = isScan ? { id: moldId.value } : { code: moldCode.value }
const moldIdParam = isScan ? { moldId: moldId.value } : { code: moldCode.value }
const [detailRes, inspectionRes, maintainRes, repairRes] = await Promise.all([ const [detailRes, inspectionRes, maintainRes, repairRes] = await Promise.all([
getMoldDetail(moldId.value), getMoldDetail(moldId.value, idParam),
getMoldInspectionByMoldId(moldId.value), getMoldInspectionByMoldId(moldId.value, moldIdParam),
getMoldMaintenanceByMoldId(moldId.value), getMoldMaintenanceByMoldId(moldId.value, moldIdParam),
getMoldRepairListByMoldId(moldId.value) getMoldRepairListByMoldId(moldId.value, moldIdParam)
]) ])
detailData.value = detailRes.data detailData.value = detailRes.data
inspectionList.value = normalizeList(inspectionRes) inspectionList.value = normalizeList(inspectionRes)

@ -35,13 +35,8 @@
<view class="input-section"> <view class="input-section">
<view class="input-label">手动输入模具编码</view> <view class="input-label">手动输入模具编码</view>
<view class="input-wrapper"> <view class="input-wrapper">
<input <input v-model="moldCode" class="code-input" type="text" placeholder="请输入模具编码"
v-model="moldCode" placeholder-class="input-placeholder" />
class="code-input"
type="text"
placeholder="请输入模具编码"
placeholder-class="input-placeholder"
/>
</view> </view>
<view class="confirm-btn" :class="{ active: moldCode.length > 0 }" @click="confirmInput"> <view class="confirm-btn" :class="{ active: moldCode.length > 0 }" @click="confirmInput">
<text class="btn-text">确定</text> <text class="btn-text">确定</text>
@ -120,12 +115,20 @@ function confirmInput() {
return; return;
} }
navigateToDetail(moldCode.value.trim()); navigateToDetail(moldCode.value.trim(), 'input');
} }
function navigateToDetail(id) { function navigateToDetail(id, type = 'scan') {
let url
if (type === 'scan') {
//
url = `/pages_function/pages/mold/detail?id=${encodeURIComponent(id)}&type=${type}`
} else {
//
url = `/pages_function/pages/mold/detail?code=${moldCode.value}&type=${type}`
}
uni.navigateTo({ uni.navigateTo({
url: `/pages_function/pages/mold/detail?id=${encodeURIComponent(id)}` url: url
}); });
} }
@ -223,9 +226,11 @@ function navigateToDetail(id) {
0% { 0% {
top: 20rpx; top: 20rpx;
} }
50% { 50% {
top: 260rpx; top: 260rpx;
} }
100% { 100% {
top: 20rpx; top: 20rpx;
} }

Loading…
Cancel
Save