carDetail.js 19.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534
"use strict";
const common_vendor = require("../../common/vendor.js");
require("../../uni_modules/uview-plus/index.js");
const api_user = require("../../api/user.js");
const api_work = require("../../api/work.js");
const store_modules_user = require("../../store/modules/user.js");
const api_car = require("../../api/car.js");
if (!Array) {
  const _easycom_up_navbar2 = common_vendor.resolveComponent("up-navbar");
  const _easycom_up_form_item2 = common_vendor.resolveComponent("up-form-item");
  const _easycom_up_input2 = common_vendor.resolveComponent("up-input");
  const _easycom_up_checkbox2 = common_vendor.resolveComponent("up-checkbox");
  const _easycom_uni_data_select2 = common_vendor.resolveComponent("uni-data-select");
  const _easycom_up_form2 = common_vendor.resolveComponent("up-form");
  const _easycom_up_parse2 = common_vendor.resolveComponent("up-parse");
  const _easycom_up_popup2 = common_vendor.resolveComponent("up-popup");
  (_easycom_up_navbar2 + _easycom_up_form_item2 + _easycom_up_input2 + _easycom_up_checkbox2 + _easycom_uni_data_select2 + _easycom_up_form2 + _easycom_up_parse2 + _easycom_up_popup2)();
}
const _easycom_up_navbar = () => "../../uni_modules/uview-plus/components/u-navbar/u-navbar.js";
const _easycom_up_form_item = () => "../../uni_modules/uview-plus/components/u-form-item/u-form-item.js";
const _easycom_up_input = () => "../../uni_modules/uview-plus/components/u-input/u-input.js";
const _easycom_up_checkbox = () => "../../uni_modules/uview-plus/components/u-checkbox/u-checkbox.js";
const _easycom_uni_data_select = () => "../../uni_modules/uni-data-select/components/uni-data-select/uni-data-select.js";
const _easycom_up_form = () => "../../uni_modules/uview-plus/components/u-form/u-form.js";
const _easycom_up_parse = () => "../../uni_modules/uview-plus/components/u-parse/u-parse.js";
const _easycom_up_popup = () => "../../uni_modules/uview-plus/components/u-popup/u-popup.js";
if (!Math) {
  (_easycom_up_navbar + navTop + _easycom_up_form_item + _easycom_up_input + _easycom_up_checkbox + _easycom_uni_data_select + _easycom_up_form + _easycom_up_parse + _easycom_up_popup)();
}
const navTop = () => "../../components/navTop.js";
const _sfc_main = {
  __name: "carDetail",
  setup(__props) {
    const userStore = store_modules_user.useUserStore();
    const showCompanyTip = common_vendor.ref(false);
    const transferTip = common_vendor.ref("");
    const labelStyle = {
      fontSize: "28rpx",
      lineHeight: "38rpx",
      color: "#3D3D3D",
      marginLeft: "14rpx"
    };
    const advertisingTitle = common_vendor.ref("");
    const advertisingContent = common_vendor.ref("");
    const uFormRef = common_vendor.ref(null);
    const isShowHeader = common_vendor.ref(false);
    const taskId = common_vendor.ref("");
    const isEdit = common_vendor.ref(false);
    const isRole = common_vendor.ref(false);
    const isNewCar = common_vendor.ref(false);
    const showCompanyList = common_vendor.ref(false);
    const companyName = common_vendor.ref("请选择承保公司");
    const form = common_vendor.ref({
      name: "",
      businessName: "",
      businessPhone: "",
      uniformCreditCode: "",
      address: "",
      identificationNumber: "",
      isNewEnergy: "",
      sysDeptId: "",
      type: 0,
      customizeVehicleBrand: "",
      customizeVehicleModel: "",
      licensePlateNumber: "",
      lincensePlateTypeId: "",
      frameNumber: "",
      engineNumber: "",
      vehicleTypeId: "",
      vehicleNatureId: "",
      passengersNumber: "",
      passengerCapacity: "",
      emissions: "",
      vehicleModelId: "",
      vehicleBrandId: "",
      tractionMass: "",
      requirementsId: ""
    });
    const queryParams = common_vendor.reactive({
      pageSize: 100,
      pageNum: 1
    });
    const rules = {
      licensePlateNumber: [
        { required: true, message: "请输入车牌号", trigger: ["blur", "change"] }
        // {
        // 	validator: (rule, value, callback) => {
        // 		if(isNewCar.value){
        // 			callback()
        // 		}else {
        // 			const regex = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z]([A-HJ-NP-Z0-9]{4}[0-9A-HJ-NP-ZDF]|[DF][A-HJ-NP-Z0-9]{5}|[DF][A-HJ-NP-Z0-9]{6})$/;
        // 			return regex.test(value);
        // 		}
        // 	},
        // 	message: '车牌号不正确',
        // 	trigger: ['change', 'blur'],
        // }
      ],
      uniformCreditCode: [
        {
          // 自定义验证函数,见上说明
          pattern: /^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/,
          message: "信用代码不正确",
          // 触发器可以同时用blur和change
          trigger: ["change", "blur"]
        }
      ],
      frameNumber: [
        { required: true, message: "请输入车架号", trigger: ["blur", "change"] },
        { max: 17, message: "请正确输入车架号", trigger: ["blur", "change"] }
      ],
      sysDeptId: [
        { required: true, message: "请选择承保公司", trigger: ["change"] }
      ],
      engineNumber: [{ required: true, message: "请输入发动机号", trigger: ["blur", "change"] }],
      isNewEnergy: [{ required: true, message: "请选择是否新能源", trigger: ["change"] }],
      requirementsId: [{ required: true, message: "请选择保险需求", trigger: ["change"] }],
      vehicleNatureId: [{ required: true, message: "请选择车辆使用性质", trigger: ["blur", "change"] }]
    };
    common_vendor.onReady(() => {
      uFormRef.value.setRules(rules);
    });
    const toggleSwiper = (event) => {
      var _a;
      form.value.type = (_a = event.detail) == null ? void 0 : _a.current;
    };
    common_vendor.onLoad(async (options) => {
      if (options.roleId !== void 0) {
        isRole.value = true;
        taskId.value = options.taskId;
        showCompanyTip.value = true;
        getTransferTip();
      }
      if (options.taskId !== void 0) {
        isRole.value = true;
        taskId.value = options.taskId;
      }
      if (options.carInfoId !== void 0) {
        const { data } = await api_car.getCarDetail(options.carInfoId);
        form.value = data;
        companyOption.value.forEach((item) => {
          if (item.value === form.value.sysDeptId) {
            companyName.value = item.text;
          }
        });
        isEdit.value = true;
        isShowHeader.value = true;
      }
    });
    const newEnergyOption = common_vendor.ref([
      { value: "0", text: "否" },
      { value: "1", text: "是" }
    ]);
    const getNoticeDetail = async () => {
      const { rows } = await api_user.getAdverList(queryParams);
      if (rows[1]) {
        advertisingContent.value = rows[1].noticeContent;
        advertisingTitle.value = rows[1].noticeTitle;
      } else if (rows[0]) {
        advertisingContent.value = rows[0].noticeContent;
        advertisingTitle.value = rows[0].noticeTitle;
      }
    };
    getNoticeDetail();
    const companyOption = common_vendor.ref([{ value: "0", text: "无" }]);
    const getCompanyOption = () => {
      api_car.getListDeptApi().then((res) => {
        const { data } = res;
        const newList = data.filter((item) => item.parentId === 100);
        const arrList = newList.map((item) => {
          return {
            value: item.deptId.toString(),
            text: item.deptName
          };
        });
        companyOption.value.push(...arrList);
      });
    };
    getCompanyOption();
    const carNatureOption = common_vendor.ref([]);
    const getCarNatureOption = () => {
      api_car.getCarNatureApi(queryParams).then((res) => {
        const { data } = res;
        const arrList = data.records.map((item) => {
          return {
            value: item.id,
            text: item.name
          };
        });
        carNatureOption.value = arrList;
      });
    };
    getCarNatureOption();
    const needOption = common_vendor.ref([]);
    const getNeedOption = () => {
      api_car.getNeedApi(queryParams).then((res) => {
        const { data } = res;
        const arrList = data.records.map((item) => {
          return {
            value: item.id,
            text: item.name
          };
        });
        needOption.value = arrList;
      });
    };
    getNeedOption();
    const changeCar = (value) => {
      form.value.licensePlateNumber = value ? "新车" : "";
    };
    const chooseCompany = (company) => {
      form.value.sysDeptId = company.value;
      companyName.value = company.text;
      showCompanyList.value = false;
    };
    const upperLicensePlate = ({ target }) => {
      form.value.licensePlateNumber = common_vendor.index.$u.trim(target.value.toUpperCase(), "all");
    };
    const upperFrame = ({ target }) => {
      form.value.frameNumber = common_vendor.index.$u.trim(target.value.toUpperCase(), "all");
    };
    const upperEngine = ({ target }) => {
      form.value.engineNumber = common_vendor.index.$u.trim(target.value.toUpperCase(), "all");
    };
    const getTransferTip = async () => {
      const { data } = await api_work.getCompanyTip();
      transferTip.value = data.deptName;
      userStore.transferDeptId = data.deptId.toString();
    };
    const authMessage = () => {
      common_vendor.index.requestSubscribeMessage({
        tmplIds: ["EPaG4yDw9_hBB9E7yAjw4HoJZS9xMc11wbWaBkeFOuo"],
        //  success: async (respone) => {
        // 	await carInfoAdd(form.value)
        // 	uni.$u.toast('添加成功')
        // 	uni.navigateBack()
        // },
        // 成功或失败都会调用
        complete: async (respone) => {
          await api_user.carInfoAdd(form.value);
          common_vendor.index.$u.toast("添加成功");
          common_vendor.index.navigateBack();
        }
      });
    };
    const submitInfo = async () => {
      if (form.value.type === 1) {
        if (form.value.businessName === "" || form.value.businessPhone === "" || form.value.uniformCreditCode === "") {
          return common_vendor.index.$u.toast("企业名称、联系方式、信用代码为必填");
        }
      }
      uFormRef.value.validate().then(async (valid) => {
        if (valid) {
          authMessage();
        } else {
          common_vendor.index.$u.toast("校验失败");
        }
      }).catch((err) => {
        common_vendor.index.$u.toast("校验失败");
      });
    };
    const submitEdit = async () => {
      if (showCompanyTip.value) {
        await api_user.carInfoEdit(form.value);
        common_vendor.index.$u.toast("修改成功");
        common_vendor.index.navigateBack();
      } else {
        common_vendor.index.requestSubscribeMessage({
          tmplIds: ["EPaG4yDw9_hBB9E7yAjw4HoJZS9xMc11wbWaBkeFOuo"],
          success: async (respone) => {
            await api_user.carInfoEdit(form.value);
            api_work.disposeUser({ reregistration: "true" }, taskId.value).then((res) => {
              common_vendor.index.$u.toast("提交成功");
            });
            common_vendor.index.navigateBack();
          }
        });
      }
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.p({
          placeholder: true,
          title: "车辆信息",
          autoBack: true,
          bgColor: "#fff"
        }),
        b: !isShowHeader.value
      }, !isShowHeader.value ? {
        c: form.value.type === 0 ? 1 : "",
        d: common_vendor.o(($event) => form.value.type = 0),
        e: form.value.type === 1 ? 1 : "",
        f: common_vendor.o(($event) => form.value.type = 1)
      } : {}, {
        g: isShowHeader.value
      }, isShowHeader.value ? {
        h: common_vendor.p({
          carNum: form.value.licensePlateNumber
        }),
        i: common_vendor.t(form.value.frameNumber),
        j: common_vendor.t(form.value.engineNumber)
      } : {}, {
        k: common_vendor.t(companyName.value),
        l: common_vendor.o(($event) => showCompanyList.value = true),
        m: common_vendor.p({
          label: "上年承保公司",
          prop: "sysDeptId",
          required: true
        }),
        n: common_vendor.o(($event) => common_vendor.unref(userStore).userInfo.nickName = $event),
        o: common_vendor.p({
          disabled: true,
          disabledColor: "#fff",
          fontSize: "28rpx",
          color: "#999",
          placeholder: "请输入真实姓名",
          border: "none",
          inputAlign: "right",
          modelValue: common_vendor.unref(userStore).userInfo.nickName
        }),
        p: common_vendor.p({
          label: "车主姓名",
          prop: "name"
        }),
        q: common_vendor.o(($event) => common_vendor.unref(userStore).userInfo.identificationNumber = $event),
        r: common_vendor.p({
          disabled: true,
          disabledColor: "#fff",
          fontSize: "28rpx",
          color: "#999",
          placeholder: "请输入身份证号",
          border: "none",
          inputAlign: "right",
          modelValue: common_vendor.unref(userStore).userInfo.identificationNumber
        }),
        s: common_vendor.p({
          label: "身份证号",
          prop: "identificationNumber"
        }),
        t: common_vendor.o(($event) => common_vendor.unref(userStore).userInfo.phonenumber = $event),
        v: common_vendor.p({
          disabled: true,
          ["disabled-color"]: "#fff",
          fontSize: "28rpx",
          color: "#999",
          placeholder: "请输入手机号",
          border: "none",
          inputAlign: "right",
          modelValue: common_vendor.unref(userStore).userInfo.phonenumber
        }),
        w: common_vendor.p({
          label: "联系电话",
          prop: "phonenumber"
        }),
        x: common_vendor.o(($event) => form.value.businessName = $event),
        y: common_vendor.p({
          fontSize: "28rpx",
          color: "#999",
          placeholder: "请输入企业名称",
          border: "none",
          inputAlign: "right",
          modelValue: form.value.businessName
        }),
        z: common_vendor.p({
          label: "企业名称",
          prop: "businessName"
        }),
        A: common_vendor.o(($event) => form.value.uniformCreditCode = $event),
        B: common_vendor.p({
          fontSize: "28rpx",
          color: "#999",
          placeholder: "请输入统一社会信用代码",
          border: "none",
          inputAlign: "right",
          modelValue: form.value.uniformCreditCode
        }),
        C: common_vendor.p({
          label: "统一社会信用代码",
          prop: "uniformCreditCode"
        }),
        D: common_vendor.o(($event) => form.value.businessPhone = $event),
        E: common_vendor.p({
          fontSize: "28rpx",
          color: "#999",
          placeholder: "请输入手机号",
          border: "none",
          inputAlign: "right",
          modelValue: form.value.businessPhone
        }),
        F: common_vendor.p({
          label: "联系电话",
          prop: "phonenumber"
        }),
        G: form.value.type,
        H: common_vendor.o(toggleSwiper),
        I: common_vendor.o(changeCar),
        J: common_vendor.o(($event) => isNewCar.value = $event),
        K: common_vendor.p({
          label: "新车无牌照",
          name: "newCar",
          usedAlone: true,
          checked: isNewCar.value
        }),
        L: form.value.licensePlateNumber,
        M: isNewCar.value,
        N: common_vendor.o(upperLicensePlate),
        O: common_vendor.o(($event) => form.value.licensePlateNumber = $event),
        P: common_vendor.p({
          customStyle: {
            height: 0,
            overflow: "hidden"
          },
          border: "none",
          modelValue: form.value.licensePlateNumber
        }),
        Q: common_vendor.p({
          label: "车牌号码",
          prop: "licensePlateNumber",
          required: true
        }),
        R: form.value.frameNumber,
        S: common_vendor.o(upperFrame),
        T: common_vendor.o(($event) => form.value.frameNumber = $event),
        U: common_vendor.p({
          customStyle: {
            height: 0,
            overflow: "hidden"
          },
          border: "none",
          modelValue: form.value.frameNumber
        }),
        V: common_vendor.p({
          label: "车辆识别代号",
          prop: "frameNumber",
          required: true
        }),
        W: form.value.engineNumber,
        X: common_vendor.o(upperEngine),
        Y: common_vendor.o(($event) => form.value.engineNumber = $event),
        Z: common_vendor.p({
          customStyle: {
            height: 0,
            overflow: "hidden"
          },
          border: "none",
          modelValue: form.value.engineNumber
        }),
        aa: common_vendor.p({
          label: "发动机号",
          prop: "engineNumber",
          required: true
        }),
        ab: common_vendor.o(($event) => form.value.isNewEnergy = $event),
        ac: common_vendor.p({
          localdata: newEnergyOption.value,
          placeholder: "是否新能源",
          modelValue: form.value.isNewEnergy
        }),
        ad: common_vendor.p({
          label: "是否新能源",
          prop: "isNewEnergy",
          required: true
        }),
        ae: common_vendor.o(($event) => form.value.vehicleNatureId = $event),
        af: common_vendor.p({
          localdata: carNatureOption.value,
          placeholder: "请选择车辆使用性质",
          modelValue: form.value.vehicleNatureId
        }),
        ag: common_vendor.p({
          label: "车辆使用性质",
          prop: "vehicleNatureId",
          required: true
        }),
        ah: common_vendor.o(($event) => form.value.requirementsId = $event),
        ai: common_vendor.p({
          localdata: needOption.value,
          placeholder: "请选择保险需求",
          modelValue: form.value.requirementsId
        }),
        aj: common_vendor.p({
          label: "保险需求",
          prop: "requirements",
          required: true
        }),
        ak: common_vendor.sr(uFormRef, "1c0b8627-1", {
          "k": "uFormRef"
        }),
        al: common_vendor.p({
          model: form.value,
          ["label-width"]: "150",
          labelStyle
        }),
        am: showCompanyTip.value
      }, showCompanyTip.value ? {
        an: common_vendor.t(transferTip.value),
        ao: common_vendor.o(getTransferTip)
      } : {}, {
        ap: !isEdit.value,
        aq: common_vendor.o(submitInfo),
        ar: isRole.value,
        as: common_vendor.o(submitEdit),
        at: common_vendor.t(advertisingTitle.value),
        av: common_vendor.p({
          content: advertisingContent.value
        }),
        aw: common_vendor.o(($event) => common_vendor.unref(userStore).showTip = false),
        ax: common_vendor.o(($event) => common_vendor.unref(userStore).showTip = false),
        ay: common_vendor.p({
          show: common_vendor.unref(userStore).showTip,
          mode: "center",
          safeAreaInsetBottom: false,
          round: "20"
        }),
        az: common_vendor.f(companyOption.value, (company, index, i0) => {
          return {
            a: common_vendor.t(company.text),
            b: index,
            c: common_vendor.o(($event) => chooseCompany(company), index)
          };
        }),
        aA: common_vendor.o(($event) => showCompanyList.value = false),
        aB: common_vendor.p({
          show: showCompanyList.value,
          mode: "bottom",
          round: 10
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1c0b8627"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/carDetail/carDetail.js.map