|
|
|
|
@ -70,33 +70,66 @@ import { onLoad } from '@dcloudio/uni-app'
|
|
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
|
import NavBar from '@/components/common/NavBar.vue'
|
|
|
|
|
import { createTaskManagementTicket } from '@/api/mes/taskManagement'
|
|
|
|
|
|
|
|
|
|
import { getDeviceLedgerList } from '@/api/mes/deviceLedger'
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
|
|
|
|
const detailData = reactive({})
|
|
|
|
|
const ticketLoading = ref(false)
|
|
|
|
|
|
|
|
|
|
const deviceOptions = ref([])
|
|
|
|
|
const taskTypeText = computed(() => {
|
|
|
|
|
const normalized = Number(detailData.taskType)
|
|
|
|
|
if (normalized === 1) return t('equipmentInspectionTasks.taskTypeInspect')
|
|
|
|
|
if (normalized === 2) return t('equipmentInspectionTasks.taskTypeMaintain')
|
|
|
|
|
return textValue(detailData.taskType)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
async function ensureDeviceOptionsLoaded() {
|
|
|
|
|
try {
|
|
|
|
|
const res = await getDeviceLedgerList()
|
|
|
|
|
const root = res && res.data !== undefined ? res.data : res
|
|
|
|
|
const data = Array.isArray(root) ? root : (Array.isArray(root?.data) ? root.data : root?.list || [])
|
|
|
|
|
deviceOptions.value = (Array.isArray(data) ? data : [])
|
|
|
|
|
.filter((item) => item && item.id !== undefined && item.id !== null)
|
|
|
|
|
.map((item) => ({
|
|
|
|
|
id: item.id,
|
|
|
|
|
label: `${item.deviceCode || ''} ${item.deviceName || ''}`.trim(),
|
|
|
|
|
deviceName: item.deviceName || '',
|
|
|
|
|
raw: item
|
|
|
|
|
}))
|
|
|
|
|
} catch (error) {
|
|
|
|
|
deviceOptions.value = []
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const deviceListText = computed(() => {
|
|
|
|
|
const value = detailData.deviceListText || detailData.deviceList
|
|
|
|
|
if (Array.isArray(value)) return value.join(',') || '-'
|
|
|
|
|
return textValue(value)
|
|
|
|
|
/* if (Array.isArray(value)) return value.join(',') || '-'
|
|
|
|
|
return textValue(value)*/
|
|
|
|
|
const ids = parseIdsValue(value)
|
|
|
|
|
if (!ids.length) return '-'
|
|
|
|
|
const names = ids
|
|
|
|
|
.map((id) => {
|
|
|
|
|
const matched = deviceOptions.value.find((item) => String(item.id) === id)
|
|
|
|
|
return matched?.deviceName || matched?.label || id
|
|
|
|
|
})
|
|
|
|
|
.filter(Boolean)
|
|
|
|
|
return names.length ? names.join(',') : '-'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onLoad(() => {
|
|
|
|
|
function parseIdsValue(value) {
|
|
|
|
|
if (!value) return []
|
|
|
|
|
if (Array.isArray(value)) return value.map((item) => String(item).trim()).filter(Boolean)
|
|
|
|
|
return String(value).split(',').map((item) => item.trim()).filter(Boolean)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onLoad(async () => {
|
|
|
|
|
try {
|
|
|
|
|
const cached = uni.getStorageSync('equipmentInspectionTasksDetail')
|
|
|
|
|
if (cached) {
|
|
|
|
|
Object.assign(detailData, JSON.parse(cached))
|
|
|
|
|
uni.removeStorageSync('equipmentInspectionTasksDetail')
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {}
|
|
|
|
|
await Promise.all([ensureDeviceOptionsLoaded()])
|
|
|
|
|
} catch (error) {
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
async function handleCreateTicket() {
|
|
|
|
|
|