@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.esm.js
CHANGED
|
@@ -7070,8 +7070,6 @@ function getSelectFieldOptions(field){
|
|
|
7070
7070
|
}
|
|
7071
7071
|
|
|
7072
7072
|
async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
7073
|
-
// console.log('convertSFieldToAmisField====>', field, readonly, ctx)
|
|
7074
|
-
const isMobile = window.innerWidth <= 768;
|
|
7075
7073
|
// 创建人和修改人、创建时间和修改时间不显示
|
|
7076
7074
|
if(_$1.includes(OMIT_FIELDS, field.name) && ctx.showSystemFields != true){
|
|
7077
7075
|
return;
|
|
@@ -7160,26 +7158,33 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
7160
7158
|
};
|
|
7161
7159
|
break;
|
|
7162
7160
|
case 'date':
|
|
7163
|
-
convertData = isMobile && !readonly ? {
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
} : {
|
|
7161
|
+
// convertData = isMobile && !readonly ? {
|
|
7162
|
+
// type: "native-date",
|
|
7163
|
+
// pipeIn: (value, data) => {
|
|
7164
|
+
// if (value) {
|
|
7165
|
+
// value = moment(value).utc().format('YYYY-MM-DD');
|
|
7166
|
+
// return value;
|
|
7167
|
+
// } else {
|
|
7168
|
+
// return "";
|
|
7169
|
+
// }
|
|
7170
|
+
|
|
7171
|
+
// },
|
|
7172
|
+
// pipeOut: (value, oldValue, data) => {
|
|
7173
|
+
// if (value) {
|
|
7174
|
+
// value = moment(value).format('YYYY-MM-DDT00:00:00.000[Z]');
|
|
7175
|
+
// return value;
|
|
7176
|
+
// } else {
|
|
7177
|
+
// return "";
|
|
7178
|
+
// }
|
|
7179
|
+
// }
|
|
7180
|
+
// } : {
|
|
7181
|
+
// type: getAmisStaticFieldType('date', readonly),
|
|
7182
|
+
// inputFormat: "YYYY-MM-DD",
|
|
7183
|
+
// format:'YYYY-MM-DDT00:00:00.000[Z]',
|
|
7184
|
+
// tpl: readonly ? Tpl.getDateTpl(field) : null,
|
|
7185
|
+
// // utc: true
|
|
7186
|
+
// }
|
|
7187
|
+
convertData = {
|
|
7183
7188
|
type: getAmisStaticFieldType('date', readonly),
|
|
7184
7189
|
inputFormat: "YYYY-MM-DD",
|
|
7185
7190
|
format:'YYYY-MM-DDT00:00:00.000[Z]',
|
|
@@ -7198,43 +7203,51 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
7198
7203
|
};
|
|
7199
7204
|
break;
|
|
7200
7205
|
case 'datetime':
|
|
7201
|
-
convertData = isMobile && !readonly ? {
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
} : {
|
|
7206
|
+
// convertData = isMobile && !readonly ? {
|
|
7207
|
+
// type: "combo",
|
|
7208
|
+
// pipeIn: (value, data) => {
|
|
7209
|
+
// let revalue = {};
|
|
7210
|
+
// if (value && value != "Invalid date") {
|
|
7211
|
+
// value = moment(value).format('YYYY-MM-DD HH:mm:ss');
|
|
7212
|
+
// revalue[field.name + "-native-date"] = value.split(' ')[0];
|
|
7213
|
+
// revalue[field.name + "-native-time"] = value.split(' ')[1];
|
|
7214
|
+
// } else {
|
|
7215
|
+
// revalue[field.name + "-native-date"] = "";
|
|
7216
|
+
// revalue[field.name + "-native-time"] = "";
|
|
7217
|
+
// }
|
|
7218
|
+
// return revalue;
|
|
7219
|
+
// },
|
|
7220
|
+
// pipeOut: (value, oldValue, data) => {
|
|
7221
|
+
// let revalue = "";
|
|
7222
|
+
// if (value[field.name + "-native-date"] && value[field.name + "-native-time"]) {
|
|
7223
|
+
// revalue = value[field.name + "-native-date"] + " " + value[field.name + "-native-time"];
|
|
7224
|
+
// revalue = moment(revalue).utc().format('YYYY-MM-DDTHH:mm:ss.SSS[Z]');
|
|
7225
|
+
// }
|
|
7226
|
+
// return revalue;
|
|
7227
|
+
// },
|
|
7228
|
+
// items: [
|
|
7229
|
+
// {
|
|
7230
|
+
// type: "native-date",
|
|
7231
|
+
// name: field.name + "-native-date",
|
|
7232
|
+
// className: "steedos-native-date",
|
|
7233
|
+
// value: ""
|
|
7234
|
+
// },
|
|
7235
|
+
// {
|
|
7236
|
+
// type: "native-time",
|
|
7237
|
+
// name: field.name + "-native-time",
|
|
7238
|
+
// className: "steedos-native-time",
|
|
7239
|
+
// value: ""
|
|
7240
|
+
// }
|
|
7241
|
+
// ]
|
|
7242
|
+
// } : {
|
|
7243
|
+
// type: getAmisStaticFieldType('datetime', readonly),
|
|
7244
|
+
// inputFormat: 'YYYY-MM-DD HH:mm',
|
|
7245
|
+
// format: 'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
|
7246
|
+
// tpl: readonly ? Tpl.getDateTimeTpl(field) : null,
|
|
7247
|
+
// utc: true,
|
|
7248
|
+
// }
|
|
7249
|
+
|
|
7250
|
+
convertData = {
|
|
7238
7251
|
type: getAmisStaticFieldType('datetime', readonly),
|
|
7239
7252
|
inputFormat: 'YYYY-MM-DD HH:mm',
|
|
7240
7253
|
format: 'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
|
@@ -7254,26 +7267,34 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
7254
7267
|
};
|
|
7255
7268
|
break;
|
|
7256
7269
|
case 'time':
|
|
7257
|
-
convertData = isMobile && !readonly ? {
|
|
7258
|
-
|
|
7259
|
-
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
} : {
|
|
7270
|
+
// convertData = isMobile && !readonly ? {
|
|
7271
|
+
// type: "native-time",
|
|
7272
|
+
// pipeIn: (value, data) => {
|
|
7273
|
+
// if (value) {
|
|
7274
|
+
// value = moment(value).utc().format('HH:mm');
|
|
7275
|
+
// return value;
|
|
7276
|
+
// } else {
|
|
7277
|
+
// return "";
|
|
7278
|
+
// }
|
|
7279
|
+
|
|
7280
|
+
// },
|
|
7281
|
+
// pipeOut: (value, oldValue, data) => {
|
|
7282
|
+
// if (value) {
|
|
7283
|
+
// value = moment('1970-01-01 ' + value).format('1970-01-01THH:mm:00.000[Z]');
|
|
7284
|
+
// return value;
|
|
7285
|
+
// } else {
|
|
7286
|
+
// return "";
|
|
7287
|
+
// }
|
|
7288
|
+
// }
|
|
7289
|
+
// } : {
|
|
7290
|
+
// type: getAmisStaticFieldType('time', readonly),
|
|
7291
|
+
// inputFormat: 'HH:mm',
|
|
7292
|
+
// timeFormat:'HH:mm',
|
|
7293
|
+
// format:'1970-01-01THH:mm:00.000[Z]',
|
|
7294
|
+
// tpl: readonly ? Tpl.getDateTimeTpl(field) : null,
|
|
7295
|
+
// // utc: true
|
|
7296
|
+
// }
|
|
7297
|
+
convertData = {
|
|
7277
7298
|
type: getAmisStaticFieldType('time', readonly),
|
|
7278
7299
|
inputFormat: 'HH:mm',
|
|
7279
7300
|
timeFormat:'HH:mm',
|
|
@@ -7750,7 +7771,7 @@ var config = {
|
|
|
7750
7771
|
async function getQuickEditSchema(field, options){
|
|
7751
7772
|
//判断在amis3.2以上环境下,放开批量编辑
|
|
7752
7773
|
const isAmisVersionforBatchEdit = amisRequire('amis').version[0] >= 3 && amisRequire('amis').version[2] >= 2;
|
|
7753
|
-
const quickEditId = options.objectName + "_" + field.name + "
|
|
7774
|
+
const quickEditId = options.objectName + "_" + field.name + "_quickEdit";//定义快速编辑的表单id,用于setvalue传值
|
|
7754
7775
|
var quickEditSchema = { body: [], id: quickEditId };
|
|
7755
7776
|
//select,avatar,image,file等组件无法行记录字段赋值,暂不支持批量编辑;
|
|
7756
7777
|
if(field.type != 'avatar' && field.type != 'image' && field.type != 'file' && isAmisVersionforBatchEdit){
|
|
@@ -7760,19 +7781,16 @@ async function getQuickEditSchema(field, options){
|
|
|
7760
7781
|
{
|
|
7761
7782
|
actionType: "custom",
|
|
7762
7783
|
script: `
|
|
7763
|
-
|
|
7764
|
-
|
|
7784
|
+
let items = _.cloneDeep(event.data.items);
|
|
7785
|
+
let selectedItems = _.cloneDeep(event.data.selectedItems);
|
|
7765
7786
|
if(event.data.isBatchEdit){
|
|
7766
7787
|
selectedItems.forEach(function(selectedItem){
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
doAction({actionType: 'setValue', "args": {"value": {items}},componentId: "${options.crudId}","dataMergeMode": "override"});
|
|
7770
|
-
selectedItems.forEach(function(selectedItem){
|
|
7788
|
+
selectedItem._display.${field.name} = event.data._display.${field.name};
|
|
7789
|
+
doAction({actionType: 'setValue', "args": {"value": selectedItem._display},componentId: "_display_" + selectedItem._index});
|
|
7771
7790
|
doAction({actionType: 'setValue', "args": {"value": event.data.${field.name}},componentId: "${options.objectName + "_" + field.name + "_"}" + selectedItem._index});
|
|
7772
7791
|
})
|
|
7773
7792
|
}else{
|
|
7774
|
-
|
|
7775
|
-
doAction({actionType: 'setValue', "args": {"value": {items}},componentId: "${options.crudId}","dataMergeMode": "override"});
|
|
7793
|
+
doAction({actionType: 'setValue', "args": {"value": event.data._display},componentId: "_display_" + event.data._index});
|
|
7776
7794
|
doAction({actionType: 'setValue', "args": {"value": event.data.${field.name}},componentId: "${options.objectName + "_" + field.name + "_"}" + event.data._index});
|
|
7777
7795
|
}
|
|
7778
7796
|
`
|
|
@@ -7802,7 +7820,7 @@ async function getQuickEditSchema(field, options){
|
|
|
7802
7820
|
{
|
|
7803
7821
|
"actionType": "custom",
|
|
7804
7822
|
"script": `
|
|
7805
|
-
var _display = event.data._display;
|
|
7823
|
+
var _display = _.cloneDeep(event.data._display);
|
|
7806
7824
|
${displayField}
|
|
7807
7825
|
doAction({actionType: 'setValue', "args": {"value": {_display}},componentId: "${quickEditId}"});
|
|
7808
7826
|
`
|
|
@@ -7824,7 +7842,7 @@ async function getQuickEditSchema(field, options){
|
|
|
7824
7842
|
第二种是增加选项时,按照value的值,找到对应选项,并按照_display的规则为其赋值
|
|
7825
7843
|
*/
|
|
7826
7844
|
TempDisplayField = `
|
|
7827
|
-
const preData = event.data.__super.${field.name};
|
|
7845
|
+
const preData = _.cloneDeep(event.data.__super.${field.name});
|
|
7828
7846
|
if(preData && event.data.${field.name}.length < preData.length){
|
|
7829
7847
|
let deletedIndex;
|
|
7830
7848
|
preData.forEach(function(item,index){
|
|
@@ -8023,8 +8041,124 @@ async function getQuickEditSchema(field, options){
|
|
|
8023
8041
|
quickEditSchema.body.push({
|
|
8024
8042
|
"name": "isBatchEdit",
|
|
8025
8043
|
"type": "checkbox",
|
|
8026
|
-
"option":
|
|
8027
|
-
|
|
8044
|
+
"option": [
|
|
8045
|
+
{
|
|
8046
|
+
"type": "tpl",
|
|
8047
|
+
"tpl": "更新${COUNT(selectedItems)}个选定记录"
|
|
8048
|
+
},
|
|
8049
|
+
{
|
|
8050
|
+
"type": "spinner",
|
|
8051
|
+
"showOn": "${batchPermissionLoading}",
|
|
8052
|
+
"size": "sm",
|
|
8053
|
+
"className": "mr-4"
|
|
8054
|
+
}
|
|
8055
|
+
],
|
|
8056
|
+
"visibleOn": "${ARRAYSOME(selectedItems, item => item._id === _id) && COUNT(selectedItems)>1 && quickedit_record_permissions.allowEdit && quickedit_record_permissions_loading == false}",
|
|
8057
|
+
"disabledOn": "${batchPermissionLoading}",
|
|
8058
|
+
"onEvent":{
|
|
8059
|
+
"change":{
|
|
8060
|
+
"actions":[
|
|
8061
|
+
{
|
|
8062
|
+
"actionType": "setValue",
|
|
8063
|
+
"componentId": `service_listview_${options.objectName}`,
|
|
8064
|
+
"args": {
|
|
8065
|
+
"value":{
|
|
8066
|
+
"batchPermissionLoading": true
|
|
8067
|
+
}
|
|
8068
|
+
},
|
|
8069
|
+
"expression":"${event.data.value}"
|
|
8070
|
+
},
|
|
8071
|
+
{
|
|
8072
|
+
"actionType": "ajax",
|
|
8073
|
+
"args": {
|
|
8074
|
+
"api": {
|
|
8075
|
+
"url": "${context.rootUrl}/graphql",
|
|
8076
|
+
"method": "post",
|
|
8077
|
+
"headers": {
|
|
8078
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
8079
|
+
},
|
|
8080
|
+
"data": {
|
|
8081
|
+
"query": "{rows:${objectName}(filters:[\"_id\",\"in\",${selectedItems | pick:_id | split | json}]){_id,_permissions{allowEdit}}}"
|
|
8082
|
+
},
|
|
8083
|
+
"adaptor": `
|
|
8084
|
+
const noPermission = [];
|
|
8085
|
+
payload.data.rows.forEach(function (row) {
|
|
8086
|
+
if(!row._permissions.allowEdit){
|
|
8087
|
+
noPermission.push(row._id);
|
|
8088
|
+
}
|
|
8089
|
+
})
|
|
8090
|
+
return payload = {data:{noPermission}};
|
|
8091
|
+
`
|
|
8092
|
+
}
|
|
8093
|
+
},
|
|
8094
|
+
"expression":"${event.data.value}"
|
|
8095
|
+
},
|
|
8096
|
+
{
|
|
8097
|
+
"actionType": "setValue",
|
|
8098
|
+
"componentId": `service_listview_${options.objectName}`,
|
|
8099
|
+
"args": {
|
|
8100
|
+
"value":{
|
|
8101
|
+
"batchPermissionLoading": false
|
|
8102
|
+
}
|
|
8103
|
+
},
|
|
8104
|
+
"expression":"${event.data.value}"
|
|
8105
|
+
},
|
|
8106
|
+
{
|
|
8107
|
+
"actionType": "dialog",
|
|
8108
|
+
"dialog":{
|
|
8109
|
+
"title": "记录权限",
|
|
8110
|
+
"showCloseButton": false,
|
|
8111
|
+
"body":[
|
|
8112
|
+
{
|
|
8113
|
+
"type": "tpl",
|
|
8114
|
+
"tpl": "当前选中记录中,有${COUNT(noPermission)}条记录无编辑权限,是否需要批量编辑其他记录?"
|
|
8115
|
+
}
|
|
8116
|
+
],
|
|
8117
|
+
"onEvent":{
|
|
8118
|
+
"confirm":{
|
|
8119
|
+
"actions":[
|
|
8120
|
+
{
|
|
8121
|
+
"actionType": "custom",
|
|
8122
|
+
"script": `
|
|
8123
|
+
const noPermission = event.data.noPermission;
|
|
8124
|
+
const crudComponent = event.context.scoped.getComponentById("${options.crudId}");
|
|
8125
|
+
const selectedItems = crudComponent && crudComponent.props.store.selectedItems.concat();
|
|
8126
|
+
noPermission.forEach(function (item) {
|
|
8127
|
+
crudComponent && crudComponent.unSelectItem(_.find(selectedItems,{_id:item}));
|
|
8128
|
+
})
|
|
8129
|
+
`
|
|
8130
|
+
},
|
|
8131
|
+
{
|
|
8132
|
+
"actionType": "setValue",
|
|
8133
|
+
"componentId": quickEditId,
|
|
8134
|
+
"args": {
|
|
8135
|
+
"value":{
|
|
8136
|
+
"isBatchEdit": true
|
|
8137
|
+
}
|
|
8138
|
+
},
|
|
8139
|
+
}
|
|
8140
|
+
]
|
|
8141
|
+
},
|
|
8142
|
+
"cancel":{
|
|
8143
|
+
"actions":[
|
|
8144
|
+
{
|
|
8145
|
+
"actionType": "setValue",
|
|
8146
|
+
"componentId": quickEditId,
|
|
8147
|
+
"args": {
|
|
8148
|
+
"value":{
|
|
8149
|
+
"isBatchEdit": false
|
|
8150
|
+
}
|
|
8151
|
+
},
|
|
8152
|
+
}
|
|
8153
|
+
]
|
|
8154
|
+
}
|
|
8155
|
+
}
|
|
8156
|
+
},
|
|
8157
|
+
"expression":"${COUNT(event.data.noPermission)>0}"
|
|
8158
|
+
}
|
|
8159
|
+
]
|
|
8160
|
+
}
|
|
8161
|
+
}
|
|
8028
8162
|
});
|
|
8029
8163
|
}
|
|
8030
8164
|
} else {
|
|
@@ -8061,6 +8195,8 @@ async function getTableColumns(fields, options){
|
|
|
8061
8195
|
const columns = [];
|
|
8062
8196
|
if(!options.isLookup){
|
|
8063
8197
|
columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
|
|
8198
|
+
//将_display放入crud的columns中,可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
|
|
8199
|
+
columns.push({name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
|
|
8064
8200
|
}
|
|
8065
8201
|
const allowEdit = options.permissions?.allowEdit && !options.isLookup && options.enable_inline_edit != false;
|
|
8066
8202
|
|
|
@@ -10418,7 +10554,8 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
10418
10554
|
const quickSaveApiRequestAdaptor = `
|
|
10419
10555
|
var graphqlOrder = "";
|
|
10420
10556
|
var imageNames = ${JSON.stringify(imageNames)};
|
|
10421
|
-
api.data.rowsDiff
|
|
10557
|
+
const rowsDiff = _.cloneDeep(api.data.rowsDiff);
|
|
10558
|
+
rowsDiff.forEach(function (item, index) {
|
|
10422
10559
|
for(key in item){
|
|
10423
10560
|
if(_.includes(imageNames, key)){
|
|
10424
10561
|
if(typeof item[key] == "string"){
|
|
@@ -10432,6 +10569,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
10432
10569
|
}
|
|
10433
10570
|
}
|
|
10434
10571
|
}
|
|
10572
|
+
item = _.omit(item, '_display');
|
|
10435
10573
|
const itemOrder = 'update' + index + ':' + api.data.objectName + '__update(id:"' + item._id + '", doc:' + JSON.stringify(JSON.stringify(_.omit(item, '_id'))) + ') {_id}';
|
|
10436
10574
|
graphqlOrder += itemOrder;
|
|
10437
10575
|
})
|