@jctrans-materials/comps-vue3 1.0.41-beta.4 → 1.0.41-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -3461,27 +3461,22 @@ const useIsEn = (lang = "") => {
3461
3461
  };
3462
3462
  const _hoisted_1$l = { class: "global-company-input" };
3463
3463
  const _hoisted_2$j = { class: "company-option-item" };
3464
- const _sfc_main$p = {
3464
+ const CHINA_COUNTRY_ID = 1;
3465
+ const _sfc_main$p = /* @__PURE__ */ defineComponent({
3465
3466
  __name: "index",
3466
3467
  props: {
3467
- lang: { type: String, default: "" },
3468
- companyName: { type: String, default: "" },
3469
- countryId: { type: [String, Number, null], required: true },
3468
+ lang: { default: "" },
3469
+ companyName: { default: "" },
3470
+ countryId: {},
3470
3471
  useKq: { type: Boolean, default: false },
3471
- kqCode: { type: [String, Number], default: "" },
3472
- kqInfo: { type: Object, default: () => ({}) },
3473
- city: { type: Object, default: () => ({}) },
3472
+ kqCode: { default: "" },
3473
+ kqInfo: { default: () => ({}) },
3474
+ city: { default: () => ({}) },
3474
3475
  disabled: { type: Boolean, default: false },
3475
3476
  defaultFirstOption: { type: Boolean, default: false },
3476
3477
  allowCreate: { type: Boolean, default: false }
3477
3478
  },
3478
- emits: [
3479
- "update:companyName",
3480
- "update:useKq",
3481
- "update:kqCode",
3482
- "update:kqInfo",
3483
- "change"
3484
- ],
3479
+ emits: ["update:companyName", "update:useKq", "update:kqCode", "update:kqInfo", "change"],
3485
3480
  setup(__props, { emit: __emit }) {
3486
3481
  const props = __props;
3487
3482
  const emit = __emit;
@@ -3493,7 +3488,9 @@ const _sfc_main$p = {
3493
3488
  get: () => props.companyName,
3494
3489
  set: (val) => emit("update:companyName", val)
3495
3490
  });
3491
+ const isChina = computed(() => props.countryId === CHINA_COUNTRY_ID);
3496
3492
  const isDisabled = ref(false);
3493
+ let abortController = null;
3497
3494
  const handleRemoteSearch = (query) => {
3498
3495
  if (query) {
3499
3496
  loading.value = true;
@@ -3502,28 +3499,34 @@ const _sfc_main$p = {
3502
3499
  options.value = [];
3503
3500
  }
3504
3501
  };
3505
- const fetchOptionsDebounced = debounce((query) => {
3506
- var _a;
3507
- console.log("🍉 ~ index.vue:119 ~ props.city:", props.city);
3502
+ const fetchOptionsDebounced = debounce(async (query) => {
3503
+ var _a, _b, _c, _d;
3504
+ if (abortController) {
3505
+ abortController.abort();
3506
+ }
3507
+ abortController = new AbortController();
3508
3508
  const data = {
3509
3509
  current: 1,
3510
3510
  size: 50,
3511
3511
  compName: query,
3512
3512
  cityName: ((_a = props.city) == null ? void 0 : _a.nameCn) + "市"
3513
3513
  };
3514
- getCompanyOptionApi(data).then((res) => {
3515
- var _a2;
3516
- options.value = ((_a2 = res.data.data.records) == null ? void 0 : _a2.map((i) => ({
3514
+ try {
3515
+ const res = await getCompanyOptionApi(data);
3516
+ options.value = ((_d = (_c = (_b = res == null ? void 0 : res.data) == null ? void 0 : _b.data) == null ? void 0 : _c.records) == null ? void 0 : _d.map((i) => ({
3517
3517
  value: i.nameCn,
3518
3518
  code: i.kqId,
3519
+ kqId: i.kqId,
3519
3520
  ...i
3520
3521
  }))) || [];
3521
- }).catch((err) => {
3522
- console.error("获取公司选项失败:", err);
3522
+ } catch (err) {
3523
+ if ((err == null ? void 0 : err.name) !== "AbortError" && (err == null ? void 0 : err.name) !== "CanceledError") {
3524
+ console.error("获取公司选项失败:", err);
3525
+ }
3523
3526
  options.value = [];
3524
- }).finally(() => {
3527
+ } finally {
3525
3528
  loading.value = false;
3526
- });
3529
+ }
3527
3530
  }, 800);
3528
3531
  const handleSelectChange = (val) => {
3529
3532
  const selectedObj = options.value.find((item) => item.value === val);
@@ -3543,7 +3546,10 @@ const _sfc_main$p = {
3543
3546
  emit("update:useKq", false);
3544
3547
  emit("update:kqCode", "");
3545
3548
  emit("change", val);
3546
- (_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "change").catch(() => {
3549
+ (_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "change").catch((err) => {
3550
+ if (process.env.NODE_ENV === "development") {
3551
+ console.warn("[ChineseCompanySearch] formItem.validate 失败:", err);
3552
+ }
3547
3553
  });
3548
3554
  };
3549
3555
  const resetKq = () => {
@@ -3552,7 +3558,10 @@ const _sfc_main$p = {
3552
3558
  emit("update:useKq", false);
3553
3559
  emit("update:kqCode", "");
3554
3560
  emit("update:kqInfo", {});
3555
- (_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "change").catch(() => {
3561
+ (_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "change").catch((err) => {
3562
+ if (process.env.NODE_ENV === "development") {
3563
+ console.warn("[ChineseCompanySearch] formItem.validate 失败:", err);
3564
+ }
3556
3565
  });
3557
3566
  options.value = [];
3558
3567
  };
@@ -3564,10 +3573,13 @@ const _sfc_main$p = {
3564
3573
  );
3565
3574
  onBeforeUnmount(() => {
3566
3575
  fetchOptionsDebounced.cancel();
3576
+ if (abortController) {
3577
+ abortController.abort();
3578
+ }
3567
3579
  });
3568
3580
  return (_ctx, _cache) => {
3569
3581
  return openBlock(), createElementBlock("div", _hoisted_1$l, [
3570
- [1].includes(Number(props.countryId)) ? (openBlock(), createBlock(unref(ElSelect), {
3582
+ isChina.value ? (openBlock(), createBlock(unref(ElSelect), {
3571
3583
  key: 0,
3572
3584
  modelValue: companyNameValue.value,
3573
3585
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => companyNameValue.value = $event),
@@ -3575,13 +3587,12 @@ const _sfc_main$p = {
3575
3587
  remote: "",
3576
3588
  "reserve-keyword": "",
3577
3589
  clearable: "",
3578
- "allow-create": __props.allowCreate,
3579
- "default-first-option": __props.defaultFirstOption,
3590
+ "allow-create": props.allowCreate,
3591
+ "default-first-option": props.defaultFirstOption,
3580
3592
  "remote-method": handleRemoteSearch,
3581
3593
  loading: loading.value,
3582
3594
  disabled: isDisabled.value || props.disabled,
3583
3595
  placeholder: unref(isEn) ? "Company Name in Chinese" : "请输入您的公司中文名称",
3584
- style: { "width": "100%" },
3585
3596
  "popper-class": `company-search dialog-join-us`,
3586
3597
  onChange: handleSelectChange
3587
3598
  }, {
@@ -3591,7 +3602,7 @@ const _sfc_main$p = {
3591
3602
  default: withCtx(() => [
3592
3603
  (openBlock(true), createElementBlock(Fragment, null, renderList(options.value, (item) => {
3593
3604
  return openBlock(), createBlock(unref(ElOption), {
3594
- key: item.code,
3605
+ key: item.kqId,
3595
3606
  label: item.value,
3596
3607
  value: item.value
3597
3608
  }, {
@@ -3612,7 +3623,6 @@ const _sfc_main$p = {
3612
3623
  disabled: isDisabled.value || props.disabled,
3613
3624
  placeholder: unref(isEn) ? "Company name in English" : "请输入您的公司英文名称",
3614
3625
  "max-length": "200",
3615
- style: { "width": "100%" },
3616
3626
  onChange: handleChange
3617
3627
  }, {
3618
3628
  prepend: withCtx(() => [
@@ -3623,8 +3633,8 @@ const _sfc_main$p = {
3623
3633
  ]);
3624
3634
  };
3625
3635
  }
3626
- };
3627
- const ChineseCompanySearch$1 = /* @__PURE__ */ _export_sfc(_sfc_main$p, [["__scopeId", "data-v-07246d14"]]);
3636
+ });
3637
+ const ChineseCompanySearch$1 = /* @__PURE__ */ _export_sfc(_sfc_main$p, [["__scopeId", "data-v-1c4f606a"]]);
3628
3638
  const __vite_glob_0_1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3629
3639
  __proto__: null,
3630
3640
  default: ChineseCompanySearch$1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jctrans-materials/comps-vue3",
3
- "version": "1.0.41-beta.4",
3
+ "version": "1.0.41-beta.6",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "type": "module",
@@ -38,7 +38,7 @@
38
38
  "nanoid": "^5.1.6",
39
39
  "qrcode": "^1.5.4",
40
40
  "tailwindcss": "4.1.18",
41
- "@jctrans-materials/shared": "1.0.41-beta.4"
41
+ "@jctrans-materials/shared": "1.0.41-beta.6"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@tailwindcss/postcss": "4.1.18",