@steedos-widgets/amis-lib 1.3.7 → 1.3.9

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/index.cjs.js CHANGED
@@ -209,6 +209,217 @@ const amisRender = (root, schema, data = {}, env = {}, options) => {
209
209
  return amis.embed(root, schema, data, Object.assign(getEvn(router), env));
210
210
  };
211
211
 
212
+ /*
213
+ * @Author: 殷亮辉 yinlianghui@hotoa.com
214
+ * @Date: 2023-11-15 09:50:22
215
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
216
+ * @LastEditTime: 2023-11-16 18:38:21
217
+ */
218
+
219
+ /**
220
+ * @param {*} props
221
+ * @param {*} mode edit/new/readonly
222
+ */
223
+ function getFormFields$1(props, mode = "edit") {
224
+ return props.fields || [];
225
+ }
226
+
227
+ /**
228
+ * @param {*} props
229
+ * @param {*} mode edit/new/readonly
230
+ */
231
+ function getInputTableColumns(props) {
232
+ return props.fields.map(function(item){
233
+ return Object.assign({}, item, {
234
+ "type": "static"
235
+ });
236
+ }) || [];
237
+ }
238
+
239
+ /**
240
+ * @param {*} props
241
+ * @param {*} mode edit/new/readonly
242
+ */
243
+ function getForm(props, mode = "edit") {
244
+ let schema = {
245
+ "type": "form",
246
+ "title": "表单",
247
+ "body": getFormFields$1(props, mode)
248
+ };
249
+ if (mode === "edit") {
250
+ Object.assign(schema, {
251
+ "onEvent": {
252
+ "submit": {
253
+ "weight": 0,
254
+ "actions": [
255
+ {
256
+ "actionType": "setValue",
257
+ "args": {
258
+ "index": "${index}",
259
+ "value": {
260
+ "&": "$$"
261
+ }
262
+ },
263
+ "componentId": props.id
264
+ }
265
+ ]
266
+ }
267
+ }
268
+ });
269
+ }
270
+ else if (mode === "new") {
271
+ Object.assign(schema, {
272
+ "onEvent": {
273
+ "submit": {
274
+ "weight": 0,
275
+ "actions": [
276
+ {
277
+ "componentId": props.id,
278
+ "actionType": "addItem",
279
+ "args": {
280
+ "index": `\${${props.name}.length || 9000}`,//这里加9000是因为字段如果没放在form组件内,props.name.length拿不到值
281
+ "item": {
282
+ "&": "$$"
283
+ }
284
+ }
285
+ }
286
+ ]
287
+ }
288
+ }
289
+ });
290
+ }
291
+ return schema;
292
+ }
293
+
294
+ function getButtonNew(props) {
295
+ return {
296
+ "label": "新增",
297
+ "type": "button",
298
+ "icon": "fa fa-plus",
299
+ "onEvent": {
300
+ "click": {
301
+ "actions": [
302
+ {
303
+ "actionType": "dialog",
304
+ "dialog": {
305
+ "type": "dialog",
306
+ "title": "弹框标题",
307
+ "body": [
308
+ getForm(props, "new")
309
+ ],
310
+ "showCloseButton": true,
311
+ "showErrorMsg": true,
312
+ "showLoading": true,
313
+ "className": "app-popover",
314
+ "closeOnEsc": false
315
+ }
316
+ }
317
+ ]
318
+ }
319
+ },
320
+ "level": "primary"
321
+ };
322
+ }
323
+
324
+ function getButtonEdit(props) {
325
+ return {
326
+ "type": "button",
327
+ "label": "编辑",
328
+ "onEvent": {
329
+ "click": {
330
+ "actions": [
331
+ {
332
+ "actionType": "dialog",
333
+ "dialog": {
334
+ "type": "dialog",
335
+ "title": "弹框标题",
336
+ "body": [
337
+ getForm(props, "edit")
338
+ ],
339
+ "showCloseButton": true,
340
+ "showErrorMsg": true,
341
+ "showLoading": true,
342
+ "className": "app-popover",
343
+ "closeOnEsc": false
344
+ }
345
+ }
346
+ ]
347
+ }
348
+ }
349
+ };
350
+ }
351
+
352
+ function getButtonDelete(props) {
353
+ return {
354
+ "type": "button",
355
+ "label": "删除",
356
+ "onEvent": {
357
+ "click": {
358
+ "actions": [
359
+ {
360
+ "actionType": "deleteItem",
361
+ "args": {
362
+ "index": "${index+','}" //这里不加逗号后续会报错,语法是逗号分隔可以删除多行
363
+ },
364
+ "componentId": props.id
365
+ }
366
+ ]
367
+ }
368
+ }
369
+ };
370
+ }
371
+
372
+ const getAmisInputTableSchema = async (props, readonly) => {
373
+ if (!props.id) {
374
+ props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
375
+ }
376
+ let buttonNewSchema = getButtonNew(props);
377
+ let buttonEditSchema = getButtonEdit(props);
378
+ let buttonDeleteSchema = getButtonDelete(props);
379
+ let buttonsForColumnOperations = [];
380
+ if(props.editable){
381
+ buttonsForColumnOperations.push(buttonEditSchema);
382
+ }
383
+ if(props.removable){
384
+ buttonsForColumnOperations.push(buttonDeleteSchema);
385
+ }
386
+ let inputTableSchema = {
387
+ "type": "input-table",
388
+ "label": props.label,
389
+ "name": props.name,
390
+ "addable": props.addable,
391
+ "editable": props.editable,
392
+ // "removable": props.removable, //不可以removable设置为true,因为会在原生的操作列显示减号操作按钮,此开关实测只控制这个按钮显示不会影响删除功能
393
+ "draggable": props.draggable,
394
+ "showIndex": props.showIndex,
395
+ "perPage": props.perPage,
396
+ "id": props.id,
397
+ "columns": getInputTableColumns(props),
398
+ "needConfirm": false,
399
+ "strictMode": true,
400
+ "showTableAddBtn": false,
401
+ "showFooterAddBtn": false
402
+ };
403
+ if(buttonsForColumnOperations.length){
404
+ inputTableSchema.columns.push({
405
+ "name": "__op__",
406
+ "type": "static",
407
+ "body": buttonsForColumnOperations
408
+ });
409
+ }
410
+ let schema = {
411
+ "type": "wrapper",
412
+ "size": "none",
413
+ "body": [
414
+ inputTableSchema
415
+ ]
416
+ };
417
+ if(props.addable){
418
+ schema.body.push(buttonNewSchema);
419
+ }
420
+ return schema;
421
+ };
422
+
212
423
  /*
213
424
  * @Author: baozhoutao@steedos.com
214
425
  * @Date: 2022-07-04 11:24:28
@@ -938,6 +1149,7 @@ function getSaveDataTpl(fields){
938
1149
  delete formData.initialValues;
939
1150
  delete formData.editFormInited;
940
1151
  delete formData.isLookup;
1152
+ delete formData.selectedRowResponseResult;
941
1153
  ${getScriptForReadonlyFields(fields)}
942
1154
  ${getScriptForRemoveUrlPrefixForImgFields(fields)}
943
1155
  ${getScriptForSimplifiedValueForFileFields(fields)}
@@ -7840,7 +8052,7 @@ var config = {
7840
8052
  };
7841
8053
 
7842
8054
  async function getQuickEditSchema(field, options){
7843
- //判断在amis3.2以上环境下,放开批量编辑
8055
+ //判断在amis3.2以上环境下,放开批量编辑与lookup的单元格编辑
7844
8056
  let isAmisVersionforBatchEdit = false;
7845
8057
  if(window.amisRequire && window.amisRequire('amis')){
7846
8058
  isAmisVersionforBatchEdit = window.amisRequire('amis').version[0] >= 3 && window.amisRequire('amis').version[2] >= 2;
@@ -8241,6 +8453,10 @@ async function getQuickEditSchema(field, options){
8241
8453
  } else {
8242
8454
  quickEditSchema = false;
8243
8455
  }
8456
+ //amis3.2以下禁用lookup的单元格编辑
8457
+ if(field.type == "lookup" && !isAmisVersionforBatchEdit){
8458
+ quickEditSchema = false;
8459
+ }
8244
8460
  //TODO:附件多选时会覆盖老数据,暂时禁用
8245
8461
  if(field.type == "file" && field.multiple){
8246
8462
  quickEditSchema = false;
@@ -8271,9 +8487,9 @@ function getFieldWidth(width){
8271
8487
  async function getTableColumns(fields, options){
8272
8488
  const columns = [];
8273
8489
  if(!options.isLookup){
8274
- columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
8275
8490
  //将_display放入crud的columns中,可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
8276
8491
  columns.push({name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
8492
+ columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
8277
8493
  }
8278
8494
  const allowEdit = options.permissions?.allowEdit && !options.isLookup && options.enable_inline_edit != false;
8279
8495
 
@@ -8365,14 +8581,14 @@ async function getTableColumns(fields, options){
8365
8581
  }
8366
8582
  else {
8367
8583
  const tpl = await getFieldTpl(field, options);
8368
- let type = 'text';
8584
+ let type = 'static-text';
8369
8585
  if(tpl){
8370
8586
  type = 'static';
8371
8587
  }else if(field.type === 'html'){
8372
- type = 'markdown';
8588
+ type = 'static-markdown';
8373
8589
  }else if(field.type === 'url'){
8374
8590
  if(field.show_as_qr){
8375
- type = 'qr-code';
8591
+ type = 'static-qr-code';
8376
8592
  }else {
8377
8593
  type = 'input-url';
8378
8594
  }
@@ -9524,6 +9740,7 @@ function getSaveApi(object, recordId, fields, options){
9524
9740
  },
9525
9741
  adaptor: `
9526
9742
  if(payload.errors){
9743
+ delete payload.data;
9527
9744
  payload.status = 2;
9528
9745
  payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
9529
9746
  }
@@ -14802,6 +15019,7 @@ exports.executeButton = executeButton;
14802
15019
  exports.extendObject = extendObject;
14803
15020
  exports.fetchAPI = fetchAPI;
14804
15021
  exports.filtersToConditions = filtersToConditions;
15022
+ exports.getAmisInputTableSchema = getAmisInputTableSchema;
14805
15023
  exports.getApp = getApp;
14806
15024
  exports.getApps = getApps;
14807
15025
  exports.getAuthToken = getAuthToken;