@steedos-widgets/amis-lib 1.3.4-beta.20 → 1.3.4-beta.21
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/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/index.cjs.js +231 -93
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +231 -93
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +113 -20
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -7097,8 +7097,6 @@ function getSelectFieldOptions(field){
|
|
|
7097
7097
|
}
|
|
7098
7098
|
|
|
7099
7099
|
async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
7100
|
-
// console.log('convertSFieldToAmisField====>', field, readonly, ctx)
|
|
7101
|
-
const isMobile = window.innerWidth <= 768;
|
|
7102
7100
|
// 创建人和修改人、创建时间和修改时间不显示
|
|
7103
7101
|
if(___namespace.includes(OMIT_FIELDS, field.name) && ctx.showSystemFields != true){
|
|
7104
7102
|
return;
|
|
@@ -7187,26 +7185,33 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
7187
7185
|
};
|
|
7188
7186
|
break;
|
|
7189
7187
|
case 'date':
|
|
7190
|
-
convertData = isMobile && !readonly ? {
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
} : {
|
|
7188
|
+
// convertData = isMobile && !readonly ? {
|
|
7189
|
+
// type: "native-date",
|
|
7190
|
+
// pipeIn: (value, data) => {
|
|
7191
|
+
// if (value) {
|
|
7192
|
+
// value = moment(value).utc().format('YYYY-MM-DD');
|
|
7193
|
+
// return value;
|
|
7194
|
+
// } else {
|
|
7195
|
+
// return "";
|
|
7196
|
+
// }
|
|
7197
|
+
|
|
7198
|
+
// },
|
|
7199
|
+
// pipeOut: (value, oldValue, data) => {
|
|
7200
|
+
// if (value) {
|
|
7201
|
+
// value = moment(value).format('YYYY-MM-DDT00:00:00.000[Z]');
|
|
7202
|
+
// return value;
|
|
7203
|
+
// } else {
|
|
7204
|
+
// return "";
|
|
7205
|
+
// }
|
|
7206
|
+
// }
|
|
7207
|
+
// } : {
|
|
7208
|
+
// type: getAmisStaticFieldType('date', readonly),
|
|
7209
|
+
// inputFormat: "YYYY-MM-DD",
|
|
7210
|
+
// format:'YYYY-MM-DDT00:00:00.000[Z]',
|
|
7211
|
+
// tpl: readonly ? Tpl.getDateTpl(field) : null,
|
|
7212
|
+
// // utc: true
|
|
7213
|
+
// }
|
|
7214
|
+
convertData = {
|
|
7210
7215
|
type: getAmisStaticFieldType('date', readonly),
|
|
7211
7216
|
inputFormat: "YYYY-MM-DD",
|
|
7212
7217
|
format:'YYYY-MM-DDT00:00:00.000[Z]',
|
|
@@ -7225,43 +7230,51 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
7225
7230
|
};
|
|
7226
7231
|
break;
|
|
7227
7232
|
case 'datetime':
|
|
7228
|
-
convertData = isMobile && !readonly ? {
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
} : {
|
|
7233
|
+
// convertData = isMobile && !readonly ? {
|
|
7234
|
+
// type: "combo",
|
|
7235
|
+
// pipeIn: (value, data) => {
|
|
7236
|
+
// let revalue = {};
|
|
7237
|
+
// if (value && value != "Invalid date") {
|
|
7238
|
+
// value = moment(value).format('YYYY-MM-DD HH:mm:ss');
|
|
7239
|
+
// revalue[field.name + "-native-date"] = value.split(' ')[0];
|
|
7240
|
+
// revalue[field.name + "-native-time"] = value.split(' ')[1];
|
|
7241
|
+
// } else {
|
|
7242
|
+
// revalue[field.name + "-native-date"] = "";
|
|
7243
|
+
// revalue[field.name + "-native-time"] = "";
|
|
7244
|
+
// }
|
|
7245
|
+
// return revalue;
|
|
7246
|
+
// },
|
|
7247
|
+
// pipeOut: (value, oldValue, data) => {
|
|
7248
|
+
// let revalue = "";
|
|
7249
|
+
// if (value[field.name + "-native-date"] && value[field.name + "-native-time"]) {
|
|
7250
|
+
// revalue = value[field.name + "-native-date"] + " " + value[field.name + "-native-time"];
|
|
7251
|
+
// revalue = moment(revalue).utc().format('YYYY-MM-DDTHH:mm:ss.SSS[Z]');
|
|
7252
|
+
// }
|
|
7253
|
+
// return revalue;
|
|
7254
|
+
// },
|
|
7255
|
+
// items: [
|
|
7256
|
+
// {
|
|
7257
|
+
// type: "native-date",
|
|
7258
|
+
// name: field.name + "-native-date",
|
|
7259
|
+
// className: "steedos-native-date",
|
|
7260
|
+
// value: ""
|
|
7261
|
+
// },
|
|
7262
|
+
// {
|
|
7263
|
+
// type: "native-time",
|
|
7264
|
+
// name: field.name + "-native-time",
|
|
7265
|
+
// className: "steedos-native-time",
|
|
7266
|
+
// value: ""
|
|
7267
|
+
// }
|
|
7268
|
+
// ]
|
|
7269
|
+
// } : {
|
|
7270
|
+
// type: getAmisStaticFieldType('datetime', readonly),
|
|
7271
|
+
// inputFormat: 'YYYY-MM-DD HH:mm',
|
|
7272
|
+
// format: 'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
|
7273
|
+
// tpl: readonly ? Tpl.getDateTimeTpl(field) : null,
|
|
7274
|
+
// utc: true,
|
|
7275
|
+
// }
|
|
7276
|
+
|
|
7277
|
+
convertData = {
|
|
7265
7278
|
type: getAmisStaticFieldType('datetime', readonly),
|
|
7266
7279
|
inputFormat: 'YYYY-MM-DD HH:mm',
|
|
7267
7280
|
format: 'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
|
@@ -7281,26 +7294,34 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
7281
7294
|
};
|
|
7282
7295
|
break;
|
|
7283
7296
|
case 'time':
|
|
7284
|
-
convertData = isMobile && !readonly ? {
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
} : {
|
|
7297
|
+
// convertData = isMobile && !readonly ? {
|
|
7298
|
+
// type: "native-time",
|
|
7299
|
+
// pipeIn: (value, data) => {
|
|
7300
|
+
// if (value) {
|
|
7301
|
+
// value = moment(value).utc().format('HH:mm');
|
|
7302
|
+
// return value;
|
|
7303
|
+
// } else {
|
|
7304
|
+
// return "";
|
|
7305
|
+
// }
|
|
7306
|
+
|
|
7307
|
+
// },
|
|
7308
|
+
// pipeOut: (value, oldValue, data) => {
|
|
7309
|
+
// if (value) {
|
|
7310
|
+
// value = moment('1970-01-01 ' + value).format('1970-01-01THH:mm:00.000[Z]');
|
|
7311
|
+
// return value;
|
|
7312
|
+
// } else {
|
|
7313
|
+
// return "";
|
|
7314
|
+
// }
|
|
7315
|
+
// }
|
|
7316
|
+
// } : {
|
|
7317
|
+
// type: getAmisStaticFieldType('time', readonly),
|
|
7318
|
+
// inputFormat: 'HH:mm',
|
|
7319
|
+
// timeFormat:'HH:mm',
|
|
7320
|
+
// format:'1970-01-01THH:mm:00.000[Z]',
|
|
7321
|
+
// tpl: readonly ? Tpl.getDateTimeTpl(field) : null,
|
|
7322
|
+
// // utc: true
|
|
7323
|
+
// }
|
|
7324
|
+
convertData = {
|
|
7304
7325
|
type: getAmisStaticFieldType('time', readonly),
|
|
7305
7326
|
inputFormat: 'HH:mm',
|
|
7306
7327
|
timeFormat:'HH:mm',
|
|
@@ -7777,7 +7798,7 @@ var config = {
|
|
|
7777
7798
|
async function getQuickEditSchema(field, options){
|
|
7778
7799
|
//判断在amis3.2以上环境下,放开批量编辑
|
|
7779
7800
|
const isAmisVersionforBatchEdit = amisRequire('amis').version[0] >= 3 && amisRequire('amis').version[2] >= 2;
|
|
7780
|
-
const quickEditId = options.objectName + "_" + field.name + "
|
|
7801
|
+
const quickEditId = options.objectName + "_" + field.name + "_quickEdit";//定义快速编辑的表单id,用于setvalue传值
|
|
7781
7802
|
var quickEditSchema = { body: [], id: quickEditId };
|
|
7782
7803
|
//select,avatar,image,file等组件无法行记录字段赋值,暂不支持批量编辑;
|
|
7783
7804
|
if(field.type != 'avatar' && field.type != 'image' && field.type != 'file' && isAmisVersionforBatchEdit){
|
|
@@ -7787,19 +7808,16 @@ async function getQuickEditSchema(field, options){
|
|
|
7787
7808
|
{
|
|
7788
7809
|
actionType: "custom",
|
|
7789
7810
|
script: `
|
|
7790
|
-
|
|
7791
|
-
|
|
7811
|
+
let items = _.cloneDeep(event.data.items);
|
|
7812
|
+
let selectedItems = _.cloneDeep(event.data.selectedItems);
|
|
7792
7813
|
if(event.data.isBatchEdit){
|
|
7793
7814
|
selectedItems.forEach(function(selectedItem){
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
doAction({actionType: 'setValue', "args": {"value": {items}},componentId: "${options.crudId}","dataMergeMode": "override"});
|
|
7797
|
-
selectedItems.forEach(function(selectedItem){
|
|
7815
|
+
selectedItem._display.${field.name} = event.data._display.${field.name};
|
|
7816
|
+
doAction({actionType: 'setValue', "args": {"value": selectedItem._display},componentId: "_display_" + selectedItem._index});
|
|
7798
7817
|
doAction({actionType: 'setValue', "args": {"value": event.data.${field.name}},componentId: "${options.objectName + "_" + field.name + "_"}" + selectedItem._index});
|
|
7799
7818
|
})
|
|
7800
7819
|
}else{
|
|
7801
|
-
|
|
7802
|
-
doAction({actionType: 'setValue', "args": {"value": {items}},componentId: "${options.crudId}","dataMergeMode": "override"});
|
|
7820
|
+
doAction({actionType: 'setValue', "args": {"value": event.data._display},componentId: "_display_" + event.data._index});
|
|
7803
7821
|
doAction({actionType: 'setValue', "args": {"value": event.data.${field.name}},componentId: "${options.objectName + "_" + field.name + "_"}" + event.data._index});
|
|
7804
7822
|
}
|
|
7805
7823
|
`
|
|
@@ -7829,7 +7847,7 @@ async function getQuickEditSchema(field, options){
|
|
|
7829
7847
|
{
|
|
7830
7848
|
"actionType": "custom",
|
|
7831
7849
|
"script": `
|
|
7832
|
-
var _display = event.data._display;
|
|
7850
|
+
var _display = _.cloneDeep(event.data._display);
|
|
7833
7851
|
${displayField}
|
|
7834
7852
|
doAction({actionType: 'setValue', "args": {"value": {_display}},componentId: "${quickEditId}"});
|
|
7835
7853
|
`
|
|
@@ -7851,7 +7869,7 @@ async function getQuickEditSchema(field, options){
|
|
|
7851
7869
|
第二种是增加选项时,按照value的值,找到对应选项,并按照_display的规则为其赋值
|
|
7852
7870
|
*/
|
|
7853
7871
|
TempDisplayField = `
|
|
7854
|
-
const preData = event.data.__super.${field.name};
|
|
7872
|
+
const preData = _.cloneDeep(event.data.__super.${field.name});
|
|
7855
7873
|
if(preData && event.data.${field.name}.length < preData.length){
|
|
7856
7874
|
let deletedIndex;
|
|
7857
7875
|
preData.forEach(function(item,index){
|
|
@@ -8050,8 +8068,124 @@ async function getQuickEditSchema(field, options){
|
|
|
8050
8068
|
quickEditSchema.body.push({
|
|
8051
8069
|
"name": "isBatchEdit",
|
|
8052
8070
|
"type": "checkbox",
|
|
8053
|
-
"option":
|
|
8054
|
-
|
|
8071
|
+
"option": [
|
|
8072
|
+
{
|
|
8073
|
+
"type": "tpl",
|
|
8074
|
+
"tpl": "更新${COUNT(selectedItems)}个选定记录"
|
|
8075
|
+
},
|
|
8076
|
+
{
|
|
8077
|
+
"type": "spinner",
|
|
8078
|
+
"showOn": "${batchPermissionLoading}",
|
|
8079
|
+
"size": "sm",
|
|
8080
|
+
"className": "mr-4"
|
|
8081
|
+
}
|
|
8082
|
+
],
|
|
8083
|
+
"visibleOn": "${ARRAYSOME(selectedItems, item => item._id === _id) && COUNT(selectedItems)>1 && quickedit_record_permissions.allowEdit && quickedit_record_permissions_loading == false}",
|
|
8084
|
+
"disabledOn": "${batchPermissionLoading}",
|
|
8085
|
+
"onEvent":{
|
|
8086
|
+
"change":{
|
|
8087
|
+
"actions":[
|
|
8088
|
+
{
|
|
8089
|
+
"actionType": "setValue",
|
|
8090
|
+
"componentId": `service_listview_${options.objectName}`,
|
|
8091
|
+
"args": {
|
|
8092
|
+
"value":{
|
|
8093
|
+
"batchPermissionLoading": true
|
|
8094
|
+
}
|
|
8095
|
+
},
|
|
8096
|
+
"expression":"${event.data.value}"
|
|
8097
|
+
},
|
|
8098
|
+
{
|
|
8099
|
+
"actionType": "ajax",
|
|
8100
|
+
"args": {
|
|
8101
|
+
"api": {
|
|
8102
|
+
"url": "${context.rootUrl}/graphql",
|
|
8103
|
+
"method": "post",
|
|
8104
|
+
"headers": {
|
|
8105
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
8106
|
+
},
|
|
8107
|
+
"data": {
|
|
8108
|
+
"query": "{rows:${objectName}(filters:[\"_id\",\"in\",${selectedItems | pick:_id | split | json}]){_id,_permissions{allowEdit}}}"
|
|
8109
|
+
},
|
|
8110
|
+
"adaptor": `
|
|
8111
|
+
const noPermission = [];
|
|
8112
|
+
payload.data.rows.forEach(function (row) {
|
|
8113
|
+
if(!row._permissions.allowEdit){
|
|
8114
|
+
noPermission.push(row._id);
|
|
8115
|
+
}
|
|
8116
|
+
})
|
|
8117
|
+
return payload = {data:{noPermission}};
|
|
8118
|
+
`
|
|
8119
|
+
}
|
|
8120
|
+
},
|
|
8121
|
+
"expression":"${event.data.value}"
|
|
8122
|
+
},
|
|
8123
|
+
{
|
|
8124
|
+
"actionType": "setValue",
|
|
8125
|
+
"componentId": `service_listview_${options.objectName}`,
|
|
8126
|
+
"args": {
|
|
8127
|
+
"value":{
|
|
8128
|
+
"batchPermissionLoading": false
|
|
8129
|
+
}
|
|
8130
|
+
},
|
|
8131
|
+
"expression":"${event.data.value}"
|
|
8132
|
+
},
|
|
8133
|
+
{
|
|
8134
|
+
"actionType": "dialog",
|
|
8135
|
+
"dialog":{
|
|
8136
|
+
"title": "记录权限",
|
|
8137
|
+
"showCloseButton": false,
|
|
8138
|
+
"body":[
|
|
8139
|
+
{
|
|
8140
|
+
"type": "tpl",
|
|
8141
|
+
"tpl": "当前选中记录中,有${COUNT(noPermission)}条记录无编辑权限,是否需要批量编辑其他记录?"
|
|
8142
|
+
}
|
|
8143
|
+
],
|
|
8144
|
+
"onEvent":{
|
|
8145
|
+
"confirm":{
|
|
8146
|
+
"actions":[
|
|
8147
|
+
{
|
|
8148
|
+
"actionType": "custom",
|
|
8149
|
+
"script": `
|
|
8150
|
+
const noPermission = event.data.noPermission;
|
|
8151
|
+
const crudComponent = event.context.scoped.getComponentById("${options.crudId}");
|
|
8152
|
+
const selectedItems = crudComponent && crudComponent.props.store.selectedItems.concat();
|
|
8153
|
+
noPermission.forEach(function (item) {
|
|
8154
|
+
crudComponent && crudComponent.unSelectItem(_.find(selectedItems,{_id:item}));
|
|
8155
|
+
})
|
|
8156
|
+
`
|
|
8157
|
+
},
|
|
8158
|
+
{
|
|
8159
|
+
"actionType": "setValue",
|
|
8160
|
+
"componentId": quickEditId,
|
|
8161
|
+
"args": {
|
|
8162
|
+
"value":{
|
|
8163
|
+
"isBatchEdit": true
|
|
8164
|
+
}
|
|
8165
|
+
},
|
|
8166
|
+
}
|
|
8167
|
+
]
|
|
8168
|
+
},
|
|
8169
|
+
"cancel":{
|
|
8170
|
+
"actions":[
|
|
8171
|
+
{
|
|
8172
|
+
"actionType": "setValue",
|
|
8173
|
+
"componentId": quickEditId,
|
|
8174
|
+
"args": {
|
|
8175
|
+
"value":{
|
|
8176
|
+
"isBatchEdit": false
|
|
8177
|
+
}
|
|
8178
|
+
},
|
|
8179
|
+
}
|
|
8180
|
+
]
|
|
8181
|
+
}
|
|
8182
|
+
}
|
|
8183
|
+
},
|
|
8184
|
+
"expression":"${COUNT(event.data.noPermission)>0}"
|
|
8185
|
+
}
|
|
8186
|
+
]
|
|
8187
|
+
}
|
|
8188
|
+
}
|
|
8055
8189
|
});
|
|
8056
8190
|
}
|
|
8057
8191
|
} else {
|
|
@@ -8088,6 +8222,8 @@ async function getTableColumns(fields, options){
|
|
|
8088
8222
|
const columns = [];
|
|
8089
8223
|
if(!options.isLookup){
|
|
8090
8224
|
columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
|
|
8225
|
+
//将_display放入crud的columns中,可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
|
|
8226
|
+
columns.push({name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
|
|
8091
8227
|
}
|
|
8092
8228
|
const allowEdit = options.permissions?.allowEdit && !options.isLookup && options.enable_inline_edit != false;
|
|
8093
8229
|
|
|
@@ -10445,7 +10581,8 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
10445
10581
|
const quickSaveApiRequestAdaptor = `
|
|
10446
10582
|
var graphqlOrder = "";
|
|
10447
10583
|
var imageNames = ${JSON.stringify(imageNames)};
|
|
10448
|
-
api.data.rowsDiff
|
|
10584
|
+
const rowsDiff = _.cloneDeep(api.data.rowsDiff);
|
|
10585
|
+
rowsDiff.forEach(function (item, index) {
|
|
10449
10586
|
for(key in item){
|
|
10450
10587
|
if(_.includes(imageNames, key)){
|
|
10451
10588
|
if(typeof item[key] == "string"){
|
|
@@ -10459,6 +10596,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
10459
10596
|
}
|
|
10460
10597
|
}
|
|
10461
10598
|
}
|
|
10599
|
+
item = _.omit(item, '_display');
|
|
10462
10600
|
const itemOrder = 'update' + index + ':' + api.data.objectName + '__update(id:"' + item._id + '", doc:' + JSON.stringify(JSON.stringify(_.omit(item, '_id'))) + ') {_id}';
|
|
10463
10601
|
graphqlOrder += itemOrder;
|
|
10464
10602
|
})
|