Showing
3 changed files
with
92 additions
and
31 deletions
| ... | ... | @@ -2138,6 +2138,12 @@ export function executeDefault( |
| 2138 | 2138 | form.setValueByPath(fieldPath, realValue); |
| 2139 | 2139 | break;*/ |
| 2140 | 2140 | case 'OTHER': |
| 2141 | + if (default_init) { | |
| 2142 | + // 编辑时第一次不执行 | |
| 2143 | + form.setSchemaByPath(fieldPath, { default_init: false }); | |
| 2144 | + return; | |
| 2145 | + } | |
| 2146 | + | |
| 2141 | 2147 | //TODO 当前人员和部门在初始化schema时处理, 字段值在这里处理 |
| 2142 | 2148 | |
| 2143 | 2149 | //子表中的默认值 | ... | ... |
| ... | ... | @@ -95,11 +95,7 @@ const CustomButton = (props: any) => { |
| 95 | 95 | const errorCount = ids.length - res.length; |
| 96 | 96 | if (errorCount > 0) { |
| 97 | 97 | message.warn( |
| 98 | - '成功更新【' + | |
| 99 | - res.length + | |
| 100 | - '】条记录,【' + | |
| 101 | - errorCount + | |
| 102 | - '】条记录无权限更新', | |
| 98 | + '成功更新【' + res.length + '】条记录,【' + errorCount + '】条记录无权限更新', | |
| 103 | 99 | ); |
| 104 | 100 | } else { |
| 105 | 101 | message.success('更新成功'); |
| ... | ... | @@ -127,11 +123,7 @@ const CustomButton = (props: any) => { |
| 127 | 123 | Modal.confirm({ |
| 128 | 124 | content: lastedButtonData.confirmContent, |
| 129 | 125 | onOk: () => { |
| 130 | - executeButtonAction( | |
| 131 | - lastedButtonData.code, | |
| 132 | - lastedButtonData.ids, | |
| 133 | - data, | |
| 134 | - ); | |
| 126 | + executeButtonAction(lastedButtonData.code, lastedButtonData.ids, data); | |
| 135 | 127 | }, |
| 136 | 128 | onCancel: () => { |
| 137 | 129 | dialogRef.current.setLoading(false); |
| ... | ... | @@ -156,15 +148,9 @@ const CustomButton = (props: any) => { |
| 156 | 148 | appCode: currDataItemCtrl.appCode, |
| 157 | 149 | funCode: currDataItemCtrl.funCode, |
| 158 | 150 | viewCode: currDataItemCtrl.viewCode, |
| 159 | - id: | |
| 160 | - typeof currDataItemCtrl.id === 'string' | |
| 161 | - ? [currDataItemCtrl.id] | |
| 162 | - : currDataItemCtrl.id, | |
| 151 | + id: typeof currDataItemCtrl.id === 'string' ? [currDataItemCtrl.id] : currDataItemCtrl.id, | |
| 163 | 152 | }; |
| 164 | - if ( | |
| 165 | - currDataItemCtrl.from && | |
| 166 | - ['button-rel', 'button'].includes(currDataItemCtrl.from) | |
| 167 | - ) { | |
| 153 | + if (currDataItemCtrl.from && ['button-rel', 'button'].includes(currDataItemCtrl.from)) { | |
| 168 | 154 | data.actionCode = currDataItemCtrl?.params?.actionCode; |
| 169 | 155 | if (['button-rel'].includes(currDataItemCtrl.from)) { |
| 170 | 156 | data.appCode = currDataItemCtrl?.params?.appCode; |
| ... | ... | @@ -238,7 +224,10 @@ const CustomButton = (props: any) => { |
| 238 | 224 | ) { |
| 239 | 225 | const floatSchema = getFormFieldsList(schemaItem); |
| 240 | 226 | //const result = handleBtnFormSchema(floatSchema); |
| 241 | - hiddenAll = floatSchema.every((item: any) => item.hidden); | |
| 227 | + const finalSchema = floatSchema.filter((item: any) => { | |
| 228 | + return item?.title; | |
| 229 | + }); | |
| 230 | + hiddenAll = finalSchema.every((item: any) => item.hidden); | |
| 242 | 231 | } |
| 243 | 232 | //判断是否需要全隐藏 |
| 244 | 233 | /* |
| ... | ... | @@ -249,7 +238,7 @@ const CustomButton = (props: any) => { |
| 249 | 238 | * */ |
| 250 | 239 | if ( |
| 251 | 240 | (actType === 'EDIT_FORM' && !hiddenAll) || |
| 252 | - actType === 'EDIT_REL_FORM' || | |
| 241 | + (actType === 'EDIT_REL_FORM' && !hiddenAll) || | |
| 253 | 242 | (actType === 'REL_EDIT_REL_FORM' && !hiddenAll) || |
| 254 | 243 | (actType === 'REL_EDIT_FORM' && !hiddenAll) |
| 255 | 244 | ) { |
| ... | ... | @@ -295,9 +284,7 @@ const CustomButton = (props: any) => { |
| 295 | 284 | // appCode: appCode, |
| 296 | 285 | // funCode: funCode, |
| 297 | 286 | fieldName: schemaItem.fieldKey, |
| 298 | - pageType: ['EDIT_REL_FORM', 'REL_EDIT_REL_FORM'].includes(actType) | |
| 299 | - ? 'add' | |
| 300 | - : 'edit', | |
| 287 | + pageType: ['EDIT_REL_FORM', 'REL_EDIT_REL_FORM'].includes(actType) ? 'add' : 'edit', | |
| 301 | 288 | }, |
| 302 | 289 | params: { |
| 303 | 290 | actionCode: btnData.code, |
| ... | ... | @@ -320,9 +307,7 @@ const CustomButton = (props: any) => { |
| 320 | 307 | appCode: appCode, |
| 321 | 308 | funCode: schemaItem.masterFunCode, |
| 322 | 309 | fieldName: schemaItem.fieldKey, |
| 323 | - pageType: ['EDIT_REL_FORM', 'REL_EDIT_REL_FORM'].includes(actType) | |
| 324 | - ? 'add' | |
| 325 | - : 'edit', | |
| 310 | + pageType: ['EDIT_REL_FORM', 'REL_EDIT_REL_FORM'].includes(actType) ? 'add' : 'edit', | |
| 326 | 311 | }, |
| 327 | 312 | params: { |
| 328 | 313 | actionCode: btnData.code, |
| ... | ... | @@ -411,7 +396,7 @@ const CustomButton = (props: any) => { |
| 411 | 396 | }} |
| 412 | 397 | /> |
| 413 | 398 | |
| 414 | - <OpenLink cRef={linkRef} /> | |
| 399 | + <OpenLink cRef={linkRef} title={btnData?.name} /> | |
| 415 | 400 | </> |
| 416 | 401 | ); |
| 417 | 402 | }; | ... | ... |
| 1 | -import React, { useImperativeHandle, useRef, useState } from 'react'; | |
| 2 | -import { Button, Drawer, Space } from 'antd'; | |
| 1 | +import React, { useImperativeHandle, useRef, useState, useEffect } from 'react'; | |
| 2 | +import { Button, Drawer, Space, Modal } from 'antd'; | |
| 3 | 3 | import { history, useLocation } from 'umi'; |
| 4 | 4 | import { handleWindowOpen } from '@/utils'; |
| 5 | +import Draggable from 'react-draggable'; | |
| 5 | 6 | |
| 6 | 7 | // TODO: 公共依赖 |
| 7 | 8 | import { doBtnJump } from '@/pages/app-view/list/util'; |
| ... | ... | @@ -24,8 +25,50 @@ const FORM_SCHEMA = {}; |
| 24 | 25 | } |
| 25 | 26 | } */ |
| 26 | 27 | |
| 28 | +/*表单页--弹框的形式*/ | |
| 29 | +interface UrlDialogProp { | |
| 30 | + visible: boolean; | |
| 31 | + title: string; | |
| 32 | + url: string; | |
| 33 | + onVisibleChange: (visible: boolean) => void; | |
| 34 | +} | |
| 35 | + | |
| 36 | +export const UrlDialog: React.FC<UrlDialogProp> = (props) => { | |
| 37 | + const [visible, setVisible] = useState(false); | |
| 38 | + | |
| 39 | + useEffect(() => { | |
| 40 | + setVisible(props?.visible); | |
| 41 | + }, [props?.visible]); | |
| 42 | + | |
| 43 | + useEffect(() => { | |
| 44 | + props.onVisibleChange(visible); | |
| 45 | + }, [visible]); | |
| 46 | + | |
| 47 | + return ( | |
| 48 | + <> | |
| 49 | + <Modal | |
| 50 | + title={props.title} | |
| 51 | + width={'864px'} | |
| 52 | + visible={visible} | |
| 53 | + bodyStyle={{ padding: '20px 10px 20px 20px' }} // 不能加 对其详情有影响 | |
| 54 | + onCancel={() => setVisible(false)} | |
| 55 | + footer={false} | |
| 56 | + destroyOnClose={true} | |
| 57 | + modalRender={(node) => ( | |
| 58 | + <Draggable handle=".ant-modal-header"> | |
| 59 | + <div>{node}</div> | |
| 60 | + </Draggable> | |
| 61 | + )} | |
| 62 | + > | |
| 63 | + <iframe src={props.url} style={{ width: '100%', height: '500px' }} frameBorder="0" /> | |
| 64 | + </Modal> | |
| 65 | + </> | |
| 66 | + ); | |
| 67 | +}; | |
| 68 | + | |
| 27 | 69 | type ButtonFormProps = { |
| 28 | 70 | cRef: any; |
| 71 | + title?: string; | |
| 29 | 72 | successCallback?: (result: any) => void; |
| 30 | 73 | }; |
| 31 | 74 | const ButtonForm: React.FC<ButtonFormProps> = (props) => { |
| ... | ... | @@ -35,6 +78,9 @@ const ButtonForm: React.FC<ButtonFormProps> = (props) => { |
| 35 | 78 | const { pathname } = useLocation(); |
| 36 | 79 | |
| 37 | 80 | const [query, setQuery] = useState<any>({}); |
| 81 | + const [url, setUrl] = useState<string>(''); | |
| 82 | + const [urlDialogVisible, setUrlDialogVisible] = useState<boolean>(false); | |
| 83 | + | |
| 38 | 84 | const drawerRef = useRef({ |
| 39 | 85 | open: () => {}, |
| 40 | 86 | close: () => {}, |
| ... | ... | @@ -92,11 +138,26 @@ const ButtonForm: React.FC<ButtonFormProps> = (props) => { |
| 92 | 138 | return `${item.name}=${getParaVal(item.value, record)}`; |
| 93 | 139 | }); |
| 94 | 140 | if (btnSchema.type === 'URL') { |
| 95 | - doBtnJump(btnSchema, record, params); | |
| 141 | + //TODO,开发者模式下才有,不完善。 for 易才项目 from 史婷婷 | |
| 142 | + if (btnSchema?.link?.openType === 'DIALOG') { | |
| 143 | + const _url = btnSchema?.link?.url; | |
| 144 | + if (_url) { | |
| 145 | + try { | |
| 146 | + const _urlArr = _url.split('?'); | |
| 147 | + _urlArr[1] = params.join('&') + (_urlArr[1] ? '&' : '') + _urlArr[1]; | |
| 148 | + setUrl(_urlArr.join('?')); | |
| 149 | + setUrlDialogVisible(true); | |
| 150 | + } catch (e) { | |
| 151 | + console.log(e); | |
| 152 | + } | |
| 153 | + } | |
| 154 | + } else { | |
| 155 | + doBtnJump(btnSchema, record, params); | |
| 156 | + } | |
| 96 | 157 | return; |
| 97 | 158 | } |
| 98 | 159 | if (btnSchema.type === 'FORM_PAGE' && btnSchema.link) { |
| 99 | - console.log('FORM_PAGE!!!!!!!!!!'); | |
| 160 | + // console.log('FORM_PAGE!!!!!!!!!!'); | |
| 100 | 161 | const mcode = btnSchema.link.methodCode; |
| 101 | 162 | |
| 102 | 163 | if (mcode) method[mcode].call(null, btnSchema.link, params); |
| ... | ... | @@ -166,8 +227,17 @@ const ButtonForm: React.FC<ButtonFormProps> = (props) => { |
| 166 | 227 | type={'add'} |
| 167 | 228 | // onAfterSave={props.onAfterSave} |
| 168 | 229 | /> */} |
| 230 | + <UrlDialog | |
| 231 | + visible={urlDialogVisible} | |
| 232 | + onVisibleChange={(visible: boolean) => { | |
| 233 | + setUrlDialogVisible(visible); | |
| 234 | + }} | |
| 235 | + title={props?.title || ''} | |
| 236 | + url={url} | |
| 237 | + /> | |
| 169 | 238 | </div> |
| 170 | 239 | ); |
| 171 | 240 | }; |
| 172 | 241 | |
| 173 | 242 | export default ButtonForm; |
| 243 | + | ... | ... |