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.
package/dist/render.es.js CHANGED
@@ -2004,6 +2004,7 @@ var enLocale_extension = {
2004
2004
  meetingRoomRemoteUrl: "Request URL",
2005
2005
  allowMultiple: "Allow Multiple",
2006
2006
  currentUserType: "Current User Type",
2007
+ currentUserValueType: "Value Type",
2007
2008
  selectTreeCheckStrictly: "Check Strictly",
2008
2009
  assetSelectButtonText: "Button Text",
2009
2010
  assetSelectTypeJson: "Asset Type Json",
@@ -2077,6 +2078,7 @@ var zhLocale_extension = {
2077
2078
  meetingRoomRemoteUrl: "\u8BF7\u6C42\u5730\u5740",
2078
2079
  allowMultiple: "\u662F\u5426\u591A\u9009",
2079
2080
  currentUserType: "\u5F53\u524D\u7528\u6237\u7C7B\u578B",
2081
+ currentUserValueType: "\u503C\u7C7B\u578B",
2080
2082
  selectTreeCheckStrictly: "\u662F\u5426\u4E25\u683C\u9009\u4E2D",
2081
2083
  assetSelectButtonText: "\u6309\u94AE\u6587\u5B57",
2082
2084
  assetSelectTypeJson: "\u8D44\u4EA7\u7C7B\u578BJson",
@@ -26644,13 +26646,13 @@ function registerIcon(app) {
26644
26646
  if (typeof window !== "undefined") {
26645
26647
  let loadSvg = function() {
26646
26648
  var body = document.body;
26647
- var svgDom = document.getElementById("__svg__icons__dom__1783062051755__");
26649
+ var svgDom = document.getElementById("__svg__icons__dom__1783064649026__");
26648
26650
  if (!svgDom) {
26649
26651
  svgDom = document.createElementNS("http://www.w3.org/2000/svg", "svg");
26650
26652
  svgDom.style.position = "absolute";
26651
26653
  svgDom.style.width = "0";
26652
26654
  svgDom.style.height = "0";
26653
- svgDom.id = "__svg__icons__dom__1783062051755__";
26655
+ svgDom.id = "__svg__icons__dom__1783064649026__";
26654
26656
  svgDom.setAttribute("xmlns", "http://www.w3.org/2000/svg");
26655
26657
  svgDom.setAttribute("xmlns:link", "http://www.w3.org/1999/xlink");
26656
26658
  }
@@ -62346,20 +62348,26 @@ const _sfc_main$f = {
62346
62348
  return {
62347
62349
  fieldModel: null,
62348
62350
  oldFieldValue: null,
62349
- rules: []
62351
+ rules: [],
62352
+ rawUserData: null
62350
62353
  };
62351
62354
  },
62352
62355
  computed: {
62353
62356
  displayModel() {
62357
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
62358
+ if (this.isStringValueType) {
62359
+ return (_a = this.fieldModel) != null ? _a : "";
62360
+ }
62354
62361
  if (this.currentUserType === "username") {
62355
- return this.fieldModel ? this.fieldModel.username : "";
62356
- } else if (this.currentUserType === "deptName") {
62357
- return this.fieldModel ? this.fieldModel.deptName : "";
62358
- } else if (this.currentUserType === "companyName") {
62359
- return this.fieldModel ? this.fieldModel.companyName : "";
62360
- } else {
62361
- return JSON.stringify(this.fieldModel);
62362
+ return (_e = (_d = (_b = this.fieldModel) == null ? void 0 : _b.username) != null ? _d : (_c = this.fieldModel) == null ? void 0 : _c.userName) != null ? _e : "";
62362
62363
  }
62364
+ if (this.currentUserType === "deptName") {
62365
+ return (_g = (_f = this.fieldModel) == null ? void 0 : _f.deptName) != null ? _g : "";
62366
+ }
62367
+ if (this.currentUserType === "companyName") {
62368
+ return (_i = (_h = this.fieldModel) == null ? void 0 : _h.companyName) != null ? _i : "";
62369
+ }
62370
+ return this.fieldModel ? JSON.stringify(this.fieldModel) : "";
62363
62371
  },
62364
62372
  widgetStyle() {
62365
62373
  return {
@@ -62369,22 +62377,90 @@ const _sfc_main$f = {
62369
62377
  currentUserType() {
62370
62378
  var _a;
62371
62379
  return ((_a = this.field.options) == null ? void 0 : _a.type) || "username";
62380
+ },
62381
+ isStringValueType() {
62382
+ var _a;
62383
+ return ((_a = this.field.options) == null ? void 0 : _a.valueType) === "string";
62372
62384
  }
62373
62385
  },
62374
62386
  methods: {
62387
+ extractStringValue(data2) {
62388
+ var _a, _b, _c, _d;
62389
+ if (data2 == null) {
62390
+ return "";
62391
+ }
62392
+ if (typeof data2 === "string") {
62393
+ return data2;
62394
+ }
62395
+ if (this.currentUserType === "username") {
62396
+ return (_b = (_a = data2.username) != null ? _a : data2.userName) != null ? _b : "";
62397
+ }
62398
+ if (this.currentUserType === "deptName") {
62399
+ return (_c = data2.deptName) != null ? _c : "";
62400
+ }
62401
+ if (this.currentUserType === "companyName") {
62402
+ return (_d = data2.companyName) != null ? _d : "";
62403
+ }
62404
+ return "";
62405
+ },
62406
+ normalizeFieldValue(data2) {
62407
+ if (this.isStringValueType) {
62408
+ return this.extractStringValue(data2);
62409
+ }
62410
+ if (data2 && typeof data2 === "object") {
62411
+ return data2;
62412
+ }
62413
+ return data2;
62414
+ },
62415
+ applyFieldValue(data2, emitChange = true) {
62416
+ var _a;
62417
+ const oldValue = (_a = this.oldFieldValue) != null ? _a : this.fieldModel;
62418
+ this.fieldModel = this.normalizeFieldValue(data2);
62419
+ this.syncUpdateFormModel(this.fieldModel);
62420
+ if (emitChange) {
62421
+ this.emitFieldDataChange(this.fieldModel, oldValue);
62422
+ }
62423
+ },
62375
62424
  hasExistingValue() {
62376
62425
  var _a;
62377
62426
  const v = (_a = this.fieldModel) != null ? _a : this.oldFieldValue;
62378
- return v !== void 0 && v !== null && v !== "";
62427
+ if (v === void 0 || v === null) {
62428
+ return false;
62429
+ }
62430
+ if (this.isStringValueType) {
62431
+ return v !== "";
62432
+ }
62433
+ if (typeof v === "object") {
62434
+ return Object.keys(v).length > 0;
62435
+ }
62436
+ return v !== "";
62379
62437
  },
62380
62438
  async getCurrentUser() {
62381
62439
  const { data: data2 } = await service$1({
62382
62440
  method: "get",
62383
62441
  url: "unified-system/employee/loginInfo?accessType=0"
62384
62442
  });
62385
- this.fieldModel = data2;
62386
- this.syncUpdateFormModel(this.fieldModel);
62387
- this.emitFieldDataChange(this.fieldModel, this.oldFieldValue);
62443
+ this.rawUserData = data2;
62444
+ this.applyFieldValue(data2);
62445
+ },
62446
+ refreshFieldValueFromOptions() {
62447
+ var _a;
62448
+ const source2 = (_a = this.rawUserData) != null ? _a : this.fieldModel;
62449
+ if (source2 == null) {
62450
+ if (!this.designState) {
62451
+ this.getCurrentUser();
62452
+ }
62453
+ return;
62454
+ }
62455
+ if (this.isStringValueType && typeof source2 === "object") {
62456
+ this.applyFieldValue(source2);
62457
+ return;
62458
+ }
62459
+ if (!this.isStringValueType && typeof source2 === "string") {
62460
+ this.getCurrentUser();
62461
+ return;
62462
+ }
62463
+ this.applyFieldValue(source2);
62388
62464
  }
62389
62465
  },
62390
62466
  watch: {
@@ -62397,13 +62473,11 @@ const _sfc_main$f = {
62397
62473
  "field.options.onValidate"() {
62398
62474
  this.buildFieldRules();
62399
62475
  },
62400
- "field.options.type": {
62401
- handler(newVal, oldVal) {
62402
- if (oldVal === void 0)
62403
- return;
62404
- this.getCurrentUser();
62405
- },
62406
- immediate: false
62476
+ "field.options.type"() {
62477
+ this.refreshFieldValueFromOptions();
62478
+ },
62479
+ "field.options.valueType"() {
62480
+ this.refreshFieldValueFromOptions();
62407
62481
  }
62408
62482
  },
62409
62483
  created() {
@@ -62412,10 +62486,17 @@ const _sfc_main$f = {
62412
62486
  this.initEventHandler();
62413
62487
  this.buildFieldRules();
62414
62488
  this.handleOnCreated();
62489
+ if (this.fieldModel && typeof this.fieldModel === "object") {
62490
+ this.rawUserData = this.fieldModel;
62491
+ }
62415
62492
  },
62416
62493
  mounted() {
62417
- if (this.hasExistingValue())
62494
+ if (this.hasExistingValue()) {
62495
+ if (this.isStringValueType && typeof this.fieldModel === "object") {
62496
+ this.applyFieldValue(this.fieldModel, false);
62497
+ }
62418
62498
  return;
62499
+ }
62419
62500
  this.getCurrentUser();
62420
62501
  }
62421
62502
  };
@@ -66908,6 +66989,12 @@ const loadExtension = function(app) {
66908
66989
  { label: "\u516C\u53F8\u540D\u79F0", value: "companyName" }
66909
66990
  ]
66910
66991
  }));
66992
+ registerCPEditor(app, "current-user-valueType", "current-user-valueType-editor", createSelectEditor("valueType", "extension.setting.currentUserValueType", {
66993
+ optionItems: [
66994
+ { label: "\u5B57\u7B26\u4E32", value: "string" },
66995
+ { label: "\u5BF9\u8C61", value: "object" }
66996
+ ]
66997
+ }));
66911
66998
  app.component(CurrentUserSecondCompanyWidget.name, CurrentUserSecondCompanyWidget);
66912
66999
  app.component(AssetSelectWidget.name, AssetSelectWidget);
66913
67000
  registerCPEditor(app, "asset-select-buttonText", "asset-select-buttonText-editor", createInputTextEditor("buttonText", "extension.setting.assetSelectButtonText"));