paas-component-library 0.9.96 → 0.9.98

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/paas-ui.js CHANGED
@@ -9128,50 +9128,69 @@ const ZH = /* @__PURE__ */ qt(UH, [["render", GH]]), YH = {
9128
9128
  },
9129
9129
  data: {
9130
9130
  type: Array,
9131
- default: []
9131
+ default: () => []
9132
9132
  },
9133
9133
  params: {
9134
9134
  type: String,
9135
9135
  default: ""
9136
9136
  }
9137
9137
  },
9138
- created() {
9139
- this.data && this.data.length > 0 ? this.datas = this.data : this.datas = this.$store.dicts[this.params] || [];
9140
- },
9141
- mounted() {
9142
- this.modelValue ? typeof this.modelValue == "string" && this.modelValue.includes(",") ? this.value = this.modelValue.split(",") : this.modelValue != null && (this.value = Array.isArray(this.modelValue) ? this.modelValue : [this.modelValue]) : this.modelValue != null && (this.value = String(this.modelValue));
9143
- },
9144
9138
  data() {
9145
9139
  return {
9146
- value: null,
9147
- datas: []
9140
+ stringValue: null,
9141
+ // 内部用于绑定 Select 的值(统一为字符串)
9142
+ internalOptions: [],
9143
+ // options,value 同样转为字符串,附加原始值
9144
+ originMap: /* @__PURE__ */ new Map()
9145
+ // stringValue -> 原始值
9148
9146
  };
9149
9147
  },
