<template> 
 | 
  <view> 
 | 
    <CardTitle title="绞线盘具领用" :hideAction="false" /> 
 | 
    <PlateForm ref="formRef" class="mx-4" /> 
 | 
    <view class="footer"> 
 | 
      <wd-button 
 | 
        class="submit_btn" 
 | 
        type="primary" 
 | 
        size="large" 
 | 
        block 
 | 
        :round="false" 
 | 
        @click="handleSubmit" 
 | 
      > 
 | 
        保存 
 | 
      </wd-button> 
 | 
    </view> 
 | 
  </view> 
 | 
  <wd-toast /> 
 | 
</template> 
 | 
<script lang="ts" setup> 
 | 
import CardTitle from "@/components/card-title/index.vue"; 
 | 
import PlateForm from "./form.vue"; 
 | 
import { useToast } from "wot-design-uni"; 
 | 
import { onLoad, onUnload } from "@dcloudio/uni-app"; 
 | 
  
 | 
const formRef = ref(); 
 | 
const toast = useToast(); 
 | 
  
 | 
const handleSubmit = async () => { 
 | 
  const success = await formRef.value.submitEdit(); 
 | 
  if (success) { 
 | 
    setTimeout(() => { 
 | 
      uni.navigateBack(); 
 | 
    }, 500); 
 | 
  } 
 | 
}; 
 | 
  
 | 
// 接收列表页传递的数据 
 | 
const receiveEditData = (data: any) => { 
 | 
  console.log("receiveEditData 接收到的数据:", data); 
 | 
  if (data && formRef.value) { 
 | 
    // 确保 list 和 editId 都存在 
 | 
    if (data.list && data.editId) { 
 | 
      formRef.value.setFormData(data.list, data.editId); 
 | 
    } else { 
 | 
      console.error("数据格式错误:", data); 
 | 
    } 
 | 
  } 
 | 
}; 
 | 
  
 | 
onLoad((options: any) => { 
 | 
  // 监听数据传递事件 
 | 
  uni.$on("plateEditData", receiveEditData); 
 | 
}); 
 | 
  
 | 
onUnload(() => { 
 | 
  // 页面卸载时移除监听 
 | 
  uni.$off("plateEditData", receiveEditData); 
 | 
}); 
 | 
</script> 
 | 
<style lang="scss" scoped> 
 | 
.footer { 
 | 
  margin: 20px 16px 0 16px; 
 | 
} 
 | 
</style> 
 |