@steedos-labs/content-compliance 0.8.22 → 0.8.24

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.
Files changed (36) hide show
  1. package/dist/index.js +1 -1
  2. package/lib/index.js +12 -7
  3. package/lib/index.js.map +1 -1
  4. package/lib/methods/AI.d.ts +2 -2
  5. package/lib/methods/AI.js +4 -3
  6. package/lib/methods/AI.js.map +1 -1
  7. package/lib/methods/__tests__/plsReview.test.js +179 -1
  8. package/lib/methods/__tests__/plsReview.test.js.map +1 -1
  9. package/lib/methods/__tests__/qcParallelReview.test.js +10 -3
  10. package/lib/methods/__tests__/qcParallelReview.test.js.map +1 -1
  11. package/lib/methods/__tests__/resubmissionAutoApprove.test.d.ts +1 -0
  12. package/lib/methods/__tests__/resubmissionAutoApprove.test.js +195 -0
  13. package/lib/methods/__tests__/resubmissionAutoApprove.test.js.map +1 -0
  14. package/lib/methods/approval_engine.d.ts +1 -0
  15. package/lib/methods/approval_engine.js +324 -281
  16. package/lib/methods/approval_engine.js.map +1 -1
  17. package/lib/methods/pls.d.ts +6 -2
  18. package/lib/methods/pls.js +53 -27
  19. package/lib/methods/pls.js.map +1 -1
  20. package/lib/pages/__tests__/plsReviewCardStyles.test.js +10 -6
  21. package/lib/pages/__tests__/plsReviewCardStyles.test.js.map +1 -1
  22. package/lib/pages/__tests__/plsReviewPage.test.js +43 -13
  23. package/lib/pages/__tests__/plsReviewPage.test.js.map +1 -1
  24. package/main/default/objects/pepsico_material/buttons/pepsico_upload_supplement.button.yml +1 -1
  25. package/main/default/objects/pepsico_material_approval/fields/approved_flows.field.yml +1 -1
  26. package/main/default/objects/pepsico_material_approval/fields/ec_has_detail_page.field.yml +3 -3
  27. package/main/default/objects/pepsico_material_approval/fields/ec_producers.field.yml +3 -0
  28. package/main/default/objects/pepsico_material_approval/fields/ec_qc_production_email.field.yml +1 -1
  29. package/main/default/objects/pepsico_material_approval/fields/has_nutrition_table.field.yml +1 -1
  30. package/main/default/objects/pepsico_material_approval/fields/pls_km_files.field.yml +1 -1
  31. package/main/default/objects/pepsico_material_approval/fields/pls_upload_files.field.yml +1 -1
  32. package/main/default/objects/pepsico_material_approval/listviews/collaboration.listview.yml +5 -0
  33. package/main/default/pages/pepsico_content_review_detail.page.amis.json +233 -109
  34. package/main/default/pages/pepsico_material_detail.page.amis.json +296 -230
  35. package/package.json +1 -1
  36. package/public/content-review/amis.css +20 -13
@@ -309,121 +309,154 @@
309
309
  }
310
310
  },
