<script setup>
import { postWorkDataRecordUploadApi } from '@/api/elevator'

const content = ref('')

const instance = getCurrentInstance().proxy
const eventChannel = instance.getOpenerEventChannel()
const submit = async () => {
  console.log('提交')
  // uploadFile(tempFilePaths, async ({ url }) => {
  // await postWorkDataRecordUploadApi(
  //   [{ remark: '', attachmentUrl: url, attachmentType: 1 }],
  //   id
  // )
  const { id } = options.value
  await postWorkDataRecordUploadApi(
    [{ remark: content.value, attachmentUrl: '' }],
    id
  )
  uni.navigateBack()

  eventChannel.emit('done', {})
}

const options = ref({})
onLoad(async (e) => {
  options.value = e
})
</script>

<template>
  <view px-28 mt-20>
    <up-textarea
      v-model="content"
      placeholder="请输入..."
      maxlength="300"
      count
      height="150"
    />
  </view>

  <view position="fixed" w-full bottom-36 f-c-c>
    <up-button
      type="primary"
      text="完成"
      :custom-style="{
        width: '650rpx'
      }"
      @click="submit"
    />
  </view>
</template>
