<template>
  <view class="u-p-30">
    <NameGenderAge />

    <uni-card title="评分标准" :border="false">
      <uni-data-checkbox mode="list" v-model="formData.value" :localdata="MRS_LIST"></uni-data-checkbox>

      <view class="flex justify-center u-p-30">
        <u-button type="primary" size="medium" @click="onSubmit" class="bg-main" shape="circle">提交</u-button>
      </view>
    </uni-card>
  </view>
</template>

<script lang="ts" setup>
import { reactive } from 'vue';
import { MRS_LIST } from '@/config/service'
import { useGetFirstAidId } from '@/hooks/useGetFirstAidId';

const { firstAidId } = useGetFirstAidId()

const formData = reactive({ value: '' })

async function onSubmit() {
  try {
    const answer = [formData.value]
    const param = { codeAndAnswerList: [{ questionCode: 'RYPG-MRS', answer, time: '' }], firstAidId: firstAidId?.value, sourceId: '', sourceType: '' }
    await uni.$u.api.updateAidCode(param)
    uni.$u.toast('更新成功')

    // 更新数据
    uni.$u.openPage('detail2', true, `firstAidId=${firstAidId.value}`)
    // uni.navigateBack()
  } catch (error) {
    uni.$u.alertError(error)
  }
}
</script>
