<template>
  <el-form :model="form" label-width="130px" 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="remark">
          <el-input v-model="form.remark" placeholder="请填写备注" :rows="5" type="textarea" />
        </el-form-item>
      </div>
    </div>
    <div class="flex justify-end">
      <el-button type="primary" size="default" @click="doSave(ruleForm)">确定</el-button>
    </div>
  </el-form>
</template>

<script lang="ts" setup>
import type { FormInstance, FormRules } from 'element-plus'
import { managePayConfigRemark } from '@/api/iPayment/index'
const props = defineProps({
  primary: Object | null,
});
const ruleForm = ref<FormInstance>()
const loading = ref(false)
const rules = reactive({
  remark: [
    {
      required: false,
      message: '请输入备注',
      trigger: 'blur'
    }
  ],
});
const form = ref({})
const emit = defineEmits(['close']);
const doSave = (formEl: FormInstance | undefined) => {
  if (!formEl) return;
  formEl
    .validate(valid => {
      if (valid) {
        managePayConfigRemark(form.value).then(res => {
          ElMessage.success(res.message)
          loading.value = false;
          emit('close')
        })
      } else {
        loading.value = false;
      }
    })
    .then(() => { });
}

if (props.primary) {
  form.value.remark = props.primary.remark
  form.value.id = props.primary.id
}


onMounted(() => {

})

</script>

<style lang="scss" scoped>
::v-deep(.el-input__wrapper) {
  display: flex;
  width: 180px;
  flex: none;
}

.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}
</style>
