Commit ff824d5e2469fd4ab2b8143246ca84cb443b43e3
Merge branch 'bug_fix' into 'master'
Bug fix See merge request !248
Showing
3 changed files
with
38 additions
and
16 deletions
src/pages/ehr/components/EditTable.tsx
... | ... | @@ -5,10 +5,11 @@ import { |
5 | 5 | FormInstance, |
6 | 6 | Input, |
7 | 7 | InputRef, |
8 | + Popover, | |
8 | 9 | Table, |
9 | 10 | TableProps, |
10 | 11 | } from "antd"; |
11 | -import { EditOutlined } from "@ant-design/icons"; | |
12 | +import { EditOutlined, ExclamationCircleFilled } from "@ant-design/icons"; | |
12 | 13 | import React, { useContext, useEffect, useMemo, useRef, useState } from "react"; |
13 | 14 | import { Rule, RuleObject } from "antd/lib/form"; |
14 | 15 | import { StoreValue } from "antd/lib/form/interface"; |
... | ... | @@ -122,7 +123,7 @@ export default function EditTable<T>({ |
122 | 123 | useEffect(() => { |
123 | 124 | if (edit) { |
124 | 125 | form.setFieldsValue({ |
125 | - [dataIndex]: record?.[dataIndex] ?? '', | |
126 | + [dataIndex]: record?.[dataIndex] ?? "", | |
126 | 127 | }); |
127 | 128 | } |
128 | 129 | }, []); |
... | ... | @@ -147,10 +148,12 @@ export default function EditTable<T>({ |
147 | 148 | |
148 | 149 | const save = async (e: any) => { |
149 | 150 | try { |
150 | - e.preventDefault(); | |
151 | - const values = await form.validateFields(); | |
152 | - toggleEdit(); | |
153 | - handleSave({ ...record, ...values }); | |
151 | + if (!e.shiftKey) { | |
152 | + e.preventDefault(); | |
153 | + const values = await form.validateFields(); | |
154 | + toggleEdit(); | |
155 | + handleSave({ ...record, [dataIndex]: (values?.[dataIndex] as string)?.trim() }); | |
156 | + } | |
154 | 157 | } catch (errInfo) { |
155 | 158 | console.log("Save failed:", errInfo); |
156 | 159 | } |
... | ... | @@ -207,6 +210,7 @@ export default function EditTable<T>({ |
207 | 210 | ref={inputRef} |
208 | 211 | allowClear |
209 | 212 | maxLength={maxLength} |
213 | + autoSize={{ minRows: 2 }} | |
210 | 214 | // showCount={!!maxLength} |
211 | 215 | onPressEnter={save} |
212 | 216 | onBlur={save} |
... | ... | @@ -222,7 +226,7 @@ export default function EditTable<T>({ |
222 | 226 | onFocus={() => { |
223 | 227 | inputType === "number" && |
224 | 228 | form.setFieldsValue({ |
225 | - [dataIndex]: `${record?.[dataIndex] ?? ''}`?.replace( | |
229 | + [dataIndex]: `${record?.[dataIndex] ?? ""}`?.replace( | |
226 | 230 | /^0+/g, |
227 | 231 | "" |
228 | 232 | ), |
... | ... | @@ -250,7 +254,11 @@ export default function EditTable<T>({ |
250 | 254 | ) : ( |
251 | 255 | <div |
252 | 256 | className="editable-cell-value-wrap" |
253 | - style={{ paddingRight: 24, cursor: "pointer" }} | |
257 | + style={{ | |
258 | + paddingRight: 24, | |
259 | + cursor: "pointer", | |
260 | + whiteSpace: "pre-wrap", | |
261 | + }} | |
254 | 262 | onClick={(e) => { |
255 | 263 | e.stopPropagation(); |
256 | 264 | toggleEdit(); |
... | ... | @@ -297,6 +305,20 @@ export default function EditTable<T>({ |
297 | 305 | } |
298 | 306 | return { |
299 | 307 | ...col, |
308 | + title: | |
309 | + col.editable && col.inputType === "text" ? ( | |
310 | + <> | |
311 | + {col.title} | |
312 | + <Popover | |
313 | + // trigger="" | |
314 | + content="在输入时,如需输入回车换行,请同时按下(Shfit + Enter)键进行换行输入" | |
315 | + > | |
316 | + <ExclamationCircleFilled /> | |
317 | + </Popover> | |
318 | + </> | |
319 | + ) : ( | |
320 | + col.title | |
321 | + ), | |
300 | 322 | onCell: (record: T) => ({ |
301 | 323 | record, |
302 | 324 | ...col, | ... | ... |
src/pages/order3/AddValueTaskConfig/components/List.tsx
... | ... | @@ -63,7 +63,7 @@ export default function LargeList({addedValueType} : Props) { |
63 | 63 | <div style={{display: 'flex', flexDirection: 'column'}}> |
64 | 64 | <span>商业险金额*{record.vciOutputValueRatio}%</span> |
65 | 65 | <span>交强险金额*{record.tciOutputValueRatio}%</span> |
66 | - <span>架意险产值*{record.jcxOutputValueRatio}%</span> | |
66 | + <span>驾意险产值*{record.jcxOutputValueRatio}%</span> | |
67 | 67 | </div> |
68 | 68 | )} |
69 | 69 | /> |
... | ... | @@ -80,7 +80,7 @@ export default function LargeList({addedValueType} : Props) { |
80 | 80 | render={(_text, record: ListResult) => `装潢产值*${_text}%`} |
81 | 81 | /> |
82 | 82 | <Column |
83 | - title="适用门店" | |
83 | + title="适用门店" | |
84 | 84 | dataIndex="shopList" |
85 | 85 | align="left" |
86 | 86 | render={(_text, record: ListResult) => <span style={{color: "#4189FD"}} onClick={() => setShopData({visible: true, data: record.shopList})}>{handleRenderShop(record.shopList)}</span>} | ... | ... |
src/utils/utils.ts
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | * @Author: wangqiang@feewee.cn |
3 | 3 | * @Date: 2022-05-11 15:58:56 |
4 | 4 | * @LastEditors: wangqiang@feewee.cn |
5 | - * @LastEditTime: 2023-05-06 14:51:12 | |
5 | + * @LastEditTime: 2023-05-09 14:04:54 | |
6 | 6 | */ |
7 | 7 | |
8 | 8 | import { checkNull } from "@/utils/validate"; |
... | ... | @@ -32,12 +32,12 @@ const isAntDesignProOrDev = (): boolean => { |
32 | 32 | |
33 | 33 | export { isAntDesignProOrDev, isAntDesignPro, isUrl }; |
34 | 34 | |
35 | -export const formatObjText = ( | |
36 | - list: any[], | |
37 | - formatKey: string = "staffName", | |
35 | +export function formatObjText<T>( | |
36 | + list: T[], | |
37 | + formatKey: keyof T, | |
38 | 38 | maxCount: number = 2, |
39 | 39 | unit: string = "人" |
40 | -) => { | |
40 | +): string { | |
41 | 41 | if (!list || (list && !list.length)) return "-"; |
42 | 42 | else { |
43 | 43 | let result = ""; |
... | ... | @@ -50,7 +50,7 @@ export const formatObjText = ( |
50 | 50 | } |
51 | 51 | return result; |
52 | 52 | } |
53 | -}; | |
53 | +} | |
54 | 54 | |
55 | 55 | export function isNumber(str: string | number) { |
56 | 56 | // 匹配整数或带有小数点的数字 | ... | ... |