ProductInvoice.vue 2.23 KB
<template>
  <BasicModal
    v-bind="$attrs"
    @register="register"
    title="生产对账单"
    width="500px"
    :bodyStyle="{ height: '140px' }"
    @ok="handleOk"
    @visible-change="handleShow"
  >
    <a-space direction="vertical">
      <div style="margin: 16px 0"></div>
      <div class="divAll">
        <div
          style="
            margin-left: 22px;
            margin-right: 5px;
            width: 100px;
            text-align: center;
            line-height: 30px;
          "
          >生产科对账单号</div
        ><a-input v-model:value="Input1" placeholder="请输入" style="width: 320px" />
      </div>
      <div class="divAll">
        <div
          style="
            margin-left: 0px;
            margin-right: 1px;
            width: 180px;
            text-align: center;
            line-height: 30px;
          "
          >生产科应付款日期</div
        ><a-input v-model:value="Input2" disabled />
      </div> </a-space
  ></BasicModal>
</template>
<script lang="ts" setup>
  import { BasicModal, useModalInner } from '@/components/Modal';
  import { computed, ref } from 'vue';
  import { payDate, checkCreate } from '@/api/project/invoice';
  import { useMessage } from '/@/hooks/web/useMessage';

  const { createMessage } = useMessage();
  const { error } = createMessage;
  const emit = defineEmits(['success']);
  const Input1 = ref('');
  const Input2 = ref();
  const res = ref();
  const [register, { closeModal }] = useModalInner(async (data) => {
    res.value = data.data;
    Input2.value = await payDate({ orderIds: res.value });
  });
  const isDisabled = ref(false);

  async function handleOk() {
    if (isDisabled.value) {
      error('请勿连续点击生成按钮,需要等待三秒再点击生成');
      return;
    }
    isDisabled.value = true;
    setTimeout(() => {
      isDisabled.value = false;
    }, 3000);
    await checkCreate({
      orderIds: res.value,
      payedDate: Input2.value,
      checkNo: Input1.value,
    });
    emit('success');
    closeModal();
  }
  function handleShow(visible: boolean) {
    if (!visible) {
      Input1.value = '';
    }
  }
</script>
<style scoped>
  .divAll {
    display: flex;
    justify-content: center;
    align-items: center;
  }
</style>