const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_hooks = require("../hooks.js");
const require_locales = require("../locales.js");
const require_index = require("../components/CustomerAndCupModal/index.js");
const require_index$1 = require("../components/PageHeader/index.js");
const require_useColumns = require("./hooks/useColumns.js");
const require_const = require("./const.js");
const require_useCustomerApi = require("./hooks/useCustomerApi.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
let ahooks = require("ahooks");
require("./index.less");
//#region src/components/ecocup/customerList/index.tsx
const prefixCls = "ecocup-customer-list";
const PAGE_SIZE = 20;
function CustomerList(props) {
	const language = require_hooks.useLanguage();
	const [listParams, setListParams] = (0, react.useState)({
		skip: 1,
		num: PAGE_SIZE
	});
	_pisell_utils.locales.init(require_locales.default, language);
	const customerListModal = require_hooks.useModal("ecocup-customer-list-modal");
	const { loading, data, run } = require_useCustomerApi.useCustomerListsApi();
	const getLists = (0, react.useCallback)((params) => {
		run(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, listParams), params));
	}, [listParams]);
	(0, react.useEffect)(() => {
		getLists();
	}, [getLists]);
	console.log(data, "whasdf");
	const columns = require_useColumns.useColumns(_pisell_utils.locales);
	/**
	* @description: 值变化回调处理函数
	* @param {any} changedValues
	* @param {any} values
	* @return {*}
	*/
	const handleValuesChange = (changedValues, values) => {
		var _values$order_by, _values$pagination, _values$pagination2;
		console.log(changedValues, values, "changedValues234");
		const orderByTypes = values === null || values === void 0 || (_values$order_by = values.order_by) === null || _values$order_by === void 0 ? void 0 : _values$order_by.split(":");
		const params = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, (values === null || values === void 0 ? void 0 : values.filters) || {}), {}, {
			order_by: orderByTypes === null || orderByTypes === void 0 ? void 0 : orderByTypes[0],
			sort: orderByTypes === null || orderByTypes === void 0 ? void 0 : orderByTypes[1],
			skip: (values === null || values === void 0 || (_values$pagination = values.pagination) === null || _values$pagination === void 0 ? void 0 : _values$pagination.page) || 1,
			num: (values === null || values === void 0 || (_values$pagination2 = values.pagination) === null || _values$pagination2 === void 0 ? void 0 : _values$pagination2.size) || PAGE_SIZE
		});
		setListParams((prev) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, prev), params));
	};
	/**
	* @description: 值变化回调防抖处理函数
	* @return {*}
	*/
	const { run: handleValuesChangeDebounce } = (0, ahooks.useDebounceFn)(handleValuesChange, { wait: 200 });
	const handleClickRow = (record) => {
		customerListModal.open({
			title: _pisell_utils.locales.getText("pisell2.text.ecocup.customer.list.customer.profile"),
			data: {
				customerData: record,
				firstType: "customer"
			}
		});
	};
	return /* @__PURE__ */ react.default.createElement("div", { className: `${prefixCls}-container` }, /* @__PURE__ */ react.default.createElement(_pisell_materials.Table, {
		dataSource: (data === null || data === void 0 ? void 0 : data.list) || [],
		columns,
		align: "center",
		title: /* @__PURE__ */ react.default.createElement(require_index$1.default, { title: _pisell_utils.locales.getText("pisell2.text.ecocup.customer.list.title") }),
		pagination: {
			pageSize: PAGE_SIZE,
			total: (data === null || data === void 0 ? void 0 : data.count) || 0,
			size: "large"
		},
		columnSetting: require_const.COLUMN_SETTING,
		sort: require_const.SORT_SETTINGS,
		filter: require_const.FILTER(_pisell_utils.locales),
		loading,
		onValuesChange: handleValuesChangeDebounce,
		rowKey: "id",
		virtual: false,
		tableLayout: "",
		scroll: {
			scrollToFirstRowOnChange: true,
			autoCalc: true
		},
		onRow: (record) => {
			return {
				style: { cursor: "pointer" },
				onClick: () => handleClickRow(record)
			};
		}
	}), customerListModal.visible && /* @__PURE__ */ react.default.createElement(require_index.default, customerListModal.modalProps));
}
//#endregion
exports.default = CustomerList;
