Commit f9f8fb6e authored by wuhao's avatar wuhao 🎯

ader

parent f3792e17
......@@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite",
"":"",
"": "",
"build": "vite build",
"preview": "vite preview"
},
......@@ -23,6 +23,7 @@
"@mui/material": "^5.11.16",
"@mui/styled-engine-sc": "^5.11.11",
"@reduxjs/toolkit": "^1.9.3",
"ahooks": "^3.7.6",
"apexcharts": "^3.37.0",
"change-case": "^4.1.2",
"date-fns": "^2.29.3",
......@@ -37,6 +38,7 @@
"react-helmet-async": "^1.3.0",
"react-hook-form": "^7.43.1",
"react-redux": "^8.0.5",
"react-resizable": "^3.0.5",
"react-router-dom": "^6.9.0",
"react-scripts": "^5.0.1",
"redux": "^4.2.1",
......
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36"><path fill="#637381" d="M9.8 18.8h16.4v3.08h1.6V17.2h-9V14h-1.6v3.2h-9v4.68h1.6V18.8z" class="clr-i-solid clr-i-solid-path-1"/><rect width="14" height="10" x="2" y="23" fill="#637381" class="clr-i-solid clr-i-solid-path-2" rx="2" ry="2"/><rect width="14" height="10" x="20" y="23" fill="#637381" class="clr-i-solid clr-i-solid-path-3" rx="2" ry="2"/><rect width="14" height="10" x="11" y="3" fill="#637381" class="clr-i-solid clr-i-solid-path-4" rx="2" ry="2"/><path fill="none" d="M0 0h36v36H0z"/></svg>
\ No newline at end of file
import React, { Component } from 'react';
import { Resizable } from 'react-resizable';
function Resizecell({ onResize, onResizeStop, width, onClick, ...restProps }) {
return (
<Resizable width={width ?? 1} height={0} onResize={onResize} onResizeStop={onResizeStop}>
<th {...restProps} />
</Resizable>
);
}
export default Resizecell;
/* eslint-disable react-hooks/exhaustive-deps */
/* eslint-disable react-hooks/rules-of-hooks */
import React, { useEffect, useRef, useState, memo, useMemo } from 'react';
import { ProTable } from '@ant-design/pro-components';
import Resizecell from './Resizecell';
import { Tooltip } from '@mui/material';
import { doFetch } from '@/utils/doFetch';
import { useAsyncEffect } from 'ahooks';
let handlEmptyChild = (tree = []) => {
const newtree = tree.map((item) => {
if (!item.children || item.children.length == 0) {
item.value = item.key;
return item;
} else {
item.value = item.key;
return {
...item,
children: handlEmptyChild(item.children),
};
}
});
return newtree;
};
const Mtable = (props) => {
const {
actionRef, //表格动作
formRef, //表单Ref
rowKey, // key
columns = [], //columns
style, //style
path, //接口地址
extraparams, //额外参数
pageSize, //修改默认pageSize
pagination, //分页设置
x, //横向滚动
activeTabKey, //激活的tabKey 拖拽表格唯一标识使用 其他情况用不到
refreshDep, //依赖刷新 (已废弃)
resizeable = true,
iscurrent = true,
} = props;
const actionRefs = actionRef ?? useRef(),
formRefs = formRef ?? useRef(),
ifspagination = pagination == 'false' || pagination === false,
[size, setsize] = useState('small'),
[valueColumns, setvalueColumns] = useState({});
const [columnes, setcolumnes] = useState(
columns?.filter?.((it) => it.valueType != 'split') ?? [],
);
const [newparames, setnewparams] = useState({});
//调用接口
const request = async (params, sort, filter) => {
if (!path) return;
let newparams = {
...params,
...extraparams, //父组件传参
pageIndex: params.current,
pageSize: params.pageSize || pageSize,
};
delete newparams.current;
if (ifspagination) {
delete newparams.pageIndex;
delete newparams.pageSize;
}
const result = await doFetch({ url: path, params: newparams });
//分页结果
let data = result?.data?.page?.list,
success = true,
total = result?.data?.page?.total;
//不带分页获取结果
if (ifspagination) {
data = result?.data?.dataList;
total = result?.data?.dataList?.length;
}
return {
data,
success,
total,
};
};
function changeColumns(allcol = {}) {
setcolumnes((s) => {
return s
.filter((it) => it.valueType != 'split')
.map((item, index) => {
let it = { ...item },
curkey = it?.key ?? it?.dataIndex;
if (it.valueType == 'option') {
curkey = 'option';
}
let itemwidth = allcol[curkey]?.width
? allcol[curkey].width
: it.width
? it.width
: resizeable
? 160
: 'auto';
let options = {};
if (['select', 'treeSelect', 'radio', 'checkbox', 'cascader'].includes(it?.valueType)) {
if (Array.isArray(it.options)) {
options = {
fieldProps: {
...it?.fieldProps,
options: [...it.options],
},
};
} else if (it.options) {
options = {
params: newparames,
request: async (params) => {
if (Object.keys(it?.options).includes('linkParams')) {
let list = await doFetch({ url: it?.options?.path, params: newparames });
const res = list.data.dataList;
return it.valueType == 'treeSelect' ? handlEmptyChild(res) : res;
} else {
let list = await doFetch({
url: it?.options?.path,
params: it?.options?.params,
});
const res = list.data.dataList;
return it.valueType == 'treeSelect' ? handlEmptyChild(res) : res;
}
},
};
}
}
if (it.valueType == 'option') {
options = {
key: 'option',
dataIndex: 'option',
fixed: 'right',
};
}
if (!it.render) {
options = {
...options,
render: (text, row) => {
return (
<Tooltip title={row[it.dataIndex]}>
<span className="table-cell">{row[it.dataIndex] ?? '-'}</span>
</Tooltip>
);
},
};
}
options = {
...options,
width: itemwidth,
};
delete it.formItemProps;
return {
...it,
...options,
onHeaderCell: (column) => ({
width: column.width ?? itemwidth,
onResize: handleResize(index),
onResizeStop: handleResizeStop(index),
}),
};
});
});
}
//初始化操作数据
const initDrage = async () => {
if (!path) return;
let res = await doFetch({
url: '/ngic-base-business/paFieldScene/queryContro',
params: {
sceneMark: activeTabKey ? path + activeTabKey : path,
},
});
if (res.code == '0000') {
//datalist:接口返回状态
let datalist = {};
res?.data?.dataList &&
res.data.dataList.map((it) => {
const { fieldKey, fieldWidth, fieldOrder, fieldFixed, fieldShow } = it ?? {};
datalist[fieldKey] = {
width: fieldWidth,
order: fieldOrder,
fixed: fieldKey == 'option' || fieldKey == 'option_dataindex' ? 'right' : fieldFixed,
show: fieldShow,
};
});
//allcol 默认状态设置 valueColumns 为columns全列设置
let allcol = {};
columns
.filter((it) => it.valueType != 'split')
.map((it, i) => {
if (it.valueType == 'option') {
allcol.option = {
order: columns.length - 1,
show: true,
fixed: 'right',
...datalist.option,
};
} else {
allcol[it.key ?? it.dataIndex] = {
order: i,
show: true,
...datalist[it.key ?? it.dataIndex],
};
}
});
setvalueColumns(allcol);
return allcol;
}
};
//调用重新渲染表格
useAsyncEffect(async () => {
let allcol = {};
if (resizeable) {
allcol = await initDrage();
}
changeColumns(allcol);
iscurrent && actionRefs?.current?.reload();
}, [columns, extraparams, path, activeTabKey, refreshDep, iscurrent]);
//缩放表格
const handleResize =
(index) =>
(e, { size }) => {
e.stopImmediatePropagation();
setcolumnes((s) => {
const nextColumns = [...s];
nextColumns[index] = {
...nextColumns[index],
width: size.width,
};
return nextColumns;
});
};
//更新表格缩放
const handleResizeStop =
(index) =>
(e, { size }) => {
e.stopImmediatePropagation();
setvalueColumns((s) => {
let submitdata = { ...s } ?? {},
curkey = columnes[index]?.key ?? columnes[index]?.dataIndex;
console.log(curkey, size.width);
if (!curkey) return;
submitdata[curkey] = submitdata[curkey] ?? {};
submitdata[curkey].width = parseInt(size.width);
delete submitdata['undefined'];
doFetch({
url: '/ngic-base-business/paFieldScene/save',
params: {
sceneMark: activeTabKey ? path + activeTabKey : path,
controList: Object.keys(submitdata).map((it, i) => {
return {
fieldKey: it,
fieldWidth: submitdata[it].width,
fieldOrder: submitdata[it].order,
fieldFixed: submitdata[it].fixed,
fieldShow: submitdata[it].show,
};
}),
},
});
return submitdata;
});
};
const components = resizeable
? {
components: {
header: {
cell: Resizecell,
},
},
columnsState: {
value: valueColumns,
onChange: (val, state) => {
setvalueColumns((s) => {
let submitdata = {
...s,
...val,
};
doFetch({
url: '/ngic-base-business/paFieldScene/save',
params: {
sceneMark: activeTabKey ? path + activeTabKey : path,
controList: Object.keys(submitdata).map((it) => {
return {
fieldKey: it,
fieldWidth: submitdata[it].width,
fieldOrder: submitdata[it].order,
fieldFixed: submitdata[it].fixed,
fieldShow: submitdata[it].show,
};
}),
},
});
return submitdata;
});
},
},
}
: {};
return (
<ProTable
{...props}
{...components}
size={size}
onSubmit={(params) => {
let newparams = {};
columns.map((it, i) => {
if (
it?.options?.linkParams &&
Object.keys(it?.options?.linkParams).includes(Object.keys(params)[0])
) {
for (let dataindex in it?.options?.linkParams) {
newparams[dataindex] = formRefs?.current?.getFieldValue?.(dataindex);
}
}
});
setnewparams(newparams);
}}
onSizeChange={(size) => {
localStorage.setItem('size', size); //设置全局表格规格缓存
setsize(size);
}}
columns={columnes ?? []}
style={style || {}}
actionRef={actionRefs}
formRef={formRefs}
rowKey={rowKey ?? 'id'} //表格每行数据的key
dateFormatter="string"
request={request}
scroll={
x
? {
x: x,
}
: {
x: 1500,
}
}
pagination={
ifspagination
? false
: {
showTotal: (total, range) => <span>{total}</span>,
showQuickJumper: true,
showSizeChanger: true,
pageSizeOptions: [5, 10, 15, 30, 50, 100, 200],
defaultPageSize: pageSize || 15,
}
}
search={{
filterType: 'light', //轻量模式
}}
/>
);
};
export default memo(Mtable);
......@@ -82,6 +82,11 @@ const navConfig = [
path: "/dashboard/app",
icon: icon("ic_analytics"),
},
{
title: "组织管理",
path: "/dashboard/organization",
icon: icon("ic_org"),
},
{
title: "教师管理",
path: "/dashboard/blog",
......
import React, { useState, useEffect } from 'react';
function Organization() {
return (
<div>
organization
</div>
);
}
export default Organization;
\ No newline at end of file
......@@ -21,7 +21,8 @@ const LoginPage = loadable(() => import("./pages/LoginPage"));
const Page404 = loadable(() => import("./pages/Page404"));
const ProductsPage = loadable(() => import("./pages/ProductsPage"));
const DashboardAppPage = loadable(() => import("./pages/DashboardAppPage"));
// const SimpleLayout = loadable(() => import());
const Organization = loadable(() => import("./pages/organization"));
// const SimpleLayout = loadable(() => import());
// const SimpleLayout = loadable(() => import());
// const SimpleLayout = loadable(() => import());
......@@ -66,6 +67,10 @@ const router = createHashRouter([
path: "home",
element: <Home />,
},
{
path: "organization",
element: <Organization />,
},
],
},
// {
......
......@@ -2665,6 +2665,11 @@
dependencies:
"@types/istanbul-lib-report" "*"
"@types/js-cookie@^2.x.x":
version "2.2.7"
resolved "https://registry.npmmirror.com/@types/js-cookie/-/js-cookie-2.2.7.tgz#226a9e31680835a6188e887f3988e60c04d3f6a3"
integrity sha512-aLkWa0C0vO5b4Sr798E26QgOkss68Un0bLjs7u9qxzPT5CG+8DuNTffWES58YzJs3hrVAOs1wonycqEBqNJubA==
"@types/json-schema@*", "@types/json-schema@^7.0.4", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9":
version "7.0.11"
resolved "https://registry.npmmirror.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3"
......@@ -3163,6 +3168,27 @@ agent-base@6:
dependencies:
debug "4"
ahooks-v3-count@^1.0.0:
version "1.0.0"
resolved "https://registry.npmmirror.com/ahooks-v3-count/-/ahooks-v3-count-1.0.0.tgz#ddeb392e009ad6e748905b3cbf63a9fd8262ca80"
integrity sha512-V7uUvAwnimu6eh/PED4mCDjE7tokeZQLKlxg9lCTMPhN+NjsSbtdacByVlR1oluXQzD3MOw55wylDmQo4+S9ZQ==
ahooks@^3.7.6:
version "3.7.6"
resolved "https://registry.npmmirror.com/ahooks/-/ahooks-3.7.6.tgz#4fdbe3be421775844bd64ab17c9c170424675247"
integrity sha512-p+2j4H/BI9vqXR0fZI7S/q6fUPxPklQnHqvU7zAVBljMFNSFeYRWB2iHHbjpXGOwUTOBYCh2OuvIHyJYj6Lpag==
dependencies:
"@babel/runtime" "^7.21.0"
"@types/js-cookie" "^2.x.x"
ahooks-v3-count "^1.0.0"
dayjs "^1.9.1"
intersection-observer "^0.12.0"
js-cookie "^2.x.x"
lodash "^4.17.21"
resize-observer-polyfill "^1.5.1"
screenfull "^5.0.0"
tslib "^2.4.1"
ajv-formats@^2.1.1:
version "2.1.1"
resolved "https://registry.npmmirror.com/ajv-formats/-/ajv-formats-2.1.1.tgz#6e669400659eb74973bbf2e33327180a0996b520"
......@@ -3887,7 +3913,7 @@ cliui@^7.0.2:
strip-ansi "^6.0.0"
wrap-ansi "^7.0.0"
clsx@^1.2.1:
clsx@^1.1.1, clsx@^1.2.1:
version "1.2.1"
resolved "https://registry.npmmirror.com/clsx/-/clsx-1.2.1.tgz#0ddc4a20a549b59c93a4116bb26f5294ca17dc12"
integrity sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==
......@@ -4361,7 +4387,7 @@ date-fns@^2.29.3:
resolved "https://registry.npmmirror.com/date-fns/-/date-fns-2.29.3.tgz#27402d2fc67eb442b511b70bbdf98e6411cd68a8"
integrity sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==
dayjs@^1.11.4:
dayjs@^1.11.4, dayjs@^1.9.1:
version "1.11.7"
resolved "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.7.tgz#4b296922642f70999544d1144a2c25730fce63e2"
integrity sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ==
......@@ -5969,6 +5995,11 @@ internal-slot@^1.0.3, internal-slot@^1.0.4, internal-slot@^1.0.5:
has "^1.0.3"
side-channel "^1.0.4"
intersection-observer@^0.12.0:
version "0.12.2"
resolved "https://registry.npmmirror.com/intersection-observer/-/intersection-observer-0.12.2.tgz#4a45349cc0cd91916682b1f44c28d7ec737dc375"
integrity sha512-7m1vEcPCxXYI8HqnL8CKI6siDyD+eIWSwgB3DZA+ZTogxk9I4CDnj4wilt9x/+/QbHI4YG5YZNmC6458/e9Ktg==
invariant@^2.2.4:
version "2.2.4"
resolved "https://registry.npmmirror.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6"
......@@ -6787,6 +6818,11 @@ jiti@^1.17.2:
resolved "https://registry.npmmirror.com/jiti/-/jiti-1.18.2.tgz#80c3ef3d486ebf2450d9335122b32d121f2a83cd"
integrity sha512-QAdOptna2NYiSSpv0O/BwoHBSmz4YhpzJHyi+fnMRTXFjp7B8i/YG5Z8IfusxB1ufjcD2Sre1F3R+nX3fvy7gg==
js-cookie@^2.x.x:
version "2.2.1"
resolved "https://registry.npmmirror.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8"
integrity sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ==
js-sdsl@^4.1.4:
version "4.4.0"
resolved "https://registry.npmmirror.com/js-sdsl/-/js-sdsl-4.4.0.tgz#8b437dbe642daa95760400b602378ed8ffea8430"
......@@ -8379,7 +8415,7 @@ prompts@^2.0.1, prompts@^2.4.2:
kleur "^3.0.3"
sisteransi "^1.0.5"
prop-types@^15.5.10, prop-types@^15.5.7, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1:
prop-types@15.x, prop-types@^15.5.10, prop-types@^15.5.7, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1:
version "15.8.1"
resolved "https://registry.npmmirror.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
......@@ -8577,6 +8613,14 @@ react-dom@^18.2.0:
loose-envify "^1.1.0"
scheduler "^0.23.0"
react-draggable@^4.0.3:
version "4.4.5"
resolved "https://registry.npmmirror.com/react-draggable/-/react-draggable-4.4.5.tgz#9e37fe7ce1a4cf843030f521a0a4cc41886d7e7c"
integrity sha512-OMHzJdyJbYTZo4uQE393fHcqqPYsEtkjfMgvCHr6rejT+Ezn4OZbNyGH50vv+SunC1RMvwOTSWkEODQLzw1M9g==
dependencies:
clsx "^1.1.1"
prop-types "^15.8.1"
react-error-overlay@^6.0.11:
version "6.0.11"
resolved "https://registry.npmmirror.com/react-error-overlay/-/react-error-overlay-6.0.11.tgz#92835de5841c5cf08ba00ddd2d677b6d17ff9adb"
......@@ -8645,6 +8689,14 @@ react-refresh@^0.14.0:
resolved "https://registry.npmmirror.com/react-refresh/-/react-refresh-0.14.0.tgz#4e02825378a5f227079554d4284889354e5f553e"
integrity sha512-wViHqhAd8OHeLS/IRMJjTSDHF3U9eWi62F/MledQGPdJGDhodXJ9PBLNGr6WWL7qlH12Mt3TyTpbS+hGXMjCzQ==
react-resizable@^3.0.5:
version "3.0.5"
resolved "https://registry.npmmirror.com/react-resizable/-/react-resizable-3.0.5.tgz#362721f2efbd094976f1780ae13f1ad7739786c1"
integrity sha512-vKpeHhI5OZvYn82kXOs1bC8aOXktGU5AmKAgaZS4F5JPburCtbmDPqE7Pzp+1kN4+Wb81LlF33VpGwWwtXem+w==
dependencies:
prop-types "15.x"
react-draggable "^4.0.3"
react-router-dom@^6.9.0:
version "6.9.0"
resolved "https://registry.npmmirror.com/react-router-dom/-/react-router-dom-6.9.0.tgz#dd8b4e461453bd4cad2e6404493d1a5b4bfea758"
......@@ -9102,6 +9154,11 @@ schema-utils@^4.0.0:
ajv-formats "^2.1.1"
ajv-keywords "^5.0.0"
screenfull@^5.0.0:
version "5.2.0"
resolved "https://registry.npmmirror.com/screenfull/-/screenfull-5.2.0.tgz#6533d524d30621fc1283b9692146f3f13a93d1ba"
integrity sha512-9BakfsO2aUQN2K9Fdbj87RJIEZ82Q9IGim7FqM5OsebfoFC6ZHXgDq/KvniuLTPdeM8wY2o6Dj3WQ7KeQCj3cA==
select-hose@^2.0.0:
version "2.0.0"
resolved "https://registry.npmmirror.com/select-hose/-/select-hose-2.0.0.tgz#625d8658f865af43ec962bfc376a37359a4994ca"
......@@ -9956,7 +10013,7 @@ tslib@^1.8.1:
resolved "https://registry.npmmirror.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
tslib@^2.0.3, tslib@^2.3.0:
tslib@^2.0.3, tslib@^2.3.0, tslib@^2.4.1:
version "2.5.0"
resolved "https://registry.npmmirror.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf"
integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment