@steedos-widgets/amis-lib 1.3.0-beta.11 → 1.3.0-beta.13

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.esm.js CHANGED
@@ -2165,257 +2165,92 @@ const getSchema$2 = (uiSchema) => {
2165
2165
  title: i18next.t('frontend_import_data'),
2166
2166
  body: [
2167
2167
  {
2168
- type: "form",
2169
- mode: "edit",
2170
- persistData: false,
2171
- promptPageLeave: true,
2172
- name: "form_edit_data_import",
2173
- debug: false,
2174
- title: "",
2175
- submitText: "",
2176
- api: {
2177
- method: "post",
2178
- url: "${context.rootUrl}/graphql",
2179
- data: {
2180
- objectName: "queue_import_history",
2181
- $: "$$",
2182
- },
2183
- requestAdaptor:
2184
- "\n const formData = api.data.$;\n for (key in formData){\n // image、select等字段清空值后保存的空字符串转换为null。\n if(formData[key] === ''){\n formData[key] = null;\n }\n }\n const objectName = api.data.objectName;\n const fieldsName = Object.keys(formData);\n delete formData.created;\n delete formData.created_by;\n delete formData.modified;\n delete formData.modified_by;\n delete formData._display;\n delete formData.success_count;\ndelete formData.failure_count;\ndelete formData.total_count;\ndelete formData.start_time;\ndelete formData.end_time;\ndelete formData.state;\ndelete formData.error;\ndelete formData.created;\ndelete formData.created_by;\ndelete formData.modified;\ndelete formData.modified_by;\n \n \n let fileFieldsKeys = [\"file\"];\n let fileFields = {\"file\":{\"name\":\"file\"}};\n fileFieldsKeys.forEach((item)=>{\n let fileFieldValue = formData[item];\n if(fileFieldValue){\n // 因为表单初始化接口的接收适配器中为file字段值重写了值及格式(为了字段编辑时正常显示附件名、点击附件名正常下载),所以保存时还原(为了字段值保存时正常保存id)。\n if(fileFields[item].multiple){\n if(fileFieldValue instanceof Array && fileFieldValue.length){\n formData[item] = fileFieldValue.map((value)=>{ \n if(typeof value === 'object'){\n return value.value;\n }else{\n return value;\n }\n });\n }\n }else{\n formData[item] = typeof fileFieldValue === 'object' ? fileFieldValue.value : fileFieldValue;\n }\n }\n })\n \n let query = `mutation{record: ${objectName}__insert(doc: {__saveData}){_id}}`;\n if(formData.recordId && formData.recordId !='new'){\n query = `mutation{record: ${objectName}__update(id: \"${formData._id}\", doc: {__saveData}){_id}}`;\n };\n delete formData._id;\n let __saveData = JSON.stringify(JSON.stringify(formData));\n \n api.data = {query: query.replace('{__saveData}', __saveData)};\n return api;\n ",
2185
- responseData: {
2186
- recordId: "${record._id}",
2187
- },
2188
- adaptor:
2189
- "console.log('payload', payload)\n return payload;\n ",
2190
- headers: {
2191
- Authorization:
2192
- "Bearer ${context.tenantId},${context.authToken}",
2193
- },
2194
- dataType: "json",
2168
+ "type": "steedos-object-form",
2169
+ "label": "对象表单",
2170
+ "objectApiName": "queue_import_history",
2171
+ "recordId": "",
2172
+ "mode": "edit",
2173
+ "layout": "normal",
2174
+ "defaultData":{
2175
+ "object_name": "${objectName}"
2195
2176
  },
2196
- initFetch: true,
2197
- body: [
2198
- {
2199
- type: "fieldSet",
2200
- title: i18next.t('frontend_field_group_generalization'),
2201
- collapsable: true,
2202
- body: [
2203
- {
2204
- name: "object_name",
2205
- label: i18next.t('frontend_import_data_object_name'),
2206
- required: false,
2207
- type: "select",
2208
- joinValues: false,
2209
- extractValue: true,
2210
- autoComplete: {
2211
- method: "post",
2212
- url: "${context.rootUrl}/graphql",
2213
- data: {
2214
- orderBy: "${orderBy}",
2215
- orderDir: "${orderDir}",
2216
- pageNo: "${page}",
2217
- pageSize: "${perPage}",
2218
- query:
2219
- "{options:objects(filters: {__filters}, top: {__top}){_id label:label value:name},count:objects__count(filters:{__filters})}",
2220
- $term: "$term",
2221
- $value: "$object_name.name",
2222
- $: "$$",
2223
- rfield: "${object_name}",
2224
- },
2225
- headers: {
2226
- Authorization:
2227
- "Bearer ${context.tenantId},${context.authToken}",
2228
- },
2229
- requestAdaptor:
2230
- "\n var filters = '[]';\n var top = 10;\n if(api.data.$term){\n filters = '[\"name\", \"contains\", \"'+ api.data.$term +'\"]';\n }else if(api.data.$value){\n filters = '[\"_id\", \"=\", \"'+ api.data.$value +'\"]';\n }\n api.data.query = api.data.query.replace(/{__filters}/g, filters).replace('{__top}', top);\n return api;\n ",
2231
- },
2232
- className: "m-1",
2233
- labelClassName: "text-left",
2234
- clearValueOnHidden: false,
2235
- id: "u:04295fee3896",
2236
- multiple: false,
2237
- hidden: true,
2238
- },
2239
- {
2240
- name: "queue_import",
2241
- label: i18next.t('frontend_import_data_queue_import'),
2242
- required: true,
2243
- type: "picker",
2244
- labelField: "description",
2245
- valueField: "_id",
2246
- modalMode: "dialog",
2247
- source: {
2248
- method: "post",
2249
- url: "${context.rootUrl}/graphql",
2250
- data: {
2251
- orderBy: "${orderBy}",
2252
- orderDir: "${orderDir}",
2253
- pageNo: "${page}",
2254
- pageSize: "${perPage}",
2255
- query:
2256
- '{rows:queue_import(filters: {__filters}, top: {__top}, skip: {__skip}, sort: "{__sort}"){_id,description,object_name,encoding,template_url,_display:_ui{object_name,encoding}},count:queue_import__count(filters:{__filters})}',
2257
- $term: "$term",
2258
- $self: "$$",
2177
+ "fieldsExtend":{
2178
+ "object_name": {
2179
+ "amis": {
2180
+ "hidden": true
2181
+ }
2182
+ }
2183
+ },
2184
+ "form": {
2185
+ debug: false,
2186
+ resetAfterSubmit: false,
2187
+ initApi: {
2188
+ url: '/api/v1/queue_import_history/${recordId}?fields=["state"]',
2189
+ sendOn: 'this.recordId',
2190
+ responseData: {
2191
+ importState: "${state}"
2192
+ }
2193
+ },
2194
+ interval: 3000,
2195
+ stopAutoRefreshWhen: "this.importState === 'finished'",
2196
+ initFetch: false,
2197
+ onEvent: {
2198
+ inited: {
2199
+ weight: 0,
2200
+ actions: [
2201
+ {
2202
+ "actionType": "broadcast",
2203
+ "args": {
2204
+ "eventName": `@data.changed.${uiSchema.name}`
2259
2205
  },
2260
- headers: {
2261
- Authorization:
2262
- "Bearer ${context.tenantId},${context.authToken}",
2206
+ "data": {
2207
+ "objectName": `${uiSchema.name}`,
2208
+ "displayAs": "${displayAs}",
2209
+ "recordId": "xxxx" //不可以省略,否则会进入进入记录详细页面
2263
2210
  },
2264
- requestAdaptor:
2265
- "\n const selfData = JSON.parse(JSON.stringify(api.data.$self));\n var filters = [];\n var pageSize = api.data.pageSize || 10;\n var pageNo = api.data.pageNo || 1;\n var skip = (pageNo - 1) * pageSize;\n var orderBy = api.data.orderBy || '';\n var orderDir = api.data.orderDir || '';\n var sort = orderBy + ' ' + orderDir;\n var allowSearchFields = [\"description\"];\n if(api.data.$term){\n filters = [[\"name\", \"contains\", \"'+ api.data.$term +'\"]];\n }else if(selfData.op === 'loadOptions' && selfData.value){\n if(selfData.value && selfData.value.indexOf(',') > 0){\n filters = [[\"_id\", \"=\", selfData.value.split(',')]];\n }else{\n filters = [[\"_id\", \"=\", selfData.value]];\n }\n }\n if(allowSearchFields){\n allowSearchFields.forEach(function(key){\n const keyValue = selfData[key];\n if(keyValue){\n filters.push([key, \"contains\", keyValue]);\n }\n })\n }\n\n const filtersFunction = function(filters, values){return ['object_name', '=', values.object_name]};\n\n if(filtersFunction){\n const _filters = filtersFunction(filters, api.data.$self.__super.__super);\n if(_filters && _filters.length > 0){\n filters.push(_filters);\n }\n }\n\n api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim());\n return api;\n ",
2266
- adaptor:
2267
- "\n const enable_tree = undefined;\n if(enable_tree){\n const records = payload.data.rows;\n const treeRecords = [];\n const getChildren = (records, childrenIds)=>{\n if(!childrenIds){\n return;\n }\n const children = _.filter(records, (record)=>{\n return _.includes(childrenIds, record._id)\n });\n _.each(children, (item)=>{\n if(item.children){\n item.children = getChildren(records, item.children)\n }\n })\n return children;\n }\n\n _.each(records, (record)=>{\n if(!record.parent){\n treeRecords.push(Object.assign({}, record, {children: getChildren(records, record.children)}));\n }\n });\n payload.data.rows = treeRecords;\n }\n return payload;\n ",
2211
+ "expression": "this.importState === 'finished'"
2268
2212
  },
2269
- size: "lg",
2270
- pickerSchema: {
2271
- mode: "table",
2272
- name: "thelist",
2273
- draggable: false,
2274
- headerToolbar: ["reload"],
2275
- defaultParams: {
2276
- perPage: 20,
2277
- },
2278
- columns: [
2279
- {
2280
- name: "_index",
2281
- type: "text",
2282
- width: 32,
2283
- placeholder: "",
2284
- },
2285
- {
2286
- name: "description",
2287
- label: i18next.t('frontend_import_data_queue_import_description'),
2288
- type: "tpl",
2289
- tpl: '<a href="/app/undefined/undefined/view/${undefined}">${description}</a>',
2290
- className: "whitespace-nowrap",
2291
- html: null,
2292
- },
2293
- {
2294
- name: "object_name",
2295
- label: i18next.t('frontend_import_data_object_name'),
2296
- type: "tpl",
2297
- tpl: '<a href="/app/undefined/${_display.object_name.objectName}/view/${_display.object_name.value}">${_display.object_name.label}</a>',
2298
- className: "whitespace-nowrap",
2299
- html: null,
2300
- },
2301
- {
2302
- name: "encoding",
2303
- label: i18next.t('frontend_import_data_queue_import_encoding'),
2304
- type: "tpl",
2305
- tpl: "<div>${_display.encoding}</div>",
2306
- className: "whitespace-nowrap",
2307
- html: null,
2308
- },
2309
- {
2310
- name: "template_url",
2311
- label: i18next.t('frontend_import_data_queue_import_template_url'),
2312
- type: "button-group",
2313
- buttons: [
2314
- {
2315
- type: "button",
2316
- label: i18next.t('frontend_download'),
2317
- visibleOn: "${template_url}",
2318
- level: "link",
2319
- actionType: "download",
2320
- api:{
2321
- url: "${template_url}",
2322
- method: "get",
2323
- headers: {
2324
- Authorization: "Bearer ${context.tenantId},${context.authToken}"
2325
- }
2326
- }
2327
- }
2328
- ],
2329
- options: {
2330
- html: true
2213
+ {
2214
+ "actionType": "closeDialog",
2215
+ "expression": "this.importState === 'finished'"
2216
+ }
2217
+ ]
2218
+ },
2219
+ submitSucc: {
2220
+ weight: 0,
2221
+ actions: [
2222
+ {
2223
+ args: {
2224
+ api: {
2225
+ url: "${context.rootUrl}/api/data/initiateImport",
2226
+ method: "post",
2227
+ data: {
2228
+ eventData: "${event.data}",
2229
+ },
2230
+ dataType: "json",
2231
+ requestAdaptor:
2232
+ "\napi.data = {\n importObjectHistoryId: api.body.eventData.result.data.recordId\n}\nreturn api;",
2233
+ adaptor:
2234
+ "payload.status = payload.status === 'success' ? 0 : payload.status;\nconsole.log(\"payload ssss==>\", payload)\nreturn payload;",
2235
+ headers: {
2236
+ Authorization:
2237
+ "Bearer ${context.tenantId},${context.authToken}",
2331
2238
  },
2332
- className: "whitespace-nowrap",
2333
- },
2334
- null,
2335
- ],
2336
- syncLocation: false,
2337
- keepItemSelectionOnPageChange: true,
2338
- checkOnItemClick: false,
2339
- autoFillHeight: false,
2340
- },
2341
- joinValues: false,
2342
- extractValue: true,
2343
- className: "m-1",
2344
- labelClassName: "text-left",
2345
- clearValueOnHidden: true,
2346
- id: "u:401df27113e0",
2347
- },
2348
- {
2349
- name: "file",
2350
- label: i18next.t('frontend_import_data_file'),
2351
- required: true,
2352
- type: "input-file",
2353
- accept: ".xlsx,.xls",
2354
- className: "m-1",
2355
- labelClassName: "text-left",
2356
- clearValueOnHidden: true,
2357
- useChunk: false,
2358
- receiver: {
2359
- method: "post",
2360
- url: "${context.rootUrl}/s3/files",
2361
- data: {
2362
- $: "$$",
2363
- context: "${context}",
2364
- },
2365
- adaptor:
2366
- '\n const { context } = api.body; \n var rootUrl = context.rootUrl + "/api/files/files/";\n payload = {\n status: response.status == 200 ? 0 : response.status,\n msg: response.statusText,\n data: {\n value: payload._id,\n name: payload.original.name,\n url: rootUrl + payload._id,\n }\n }\n return payload;\n ',
2367
- headers: {
2368
- Authorization:
2369
- "Bearer ${context.tenantId},${context.authToken}",
2370
- },
2371
- },
2372
- id: "u:0213f2cc365b",
2373
- },
2374
- ],
2375
- id: "u:4899c260d667",
2376
- },
2377
- ],
2378
- panelClassName: "m-0 sm:rounded-lg shadow-none",
2379
- bodyClassName: "p-0",
2380
- className: "p-4 sm:p-0 steedos-amis-form",
2381
- label: "对象表单",
2382
- objectApiName: "queue_import_history",
2383
- id: "u:e4ef598eed61",
2384
- onEvent: {
2385
- submitSucc: {
2386
- weight: 0,
2387
- actions: [
2388
- {
2389
- args: {
2390
- api: {
2391
- url: "${context.rootUrl}/api/data/initiateImport",
2392
- method: "post",
2393
- data: {
2394
- eventData: "${event.data}",
2395
2239
  },
2396
- dataType: "json",
2397
- requestAdaptor:
2398
- "\napi.data = {\n importObjectHistoryId: api.body.eventData.result.data.recordId\n}\nreturn api;",
2399
- adaptor:
2400
- "payload.status = payload.status === 'success' ? 0 : payload.status;\nconsole.log(\"payload ssss==>\", payload)\nreturn payload;",
2401
- headers: {
2402
- Authorization:
2403
- "Bearer ${context.tenantId},${context.authToken}",
2240
+ messages: {
2241
+ success: i18next.t('frontend_import_data_message_success'),
2242
+ failed: i18next.t('frontend_import_data_message_failed'),
2404
2243
  },
2405
2244
  },
2406
- messages: {
2407
- success: i18next.t('frontend_import_data_message_success'),
2408
- failed: i18next.t('frontend_import_data_message_failed'),
2409
- },
2245
+ actionType: "ajax",
2246
+ expression: "event.data.result",
2410
2247
  },
2411
- actionType: "ajax",
2412
- expression: "event.data.result",
2413
- },
2414
- ],
2248
+ ],
2249
+ },
2415
2250
  },
2416
- },
2417
- closeDialogOnSubmit: true,
2418
- },
2251
+ closeDialogOnSubmit: false,
2252
+ }
2253
+ }
2419
2254
  ],
2420
2255
  id: "u:dc05498d3bd4",
2421
2256
  closeOnEsc: false,
@@ -2605,7 +2440,7 @@ const StandardButtons = {
2605
2440
  getStandardImportData: async (uiSchema, ctx)=>{
2606
2441
  return {
2607
2442
  type: 'amis_button',
2608
- amis_schema: await getSchema$2()
2443
+ amis_schema: await getSchema$2(uiSchema)
2609
2444
  }
2610
2445
  },
2611
2446
  getStandardOpenView: async (uiSchema, ctx)=>{
@@ -2635,7 +2470,7 @@ function getButtonVisibleOn$1(button){
2635
2470
  visible = button._visible;
2636
2471
  }
2637
2472
 
2638
- if(___default.isBoolean(visible)){
2473
+ if(_$1.isBoolean(visible)){
2639
2474
  visible = visible.toString();
2640
2475
  }
2641
2476
 
@@ -2663,7 +2498,7 @@ function getButtonVisibleOn$1(button){
2663
2498
 
2664
2499
  const getButtonVisible = (button, ctx) => {
2665
2500
  if (button._visible) {
2666
- if (___default.startsWith(___default.trim(button._visible), "function")) {
2501
+ if (_$1.startsWith(_$1.trim(button._visible), "function")) {
2667
2502
  window.eval("var fun = " + button._visible);
2668
2503
  button.visible = fun;
2669
2504
  } else if (isExpression(button._visible)) {
@@ -2678,7 +2513,7 @@ const getButtonVisible = (button, ctx) => {
2678
2513
  };
2679
2514
  }
2680
2515
  }
2681
- if (___default.isFunction(button.visible)) {
2516
+ if (_$1.isFunction(button.visible)) {
2682
2517
  try {
2683
2518
  return button.visible(ctx);
2684
2519
  } catch (error) {
@@ -2700,7 +2535,7 @@ const standardButtonsTodo = {
2700
2535
  } = this;
2701
2536
  const listViewRef = SteedosUI?.getRef(scopeId || listViewId).getComponentById(`listview_${uiSchema.name}`);
2702
2537
 
2703
- if(___default.isEmpty(listViewRef.props.store.toJSON().selectedItems)){
2538
+ if(_$1.isEmpty(listViewRef.props.store.toJSON().selectedItems)){
2704
2539
  listViewRef.handleAction({}, {
2705
2540
  "actionType": "toast",
2706
2541
  "toast": {
@@ -2727,19 +2562,19 @@ const standardButtonsTodo = {
2727
2562
  */
2728
2563
  const getButtons = (uiSchema, ctx) => {
2729
2564
  const disabledButtons = uiSchema.permissions && uiSchema.permissions.disabled_actions;
2730
- let buttons = ___default.sortBy(___default.values(uiSchema.actions), "sort");
2731
- if (___default.has(uiSchema, "allow_customActions")) {
2732
- buttons = ___default.filter(buttons, (button) => {
2733
- return ___default.include(uiSchema.allow_customActions, button.name); // || _.include(_.keys(Creator.getObject('base').actions) || {}, button.name)
2565
+ let buttons = _$1.sortBy(_$1.values(uiSchema.actions), "sort");
2566
+ if (_$1.has(uiSchema, "allow_customActions")) {
2567
+ buttons = _$1.filter(buttons, (button) => {
2568
+ return _$1.include(uiSchema.allow_customActions, button.name); // || _.include(_.keys(Creator.getObject('base').actions) || {}, button.name)
2734
2569
  });
2735
2570
  }
2736
- if (___default.has(uiSchema, "exclude_actions")) {
2737
- buttons = ___default.filter(buttons, (button) => {
2738
- return !___default.include(uiSchema.exclude_actions, button.name);
2571
+ if (_$1.has(uiSchema, "exclude_actions")) {
2572
+ buttons = _$1.filter(buttons, (button) => {
2573
+ return !_$1.include(uiSchema.exclude_actions, button.name);
2739
2574
  });
2740
2575
  }
2741
2576
 
2742
- ___default.each(buttons, (button) => {
2577
+ _$1.each(buttons, (button) => {
2743
2578
  button.objectName = uiSchema.name;
2744
2579
  if (
2745
2580
  ctx.isMobile &&
@@ -2758,7 +2593,7 @@ const getButtons = (uiSchema, ctx) => {
2758
2593
  ctx.isMobile &&
2759
2594
  ["cms_files", "cfs.files.filerecord"].indexOf(uiSchema.name) > -1
2760
2595
  ) {
2761
- ___default.map(buttons, (button) => {
2596
+ _$1.map(buttons, (button) => {
2762
2597
  if (button.name === "standard_edit") {
2763
2598
  button.on = "record_more";
2764
2599
  }
@@ -2768,14 +2603,14 @@ const getButtons = (uiSchema, ctx) => {
2768
2603
  });
2769
2604
  }
2770
2605
 
2771
- return ___default.filter(buttons, (button) => {
2772
- return ___default.indexOf(disabledButtons, button.name) < 0 && button.name != 'standard_query';
2606
+ return _$1.filter(buttons, (button) => {
2607
+ return _$1.indexOf(disabledButtons, button.name) < 0 && button.name != 'standard_query';
2773
2608
  });
2774
2609
  };
2775
2610
 
2776
2611
  const getListViewButtons = (uiSchema, ctx) => {
2777
2612
  const buttons = getButtons(uiSchema, ctx);
2778
- const listButtons = ___default.filter(buttons, (button) => {
2613
+ const listButtons = _$1.filter(buttons, (button) => {
2779
2614
  return button.on == "list";
2780
2615
  });
2781
2616
  return listButtons;
@@ -2783,23 +2618,23 @@ const getListViewButtons = (uiSchema, ctx) => {
2783
2618
 
2784
2619
  const getObjectDetailButtons = (uiSchema, ctx) => {
2785
2620
  const buttons = getButtons(uiSchema, ctx);
2786
- const detailButtons = ___default.filter(buttons, (button) => {
2621
+ const detailButtons = _$1.filter(buttons, (button) => {
2787
2622
  return button.on == "record" || button.on == "record_only";
2788
2623
  });
2789
- return ___default.sortBy(detailButtons, "sort");
2624
+ return _$1.sortBy(detailButtons, "sort");
2790
2625
  };
2791
2626
 
2792
2627
  const getObjectDetailMoreButtons = (uiSchema, ctx) => {
2793
2628
  const buttons = getButtons(uiSchema, ctx);
2794
- const moreButtons = ___default.filter(buttons, (button) => {
2629
+ const moreButtons = _$1.filter(buttons, (button) => {
2795
2630
  return button.on == "record_more" || button.on == "record_only_more";
2796
2631
  });
2797
- return ___default.sortBy(moreButtons, "sort");
2632
+ return _$1.sortBy(moreButtons, "sort");
2798
2633
  };
2799
2634
 
2800
2635
  const getListViewItemButtons = async (uiSchema, ctx)=>{
2801
2636
  const buttons = getButtons(uiSchema, ctx);
2802
- const listButtons = ___default.filter(buttons, (button) => {
2637
+ const listButtons = _$1.filter(buttons, (button) => {
2803
2638
  return button.on == "record" || button.on == "list_item" || button.on === 'record_more';
2804
2639
  });
2805
2640
  return listButtons;
@@ -2816,7 +2651,7 @@ const getObjectRelatedListButtons = (uiSchema, ctx)=>{
2816
2651
  // });
2817
2652
  // return relatedListButtons;
2818
2653
  const buttons = getButtons(uiSchema, ctx);
2819
- const listButtons = ___default.filter(buttons, (button) => {
2654
+ const listButtons = _$1.filter(buttons, (button) => {
2820
2655
  return button.on == "list";
2821
2656
  });
2822
2657
  return listButtons;
@@ -2833,7 +2668,7 @@ const getButton = async (objectName, buttonName, ctx)=>{
2833
2668
  const uiSchema = await getUISchema(objectName);
2834
2669
  if(uiSchema){
2835
2670
  const buttons = await getButtons(uiSchema, ctx);
2836
- const button = ___default.find(buttons, (button)=>{
2671
+ const button = _$1.find(buttons, (button)=>{
2837
2672
  return button.name === buttonName
2838
2673
  });
2839
2674
 
@@ -2919,13 +2754,13 @@ const execute = (button, props) => {
2919
2754
  return; //TODO 弹出提示未配置todo
2920
2755
  }
2921
2756
 
2922
- if (___default.isString(button.todo)) {
2923
- if (___default.startsWith(___default.trim(button.todo), "function")) {
2757
+ if (_$1.isString(button.todo)) {
2758
+ if (_$1.startsWith(_$1.trim(button.todo), "function")) {
2924
2759
  window.eval("var fun = " + button.todo);
2925
2760
  button.todo = fun;
2926
2761
  }
2927
2762
  }
2928
- if (___default.isFunction(button.todo)) {
2763
+ if (_$1.isFunction(button.todo)) {
2929
2764
  const todoThis = {
2930
2765
  objectName: props.objectName,
2931
2766
  object_name: props.objectName,
@@ -2950,7 +2785,7 @@ const getObjectDetailHeaderButtons = (objectSchema, recordId)=>{
2950
2785
  recordId: recordId,
2951
2786
  objectName: name
2952
2787
  });
2953
- let amisButtonsSchema = ___default.map(buttons, (button) => {
2788
+ let amisButtonsSchema = _$1.map(buttons, (button) => {
2954
2789
  return {
2955
2790
  type: 'steedos-object-button',
2956
2791
  name: button.name,
@@ -2960,7 +2795,7 @@ const getObjectDetailHeaderButtons = (objectSchema, recordId)=>{
2960
2795
  }
2961
2796
  });
2962
2797
  let moreButtonsVisibleOn = '';
2963
- let dropdownButtons = ___default.map(moreButtons, (button, index) => {
2798
+ let dropdownButtons = _$1.map(moreButtons, (button, index) => {
2964
2799
  if(index === 0){
2965
2800
  moreButtonsVisibleOn = getButtonVisibleOn$1(button);
2966
2801
  }else {
@@ -3003,11 +2838,11 @@ const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
3003
2838
  "vertical": true,
3004
2839
  "tiled": true,
3005
2840
  "buttons": [
3006
- ...___default.map(buttons, (button)=>{
2841
+ ..._$1.map(buttons, (button)=>{
3007
2842
  button.className += ' w-full';
3008
2843
  return button;
3009
2844
  }),
3010
- ...___default.map(moreButtons, (button)=>{
2845
+ ..._$1.map(moreButtons, (button)=>{
3011
2846
  button.className += ' w-full';
3012
2847
  return button;
3013
2848
  })
@@ -3069,7 +2904,7 @@ const getObjectListViewButtonsSchemas = (objectSchema, ctx)=>{
3069
2904
  "vertical": true,
3070
2905
  "tiled": true,
3071
2906
  "buttons": [
3072
- ...___default.map(buttons, (button)=>{
2907
+ ..._$1.map(buttons, (button)=>{
3073
2908
  return {
3074
2909
  type: 'steedos-object-button',
3075
2910
  name: button.name,
@@ -3098,13 +2933,13 @@ const getObjectListViewButtonsSchemas = (objectSchema, ctx)=>{
3098
2933
  }
3099
2934
  }
3100
2935
  }else {
3101
- return ___default.map(buttons, (button) => {
2936
+ return _$1.map(buttons, (button) => {
3102
2937
  return {
3103
2938
  type: 'steedos-object-button',
3104
2939
  name: button.name,
3105
2940
  objectName: button.objectName,
3106
2941
  visibleOn: getButtonVisibleOn$1(button),
3107
- className: `button_${button.name} mr-0`
2942
+ className: `button_${button.name}`
3108
2943
  }
3109
2944
  });
3110
2945
  }
@@ -3131,7 +2966,7 @@ const getObjectRecordDetailRelatedListButtonsSchemas = (objectSchema, ctx)=>{
3131
2966
  "vertical": true,
3132
2967
  "tiled": true,
3133
2968
  "buttons": [
3134
- ...___default.map(buttons, (button)=>{
2969
+ ..._$1.map(buttons, (button)=>{
3135
2970
  return {
3136
2971
  type: 'steedos-object-button',
3137
2972
  name: button.name,
@@ -3160,7 +2995,7 @@ const getObjectRecordDetailRelatedListButtonsSchemas = (objectSchema, ctx)=>{
3160
2995
  }
3161
2996
  }
3162
2997
  }else {
3163
- return ___default.map(buttons, (button) => {
2998
+ return _$1.map(buttons, (button) => {
3164
2999
  return {
3165
3000
  type: 'steedos-object-button',
3166
3001
  name: button.name,
@@ -5245,6 +5080,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
5245
5080
 
5246
5081
  return {
5247
5082
  "type": "tooltip-wrapper",
5083
+ "id": "steedos_crud_toolbar_quick_search",
5248
5084
  "align": "right",
5249
5085
  "title": "",
5250
5086
  "content": "可搜索字段:" + searchableFieldsLabel.join(","),
@@ -5276,76 +5112,134 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
5276
5112
  if(isMobile){
5277
5113
  showDisplayAs = false;
5278
5114
  }
5115
+ let toolbarCount;
5116
+ if(!hiddenCount){
5117
+ toolbarCount = {
5118
+ "type": "tpl",
5119
+ "tpl": "${count} " + i18next.t('frontend_record_sum')
5120
+ };
5121
+ }
5122
+ let toolbarReloadButton;
5279
5123
  if(formFactor === 'SMALL'){
5280
- const onReloadScript = `
5281
- const scope = event.context.scoped;
5282
- var listView = scope.parent.getComponents().find(function(n){
5283
- return n.props.type === "crud";
5284
- });
5285
- listView.handleChangePage(1);
5286
- `;
5124
+ // const onReloadScript = `
5125
+ // const scope = event.context.scoped;
5126
+ // var listView = scope.parent.getComponents().find(function(n){
5127
+ // return n.props.type === "crud";
5128
+ // });
5129
+ // listView.handleChangePage(1);
5130
+ // `;
5131
+ // toolbarReloadButton = {
5132
+ // // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页,这在加载更多按钮的翻页模式下会有问题
5133
+ // "type": "button",
5134
+ // "align": "right",
5135
+ // //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
5136
+ // // "tooltip": i18next.t('frontend_button_reload_tooltip'),
5137
+ // "tooltipPlacement": "top",
5138
+ // "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
5139
+ // "label": "",
5140
+ // "icon": "fa fa-sync",
5141
+ // "visibleOn": "${!showFieldsFilter}",
5142
+ // "onEvent": {
5143
+ // "click": {
5144
+ // "actions": [
5145
+ // {
5146
+ // "actionType": "custom",
5147
+ // "script": onReloadScript
5148
+ // }
5149
+ // ]
5150
+ // }
5151
+ // },
5152
+ // };
5153
+
5154
+ // 后续如果换成加载更多按钮的翻页模式的话,不可以直接使用下面的reload,需要换成上面的自定义脚本模式
5155
+ toolbarReloadButton = {
5156
+ "type": "reload",
5157
+ "align": "right",
5158
+ //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
5159
+ // "tooltip": i18next.t('frontend_button_reload_tooltip'),
5160
+ "tooltip":"",
5161
+ "tooltipPlacement": "top",
5162
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
5163
+ };
5164
+ }
5165
+ else {
5166
+ toolbarReloadButton = {
5167
+ "type": "reload",
5168
+ "align": "right",
5169
+ //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
5170
+ // "tooltip": i18next.t('frontend_button_reload_tooltip'),
5171
+ "tooltip":"",
5172
+ "tooltipPlacement": "top",
5173
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
5174
+ };
5175
+ }
5176
+ let toolbarFilter;
5177
+ if(filterVisible){
5178
+ toolbarFilter ={
5179
+ "label": i18next.t('frontend_button_search_tooltip'),
5180
+ "icon": "fa fa-filter",
5181
+ //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
5182
+ // "tooltip": i18next.t('frontend_button_search_tooltip'),
5183
+ // "tooltipPlacement": "top",
5184
+ "type": "button",
5185
+ "badge": {
5186
+ "offset": [
5187
+ -5,
5188
+ 1
5189
+ ],
5190
+ "size":8,
5191
+ "animation": true,
5192
+ "visibleOn": "${isFieldsFilterEmpty == false && isLookup != true}"
5193
+ },
5194
+ "align": "right",
5195
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
5196
+ "onEvent": {
5197
+ "click": {
5198
+ "actions": [
5199
+ {
5200
+ "actionType": "custom",
5201
+ "script": onFieldsFilterToggleScript
5202
+ }
5203
+ ]
5204
+ }
5205
+ },
5206
+ "id": "steedos_crud_toolbar_filter"
5207
+ };
5208
+ }
5209
+ let toolbarDisplayAsButton = getDisplayAsButton(mainObject?.name);
5210
+ let toolbarDQuickSearchBox = getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup, keywordsSearchBoxName });
5211
+
5212
+ // toolbars返回的数组元素不可以是空对象{},比如hiddenCount ? {} : {"type": "tpl",...},因为空对象最终还是会生成一个空的.antd-Crud-toolbar-item dom
5213
+ // 当出现空的.antd-Crud-toolbar-item dom时会影响toolbar元素的maring-right css样式计算,如果有动态需要应该加到动态数组变量toolbars中
5214
+ let toolbars = [];
5215
+ if(formFactor === 'SMALL'){
5216
+ if(toolbarCount){
5217
+ toolbars.push(toolbarCount);
5218
+ }
5219
+ toolbars.push(toolbarReloadButton);
5220
+ if(toolbarFilter){
5221
+ toolbars.push(toolbarFilter);
5222
+ }
5223
+ toolbars.push(toolbarDisplayAsButton);
5224
+ toolbars.push(toolbarDQuickSearchBox);
5287
5225
  return [
5288
5226
  // "bulkActions",
5289
5227
  ...(headerToolbarItems || []),
5290
- hiddenCount ? {} :{
5291
- "type": "tpl",
5292
- "tpl": "${count} " + i18next.t('frontend_record_sum')
5293
- },
5294
- {
5295
- // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
5296
- "type": "button",
5297
- "align": "right",
5298
- //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
5299
- // "tooltip": i18next.t('frontend_button_reload_tooltip'),
5300
- "tooltipPlacement": "top",
5301
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
5302
- "label": "",
5303
- "icon": "fa fa-sync",
5304
- "visibleOn": "${!showFieldsFilter}",
5305
- "onEvent": {
5306
- "click": {
5307
- "actions": [
5308
- {
5309
- "actionType": "custom",
5310
- "script": onReloadScript
5311
- }
5312
- ]
5313
- }
5314
- },
5315
- },
5316
- filterVisible ? {
5317
- "label": i18next.t('frontend_button_search_tooltip'),
5318
- "icon": "fa fa-search",
5319
- "type": "button",
5320
- "tooltipPlacement": "top",
5321
- //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
5322
- // "tooltip": i18next.t('frontend_button_search_tooltip'),
5323
- "badge": {
5324
- "offset": [
5325
- -5,
5326
- 1
5327
- ],
5328
- "size":8,
5329
- "animation": true,
5330
- "visibleOn": "${isFieldsFilterEmpty == false && isLookup != true}"
5331
- },
5332
- "align": "right",
5333
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
5334
- "onEvent": {
5335
- "click": {
5336
- "actions": [
5337
- {
5338
- "actionType": "custom",
5339
- "script": onFieldsFilterToggleScript
5340
- }
5341
- ]
5342
- }
5343
- }
5344
- } : {},
5345
- getDisplayAsButton(mainObject?.name),
5346
- getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup, keywordsSearchBoxName })
5228
+ ...toolbars,
5347
5229
  ]
5348
5230
  }else {
5231
+ if(toolbarCount){
5232
+ toolbars.push(toolbarCount);
5233
+ }
5234
+ if(toolbarFilter){
5235
+ toolbars.push(toolbarFilter);
5236
+ }
5237
+ toolbars.push(toolbarReloadButton);
5238
+ if(mainObject?.permissions?.allowCreateListViews){
5239
+ toolbars.push(getSettingListviewToolbarButtonSchema());
5240
+ }
5241
+ toolbars.push(toolbarDisplayAsButton);
5242
+ toolbars.push(toolbarDQuickSearchBox);
5349
5243
  return [
5350
5244
  // "filter-toggler",
5351
5245
  ...(headerToolbarItems || []),
@@ -5354,56 +5248,12 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
5354
5248
  "type": "columns-toggler",
5355
5249
  "className": "hidden"
5356
5250
  },
5251
+ ...toolbars,
5357
5252
  // {
5358
5253
  // "type": "columns-toggler",
5359
5254
  // "className": "mr-2"
5360
5255
  // },
5361
- hiddenCount ? {} : {
5362
- "type": "tpl",
5363
- "tpl": "${count} " + i18next.t('frontend_record_sum')
5364
- },
5365
- filterVisible ? {
5366
- "label": i18next.t('frontend_button_search_tooltip'),
5367
- "icon": "fa fa-filter",
5368
- //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
5369
- // "tooltip": i18next.t('frontend_button_search_tooltip'),
5370
- // "tooltipPlacement": "top",
5371
- "type": "button",
5372
- "badge": {
5373
- "offset": [
5374
- -5,
5375
- 1
5376
- ],
5377
- "size":8,
5378
- "animation": true,
5379
- "visibleOn": "${isFieldsFilterEmpty == false && isLookup != true}"
5380
- },
5381
- "align": "right",
5382
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
5383
- "onEvent": {
5384
- "click": {
5385
- "actions": [
5386
- {
5387
- "actionType": "custom",
5388
- "script": onFieldsFilterToggleScript
5389
- }
5390
- ]
5391
- }
5392
- }
5393
- } : {},
5394
- {
5395
- "type": "reload",
5396
- "align": "right",
5397
- //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
5398
- // "tooltip": i18next.t('frontend_button_reload_tooltip'),
5399
- "tooltip":"",
5400
- "tooltipPlacement": "top",
5401
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
5402
- },
5403
5256
  // getExportExcelToolbarButtonSchema(),
5404
- mainObject?.permissions?.allowCreateListViews ? getSettingListviewToolbarButtonSchema() : {},
5405
- getDisplayAsButton(mainObject?.name),
5406
- getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup, keywordsSearchBoxName }),
5407
5257
  // {
5408
5258
  // "type": "drag-toggler",
5409
5259
  // "align": "right"
@@ -5697,12 +5547,11 @@ const getReferenceTo = async (field)=>{
5697
5547
  }
5698
5548
  };
5699
5549
 
5700
- function getLookupSapceUserTreeSchema(){
5701
- const tree = [{
5550
+ function getLookupSapceUserTreeSchema(isMobile){
5551
+ const treeSchema = {
5702
5552
  "type": "input-tree",
5703
- "className": "",
5553
+ "className":"steedos-select-user-tree",
5704
5554
  "inputClassName": "p-0",
5705
- "id": "u:7fd77b7915b0",
5706
5555
  "source": {
5707
5556
  "method": "post",
5708
5557
  "url": "${context.rootUrl}/graphql",
@@ -5733,6 +5582,10 @@ function getLookupSapceUserTreeSchema(){
5733
5582
  });
5734
5583
  listView.handleFilterSubmit(Object.assign({}, filterFormValues));
5735
5584
  `
5585
+ },
5586
+ {
5587
+ "actionType": "custom",
5588
+ "script": " if(window.innerWidth < 768){ document.querySelector('.steedos-select-user-sidebar').classList.remove('steedos-select-user-sidebar-open'); }"
5736
5589
  }
5737
5590
  ]
5738
5591
  }
@@ -5757,18 +5610,56 @@ function getLookupSapceUserTreeSchema(){
5757
5610
  "placeholder": "查找部门"
5758
5611
  },
5759
5612
  "unfoldedLevel": 2,
5760
- "style": {
5761
- "max-height": "100%",
5762
- "position": "absolute",
5763
- "left": "-330px",
5764
- "width": "320px",
5765
- "bottom": 0,
5766
- "top": "0",
5767
- "overflow": "auto",
5768
- "min-height":"300px"
5769
- },
5770
5613
  "originPosition": "left-top"
5771
- }];
5614
+ };
5615
+ const tree = [];
5616
+ if(isMobile){
5617
+ tree.push({
5618
+ type: "action",
5619
+ body:[
5620
+ {
5621
+ type: "action",
5622
+ body:[
5623
+ treeSchema
5624
+ ],
5625
+ className:"h-full w-[240px]"
5626
+ }
5627
+ ],
5628
+ className: "absolute inset-0 steedos-select-user-sidebar",
5629
+ "onEvent": {
5630
+ "click": {
5631
+ "actions": [
5632
+ {
5633
+ "actionType": "custom",
5634
+ "script": "document.querySelector('.steedos-select-user-sidebar').classList.remove('steedos-select-user-sidebar-open')"
5635
+ }
5636
+ ]
5637
+ }
5638
+ },
5639
+ id: "steedos_crud_toolbar_select_user_tree"
5640
+ });
5641
+ tree.push({
5642
+ "type": "button",
5643
+ "label": "组织",
5644
+ "icon": "fa fa-sitemap",
5645
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
5646
+ "align": "left",
5647
+ "onEvent": {
5648
+ "click": {
5649
+ "actions": [
5650
+ {
5651
+ "actionType": "custom",
5652
+ "script": "document.querySelector('.steedos-select-user-sidebar').classList.toggle('steedos-select-user-sidebar-open')"
5653
+ }
5654
+ ]
5655
+ }
5656
+ },
5657
+ "id": "steedos_crud_toolbar_organization_button"
5658
+ });
5659
+ }else {
5660
+ tree.push(treeSchema);
5661
+ }
5662
+
5772
5663
  return tree;
5773
5664
  }
5774
5665
 
@@ -6032,13 +5923,9 @@ async function lookupToAmisPicker(field, readonly, ctx){
6032
5923
  pickerSchema.affixHeader = false;
6033
5924
 
6034
5925
  var headerToolbarItems = [];
6035
- if(referenceTo.objectName === "space_users" && field.reference_to_field === "user" && !isMobile){
6036
- headerToolbarItems = getLookupSapceUserTreeSchema();
6037
- pickerSchema["style"] = {
6038
- "margin-left":"330px",
6039
- "min-height": "300px"
6040
- };
6041
- pickerSchema.className = pickerSchema.className || "" + " steedos-select-user";
5926
+ if(referenceTo.objectName === "space_users" && field.reference_to_field === "user"){
5927
+ headerToolbarItems = getLookupSapceUserTreeSchema(isMobile);
5928
+ pickerSchema.className = pickerSchema.className || "" + " steedos-select-user";
6042
5929
  }
6043
5930
 
6044
5931
  pickerSchema.headerToolbar = getObjectHeaderToolbar(refObjectConfig, fieldsArr, ctx.formFactor, { headerToolbarItems, isLookup: true, keywordsSearchBoxName });
@@ -6134,6 +6021,18 @@ async function lookupToAmisPicker(field, readonly, ctx){
6134
6021
  pickerSchema = Object.assign({}, pickerSchema, field.pickerSchema);
6135
6022
  }
6136
6023
 
6024
+ if(referenceTo.objectName === "space_users" && field.reference_to_field === "user" && isMobile){
6025
+ //手机端选人控件只保留部分toolbar
6026
+ pickerSchema.headerToolbar = pickerSchema.headerToolbar && pickerSchema.headerToolbar.filter(function(item){
6027
+ if(["steedos_crud_toolbar_quick_search","steedos_crud_toolbar_filter","steedos_crud_toolbar_select_user_tree","steedos_crud_toolbar_organization_button"].indexOf(item.id) > -1){
6028
+ return true;
6029
+ }else {
6030
+ return false;
6031
+ }
6032
+ });
6033
+ pickerSchema.footerToolbar = ["pagination"];
6034
+ }
6035
+
6137
6036
  const data = {
6138
6037
  type: getAmisStaticFieldType('picker', readonly),
6139
6038
  modalTitle: i18next.t('frontend_form_please_select') + " " + refObjectConfig.label,
@@ -6613,6 +6512,12 @@ const getHtmlFieldSchema = (field, readonly, ctx)=>{
6613
6512
  "receiver": "${context.rootUrl}/s3/images",
6614
6513
  "name": field.name,
6615
6514
  "options": {
6515
+ "menu": {
6516
+ "insert": {
6517
+ "title": "Insert",
6518
+ "items": "image link media addcomment pageembed codesample inserttable | charmap emoticons hr | pagebreak nonbreaking anchor tableofcontents | insertdatetime"
6519
+ }
6520
+ },
6616
6521
  "plugins": [
6617
6522
  "autoresize"
6618
6523
  ],
@@ -6627,6 +6532,14 @@ const getHtmlFieldSchema = (field, readonly, ctx)=>{
6627
6532
  return {
6628
6533
  "type": "input-rich-text",
6629
6534
  "receiver": "${context.rootUrl}/s3/images",
6535
+ "options":{
6536
+ "menu": {
6537
+ "insert": {
6538
+ "title": "Insert",
6539
+ "items": "image link media addcomment pageembed codesample inserttable | charmap emoticons hr | pagebreak nonbreaking anchor tableofcontents | insertdatetime"
6540
+ }
6541
+ }
6542
+ },
6630
6543
  "name": field.name
6631
6544
  }
6632
6545
  // return {
@@ -7400,7 +7313,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
7400
7313
  convertData.className = 'm-1';
7401
7314
  }
7402
7315
  if(readonly){
7403
- convertData.className = `${convertData.className} md:border-b`;
7316
+ convertData.className = `${convertData.className} border-b`;
7404
7317
  }
7405
7318
  if(readonly){
7406
7319
  convertData.quickEdit = false;
@@ -7870,7 +7783,10 @@ function getFieldWidth(width){
7870
7783
  }
7871
7784
 
7872
7785
  async function getTableColumns(fields, options){
7873
- const columns = [{name: '_index',type: 'text', width: 32, placeholder: ""}];
7786
+ const columns = [];
7787
+ if(!options.isLookup){
7788
+ columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
7789
+ }
7874
7790
  const allowEdit = options.permissions?.allowEdit && !options.isLookup && options.enable_inline_edit != false;
7875
7791
 
7876
7792
  for (const field of fields) {