311
311
  "steps": [
312
- {
313
- "title": "选择或上传 PLS文件",
314
- "api": {
315
- "url": "/api/pepsico-content/pls-file/upload",
316
- "method": "post",
317
- "sendOn": "${plsSourceMode === \"upload\" && (!newPlsFileId || newPlsUploadedFileId !== (uploadedPlsFile && (uploadedPlsFile.value || (uploadedPlsFile[0] && uploadedPlsFile[0].value) || uploadedPlsFile)))}",
318
- "requestAdaptor": "const file = context.uploadedPlsFile; const fileId = file && (file.value || (file[0] && file[0].value) || file); api.data = { fileIds: [fileId], approvalId: context.approvalId, materialId: context.materialId }; return api;",
319
- "adaptor": "if (payload && payload.error) { return { status: 1, msg: payload.error }; } const record = payload && payload.records && payload.records[0]; if (!record) { return { status: 1, msg: 'PLS文件上传失败' }; } const superData = (typeof context != 'undefined') ? context : api.body; const file = superData && superData.uploadedPlsFile; const uploadedFileId = file && (file.value || (file[0] && file[0].value) || file); return { status: 0, msg: '', data: { newPlsFileId: record.id, newPlsFileName: record.name, newPlsUploadedFileId: uploadedFileId } };"
320
- },
321
- "body": [
322
- {
323
- "type": "button-group-select",
324
- "name": "plsSourceMode",
325
- "label": false,
326
- "value": "existing",
327
- "className": "pepsico-pls-source-mode",
328
- "options": [
329
- {
330
- "label": "选择已有 PLS",
331
- "value": "existing"
332
- },
333
- {
334
- "label": "上传本地PLS文件",
335
- "value": "upload"
336
- }
337
- ]
338
- },
339
- {
340
- "type": "steedos-field",
341
- "name": "selectedPlsFile",
342
- "label": "新的 PLS 文件",
343
- "className": "pepsico-pls-source-field",
344
- "placeholder": "请选择PLS知识库文件",
345
- "visibleOn": "${plsSourceMode === \"existing\"}",
346
- "requiredOn": "${plsSourceMode === \"existing\"}",
347
- "config": {
348
- "type": "lookup",
349
- "name": "selectedPlsFile",
350
- "label": "新的 PLS 文件",
351
- "reference_to": "pepsico_km_pls_file",
352
- "enable_enhanced_lookup": true,
353
- "filters": [
354
- [
355
- "is_active",
356
- "=",
357
- true
358
- ],
359
- "or",
360
- [
361
- "is_active",
362
- "=",
363
- null
364
- ]
365
- ],
366
- "required": false,
367
- "amis": {
368
- "className": "pepsico-pls-source-field",
369
- "placeholder": "请选择PLS知识库文件",
370
- "joinValues": false,
371
- "extractValue": false,
372
- "visibleOn": "${plsSourceMode === \"existing\"}",
373
- "requiredOn": "${plsSourceMode === \"existing\"}"
374
- }
375
- }
376
- },
377
- {
378
- "type": "input-file",
379
- "name": "uploadedPlsFile",
380
- "label": "上传本地PLS文件",
381
- "className": "pepsico-pls-source-field",
382
- "autoUpload": true,
383
- "proxy": true,
384
- "uploadType": "fileReceptor",
385
- "btnLabel": "选择PDF文件",
386
- "multiple": false,
387
- "accept": ".pdf",
388
- "receiver": {
389
- "url": "/s3/files",
390
- "method": "post",
391
- "requestAdaptor": "const superData = (typeof context != 'undefined') ? context : api.body; const { global } = superData; api.data.append('space', global.spaceId); api.data.append('owner', global.userId); return api;",
392
- "adaptor": "const superData = (typeof context != 'undefined') ? context : api.body; const rootUrl = superData.context.rootUrl + '/api/files/files/'; payload = { status: response.status == 200 ? 0 : response.status, msg: response.statusText, data: { value: payload._id, name: payload.original.name, url: rootUrl + payload._id } }; return payload;",
393
- "dataType": "form-data"
394
- },
395
- "visibleOn": "${plsSourceMode === \"upload\"}",
396
- "requiredOn": "${plsSourceMode === \"upload\"}"
397
- }
398
- ]
399
- },
400
- {
401
- "title": "确认应用新PLS文件规则",
402
- "api": {
403
- "url": "/api/pepsico-content/pls-review/apply-source",
404
- "method": "post",
405
- "requestAdaptor": "const selected = context.selectedPlsFile; const newPlsFileId = context.plsSourceMode === 'existing' ? (selected && (selected.value || selected._id || selected)) : context.newPlsFileId; if (!newPlsFileId) { throw new Error('请选择或上传PLS文件'); } api.data = { approvalId: context.approvalId, materialId: context.materialId, oldPlsFileId: context.plsFileId, newPlsFileId: newPlsFileId, sourceMode: context.plsSourceMode }; return api;",
406
- "adaptor": "if (payload && payload.error) { return { status: 1, msg: payload.error }; } return { status: 0, msg: '正在按照新的PLS文件规则进行重新审核,请稍后刷新页面进行确认', data: payload };"
407
- },
408
- "body": [
409
- {
410
- "type": "tpl",
411
- "tpl": "<b>当前PLS文件:</b>${plsName}",
412
- "className": "pepsico-pls-source-summary"
413
- },
414
- {
415
- "type": "tpl",
416
- "tpl": "<b>新的PLS文件:</b>${plsSourceMode === \"existing\" ? (selectedPlsFile.name || selectedPlsFile.label || selectedPlsFile) : newPlsFileName}",
417
- "className": "pepsico-pls-source-summary"
418
- },
419
- {
420
- "type": "alert",
421
- "level": "warning",
422
- "body": "应用后,当前 PLS 文件关联的意见将失效,并按新的PLS文件规则重新生成对应意见。"
423
- }
424
- ]
425
- }
426
- ]
312
+ {
313
+ "title": "选择或上传 PLS文件",
314
+ "api": {
315
+ "url": "/api/pepsico-content/pls-file/upload",
316
+ "method": "post",
317
+ "requestAdaptor": "const files = context.uploadedPlsFile || []; const list = Array.isArray(files) ? files : [files]; const fileIds = list.map(function (file) { return file && (file.value || file); }).filter(Boolean); api.data = { fileIds: fileIds, approvalId: context.approvalId, materialId: context.materialId }; return api;",
318
+ "adaptor": "if (payload && payload.error) { return { status: 1, msg: payload.error }; } if (payload && payload.skipped > 0) { return { status: 1, msg: '仅支持PDF格式的PLS文件' }; } const superData = (typeof context != 'undefined') ? context : api.body; const files = (superData && superData.uploadedPlsFile) || []; const count = (Array.isArray(files) ? files : [files]).length; const records = (payload && payload.records) || []; if (count > 0 && records.length === 0) { return { status: 1, msg: 'PLS文件上传失败' }; } return { status: 0, msg: '', data: { newPlsFiles: records } };"
319
+ },
320
+ "body": [
321
+ {
322
+ "type": "tpl",
323
+ "tpl": "可同时选择已有PLS文件或上传本地PDF文件,将一起作为新的PLS重新给出AI意见。",
324
+ "className": "pepsico-pls-source-hint"
325
+ },
326
+ {
327
+ "type": "steedos-field",
328
+ "name": "selectedPlsFile",
329
+ "label": "选择已有PLS文件",
330
+ "className": "pepsico-pls-source-field",
331
+ "placeholder": "请选择PLS知识库文件",
332
+ "requiredOn": "${!uploadedPlsFile || uploadedPlsFile.length === 0}",
333
+ "config": {
334
+ "type": "lookup",
335
+ "name": "selectedPlsFile",
336
+ "label": "选择已有PLS文件",
337
+ "reference_to": "pepsico_km_pls_file",
338
+ "enable_enhanced_lookup": true,
339
+ "filters": [
340
+ [
341
+ "is_active",
342
+ "=",
343
+ true
344
+ ],
345
+ "or",
346
+ [
347
+ "is_active",
348
+ "=",
349
+ null
350
+ ]
351
+ ],
352
+ "required": false,
353
+ "amis": {
354
+ "className": "pepsico-pls-source-field",
355
+ "placeholder": "请选择PLS知识库文件",
356
+ "joinValues": false,
357
+ "extractValue": false,
358
+ "requiredOn": "${!uploadedPlsFile || uploadedPlsFile.length === 0}",
359
+ "multiple": true,
360
+ "validations": {
361
+ "maxLength": 10
362
+ },
363
+ "validationErrors": {
364
+ "maxLength": "最多选择10个PLS文件"
365
+ }
366
+ },
367
+ "multiple": true
368
+ }
369
+ },
370
+ {
371
+ "type": "input-file",
372
+ "name": "uploadedPlsFile",
373
+ "label": "上传本地PLS文件",
374
+ "className": "pepsico-pls-source-field",
375
+ "autoUpload": true,
376
+ "proxy": true,
377
+ "uploadType": "fileReceptor",
378
+ "btnLabel": "选择PDF文件",
379
+ "multiple": true,
380
+ "accept": ".pdf",
381
+ "receiver": {
382
+ "url": "/s3/files",
383
+ "method": "post",
384
+ "requestAdaptor": "const superData = (typeof context != 'undefined') ? context : api.body; const { global } = superData; api.data.append('space', global.spaceId); api.data.append('owner', global.userId); return api;",
385
+ "adaptor": "const superData = (typeof context != 'undefined') ? context : api.body; const rootUrl = superData.context.rootUrl + '/api/files/files/'; payload = { status: response.status == 200 ? 0 : response.status, msg: response.statusText, data: { value: payload._id, name: payload.original.name, url: rootUrl + payload._id } }; return payload;",
386
+ "dataType": "form-data"
387
+ },
388
+ "requiredOn": "${!selectedPlsFile || selectedPlsFile.length === 0}",
389
+ "maxLength": 10,
390
+ "joinValues": false,
391
+ "extractValue": false
392
+ }
393
+ ]
394
+ },
395
+ {
396
+ "title": "确认应用新PLS文件规则",
397
+ "api": {
398
+ "url": "/api/pepsico-content/pls-review/apply-source",
399
+ "method": "post",
400
+ "requestAdaptor": "const selected = context.selectedPlsFile; const selectedList = selected ? (Array.isArray(selected) ? selected : [selected]) : []; const existingIds = selectedList.map(function (item) { return item && (item.value || item._id || item); }).filter(Boolean); const files = context.uploadedPlsFile || []; const fileIds = (Array.isArray(files) ? files : [files]).map(function (file) { return file && (file.value || file); }).filter(Boolean); const uploadedIds = (context.newPlsFiles || []).filter(function (record) { return fileIds.indexOf(record.fileId) > -1; }).map(function (record) { return record.id; }); if (existingIds.length > 10 || uploadedIds.length > 10) { throw new Error('选择已有PLS文件和上传本地PLS文件各自最多10个'); } const newPlsFileIds = existingIds.concat(uploadedIds).filter(function (id, index, all) { return all.indexOf(id) === index; }); if (!newPlsFileIds.length) { throw new Error('请选择或上传PLS文件'); } const sourceMode = existingIds.length && uploadedIds.length ? 'mixed' : (uploadedIds.length ? 'upload' : 'existing'); api.data = { approvalId: context.approvalId, materialId: context.materialId, oldPlsFileId: context.plsFileId, newPlsFileIds: newPlsFileIds, sourceMode: sourceMode }; return api;",
401
+ "adaptor": "if (payload && payload.error) { return { status: 1, msg: payload.error }; } return { status: 0, msg: '正在按照新的PLS文件规则进行重新审核,请稍后刷新页面进行确认', data: payload };"
402
+ },
403
+ "body": [
404
+ {
405
+ "type": "container",
406
+ "className": "pepsico-pls-source-summary",
407
+ "body": [
408
+ {
409
+ "type": "tpl",
410
+ "tpl": "<b>当前PLS文件:</b>"
411
+ },
412
+ {
413
+ "type": "tpl",
414
+ "tpl": "${plsName}"
415
+ }
416
+ ]
417
+ },
418
+ {
419
+ "type": "container",
420
+ "className": "pepsico-pls-source-summary",
421
+ "body": [
422
+ {
423
+ "type": "tpl",
424
+ "tpl": "<b>新的PLS文件:</b>"
425
+ },
426
+ {
427
+ "type": "container",
428
+ "className": "pepsico-pls-summary-values",
429
+ "body": [
430
+ {
431
+ "type": "each",
432
+ "source": "${selectedPlsFile}",
433
+ "items": {
434
+ "type": "tpl",
435
+ "tpl": "${name || label || value}",
436
+ "className": "pepsico-pls-summary-item"
437
+ }
438
+ },
439
+ {
440
+ "type": "each",
441
+ "source": "${newPlsFiles}",
442
+ "items": {
443
+ "type": "tpl",
444
+ "tpl": "${name}",
445
+ "className": "pepsico-pls-summary-item"
446
+ }
447
+ }
448
+ ]
449
+ }
450
+ ]
451
+ },
452
+ {
453
+ "type": "alert",
454
+ "level": "warning",
455
+ "body": "应用后,当前 PLS 文件关联的意见将失效,并按新的PLS文件规则重新生成对应意见。"
456
+ }
457
+ ]
458
+ }
459
+ ]
427
460
  }
428
461
  ]
429
462
  }
@@ -865,121 +898,154 @@
865
898
  }
866
899
  },
867
900
  "steps": [
868
- {
869
- "title": "选择或上传 PLS文件",
870
- "api": {
871
- "url": "/api/pepsico-content/pls-file/upload",
872
- "method": "post",
873
- "sendOn": "${plsSourceMode === \"upload\" && (!newPlsFileId || newPlsUploadedFileId !== (uploadedPlsFile && (uploadedPlsFile.value || (uploadedPlsFile[0] && uploadedPlsFile[0].value) || uploadedPlsFile)))}",
874
- "requestAdaptor": "const file = context.uploadedPlsFile; const fileId = file && (file.value || (file[0] && file[0].value) || file); api.data = { fileIds: [fileId], approvalId: context.approvalId, materialId: context.materialId }; return api;",
875
- "adaptor": "if (payload && payload.error) { return { status: 1, msg: payload.error }; } const record = payload && payload.records && payload.records[0]; if (!record) { return { status: 1, msg: 'PLS文件上传失败' }; } const superData = (typeof context != 'undefined') ? context : api.body; const file = superData && superData.uploadedPlsFile; const uploadedFileId = file && (file.value || (file[0] && file[0].value) || file); return { status: 0, msg: '', data: { newPlsFileId: record.id, newPlsFileName: record.name, newPlsUploadedFileId: uploadedFileId } };"
876
- },
877
- "body": [
878
- {
879
- "type": "button-group-select",
880
- "name": "plsSourceMode",
881
- "label": false,
882
- "value": "existing",
883
- "className": "pepsico-pls-source-mode",
884
- "options": [
885
- {
886
- "label": "选择已有 PLS",
887
- "value": "existing"
888
- },
889
- {
890
- "label": "上传本地PLS文件",
891
- "value": "upload"
892
- }
893
- ]
894
- },
895
- {
896
- "type": "steedos-field",
897
- "name": "selectedPlsFile",
898
- "label": "新的 PLS 文件",
899
- "className": "pepsico-pls-source-field",
900
- "placeholder": "请选择PLS知识库文件",
901
- "visibleOn": "${plsSourceMode === \"existing\"}",
902
- "requiredOn": "${plsSourceMode === \"existing\"}",
903
- "config": {
904
- "type": "lookup",
905
- "name": "selectedPlsFile",
906
- "label": "新的 PLS 文件",
907
- "reference_to": "pepsico_km_pls_file",
908
- "enable_enhanced_lookup": true,
909
- "filters": [
910
- [
911
- "is_active",
912
- "=",
913
- true
914
- ],
915
- "or",
916
- [
917
- "is_active",
918
- "=",
919
- null
920
- ]
921
- ],
922
- "required": false,
923
- "amis": {
924
- "className": "pepsico-pls-source-field",
925
- "placeholder": "请选择PLS知识库文件",
926
- "joinValues": false,
927
- "extractValue": false,
928
- "visibleOn": "${plsSourceMode === \"existing\"}",
929
- "requiredOn": "${plsSourceMode === \"existing\"}"
930
- }
931
- }
932
- },
933
- {
934
- "type": "input-file",
935
- "name": "uploadedPlsFile",
936
- "label": "上传本地PLS文件",
937
- "className": "pepsico-pls-source-field",
938
- "autoUpload": true,
939
- "proxy": true,
940
- "uploadType": "fileReceptor",
941
- "btnLabel": "选择PDF文件",
942
- "multiple": false,
943
- "accept": ".pdf",
944
- "receiver": {
945
- "url": "/s3/files",
946
- "method": "post",
947
- "requestAdaptor": "const superData = (typeof context != 'undefined') ? context : api.body; const { global } = superData; api.data.append('space', global.spaceId); api.data.append('owner', global.userId); return api;",
948
- "adaptor": "const superData = (typeof context != 'undefined') ? context : api.body; const rootUrl = superData.context.rootUrl + '/api/files/files/'; payload = { status: response.status == 200 ? 0 : response.status, msg: response.statusText, data: { value: payload._id, name: payload.original.name, url: rootUrl + payload._id } }; return payload;",
949
- "dataType": "form-data"
950
- },
951
- "visibleOn": "${plsSourceMode === \"upload\"}",
952
- "requiredOn": "${plsSourceMode === \"upload\"}"
953
- }
954
- ]
955
- },
956
- {
957
- "title": "确认应用新PLS文件规则",
958
- "api": {
959
- "url": "/api/pepsico-content/pls-review/apply-source",
960
- "method": "post",
961
- "requestAdaptor": "const selected = context.selectedPlsFile; const newPlsFileId = context.plsSourceMode === 'existing' ? (selected && (selected.value || selected._id || selected)) : context.newPlsFileId; if (!newPlsFileId) { throw new Error('请选择或上传PLS文件'); } api.data = { approvalId: context.approvalId, materialId: context.materialId, oldPlsFileId: context.plsFileId, newPlsFileId: newPlsFileId, sourceMode: context.plsSourceMode }; return api;",
962
- "adaptor": "if (payload && payload.error) { return { status: 1, msg: payload.error }; } return { status: 0, msg: '正在按照新的PLS文件规则进行重新审核,请稍后刷新页面进行确认', data: payload };"
963
- },
964
- "body": [
965
- {
966
- "type": "tpl",
967
- "tpl": "<b>当前PLS文件:</b>${plsName}",
968
- "className": "pepsico-pls-source-summary"
969
- },
970
- {
971
- "type": "tpl",
972
- "tpl": "<b>新的PLS文件:</b>${plsSourceMode === \"existing\" ? (selectedPlsFile.name || selectedPlsFile.label || selectedPlsFile) : newPlsFileName}",
973
- "className": "pepsico-pls-source-summary"
974
- },
975
- {
976
- "type": "alert",
977
- "level": "warning",
978
- "body": "应用后,当前 PLS 文件关联的意见将失效,并按新的PLS文件规则重新生成对应意见。"
979
- }
980
- ]
981
- }
982
- ]
901
+ {
902
+ "title": "选择或上传 PLS文件",
903
+ "api": {
904
+ "url": "/api/pepsico-content/pls-file/upload",
905
+ "method": "post",
906
+ "requestAdaptor": "const files = context.uploadedPlsFile || []; const list = Array.isArray(files) ? files : [files]; const fileIds = list.map(function (file) { return file && (file.value || file); }).filter(Boolean); api.data = { fileIds: fileIds, approvalId: context.approvalId, materialId: context.materialId }; return api;",
907
+ "adaptor": "if (payload && payload.error) { return { status: 1, msg: payload.error }; } if (payload && payload.skipped > 0) { return { status: 1, msg: '仅支持PDF格式的PLS文件' }; } const superData = (typeof context != 'undefined') ? context : api.body; const files = (superData && superData.uploadedPlsFile) || []; const count = (Array.isArray(files) ? files : [files]).length; const records = (payload && payload.records) || []; if (count > 0 && records.length === 0) { return { status: 1, msg: 'PLS文件上传失败' }; } return { status: 0, msg: '', data: { newPlsFiles: records } };"
908
+ },
909
+ "body": [
910
+ {
911
+ "type": "tpl",
912
+ "tpl": "可同时选择已有PLS文件或上传本地PDF文件,将一起作为新的PLS重新给出AI意见。",
913
+ "className": "pepsico-pls-source-hint"
914
+ },
915
+ {
916
+ "type": "steedos-field",
917
+ "name": "selectedPlsFile",
918
+ "label": "选择已有PLS文件",
919
+ "className": "pepsico-pls-source-field",
920
+ "placeholder": "请选择PLS知识库文件",
921
+ "requiredOn": "${!uploadedPlsFile || uploadedPlsFile.length === 0}",
922
+ "config": {
923
+ "type": "lookup",
924
+ "name": "selectedPlsFile",
925
+ "label": "选择已有PLS文件",
926
+ "reference_to": "pepsico_km_pls_file",
927
+ "enable_enhanced_lookup": true,
928
+ "filters": [
929
+ [
930
+ "is_active",
931
+ "=",
932
+ true
933
+ ],
934
+ "or",
935
+ [
936
+ "is_active",
937
+ "=",
938
+ null
939
+ ]
940
+ ],
941
+ "required": false,
942
+ "amis": {
943
+ "className": "pepsico-pls-source-field",
944
+ "placeholder": "请选择PLS知识库文件",
945
+ "joinValues": false,
946
+ "extractValue": false,
947
+ "requiredOn": "${!uploadedPlsFile || uploadedPlsFile.length === 0}",
948
+ "multiple": true,
949
+ "validations": {
950
+ "maxLength": 10
951
+ },
952
+ "validationErrors": {
953
+ "maxLength": "最多选择10个PLS文件"
954
+ }
955
+ },
956
+ "multiple": true
957
+ }
958
+ },
959
+ {
960
+ "type": "input-file",
961
+ "name": "uploadedPlsFile",
962
+ "label": "上传本地PLS文件",
963
+ "className": "pepsico-pls-source-field",
964
+ "autoUpload": true,
965
+ "proxy": true,
966
+ "uploadType": "fileReceptor",
967
+ "btnLabel": "选择PDF文件",
968
+ "multiple": true,
969
+ "accept": ".pdf",
970
+ "receiver": {
971
+ "url": "/s3/files",
972
+ "method": "post",
973
+ "requestAdaptor": "const superData = (typeof context != 'undefined') ? context : api.body; const { global } = superData; api.data.append('space', global.spaceId); api.data.append('owner', global.userId); return api;",
974
+ "adaptor": "const superData = (typeof context != 'undefined') ? context : api.body; const rootUrl = superData.context.rootUrl + '/api/files/files/'; payload = { status: response.status == 200 ? 0 : response.status, msg: response.statusText, data: { value: payload._id, name: payload.original.name, url: rootUrl + payload._id } }; return payload;",
975
+ "dataType": "form-data"
976
+ },
977
+ "requiredOn": "${!selectedPlsFile || selectedPlsFile.length === 0}",
978
+ "maxLength": 10,
979
+ "joinValues": false,
980
+ "extractValue": false
981
+ }
982
+ ]
983
+ },
984
+ {
985
+ "title": "确认应用新PLS文件规则",
986
+ "api": {
987
+ "url": "/api/pepsico-content/pls-review/apply-source",
988
+ "method": "post",
989
+ "requestAdaptor": "const selected = context.selectedPlsFile; const selectedList = selected ? (Array.isArray(selected) ? selected : [selected]) : []; const existingIds = selectedList.map(function (item) { return item && (item.value || item._id || item); }).filter(Boolean); const files = context.uploadedPlsFile || []; const fileIds = (Array.isArray(files) ? files : [files]).map(function (file) { return file && (file.value || file); }).filter(Boolean); const uploadedIds = (context.newPlsFiles || []).filter(function (record) { return fileIds.indexOf(record.fileId) > -1; }).map(function (record) { return record.id; }); if (existingIds.length > 10 || uploadedIds.length > 10) { throw new Error('选择已有PLS文件和上传本地PLS文件各自最多10个'); } const newPlsFileIds = existingIds.concat(uploadedIds).filter(function (id, index, all) { return all.indexOf(id) === index; }); if (!newPlsFileIds.length) { throw new Error('请选择或上传PLS文件'); } const sourceMode = existingIds.length && uploadedIds.length ? 'mixed' : (uploadedIds.length ? 'upload' : 'existing'); api.data = { approvalId: context.approvalId, materialId: context.materialId, oldPlsFileId: context.plsFileId, newPlsFileIds: newPlsFileIds, sourceMode: sourceMode }; return api;",
990
+ "adaptor": "if (payload && payload.error) { return { status: 1, msg: payload.error }; } return { status: 0, msg: '正在按照新的PLS文件规则进行重新审核,请稍后刷新页面进行确认', data: payload };"
991
+ },
992
+ "body": [
993
+ {
994
+ "type": "container",
995
+ "className": "pepsico-pls-source-summary",
996
+ "body": [
997
+ {
998
+ "type": "tpl",
999
+ "tpl": "<b>当前PLS文件:</b>"
1000
+ },
1001
+ {
1002
+ "type": "tpl",
1003
+ "tpl": "${plsName}"
1004
+ }
1005
+ ]
1006
+ },
1007
+ {
1008
+ "type": "container",
1009
+ "className": "pepsico-pls-source-summary",
1010
+ "body": [
1011
+ {
1012
+ "type": "tpl",
1013
+ "tpl": "<b>新的PLS文件:</b>"
1014
+ },
1015
+ {
1016
+ "type": "container",
1017
+ "className": "pepsico-pls-summary-values",
1018
+ "body": [
1019
+ {
1020
+ "type": "each",
1021
+ "source": "${selectedPlsFile}",
1022
+ "items": {
1023
+ "type": "tpl",
1024
+ "tpl": "${name || label || value}",
1025
+ "className": "pepsico-pls-summary-item"
1026
+ }
1027
+ },
1028
+ {
1029
+ "type": "each",
1030
+ "source": "${newPlsFiles}",
1031
+ "items": {
1032
+ "type": "tpl",
1033
+ "tpl": "${name}",
1034
+ "className": "pepsico-pls-summary-item"
1035
+ }
1036
+ }
1037
+ ]
1038
+ }
1039
+ ]
1040
+ },
1041
+ {
1042
+ "type": "alert",
1043
+ "level": "warning",
1044
+ "body": "应用后,当前 PLS 文件关联的意见将失效,并按新的PLS文件规则重新生成对应意见。"
1045
+ }
1046
+ ]
1047
+ }
1048
+ ]
983
1049
  }
984
1050
  ]
985
1051
  }