cloud-web-corejs 1.1.0-dev.75 → 1.1.0-dev.77
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/package.json +1 -1
- package/src/components/xform/docs//345/270/270/347/224/250/350/204/232/346/234/254/350/260/203/347/224/250.md +227 -0
- package/src/components/xform/docs//347/272/247/350/201/224/351/200/211/346/213/251/346/207/222/345/212/240/350/275/275/344/275/277/347/224/250/350/257/264/346/230/216.md +177 -0
- package/src/components/xform/form-designer/form-widget/field-widget/cascader-widget.vue +195 -2
- package/src/components/xform/form-designer/form-widget/field-widget/vabUpload2-widget.vue +149 -31
- package/src/components/xform/form-designer/setting-panel/indexMixin.js +21 -1
- package/src/components/xform/form-designer/setting-panel/property-editor/event-handler/onClear-editor.vue +30 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/field-cascader/cascader-lazy-editor.vue +74 -12
- package/src/components/xform/form-designer/setting-panel/propertyRegister.js +1 -0
- package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +7 -2
package/package.json
CHANGED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# 常用脚本调用
|
|
2
|
+
|
|
3
|
+
表单事件里 `this` 是当前表单,方法直接写在 `this` 上。按钮点击脚本里 `this` 是按钮,取表单用 `this.getFormRef()`。下面按按钮脚本来写;写在表单事件里时,把 `this.getFormRef()` 换成 `this`。
|
|
4
|
+
|
|
5
|
+
按钮脚本可以直接用注入的 `dataId`、`formCode`。表格行内按钮另外有 `row`、`rowIndex`。
|
|
6
|
+
|
|
7
|
+
## 读写字段
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
let formRef = this.getFormRef();
|
|
11
|
+
|
|
12
|
+
formRef.getFieldValue("字段名");
|
|
13
|
+
formRef.setFieldValue("字段名", "值");
|
|
14
|
+
|
|
15
|
+
// 当前表单整单数据,和 formDataModel 是同一个对象
|
|
16
|
+
let formData = formRef.formModel;
|
|
17
|
+
|
|
18
|
+
// 按提交结构取出的数据(含子表)
|
|
19
|
+
let submitData = formRef.getRealFormData();
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`formModel` 是正在编辑的对象。业务里如果会改这份数据,先拷一份再处理。
|
|
23
|
+
|
|
24
|
+
## 必填校验
|
|
25
|
+
|
|
26
|
+
```javascript
|
|
27
|
+
let formRef = this.getFormRef();
|
|
28
|
+
|
|
29
|
+
formRef.validateForm((valid) => {
|
|
30
|
+
if (!valid) return;
|
|
31
|
+
let formData = formRef.formModel;
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
校验不通过时会自己提示,回调里的 `valid` 为 `false`。
|
|
36
|
+
|
|
37
|
+
## 保存
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
this.saveDefaultHandle();
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
不要默认的「您确定要保存吗?」,或保存成功后还要做事:
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
this.saveDefaultHandle({
|
|
47
|
+
config: {
|
|
48
|
+
isConfirm: false,
|
|
49
|
+
success: (res) => {
|
|
50
|
+
// res.objx 为保存后的单据 id
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
保存并提交流程:
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
this.saveAndSubmitWfHandle();
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## 调后台脚本
|
|
63
|
+
|
|
64
|
+
`scriptCode` 只写脚本编码时,走当前表单。写成 `表单编码/脚本编码` 时,调指定表单上的脚本。
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
this.formHttp({
|
|
68
|
+
scriptCode: "脚本编码",
|
|
69
|
+
data: this.getFormRef().getRealFormData(),
|
|
70
|
+
successMsg: true,
|
|
71
|
+
isConfirm: true,
|
|
72
|
+
confirmText: "您确定要执行吗?",
|
|
73
|
+
success: (res) => {
|
|
74
|
+
// res.objx
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 刷新
|
|
80
|
+
|
|
81
|
+
刷新当前页:
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
this.getFormRef().$baseReload();
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
保存或接口返回新单据 id 后,按新 id 重载表单:
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
this.getFormRef().reloadForm({
|
|
91
|
+
updateParam: {
|
|
92
|
+
_dataId: res.objx
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## 打开表单弹框
|
|
98
|
+
|
|
99
|
+
点击弹框默认「确定」后:先做必填校验,再在调用页执行业务,最后关闭弹框。
|
|
100
|
+
|
|
101
|
+
默认「确定」不会自己校验。`confirm` 不是返回 `false` 时,弹框会马上关闭。校验是异步的,所以这里固定返回 `false`,校验通过并且调用页业务执行完,再 `dialog.close()`。
|
|
102
|
+
|
|
103
|
+
目标模板如果配了 `formConfig.actionButtons`,底部就不再是这个默认「确定」,`confirm` 也不会被调用。
|
|
104
|
+
|
|
105
|
+
```javascript
|
|
106
|
+
this.getFormRef().openFormDialog({
|
|
107
|
+
formCode: "目标表单编码",
|
|
108
|
+
dialogConfig: {
|
|
109
|
+
title: "标题",
|
|
110
|
+
width: "1200px"
|
|
111
|
+
},
|
|
112
|
+
formConfig: {
|
|
113
|
+
dataId: null // 有值是编辑,null 是新增
|
|
114
|
+
},
|
|
115
|
+
confirm: (formRef, dialog) => {
|
|
116
|
+
formRef.validateForm((valid) => {
|
|
117
|
+
if (!valid) return;
|
|
118
|
+
|
|
119
|
+
let formData = formRef.formModel;
|
|
120
|
+
|
|
121
|
+
// 调用页业务逻辑,this 仍是打开弹框的按钮
|
|
122
|
+
// this.getFormRef().setFieldValue("字段名", formData.xxx);
|
|
123
|
+
|
|
124
|
+
dialog.close();
|
|
125
|
+
});
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
表单事件里打开时,把第一行换成 `this.openFormDialog`。`confirm` 里的 `this` 仍是调用页。
|
|
132
|
+
|
|
133
|
+
## 打开表单抽屉
|
|
134
|
+
|
|
135
|
+
抽屉的默认「确定」会先做必填校验,通过后把表单数据交给 `confirm`。取消或关闭时不会进 `confirm`。
|
|
136
|
+
|
|
137
|
+
业务要在抽屉关掉之前做完时,用 `beforeConfirm`。它返回的 Promise 被拒绝时,抽屉保持打开。
|
|
138
|
+
|
|
139
|
+
```javascript
|
|
140
|
+
this.getFormRef().openFormDrawer({
|
|
141
|
+
formCode: "目标表单编码",
|
|
142
|
+
dataId: null,
|
|
143
|
+
title: "标题",
|
|
144
|
+
beforeConfirm: (formData) => {
|
|
145
|
+
return this.formHttp({
|
|
146
|
+
scriptCode: "脚本编码",
|
|
147
|
+
data: formData,
|
|
148
|
+
successMsg: true
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## 打开选择弹框
|
|
155
|
+
|
|
156
|
+
`confirm` 的第一个参数是选中行。返回 `false` 时弹框不关闭。
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
this.getFormRef().openSearchDialog({
|
|
160
|
+
formCode: "选择表单编码",
|
|
161
|
+
multiple: false,
|
|
162
|
+
queryParam: {},
|
|
163
|
+
confirm: (rows) => {
|
|
164
|
+
if (!rows || !rows.length) return false;
|
|
165
|
+
let row = rows[0];
|
|
166
|
+
this.getFormRef().setFieldValue("字段名", row.id);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## 数据表格
|
|
172
|
+
|
|
173
|
+
```javascript
|
|
174
|
+
let table = this.getFormRef().getWidgetRef("表格字段名");
|
|
175
|
+
|
|
176
|
+
table.searchEvent();
|
|
177
|
+
table.addTableData([{ name: "新行" }]);
|
|
178
|
+
|
|
179
|
+
let grid = table.getGridTable();
|
|
180
|
+
let checkedRows = grid.getCheckboxRecords(true);
|
|
181
|
+
let allRows = grid.getTableData().fullData;
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
`getCheckboxRecords(true)` 取出跨页勾选的行。`addTableData` 的第二个参数是去重字段,例如 `table.addTableData(rows, "id")`。
|
|
185
|
+
|
|
186
|
+
`addTableData` 只用于普通表。树表(`isTreeTable: true`)新增走 `addTreeRows`,它会补临时节点身份,并把父字段写成根值。
|
|
187
|
+
|
|
188
|
+
```javascript
|
|
189
|
+
let table = this.getFormRef().getWidgetRef("表格字段名");
|
|
190
|
+
|
|
191
|
+
table.addTreeRows([{
|
|
192
|
+
f_attr_sid: this.$generateUUID()
|
|
193
|
+
}]);
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
要插到第一行时用 `table.addTopTreeRow({ f_attr_sid: this.$generateUUID() })`。
|
|
197
|
+
|
|
198
|
+
节点身份是 `treeConfig.rowField`(例如 `f_file_obj_id`)。新增时还没有正式编号,脚本里不要传这个字段,更不要写成 `0`。`0`、`"0"`、`null`、`""` 是根哨兵,只能出现在父字段(`parentField`,例如 `f_parent_file_obj_id`)上,表示没有父节点。写进节点身份会在入表时报「树节点 xxx 不能为空或根哨兵」。
|
|
199
|
+
|
|
200
|
+
`addTreeRows` 发现身份为空或是哨兵时,会生成 `row_时间戳_…` 临时键,并记到 `_X_TREE_TEMP_KEY`。父字段由方法写成 `rootParentValue`(默认 `0`)。表上开了 `serverGeneratesRowField` 时,提交会把临时键清成 `null`,正式编号由服务端回填。
|
|
201
|
+
|
|
202
|
+
手里已经有真实、唯一、且不是哨兵的节点身份时,可以传给 `addTreeRows`,方法会按正式身份保留。
|
|
203
|
+
|
|
204
|
+
## 显隐和禁用
|
|
205
|
+
|
|
206
|
+
参数可以是字段名,也可以是字段名数组。
|
|
207
|
+
|
|
208
|
+
```javascript
|
|
209
|
+
let formRef = this.getFormRef();
|
|
210
|
+
|
|
211
|
+
formRef.hideWidgets("字段名");
|
|
212
|
+
formRef.showWidgets(["字段甲", "字段乙"]);
|
|
213
|
+
formRef.disableWidgets("字段名");
|
|
214
|
+
formRef.enableWidgets("字段名");
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## 提示
|
|
218
|
+
|
|
219
|
+
```javascript
|
|
220
|
+
this.$baseConfirm("您确定要执行吗?").then(() => {
|
|
221
|
+
// 点确定
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
this.$baseAlert("处理完成");
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
带自定义按钮的消息框见 `消息框自定义按钮说明.md`。
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# 级联选择懒加载
|
|
2
|
+
|
|
3
|
+
级联选择开启懒加载后,展开每一级才请求下一级数据,走字段上的「请求访问」,脚本用 list,不走分页,也不走 condition。
|
|
4
|
+
|
|
5
|
+
未开启懒加载时,仍使用选项里配好的整棵树。
|
|
6
|
+
|
|
7
|
+
## 配置过程
|
|
8
|
+
|
|
9
|
+
在表单设计器里拖入「级联选择」,点中该组件,在右侧属性面板按下面的顺序配置。
|
|
10
|
+
|
|
11
|
+
### 1. 确定字段键名
|
|
12
|
+
|
|
13
|
+
请求里的 `taBm` 用的是这个字段本身。
|
|
14
|
+
|
|
15
|
+
- 要用数据属性名称时,打开「数据属性名称」,填写 `keyName`,例如 `cf_kehu2_item`。
|
|
16
|
+
- 不打开时,`taBm` 就是组件名。
|
|
17
|
+
|
|
18
|
+
### 2. 打开懒加载
|
|
19
|
+
|
|
20
|
+
在常用设置里打开「懒加载」。打开后下面出现三项:
|
|
21
|
+
|
|
22
|
+
1. **父级字段**
|
|
23
|
+
传到后台的参数名,和数据集里的父级字段一致。可以留空,留空时请求使用 `f_parent`。输入框里不会自动填上 `f_parent`。父级值取的是当前节点的「关联字段」,可以是 ID,也可以是编码。
|
|
24
|
+
2. **有子节点标识**
|
|
25
|
+
返回行里表示是否还有下级的字段。可以留空,留空时按 `f_has_child` 判断。`true`、`1` 可以继续展开,`false`、`0` 是末级。
|
|
26
|
+
3. **传参脚本**
|
|
27
|
+
需要把选中行上的其他字段一并传给后台时再写。点编辑图标,脚本签名是 `lazyParamScript(dataId, formCode, row)`。`row` 是当前选中行,第一次展开根节点时是 `null`。返回对象会并入 `data`。不写就只传父级字段。
|
|
28
|
+
|
|
29
|
+
这项不使用「请求访问设置」里的查询参数。查询参数保持原样,懒加载不会读它。
|
|
30
|
+
|
|
31
|
+
### 3. 打开请求访问
|
|
32
|
+
|
|
33
|
+
往下找到「请求访问设置」:
|
|
34
|
+
|
|
35
|
+
1. 打开「启用请求后台脚本」。不打开的话,懒加载不会按本文的 list 请求发数据。
|
|
36
|
+
2. 填写「表单脚本编码」。留空时使用 `getList`。脚本要返回数组,不要走分页,也不要走 condition。
|
|
37
|
+
3. 「请求去掉 data 层」默认不勾。勾上之后,父级参数会平铺到外层,不再包在 `data` 里。
|
|
38
|
+
4. 返回结果需要过滤时,再写「查询回调」。返回数组就用这份数组作为本级节点。
|
|
39
|
+
|
|
40
|
+
查询参数不用改。
|
|
41
|
+
|
|
42
|
+
### 4. 对齐返回列
|
|
43
|
+
|
|
44
|
+
启用请求后台脚本之后,选项设置里的「显示字段」「关联字段」才能改。
|
|
45
|
+
|
|
46
|
+
1. **显示字段**:节点上显示的文字,默认 `label`。改成数据集里的名称列,例如 `f_name`。
|
|
47
|
+
2. **关联字段**:选中后保存的值,也是下一级 `f_parent` 带上的值,默认 `value`。改成数据集里的主键或编码列,例如 `id` 或 `f_code`。
|
|
48
|
+
|
|
49
|
+
### 5. 保存并展开验证
|
|
50
|
+
|
|
51
|
+
保存表单后预览。第一次点开级联,请求体里父级值是 `null`。再点开某一行,父级值变成该行的关联字段值。有子节点标识为末级的行不再出现展开箭头。
|
|
52
|
+
|
|
53
|
+
## 选中回写
|
|
54
|
+
|
|
55
|
+
地区全称不入库,每次打开保持空白,不用在 `onMounted` 里回显。省、市、区、镇的名称和 ID 在选中时写入,清空时单独处理。
|
|
56
|
+
|
|
57
|
+
级联有 `onSelect`,只在用户选中时触发,清空不进这个事件。参数是 `value`、`oldValue`、`item`。`item.level` 是当前选到的级别:`0` 省、`1` 市、`2` 区、`3` 镇。各级 ID 在选中行的 `tree_path` 里,各级名称在 `tree_path_name` 里,都以英文逗号分隔。例如 `tree_path` 为 `44,4401,440106,440106001`,`tree_path_name` 为 `广东省,广州市,天河区,石牌街道`。
|
|
58
|
+
|
|
59
|
+
在地区全称 `a1` 的 `onSelect` 里按级别回写,没选到的级别写成空:
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
let level = item ? item.level : -1;
|
|
63
|
+
let data = item && item.data ? item.data : {};
|
|
64
|
+
let ids = data.tree_path ? String(data.tree_path).split(",") : [];
|
|
65
|
+
let names = data.tree_path_name ? String(data.tree_path_name).split(",") : [];
|
|
66
|
+
this.getWidgetRef("a2").setValue(level >= 0 ? names[0] || null : null);
|
|
67
|
+
this.getWidgetRef("a3").setValue(level >= 0 ? ids[0] || null : null);
|
|
68
|
+
this.getWidgetRef("a4").setValue(level >= 1 ? names[1] || null : null);
|
|
69
|
+
this.getWidgetRef("a5").setValue(level >= 1 ? ids[1] || null : null);
|
|
70
|
+
this.getWidgetRef("a6").setValue(level >= 2 ? names[2] || null : null);
|
|
71
|
+
this.getWidgetRef("a7").setValue(level >= 2 ? ids[2] || null : null);
|
|
72
|
+
this.getWidgetRef("a8").setValue(level >= 3 ? names[3] || null : null);
|
|
73
|
+
this.getWidgetRef("a9").setValue(level >= 3 ? ids[3] || null : null);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
某一级没有选到时,对应字段写成空。`a1` 不要开「数据属性名称」。
|
|
77
|
+
|
|
78
|
+
清空走 `onClear`,不进 `onSelect`。在 `a1` 的 `onClear` 里把省市区镇清空:
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
this.getWidgetRef("a2").setValue(null);
|
|
82
|
+
this.getWidgetRef("a3").setValue(null);
|
|
83
|
+
this.getWidgetRef("a4").setValue(null);
|
|
84
|
+
this.getWidgetRef("a5").setValue(null);
|
|
85
|
+
this.getWidgetRef("a6").setValue(null);
|
|
86
|
+
this.getWidgetRef("a7").setValue(null);
|
|
87
|
+
this.getWidgetRef("a8").setValue(null);
|
|
88
|
+
this.getWidgetRef("a9").setValue(null);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## 请求
|
|
92
|
+
|
|
93
|
+
脚本编码走地址 `/{服务名}/bd_api/{formCode}/{scriptCode}`,不放进 body。展开节点时的请求体是:
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
{
|
|
97
|
+
fixeData: {},
|
|
98
|
+
formCode: "kehu3_detail",
|
|
99
|
+
formVersion: 39,
|
|
100
|
+
taBm: "cf_kehu2_item",
|
|
101
|
+
data: {
|
|
102
|
+
f_parent: 64
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`fixeData` 由 `formHttp` 补上,来自当前报表的全局参数,没有时是 `{}`。`taBm` 是字段本身。`data` 里是父级参数和传参脚本返回的字段,没有 `current`、`size`、`condition`。请求访问里的查询参数不参与这次请求。
|
|
108
|
+
|
|
109
|
+
`f_parent` 的值取当前节点的「关联字段」。这一列可以是 ID,也可以是编码。根节点是 `null`。上面例子里关联字段的值是 `64`,所以 `f_parent` 就是 `64`。
|
|
110
|
+
|
|
111
|
+
传参脚本可以带上选中行的其他字段。父级字段仍以「父级字段」的配置为准。
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
// lazyParamScript(dataId, formCode, row)
|
|
115
|
+
// row 为当前选中行,根节点为 null
|
|
116
|
+
if (!row) return {};
|
|
117
|
+
return {
|
|
118
|
+
f_code: row.f_code,
|
|
119
|
+
f_name: row.f_name
|
|
120
|
+
};
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
展开编码 `A01`、同时带上该行 `f_code` 时,请求体是:
|
|
124
|
+
|
|
125
|
+
```js
|
|
126
|
+
{
|
|
127
|
+
fixeData: {},
|
|
128
|
+
formCode: "kehu3_detail",
|
|
129
|
+
formVersion: 39,
|
|
130
|
+
taBm: "cf_kehu2_item",
|
|
131
|
+
data: {
|
|
132
|
+
f_parent: 64,
|
|
133
|
+
f_code: "A01",
|
|
134
|
+
f_name: "华东"
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`node.level === 0` 是根节点。下一级时 `node.value` 就是当前节点的关联字段值,`row` 是这一行的原始数据。
|
|
140
|
+
|
|
141
|
+
## 返回
|
|
142
|
+
|
|
143
|
+
`objx` 必须是数组。每一行至少包含显示字段、关联字段,以及有子节点标识:
|
|
144
|
+
|
|
145
|
+
```js
|
|
146
|
+
[
|
|
147
|
+
{ label: "华东", value: "EAST", f_has_child: true },
|
|
148
|
+
{ label: "上海", value: "SH", f_has_child: false }
|
|
149
|
+
]
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`f_has_child` 为 true、1 时可以继续展开,为 false、0 时视为末级。字段名在「有子节点标识」里改。这一列没有值、但行上带了 `leaf` 时,仍按 `leaf` 判断。未标记的节点会一直显示展开箭头。
|
|
153
|
+
|
|
154
|
+
查询回调可以改本级数据,返回数组即可:
|
|
155
|
+
|
|
156
|
+
```js
|
|
157
|
+
// formScriptSuccess(dataId, formCode, res, rows)
|
|
158
|
+
return rows.filter(item => item.enabled !== false);
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## 保存与回显
|
|
162
|
+
|
|
163
|
+
选中值按各级关联字段组成数组保存,例如 `["EAST", "SH"]`。多选时是多条路径。
|
|
164
|
+
|
|
165
|
+
只读展示依赖已经加载过的节点名称。还没展开过的路径,只能显示原始值。
|
|
166
|
+
|
|
167
|
+
## 自定义请求
|
|
168
|
+
|
|
169
|
+
未启用「请求后台脚本」时,才走事件 `onLazyLoad(node, resolve)`。脚本里必须调用 `resolve(节点数组)`。末级节点同样按有子节点标识返回,默认字段名是 `f_has_child`。
|
|
170
|
+
|
|
171
|
+
启用了请求访问之后,不会再执行 `onLazyLoad`。
|
|
172
|
+
|
|
173
|
+
上级条件变化后需要重载时,取到级联组件再调用:
|
|
174
|
+
|
|
175
|
+
```js
|
|
176
|
+
this.getFormRef().getWidgetRef("级联字段名").reloadLazyNodes();
|
|
177
|
+
```
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
@focus="handleFocusCustomEvent"
|
|
33
33
|
@blur="handleBlurCustomEvent"
|
|
34
34
|
@clear="handleClearEvent"
|
|
35
|
-
@change="
|
|
35
|
+
@change="handleCascaderChange"
|
|
36
36
|
>
|
|
37
37
|
</el-cascader>
|
|
38
38
|
<template v-if="isReadMode">
|
|
@@ -88,6 +88,7 @@ export default {
|
|
|
88
88
|
lazyEmptyOptions: [],
|
|
89
89
|
lazyRenderKey: 0,
|
|
90
90
|
lazyLabelMap: {},
|
|
91
|
+
cascaderSyncing: false,
|
|
91
92
|
};
|
|
92
93
|
},
|
|
93
94
|
computed: {
|
|
@@ -209,6 +210,40 @@ export default {
|
|
|
209
210
|
this.lazyLabelMap = {};
|
|
210
211
|
this.lazyRenderKey += 1;
|
|
211
212
|
},
|
|
213
|
+
// 详情回显:用已有的各级 value/label 显示全称,不写入表单数据
|
|
214
|
+
initLazyChecked(levels) {
|
|
215
|
+
const path = [];
|
|
216
|
+
this.lazyLabelMap = {};
|
|
217
|
+
const list = Array.isArray(levels) ? levels : [];
|
|
218
|
+
for (let i = 0; i < list.length; i++) {
|
|
219
|
+
const item = list[i];
|
|
220
|
+
if (
|
|
221
|
+
!item ||
|
|
222
|
+
item.value === null ||
|
|
223
|
+
item.value === undefined ||
|
|
224
|
+
item.value === ""
|
|
225
|
+
) {
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
path.push(item.value);
|
|
229
|
+
this.$set(this.lazyLabelMap, this.lazyPathKey(path.slice()), {
|
|
230
|
+
path: path.slice(),
|
|
231
|
+
label: item.label == null ? "" : item.label,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
this.cascaderSyncing = true;
|
|
235
|
+
this.fieldModel = path.length ? path.slice() : null;
|
|
236
|
+
this.$nextTick(() => {
|
|
237
|
+
this.cascaderSyncing = false;
|
|
238
|
+
this.$nextTick(() => {
|
|
239
|
+
const editor = this.$refs.fieldEditor;
|
|
240
|
+
const text = this.resolveLazyDisplayValue(this.fieldModel);
|
|
241
|
+
if (!editor || !text || Array.isArray(text)) return;
|
|
242
|
+
editor.presentText = text;
|
|
243
|
+
editor.inputValue = text;
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
},
|
|
212
247
|
lazyPathKey(path) {
|
|
213
248
|
return JSON.stringify(path);
|
|
214
249
|
},
|
|
@@ -236,6 +271,11 @@ export default {
|
|
|
236
271
|
resolve([]);
|
|
237
272
|
return;
|
|
238
273
|
}
|
|
274
|
+
// 启用请求访问时,按级走表单脚本;否则才用 onLazyLoad 自定义请求
|
|
275
|
+
if (this.field.options.formScriptEnabled) {
|
|
276
|
+
this.loadLazyNodesByFormScript(node, resolve);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
239
279
|
const handler = this.field.options.onLazyLoad;
|
|
240
280
|
if (!handler) {
|
|
241
281
|
resolve([]);
|
|
@@ -245,7 +285,7 @@ export default {
|
|
|
245
285
|
const done = (list) => {
|
|
246
286
|
if (settled) return;
|
|
247
287
|
settled = true;
|
|
248
|
-
const nodes =
|
|
288
|
+
const nodes = this.normalizeLazyNodes(list);
|
|
249
289
|
this.rememberLazyNodes(node, nodes);
|
|
250
290
|
resolve(nodes);
|
|
251
291
|
};
|
|
@@ -255,6 +295,86 @@ export default {
|
|
|
255
295
|
done([]);
|
|
256
296
|
}
|
|
257
297
|
},
|
|
298
|
+
// 展开节点时复用「请求访问」的脚本编码。查询参数不参与懒加载
|
|
299
|
+
loadLazyNodesByFormScript(node, resolve) {
|
|
300
|
+
const formRef = this.getFormRef && this.getFormRef();
|
|
301
|
+
const reportTemplate = formRef && formRef.reportTemplate;
|
|
302
|
+
if (!reportTemplate) {
|
|
303
|
+
resolve([]);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const rowParam = this.resolveLazyRowParam(node);
|
|
307
|
+
let settled = false;
|
|
308
|
+
const done = (list) => {
|
|
309
|
+
if (settled) return;
|
|
310
|
+
settled = true;
|
|
311
|
+
const nodes = this.normalizeLazyNodes(list);
|
|
312
|
+
this.rememberLazyNodes(node, nodes);
|
|
313
|
+
resolve(nodes);
|
|
314
|
+
};
|
|
315
|
+
this.formHttp({
|
|
316
|
+
scriptCode: this.field.options.formScriptCode || "getList",
|
|
317
|
+
...this.getQueryConditionHttpOption(),
|
|
318
|
+
isLoading: false,
|
|
319
|
+
data: this.buildLazyFormScriptData(reportTemplate, node, rowParam),
|
|
320
|
+
callback: (res) => {
|
|
321
|
+
const objx = res.objx;
|
|
322
|
+
let rows = Array.isArray(objx) ? objx : [];
|
|
323
|
+
const handled = this.handleCustomEvent(
|
|
324
|
+
this.field.options.formScriptSuccess,
|
|
325
|
+
["res", "rows"],
|
|
326
|
+
[res, rows]
|
|
327
|
+
);
|
|
328
|
+
if (Array.isArray(handled)) rows = handled;
|
|
329
|
+
done(rows);
|
|
330
|
+
},
|
|
331
|
+
fail: () => done([]),
|
|
332
|
+
error: () => done([]),
|
|
333
|
+
});
|
|
334
|
+
},
|
|
335
|
+
// 传参脚本返回选中行上的其他字段。根节点没有选中行。
|
|
336
|
+
resolveLazyRowParam(node) {
|
|
337
|
+
const row = node && node.level > 0 ? node.data || null : null;
|
|
338
|
+
const rowParam = this.handleCustomEvent(
|
|
339
|
+
this.field.options.lazyParamScript,
|
|
340
|
+
["row"],
|
|
341
|
+
[row]
|
|
342
|
+
);
|
|
343
|
+
if (!rowParam || typeof rowParam !== "object" || Array.isArray(rowParam)) {
|
|
344
|
+
return {};
|
|
345
|
+
}
|
|
346
|
+
return rowParam;
|
|
347
|
+
},
|
|
348
|
+
// 未维护父级字段时用 f_parent,不把默认值写回配置
|
|
349
|
+
buildLazyFormScriptData(reportTemplate, node, rowParam) {
|
|
350
|
+
const parentField =
|
|
351
|
+
(this.field.options.parentKey || "f_parent").trim() || "f_parent";
|
|
352
|
+
const data = { ...(rowParam || {}) };
|
|
353
|
+
data[parentField] = node && node.level > 0 ? node.value : null;
|
|
354
|
+
return this.buildFormScriptData(reportTemplate, data);
|
|
355
|
+
},
|
|
356
|
+
normalizeLazyNodes(list) {
|
|
357
|
+
if (!Array.isArray(list)) return [];
|
|
358
|
+
const hasChildKey =
|
|
359
|
+
(this.field.options.hasChildKey || "f_has_child").trim() ||
|
|
360
|
+
"f_has_child";
|
|
361
|
+
return list.map((item) => {
|
|
362
|
+
if (!item || typeof item !== "object") return item;
|
|
363
|
+
const row = { ...item };
|
|
364
|
+
if (item[hasChildKey] != null && item[hasChildKey] !== "") {
|
|
365
|
+
row.leaf = !this.isHasChildFlag(item[hasChildKey]);
|
|
366
|
+
} else if (item.leaf != null) {
|
|
367
|
+
row.leaf = !!item.leaf;
|
|
368
|
+
}
|
|
369
|
+
return row;
|
|
370
|
+
});
|
|
371
|
+
},
|
|
372
|
+
isHasChildFlag(value) {
|
|
373
|
+
if (value === false || value === 0 || value === "0" || value === "false") {
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
return !!value;
|
|
377
|
+
},
|
|
258
378
|
resolveLazyDisplayValue(rawValue) {
|
|
259
379
|
if (!this.lazyLabelMap || !Object.keys(this.lazyLabelMap).length) {
|
|
260
380
|
return null;
|
|
@@ -359,6 +479,79 @@ export default {
|
|
|
359
479
|
}, 100);
|
|
360
480
|
},
|
|
361
481
|
|
|
482
|
+
// 脚本赋值不视为用户选中,避免回写省市区镇
|
|
483
|
+
setValue(value) {
|
|
484
|
+
this.cascaderSyncing = true;
|
|
485
|
+
fieldMixin.methods.setValue.call(this, value);
|
|
486
|
+
this.$nextTick(() => {
|
|
487
|
+
this.cascaderSyncing = false;
|
|
488
|
+
});
|
|
489
|
+
},
|
|
490
|
+
handleCascaderChange(value) {
|
|
491
|
+
const userAction = !this.cascaderSyncing;
|
|
492
|
+
const oldValue = this.oldFieldValue;
|
|
493
|
+
this.onFieldChangeEvent(value);
|
|
494
|
+
if (!userAction) return;
|
|
495
|
+
if (this.isEmptyCascaderValue(value)) {
|
|
496
|
+
this.fireOnClear();
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
this.fireOnSelect(value, oldValue);
|
|
500
|
+
},
|
|
501
|
+
isEmptyCascaderValue(value) {
|
|
502
|
+
if (value == null || value === "") return true;
|
|
503
|
+
return Array.isArray(value) && value.length === 0;
|
|
504
|
+
},
|
|
505
|
+
fireOnClear() {
|
|
506
|
+
if (!this.field.options.onClear) return;
|
|
507
|
+
const tableParam = this.tableParam;
|
|
508
|
+
this.handleCustomEvent(
|
|
509
|
+
this.field.options.onClear,
|
|
510
|
+
["rowData", "rowIndex"],
|
|
511
|
+
[
|
|
512
|
+
tableParam ? tableParam.row : null,
|
|
513
|
+
tableParam ? tableParam.rowIndex : null,
|
|
514
|
+
]
|
|
515
|
+
);
|
|
516
|
+
},
|
|
517
|
+
// 仅用户选中。item 为当前节点,多选为节点数组
|
|
518
|
+
fireOnSelect(value, oldValue) {
|
|
519
|
+
if (!this.field.options.onSelect) return;
|
|
520
|
+
const editor = this.$refs.fieldEditor;
|
|
521
|
+
const nodes =
|
|
522
|
+
editor && typeof editor.getCheckedNodes === "function"
|
|
523
|
+
? (editor.getCheckedNodes(false) || []).filter(Boolean)
|
|
524
|
+
: [];
|
|
525
|
+
const toItem = (node) => {
|
|
526
|
+
const path = node.path ? node.path.slice() : [];
|
|
527
|
+
return {
|
|
528
|
+
value: node.value,
|
|
529
|
+
label: node.label,
|
|
530
|
+
// 0 省、1 市、2 区、3 镇,对应当前选中节点
|
|
531
|
+
level: path.length ? path.length - 1 : 0,
|
|
532
|
+
path: path,
|
|
533
|
+
pathLabels: node.pathLabels ? node.pathLabels.slice() : [],
|
|
534
|
+
data: node.data || null,
|
|
535
|
+
};
|
|
536
|
+
};
|
|
537
|
+
const item = this.field.options.multiple
|
|
538
|
+
? nodes.map(toItem)
|
|
539
|
+
: nodes[0]
|
|
540
|
+
? toItem(nodes[0])
|
|
541
|
+
: null;
|
|
542
|
+
const tableParam = this.tableParam;
|
|
543
|
+
this.handleCustomEvent(
|
|
544
|
+
this.field.options.onSelect,
|
|
545
|
+
["value", "oldValue", "item", "rowData", "rowIndex"],
|
|
546
|
+
[
|
|
547
|
+
value,
|
|
548
|
+
oldValue,
|
|
549
|
+
item,
|
|
550
|
+
tableParam ? tableParam.row : null,
|
|
551
|
+
tableParam ? tableParam.rowIndex : null,
|
|
552
|
+
]
|
|
553
|
+
);
|
|
554
|
+
},
|
|
362
555
|
handleClearEvent() {
|
|
363
556
|
if (!!this.designState) {
|
|
364
557
|
//设计状态不触发事件
|
|
@@ -131,6 +131,8 @@ import fieldMixin from "../../../../../components/xform/form-designer/form-widge
|
|
|
131
131
|
import settingConfig from "@/settings.js";
|
|
132
132
|
|
|
133
133
|
const BATCH_UPLOAD_API = "/api/v1.0/FileOperation/BatchUploadFilesFromPortal";
|
|
134
|
+
/** 全部处理完显示 100 后,再停一会儿关闭加载。 */
|
|
135
|
+
const HX_UPLOAD_DONE_DELAY = 200;
|
|
134
136
|
|
|
135
137
|
function parseJsonValue(value) {
|
|
136
138
|
if (value == null || value === "") return null;
|
|
@@ -342,6 +344,7 @@ export default {
|
|
|
342
344
|
|
|
343
345
|
beforeDestroy() {
|
|
344
346
|
this.componentDestroyed = true;
|
|
347
|
+
this.closeHxUploadLoading();
|
|
345
348
|
this.revokeOwnedBlobUrls();
|
|
346
349
|
this.unregisterFromRefList();
|
|
347
350
|
},
|
|
@@ -644,14 +647,22 @@ export default {
|
|
|
644
647
|
}
|
|
645
648
|
target.clearFiles();
|
|
646
649
|
if (uploadUrl) {
|
|
650
|
+
let fileOrder = 0;
|
|
647
651
|
if (!isCustom) {
|
|
652
|
+
if (this.uploadingCount === 0) {
|
|
653
|
+
this.hxUploadTotal = 0;
|
|
654
|
+
this.openHxUploadLoading();
|
|
655
|
+
}
|
|
648
656
|
this.uploadingCount++;
|
|
657
|
+
this.hxUploadTotal++;
|
|
658
|
+
fileOrder = this.hxUploadTotal;
|
|
649
659
|
}
|
|
650
660
|
var abort;
|
|
651
661
|
|
|
652
662
|
let config = {
|
|
653
663
|
useToken: false,
|
|
654
|
-
isLoading
|
|
664
|
+
// 串行时每个请求单独 isLoading,上一个的延迟关闭会把后一个的遮罩关掉,中间空一截
|
|
665
|
+
isLoading: false,
|
|
655
666
|
headers: {
|
|
656
667
|
"Content-Type": "multipart/form-data",
|
|
657
668
|
Authorization: `Bearer ${this.token}`,
|
|
@@ -663,12 +674,14 @@ export default {
|
|
|
663
674
|
}
|
|
664
675
|
}), */
|
|
665
676
|
onUploadProgress: (progressEvent) => {
|
|
677
|
+
const percent = progressEvent.total
|
|
678
|
+
? Math.floor((progressEvent.loaded * 100) / progressEvent.total)
|
|
679
|
+
: 0;
|
|
666
680
|
if (isCustom || file) {
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
);
|
|
681
|
+
progressEvent.percent = percent;
|
|
682
|
+
}
|
|
683
|
+
if (!isCustom) {
|
|
684
|
+
this.setHxUploadProgress(fileOrder, percent);
|
|
672
685
|
}
|
|
673
686
|
},
|
|
674
687
|
failMsg: false,
|
|
@@ -678,36 +691,111 @@ export default {
|
|
|
678
691
|
config = extendDeeply(config, config.httpConfig);
|
|
679
692
|
}
|
|
680
693
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
694
|
+
this.enqueueHxUpload(() => {
|
|
695
|
+
if (this.componentDestroyed || !this.getFormRef()) {
|
|
696
|
+
this.finishHxUpload(!isCustom);
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
if (!isCustom) {
|
|
700
|
+
this.setHxUploadProgress(fileOrder, 0);
|
|
701
|
+
}
|
|
702
|
+
let batchDone = false;
|
|
703
|
+
return this.getFormRef()
|
|
704
|
+
.$http.post(uploadUrl, form, config)
|
|
705
|
+
.then((res1) => {
|
|
706
|
+
if (this.componentDestroyed) return;
|
|
707
|
+
const isLast = !isCustom && this.uploadingCount <= 1;
|
|
708
|
+
if (isLast) {
|
|
709
|
+
this.setHxUploadPercentText(99);
|
|
710
|
+
}
|
|
711
|
+
uploadConfig && uploadConfig.callback && uploadConfig.callback(res1, fileObj);
|
|
685
712
|
|
|
686
|
-
|
|
713
|
+
const adaptedResponse = this.responseAdapter(res1);
|
|
687
714
|
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
715
|
+
if (!isCustom) {
|
|
716
|
+
if (adaptedResponse.success) {
|
|
717
|
+
// this.initShowImageUrl(adaptedResponse.data)
|
|
718
|
+
if (adaptedResponse.data) {
|
|
719
|
+
let fileInfo = {
|
|
720
|
+
...adaptedResponse.data,
|
|
721
|
+
showUrl: null,
|
|
722
|
+
};
|
|
723
|
+
this.appendUploadedFile(fileInfo);
|
|
724
|
+
// this.initShowUrl();
|
|
725
|
+
}
|
|
726
|
+
batchDone = isLast;
|
|
727
|
+
} else {
|
|
728
|
+
if (isLast) {
|
|
729
|
+
this.closeHxUploadLoading();
|
|
730
|
+
}
|
|
731
|
+
// param.onError(new Error(res1.content || '上传异常'));
|
|
732
|
+
this.$baseAlert(adaptedResponse.message);
|
|
698
733
|
}
|
|
699
|
-
} else {
|
|
700
|
-
// param.onError(new Error(res1.content || '上传异常'));
|
|
701
|
-
this.$baseAlert(adaptedResponse.message);
|
|
702
734
|
}
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
735
|
+
})
|
|
736
|
+
.finally(() => {
|
|
737
|
+
return this.finishHxUpload(!isCustom, batchDone);
|
|
738
|
+
});
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
},
|
|
742
|
+
/**
|
|
743
|
+
* 同一控件内串行上传。上一次请求结束后立刻发下一次,
|
|
744
|
+
* 避免海信回写工单字段时后一次覆盖前一次。
|
|
745
|
+
*/
|
|
746
|
+
enqueueHxUpload(task) {
|
|
747
|
+
if (!this.hxUploadChain) {
|
|
748
|
+
this.hxUploadChain = Promise.resolve();
|
|
710
749
|
}
|
|
750
|
+
const scheduled = this.hxUploadChain.then(() => task());
|
|
751
|
+
this.hxUploadChain = scheduled.catch(() => {});
|
|
752
|
+
return scheduled;
|
|
753
|
+
},
|
|
754
|
+
openHxUploadLoading() {
|
|
755
|
+
if (this.hxUploadLoading) return;
|
|
756
|
+
this.hxUploadLoading = this.$baseLoading({
|
|
757
|
+
target: document.body,
|
|
758
|
+
background: "unset",
|
|
759
|
+
customClass: "hx-upload-loading",
|
|
760
|
+
text: "",
|
|
761
|
+
});
|
|
762
|
+
},
|
|
763
|
+
setHxUploadProgress(index, percent) {
|
|
764
|
+
if (!this.hxUploadLoading || typeof this.hxUploadLoading.setText !== "function") {
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
const total = this.hxUploadTotal || 1;
|
|
768
|
+
const safePercent = Number.isFinite(percent) ? Math.min(percent, 98) : 0;
|
|
769
|
+
const text = total > 1 ? `${index}/${total}` : `${safePercent}%`;
|
|
770
|
+
this.hxUploadLoading.setText(text);
|
|
771
|
+
},
|
|
772
|
+
setHxUploadPercentText(percent) {
|
|
773
|
+
if (!this.hxUploadLoading || typeof this.hxUploadLoading.setText !== "function") {
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
this.hxUploadLoading.setText(`${percent}%`);
|
|
777
|
+
},
|
|
778
|
+
closeHxUploadLoading() {
|
|
779
|
+
const loading = this.hxUploadLoading;
|
|
780
|
+
if (!loading) return;
|
|
781
|
+
this.hxUploadLoading = null;
|
|
782
|
+
loading.close();
|
|
783
|
+
},
|
|
784
|
+
finishHxUpload(counted, showDone) {
|
|
785
|
+
if (!counted) return;
|
|
786
|
+
this.uploadingCount = Math.max(0, this.uploadingCount - 1);
|
|
787
|
+
if (this.uploadingCount !== 0) return;
|
|
788
|
+
if (!showDone) {
|
|
789
|
+
this.closeHxUploadLoading();
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
this.setHxUploadPercentText(100);
|
|
793
|
+
return new Promise((resolve) => {
|
|
794
|
+
setTimeout(() => {
|
|
795
|
+
this.closeHxUploadLoading();
|
|
796
|
+
resolve();
|
|
797
|
+
}, HX_UPLOAD_DONE_DELAY);
|
|
798
|
+
});
|
|
711
799
|
},
|
|
712
800
|
handleUploadExceed(files) {
|
|
713
801
|
let limit = this.pickLimit || this.uploadLimit;
|
|
@@ -923,3 +1011,33 @@ export default {
|
|
|
923
1011
|
}
|
|
924
1012
|
}
|
|
925
1013
|
</style>
|
|
1014
|
+
|
|
1015
|
+
<style lang="scss">
|
|
1016
|
+
/* 进度写在转圈中间。全局 spinner 被 zoom:2 放大,这里单独收回来,避免文字掉到圈外。 */
|
|
1017
|
+
body .el-loading-mask.hx-upload-loading .el-loading-spinner {
|
|
1018
|
+
zoom: 1;
|
|
1019
|
+
margin-top: -42px;
|
|
1020
|
+
|
|
1021
|
+
.circular {
|
|
1022
|
+
width: 84px;
|
|
1023
|
+
height: 84px;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
.el-loading-text {
|
|
1027
|
+
zoom: 1;
|
|
1028
|
+
position: absolute;
|
|
1029
|
+
left: 50%;
|
|
1030
|
+
top: 42px;
|
|
1031
|
+
width: 52px;
|
|
1032
|
+
margin: 0;
|
|
1033
|
+
padding: 0;
|
|
1034
|
+
transform: translate(-50%, -50%);
|
|
1035
|
+
font-size: 14px;
|
|
1036
|
+
line-height: 1;
|
|
1037
|
+
text-align: center;
|
|
1038
|
+
white-space: nowrap;
|
|
1039
|
+
overflow: hidden;
|
|
1040
|
+
color: #409eff;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
</style>
|
|
@@ -241,9 +241,29 @@ modules = {
|
|
|
241
241
|
this.eventHandlerCode =
|
|
242
242
|
" /* sample code */\n /*\n if ((value > 100) || (value < 0)) {\n callback(new Error('error message')) //fail\n } else {\n callback(); //pass\n }\n */";
|
|
243
243
|
}
|
|
244
|
+
if (eventName === "lazyParamScript" && !this.optionModel["lazyParamScript"]) {
|
|
245
|
+
this.eventHandlerCode =
|
|
246
|
+
" /* row 为当前选中行,根节点为 null。返回对象会并入请求 data。 */\n" +
|
|
247
|
+
" if (!row) return {};\n" +
|
|
248
|
+
" return {\n" +
|
|
249
|
+
" f_code: row.f_code\n" +
|
|
250
|
+
" };";
|
|
251
|
+
}
|
|
252
|
+
if (
|
|
253
|
+
eventName === "onSelect" &&
|
|
254
|
+
selectedWidget &&
|
|
255
|
+
selectedWidget.type === "cascader" &&
|
|
256
|
+
!this.optionModel["onSelect"]
|
|
257
|
+
) {
|
|
258
|
+
this.eventHandlerCode =
|
|
259
|
+
" /* item 为选中节点。清空走 onClear,不会进这里。\n" +
|
|
260
|
+
" item.level:0 省、1 市、2 区、3 镇。\n" +
|
|
261
|
+
" item.data 为当前行,tree_path、tree_path_name 以英文逗号分隔。 */";
|
|
262
|
+
}
|
|
244
263
|
if (eventName === "onLazyLoad" && !this.optionModel["onLazyLoad"]) {
|
|
245
264
|
this.eventHandlerCode =
|
|
246
|
-
" /*
|
|
265
|
+
" /* 启用「请求访问」时不会走这里。\n" +
|
|
266
|
+
" node.level === 0 为根节点,否则 node.value 为父级。\n" +
|
|
247
267
|
" 末级节点设置 leaf: true。必须调用 resolve。\n" +
|
|
248
268
|
" 回显值须为各级 value 组成的数组。isLoading 请保持 false。 */\n" +
|
|
249
269
|
" var parentValue = node.level === 0 ? null : node.value;\n" +
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-form-item label="onClear" label-width="150px">
|
|
3
|
+
<a href="javascript:void(0);" class="a-link link-oneLind" @click="editEventHandler('onClear', eventParams)">
|
|
4
|
+
<span>{{ optionModel.onClear }}</span>
|
|
5
|
+
<i class="el-icon-edit"></i>
|
|
6
|
+
</a>
|
|
7
|
+
</el-form-item>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
import i18n from "../../../../../../components/xform/utils/i18n";
|
|
12
|
+
import eventMixin from "../../../../../../components/xform/form-designer/setting-panel/property-editor/event-handler/eventMixin";
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
name: "onClear-editor",
|
|
16
|
+
mixins: [i18n, eventMixin],
|
|
17
|
+
props: {
|
|
18
|
+
designer: Object,
|
|
19
|
+
selectedWidget: Object,
|
|
20
|
+
optionModel: Object,
|
|
21
|
+
},
|
|
22
|
+
data() {
|
|
23
|
+
return {
|
|
24
|
+
eventParams: ["dataId", "formCode", "rowData", "rowIndex"],
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<style scoped></style>
|
|
@@ -3,35 +3,97 @@
|
|
|
3
3
|
<el-form-item :label="i18nt('designer.setting.lazy')">
|
|
4
4
|
<el-switch v-model="optionModel.lazy"></el-switch>
|
|
5
5
|
</el-form-item>
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
<template v-if="optionModel.lazy">
|
|
7
|
+
<el-form-item class="form-item-label-top">
|
|
8
|
+
<span slot="label">
|
|
9
|
+
{{ $t1("父级字段") }}
|
|
10
|
+
<el-tooltip effect="light" placement="top">
|
|
11
|
+
<div slot="content" class="cascader-lazy-tip">
|
|
12
|
+
{{
|
|
13
|
+
$t1(
|
|
14
|
+
"按 list 请求下一级,不走分页。展开节点时,取该节点「关联字段」的值,以父级字段为参数名放入 data。父级字段默认 f_parent,值可能是 ID 或编码。有子节点标识默认 f_has_child,为 false 时视为末级。taBm 用字段本身。根节点值为 null。"
|
|
15
|
+
)
|
|
16
|
+
}}
|
|
17
|
+
</div>
|
|
18
|
+
<i class="el-icon-info cascader-lazy-tip-icon"></i>
|
|
19
|
+
</el-tooltip>
|
|
20
|
+
</span>
|
|
21
|
+
<el-input
|
|
22
|
+
v-model="parentKey"
|
|
23
|
+
clearable
|
|
24
|
+
:placeholder="$t1('默认 f_parent')"
|
|
25
|
+
></el-input>
|
|
26
|
+
</el-form-item>
|
|
27
|
+
<el-form-item :label="$t1('有子节点标识')" class="form-item-label-top">
|
|
28
|
+
<el-input
|
|
29
|
+
v-model="hasChildKey"
|
|
30
|
+
clearable
|
|
31
|
+
:placeholder="$t1('默认 f_has_child')"
|
|
32
|
+
></el-input>
|
|
33
|
+
</el-form-item>
|
|
34
|
+
<el-form-item :label="$t1('传参脚本')" class="form-item-label-top">
|
|
35
|
+
<a
|
|
36
|
+
href="javascript:void(0);"
|
|
37
|
+
class="a-link link-oneLind"
|
|
38
|
+
@click="editEventHandler('lazyParamScript', lazyParamEventParams)"
|
|
39
|
+
>
|
|
40
|
+
<span>{{ optionModel.lazyParamScript }}</span>
|
|
41
|
+
<i class="el-icon-edit"></i>
|
|
42
|
+
</a>
|
|
43
|
+
</el-form-item>
|
|
44
|
+
</template>
|
|
13
45
|
</div>
|
|
14
46
|
</template>
|
|
15
47
|
|
|
16
48
|
<script>
|
|
17
49
|
import i18n from "../../../../../../components/xform/utils/i18n";
|
|
50
|
+
import eventMixin from "../../../../../../components/xform/form-designer/setting-panel/property-editor/event-handler/eventMixin";
|
|
18
51
|
|
|
19
52
|
export default {
|
|
20
53
|
name: "cascader-lazy-editor",
|
|
21
|
-
mixins: [i18n],
|
|
54
|
+
mixins: [i18n, eventMixin],
|
|
22
55
|
props: {
|
|
23
56
|
designer: Object,
|
|
24
57
|
selectedWidget: Object,
|
|
25
58
|
optionModel: Object,
|
|
26
59
|
},
|
|
60
|
+
computed: {
|
|
61
|
+
parentKey: {
|
|
62
|
+
get() {
|
|
63
|
+
return this.optionModel.parentKey || "";
|
|
64
|
+
},
|
|
65
|
+
set(val) {
|
|
66
|
+
this.$set(this.optionModel, "parentKey", val == null ? "" : val);
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
hasChildKey: {
|
|
70
|
+
get() {
|
|
71
|
+
return this.optionModel.hasChildKey || "";
|
|
72
|
+
},
|
|
73
|
+
set(val) {
|
|
74
|
+
this.$set(this.optionModel, "hasChildKey", val == null ? "" : val);
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
lazyParamEventParams() {
|
|
78
|
+
return ["dataId", "formCode", "row"];
|
|
79
|
+
},
|
|
80
|
+
},
|
|
27
81
|
};
|
|
28
82
|
</script>
|
|
29
83
|
|
|
30
84
|
<style scoped>
|
|
31
|
-
.cascader-lazy-tip {
|
|
32
|
-
margin:
|
|
85
|
+
.cascader-lazy-tip-icon {
|
|
86
|
+
margin-left: 4px;
|
|
33
87
|
color: #909399;
|
|
34
|
-
|
|
35
|
-
|
|
88
|
+
cursor: pointer;
|
|
89
|
+
font-size: 14px;
|
|
90
|
+
vertical-align: middle;
|
|
91
|
+
}
|
|
92
|
+
</style>
|
|
93
|
+
|
|
94
|
+
<style>
|
|
95
|
+
.cascader-lazy-tip {
|
|
96
|
+
max-width: 320px;
|
|
97
|
+
line-height: 1.4;
|
|
36
98
|
}
|
|
37
99
|
</style>
|
|
@@ -254,6 +254,7 @@ const EVENT_PROPERTIES = {
|
|
|
254
254
|
onInput: "onInput-editor",
|
|
255
255
|
onChange: "onChange-editor",
|
|
256
256
|
onSelect: "onSelect-editor",
|
|
257
|
+
onClear: "onClear-editor",
|
|
257
258
|
onFocus: "onFocus-editor",
|
|
258
259
|
onBlur: "onBlur-editor",
|
|
259
260
|
onRemoteQuery: "onRemoteQuery-editor",
|
|
@@ -4058,7 +4058,10 @@ export const advancedFields = [
|
|
|
4058
4058
|
flatCollapseTags: false,
|
|
4059
4059
|
checkStrictly: false, //可选择任意一级选项,默认不开启
|
|
4060
4060
|
showAllLevels: true, //显示完整路径
|
|
4061
|
-
lazy: false,
|
|
4061
|
+
lazy: false, //展开节点时按级请求「请求访问」脚本,只走 list,不走分页
|
|
4062
|
+
parentKey: "", //未维护时请求仍用 f_parent,不回填到输入框
|
|
4063
|
+
hasChildKey: "", //未维护时用 f_has_child 判断是否有子节点,不回填到输入框
|
|
4064
|
+
lazyParamScript: "", //懒加载传参脚本,返回选中行的其他字段并入 data
|
|
4062
4065
|
dsEnabled: false, // 是否使用数据源数据
|
|
4063
4066
|
dsName: "", // 数据源名称
|
|
4064
4067
|
dataSetName: "", //数据集名称
|
|
@@ -4091,10 +4094,12 @@ export const advancedFields = [
|
|
|
4091
4094
|
onCreated: "",
|
|
4092
4095
|
onMounted: "",
|
|
4093
4096
|
onChange: "",
|
|
4097
|
+
onSelect: "", //用户选中时触发,item.level 为 0 省、1 市、2 区、3 镇
|
|
4098
|
+
onClear: "", //用户清空时触发,不走 onSelect
|
|
4094
4099
|
onFocus: "",
|
|
4095
4100
|
onBlur: "",
|
|
4096
4101
|
onValidate: "",
|
|
4097
|
-
onLazyLoad: "",
|
|
4102
|
+
onLazyLoad: "", //未启用请求访问时的自定义懒加载:onLazyLoad(node, resolve)
|
|
4098
4103
|
},
|
|
4099
4104
|
},
|
|
4100
4105
|
];
|