<template>
  <div>
    <Spin fix v-if="loading">
      <div class="loader">
        <svg class="circular" viewBox="25 25 50 50">
          <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="5" stroke-miterlimit="10"></circle>
        </svg>
      </div>
      <div>正在标记为已创建，请稍后...</div>
    </Spin>
    <div v-else v-html="message"></div>
    <businessButton :btn-config="btnConfig" />
  </div>
</template>

<script lang="js">
  import businessButton from 'professionalComponents/businessButton';
  import { jitDelivery } from '@yunque/service/index';

  export default {
    name: 'JitDelivery_EditPoDelivery',
    components: {
      businessButton
    },
    props: {
      idArray: { // 获取ID用于多选
        type: Array,
        default: () => []
      },
    },
    async created() {
      try {
        try {
          let data = await jitDelivery.editPoDelivery(this.idArray[0]);

          if (data.code != 0) {
            this.message = data.message;
          } else {
            this.message = '标记为已创建成功';
          }
        } catch (e) {
          console.log(e);
          this.message = '系统出现异常，请联系管理员！';
        }
      } finally {
        this.loading = false;
      }
    },
    data() {
      return {
        loading: true,
        message: '',
        btnConfig: {
          typeAll: 'error', // 按钮统一风格样式
          btnsite: 'right', // 按钮位置 (right , center , left)
          buttons: [
            {
              type: '', // 按钮类型
              text: '确定', // 按钮文本
              icon: '', // 按钮图标
              size: '', // 按钮大小
              disabled: false, // 按钮禁用控制
              btnclick: () => {
                this.closeDialog(true);
              }, // 按钮点击事件
            }
          ]
        }
      };
    },
    methods: {
      /**
       * 关闭弹窗
       * @param refreshGrid 关闭后是否刷新列表
       */
      closeDialog(refreshGrid = false) {
        this.$emit('closeActionDialog', refreshGrid);
      }
    }
  };
</script>
