Commit fb5395b5401b4b1f9e605d2721784482a76d49cc

Authored by vben
1 parent 88f4a3f0

fix(upload): fix file upload key loss #120

src/components/Upload/src/FileList.tsx
1 -import { defineComponent } from 'vue'; 1 +import { defineComponent, CSSProperties } from 'vue';
2 import { fileListProps } from './props'; 2 import { fileListProps } from './props';
3 import { isFunction } from '/@/utils/is'; 3 import { isFunction } from '/@/utils/is';
4 import './FileList.less'; 4 import './FileList.less';
@@ -16,11 +16,13 @@ export default defineComponent({ @@ -16,11 +16,13 @@ export default defineComponent({
16 <colgroup> 16 <colgroup>
17 {columnList.map((item) => { 17 {columnList.map((item) => {
18 const { width = 0, dataIndex } = item; 18 const { width = 0, dataIndex } = item;
19 - return width ? (  
20 - <col style={'width:' + width + 'px;min-width:' + width + 'px;'} key={dataIndex} />  
21 - ) : (  
22 - <col />  
23 - ); 19 +
  20 + const style: CSSProperties = {
  21 + width: `${width}px`,
  22 + minWidth: `${width}px`,
  23 + };
  24 +
  25 + return <col style={width ? style : {}} key={dataIndex} />;
24 })} 26 })}
25 </colgroup> 27 </colgroup>
26 <thead> 28 <thead>
@@ -38,22 +40,17 @@ export default defineComponent({ @@ -38,22 +40,17 @@ export default defineComponent({
38 <tbody> 40 <tbody>
39 {dataSource.map((record = {}) => { 41 {dataSource.map((record = {}) => {
40 return ( 42 return (
41 - <tr class="file-table-tr"> 43 + <tr class="file-table-tr" key={record.uuid}>
42 {columnList.map((item) => { 44 {columnList.map((item) => {
43 const { dataIndex = '', customRender, align = 'center' } = item; 45 const { dataIndex = '', customRender, align = 'center' } = item;
44 - if (customRender && isFunction(customRender)) {  
45 - return (  
46 - <td class={['file-table-td', align]} key={dataIndex}>  
47 - {customRender({ text: record[dataIndex], record })}  
48 - </td>  
49 - );  
50 - } else {  
51 - return (  
52 - <td class={['file-table-td', align]} key={dataIndex}>  
53 - {record[dataIndex]}  
54 - </td>  
55 - );  
56 - } 46 + const render = customRender && isFunction(customRender);
  47 + return (
  48 + <td class={['file-table-td', align]} key={dataIndex}>
  49 + {render
  50 + ? customRender?.({ text: record[dataIndex], record })
  51 + : record[dataIndex]}
  52 + </td>
  53 + );
57 })} 54 })}
58 </tr> 55 </tr>
59 ); 56 );