"use strict";
const common_vendor = require("../../common/vendor.js");
const _sfc_main = {
  data() {
    return {
      showTypePicker: false,
      showSurfacePicker: false,
      showPackagePicker: false,
      tempSelectedIndex: -1,
      tempSurfaceIndex: -1,
      tempPackageIndex: -1,
      typeList: ["TY0018", "TY0019", "TY0020", "TY0021", "TY0022", "TY0023", "TY0024", "TY0025", "TY0026", "TY0027", "TY0028"],
      surfaceList: ["PL坯料", "阳极氧化", "电泳涂漆", "粉末喷涂", "氟碳喷涂", "木纹转印"],
      packageList: ["不贴膜+3点捆扎", "贴膜+纸箱", "气泡膜包装", "简易编织袋", "木托架包装"],
      formData: {
        type: "",
        name: "",
        material: "",
        surfaceName: "",
        packageMethod: "",
        length: "",
        wallThickness: "",
        count: ""
      }
    };
  },
  methods: {
    openTypePicker() {
      if (this.formData.type)
        this.tempSelectedIndex = this.typeList.indexOf(this.formData.type);
      this.showTypePicker = true;
    },
    closeTypePicker() {
      this.showTypePicker = false;
    },
    selectTypeItem(index) {
      this.tempSelectedIndex = index;
    },
    confirmTypeSelect() {
      if (this.tempSelectedIndex === -1)
        return;
      const val = this.typeList[this.tempSelectedIndex];
      this.formData.type = val;
      this.formData.name = "工业铝材";
      this.formData.material = this.tempSelectedIndex % 2 === 0 ? "6063-T5" : "6061-T6";
      this.closeTypePicker();
    },
    openSurfacePicker() {
      if (this.formData.surfaceName)
        this.tempSurfaceIndex = this.surfaceList.indexOf(this.formData.surfaceName);
      this.showSurfacePicker = true;
    },
    closeSurfacePicker() {
      this.showSurfacePicker = false;
    },
    selectSurfaceItem(index) {
      this.tempSurfaceIndex = index;
    },
    confirmSurfaceSelect() {
      if (this.tempSurfaceIndex === -1)
        return;
      this.formData.surfaceName = this.surfaceList[this.tempSurfaceIndex];
      this.closeSurfacePicker();
    },
    openPackagePicker() {
      if (this.formData.packageMethod)
        this.tempPackageIndex = this.packageList.indexOf(this.formData.packageMethod);
      this.showPackagePicker = true;
    },
    closePackagePicker() {
      this.showPackagePicker = false;
    },
    selectPackageItem(index) {
      this.tempPackageIndex = index;
    },
    confirmPackageSelect() {
      if (this.tempPackageIndex === -1)
        return;
      this.formData.packageMethod = this.packageList[this.tempPackageIndex];
      this.closePackagePicker();
    },
    confirmAddModel() {
      const fields = [
        { key: "type", label: "型号" },
        { key: "surfaceName", label: "表面名称" },
        { key: "packageMethod", label: "包装方式" },
        { key: "length", label: "长度" },
        { key: "wallThickness", label: "壁厚" },
        { key: "count", label: "支数" }
      ];
      for (let item of fields) {
        if (!this.formData[item.key]) {
          common_vendor.index.showToast({ title: `请完善项目：${item.label}`, icon: "none" });
          return;
        }
      }
      common_vendor.index.$emit("add_order_item", JSON.parse(JSON.stringify(this.formData)));
      common_vendor.index.navigateBack();
    }
  }
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: common_vendor.t($data.formData.type || "请选择型号"),
    b: !$data.formData.type ? 1 : "",
    c: common_vendor.o((...args) => $options.openTypePicker && $options.openTypePicker(...args), "d9"),
    d: $data.formData.name,
    e: common_vendor.o(($event) => $data.formData.name = $event.detail.value, "fa"),
    f: $data.formData.material,
    g: common_vendor.o(($event) => $data.formData.material = $event.detail.value, "77"),
    h: common_vendor.t($data.formData.surfaceName || "请选择表面名称"),
    i: !$data.formData.surfaceName ? 1 : "",
    j: common_vendor.o((...args) => $options.openSurfacePicker && $options.openSurfacePicker(...args), "b0"),
    k: common_vendor.t($data.formData.packageMethod || "请选择包装方式"),
    l: !$data.formData.packageMethod ? 1 : "",
    m: common_vendor.o((...args) => $options.openPackagePicker && $options.openPackagePicker(...args), "d5"),
    n: $data.formData.length,
    o: common_vendor.o(($event) => $data.formData.length = $event.detail.value, "14"),
    p: $data.formData.wallThickness,
    q: common_vendor.o(($event) => $data.formData.wallThickness = $event.detail.value, "b0"),
    r: $data.formData.count,
    s: common_vendor.o(($event) => $data.formData.count = $event.detail.value, "8c"),
    t: !$data.showTypePicker && !$data.showSurfacePicker && !$data.showPackagePicker,
    v: common_vendor.o((...args) => $options.confirmAddModel && $options.confirmAddModel(...args), "48"),
    w: $data.showTypePicker
  }, $data.showTypePicker ? {
    x: common_vendor.o((...args) => $options.closeTypePicker && $options.closeTypePicker(...args), "9a"),
    y: common_vendor.o((...args) => $options.confirmTypeSelect && $options.confirmTypeSelect(...args), "9a"),
    z: common_vendor.f($data.typeList, (item, index, i0) => {
      return common_vendor.e({
        a: common_vendor.t(item),
        b: $data.tempSelectedIndex === index
      }, $data.tempSelectedIndex === index ? {} : {}, {
        c: index,
        d: $data.tempSelectedIndex === index ? 1 : "",
        e: common_vendor.o(($event) => $options.selectTypeItem(index), index)
      });
    }),
    A: common_vendor.o(() => {
    }, "ed"),
    B: common_vendor.o((...args) => $options.closeTypePicker && $options.closeTypePicker(...args), "7c"),
    C: common_vendor.o(() => {
    }, "c4")
  } : {}, {
    D: $data.showSurfacePicker
  }, $data.showSurfacePicker ? {
    E: common_vendor.o((...args) => $options.closeSurfacePicker && $options.closeSurfacePicker(...args), "10"),
    F: common_vendor.o((...args) => $options.confirmSurfaceSelect && $options.confirmSurfaceSelect(...args), "9b"),
    G: common_vendor.f($data.surfaceList, (item, index, i0) => {
      return common_vendor.e({
        a: common_vendor.t(item),
        b: $data.tempSurfaceIndex === index
      }, $data.tempSurfaceIndex === index ? {} : {}, {
        c: index,
        d: $data.tempSurfaceIndex === index ? 1 : "",
        e: common_vendor.o(($event) => $options.selectSurfaceItem(index), index)
      });
    }),
    H: common_vendor.o(() => {
    }, "12"),
    I: common_vendor.o((...args) => $options.closeSurfacePicker && $options.closeSurfacePicker(...args), "fc"),
    J: common_vendor.o(() => {
    }, "71")
  } : {}, {
    K: $data.showPackagePicker
  }, $data.showPackagePicker ? {
    L: common_vendor.o((...args) => $options.closePackagePicker && $options.closePackagePicker(...args), "8b"),
    M: common_vendor.o((...args) => $options.confirmPackageSelect && $options.confirmPackageSelect(...args), "d8"),
    N: common_vendor.f($data.packageList, (item, index, i0) => {
      return common_vendor.e({
        a: common_vendor.t(item),
        b: $data.tempPackageIndex === index
      }, $data.tempPackageIndex === index ? {} : {}, {
        c: index,
        d: $data.tempPackageIndex === index ? 1 : "",
        e: common_vendor.o(($event) => $options.selectPackageItem(index), index)
      });
    }),
    O: common_vendor.o(() => {
    }, "46"),
    P: common_vendor.o((...args) => $options.closePackagePicker && $options.closePackagePicker(...args), "76"),
    Q: common_vendor.o(() => {
    }, "93")
  } : {});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-9b2fa429"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/order/add_model.js.map
