<template>
  <el-form :model="formData" label-width="120px" ref="ruleForm" :rules="rules" v-loading="loading" class="pr-4">
    <div class="flex flex-row justify-between">
      <div class="w-full">
        <el-form-item label="支付通道" prop="pay_channel">
          <el-input v-model="formData.pay_channel" placeholder="请输入支付通道" />
        </el-form-item>
        <el-form-item label="银行流水" prop="pay_no" v-if="props.primary.isShowPayNo">
          <el-input v-model="formData.pay_no" placeholder="请输入银行流水" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="formData.remark" placeholder="请输入备注" />
        </el-form-item>
      </div>
    </div>
    <div class="flex justify-end">
      <el-button type="primary" @click="submitForm(ruleForm)">{{ $t('system.confirm') }}</el-button>
    </div>
  </el-form>
</template>

<script lang="ts" setup>
import { useCreate } from '@/hook/curd/useCreate';
import { useShow } from '@/hook/curd/useShow';
import type { FormInstance, FormRules } from 'element-plus'
import { jiesuanManageFinanceCheckRemit } from '@/api/settlement/index'
const ruleForm = ref<FormInstance>()
import { onMounted, ref } from 'vue';
const props = defineProps({
  primary: Object,
});
const formData = ref({})
const rules = reactive({
  pay_channel: [{
    required: true,
    message: '请输入支付通道',
    trigger: 'blur'
  },],
  pay_no: [
    {
      required: true,
      message: '请输入银行流水',
      trigger: 'blur'
    },
  ],
});
const loading = ref(false)
const submitForm = (formEl: FormInstance | undefined) => {
  console.log(formData.value, 'formData.valueformData.value');
  if (!formEl) return;
  formEl
    .validate(valid => {
      if (valid) {
        jiesuanManageFinanceCheckRemit(formData.value).then(res => {
          ElMessage.success(res.message)
          emit('close')
          loading.value = false;
        })
      } else {
        loading.value = false;
      }
    })
    .then(() => { });
}

if (props.primary) {
  formData.value.id = props.primary.id
  formData.value.status = props.primary.status
  console.log(props.primary, 'props.primaryprops.primary');
}

const emit = defineEmits(['close']);
onMounted(() => {

});
</script>

<style lang="scss" scoped>
.withdraw-popup-warn {
  padding: 10px;
  color: red;
  margin-bottom: 10px;
  line-height: 1.8;
  padding-left: 30px;
  font-size: 12px;
  background-color: #ffecf4;
}
</style>
