cloud-web-corejs 1.0.54-dev.702 → 1.0.54-dev.704

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.
@@ -1,6 +1,7 @@
1
1
  import { generateId } from "../../../../components/xform/utils/util";
2
2
  import {
3
3
  buildDynamicSchemaRequestData,
4
+ extractDynamicSchemaItems,
4
5
  getDynamicSchemaOption,
5
6
  normalizeDynamicFieldKey,
6
7
  resolveDynamicSchemaResponse,
@@ -10,7 +11,7 @@ import {
10
11
  * 表格布局容器(table/h5-table)专用混入。
11
12
  *
12
13
  * 提供两类「布局表格」特有能力(动态字段状态控制已统一收敛到表单设置,见 formDynamicFieldMixin):
13
- * 1. 后台字段定义(dynamicSchemaEnabled):字段定义由后台查询下发,运行时生成并插入到行布局中。
14
+ * 1. 动态字段(dynamicSchemaSourceType):字段定义由脚本或接口下发,运行时生成并插入到行布局中。
14
15
  * 2. 行折叠(默认行为):整行字段均隐藏时折叠该行(响应式,随字段显隐自动更新)。
15
16
  *
16
17
  * 依赖宿主组件已混入:containerItemMixin(formModel/formHttp/handleCustomEvent/designState)
@@ -67,23 +68,102 @@ const dynamicFieldMixin = {
67
68
  },
68
69
 
69
70
  /* ------------------- 后台字段定义模式(行布局容器) ------------------- */
71
+ getDynamicSchemaSourceType() {
72
+ const options = this.widget.options || {};
73
+ const sourceType = getDynamicSchemaOption(options, "sourceType");
74
+ if (sourceType) {
75
+ return sourceType;
76
+ }
77
+ // 兼容旧配置:dynamicSchemaEnabled
78
+ if (options.dynamicSchemaEnabled) {
79
+ return "api";
80
+ }
81
+ return "none";
82
+ },
83
+
84
+ resolveShouldInitDynamicSchema() {
85
+ const source = this.getDynamicSchemaSourceType();
86
+ if (source === "none") {
87
+ return Promise.resolve(false);
88
+ }
89
+ const options = this.widget.options;
90
+ if (source === "api" && !getDynamicSchemaOption(options, "scriptCode")) {
91
+ return Promise.resolve(false);
92
+ }
93
+ if (source === "script" && !getDynamicSchemaOption(options, "frontendScript")) {
94
+ return Promise.resolve(false);
95
+ }
96
+ const script = getDynamicSchemaOption(options, "loadScript");
97
+ if (!script) {
98
+ return Promise.resolve(true);
99
+ }
100
+ const formRef = this.getFormRef();
101
+ if (!formRef || formRef.designState) {
102
+ return Promise.resolve(false);
103
+ }
104
+ try {
105
+ const result = this.handleCustomEvent(script);
106
+ if (result === false || result === null) {
107
+ return Promise.resolve(false);
108
+ }
109
+ return Promise.resolve(true);
110
+ } catch (e) {
111
+ return Promise.resolve(false);
112
+ }
113
+ },
114
+
70
115
  initDynamicSchema() {
71
116
  if (this.designState || !this.widget) return;
72
- const options = this.widget.options || {};
73
- if (!options.dynamicSchemaEnabled || !this.supportsRowLayout()) return;
117
+ if (!this.supportsRowLayout()) return;
118
+ if (this.getDynamicSchemaSourceType() === "none") return;
74
119
  this.$nextTick(() => {
75
- this.loadDynamicSchema();
120
+ this.resolveShouldInitDynamicSchema().then((shouldInit) => {
121
+ if (shouldInit) {
122
+ this.loadDynamicSchema();
123
+ }
124
+ });
76
125
  });
77
126
  },
78
127
 
79
128
  loadDynamicSchema() {
129
+ if (this.designState || !this.supportsRowLayout()) {
130
+ return Promise.resolve();
131
+ }
132
+ const source = this.getDynamicSchemaSourceType();
133
+ if (source === "script") {
134
+ return this.loadDynamicSchemaFromScript();
135
+ }
136
+ if (source === "api") {
137
+ return this.loadDynamicSchemaFromApi();
138
+ }
139
+ return Promise.resolve();
140
+ },
141
+
142
+ loadDynamicSchemaFromScript() {
143
+ const script = getDynamicSchemaOption(this.widget.options, "frontendScript");
144
+ if (!script) {
145
+ return Promise.resolve();
146
+ }
147
+ try {
148
+ const result = this.handleCustomEvent(script);
149
+ const defs = this.normalizeSchemaScriptResult(result);
150
+ this.buildDynamicRows(defs);
151
+ return Promise.resolve();
152
+ } catch (e) {
153
+ return Promise.resolve();
154
+ }
155
+ },
156
+
157
+ normalizeSchemaScriptResult(result) {
158
+ if (result === null || result === undefined) {
159
+ return [];
160
+ }
161
+ return extractDynamicSchemaItems(result);
162
+ },
163
+
164
+ loadDynamicSchemaFromApi() {
80
165
  const options = this.widget.options;
81
- if (
82
- this.designState
83
- || !options.dynamicSchemaEnabled
84
- || !getDynamicSchemaOption(options, "scriptCode")
85
- || !this.supportsRowLayout()
86
- ) {
166
+ if (!getDynamicSchemaOption(options, "scriptCode")) {
87
167
  return Promise.resolve();
88
168
  }
89
169
  const requestData = buildDynamicSchemaRequestData(
@@ -50,6 +50,9 @@ export const DYNAMIC_SCHEMA_OPTION_KEYS = {
50
50
  scriptParam: ["dynamicSchemaScriptParam", "dynamicColumnScriptParam"],
51
51
  convert: ["dynamicSchemaConvert"],
52
52
  mode: ["dynamicSchemaMode", "dynamicColumnMode"],
53
+ sourceType: ["dynamicSchemaSourceType", "dynamicColumnSourceType"],
54
+ loadScript: ["dynamicSchemaLoadScript", "dynamicColumnLoadScript"],
55
+ frontendScript: ["dynamicSchemaScript", "dynamicColumnsScript"],
53
56
  };
54
57
 
55
58
  export const widgetTypeToEditFormatMap = {
@@ -90,6 +90,76 @@
90
90
  <el-input v-model="formData.remark" clearable />
91
91
  </template>
92
92
  </vxe-form-item>
93
+ <vxe-form-item :title="$t1('创建人') + ':'">
94
+ <template v-slot>
95
+ <el-input
96
+ v-model="formData.createBy"
97
+ size="small"
98
+ clearable
99
+ />
100
+ </template>
101
+ </vxe-form-item>
102
+ <vxe-form-item :title="$t1('更新人') + ':'">
103
+ <template v-slot>
104
+ <el-input
105
+ v-model="formData.modifyBy"
106
+ size="small"
107
+ clearable
108
+ />
109
+ </template>
110
+ </vxe-form-item>
111
+ <vxe-form-item title="创建时间:">
112
+ <template v-slot>
113
+ <el-date-picker
114
+ v-model="formData.startCreateDate"
115
+ type="datetime"
116
+ placeholder=""
117
+ size="small"
118
+ clearable
119
+ value-format="yyyy-MM-dd HH:mm:ss"
120
+ :picker-options="$baseStartPickerOptions(formData.endCreateDate)"
121
+ ></el-date-picker>
122
+ <span>-</span>
123
+ <el-date-picker
124
+ v-model="formData.endCreateDate"
125
+ type="datetime"
126
+ placeholder=""
127
+ size="small"
128
+ clearable
129
+ value-format="yyyy-MM-dd HH:mm:ss"
130
+ default-time="23:59:59"
131
+ :picker-options="
132
+ $baseEndPickerOptions(formData.startCreateDate)
133
+ "
134
+ ></el-date-picker>
135
+ </template>
136
+ </vxe-form-item>
137
+ <vxe-form-item title="更新时间:">
138
+ <template v-slot>
139
+ <el-date-picker
140
+ v-model="formData.startModifyDate"
141
+ type="datetime"
142
+ placeholder=""
143
+ size="small"
144
+ clearable
145
+ value-format="yyyy-MM-dd HH:mm:ss"
146
+ :picker-options="$baseStartPickerOptions(formData.endModifyDate)"
147
+ ></el-date-picker>
148
+ <span>-</span>
149
+ <el-date-picker
150
+ v-model="formData.endModifyDate"
151
+ type="datetime"
152
+ placeholder=""
153
+ size="small"
154
+ clearable
155
+ value-format="yyyy-MM-dd HH:mm:ss"
156
+ default-time="23:59:59"
157
+ :picker-options="
158
+ $baseEndPickerOptions(formData.startModifyDate)
159
+ "
160
+ ></el-date-picker>
161
+ </template>
162
+ </vxe-form-item>
93
163
  </vxe-form>
94
164
  </template>
95
165
  </vxe-grid>
@@ -135,10 +205,13 @@ export default {
135
205
  components: {
136
206
  formDesignerDialog: () =>
137
207
  import("@base/views/bd/setting/form_template/formDesignerDialog.vue"),
138
- compareDialog: () => import("@base/views/bd/setting/formVersion/compareDialog.vue"),
139
- FormTemplateEdit: () => import("@base/views/bd/setting/form_template/edit.vue"),
208
+ compareDialog: () =>
209
+ import("@base/views/bd/setting/formVersion/compareDialog.vue"),
210
+ FormTemplateEdit: () =>
211
+ import("@base/views/bd/setting/form_template/edit.vue"),
140
212
  FormScriptEdit: () => import("@base/views/bd/setting/form_script/edit.vue"),
141
- FormScriptEdit1: () => import("@base/views/bd/setting/form_script/edit1.vue"),
213
+ FormScriptEdit1: () =>
214
+ import("@base/views/bd/setting/form_script/edit1.vue"),
142
215
  SzTaMbEdit: () => import("@base/views/bd/setting/table_model/edit.vue"),
143
216
  },
144
217
  created() {
@@ -187,13 +260,14 @@ export default {
187
260
  },
188
261
  methods: {
189
262
  getCompareData(row1, row2, callback) {
190
- Promise.all([this.getFormVersion(row1.id), this.getFormVersion(row2.id)]).then(
191
- (res) => {
192
- let compareHData1 = res[0].objx;
193
- let compareHData2 = res[1].objx;
194
- callback && callback(compareHData1, compareHData2);
195
- }
196
- );
263
+ Promise.all([
264
+ this.getFormVersion(row1.id),
265
+ this.getFormVersion(row2.id),
266
+ ]).then((res) => {
267
+ let compareHData1 = res[0].objx;
268
+ let compareHData2 = res[1].objx;
269
+ callback && callback(compareHData1, compareHData2);
270
+ });
197
271
  },
198
272
  getFormVersion(id) {
199
273
  return this.$http({
@@ -284,7 +358,7 @@ export default {
284
358
  title: this.$t1("创建人"),
285
359
  field: "_createBy",
286
360
  width: 150,
287
- },
361
+ },
288
362
  {
289
363
  title: this.$t1("创建时间"),
290
364
  field: "createDate",