import { useWeAppAuthStore } from '@/common'
import useModel from './model'
import { Apis } from '@/gen/Apis'
import { getApiLoading } from '@/common/libraries/apiLoading'
const auth = useWeAppAuthStore()
import { showToastBack, showToast } from '@/common/libraries/naviHelper'
export default {
  init(data: any) {
    useModel.HouseWorkOrdersAcceptResultEnum.value = {
      Processing2: { text: '是', value: '1' },
      Processing1: { text: '否', value: '0' }
    }
    useModel.formData.value = {
      ...data
    }
  },
  handleSubmit() {
    let data = useModel?.formData?.value
    if (!data?.is_completed) {
      return showToast('请选择是否已经完工！')
    }
    if (data?.is_completed === '0' && !data?.accept_remark) {
      return showToast('请先输入原因！')
    }
    getApiLoading(Apis.WorkOrder.HouseWorkOrders.Accept, {
      ...data,
      is_completed: data?.is_completed === '1' ? true : false
    }).then(res => {
      showToastBack('提交成功！', 1, true)
      console.log(res)
    })
  }
}
