Skip to content

Commit 5132ee5

Browse files
author
JerryLiu
committed
feat: CompanyCategoryName Input
1 parent 3d05f33 commit 5132ee5

File tree

29 files changed

+271
-191
lines changed

29 files changed

+271
-191
lines changed

js/src/components/CreatCompanyCategoryCard/index.tsx

Lines changed: 0 additions & 105 deletions
This file was deleted.

js/src/components/CreatCompanyCategoryInput/index.tsx

Lines changed: 0 additions & 22 deletions
This file was deleted.

js/src/components/CustomLayouts/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { useState, useEffect } from 'react'
22
import { defaultRouterMetas } from '@/utils'
33
import { useColor } from '@/hooks'
4-
import { Outlet } from 'react-router-dom'
4+
import { Outlet, useLocation } from 'react-router-dom'
55

66
const CustomLayouts = () => {
77
const { colorText } = useColor()
8-
const pathname = window.location.pathname
8+
const location = useLocation()
9+
const pathname = location.pathname
910
const [
1011
title,
1112
setTitle,

js/src/components/ProjectsCompanyCard/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import { Card } from 'antd'
33
import { Link } from 'react-router-dom'
4-
import defaultImage from '@/defaultImage.jpg'
4+
import defaultImage from '@/static/defaultImage.jpg'
55
import { renderHTML } from '@/utils'
66

77
const { Meta } = Card

js/src/defaultImage.jpg

-25.9 KB
Binary file not shown.

js/src/pages/Check/Export/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ const Export = () => {
8080
centered
8181
open={isExportModalOpen}
8282
footer={null}
83+
onCancel={() => setIsExportModalOpen(false)}
8384
>
8485
<Input.TextArea value={jsonString} rows={6} />
8586
<div className="flex justify-end mt-4">

js/src/pages/Check/index.tsx

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,27 @@ import { useQueryClient } from '@tanstack/react-query'
2727
import { IGroupData } from './ScopeI/CheckScopeITable/Table/types'
2828
import { isEqual } from 'lodash-es'
2929
import ImageUpload from '@/components/ImageUpload'
30-
import { renderHTML } from '@/utils'
3130

31+
export const defaultScopes = {
32+
scopeI: [
33+
{
34+
groupKey: '0',
35+
groupName: '工廠 #1',
36+
dataSource: [],
37+
},
38+
],
39+
scopeII: [
40+
{
41+
groupKey: '0',
42+
groupName: '工廠 #1',
43+
dataSource: [],
44+
},
45+
],
46+
info: {
47+
title: '○○○○股份有限公司',
48+
companyCategory: '未分類',
49+
},
50+
}
3251
export const ProjectContext = createContext<{
3352
projectData: any
3453
scopes: {
@@ -41,22 +60,7 @@ export const ProjectContext = createContext<{
4160
}>
4261
}>({
4362
projectData: null,
44-
scopes: {
45-
scopeI: [
46-
{
47-
groupKey: '0',
48-
groupName: '工廠 #1',
49-
dataSource: [],
50-
},
51-
],
52-
scopeII: [
53-
{
54-
groupKey: '0',
55-
groupName: '工廠 #1',
56-
dataSource: [],
57-
},
58-
],
59-
},
63+
scopes: defaultScopes,
6064
setScopes: () => {},
6165
})
6266

@@ -94,22 +98,11 @@ const App: React.FC = () => {
9498
] = useState<{
9599
scopeI: IGroupData[]
96100
scopeII: IGroupData[]
97-
}>({
98-
scopeI: [
99-
{
100-
groupKey: '0',
101-
groupName: '工廠 #1',
102-
dataSource: [],
103-
},
104-
],
105-
scopeII: [
106-
{
107-
groupKey: '0',
108-
groupName: '工廠 #1',
109-
dataSource: [],
110-
},
111-
],
112-
})
101+
info: {
102+
title: string
103+
companyCategory: string
104+
}
105+
}>(defaultScopes)
113106
const [
114107
popoverOpen,
115108
setPopoverOpen,
@@ -138,7 +131,8 @@ const App: React.FC = () => {
138131

139132
const handleUpdate = async () => {
140133
const content = form.getFieldValue(['content'])
141-
const copyScopes = JSON.parse(JSON.stringify(scopes))
134+
const copyScopes = JSON.parse(JSON.stringify(scopes || defaultScopes))
135+
142136
const updateScopeI = copyScopes.scopeI.map(
143137
(theGroup: IGroupData, groupIndex: number) => ({
144138
...theGroup,
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React from 'react'
2+
import { Card } from 'antd'
3+
4+
const { Meta } = Card
5+
6+
const CreatCompanyCategoryCard: React.FC<{
7+
option: {
8+
name: string
9+
key: string
10+
image: string
11+
}
12+
showModal: (_name: string) => () => void
13+
}> = ({ option, showModal }) => {
14+
return (
15+
<>
16+
<Card
17+
onClick={showModal(option.name || '沒有名稱')}
18+
className="w-full"
19+
cover={
20+
<img
21+
className="aspect-[16/9]"
22+
alt={option.name || '沒有名稱'}
23+
src={
24+
option.image ||
25+
'https://via.placeholder.com/480x270.png?text=NO+IMAGE'
26+
}
27+
/>
28+
}
29+
>
30+
<Meta
31+
title={
32+
<p className="text-center my-auto">{option.name || '沒有名稱'}</p>
33+
}
34+
/>
35+
</Card>
36+
</>
37+
)
38+
}
39+
40+
export default CreatCompanyCategoryCard
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React, { useState } from 'react'
2+
import { QuestionOutlined } from '@ant-design/icons'
3+
import { Input, Button } from 'antd'
4+
5+
const CreatCompanyCategoryInput: React.FC<{
6+
showModal: (_name: string) => () => void
7+
setCompanyCategoryName: React.Dispatch<React.SetStateAction<string>>
8+
}> = ({ showModal, setCompanyCategoryName }) => {
9+
const [
10+
inputValue,
11+
setInputValue,
12+
] = useState<string>('')
13+
const handleInpuChange = (e: React.ChangeEvent<HTMLInputElement>) => {
14+
setInputValue(e.target.value)
15+
}
16+
const handleSubmit = () => {
17+
showModal(inputValue)()
18+
setCompanyCategoryName(inputValue)
19+
}
20+
21+
return (
22+
<div className="border-2 border-gray-300 h-full w-full rounded-lg border-dashed flex flex-col justify-center items-center">
23+
<div className="aspect-[16/9] flex flex-col justify-center items-center w-full">
24+
<QuestionOutlined className="text-gray-300" style={{ fontSize: 48 }} />
25+
<div className="text-gray-300" style={{ marginTop: 24 }}>
26+
找不到所屬的產業
27+
</div>
28+
</div>
29+
<div className="w-full py-4">
30+
<Input.Group compact className="text-center">
31+
<Input
32+
onChange={handleInpuChange}
33+
style={{ width: 'calc(100% - 200px)' }}
34+
placeholder="自行輸入"
35+
/>
36+
<Button onClick={handleSubmit} type="primary">
37+
送出
38+
</Button>
39+
</Input.Group>
40+
</div>
41+
</div>
42+
)
43+
}
44+
45+
export default CreatCompanyCategoryInput

0 commit comments

Comments
 (0)