"use strict";
const common_vendor = require("../../common/vendor.js");
const api_api = require("../../api/api.js");
if (!Array) {
  const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
  const _easycom_up_textarea2 = common_vendor.resolveComponent("up-textarea");
  const _easycom_up_button2 = common_vendor.resolveComponent("up-button");
  const _easycom_up_picker2 = common_vendor.resolveComponent("up-picker");
  (_easycom_up_icon2 + _easycom_up_textarea2 + _easycom_up_button2 + _easycom_up_picker2)();
}
const _easycom_up_icon = () => "../../uni_modules/uview-plus/components/u-icon/u-icon.js";
const _easycom_up_textarea = () => "../../uni_modules/uview-plus/components/u-textarea/u-textarea.js";
const _easycom_up_button = () => "../../uni_modules/uview-plus/components/u-button/u-button.js";
const _easycom_up_picker = () => "../../uni_modules/uview-plus/components/u-picker/u-picker.js";
if (!Math) {
  (_easycom_up_icon + _easycom_up_textarea + _easycom_up_button + _easycom_up_picker)();
}
const _sfc_main = {
  __name: "makeInvoice",
  setup(__props) {
    common_vendor.ref([]);
    let dataFrom = common_vendor.ref({
      invoiceType: null,
      subjectType: null,
      ordersIds: []
    });
    let show1 = common_vendor.ref(false);
    let show2 = common_vendor.ref(false);
    common_vendor.onLoad(async (options) => {
      console.log(options);
      console.log(JSON.parse(decodeURIComponent(options.list)));
      dataFrom.value.ordersIds = JSON.parse(decodeURIComponent(options.list));
    });
    const applyCon = async () => {
      if (!dataFrom.value.subjectType)
        return common_vendor.index.showToast({ title: "请选择发票主体", icon: "none" });
      if (!dataFrom.value.invoiceType)
        return common_vendor.index.showToast({ title: "请选择发票类型", icon: "none" });
      if (!dataFrom.value.invoiceType == 1 && !dataFrom.value.taxNumber)
        return common_vendor.index.showToast({ title: "请输入发票税号", icon: "none" });
      if (!dataFrom.value.subjectType == 1 && !dataFrom.value.registrationPhone)
        return common_vendor.index.showToast({ title: "请输入发票税号", icon: "none" });
      if (!dataFrom.value.subjectType == 1 && !dataFrom.value.invoiceType == 2 && !dataFrom.value.taxNumber)
        return common_vendor.index.showToast({ title: "请输入发票税号", icon: "none" });
      if (!dataFrom.value.subjectType == 1 && !dataFrom.value.invoiceType == 2 && !dataFrom.value.registrationAddress)
        return common_vendor.index.showToast({ title: "请输入公司地址", icon: "none" });
      if (!dataFrom.value.subjectType == 1 && !dataFrom.value.invoiceType == 2 && !dataFrom.value.registrationPhone)
        return common_vendor.index.showToast({ title: "请输入公司电话", icon: "none" });
      if (!dataFrom.value.subjectType == 1 && !dataFrom.value.invoiceType == 2 && !dataFrom.value.bankName)
        return common_vendor.index.showToast({ title: "请输入开户行名称", icon: "none" });
      if (!dataFrom.value.subjectType == 1 && !dataFrom.value.invoiceType == 2 && !dataFrom.value.bankAccount)
        return common_vendor.index.showToast({ title: "请输入开户行账户", icon: "none" });
      if (!dataFrom.value.name)
        return common_vendor.index.showToast({ title: "请输入收票人姓名", icon: "none" });
      if (!dataFrom.value.address)
        return common_vendor.index.showToast({ title: "请输入收票人地址", icon: "none" });
      if (!dataFrom.value.phone)
        return common_vendor.index.showToast({ title: "请输入收票人电话", icon: "none" });
      if (!dataFrom.value.email)
        return common_vendor.index.showToast({ title: "请输入收票人邮箱", icon: "none" });
      await api_api.apply(dataFrom.value);
      common_vendor.index.navigateBack({
        delta: 3
      });
    };
    const aaa1 = (ee) => {
      dataFrom.value.invoiceType = ee.value[0].id;
      show1.value = false;
      console.log(dataFrom.value.invoiceType);
    };
    const aaa2 = (ee) => {
      dataFrom.value.subjectType = ee.value[0].id;
      show2.value = false;
      if (ee.value[0].id == 2) {
        dataFrom.value.invoiceType = 1;
      }
    };
    const show1True = () => {
      if (dataFrom.value.subjectType == 2) {
        return;
      }
      show1.value = true;
    };
    const columns1 = common_vendor.reactive([
      [
        {
          label: "增值税普通发票",
          id: 1
        },
        {
          label: "增值税专用发票",
          id: 2
        }
      ]
    ]);
    const columns2 = common_vendor.reactive([
      [
        {
          label: "企业",
          id: 1
        },
        {
          label: "个人",
          id: 2
        }
      ]
    ]);
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.p({
          name: "error-circle-fill",
          color: "#3c9cff"
        }),
        b: common_vendor.t(!common_vendor.unref(dataFrom).subjectType ? "请选择" : columns2[0].find((val) => val.id == common_vendor.unref(dataFrom).subjectType).label),
        c: !common_vendor.unref(dataFrom).subjectType ? "#808080" : "",
        d: common_vendor.p({
          name: "arrow-down"
        }),
        e: common_vendor.o(($event) => common_vendor.isRef(show2) ? show2.value = true : show2 = true),
        f: common_vendor.t(!common_vendor.unref(dataFrom).invoiceType ? "请选择" : columns1[0].find((val) => val.id == common_vendor.unref(dataFrom).invoiceType).label),
        g: !common_vendor.unref(dataFrom).invoiceType ? "#808080" : "",
        h: common_vendor.p({
          name: "arrow-down"
        }),
        i: common_vendor.o(show1True),
        j: common_vendor.unref(dataFrom).invoiceTitle,
        k: common_vendor.o(($event) => common_vendor.unref(dataFrom).invoiceTitle = $event.detail.value),
        l: common_vendor.unref(dataFrom).subjectType == 1
      }, common_vendor.unref(dataFrom).subjectType == 1 ? {
        m: common_vendor.unref(dataFrom).taxNumber,
        n: common_vendor.o(($event) => common_vendor.unref(dataFrom).taxNumber = $event.detail.value)
      } : {}, {
        o: common_vendor.unref(dataFrom).invoiceType == 2
      }, common_vendor.unref(dataFrom).invoiceType == 2 ? {
        p: common_vendor.unref(dataFrom).registrationAddress,
        q: common_vendor.o(($event) => common_vendor.unref(dataFrom).registrationAddress = $event.detail.value)
      } : {}, {
        r: common_vendor.unref(dataFrom).invoiceType == 2
      }, common_vendor.unref(dataFrom).invoiceType == 2 ? {
        s: common_vendor.unref(dataFrom).registrationPhone,
        t: common_vendor.o(($event) => common_vendor.unref(dataFrom).registrationPhone = $event.detail.value)
      } : {}, {
        v: common_vendor.unref(dataFrom).invoiceType == 2
      }, common_vendor.unref(dataFrom).invoiceType == 2 ? {
        w: common_vendor.unref(dataFrom).bankName,
        x: common_vendor.o(($event) => common_vendor.unref(dataFrom).bankName = $event.detail.value)
      } : {}, {
        y: common_vendor.unref(dataFrom).invoiceType == 2
      }, common_vendor.unref(dataFrom).invoiceType == 2 ? {
        z: common_vendor.unref(dataFrom).bankAccount,
        A: common_vendor.o(($event) => common_vendor.unref(dataFrom).bankAccount = $event.detail.value)
      } : {}, {
        B: common_vendor.unref(dataFrom).name,
        C: common_vendor.o(($event) => common_vendor.unref(dataFrom).name = $event.detail.value),
        D: common_vendor.unref(dataFrom).phone,
        E: common_vendor.o(($event) => common_vendor.unref(dataFrom).phone = $event.detail.value),
        F: common_vendor.unref(dataFrom).address,
        G: common_vendor.o(($event) => common_vendor.unref(dataFrom).address = $event.detail.value),
        H: common_vendor.unref(dataFrom).email,
        I: common_vendor.o(($event) => common_vendor.unref(dataFrom).email = $event.detail.value),
        J: common_vendor.o(($event) => common_vendor.unref(dataFrom).invoiceRemark = $event),
        K: common_vendor.p({
          placeholder: "请输入内容",
          modelValue: common_vendor.unref(dataFrom).invoiceRemark
        }),
        L: common_vendor.o(applyCon),
        M: common_vendor.p({
          customStyle: {
            height: "80rpx",
            width: "230rpx"
          },
          color: "#4879e6",
          text: "确认开票",
          shape: "circle"
        }),
        N: common_vendor.o(aaa1),
        O: common_vendor.o(($event) => common_vendor.isRef(show1) ? show1.value = false : show1 = false),
        P: common_vendor.p({
          keyName: "label",
          show: common_vendor.unref(show1),
          columns: columns1
        }),
        Q: common_vendor.o(aaa2),
        R: common_vendor.o(($event) => common_vendor.isRef(show2) ? show2.value = false : show2 = false),
        S: common_vendor.p({
          keyName: "label",
          show: common_vendor.unref(show2),
          columns: columns2
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4c7e3b70"]]);
my.createPage(MiniProgramPage);
