<template>
  <div>
    <AModal v-model:open="data.isShowModal" title="流程操作" width="30%" @cancel="_close" @ok="handleConfirm">
      <AForm ref="formRef" :model="form" :rules="rules" :label-col="{ span: 8 }" labelAlign="left"
             :labelWrap="true">
        <ARow :gutter="24">
          <ACol :span="12">
            <AFormItem label="审核结果" name="dataCenterName">
              <!-- 单选框，通过，不通过 -->
              <ARadioGroup v-model:value="form.status" buttonStyle="solid">
                <ARadio :value="3">通过</ARadio>
                <ARadio :value="4">不通过</ARadio>
              </ARadioGroup>
            </AFormItem>
          </ACol>
          <ACol :span="24">
            <AFormItem :label-col="{ span: 4 }" :label="$t('page.inventory_inboundapplication.notes')" name="notes">
              <ATextarea v-model:value="form.notes" :rows="3" allowClear
                         :placeholder="$t('common.placeholderIn')"/>
            </AFormItem>
          </ACol>
        </ARow>
      </AForm>
    </AModal>
  </div>
</template>

<script setup lang="ts">
import {reactive} from "vue";
import {$t} from "@/locales";

let form = reactive({
  status: 3,
  notes: '',
})

const data = reactive({
  isShowModal: false,
  resolve: null,
  reject: null,
})

function handleConfirm() {
  //回调
  data.resolve ? data.resolve({...form}) : '';
  _close();
}

function _open() {
  data.isShowModal = true;
  return new Promise((resolve, reject) => {
    data.resolve = resolve;
    data.reject = reject;
  });
}

function _close() {
  data.isShowModal = false;
  form = reactive({
    status: 3,
    notes: '',
  })
  data.reject ? data.reject() : '';
}

defineExpose({_open, _close});
</script>

<style scoped>

</style>
