<script lang="js">
  import IframeContent from '@yunque/component/IframeContent';
  import { showModalFcError } from '@yunque/service/modules/utils';
  import { common } from '@yunque/service/index';

  export default {
    name: 'OMSPrintOrderPrintTaoda',
    mixins: [IframeContent],
    props: {
      idArray: { // 获取ID用于多选
        type: Array,
        default: () => []
      }
    },
    async created() {
      try {
        let param = {
          table: 'T_V_OMSPRINTORDER',
          startindex: 0,
          range: 1000,
          fixedcolumns: {
            ID: this.idArray
          },
          isdroplistsearch: true,
          fkdrplist: {
            searchcols: ['PAYTYPE', 'SHIPPERID', 'ORDERSHOPID']
          }
        };
        let rsp = await common.listQuery(param);
        let payTypes = rsp.rows.map(a => a.PAYTYPE.val);
        let shipperIds = rsp.rows.map(a => a.SHIPPERID.refobjid);
        let orderShopIds = rsp.rows.map(a => a.ORDERSHOPID.refobjid);

        // 改成统一由DB判断，前端无需再校验
        // if ([...new Set(payTypes)].length > 1) {
        //   showModalFcError('友情提示', '请选择“面单类型”一致的单据');
        //   this.closeDialog();
        // } else if ([...new Set(shipperIds)].length > 1) {
        //   showModalFcError('友情提示', '请选择“物流公司”一致的单据');
        //   this.closeDialog();
        // } else if ([...new Set(orderShopIds)].length > 1) {
        //   showModalFcError('友情提示', '请选择“下单店铺”一致的单据');
        //   this.closeDialog();
        // }
      } catch (e) {
        showModalFcError('错误', `系统出现异常(${e.toString()})`);
      }
    },
    methods: {
      /**
       * 关闭窗口
       */
      closeDialog() {
        this.$emit('closeActionDialog', false);
      },
    }
  };
</script>
