<template>
  <BasicModal
  :maskClosable="false"
    :width="500"
    @register="registerModal"
    v-bind="$attrs"
    :title="getTitle"
    @ok="handleSubmit"
  >
    <div class="modal-box">
      <div><BasicForm @register="registerForm" /></div>
    </div>
  </BasicModal>
</template>
<script lang="ts">
import { defineComponent, ref, computed, unref, reactive, onMounted } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index';
const { createMessage } = useMessage();
import { useMessage } from '/@/hooks/web/useMessage';
import { getHangduingConfigUpdate } from '/@/api/swHome/index';
import { useUserStore } from '/@/store/modules/user';
import { tenantFormSchema } from '../columnsProcessing';
const userStore = useUserStore();
export default defineComponent({
  name: 'AccountModal',
  components: { BasicModal, BasicForm },
  setup(_, { emit }) {

    const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
      setFieldsValue(data.data);
    });
    const [registerForm, { setFieldsValue, updateSchema, resetFields, validate, getFieldsValue }] =
      useForm({
        labelWidth: 140,
        schemas: tenantFormSchema,
        showActionButtonGroup: false,
        actionColOptions: {
          span: 18,
        },
      });
    const getTitle = ref('编辑');
    async function handleSubmit() {
      try {
        let formData = getFieldsValue();
        getHangduingConfigUpdate(formData).then((res) => {
          if (res.code == 200) {
            createMessage.success(res.msg);
            closeModal();
            emit('success');
          } else {
            createMessage.warning(res.msg);
          }
        });
      } finally {
        setTimeout(() => {
          setModalProps({ confirmLoading: false });
        }, 300);
      }
    }
    return {
      registerModal,
      getTitle,
      handleSubmit,
      registerForm,
    };
  },
});
</script>
<style lang="less" scoped>
// .modal-box {
//   display: flex;
//   & > div:nth-child(1) {
//     width: 40%;
//   }
//   & > div:nth-child(2) {
//     width: 60%;
//   }
// }
::v-deep(.ant-calendar-picker) {
  width: 100% !important;
}
::v-deep(.ant-input-number) {
  width: 100% !important;
}
</style>
