nili
3 years ago
17 changed files with 291 additions and 129 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@ |
|||
(self.webpackChunkant_design_pro=self.webpackChunkant_design_pro||[]).push([[816],{51975:function(q,O,n){"use strict";n.r(O),n.d(O,{default:function(){return L}});var _=n(57663),b=n(71577),v=n(3182),c=n(11849),I=n(93224),C=n(94043),p=n.n(C),R=n(4614);function P(a,r){return y.apply(this,arguments)}function y(){return y=(0,v.Z)(p().mark(function a(r,t){return p().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,R.WY)("/api/luigi/author/seek",(0,c.Z)({method:"GET",params:(0,c.Z)({},r)},t||{})));case 1:case"end":return e.stop()}},a)})),y.apply(this,arguments)}var m=n(67294),ee=n(43358),G=n(34041),te=n(20228),U=n(11382),$=n(57337),A=n(23279),F=n.n(A),h=n(85893);function B(a){var r=a.fetchOptions,t=a.debounceTimeout,u=t===void 0?800:t,e=a.initOption,i=(0,I.Z)(a,["fetchOptions","debounceTimeout","initOption"]),d=m.useState(!1),l=(0,$.Z)(d,2),f=l[0],o=l[1],s=[],g=null;if(e&&typeof e=="string"){var j=JSON.parse(e);s.push(j),g=j.value}var Y=m.useState(s),x=(0,$.Z)(Y,2),w=x[0],E=x[1],Z=m.useRef(0),M=m.useMemo(function(){var H=function(Q){Z.current+=1;var X=Z.current;E([]),o(!0),r(Q).then(function(k){X===Z.current&&(E(k),o(!1))})};return F()(H,u)},[r,u]);return(0,h.jsx)(G.Z,(0,c.Z)((0,c.Z)({showSearch:!0,labelInValue:!0,filterOption:!1,defaultValue:g,onSearch:M,notFoundContent:f?(0,h.jsx)(U.Z,{size:"small"}):null},i),{},{options:w}))}var D=B,z=function(r){return(0,h.jsx)(D,{initOption:r.value,fetchOptions:function(){var t=(0,v.Z)(p().mark(function u(e){var i,d,l;return p().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,P({name:e});case 2:if(d=o.sent,!((i=d.data)!==null&&i!==void 0&&i.list)){o.next=5;break}return o.abrupt("return",(l=d.data.list)===null||l===void 0?void 0:l.map(function(s){var g={label:s.name,value:s.id,key:s.id};return g}));case 5:return o.abrupt("return",void 0);case 6:case"end":return o.stop()}},u)}));return function(u){return t.apply(this,arguments)}}(),onChange:function(u){r.onChange(u)},style:{width:"100%"}})},W=z;function ne(a,r){return S.apply(this,arguments)}function S(){return S=_asyncToGenerator(_regeneratorRuntime.mark(function a(r,t){return _regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",request("/api/luigi/poem/detail",_objectSpread({method:"GET",params:_objectSpread({},r)},t||{})));case 1:case"end":return e.stop()}},a)})),S.apply(this,arguments)}function N(a,r){return T.apply(this,arguments)}function T(){return T=(0,v.Z)(p().mark(function a(r,t){return p().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,R.WY)("/api/luigi/poem/list",(0,c.Z)({method:"POST",headers:{"Content-Type":"application/json"},data:r},t||{})));case 1:case"end":return e.stop()}},a)})),T.apply(this,arguments)}var V=n(49101),J=n(99542),K=[{dataIndex:"index",valueType:"indexBorder",width:48},{title:"\u6807\u9898",dataIndex:"title",ellipsis:!0,hideInSearch:!0,tip:"\u6807\u9898\u8FC7\u957F\u4F1A\u81EA\u52A8\u6536\u7F29",formItemProps:{rules:[{required:!0,message:"\u6B64\u9879\u4E3A\u5FC5\u586B\u9879"}]}},{title:"\u72B6\u6001",dataIndex:"status",valueType:"select",valueEnum:{0:{text:"\u672A\u6821\u51C6",status:"Error"},1:{text:"\u5DF2\u6821\u51C6",status:"Success"}}},{title:"\u4F5C\u8005",dataIndex:"authorName",hideInSearch:!0},{title:"\u4F5C\u8005",dataIndex:"author",hideInTable:!0,formItemProps:{rules:[{required:!0,message:"\u6B64\u9879\u4E3A\u5FC5\u586B\u9879"}]},renderFormItem:function(r,t){var u=t.type,e=t.defaultRender,i=(0,I.Z)(t,["type","defaultRender"]);return(0,h.jsx)(W,(0,c.Z)({},i))}},{title:"\u9996\u884C",dataIndex:"line",hideInSearch:!0}],L=function(){var a=(0,m.useRef)();return(0,h.jsx)(J.ZP,{columns:K,actionRef:a,cardBordered:!0,request:(0,v.Z)(p().mark(function r(){var t,u,e,i,d,l,f=arguments;return p().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return e=f.length>0&&f[0]!==void 0?f[0]:{},i=[],e.author&&(d=e.author,typeof e.author=="string"&&(d=JSON.parse(e.author)),i.push({key:"authorId",val:d.value})),e.status&&i.push({key:"status",val:e.status}),s.next=6,N({current:e.current,pageSize:e.pageSize,query:i});case 6:return l=s.sent,s.abrupt("return",{data:(t=l.data)===null||t===void 0?void 0:t.list,total:(u=l.data)===null||u===void 0?void 0:u.total});case 8:case"end":return s.stop()}},r)})),editable:{type:"multiple"},columnsState:{persistenceKey:"pro-table-singe-demos",persistenceType:"localStorage",onChange:function(t){console.log("value: ",t)}},rowKey:"id",search:{labelWidth:"auto"},form:{syncToUrl:function(t,u){return u==="get"?(0,c.Z)((0,c.Z)({},t),{},{created_at:[t.startTime,t.endTime]}):t}},pagination:{pageSize:5},dateFormatter:"string",headerTitle:"\u9AD8\u7EA7\u8868\u683C",toolBarRender:function(){return[(0,h.jsx)(b.Z,{icon:(0,h.jsx)(V.Z,{}),type:"primary",children:"\u65B0\u5EFA"},"button")]}})}}}]); |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,78 @@ |
|||
import AuthorSelect from '@/components/AuthorSelect'; |
|||
import { DrawerForm, ProFormText, ProFormTextArea } from '@ant-design/pro-form'; |
|||
import { Button, Form, message } from 'antd'; |
|||
import React, { useRef } from 'react'; |
|||
|
|||
import { poemDetailUsingGET, savePoemUsingPOST } from '@/services/luigi/poem'; |
|||
|
|||
import type { ProFormInstance } from '@ant-design/pro-form'; |
|||
|
|||
const PoemForm: React.FC<{ |
|||
triggerText: string; |
|||
formTitle: string; |
|||
poemId?: number; |
|||
refresh?: () => void; |
|||
}> = (props) => { |
|||
const formRef = useRef<ProFormInstance<API.PoemBo>>(); |
|||
return ( |
|||
<DrawerForm<API.PoemBo> |
|||
title={props.formTitle} |
|||
formRef={formRef} |
|||
layout="horizontal" |
|||
trigger={<Button type="primary">{props.triggerText}</Button>} |
|||
autoFocusFirstInput |
|||
drawerProps={{ |
|||
destroyOnClose: true, |
|||
}} |
|||
onVisibleChange={async (visible: boolean) => { |
|||
if (!visible || !props.poemId) { |
|||
return; |
|||
} |
|||
const response = await poemDetailUsingGET({ id: props.poemId }); |
|||
if (response.data) { |
|||
formRef.current?.setFieldsValue(response.data); |
|||
} |
|||
}} |
|||
onFinish={async (values) => { |
|||
const rsp = await savePoemUsingPOST({ ...values, id: props.poemId }); |
|||
if (rsp.code) { |
|||
message.success('提交成功'); |
|||
if (props.refresh) { |
|||
props.refresh(); |
|||
} |
|||
return true; |
|||
} |
|||
return false; |
|||
}} |
|||
> |
|||
<ProFormText width="md" name="title" label="标题" placeholder="请输入" /> |
|||
<Form.Item style={{ width: '40%' }} label={<span>作者</span>} name="authorId" shouldUpdate> |
|||
<AuthorSelect /> |
|||
</Form.Item> |
|||
<ProFormTextArea |
|||
fieldProps={{ autoSize: true }} |
|||
width="md" |
|||
name="content" |
|||
label="内容" |
|||
placeholder="请输入" |
|||
/> |
|||
<ProFormText width="md" name="line" label="首行" placeholder="请输入" /> |
|||
<ProFormTextArea |
|||
fieldProps={{ autoSize: true }} |
|||
width="md" |
|||
name="note" |
|||
label="解析" |
|||
placeholder="请输入" |
|||
/> |
|||
<ProFormTextArea |
|||
fieldProps={{ autoSize: true }} |
|||
width="md" |
|||
name="translation" |
|||
label="翻译" |
|||
placeholder="请输入" |
|||
/> |
|||
</DrawerForm> |
|||
); |
|||
}; |
|||
|
|||
export default PoemForm; |
Loading…
Reference in new issue