You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

personalData.jsx 14 kB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. import { getAccessToken } from '@/access';
  2. import { addModel, getAssetIcon, getModelList } from '@/services/dataset/index.js';
  3. import { PlusCircleOutlined, UploadOutlined } from '@ant-design/icons';
  4. import { Button, Form, Input, Modal, Pagination, Radio, Select, Upload } from 'antd';
  5. import moment from 'moment';
  6. import { useEffect, useState } from 'react';
  7. import { useNavigate } from 'react-router-dom';
  8. import Styles from './index.less';
  9. const { Search } = Input;
  10. const leftdataList = [1, 2, 3];
  11. const PublicData = () => {
  12. const props = {
  13. action: '/api/mmp/dataset/upload',
  14. // headers: {
  15. // 'X-Requested-With': null
  16. // },
  17. headers: {
  18. Authorization: getAccessToken(),
  19. 'X-Requested-With': null,
  20. },
  21. onChange({ file, fileList }) {
  22. if (file.status !== 'uploading') {
  23. console.log(file, fileList);
  24. form.setFieldsValue({
  25. models_version_vos: fileList.map((item) => {
  26. const data = item.response.data[0];
  27. return {
  28. file_name: data.fileName,
  29. file_size: data.fileSize,
  30. url: data.url,
  31. };
  32. }),
  33. });
  34. }
  35. },
  36. defaultFileList: [],
  37. };
  38. const [queryFlow, setQueryFlow] = useState({
  39. page: 0,
  40. size: 20,
  41. name: null,
  42. available_range: 0,
  43. });
  44. const navgite = useNavigate();
  45. const [iconParams, setIconParams] = useState({
  46. name: null,
  47. page: 0,
  48. size: 10000,
  49. });
  50. const [activeType, setActiveType] = useState(null);
  51. const [activeTag, setActiveTag] = useState(null);
  52. const [datasetTypeList, setDatasetTypeList] = useState([]);
  53. const [datasetDirectionList, setDatasetDirectionList] = useState([]);
  54. const [isModalOpen, setIsModalOpen] = useState(false);
  55. const [datasetList, setDatasetList] = useState([]);
  56. const [total, setTotal] = useState(0);
  57. const [form] = Form.useForm();
  58. const [dialogTitle, setDialogTitle] = useState('新建模型');
  59. const [uuid, setUuid] = useState(Date.now());
  60. const getModelLists = (queryFlow) => {
  61. getModelList(queryFlow).then((ret) => {
  62. console.log(ret);
  63. if (ret.code == 200) {
  64. setDatasetList(ret.data.content);
  65. setTotal(ret.data.totalElements);
  66. }
  67. });
  68. };
  69. const showModal = () => {
  70. form.resetFields();
  71. setDialogTitle('新建模型');
  72. setUuid(Date.now());
  73. setIsModalOpen(true);
  74. };
  75. const getAssetIconList = (params) => {
  76. getAssetIcon(params).then((ret) => {
  77. console.log(ret);
  78. if (ret.code == 200 && ret.data.content && ret.data.content.length > 0) {
  79. setDatasetTypeList(ret.data.content.filter((item) => item.category_id == 3));
  80. setDatasetDirectionList(ret.data.content.filter((item) => item.category_id == 4));
  81. } else {
  82. setDatasetTypeList([]);
  83. setDatasetDirectionList([]);
  84. }
  85. });
  86. };
  87. const onSearch = (values) => {
  88. console.log(values);
  89. getAssetIconList({ ...iconParams, name: values });
  90. };
  91. const nameSearch = (values) => {
  92. console.log(values);
  93. getModelLists({ ...queryFlow, name: values });
  94. };
  95. const handleOk = () => {
  96. console.log(1111);
  97. setIsModalOpen(false);
  98. };
  99. const handleCancel = () => {
  100. setIsModalOpen(false);
  101. };
  102. const onFinish = (values) => {
  103. addModel(values).then((ret) => {
  104. console.log(ret);
  105. getModelLists(queryFlow);
  106. setIsModalOpen(false);
  107. });
  108. };
  109. const chooseModelType = (val, item) => {
  110. console.log(val, item);
  111. if (item.path == queryFlow.model_type) {
  112. setActiveType('');
  113. setQueryFlow({ ...queryFlow, model_type: null });
  114. getModelLists({ ...queryFlow, model_type: null });
  115. } else {
  116. setActiveType(item.path);
  117. setQueryFlow({ ...queryFlow, model_type: item.path });
  118. getModelLists({ ...queryFlow, model_type: item.path });
  119. }
  120. // setQueryFlow({...queryFlow,data_type:item.path},()=>{
  121. // getDatasetlist()
  122. // })
  123. };
  124. const chooseModelTag = (val, item) => {
  125. if (item.path == queryFlow.model_tag) {
  126. setActiveTag('');
  127. setQueryFlow({ ...queryFlow, model_tag: null });
  128. getModelLists({ ...queryFlow, model_tag: null });
  129. } else {
  130. setActiveTag(item.path);
  131. setQueryFlow({ ...queryFlow, model_tag: item.path });
  132. getModelLists({ ...queryFlow, model_tag: item.path });
  133. }
  134. // setQueryFlow({...queryFlow,data_type:item.path},()=>{
  135. // getDatasetlist()
  136. // })
  137. };
  138. const routeToIntro = (e, record) => {
  139. e.stopPropagation();
  140. console.log(record);
  141. navgite({ pathname: `/dataset/modelIntro/${record.id}` });
  142. };
  143. const onFinishFailed = (errorInfo) => {
  144. console.log('Failed:', errorInfo);
  145. };
  146. useEffect(() => {
  147. getAssetIconList(iconParams);
  148. getModelLists(queryFlow);
  149. return () => {};
  150. }, []);
  151. return (
  152. <>
  153. <div className={Styles.datasetCneterBox}>
  154. <div className={Styles.datasetCneterLeftBox}>
  155. <div className={Styles.leftContentBox}>
  156. <Search
  157. placeholder="搜索"
  158. allowClear
  159. onSearch={onSearch}
  160. style={{
  161. width: 300,
  162. marginBottom: '15px',
  163. }}
  164. />
  165. <div className={Styles.itemTitle}>模型框架</div>
  166. <div className={Styles.itemBox}>
  167. {datasetTypeList && datasetTypeList.length > 0
  168. ? datasetTypeList.map((item) => {
  169. return (
  170. <div>
  171. <div
  172. className={[
  173. Styles.messageBox,
  174. item.path === activeType ? Styles.active : null,
  175. ].join(' ')}
  176. onClick={(e) => {
  177. chooseModelType(e, item);
  178. }}
  179. >
  180. <img
  181. className={Styles.ptIcon}
  182. style={{ width: '22px' }}
  183. src={`/assets/images/model/${item.path}.png`}
  184. alt=""
  185. />
  186. <img
  187. className={Styles.hoverIcon}
  188. style={{ width: '22px' }}
  189. src={`/assets/images/model/${item.path}-hover.png`}
  190. alt=""
  191. />
  192. <span
  193. className={Styles.messageText}
  194. onClick={(e) => {
  195. chooseModelTag(e, item);
  196. }}
  197. >
  198. {item.name}
  199. </span>
  200. </div>
  201. </div>
  202. );
  203. })
  204. : ''}
  205. </div>
  206. <div className={Styles.itemTitle}>模型能力</div>
  207. <div className={Styles.itemBox}>
  208. {datasetDirectionList && datasetDirectionList.length > 0
  209. ? datasetDirectionList.map((item) => {
  210. return (
  211. <div>
  212. <div
  213. className={[
  214. Styles.messageBox,
  215. item.path === activeTag ? Styles.active : null,
  216. ].join(' ')}
  217. onClick={(e) => {
  218. chooseModelTag(e, item);
  219. }}
  220. >
  221. <img
  222. className={Styles.ptIcon}
  223. style={{ width: '22px' }}
  224. src={`/assets/images/model/${item.path}.png`}
  225. alt=""
  226. />
  227. <img
  228. className={Styles.hoverIcon}
  229. style={{ width: '22px' }}
  230. src={`/assets/images/model/${item.path}-hover.png`}
  231. alt=""
  232. />
  233. <span className={Styles.messageText}>{item.name}</span>
  234. </div>
  235. </div>
  236. );
  237. })
  238. : ''}
  239. </div>
  240. </div>
  241. </div>
  242. <div className={Styles.datasetCneterRightBox}>
  243. <div className={Styles.dataSource}>
  244. <span>数据总数:{total}个</span>
  245. <div>
  246. <Search
  247. placeholder="按模型名称筛选"
  248. allowClear
  249. onSearch={nameSearch}
  250. style={{
  251. width: 300,
  252. }}
  253. />
  254. <Button
  255. type="primary"
  256. className={Styles.plusButton}
  257. onClick={showModal}
  258. icon={<PlusCircleOutlined style={{ color: '#1664ff' }} />}
  259. >
  260. 模型注册
  261. </Button>
  262. </div>
  263. </div>
  264. <div className={Styles.dataContent}>
  265. {datasetList && datasetList.length > 0
  266. ? datasetList.map((item) => {
  267. return (
  268. <div className={Styles.dataItem} onClick={(e) => routeToIntro(e, item)}>
  269. <div className={Styles.itemText}>{item.name}</div>
  270. <div className={Styles.itemTime}>
  271. <span>最近更新: {moment(item.update_time).format('YYYY-MM-DD')}</span>
  272. </div>
  273. <div className={Styles.itemIcon}>
  274. <img
  275. style={{ width: '17px', marginRight: '3px' }}
  276. src={`/assets/images/upload-icon.png`}
  277. alt=""
  278. />
  279. <span>1582</span>
  280. </div>
  281. </div>
  282. );
  283. })
  284. : ''}
  285. {/* <Select.Option value="demo">Demo</Select.Option> */}
  286. </div>
  287. <Pagination size="small" total={total} showSizeChanger showQuickJumper />
  288. </div>
  289. </div>
  290. <Modal
  291. title={
  292. <div style={{ display: 'flex', alignItems: 'center', fontWeight: 500 }}>
  293. <img
  294. style={{ width: '20px', marginRight: '10px' }}
  295. src={`/assets/images/pipeline-edit-icon.png`}
  296. alt=""
  297. />
  298. {dialogTitle}
  299. </div>
  300. }
  301. open={isModalOpen}
  302. className={Styles.modal}
  303. okButtonProps={{
  304. htmlType: 'submit',
  305. form: 'form',
  306. }}
  307. onCancel={handleCancel}
  308. >
  309. <Form
  310. name="form"
  311. form={form}
  312. layout="vertical"
  313. initialValues={{
  314. remember: true,
  315. }}
  316. onFinish={onFinish}
  317. onFinishFailed={onFinishFailed}
  318. autoComplete="off"
  319. >
  320. <Form.Item
  321. label="模型名称"
  322. name="name"
  323. rules={[
  324. {
  325. required: true,
  326. message: '请输入模型名称!',
  327. },
  328. ]}
  329. >
  330. <Input placeholder="请输入模型名称" showCount maxLength={64} />
  331. </Form.Item>
  332. <Form.Item
  333. label="模型版本"
  334. name="version"
  335. rules={
  336. [
  337. // {
  338. // required: true,
  339. // message: 'Please input your username!',
  340. // },
  341. ]
  342. }
  343. >
  344. <Input placeholder="请输入模型版本" />
  345. </Form.Item>
  346. <Form.Item
  347. label="模型描述"
  348. name="description"
  349. rules={[
  350. {
  351. required: true,
  352. message: '请输入模型描述!',
  353. },
  354. ]}
  355. >
  356. <Input placeholder="请输入模型描述" showCount maxLength={256} />
  357. </Form.Item>
  358. <Form.Item label="可见范围" name="available_range">
  359. <Radio.Group>
  360. <Radio value="0">仅自己可见</Radio>
  361. <Radio value="1">工作空间可见</Radio>
  362. </Radio.Group>
  363. </Form.Item>
  364. <Form.Item
  365. label="模型框架"
  366. name="model_type"
  367. rules={
  368. [
  369. // {
  370. // required: true,
  371. // message: 'Please input your username!',
  372. // },
  373. ]
  374. }
  375. >
  376. <Select allowClear placeholder="请选择模型类型" options={[]} />
  377. </Form.Item>
  378. <Form.Item
  379. label="模型能力"
  380. name="model_tag"
  381. rules={
  382. [
  383. // {
  384. // required: true,
  385. // message: 'Please input your username!',
  386. // },
  387. ]
  388. }
  389. >
  390. <Select allowClear placeholder="请选择模型标签" options={[]} />
  391. </Form.Item>
  392. <Form.Item label="模型文件" name="models_version_vos">
  393. <Upload {...props} data={{ uuid: uuid }}>
  394. <Button
  395. style={{
  396. fontSize: '14px',
  397. border: '1px solid',
  398. borderColor: '#1664ff',
  399. background: '#fff',
  400. }}
  401. icon={<UploadOutlined style={{ color: '#1664ff', fontSize: '14px' }} />}
  402. >
  403. 上传文件
  404. </Button>
  405. </Upload>
  406. </Form.Item>
  407. </Form>
  408. </Modal>
  409. </>
  410. );
  411. };
  412. export default PublicData;