@aliretail/react-materials-components
Version:
95 lines (85 loc) • 2.79 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import * as React from 'react';
import { AliretailTableContainer, AliretailTable } from "../../../Tablex";
import { getListCt, COM_PREFIX } from "../../properties";
export default (function (props) {
var appCode = props.appCode,
apiCode = props.apiCode,
url = props.url,
traceId = props.traceId,
params = props.params;
var _React$useState = React.useState('id'),
primaryKey = _React$useState[0];
var _React$useState2 = React.useState([]),
dataSource = _React$useState2[0],
setDataSource = _React$useState2[1];
var _React$useState3 = React.useState(true),
loading = _React$useState3[0],
setLoading = _React$useState3[1];
var getCt = /*#__PURE__*/function () {
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
var res;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
setLoading(true);
_context.prev = 1;
_context.next = 4;
return getListCt({
appCode: appCode,
apiCode: apiCode,
url: url
}, _extends({
traceId: traceId
}, params));
case 4:
res = _context.sent;
setDataSource((res === null || res === void 0 ? void 0 : res.result) || []);
_context.next = 11;
break;
case 8:
_context.prev = 8;
_context.t0 = _context["catch"](1);
console.warn(_context.t0);
case 11:
setLoading(false);
case 12:
case "end":
return _context.stop();
}
}
}, _callee, null, [[1, 8]]);
}));
return function getCt() {
return _ref.apply(this, arguments);
};
}();
React.useEffect(function () {
getCt();
}, []);
return /*#__PURE__*/React.createElement(AliretailTableContainer, {
dataSource: dataSource,
primaryKey: primaryKey,
className: COM_PREFIX + "-table-child",
loading: loading,
columns: [{
title: '操作类型',
dataIndex: 'operateType'
}, {
title: '操作对象',
dataIndex: 'operateObject'
}, {
title: '属性ID',
dataIndex: 'fieldName'
}, {
title: '原字段',
dataIndex: 'beforeValue'
}, {
title: '新字段',
dataIndex: 'afterValue'
}]
}, /*#__PURE__*/React.createElement(AliretailTable, null));
});