9148
+ created() {
9149
+ this.initOptions();
9150
+ },
9151
+ mounted() {
9152
+ this.setInternalValue(this.modelValue);
9153
+ },
9150
9154
  watch: {
9151
9155
  modelValue(r) {
9152
- r == null && (r = "");
9153
- let e = new Array();
9154
- Array.isArray(r) ? (r.forEach((t) => {
9155
- t != "" && e.push(String(t));
9156
- }), this.value = e) : r instanceof String && (r != null && r.includes(",")) ? (r.spit(",").forEach((t) => {
9157
- t != "" && e.push(String(t));
9158
- }), this.value = e) : this.multiple && r ? this.value = [String(r)] : this.value = String(r);
9156
+ this.setInternalValue(r);
9159
9157
  },
9160
- data(r) {
9161
- r && r.length > 0 && (this.datas = r);
9158
+ data() {
9159
+ this.initOptions();
9162
9160
  },
9163
- value(r) {
9164
- this.$emit("update:modelValue", r), this.$emit("change", r);
9161
+ stringValue(r) {
9162
+ if (this.multiple) {
9163
+ const e = (r == null ? void 0 : r.map((t) => this.originMap.get(t))) || [];
9164
+ this.$emit("update:modelValue", e), this.$emit("change", e);
9165
+ } else {
9166
+ const e = this.originMap.get(r) ?? null;
9167
+ this.$emit("update:modelValue", e), this.$emit("change", e);
9168
+ }
9169
+ }
9170
+ },
9171
+ methods: {
9172
+ initOptions() {
9173
+ const r = this.data.length > 0 ? this.data : this.$store.dicts[this.params] || [];
9174
+ this.internalOptions = r.map((e) => {
9175
+ const t = String(e.value);
9176
+ return this.originMap.set(t, e.value), {
9177
+ ...e,
9178
+ value: t
9179
+ };
9180
+ });
9181
+ },
9182
+ setInternalValue(r) {
9183
+ this.multiple ? Array.isArray(r) ? this.stringValue = r.map((e) => String(e)) : typeof r == "string" && r.includes(",") ? this.stringValue = r.split(",").map((e) => String(e.trim())) : r != null && r !== "" ? this.stringValue = [String(r)] : this.stringValue = [] : this.stringValue = r != null ? String(r) : null;
9165
9184
  }
9166
9185
  }
9167
9186
  };
9168
9187
  function QH(r, e, t, n, a, f) {
9169
9188
  const h = Ee("a-select");
9170
9189
  return nt(), wt(h, {
9171
- options: a.datas,
9190
+ options: a.internalOptions,
9172
9191
  mode: t.multiple ? "multiple" : void 0,
9173
- value: a.value,
9174
- "onUpdate:value": e[0] || (e[0] = (m) => a.value = m),
9192
+ value: a.stringValue,
9193
+ "onUpdate:value": e[0] || (e[0] = (m) => a.stringValue = m),
9175
9194
  disabled: t.disabled,
9176
9195
  allowClear: !0,
9177
9196
  style: { "min-width": "200px", width: "100%" },
@@ -30420,51 +30439,27 @@ const Ul = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
30420
30439
  }
30421
30440
  },
30422
30441
  props: {
30423
- placeholder: {
30424
- type: String,
30425
- default: ""
30426
- },
30427
- size: {
30428
- type: Number,
30429
- default: 2
30430
- },
30431
- textWidth: {
30432
- type: String,
30433
- default: ""
30434
- },
30435
- data: {
30436
- type: Array,
30437
- default: () => []
30438
- },
30439
- multiple: {
30440
- type: Boolean,
30441
- default: !1
30442
- },
30442
+ placeholder: { type: String, default: "" },
30443
+ size: { type: Number, default: 2 },
30444
+ textWidth: { type: String, default: "" },
30445
+ data: { type: Array, default: () => [] },
30446
+ multiple: { type: Boolean, default: !1 },
30443
30447
  modelValue: {
30444
- type: [
30445
- String,
30446
- Number,
30447
- Object,
30448
- Array
30449
- ],
30448
+ type: [String, Number, Object, Array],
30450
30449
  default: null
30451
30450
  },
30452
- params: {
30453
- type: String,
30454
- default: ""
30455
- },
30456
- label: {
30457
- type: String,
30458
- default: ""
30459
- },
30460
- name: {
30461
- type: String,
30462
- default: ""
30463
- },
30464
- disabled: {
30465
- type: Boolean,
30466
- default: !1
30467
- }
30451
+ params: { type: String, default: "" },
30452
+ label: { type: String, default: "" },
30453
+ name: { type: String, default: "" },
30454
+ disabled: { type: Boolean, default: !1 }
30455
+ },
30456
+ data() {
30457
+ return {
30458
+ value: this.multiple ? [] : "",
30459
+ // 绑定给 paas-select 的值,统一字符串或字符串数组
30460
+ datas: []
30461
+ // 处理后的 data,保证 options.value 都是字符串
30462
+ };
30468
30463
  },
30469
30464
  computed: {
30470
30465
  see() {
@@ -30472,28 +30467,39 @@ const Ul = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
30472
30467
  }
30473
30468
  },
30474
30469
  watch: {
30475
- modelValue(r) {
30476
- r == null && (r = "");
30477
- let e = new Array();
30478
- Array.isArray(r) ? (r.forEach((t) => {
30479
- t != "" && e.push(String(t));
30480
- }), this.value = e) : r instanceof String && (r != null && r.includes(",")) ? (r.spit(",").forEach((t) => {
30481
- t != "" && e.push(String(t));
30482
- }), this.value = e) : this.multiple && r ? this.value = [String(r)] : this.value = String(r);
30470
+ modelValue: {
30471
+ immediate: !0,
30472
+ handler(r) {
30473
+ this.syncValue(r);
30474
+ }
30475
+ },
30476
+ data: {
30477
+ immediate: !0,
30478
+ handler(r) {
30479
+ this.datas = (r || []).map((e) => ({
30480
+ ...e,
30481
+ value: e.value != null ? String(e.value) : e.value
30482
+ }));
30483
+ }
30483
30484
  }
30484
30485
  },
30485
- mounted() {
30486
- this.modelValue ? typeof this.modelValue == "string" && this.modelValue.includes(",") ? this.value = this.modelValue.split(",") : this.value = Array.isArray(this.modelValue) ? this.modelValue : [this.modelValue] : this.value = this.modelValue;
30487
- },
30488
- data() {
30489
- return {
30490
- value: null
30491
- };
30492
- },
30493
30486
  methods: {
30487
+ syncValue(r) {
30488
+ if (console.log("syncValue", r), r == null || r === "") {
30489
+ this.value = this.multiple ? [] : "";
30490
+ return;
30491
+ }
30492
+ this.multiple ? Array.isArray(r) ? this.value = r.filter((e) => e != null).map((e) => String(e)) : typeof r == "string" && r.includes(",") ? this.value = r.split(",").map((e) => e.trim()).filter((e) => e !== "") : this.value = [String(r)] : Array.isArray(r) && r.length > 0 ? this.value = String(r[0]) : typeof r == "string" || typeof r == "number" ? this.value = String(r) : this.value = "";
30493
+ },
30494
30494
  handleChange(r) {
30495
- this.$emit("update:modelValue", r), this.$emit("change", r);
30495
+ this.multiple ? (this.$emit("update:modelValue", r), this.$emit("change", r)) : (this.$emit("update:modelValue", r), this.$emit("change", r));
30496
30496
  }
30497
+ },
30498
+ mounted() {
30499
+ this.syncValue(this.modelValue), this.datas = (this.data || []).map((r) => ({
30500
+ ...r,
30501
+ value: r.value != null ? String(r.value) : r.value
30502
+ }));
30497
30503
  }
30498
30504
  };
30499
30505
  function Nce(r, e, t, n, a, f) {
@@ -30505,12 +30511,12 @@ function Nce(r, e, t, n, a, f) {
30505
30511
  O(m, {
30506
30512
  label: t.label,
30507
30513
  name: t.name,
30508
- "label-col": { style: { width: t.textWidth ? t.textWidth : f.labelWidth } },
30514
+ "label-col": { style: { width: t.textWidth || f.labelWidth } },
30509
30515
  "wrapper-col": { style: { flex: 1 } }
30510
30516
  }, {
30511
30517
  default: Fe(() => [
30512
30518
  O(h, {
30513
- data: t.data,
30519
+ data: a.datas,
30514
30520
  value: a.value,
30515
30521
  disabled: f.see || t.disabled,
30516
30522
  mode: t.multiple ? "multiple" : void 0,