step3.js 9.26 KB
"use strict";
const common_vendor = require("../../common/vendor.js");
const training_train = require("../train.js");
require("../../common/request.js");
require("../../common/login.js");
require("../../config.js");
require("../../common/aes.js");
if (!Array) {
  const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
  const _easycom_uni_forms_item2 = common_vendor.resolveComponent("uni-forms-item");
  const _easycom_uni_data_checkbox2 = common_vendor.resolveComponent("uni-data-checkbox");
  const _easycom_uni_file_picker2 = common_vendor.resolveComponent("uni-file-picker");
  const _easycom_uni_data_select2 = common_vendor.resolveComponent("uni-data-select");
  const _easycom_uni_forms2 = common_vendor.resolveComponent("uni-forms");
  (_easycom_uni_easyinput2 + _easycom_uni_forms_item2 + _easycom_uni_data_checkbox2 + _easycom_uni_file_picker2 + _easycom_uni_data_select2 + _easycom_uni_forms2)();
}
const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
const _easycom_uni_forms_item = () => "../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.js";
const _easycom_uni_data_checkbox = () => "../../uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.js";
const _easycom_uni_file_picker = () => "../../uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.js";
const _easycom_uni_data_select = () => "../../uni_modules/uni-data-select/components/uni-data-select/uni-data-select.js";
const _easycom_uni_forms = () => "../../uni_modules/uni-forms/components/uni-forms/uni-forms.js";
if (!Math) {
  (_easycom_uni_easyinput + _easycom_uni_forms_item + _easycom_uni_data_checkbox + _easycom_uni_file_picker + _easycom_uni_data_select + _easycom_uni_forms)();
}
const _sfc_main = {
  __name: "step3",
  props: {
    activity: {
      type: Object,
      default: () => {
      }
    },
    trainId: {
      type: String,
      default: () => {
      }
    },
    active: {
      type: Number,
      default: () => {
      }
    }
  },
  emits: ["prev", "next"],
  setup(__props, { emit }) {
    const props = __props;
    const customInfo = common_vendor.computed(() => {
      if (props.activity.customInfo) {
        return JSON.parse(props.activity.customInfo).info;
      } else {
        return [];
      }
    });
    const data = common_vendor.reactive({
      form: {
        invoiceFlag: "1",
        customInfoObj: {}
      },
      invoiceFlag: [{
        value: "0",
        text: "否"
      }, {
        value: "1",
        text: "是"
      }],
      invoiceType: [{
        value: 0,
        text: "电子票"
      }, {
        value: 1,
        text: "纸质专票"
      }, {
        value: 2,
        text: "纸质普票"
      }]
    });
    const {
      form,
      invoiceType,
      invoiceFlag
    } = common_vendor.toRefs(data);
    common_vendor.watch(() => props.activity.invoiceFlag, (val) => {
      if (val == "1") {
        if (!form.value.invoiceType) {
          form.value.invoiceType = common_vendor._.orderBy(props.activity.invoiceType.split(","))[0];
        }
      }
    }, {
      immediate: true
    });
    common_vendor.watch(() => props.active, (val) => {
      if (val == 2) {
        common_vendor.index.showLoading({
          title: "加载中"
        });
        training_train.getTrainPersonalInfo(props.trainId).then((res) => {
          var _a;
          form.value = res.data || {};
          if ((_a = res.data) == null ? void 0 : _a.customInfo) {
            form.value.customInfoObj = JSON.parse(res.data.customInfo);
          } else {
            form.value.customInfoObj = {};
          }
          common_vendor.index.hideLoading();
        });
      }
    });
    function prev() {
      emit("prev");
    }
    function next() {
      if (!form.value.unitName) {
        common_vendor.index.showToast({
          title: "请填写所在单位",
          icon: "none"
        });
        return;
      }
      if (!form.value.unitRole) {
        common_vendor.index.showToast({
          title: "请填写职务信息",
          icon: "none"
        });
        return;
      }
      form.value.activityId = props.trainId;
      form.value.customInfo = JSON.stringify(form.value.customInfoObj);
      training_train.savePersonalInfo(form.value).then(() => {
        common_vendor.index.showToast({
          title: "保存成功",
          icon: "none"
        }).finally((res) => {
          emit("next");
        });
      });
    }
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.o(($event) => common_vendor.unref(form).unitName = $event),
        b: common_vendor.p({
          placeholder: "请输入所在单位名称",
          modelValue: common_vendor.unref(form).unitName
        }),
        c: common_vendor.p({
          label: "所在单位名称",
          required: true,
          name: "unitName"
        }),
        d: common_vendor.o(($event) => common_vendor.unref(form).unitRole = $event),
        e: common_vendor.p({
          placeholder: "请输入现任职务",
          modelValue: common_vendor.unref(form).unitRole
        }),
        f: common_vendor.p({
          label: "现任职务",
          required: true,
          name: "unitRole"
        }),
        g: __props.activity.invoiceFlag == "1"
      }, __props.activity.invoiceFlag == "1" ? common_vendor.e({
        h: common_vendor.o(($event) => common_vendor.unref(form).invoiceFlag = $event),
        i: common_vendor.p({
          localdata: common_vendor.unref(invoiceFlag),
          modelValue: common_vendor.unref(form).invoiceFlag
        }),
        j: common_vendor.p({
          label: "是否需要发票",
          required: true,
          name: "invoiceFlag"
        }),
        k: common_vendor.unref(form).invoiceFlag == "1"
      }, common_vendor.unref(form).invoiceFlag == "1" ? {
        l: common_vendor.o(($event) => common_vendor.unref(form).invoiceType = $event),
        m: common_vendor.p({
          localdata: common_vendor.unref(invoiceType),
          modelValue: common_vendor.unref(form).invoiceType
        }),
        n: common_vendor.p({
          label: "发票形式",
          required: true,
          name: "invoiceType"
        })
      } : {}, {
        o: common_vendor.unref(form).invoiceFlag == "1"
      }, common_vendor.unref(form).invoiceFlag == "1" ? {
        p: common_vendor.o(($event) => common_vendor.unref(form).invoiceInfo = $event),
        q: common_vendor.p({
          placeholder: "请输入开票信息",
          modelValue: common_vendor.unref(form).invoiceInfo
        }),
        r: common_vendor.p({
          label: "开票信息",
          required: true,
          name: "invoiceInfo"
        })
      } : {}) : {}, {
        s: common_vendor.f(common_vendor.unref(customInfo), (c, k0, i0) => {
          return common_vendor.e({
            a: c.type == "1"
          }, c.type == "1" ? {
            b: "9bd2f2aa-12-" + i0 + "," + ("9bd2f2aa-11-" + i0),
            c: common_vendor.o(($event) => common_vendor.unref(form).customInfoObj[c.id] = $event, c.id),
            d: common_vendor.p({
              placeholder: "请输入",
              modelValue: common_vendor.unref(form).customInfoObj[c.id]
            })
          } : {}, {
            e: c.type == "2"
          }, c.type == "2" ? {
            f: common_vendor.o(_ctx.selectFile, c.id),
            g: common_vendor.o(($event) => _ctx.delSupplementFile(c, $event), c.id),
            h: "9bd2f2aa-13-" + i0 + "," + ("9bd2f2aa-11-" + i0),
            i: common_vendor.o(($event) => c.value = $event, c.id),
            j: common_vendor.p({
              limit: "1",
              ["file-mediatype"]: "all",
              ["file-extname"]: "doc,docx,pdf,txt",
              modelValue: c.value
            })
          } : {}, {
            k: c.type == "2"
          }, c.type == "2" ? {} : {}, {
            l: c.type == "3"
          }, c.type == "3" ? {
            m: common_vendor.o(_ctx.upSupplement3, c.id),
            n: common_vendor.o(($event) => _ctx.delSupplementImg(c, $event), c.id),
            o: "9bd2f2aa-14-" + i0 + "," + ("9bd2f2aa-11-" + i0),
            p: common_vendor.o(($event) => _ctx.upSupplement3Value = $event, c.id),
            q: common_vendor.p({
              ["return-type"]: "object",
              limit: "1",
              modelValue: _ctx.upSupplement3Value
            })
          } : {}, {
            r: c.type == "4"
          }, c.type == "4" ? {
            s: "9bd2f2aa-15-" + i0 + "," + ("9bd2f2aa-11-" + i0),
            t: common_vendor.o(($event) => c.value = $event, c.id),
            v: common_vendor.p({
              localdata: c.option,
              modelValue: c.value
            })
          } : {}, {
            w: c.id,
            x: "9bd2f2aa-11-" + i0 + ",9bd2f2aa-0",
            y: common_vendor.p({
              label: c.name
            })
          });
        }),
        t: common_vendor.sr("baseForm", "9bd2f2aa-0"),
        v: common_vendor.p({
          modelValue: common_vendor.unref(form),
          ["label-width"]: "120"
        }),
        w: common_vendor.o(prev),
        x: common_vendor.o(next)
      });
    };
  }
};
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "/Users/yangyang/ztx_wx_minapp/training/components/step3.vue"]]);
wx.createComponent(Component);