Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dwsproject
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dws
dwsproject
Commits
2edde48c
Commit
2edde48c
authored
May 28, 2025
by
龚桂斌
Browse files
Options
Browse Files
Download
Plain Diff
合并分支 'jzjx_project' 到 'master'
Jzjx project 查看合并请求
!15
parents
a99b7867
d95d26b3
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
476 additions
and
37 deletions
+476
-37
jzjx_project/models/__init__.py
+1
-0
jzjx_project/models/inherit_ir_http.py
+51
-0
jzjx_project/views/iniherit_work_center_view.xml
+2
-1
roke_product_income_expense/controller/main.py
+111
-6
roke_product_income_expense/models/product_income_expense.py
+6
-3
roke_product_income_expense/static/src/js/index.html
+305
-27
No files found.
jzjx_project/models/__init__.py
View file @
2edde48c
...
...
@@ -3,3 +3,4 @@ from . import inherit_production_task
from
.
import
inherit_workcenter
from
.
import
work_log
from
.
import
inherit_roke_routing
from
.
import
inherit_ir_http
jzjx_project/models/inherit_ir_http.py
0 → 100644
View file @
2edde48c
import
base64
import
hashlib
import
os
import
re
from
odoo
import
models
,
fields
,
http
,
api
,
_
from
odoo.modules.module
import
get_resource_path
,
get_module_path
from
odoo.tools.mimetypes
import
guess_mimetype
from
odoo.tools
import
consteq
,
pycompat
class
InheritIrHttp
(
models
.
AbstractModel
):
_inherit
=
'ir.http'
@classmethod
def
_binary_ir_attachment_redirect_content
(
cls
,
record
,
default_mimetype
=
'application/octet-stream'
):
# mainly used for theme images attachemnts
base
=
http
.
request
.
env
[
'ir.config_parameter'
]
.
sudo
()
.
get_param
(
'web.base.url'
,
''
)
if
record
.
type
==
'url'
and
record
.
url
and
base
.
startswith
(
"https"
)
and
"http://121.37.69.162:9000"
in
record
.
url
:
filename
=
filehash
=
None
mimetype
=
getattr
(
record
,
'mimetype'
,
False
)
url
=
record
.
url
.
replace
(
"http://121.37.69.162:9000"
,
"https://minio.xbg.rokeris.com"
)
status
=
301
content
=
url
else
:
status
=
content
=
filename
=
filehash
=
None
mimetype
=
getattr
(
record
,
'mimetype'
,
False
)
if
record
.
type
==
'url'
and
record
.
url
:
# if url in in the form /somehint server locally
url_match
=
re
.
match
(
"^/(
\
w+)/(.+)$"
,
record
.
url
)
if
url_match
:
module
=
url_match
.
group
(
1
)
module_path
=
get_module_path
(
module
)
module_resource_path
=
get_resource_path
(
module
,
url_match
.
group
(
2
))
if
module_path
and
module_resource_path
:
module_path
=
os
.
path
.
join
(
os
.
path
.
normpath
(
module_path
),
''
)
# join ensures the path ends with '/'
module_resource_path
=
os
.
path
.
normpath
(
module_resource_path
)
if
module_resource_path
.
startswith
(
module_path
):
with
open
(
module_resource_path
,
'rb'
)
as
f
:
content
=
base64
.
b64encode
(
f
.
read
())
status
=
200
filename
=
os
.
path
.
basename
(
module_resource_path
)
mimetype
=
guess_mimetype
(
base64
.
b64decode
(
content
),
default
=
default_mimetype
)
filehash
=
'"
%
s"'
%
hashlib
.
md5
(
pycompat
.
to_text
(
content
)
.
encode
(
'utf-8'
))
.
hexdigest
()
if
not
content
:
status
=
301
content
=
record
.
url
return
status
,
content
,
filename
,
mimetype
,
filehash
jzjx_project/views/iniherit_work_center_view.xml
View file @
2edde48c
...
...
@@ -9,9 +9,10 @@
<div
id=
"jzjx_work_center_state"
class=
"row"
style=
"display:flex;justify-content: center;align-items: center;font-size: 30px;"
>
<p
style=
"color:#dee2e6;"
><field
name=
"deviceState"
/></p>
</div>
<div
id=
"work_center_wo"
/>
</xpath>
<xpath
expr=
"//div[@id='work_center_empty']"
position=
"replace"
>
<div/>
<div
id=
"work_center_empty"
/>
</xpath>
</field>
</record>
...
...
roke_product_income_expense/controller/main.py
View file @
2edde48c
import
datetime
import
pandas
as
pd
import
xlsxwriter
from
odoo
import
http
,
tools
from
odoo.http
import
content_disposition
,
request
import
os
import
io
from
jinja2
import
FileSystemLoader
,
Environment
import
logging
_logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -32,10 +35,19 @@ class ProductIncomeExpenseIframe(http.Controller):
"business_date"
:
v
.
get
(
"business_date"
,
False
),
"abstract"
:
v
.
get
(
"abstract"
,
False
),
"income"
:
v
.
get
(
"income"
,
False
),
"expenditure"
:
v
.
get
(
"expenditure"
,
False
)
"machinery_type"
:
v
.
get
(
"machinery_type"
,
"其他"
),
"expenditure"
:
v
.
get
(
"expenditure"
,
False
),
"customer"
:
v
.
get
(
"customer"
,
False
)
}
# 看是否有id,如果有的话就说明是更新,没有的话就说明是创建
if
v
.
get
(
"id"
,
False
):
expense_obj
=
_self
.
env
[
"roke.product.income.expense"
]
.
sudo
()
.
search
([(
"id"
,
"="
,
v
.
get
(
"id"
))])
if
not
expense_obj
:
return
{
"code"
:
1
,
"message"
:
"更新失败,没找到对应数据。"
}
expense_obj
.
write
(
data
)
else
:
_self
.
env
(
user
=
v
.
get
(
"user_id"
))[
"roke.product.income.expense"
]
.
create
(
data
)
return
{
"code"
:
0
,
"message"
:
"
创建
成功!"
}
return
{
"code"
:
0
,
"message"
:
"
操作
成功!"
}
@http.route
(
"/roke/product/product_income_expense/get"
,
type
=
"json"
,
auth
=
'none'
,
cors
=
'*'
,
csrf
=
False
)
def
product_income_expense_get_list
(
self
):
...
...
@@ -44,10 +56,19 @@ class ProductIncomeExpenseIframe(http.Controller):
page
=
_self
.
jsonrequest
.
get
(
"page"
,
1
)
start_date
=
_self
.
jsonrequest
.
get
(
"start_date"
,
""
)
end_date
=
_self
.
jsonrequest
.
get
(
"end_date"
,
""
)
type_str
=
_self
.
jsonrequest
.
get
(
"type_str"
,
False
)
# income收入/expenditure支出
machinery_type
=
_self
.
jsonrequest
.
get
(
"machinery_type"
,
False
)
customer
=
_self
.
jsonrequest
.
get
(
"customer"
,
False
)
domain
=
[]
if
start_date
and
end_date
:
domain
.
append
((
"business_date"
,
">="
,
start_date
))
domain
.
append
((
"business_date"
,
"<="
,
end_date
))
if
type_str
:
domain
.
append
((
type_str
,
">"
,
0
))
if
machinery_type
:
domain
.
append
((
"machinery_type"
,
"="
,
machinery_type
))
if
customer
:
domain
.
append
((
"customer"
,
"ilike"
,
customer
))
data_list
=
_self
.
env
[
"roke.product.income.expense"
]
.
sudo
()
.
search
(
domain
,
limit
=
limit
,
offset
=
(
page
-
1
)
*
limit
,
order
=
"business_date desc, create_date desc"
)
...
...
@@ -58,9 +79,11 @@ class ProductIncomeExpenseIframe(http.Controller):
"id"
:
v
.
id
,
"business_date"
:
v
.
business_date
and
v
.
business_date
.
strftime
(
'
%
Y-
%
m-
%
d'
),
"abstract"
:
v
.
abstract
or
""
,
"income"
:
v
.
income
or
0
,
"expenditure"
:
v
.
expenditure
or
0
,
"balance"
:
v
.
balance
or
0
,
"customer"
:
v
.
customer
or
""
,
"income"
:
round
(
v
.
income
,
2
)
or
0
,
"machinery_type"
:
v
.
machinery_type
or
"其他"
,
"expenditure"
:
round
(
v
.
expenditure
)
or
0
,
"balance"
:
round
(
v
.
balance
,
2
)
or
0
,
"user_name"
:
v
.
create_uid
.
name
or
""
,
"create_date"
:
(
v
.
create_date
+
datetime
.
timedelta
(
hours
=
8
))
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M'
),
})
...
...
@@ -77,3 +100,85 @@ class ProductIncomeExpenseIframe(http.Controller):
return
{
"code"
:
1
,
"message"
:
"删除失败,没找到对应数据。"
}
data
.
unlink
()
return
{
"code"
:
0
,
"message"
:
"删除成功!"
}
@http.route
(
"/roke/product/product_income_expense/export"
,
type
=
"http"
,
auth
=
'none'
,
cors
=
'*'
,
csrf
=
False
)
def
get_product_income_expense_export
(
self
,
**
kwargs
):
_self
=
http
.
request
start_date
=
kwargs
.
get
(
"start_date"
,
""
)
end_date
=
kwargs
.
get
(
"end_date"
,
""
)
type_str
=
kwargs
.
get
(
"type_str"
,
False
)
# income收入/expenditure支出
machinery_type
=
kwargs
.
get
(
"machinery_type"
,
False
)
customer
=
kwargs
.
get
(
"customer"
,
False
)
domain
=
[]
if
start_date
and
end_date
:
domain
.
append
((
"business_date"
,
">="
,
start_date
))
domain
.
append
((
"business_date"
,
"<="
,
end_date
))
if
type_str
:
domain
.
append
((
type_str
,
">"
,
0.0
))
if
machinery_type
:
domain
.
append
((
"machinery_type"
,
"="
,
machinery_type
))
if
customer
:
domain
.
append
((
"customer"
,
"ilike"
,
customer
))
data_list
=
_self
.
env
[
"roke.product.income.expense"
]
.
sudo
()
.
search
(
domain
,
order
=
"business_date desc, create_date desc"
)
data
=
[]
for
v
in
data_list
:
data
.
append
({
"business_date"
:
v
.
business_date
,
"abstract"
:
v
.
abstract
or
""
,
"customer"
:
v
.
customer
or
""
,
"income"
:
v
.
income
or
0
,
"expenditure"
:
v
.
expenditure
or
0
,
"balance"
:
v
.
balance
or
0
,
"machinery_type"
:
v
.
machinery_type
or
'其他'
,
"user_name"
:
v
.
create_uid
.
name
or
""
,
"create_date"
:
v
.
create_date
+
datetime
.
timedelta
(
hours
=
8
),
})
output
=
io
.
BytesIO
()
workbook
=
xlsxwriter
.
Workbook
(
output
,
{
'in_memory'
:
True
})
worksheet
=
workbook
.
add_worksheet
(
'Sheet1'
)
header_format
=
workbook
.
add_format
({
'bold'
:
True
,
'border'
:
1
,
'fg_color'
:
'#17a2b8'
,
'font_color'
:
'#FFFFFF'
,
'align'
:
'center'
,
'valign'
:
'vcenter'
})
date_format
=
workbook
.
add_format
({
'num_format'
:
'YYYY-MM-DD'
})
datetime_format
=
workbook
.
add_format
({
'num_format'
:
'YYYY-MM-DD HH:MM'
})
currency_format
=
workbook
.
add_format
({
'num_format'
:
'#,##0.00'
})
# 逗号作为千分位分隔符
worksheet
.
write
(
0
,
0
,
"业务日期"
,
header_format
)
worksheet
.
write
(
0
,
1
,
"摘要"
,
header_format
)
worksheet
.
write
(
0
,
2
,
"客户"
,
header_format
)
worksheet
.
write
(
0
,
3
,
"收入"
,
header_format
)
worksheet
.
write
(
0
,
4
,
"支出"
,
header_format
)
worksheet
.
write
(
0
,
5
,
"结余"
,
header_format
)
worksheet
.
write
(
0
,
6
,
"类型"
,
header_format
)
worksheet
.
write
(
0
,
7
,
"创建人"
,
header_format
)
worksheet
.
write
(
0
,
8
,
"创建时间"
,
header_format
)
for
row_num
,
row_data
in
enumerate
(
data
):
worksheet
.
write_datetime
(
row_num
+
1
,
0
,
row_data
.
get
(
"business_date"
),
date_format
)
worksheet
.
write
(
row_num
+
1
,
1
,
row_data
.
get
(
"abstract"
))
worksheet
.
write
(
row_num
+
1
,
2
,
row_data
.
get
(
"customer"
))
worksheet
.
write_number
(
row_num
+
1
,
3
,
row_data
.
get
(
"income"
),
currency_format
)
worksheet
.
write_number
(
row_num
+
1
,
4
,
row_data
.
get
(
"expenditure"
),
currency_format
)
worksheet
.
write_number
(
row_num
+
1
,
5
,
row_data
.
get
(
"balance"
),
currency_format
)
worksheet
.
write
(
row_num
+
1
,
6
,
row_data
.
get
(
"machinery_type"
))
worksheet
.
write
(
row_num
+
1
,
7
,
row_data
.
get
(
"user_name"
))
worksheet
.
write_datetime
(
row_num
+
1
,
8
,
row_data
.
get
(
"create_date"
),
datetime_format
)
workbook
.
close
()
output
.
seek
(
0
)
file_name
=
'财务收支记录.xlsx'
response
=
request
.
make_response
(
None
,
headers
=
[
(
'Content-Type'
,
'application/vnd.ms-excel'
),
(
'Content-Disposition'
,
content_disposition
(
file_name
))
]
)
response
.
stream
.
write
(
output
.
read
())
output
.
close
()
return
response
roke_product_income_expense/models/product_income_expense.py
View file @
2edde48c
...
...
@@ -14,10 +14,13 @@ class ProductIncomeExpense(models.Model):
income
=
fields
.
Float
(
string
=
"收入"
)
expenditure
=
fields
.
Float
(
string
=
"支出"
)
balance
=
fields
.
Float
(
string
=
"结余"
,
compute
=
"_compute_balance"
)
machinery_type
=
fields
.
Selection
([(
"烘干桶"
,
"烘干桶"
),
(
"钣金"
,
"钣金"
),
(
"颗粒机"
,
"颗粒机"
),
(
"其他"
,
"其他"
)],
default
=
"其他"
,
string
=
"类型"
)
customer
=
fields
.
Char
(
string
=
"客户"
)
@api.depends
(
"income"
,
"expenditure"
)
def
_compute_balance
(
self
):
data
=
self
.
search
([
(
"id"
,
"in"
,
self
.
ids
)
],
order
=
"business_date asc, create_date asc"
)
data
=
self
.
search
([],
order
=
"business_date asc, create_date asc"
)
for
v
in
data
:
last_data
=
self
.
search
([
"|"
,
...
...
@@ -28,6 +31,6 @@ class ProductIncomeExpense(models.Model):
(
"id"
,
"!="
,
v
.
id
)
],
limit
=
1
,
order
=
"business_date desc, create_date desc"
)
if
not
last_data
:
v
.
balance
=
0
+
v
.
income
-
v
.
expenditure
v
.
balance
=
round
(
0
+
v
.
income
-
v
.
expenditure
,
2
)
else
:
v
.
balance
=
last_data
.
balance
+
v
.
income
-
v
.
expenditure
v
.
balance
=
round
(
last_data
.
balance
+
v
.
income
-
v
.
expenditure
,
2
)
roke_product_income_expense/static/src/js/index.html
View file @
2edde48c
...
...
@@ -34,6 +34,11 @@
<el-input
v-model=
"scope.row.abstract"
placeholder=
"请输入"
></el-input>
</template>
</el-table-column>
<el-table-column
label=
"客户"
align=
"center"
width=
"180"
>
<template
slot-scope=
"scope"
>
<el-input
v-model=
"scope.row.customer"
placeholder=
"请输入"
></el-input>
</template>
</el-table-column>
<el-table-column
label=
"收入"
align=
"center"
width=
"120"
>
<template
slot-scope=
"scope"
>
<el-input
v-model=
"scope.row.income"
type=
"number"
placeholder=
"请输入"
></el-input>
...
...
@@ -44,56 +49,101 @@
<el-input
v-model=
"scope.row.expenditure"
type=
"number"
placeholder=
"请输入"
></el-input>
</template>
</el-table-column>
<!-- <el-table-column label="创建人" align="center" width="110">-->
<!-- <template slot-scope="scope">-->
<!-- <div>-->
<!-- [[ scope.row.user_name ]]-->
<!-- </div>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column
label=
"类型"
align=
"center"
width=
"180"
>
<template
slot-scope=
"scope"
>
<!-- <el-input v-model="scope.row.machinery_type" type="number" placeholder="请输入"></el-input> -->
<el-select
v-model=
"scope.row.machinery_type"
clearable
placeholder=
"请选择类型"
>
<el-option
v-for=
"item in machinery_type_options"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
>
</el-option>
</el-select>
</template>
</el-table-column>
<!-- <el-table-column label="创建人" align="center" width="110">
<template slot-scope="scope">
<div>
[[ scope.row.user_name ]]
</div>
</template>
</el-table-column> -->
<el-table-column
label=
"操作"
align=
"center"
width=
"95"
>
<template
slot-scope=
"scope"
>
<el-button
type=
"primary"
@
click=
"saveListData"
>
保存
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div
style=
"text-align: right; margin-bottom: 5px;"
>
<el-date-picker
v-model=
"datePickerValue"
type=
"daterange"
range-separator=
"至"
start-placeholder=
"开始日期"
end-placeholder=
"结束日期"
format=
"yyyy-MM-dd"
value-format=
"yyyy-MM-dd"
<div
style=
"display: flex;justify-content: flex-end; text-align: right; margin-bottom: 5px;"
>
<el-select
v-model=
"select_value"
clearable
placeholder=
"请选择收支类型"
@
change=
"select_change"
>
<el-option
v-for=
"item in select_options"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
>
</el-option>
</el-select>
<el-select
class=
"margin_sty"
v-model=
"machinery_type_value"
clearable
placeholder=
"请选择类型"
@
change=
"machinery_type_change"
>
<el-option
v-for=
"item in machinery_type_options"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
>
</el-option>
</el-select>
<el-input
style=
"width: 15%;"
v-model=
"customer_value"
placeholder=
"请填写客户名称"
@
change=
"select_change"
></el-input>
<el-date-picker
class=
"margin_sty"
v-model=
"datePickerValue"
type=
"daterange"
range-separator=
"至"
start-placeholder=
"开始日期"
end-placeholder=
"结束日期"
format=
"yyyy-MM-dd"
value-format=
"yyyy-MM-dd"
@
change=
"datePickerChange"
>
</el-date-picker>
<el-button
type=
"primary"
@
click=
"export_click"
>
导出
</el-button>
<el-button
v-if=
"edit_state"
type=
"primary"
@
click=
"save_modifications"
>
保存修改
</el-button>
</div>
<el-table
:data=
"dataList"
border
height=
"500"
:row-style=
"{height: '0'}"
<el-table
:data=
"dataList"
border
height=
"500"
:row-style=
"{height: '0'}"
:key=
"table_key"
style=
"width: 100%;border: 1px solid black;border-color: black"
:cell-style=
"tableCellStyle"
:header-cell-style=
"tableHeaderCellStyle"
>
<el-table-column
label=
"业务日期"
align=
"center"
width=
"1
66
"
>
<el-table-column
label=
"业务日期"
align=
"center"
width=
"1
50
"
>
<template
slot-scope=
"scope"
>
<div>
<el-date-picker
v-if=
"scope.row.whether_edit"
v-model=
"scope.row.business_date"
type=
"date"
format=
"yyyy-MM-dd"
value-format=
"yyyy-MM-dd"
placeholder=
"选择日期"
>
</el-date-picker>
<div
v-else
>
[[ scope.row.business_date ]]
</div>
</template>
</el-table-column>
<el-table-column
label=
"摘要"
align=
"center"
>
<template
slot-scope=
"scope"
>
<div
style=
"text-align: left;"
>
<el-input
v-if=
"scope.row.whether_edit"
type=
"textarea"
v-model=
"scope.row.abstract"
placeholder=
"请输入"
></el-input>
<div
style=
"text-align: left;"
v-else
>
[[ scope.row.abstract ]]
</div>
</template>
</el-table-column>
<el-table-column
label=
"收入"
align=
"center"
width=
"120"
>
<el-table-column
label=
"客户"
align=
"center"
>
<template
slot-scope=
"scope"
>
<el-input
v-if=
"scope.row.whether_edit"
v-model=
"scope.row.customer"
placeholder=
"请输入"
></el-input>
<div
style=
"text-align: left;"
v-else
>
[[ scope.row.customer ]]
</div>
</template>
</el-table-column>
<el-table-column
label=
"收入"
align=
"center"
width=
"100"
>
<template
slot-scope=
"scope"
>
<div
style=
"text-align: right;"
>
<el-input
v-if=
"scope.row.whether_edit"
v-model=
"scope.row.income"
type=
"number"
placeholder=
"请输入"
></el-input>
<div
style=
"text-align: right;"
v-else
>
[[ scope.row.income ]]
</div>
</template>
</el-table-column>
<el-table-column
label=
"支出"
align=
"center"
width=
"1
2
0"
>
<el-table-column
label=
"支出"
align=
"center"
width=
"1
0
0"
>
<template
slot-scope=
"scope"
>
<div
style=
"text-align: right;"
>
<el-input
v-if=
"scope.row.whether_edit"
v-model=
"scope.row.expenditure"
type=
"number"
placeholder=
"请输入"
></el-input>
<div
style=
"text-align: right;"
v-else
>
[[ scope.row.expenditure ]]
</div>
</template>
...
...
@@ -105,7 +155,20 @@
</div>
</template>
</el-table-column>
<el-table-column
label=
"创建人"
align=
"center"
width=
"110"
>
<el-table-column
label=
"类型"
align=
"center"
width=
"120"
>
<template
slot-scope=
"scope"
>
<el-select
v-if=
"scope.row.whether_edit"
v-model=
"scope.row.machinery_type"
clearable
placeholder=
"请选择类型"
>
<el-option
v-for=
"item in machinery_type_options"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
>
</el-option>
</el-select>
<div
v-else
>
[[ scope.row.machinery_type ]]
</div>
</template>
</el-table-column>
<el-table-column
label=
"创建人"
align=
"center"
width=
"100"
>
<template
slot-scope=
"scope"
>
<div>
[[ scope.row.user_name ]]
...
...
@@ -119,8 +182,11 @@
</div>
</template>
</el-table-column>
<el-table-column
label=
"操作"
align=
"center"
width=
"
8
0"
>
<el-table-column
label=
"操作"
align=
"center"
width=
"
12
0"
>
<template
slot-scope=
"scope"
>
<!-- <el-button v-if="scope.row.whether_edit" type="primary">保存</el-button> -->
<el-button
v-if=
"!scope.row.whether_edit"
type=
"primary"
icon=
"el-icon-edit"
circle
@
click=
"item_edit(scope)"
></el-button>
<el-button
type=
"danger"
icon=
"el-icon-delete"
circle
@
click=
"deleteItem(scope)"
></el-button>
</template>
</el-table-column>
...
...
@@ -144,19 +210,47 @@
paginationTotal
:
10
,
loading
:
false
,
dataList
:
[],
table_key
:
false
,
user_name
:
''
,
user_id
:
null
,
createList
:
[
{
business_date
:
''
,
abstract
:
''
,
customer
:
''
,
income
:
''
,
expenditure
:
''
,
user_name
:
''
,
user_id
:
null
,
machinery_type
:
''
}
],
datePickerValue
:
[
''
,
''
]
datePickerValue
:
[
''
,
''
],
select_options
:
[{
value
:
'income'
,
label
:
'收入'
},
{
value
:
'expenditure'
,
label
:
'支出'
}],
machinery_type_options
:
[{
value
:
'烘干桶'
,
label
:
'烘干桶'
},
{
value
:
'钣金'
,
label
:
'钣金'
},
{
value
:
'颗粒机'
,
label
:
'颗粒机'
},
{
value
:
'其他'
,
label
:
'其他'
}],
select_value
:
''
,
machinery_type_value
:
''
,
customer_value
:
''
,
edit_state
:
false
,
edit_list
:
[]
};
},
...
...
@@ -170,9 +264,84 @@
this
.
getDataList
()
},
methods
:
{
// 保存修改
save_modifications
()
{
for
(
let
i
=
0
;
i
<
this
.
edit_list
.
length
;
i
++
)
{
if
(
!
this
.
edit_list
[
i
].
business_date
)
{
return
this
.
$message
({
type
:
"warning"
,
message
:
"请选择业务日期"
,
});
}
else
if
(
this
.
edit_list
[
i
].
machinery_type
==
''
)
{
return
this
.
$message
({
type
:
"warning"
,
message
:
"请选择类型"
,
});
}
else
if
((
this
.
edit_list
[
i
].
income
==
''
&&
this
.
edit_list
[
i
].
income
!=
0
)
||
(
this
.
edit_list
[
i
].
expenditure
==
''
&&
this
.
edit_list
[
i
].
expenditure
!=
0
))
{
return
this
.
$message
({
type
:
"warning"
,
message
:
"请填写收入或支出后保存"
,
});
}
this
.
edit_list
[
i
].
user_id
=
this
.
user_id
}
this
.
loading
=
true
;
axios
.
request
({
url
:
"/roke/product/product_income_expense/create"
,
method
:
"post"
,
headers
:
{
"Content-Type"
:
"application/json"
,
},
data
:
{
data_list
:
this
.
edit_list
}
}).
then
((
res
)
=>
{
if
(
res
.
data
.
result
.
code
===
0
)
{
this
.
$message
({
type
:
"success"
,
message
:
res
.
data
.
result
.
message
||
"修改成功"
,
});
this
.
currentPageNo
=
1
this
.
createList
=
[
{
business_date
:
moment
().
format
(
"YYYY-MM-DD"
),
abstract
:
''
,
income
:
''
,
customer
:
''
,
expenditure
:
''
,
user_name
:
this
.
user_name
,
user_id
:
this
.
user_id
,
machinery_type
:
''
}
]
this
.
select_value
=
''
this
.
machinery_type_value
=
''
this
.
customer_value
=
''
this
.
datePickerValue
=
''
this
.
edit_list
=
[]
this
.
edit_state
=
false
this
.
getDataList
()
}
else
{
this
.
$message
({
type
:
"error"
,
message
:
res
.
data
.
result
.
message
||
"修改失败"
,
});
}
this
.
loading
=
false
;
});
},
machinery_type_change
(
e
)
{
this
.
getDataList
()
},
select_change
(
e
)
{
console
.
log
(
e
);
console
.
log
(
this
.
select_value
);
this
.
getDataList
()
},
// 列表 时间过滤
datePickerChange
(
e
)
{
console
.
log
(
e
);
if
(
!
e
)
{
this
.
datePickerValue
=
[
''
,
''
]
}
...
...
@@ -180,17 +349,37 @@
},
// 分页请求数据
handleCurrentChangee
(
val
)
{
if
(
this
.
edit_list
.
length
>
0
)
{
this
.
$confirm
(
'有编辑的内容未保存, 是否保存?'
,
'提示'
,
{
confirmButtonText
:
'确认保存'
,
cancelButtonText
:
'取消保存'
,
type
:
'warning'
}).
then
(()
=>
{
this
.
save_modifications
()
}).
catch
(()
=>
{
this
.
edit_list
=
[]
this
.
currentPageNo
=
val
;
this
.
getDataList
()
});
}
else
{
this
.
currentPageNo
=
val
;
this
.
getDataList
()
}
},
// 获取列表数据
getDataList
()
{
if
(
!
this
.
datePickerValue
)
{
this
.
datePickerValue
=
[
''
,
''
]
}
this
.
loading
=
true
;
let
parameter
=
{
limit
:
10
,
//每页数量 非必填
page
:
this
.
currentPageNo
,
//当前页码
start_date
:
this
.
datePickerValue
[
0
],
end_date
:
this
.
datePickerValue
[
1
]
end_date
:
this
.
datePickerValue
[
1
],
type_str
:
this
.
select_value
,
machinery_type
:
this
.
machinery_type_value
,
customer
:
this
.
customer_value
}
axios
.
request
({
url
:
"/roke/product/product_income_expense/get"
,
...
...
@@ -202,6 +391,9 @@
}).
then
((
res
)
=>
{
if
(
res
.
data
.
result
.
code
===
0
)
{
this
.
paginationTotal
=
res
.
data
.
result
.
count
res
.
data
.
result
.
data
.
forEach
(
item
=>
{
item
.
whether_edit
=
false
});
this
.
dataList
=
res
.
data
.
result
.
data
}
else
{
this
.
$message
({
...
...
@@ -210,7 +402,20 @@
});
}
this
.
loading
=
false
;
}).
catch
(
err
=>
{
console
.
log
(
err
);
this
.
$message
({
type
:
"error"
,
message
:
"接口报错,获取列表数据失败"
,
});
})
},
item_edit
(
scope
)
{
console
.
log
(
scope
);
this
.
edit_list
.
push
(
scope
.
row
)
this
.
edit_state
=
true
scope
.
row
.
whether_edit
=
true
this
.
table_key
=
!
this
.
table_key
},
// 删除
deleteItem
(
item
,
index
)
{
...
...
@@ -243,10 +448,65 @@
}
else
{
this
.
dataList
.
splice
(
item
.
$index
,
1
)
}
if
(
this
.
edit_list
.
length
>
0
)
{
this
.
edit_list
.
forEach
((
res_itm
,
res_idx
)
=>
{
if
(
res_itm
.
id
==
item
.
row
.
id
)
{
this
.
edit_list
.
splice
(
res_idx
,
1
)
}
})
}
},
// 导出
export_click
()
{
if
(
this
.
dataList
.
length
>
0
)
{
this
.
loading
=
true
;
let
formData
=
new
FormData
();
let
_config
=
{
responseType
:
'blob'
}
if
(
!
this
.
datePickerValue
)
{
this
.
datePickerValue
=
[
''
,
''
]
}
formData
.
append
(
"start_date"
,
this
.
datePickerValue
[
0
]);
formData
.
append
(
"end_date"
,
this
.
datePickerValue
[
1
]);
formData
.
append
(
"type_str"
,
this
.
select_value
);
formData
.
append
(
"machinery_type"
,
this
.
machinery_type_value
);
formData
.
append
(
"customer"
,
this
.
customer_value
);
axios
.
post
(
"/roke/product/product_income_expense/export"
,
formData
,
_config
,
).
then
(
res
=>
{
this
.
loading
=
false
let
blob
=
new
Blob
([
res
.
data
],
{
type
:
res
.
data
.
type
});
let
url
=
window
.
URL
.
createObjectURL
(
blob
);
let
link
=
document
.
createElement
(
"a"
);
link
.
style
.
display
=
"none"
;
link
.
href
=
url
;
link
.
setAttribute
(
"download"
,
`财务收入支出表.xlsx`
);
document
.
body
.
appendChild
(
link
);
link
.
click
();
document
.
body
.
removeChild
(
link
);
window
.
URL
.
revokeObjectURL
(
url
);
})
}
else
{
this
.
$message
({
type
:
'error'
,
message
:
'请根据配置的筛选条件查询数据后在导出报表!'
});
}
},
// 保存
saveListData
()
{
if
(
!
this
.
createList
[
0
].
business_date
)
{
return
this
.
$message
({
type
:
"warning"
,
message
:
"请选择业务日期"
,
});
}
if
(
this
.
createList
[
0
].
machinery_type
==
''
)
{
this
.
$message
({
type
:
"warning"
,
message
:
"请选择类型"
,
});
}
else
{
if
(
this
.
createList
[
0
].
income
!=
''
||
this
.
createList
[
0
].
expenditure
!=
''
)
{
this
.
loading
=
true
;
axios
.
request
({
...
...
@@ -270,11 +530,17 @@
business_date
:
moment
().
format
(
"YYYY-MM-DD"
),
abstract
:
''
,
income
:
''
,
customer
:
''
,
expenditure
:
''
,
user_name
:
this
.
user_name
,
user_id
:
this
.
user_id
user_id
:
this
.
user_id
,
machinery_type
:
''
}
]
this
.
select_value
=
''
this
.
machinery_type_value
=
''
this
.
customer_value
=
''
this
.
datePickerValue
=
''
this
.
getDataList
()
}
else
{
this
.
$message
({
...
...
@@ -290,6 +556,8 @@
message
:
"请填写收入或支出后保存"
,
});
}
}
},
// table样式
tableCellStyle
()
{
...
...
@@ -328,7 +596,7 @@
}
body
{
padding
:
15px
35px
30px
3
5px
;
padding
:
15px
25px
25px
2
5px
;
}
.el-table
.el-table__cell
{
...
...
@@ -338,6 +606,15 @@
.el-date-editor.el-input
{
width
:
140px
;
}
.margin_sty
{
margin
:
0
10px
;
}
.el-textarea__inner
{
font-family
:
"Helvetica Neue"
,
Helvetica
,
"PingFang SC"
,
"Hiragino Sans GB"
,
"Microsoft YaHei"
,
"微软雅黑"
,
Arial
,
sans-serif
;
}
</style>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment