Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
csbr-daop
/
fe-data-trusted-space
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
12aec4f5
authored
2025-08-19 17:39:41 +0800
by
lxs
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
入表功调整
1 parent
d1e89582
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
10 deletions
src/views/data_entry/index.vue
src/views/data_entry/index.vue
View file @
12aec4f
...
...
@@ -11,6 +11,7 @@ import { changeNum } from "@/utils/common";
import
{
costDelete
,
getAssetCatalog
,
getCostList
,
sendEntryMsg
}
from
"@/api/modules/dataEntry"
;
import
*
as
XLSXS
from
'xlsx-js-style'
;
import
{
saveAs
}
from
'file-saver'
;
import
{
t
}
from
"@wangeditor/editor"
;
const
{
proxy
}
=
getCurrentInstance
()
as
any
;
const
userStore
=
useUserStore
();
...
...
@@ -226,9 +227,9 @@ const convertConfig = {
}
const
costTableRef
=
ref
(
null
);
const
initField
:
any
=
ref
([
{
label
:
"一级指标"
,
field
:
"name1"
,
level
:
1
,
width
:
120
},
{
label
:
"一级分类"
,
field
:
"name2"
,
level
:
2
,
width
:
120
},
{
label
:
"二级分类"
,
field
:
"name3"
,
level
:
3
,
width
:
200
},
{
label
:
"一级指标"
,
field
:
"name1"
,
level
:
1
,
width
:
120
,
visible
:
true
},
{
label
:
"一级分类"
,
field
:
"name2"
,
level
:
2
,
width
:
120
,
visible
:
true
},
{
label
:
"二级分类"
,
field
:
"name3"
,
level
:
3
,
width
:
200
,
visible
:
true
},
{
label
:
"三级分类"
,
field
:
"name4"
,
level
:
4
,
width
:
200
,
visible
:
false
},
{
label
:
"累计投入"
,
field
:
"total"
,
width
:
120
,
align
:
'right'
,
visible
:
false
,
columClass
:
'inverse_cell'
,
getName
:
(
scope
)
=>
{
...
...
@@ -241,6 +242,7 @@ const tableData: any = ref([])
const
besure
=
ref
(
false
);
const
mergeRowCount
:
any
=
ref
({});
const
checkedData
:
any
=
ref
([]);
const
checkedField
:
any
=
ref
([]);
const
entryItem
=
{
year
:
''
,
...
...
@@ -438,8 +440,12 @@ const addSameData = (rIndex, name, level, tData) => {
const
lastCode
=
rowData
[
`code
${
level
-
1
}
`
];
const
tCode
=
tData
[
`code
${
level
}
`
].
split
(
lastCode
)[
1
];
const
codeVal
=
parseInt
(
tCode
,
10
)
<
10
?
`0
${
parseInt
(
tCode
,
10
)
+
1
}
`
:
parseInt
(
tCode
,
10
)
+
1
;
for
(
var
r
in
rowData
){
if
(
r
.
indexOf
(
'name'
)
==
-
1
&&
r
.
indexOf
(
'code'
)
==
-
1
)
rowData
[
r
]
=
''
;
}
rowData
[
`name
${
level
}
`
]
=
name
;
rowData
[
`code
${
level
}
`
]
=
`
${
lastCode
}${
codeVal
}
`
;
rowData
[
`checked
${
level
}
`
]
=
false
;
delete
rowData
.
name4
;
delete
rowData
.
code4
;
tableData
.
value
.
splice
(
rIndex
+
1
,
0
,
rowData
);
...
...
@@ -452,8 +458,14 @@ const addLowerData = (rIndex, name, level, len) => {
const
hasLowerItem
=
rowData
[
`code
${
level
+
1
}
`
]
?
true
:
false
;
const
lastCode
=
rowData
[
`code
${
level
}
`
];
const
codeVal
=
(
len
+
1
)
<
10
?
'0'
+
(
len
+
1
)
:
len
+
1
;
for
(
var
r
in
rowData
){
if
(
r
.
indexOf
(
'name'
)
==
-
1
&&
r
.
indexOf
(
'code'
)
==
-
1
)
rowData
[
r
]
=
''
;
}
rowData
[
`name
${
level
+
1
}
`
]
=
name
;
rowData
[
`code
${
level
+
1
}
`
]
=
`
${
lastCode
}${
codeVal
}
`
;
rowData
[
`checked
${
level
+
1
}
`
]
=
false
;
rowData
.
edit
=
false
;
hasLowerItem
?
tableData
.
value
.
splice
(
rIndex
+
1
,
0
,
rowData
)
:
tableData
.
value
.
splice
(
rIndex
,
1
,
rowData
);
tableField
.
value
[
3
].
visible
=
true
;
getMergeRow
();
...
...
@@ -919,15 +931,25 @@ const s2ab = (s) => {
// 生成成本设置表
const
exportDetailsToExcel
=
async
()
=>
{
// 准备工作表数据
const
wsData
=
[]
let
wsData
=
[],
fields
:
any
=
[];
tableField
.
value
.
map
(
f
=>
{
if
(
f
.
visible
||
f
.
field
.
indexOf
(
'name'
)
==
-
1
)
{
if
(
f
.
field
==
'name4'
)
{
const
exist4
=
checkedData
.
value
.
find
(
c
=>
c
.
code4
)
exist4
&&
fields
.
push
(
f
)
}
else
{
fields
.
push
(
f
)
}
}
});
// 表头
const
headers
=
tableField
.
value
.
map
(
item
=>
item
.
label
)
const
headers
=
fields
.
map
(
item
=>
item
.
label
)
wsData
.
push
(
headers
)
// 处理数据行
checkedData
.
value
.
forEach
(
item
=>
{
const
row
=
tableField
.
value
.
map
(
f
=>
{
const
row
=
fields
.
map
(
f
=>
{
if
(
f
.
field
.
indexOf
(
'name'
)
==
-
1
)
{
// 分类字段
return
changeNum
(
item
[
f
.
field
],
2
,
true
)
...
...
@@ -941,7 +963,7 @@ const exportDetailsToExcel = async () => {
// 添加合计行
const
totalRow
=
[
'合计'
,
''
,
''
,
''
];
const
numField
=
tableField
.
value
.
filter
(
item
=>
item
.
field
.
indexOf
(
'name'
)
==
-
1
);
const
numField
=
fields
.
filter
(
item
=>
item
.
field
.
indexOf
(
'name'
)
==
-
1
);
const
numericFields
=
numField
.
map
(
f
=>
f
.
field
);
let
totalValues
=
{}
...
...
@@ -961,7 +983,7 @@ const exportDetailsToExcel = async () => {
})
// 将合计值添加到合计行
tableField
.
value
.
forEach
((
field
,
index
)
=>
{
fields
.
forEach
((
field
,
index
)
=>
{
if
(
index
<
4
)
return
// 前4列已经处理
if
(
numericFields
.
includes
(
field
.
field
))
{
const
value
=
totalValues
[
field
.
field
]
...
...
@@ -978,7 +1000,7 @@ const exportDetailsToExcel = async () => {
const
ws
=
XLSXS
.
utils
.
aoa_to_sheet
(
wsData
)
// 自动调整列宽
const
colWidths
=
tableField
.
value
.
map
((
field
,
index
)
=>
{
const
colWidths
=
fields
.
map
((
field
,
index
)
=>
{
const
defaultWidth
=
field
.
width
||
100
// 默认宽度100
const
colWidth
=
defaultWidth
/
14
+
2
;
// 留一些余地
...
...
@@ -1054,7 +1076,7 @@ const exportDetailsToExcel = async () => {
// 数据行样式
const
fieldIndex
=
C
const
field
=
tableField
.
value
[
fieldIndex
]
const
field
=
fields
[
fieldIndex
]
// 数值列右对齐
if
(
numericFields
.
includes
(
field
.
field
))
{
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment