const require_runtime = require("../../../../../../../_virtual/_rolldown/runtime.js");
const require_index = require("../../../../../../../locales/index.js");
const require_objectSpread2 = require("../../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_useEngineContext = require("../../../../../../../hooks/useEngineContext.js");
const require_utils = require("../../../../../utils.js");
const require_serve = require("../../../../../serve.js");
const require_date = require("../../utils/date.js");
const require_Detail = require("./Detail.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let ahooks = require("ahooks");
require("./index.less");
//#region src/components/table/Actions/component/ExportImport/components/ImportLog/index.tsx
const defaultData = {
	skip: 1,
	num: 10
};
const ImportLog = (props) => {
	const { exportImport } = props;
	const { apiUrl, otherParams } = exportImport;
	const detailRef = (0, react.useRef)(null);
	const [list, setList] = (0, react.useState)([]);
	const context = require_useEngineContext.default();
	require_utils.request.setRequest(context.appHelper.utils.request);
	/**
	* @title: 导入日志
	* @description:
	* @return {*}
	* @Author: WangHan
	* @Date: 2024-06-29 15:14
	*/
	const _historyList = (0, ahooks.useRequest)(require_serve.getImportLog, {
		manual: true,
		onSuccess: (res) => {
			if (res.code == 200) {
				var _res$data;
				setList(((_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.list) || []);
			}
		}
	});
	const init = () => {
		const _defaultParams = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, defaultData), otherParams), {}, { url: apiUrl === null || apiUrl === void 0 ? void 0 : apiUrl.import_log });
		_historyList.run(_defaultParams);
	};
	(0, react.useEffect)(() => {
		init();
	}, [exportImport]);
	const columns = [
		{
			title: require_index.getText("table-action-export-import-log-name"),
			dataIndex: "file_name"
		},
		{
			title: require_index.getText("table-action-export-import-log-result"),
			dataIndex: "result",
			render: (text, record) => {
				var _record$result;
				return /* @__PURE__ */ react.default.createElement("div", null, require_index.getText("table-action-export-import-log-ok")((text === null || text === void 0 ? void 0 : text.success) || 0), (record === null || record === void 0 || (_record$result = record.result) === null || _record$result === void 0 ? void 0 : _record$result.fail) ? require_index.getText("table-action-export-import-log-err")((text === null || text === void 0 ? void 0 : text.fail) || 0) : null, (text === null || text === void 0 ? void 0 : text.fail) ? /* @__PURE__ */ react.default.createElement("a", {
					style: { marginLeft: "10px" },
					onClick: () => {
						var _detailRef$current, _detailRef$current$op;
						detailRef === null || detailRef === void 0 || (_detailRef$current = detailRef.current) === null || _detailRef$current === void 0 || (_detailRef$current$op = _detailRef$current.open) === null || _detailRef$current$op === void 0 || _detailRef$current$op.call(_detailRef$current, { list: [record] });
					}
				}, require_index.getText("table-action-export-import-log-check")) : null);
			}
		},
		{
			title: require_index.getText("table-action-export-import-file-account"),
			dataIndex: "account",
			render: (text) => {
				return text ? /* @__PURE__ */ react.default.createElement("div", null, `${(text === null || text === void 0 ? void 0 : text.first_name) || ""} ${(text === null || text === void 0 ? void 0 : text.last_name) || ""}`) : null;
			}
		},
		{
			title: require_index.getText("table-action-export-import-file-created"),
			dataIndex: "created_at",
			render: (text) => require_date.formatDate(text)
		}
	];
	return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", { className: "export-history-content" }, /* @__PURE__ */ react.default.createElement(antd.Spin, { spinning: _historyList === null || _historyList === void 0 ? void 0 : _historyList.loading }, /* @__PURE__ */ react.default.createElement("div", { className: "content-hint" }, require_index.getText("table-action-export-import-log-hint"), /* @__PURE__ */ react.default.createElement("a", { onClick: () => init() }, require_index.getText("table-action-export-import-file-refresh"))), /* @__PURE__ */ react.default.createElement(antd.Table, {
		rowClassName: "antd-table-row",
		columns,
		dataSource: list,
		pagination: false,
		rowKey: (record) => record.id,
		scroll: { x: true }
	}))), /* @__PURE__ */ react.default.createElement(require_Detail.default, { ref: detailRef }));
};
//#endregion
exports.default = ImportLog;
