| | |
| | | |
| | | <script setup> |
| | | import { ref, computed, onMounted, onUnmounted } from 'vue'; |
| | | import { onShow } from '@dcloudio/uni-app'; |
| | | import { onShow, onUnload } from '@dcloudio/uni-app'; |
| | | import PageHeader from '@/components/PageHeader.vue'; |
| | | import { getDeviceLedger } from '@/api/equipmentManagement/ledger'; |
| | | import { addUpkeep, editUpkeep, getUpkeepById } from '@/api/equipmentManagement/upkeep'; |
| | |
| | | icon: 'none' |
| | | }) |
| | | } |
| | | |
| | | const normalizeId = (raw) => { |
| | | if (raw === null || raw === undefined) return undefined; |
| | | const val = String(raw).trim(); |
| | | if (!val || val === 'undefined' || val === 'null') return undefined; |
| | | return val; |
| | | }; |
| | | |
| | | // 表单引用 |
| | | const formRef = ref(null); |
| | |
| | | if (code == 200) { |
| | | showToast(`${id ? "编辑" : "新增"}计划成功`); |
| | | setTimeout(() => { |
| | | uni.removeStorageSync('repairId'); |
| | | uni.navigateBack(); |
| | | }, 1500); |
| | | } else { |
| | |
| | | uni.navigateBack(); |
| | | }; |
| | | |
| | | // 获取页面ID |
| | | const getPageId = () => { |
| | | return normalizeId(uni.getStorageSync('repairId')); |
| | | }; |
| | | |
| | | // 获取页面参数 |
| | | const getPageParams = () => { |
| | | // 从本地存储获取id |
| | | const id = uni.getStorageSync('repairId'); |
| | | |
| | | // 根据是否有id参数来判断是新增还是编辑 |
| | | const id = getPageId(); |
| | | if (id) { |
| | | // 编辑模式,获取详情 |
| | | loadForm(id); |
| | | } else { |
| | | // 新增模式 |
| | | operationType.value = 'add'; |
| | | loadForm(); |
| | | } |
| | | }; |
| | | |
| | | // 获取页面ID |
| | | const getPageId = () => { |
| | | // 从本地存储获取id |
| | | return uni.getStorageSync('repairId'); |
| | | }; |
| | | onUnload(() => { |
| | | uni.removeStorageSync('repairId'); |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |