ztxkui 4.2.23-340-beta → 4.2.23-342-beta

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.
@@ -8,8 +8,9 @@ import { getToken } from 'ztxkutils/dist/authority';
8
8
  import { dangerouslySetXss } from 'ztxkutils/dist/tools';
9
9
  import { downloadFile } from './fileUtils';
10
10
  import { isImage } from '../../utils/upload';
11
+ import FileUpload from './file-upload';
11
12
  var FileOperation = function (props) {
12
- var isDownload = props.isDownload, isPreview = props.isPreview, isEdit = props.isEdit, isWater = props.isWater, records = props.records, isDelete = props.isDelete, fileName = props.fileName, _a = props.fileId, fileId = _a === void 0 ? '' : _a, _b = props.preFileId, preFileId = _b === void 0 ? '' : _b, _c = props.preFileName, preFileName = _c === void 0 ? '' : _c, _d = props.apiBaseUrl, apiBaseUrl = _d === void 0 ? '' : _d, _e = props.fileBaseUrl, fileBaseUrl = _e === void 0 ? '' : _e, onDelete = props.onDelete, onWatermarkChange = props.onWatermarkChange, organizationId = props.organizationId;
13
+ var isDownload = props.isDownload, isPreview = props.isPreview, isEdit = props.isEdit, isWater = props.isWater, records = props.records, isDelete = props.isDelete, fileName = props.fileName, _a = props.fileId, fileId = _a === void 0 ? '' : _a, _b = props.preFileId, preFileId = _b === void 0 ? '' : _b, _c = props.preFileName, preFileName = _c === void 0 ? '' : _c, _d = props.apiBaseUrl, apiBaseUrl = _d === void 0 ? '' : _d, _e = props.fileBaseUrl, fileBaseUrl = _e === void 0 ? '' : _e, onDelete = props.onDelete, onWatermarkChange = props.onWatermarkChange, organizationId = props.organizationId, isReplaceFile = props.isReplaceFile, fileList = props.fileList, onFileReplace = props.onFileReplace;
13
14
  var previewBtn = function (attachId, previewTitle, fileName) {
14
15
  return (React.createElement(Button, { type: "link", onClick: function () {
15
16
  // 实现批量预览,只针对图片
@@ -28,6 +29,9 @@ var FileOperation = function (props) {
28
29
  });
29
30
  } }, previewTitle));
30
31
  };
32
+ function onFileChange(info) {
33
+ onFileReplace && onFileReplace(info, fileId);
34
+ }
31
35
  return (React.createElement("div", { className: "file-operation--wrap" },
32
36
  React.createElement("p", { className: "file-operation--title" }, fileName),
33
37
  isEdit && fileId && (React.createElement("div", { className: "file-operation--isWater" },
@@ -35,6 +39,7 @@ var FileOperation = function (props) {
35
39
  onWatermarkChange && onWatermarkChange(e.target.checked);
36
40
  } }, "\u6DFB\u52A0\u6C34\u5370"))),
37
41
  React.createElement("div", { className: "file-operation--list" },
42
+ isReplaceFile && (React.createElement(FileUpload, { fileList: fileList, apiBaseUrl: apiBaseUrl, onFileChange: onFileChange, type: "link" }, "\u66FF\u6362")),
38
43
  isDownload && fileId ? (React.createElement(Button, { type: "link", onClick: function () {
39
44
  downloadFileCallBack(apiBaseUrl, fileId, dangerouslySetXss(fileName) || '附件', {
40
45
  addWaterMark: false,
@@ -20,16 +20,16 @@ import useLastest from '../../utils/useLastest';
20
20
  import { getToken } from 'ztxkutils/dist/authority';
21
21
  import { formatUnit, getFileExtension } from '../utils';
22
22
  var FileUpload = function (props) {
23
- var apiBaseUrl = props.apiBaseUrl, headers = props.headers, data = props.data, isPublic = props.isPublic, acceptList = props.acceptList, maxSize = props.maxSize, beforeUpload = props.beforeUpload, disAllowDuplicateFile = props.disAllowDuplicateFile, fileList = props.fileList, onFileChange = props.onFileChange;
24
- var _a = useState(false), loading = _a[0], setLoading = _a[1];
23
+ var apiBaseUrl = props.apiBaseUrl, headers = props.headers, data = props.data, isPublic = props.isPublic, acceptList = props.acceptList, maxSize = props.maxSize, beforeUpload = props.beforeUpload, disAllowDuplicateFile = props.disAllowDuplicateFile, fileList = props.fileList, onFileChange = props.onFileChange, children = props.children, _a = props.multiple, multiple = _a === void 0 ? true : _a, _b = props.type, type = _b === void 0 ? 'primary' : _b;
24
+ var _c = useState(false), loading = _c[0], setLoading = _c[1];
25
25
  // 取接口地址
26
26
  var defaultApiBaseUrl = useBaseContext().apiBaseUrl;
27
- var _b = useBasicInfo({
27
+ var _d = useBasicInfo({
28
28
  apiBaseUrl: apiBaseUrl || defaultApiBaseUrl,
29
29
  headers: headers,
30
30
  data: data,
31
31
  isPublic: isPublic,
32
- }), fileAction = _b.fileAction, fileHeaders = _b.fileHeaders, fileData = _b.fileData;
32
+ }), fileAction = _d.fileAction, fileHeaders = _d.fileHeaders, fileData = _d.fileData;
33
33
  // 文件上传前的判断处理
34
34
  var beforeUploadHandle = useBeforeUpload({
35
35
  acceptList: acceptList,
@@ -49,8 +49,8 @@ var FileUpload = function (props) {
49
49
  }
50
50
  onFileChange && onFileChange(info);
51
51
  }, [onFileChange]);
52
- return (React.createElement(Upload, { action: fileAction, headers: fileHeaders, data: fileData, showUploadList: false, beforeUpload: beforeUploadHandle, onChange: onChange, disabled: loading, multiple: true, className: "electron-file-upload" },
53
- React.createElement(Button, { type: "primary", loading: loading }, "\u6DFB\u52A0\u9644\u4EF6")));
52
+ return (React.createElement(Upload, { action: fileAction, headers: fileHeaders, data: fileData, showUploadList: false, beforeUpload: beforeUploadHandle, onChange: onChange, disabled: loading, multiple: multiple, className: "electron-file-upload" },
53
+ React.createElement(Button, { type: type, loading: loading }, children)));
54
54
  };
55
55
  export default memo(FileUpload);
56
56
  function useBasicInfo(props) {
@@ -25,6 +25,7 @@ interface IOptions {
25
25
  currentIsEditMemo?: boolean;
26
26
  isControlNeedQys?: IElectronSignaturesItemPublic['isControlNeedQys'];
27
27
  organizationId?: string;
28
+ onFileReplace: any;
28
29
  }
29
30
  export default function useFileColumns(options: IOptions): {
30
31
  fileColumns: ColumnsType<any>;
@@ -22,7 +22,7 @@ import dayjs from 'dayjs';
22
22
  export default function useFileColumns(options) {
23
23
  var records = options.records, dataTypeSort = options.dataTypeSort, allData = options.allData, isShowFileUpload = options.isShowFileUpload, apiBaseUrl = options.apiBaseUrl, fileBaseUrl = options.fileBaseUrl, firstDataType = options.firstDataType,
24
24
  // fileUploadProps,
25
- onValueChange = options.onValueChange, onFileTypeChangeGetItem = options.onFileTypeChangeGetItem, getCreateTimeHand = options.getCreateTimeHand, isSingleQj = options.isSingleQj, justNeedQj = options.justNeedQj, setJustNeedQj = options.setJustNeedQj, isShowFileType = options.isShowFileType, currentIsEditMemo = options.currentIsEditMemo, isDeleteAllFileWhenJustUseQj = options.isDeleteAllFileWhenJustUseQj, isControlNeedQys = options.isControlNeedQys, organizationId = options.organizationId;
25
+ onValueChange = options.onValueChange, onFileTypeChangeGetItem = options.onFileTypeChangeGetItem, getCreateTimeHand = options.getCreateTimeHand, isSingleQj = options.isSingleQj, justNeedQj = options.justNeedQj, setJustNeedQj = options.setJustNeedQj, isShowFileType = options.isShowFileType, currentIsEditMemo = options.currentIsEditMemo, isDeleteAllFileWhenJustUseQj = options.isDeleteAllFileWhenJustUseQj, isControlNeedQys = options.isControlNeedQys, organizationId = options.organizationId, onFileReplace = options.onFileReplace;
26
26
  var _a = allData[firstDataType] || {},
27
27
  // records: sameTypeRecords,
28
28
  setSameTypeRecords = _a.setRecords, onClearElectronListData = _a.onClearElectronListData, onClearElectronSetting = _a.onClearElectronSetting,
@@ -128,7 +128,9 @@ export default function useFileColumns(options) {
128
128
  var _c = (fileFieldsNameRef === null || fileFieldsNameRef === void 0 ? void 0 : fileFieldsNameRef.current) || {}, oldVersionId = _c.oldVersionId, oldVersionName = _c.oldVersionName;
129
129
  // 是否添加水印
130
130
  var isWater = (record === null || record === void 0 ? void 0 : record.isWatermark) + '' === '1' ? true : false;
131
- return (React.createElement(FileOperation, { fileName: text, fileId: record.attachId, preFileId: record === null || record === void 0 ? void 0 : record[oldVersionId || ''], preFileName: record === null || record === void 0 ? void 0 : record[oldVersionName || ''], isDownload: true, isDelete: isEdit && isShowFileUpload, isPreview: true, isEdit: isEdit, isWater: isWater, apiBaseUrl: apiBaseUrl, fileBaseUrl: fileBaseUrl, records: sameTypeRecords, organizationId: organizationId, onDelete: function () {
131
+ // 是否替换附件
132
+ var isReplaceFile = (record === null || record === void 0 ? void 0 : record.isReplaceFile) + '' === '1' ? true : false;
133
+ return (React.createElement(FileOperation, { fileName: text, fileId: record.attachId, preFileId: record === null || record === void 0 ? void 0 : record[oldVersionId || ''], preFileName: record === null || record === void 0 ? void 0 : record[oldVersionName || ''], isDownload: true, isDelete: isEdit && isShowFileUpload, isPreview: true, isEdit: isEdit, isWater: isWater, apiBaseUrl: apiBaseUrl, fileBaseUrl: fileBaseUrl, records: sameTypeRecords, organizationId: organizationId, isReplaceFile: isReplaceFile, onDelete: function () {
132
134
  var _a;
133
135
  // 因为数据是按照类型来归类了,那么这个索引的长度 实际应该减去之前的所有数据类型的长度
134
136
  var dataTypeIndex = index - preDataTypeRecordsLength;
@@ -156,7 +158,7 @@ export default function useFileColumns(options) {
156
158
  copyRecords.splice(dataTypeIndex, 1, __assign(__assign({}, item), (_a = { isWatermark: isChecked ? 1 : 0 }, _a[DATA_TYPE_KEY] = currentDataType, _a)));
157
159
  return copyRecords;
158
160
  });
159
- } }));
161
+ }, fileList: records, onFileReplace: onFileReplace }));
160
162
  },
161
163
  },
162
164
  {
@@ -275,6 +275,7 @@ var ElectronSignatures = function (props) {
275
275
  isDeleteAllFileWhenJustUseQj: isDeleteAllFileWhenJustUseQj,
276
276
  isControlNeedQys: isControlNeedQys,
277
277
  organizationId: organizationId,
278
+ onFileReplace: onFileReplace,
278
279
  }).fileColumns;
279
280
  // 智能合同比对
280
281
  var contractColumns = useContractColumns({
@@ -737,44 +738,63 @@ var ElectronSignatures = function (props) {
737
738
  },
738
739
  }); }, []);
739
740
  var _v = allData[firstDataType] || {}, sameTypeRecords = _v.records, setSameTypeRecords = _v.setRecords, parseCurrentUploadFile = _v.parseCurrentUploadFile;
741
+ function addFile(info, callback) {
742
+ var _a;
743
+ var file = info.file;
744
+ if (file.status === 'done') {
745
+ var currentData = allData[firstDataType];
746
+ // 附件类型字段对应表
747
+ var _b = ((_a = currentData.fileFieldsNameRef) === null || _a === void 0 ? void 0 : _a.current) || {}, _c = _b.isQunj, isQunjKey_1 = _c === void 0 ? 'isQunj' : _c, _d = _b.qunjSeal, qunjSealKey_1 = _d === void 0 ? 'qunjSeal' : _d;
748
+ setSameTypeRecords(function (preRecords) {
749
+ var copyRecords = (preRecords === null || preRecords === void 0 ? void 0 : preRecords.slice()) || [];
750
+ copyRecords = copyRecords.filter(function (record) { return !currentRecordIsOnlyQunj(record); });
751
+ // 插入一个给开发操作附件的机会
752
+ var newFile = callback(file);
753
+ // 每个附件都可以添加群杰时控制
754
+ if (isSingleQj) {
755
+ newFile[isQunjKey_1] = 1;
756
+ newFile[qunjSealKey_1] = { isTakeOut: 0 };
757
+ }
758
+ if (parseCurrentUploadFile) {
759
+ newFile = parseCurrentUploadFile(newFile);
760
+ }
761
+ copyRecords.push(newFile);
762
+ return copyRecords;
763
+ });
764
+ }
765
+ }
766
+ function onFileChange(info) {
767
+ addFile(info, function (file) {
768
+ var _a;
769
+ var _b, _c, _d, _e;
770
+ return _a = {
771
+ attachId: (_c = (_b = file === null || file === void 0 ? void 0 : file.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.attachId,
772
+ attachName: (_e = (_d = file === null || file === void 0 ? void 0 : file.response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.originalName
773
+ },
774
+ _a[DATA_TYPE_KEY] = firstDataType,
775
+ _a;
776
+ });
777
+ }
778
+ function onFileReplace(info, oldVersionId) {
779
+ addFile(info, function (file) {
780
+ var _a;
781
+ var _b, _c, _d, _e;
782
+ return _a = {
783
+ attachId: (_c = (_b = file === null || file === void 0 ? void 0 : file.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.attachId,
784
+ attachName: (_e = (_d = file === null || file === void 0 ? void 0 : file.response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.originalName,
785
+ oldVersionId: oldVersionId
786
+ },
787
+ _a[DATA_TYPE_KEY] = firstDataType,
788
+ _a;
789
+ });
790
+ }
740
791
  return (React.createElement(React.Fragment, null,
741
792
  allOptions.map(function (options, index) {
742
793
  var mergeOptions = index === 0
743
794
  ? __assign(__assign({}, options), { onValueChange: onValueChange }) : __assign(__assign({ deptId: resetProps.deptId, flowId: resetProps.flowId }, options), { onValueChange: onValueChange });
744
795
  return (React.createElement(ElectronSignaturesFragment, __assign({ key: index, dataType: "" + index, onTrackChange: onTrackChange, request: request, isUnControlled: isUnControlled, setLoading: setLoading, apiBaseUrl: apiBaseUrl, fileBaseUrl: fileBaseUrl, isSingleQj: isSingleQj }, mergeOptions)));
745
796
  }),
746
- React.createElement(ElectronSealBatchDownload, { request: request, apiBaseUrl: apiBaseUrl, selectRows: selectRows, allData: allData, isShowElectronBatchBtn: isShowElectronBatchBtn, isShowDownloadBatchBtn: isShowDownloadBatchBtn, isShowDoubleSignedBatchBtn: isShowDoubleSignedBatchBtn, batchDownloadZipName: batchDownloadZipName, firstDataType: firstDataType }, isShowFileUpload && currentIsEditMemo ? (React.createElement(FileUpload, __assign({ fileList: sameTypeRecords, apiBaseUrl: apiBaseUrl, onFileChange: function (info) {
747
- var _a;
748
- var file = info.file;
749
- if (file.status === 'done') {
750
- var currentData = allData[firstDataType];
751
- // 附件类型字段对应表
752
- var _b = ((_a = currentData.fileFieldsNameRef) === null || _a === void 0 ? void 0 : _a.current) || {}, _c = _b.isQunj, isQunjKey_1 = _c === void 0 ? 'isQunj' : _c, _d = _b.qunjSeal, qunjSealKey_1 = _d === void 0 ? 'qunjSeal' : _d;
753
- setSameTypeRecords(function (preRecords) {
754
- var _a;
755
- var _b, _c, _d, _e;
756
- var copyRecords = (preRecords === null || preRecords === void 0 ? void 0 : preRecords.slice()) || [];
757
- copyRecords = copyRecords.filter(function (record) { return !currentRecordIsOnlyQunj(record); });
758
- // 插入一个给开发操作附件的机会
759
- var newFile = (_a = {
760
- attachId: (_c = (_b = file === null || file === void 0 ? void 0 : file.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.attachId,
761
- attachName: (_e = (_d = file === null || file === void 0 ? void 0 : file.response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.originalName
762
- },
763
- _a[DATA_TYPE_KEY] = firstDataType,
764
- _a);
765
- // 每个附件都可以添加群杰时控制
766
- if (isSingleQj) {
767
- newFile[isQunjKey_1] = 1;
768
- newFile[qunjSealKey_1] = { isTakeOut: 0 };
769
- }
770
- if (parseCurrentUploadFile) {
771
- newFile = parseCurrentUploadFile(newFile);
772
- }
773
- copyRecords.push(newFile);
774
- return copyRecords;
775
- });
776
- }
777
- } }, fileUploadProps))) : null),
797
+ React.createElement(ElectronSealBatchDownload, { request: request, apiBaseUrl: apiBaseUrl, selectRows: selectRows, allData: allData, isShowElectronBatchBtn: isShowElectronBatchBtn, isShowDownloadBatchBtn: isShowDownloadBatchBtn, isShowDoubleSignedBatchBtn: isShowDoubleSignedBatchBtn, batchDownloadZipName: batchDownloadZipName, firstDataType: firstDataType }, isShowFileUpload && currentIsEditMemo ? (React.createElement(FileUpload, __assign({ fileList: sameTypeRecords, apiBaseUrl: apiBaseUrl, onFileChange: onFileChange, multiple: true }, fileUploadProps), "\u6DFB\u52A0\u9644\u4EF6")) : null),
778
798
  React.createElement(Table, { dataSource: mergeRecords, columns: columns, rowKey: "attachId", className: "zt-table electron-table", bordered: true, pagination: false, loading: loading, rowSelection: myRowSelection, scroll: __assign({ x: 'max-content', y: 500 }, tableScroll) }),
779
799
  React.createElement(LastQysModal, { modalHandleRef: modalHandleRef, appointSignLocation: function (info) {
780
800
  // 未盖章的印章id列表
@@ -1,3 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { ButtonProps } from 'antd';
1
3
  /** 附件的字段说明 */
2
4
  export interface IFileFieldsName {
3
5
  /** 附件id */
@@ -49,6 +51,8 @@ export interface IFileFieldsName {
49
51
  qunjAddress?: string;
50
52
  /** 群杰印章信息 */
51
53
  qunjSeal?: string;
54
+ /** 是否替换附件 */
55
+ isReplaceFile?: number;
52
56
  }
53
57
  declare const FILE_FIELDS_NAME: IFileFieldsName;
54
58
  export { FILE_FIELDS_NAME };
@@ -639,6 +643,9 @@ export interface IFileUploadProps {
639
643
  fileList?: any;
640
644
  /** 附件发生改变时触发 */
641
645
  onFileChange?: any;
646
+ children?: React.ReactNode;
647
+ multiple?: boolean;
648
+ type?: ButtonProps['type'];
642
649
  }
643
650
  export interface IFileOperationProps {
644
651
  /**附件名称 */
@@ -671,4 +678,10 @@ export interface IFileOperationProps {
671
678
  onWatermarkChange?: any;
672
679
  /** 公司id */
673
680
  organizationId?: string;
681
+ /** 是否替换附件 */
682
+ isReplaceFile?: boolean;
683
+ /** 所有附件 */
684
+ fileList?: IFileItem[];
685
+ /** 替换文件回调 */
686
+ onFileReplace?: any;
674
687
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkui",
3
- "version": "4.2.23-340-beta",
3
+ "version": "4.2.23-342-beta",
4
4
  "private": false,
5
5
  "description": "React components library",
6
6
  "author": "zt-front-end",