form-custom-test 3.0.221 → 3.0.222

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.
@@ -3862,6 +3862,7 @@ const currentUserSchema = {
3862
3862
  name: "",
3863
3863
  label: "\u5F53\u524D\u7528\u6237",
3864
3864
  type: "username",
3865
+ valueType: "object",
3865
3866
  columnWidth: "auto",
3866
3867
  required: false,
3867
3868
  requiredHint: "",
@@ -4190,6 +4191,7 @@ var enLocale_extension = {
4190
4191
  meetingRoomRemoteUrl: "Request URL",
4191
4192
  allowMultiple: "Allow Multiple",
4192
4193
  currentUserType: "Current User Type",
4194
+ currentUserValueType: "Value Type",
4193
4195
  selectTreeCheckStrictly: "Check Strictly",
4194
4196
  assetSelectButtonText: "Button Text",
4195
4197
  assetSelectTypeJson: "Asset Type Json",
@@ -4263,6 +4265,7 @@ var zhLocale_extension = {
4263
4265
  meetingRoomRemoteUrl: "\u8BF7\u6C42\u5730\u5740",
4264
4266
  allowMultiple: "\u662F\u5426\u591A\u9009",
4265
4267
  currentUserType: "\u5F53\u524D\u7528\u6237\u7C7B\u578B",
4268
+ currentUserValueType: "\u503C\u7C7B\u578B",
4266
4269
  selectTreeCheckStrictly: "\u662F\u5426\u4E25\u683C\u9009\u4E2D",
4267
4270
  assetSelectButtonText: "\u6309\u94AE\u6587\u5B57",
4268
4271
  assetSelectTypeJson: "\u8D44\u4EA7\u7C7B\u578BJson",
@@ -69279,13 +69282,13 @@ function registerIcon(app) {
69279
69282
  if (typeof window !== "undefined") {
69280
69283
  let loadSvg = function() {
69281
69284
  var body = document.body;
69282
- var svgDom = document.getElementById("__svg__icons__dom__1783062042423__");
69285
+ var svgDom = document.getElementById("__svg__icons__dom__1783064639584__");
69283
69286
  if (!svgDom) {
69284
69287
  svgDom = document.createElementNS("http://www.w3.org/2000/svg", "svg");
69285
69288
  svgDom.style.position = "absolute";
69286
69289
  svgDom.style.width = "0";
69287
69290
  svgDom.style.height = "0";
69288
- svgDom.id = "__svg__icons__dom__1783062042423__";
69291
+ svgDom.id = "__svg__icons__dom__1783064639584__";
69289
69292
  svgDom.setAttribute("xmlns", "http://www.w3.org/2000/svg");
69290
69293
  svgDom.setAttribute("xmlns:link", "http://www.w3.org/1999/xlink");
69291
69294
  }
@@ -79435,20 +79438,26 @@ const _sfc_main$f = {
79435
79438
  return {
79436
79439
  fieldModel: null,
79437
79440
  oldFieldValue: null,
79438
- rules: []
79441
+ rules: [],
79442
+ rawUserData: null
79439
79443
  };
79440
79444
  },
79441
79445
  computed: {
79442
79446
  displayModel() {
79447
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i;
79448
+ if (this.isStringValueType) {
79449
+ return (_a2 = this.fieldModel) != null ? _a2 : "";
79450
+ }
79443
79451
  if (this.currentUserType === "username") {
79444
- return this.fieldModel ? this.fieldModel.username : "";
79445
- } else if (this.currentUserType === "deptName") {
79446
- return this.fieldModel ? this.fieldModel.deptName : "";
79447
- } else if (this.currentUserType === "companyName") {
79448
- return this.fieldModel ? this.fieldModel.companyName : "";
79449
- } else {
79450
- return JSON.stringify(this.fieldModel);
79452
+ return (_e = (_d = (_b2 = this.fieldModel) == null ? void 0 : _b2.username) != null ? _d : (_c2 = this.fieldModel) == null ? void 0 : _c2.userName) != null ? _e : "";
79451
79453
  }
79454
+ if (this.currentUserType === "deptName") {
79455
+ return (_g = (_f = this.fieldModel) == null ? void 0 : _f.deptName) != null ? _g : "";
79456
+ }
79457
+ if (this.currentUserType === "companyName") {
79458
+ return (_i = (_h = this.fieldModel) == null ? void 0 : _h.companyName) != null ? _i : "";
79459
+ }
79460
+ return this.fieldModel ? JSON.stringify(this.fieldModel) : "";
79452
79461
  },
79453
79462
  widgetStyle() {
79454
79463
  return {
@@ -79458,22 +79467,90 @@ const _sfc_main$f = {
79458
79467
  currentUserType() {
79459
79468
  var _a2;
79460
79469
  return ((_a2 = this.field.options) == null ? void 0 : _a2.type) || "username";
79470
+ },
79471
+ isStringValueType() {
79472
+ var _a2;
79473
+ return ((_a2 = this.field.options) == null ? void 0 : _a2.valueType) === "string";
79461
79474
  }
79462
79475
  },
79463
79476
  methods: {
79477
+ extractStringValue(data2) {
79478
+ var _a2, _b2, _c2, _d;
79479
+ if (data2 == null) {
79480
+ return "";
79481
+ }
79482
+ if (typeof data2 === "string") {
79483
+ return data2;
79484
+ }
79485
+ if (this.currentUserType === "username") {
79486
+ return (_b2 = (_a2 = data2.username) != null ? _a2 : data2.userName) != null ? _b2 : "";
79487
+ }
79488
+ if (this.currentUserType === "deptName") {
79489
+ return (_c2 = data2.deptName) != null ? _c2 : "";
79490
+ }
79491
+ if (this.currentUserType === "companyName") {
79492
+ return (_d = data2.companyName) != null ? _d : "";
79493
+ }
79494
+ return "";
79495
+ },
79496
+ normalizeFieldValue(data2) {
79497
+ if (this.isStringValueType) {
79498
+ return this.extractStringValue(data2);
79499
+ }
79500
+ if (data2 && typeof data2 === "object") {
79501
+ return data2;
79502
+ }
79503
+ return data2;
79504
+ },
79505
+ applyFieldValue(data2, emitChange = true) {
79506
+ var _a2;
79507
+ const oldValue = (_a2 = this.oldFieldValue) != null ? _a2 : this.fieldModel;
79508
+ this.fieldModel = this.normalizeFieldValue(data2);
79509
+ this.syncUpdateFormModel(this.fieldModel);
79510
+ if (emitChange) {
79511
+ this.emitFieldDataChange(this.fieldModel, oldValue);
79512
+ }
79513
+ },
79464
79514
  hasExistingValue() {
79465
79515
  var _a2;
79466
79516
  const v = (_a2 = this.fieldModel) != null ? _a2 : this.oldFieldValue;
79467
- return v !== void 0 && v !== null && v !== "";
79517
+ if (v === void 0 || v === null) {
79518
+ return false;
79519
+ }
79520
+ if (this.isStringValueType) {
79521
+ return v !== "";
79522
+ }
79523
+ if (typeof v === "object") {
79524
+ return Object.keys(v).length > 0;
79525
+ }
79526
+ return v !== "";
79468
79527
  },
79469
79528
  async getCurrentUser() {
79470
79529
  const { data: data2 } = await service$1({
79471
79530
  method: "get",
79472
79531
  url: "unified-system/employee/loginInfo?accessType=0"
79473
79532
  });
79474
- this.fieldModel = data2;
79475
- this.syncUpdateFormModel(this.fieldModel);
79476
- this.emitFieldDataChange(this.fieldModel, this.oldFieldValue);
79533
+ this.rawUserData = data2;
79534
+ this.applyFieldValue(data2);
79535
+ },
79536
+ refreshFieldValueFromOptions() {
79537
+ var _a2;
79538
+ const source2 = (_a2 = this.rawUserData) != null ? _a2 : this.fieldModel;
79539
+ if (source2 == null) {
79540
+ if (!this.designState) {
79541
+ this.getCurrentUser();
79542
+ }
79543
+ return;
79544
+ }
79545
+ if (this.isStringValueType && typeof source2 === "object") {
79546
+ this.applyFieldValue(source2);
79547
+ return;
79548
+ }
79549
+ if (!this.isStringValueType && typeof source2 === "string") {
79550
+ this.getCurrentUser();
79551
+ return;
79552
+ }
79553
+ this.applyFieldValue(source2);
79477
79554
  }
79478
79555
  },
79479
79556
  watch: {
@@ -79486,13 +79563,11 @@ const _sfc_main$f = {
79486
79563
  "field.options.onValidate"() {
79487
79564
  this.buildFieldRules();
79488
79565
  },
79489
- "field.options.type": {
79490
- handler(newVal, oldVal) {
79491
- if (oldVal === void 0)
79492
- return;
79493
- this.getCurrentUser();
79494
- },
79495
- immediate: false
79566
+ "field.options.type"() {
79567
+ this.refreshFieldValueFromOptions();
79568
+ },
79569
+ "field.options.valueType"() {
79570
+ this.refreshFieldValueFromOptions();
79496
79571
  }
79497
79572
  },
79498
79573
  created() {
@@ -79501,10 +79576,17 @@ const _sfc_main$f = {
79501
79576
  this.initEventHandler();
79502
79577
  this.buildFieldRules();
79503
79578
  this.handleOnCreated();
79579
+ if (this.fieldModel && typeof this.fieldModel === "object") {
79580
+ this.rawUserData = this.fieldModel;
79581
+ }
79504
79582
  },
79505
79583
  mounted() {
79506
- if (this.hasExistingValue())
79584
+ if (this.hasExistingValue()) {
79585
+ if (this.isStringValueType && typeof this.fieldModel === "object") {
79586
+ this.applyFieldValue(this.fieldModel, false);
79587
+ }
79507
79588
  return;
79589
+ }
79508
79590
  this.getCurrentUser();
79509
79591
  }
79510
79592
  };
@@ -84010,6 +84092,12 @@ const loadExtension = function(app) {
84010
84092
  { label: "\u516C\u53F8\u540D\u79F0", value: "companyName" }
84011
84093
  ]
84012
84094
  }));
84095
+ registerCPEditor(app, "current-user-valueType", "current-user-valueType-editor", createSelectEditor("valueType", "extension.setting.currentUserValueType", {
84096
+ optionItems: [
84097
+ { label: "\u5B57\u7B26\u4E32", value: "string" },
84098
+ { label: "\u5BF9\u8C61", value: "object" }
84099
+ ]
84100
+ }));
84013
84101
  addCustomWidgetSchema(currentUserSecondCompanySchema);
84014
84102
  app.component(CurrentUserSecondCompanyWidget.name, CurrentUserSecondCompanyWidget);
84015
84103
  addCustomWidgetSchema(assetSelectSchema);