<script setup lang='ts'>
import request from '~/request'
const router = useRouter()

function onClickLeft() {
  router.back()
}

const form = reactive({
  // axa_sycj_zdysyid_v2: undefined,
  axa_name: undefined,
  axa_mssc: '',
  axa_sycj_syxb_v2: 'male'
})
function onSubmit(values: any) {
  console.log('submit', values);
  request({
    url: '/aimooc/xnszr_audio/add',
    data: {
      aimooc_xnszr_audio: {
        ...form,
        axa_is_system: 2
      }
    }
  }).then(res => {
    const info = res.data.one_info
    console.log('info : ', info)
    // {
    //   "axa_id": "58",
    //   "axa_sycj_json_v2": "",
    //   "axa_sycj_syxb_v2": "male",
    //   "axa_sycj_sywj_v2": "bbe539bb8ad24e4ea14e36e16922c9cf",
    //   "axa_sycj_zdysyid_v2": "szbzaimooc170348221150",
    //   "axa_sycj_shzt_v2": "3",
    //   "axa_sycj_scbz_v2": "0",
    //   "axa_keyword": "",
    //   "axa_name": "朱凡1",
    //   "axa_img": "",
    //   "axa_file": "",
    //   "axa_code": "",
    //   "axa_yyfw": "",
    //   "axa_bzms": "",
    //   "axa_mssc": "朱凡测试1",
    //   "axa_status": "2",
    //   "axa_ext": null,
    //   "axa_scenario_v2": "",
    //   "axa_is_system": "2",
    //   "area_id1": "10",
    //   "area_id2": "166",
    //   "area_id3": "2069",
    //   "area_id4": "0",
    //   "sm_id": "3",
    //   "dept_id": "0",
    //   "user_id": "0",
    //   "create_user_id": "199200",
    //   "modify_user_id": "0",
    //   "create_dateline": "1703482211",
    //   "modify_dateline": "0",
    //   "isdelete": "0",
    //   "create_dateline_format": "2023-12-25 13:30:11"
    // }
    router.replace({ name: "caiji-sy-record-id", params: { id: info.axa_sycj_zdysyid_v2 } })
  })
};

</script>

<template>
  <van-nav-bar title="声音命名" left-arrow @click-left="onClickLeft"></van-nav-bar>
  <div class="flex-auto py-4 ">
    <van-form class="h-full flex flex-col" @submit="onSubmit">
      <van-cell-group inset>
        <!-- <van-field v-model="form.axa_sycj_zdysyid_v2" name="声音id" label="声音id" placeholder="自定义的声音id，英文或拼音"
          :rules="[{ required: true, message: '' }]" /> -->
        <van-field v-model="form.axa_name" name="声音名字" label="声音名字" placeholder="声音名字，一般为中文名"
          :rules="[{ required: true, message: '声音名字不能为空' }]" />
        <van-field name="性别" label="性别" :rules="[{ required: true, message: '性别不能为空' }]">
          <template #input>
            <van-radio-group v-model="form.axa_sycj_syxb_v2" direction="horizontal">
              <van-radio name="male">男性</van-radio>
              <van-radio name="female">女性</van-radio>
            </van-radio-group>
          </template>
        </van-field>
        <van-field v-model="form.axa_mssc" name="声音描述" label="声音描述" placeholder="声音描述" rows="3" autosize type="textarea"
          :rules="[{ required: true, message: '声音描述不能为空' }]" />
      </van-cell-group>
      <div class="px-4 mt-20">
        <van-button block type="primary" native-type="submit">
          提交
        </van-button>
      </div>
    </van-form>
  </div>
</template>