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
dd28d5f9
Commit
dd28d5f9
authored
Oct 28, 2024
by
夏超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fix] 收入支出修改
parent
cc119079
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
143 additions
and
132 deletions
+143
-132
roke_product_income_expense/controller/main.py
+13
-18
roke_product_income_expense/models/product_income_expense.py
+14
-1
roke_product_income_expense/static/src/js/index.html
+116
-113
No files found.
roke_product_income_expense/controller/main.py
View file @
dd28d5f9
...
@@ -27,36 +27,31 @@ class ProductIncomeExpenseIframe(http.Controller):
...
@@ -27,36 +27,31 @@ class ProductIncomeExpenseIframe(http.Controller):
def
product_income_expense_create
(
self
):
def
product_income_expense_create
(
self
):
_self
=
http
.
request
_self
=
http
.
request
data_list
=
_self
.
jsonrequest
.
get
(
"data_list"
,
[])
data_list
=
_self
.
jsonrequest
.
get
(
"data_list"
,
[])
return_data
=
[]
for
v
in
data_list
:
for
v
in
data_list
:
data
=
{
data
=
{
"business_date"
:
v
.
get
(
"business_date"
,
False
),
"business_date"
:
v
.
get
(
"business_date"
,
False
),
"abstract"
:
v
.
get
(
"abstract"
,
False
),
"abstract"
:
v
.
get
(
"abstract"
,
False
),
"income"
:
v
.
get
(
"income"
,
False
),
"income"
:
v
.
get
(
"income"
,
False
),
"expenditure"
:
v
.
get
(
"expenditure"
,
False
),
"expenditure"
:
v
.
get
(
"expenditure"
,
False
)
"balance"
:
v
.
get
(
"balance"
,
False
)
}
}
result
=
_self
.
env
(
user
=
v
.
get
(
"user_id"
))[
"roke.product.income.expense"
]
.
create
(
data
)
_self
.
env
(
user
=
v
.
get
(
"user_id"
))[
"roke.product.income.expense"
]
.
create
(
data
)
return_data
.
append
({
return
{
"code"
:
0
,
"message"
:
"创建成功!"
}
"id"
:
result
.
id
,
"business_date"
:
result
.
business_date
and
result
.
business_date
.
strftime
(
'
%
Y-
%
m-
%
d'
),
"abstract"
:
result
.
abstract
or
""
,
"income"
:
result
.
income
or
0
,
"expenditure"
:
result
.
expenditure
or
0
,
"balance"
:
result
.
balance
or
0
,
"user_name"
:
result
.
create_uid
.
name
or
""
,
"create_date"
:
(
result
.
create_date
+
datetime
.
timedelta
(
hours
=
8
))
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M'
),
})
return
{
"code"
:
0
,
"message"
:
"创建成功!"
,
"data"
:
return_data
}
@http.route
(
"/roke/product/product_income_expense/get"
,
type
=
"json"
,
auth
=
'none'
,
cors
=
'*'
,
csrf
=
False
)
@http.route
(
"/roke/product/product_income_expense/get"
,
type
=
"json"
,
auth
=
'none'
,
cors
=
'*'
,
csrf
=
False
)
def
product_income_expense_get_list
(
self
):
def
product_income_expense_get_list
(
self
):
_self
=
http
.
request
_self
=
http
.
request
limit
=
_self
.
jsonrequest
.
get
(
"limit"
,
20
)
limit
=
_self
.
jsonrequest
.
get
(
"limit"
,
20
)
page
=
_self
.
jsonrequest
.
get
(
"page"
,
1
)
page
=
_self
.
jsonrequest
.
get
(
"page"
,
1
)
data_list
=
_self
.
env
[
"roke.product.income.expense"
]
.
sudo
()
.
search
([],
limit
=
limit
,
offset
=
(
page
-
1
)
*
limit
,
start_date
=
_self
.
jsonrequest
.
get
(
"start_date"
,
""
)
order
=
"create_date desc"
)
end_date
=
_self
.
jsonrequest
.
get
(
"end_date"
,
""
)
count
=
_self
.
env
[
"roke.product.income.expense"
]
.
sudo
()
.
search_count
([])
domain
=
[]
if
start_date
and
end_date
:
domain
.
append
((
"business_date"
,
">="
,
start_date
))
domain
.
append
((
"business_date"
,
"<="
,
end_date
))
data_list
=
_self
.
env
[
"roke.product.income.expense"
]
.
sudo
()
.
search
(
domain
,
limit
=
limit
,
offset
=
(
page
-
1
)
*
limit
,
order
=
"create_date desc"
)
count
=
_self
.
env
[
"roke.product.income.expense"
]
.
sudo
()
.
search_count
(
domain
)
data
=
[]
data
=
[]
for
v
in
data_list
:
for
v
in
data_list
:
data
.
append
({
data
.
append
({
...
...
roke_product_income_expense/models/product_income_expense.py
View file @
dd28d5f9
...
@@ -13,4 +13,17 @@ class ProductIncomeExpense(models.Model):
...
@@ -13,4 +13,17 @@ class ProductIncomeExpense(models.Model):
abstract
=
fields
.
Text
(
string
=
"摘要"
)
abstract
=
fields
.
Text
(
string
=
"摘要"
)
income
=
fields
.
Float
(
string
=
"收入"
)
income
=
fields
.
Float
(
string
=
"收入"
)
expenditure
=
fields
.
Float
(
string
=
"支出"
)
expenditure
=
fields
.
Float
(
string
=
"支出"
)
balance
=
fields
.
Float
(
string
=
"结余"
)
balance
=
fields
.
Float
(
string
=
"结余"
,
compute
=
"_compute_balance"
)
@api.depends
(
"income"
,
"expenditure"
)
def
_compute_balance
(
self
):
data
=
self
.
search
([(
"id"
,
"in"
,
self
.
ids
)],
order
=
"create_date asc"
)
for
v
in
data
:
last_data
=
self
.
search
([
(
"create_date"
,
"<"
,
v
.
create_date
),
(
"id"
,
"!="
,
v
.
id
)
],
limit
=
1
,
order
=
"create_date desc"
)
if
not
last_data
:
v
.
balance
=
0
+
v
.
income
-
v
.
expenditure
else
:
v
.
balance
=
last_data
.
balance
+
v
.
income
-
v
.
expenditure
roke_product_income_expense/static/src/js/index.html
View file @
dd28d5f9
...
@@ -17,56 +17,92 @@
...
@@ -17,56 +17,92 @@
</head>
</head>
<body>
<body>
<div
id=
"app"
>
<div
id=
"app"
v-loading=
"loading"
element-loading-text=
"加载中..."
>
<div
style=
"text-align: right; margin-bottom: 10px;"
>
<div
style=
"margin-bottom: 20px;"
>
<el-button
type=
"primary"
@
click=
"saveListData"
>
保存
</el-button>
<el-table
:data=
"createList"
border
:row-style=
"{height: '0'}"
<el-button
type=
"primary"
icon=
"el-icon-plus"
@
click=
"addData"
>
添加
</el-button>
style=
"width: 100%;border: 1px solid black;border-color: black"
:cell-style=
"tableCellStyle"
:header-cell-style=
"tableHeaderCellStyle"
>
<el-table-column
label=
"业务日期"
align=
"center"
width=
"166"
>
<template
slot-scope=
"scope"
>
<el-date-picker
v-model=
"scope.row.business_date"
type=
"date"
format=
"yyyy-MM-dd"
value-format=
"yyyy-MM-dd"
placeholder=
"选择日期"
>
</el-date-picker>
</template>
</el-table-column>
<el-table-column
label=
"摘要"
align=
"center"
>
<template
slot-scope=
"scope"
>
<el-input
v-model=
"scope.row.abstract"
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>
</template>
</el-table-column>
<el-table-column
label=
"支出"
align=
"center"
width=
"120"
>
<template
slot-scope=
"scope"
>
<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=
"95"
>
<template
slot-scope=
"scope"
>
<el-button
type=
"primary"
@
click=
"saveListData"
>
保存
</el-button>
</template>
</el-table-column>
</el-table>
</div>
</div>
<el-table
:data=
"dataList"
border
height=
"578"
v-loading=
"loading"
:row-style=
"{height: '0'}"
<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"
@
change=
"datePickerChange"
>
</el-date-picker>
</div>
<el-table
:data=
"dataList"
border
height=
"500"
:row-style=
"{height: '0'}"
style=
"width: 100%;border: 1px solid black;border-color: black"
:cell-style=
"tableCellStyle"
style=
"width: 100%;border: 1px solid black;border-color: black"
:cell-style=
"tableCellStyle"
:header-cell-style=
"tableHeaderCellStyle"
>
:header-cell-style=
"tableHeaderCellStyle"
>
<el-table-column
label=
"业务日期"
align=
"center"
width=
"166"
>
<el-table-column
label=
"业务日期"
align=
"center"
width=
"166"
>
<template
slot-scope=
"scope"
>
<template
slot-scope=
"scope"
>
<div
v-if=
"scope.row.id"
>
<div>
[[ scope.row.business_date ]]
[[ scope.row.business_date ]]
</div>
</div>
<el-date-picker
v-else
v-model=
"scope.row.business_date"
type=
"date"
format=
"yyyy-MM-dd"
value-format=
"yyyy-MM-dd"
placeholder=
"选择日期"
>
</el-date-picker>
</template>
</template>
</el-table-column>
</el-table-column>
<el-table-column
label=
"摘要"
align=
"center"
width=
"600"
>
<el-table-column
label=
"摘要"
align=
"center"
>
<template
slot-scope=
"scope"
>
<template
slot-scope=
"scope"
>
<div
v-if=
"scope.row.id
"
>
<div
style=
"text-align: left;
"
>
[[ scope.row.abstract ]]
[[ scope.row.abstract ]]
</div>
</div>
<el-input
v-else
style=
"width: 570px;"
v-model=
"scope.row.abstract"
placeholder=
"请输入摘要"
></el-input>
</template>
</template>
</el-table-column>
</el-table-column>
<el-table-column
label=
"收入"
align=
"center"
>
<el-table-column
label=
"收入"
align=
"center"
width=
"120"
>
<template
slot-scope=
"scope"
>
<template
slot-scope=
"scope"
>
<div
v-if=
"scope.row.id
"
>
<div
style=
"text-align: right;
"
>
[[ scope.row.income ]]
[[ scope.row.income ]]
</div>
</div>
<el-input
v-else
v-model=
"scope.row.income"
type=
"number"
placeholder=
"请输入收入"
@
input=
"calculationFormula(scope.row)"
></el-input>
</template>
</template>
</el-table-column>
</el-table-column>
<el-table-column
label=
"支出"
align=
"center"
>
<el-table-column
label=
"支出"
align=
"center"
width=
"120"
>
<template
slot-scope=
"scope"
>
<template
slot-scope=
"scope"
>
<div
v-if=
"scope.row.id
"
>
<div
style=
"text-align: right;
"
>
[[ scope.row.expenditure ]]
[[ scope.row.expenditure ]]
</div>
</div>
<el-input
v-else
v-model=
"scope.row.expenditure"
type=
"number"
placeholder=
"请输入支出"
@
input=
"calculationFormula(scope.row)"
></el-input>
</template>
</template>
</el-table-column>
</el-table-column>
<el-table-column
label=
"结余"
align=
"center"
width=
"1
1
0"
>
<el-table-column
label=
"结余"
align=
"center"
width=
"1
2
0"
>
<template
slot-scope=
"scope"
>
<template
slot-scope=
"scope"
>
<div>
<div>
[[ scope.row.balance ]]
[[ scope.row.balance ]]
</div>
</div>
<!-- <el-input v-else v-model="scope.row.balance" placeholder="请输入结余"></el-input> -->
</template>
</template>
</el-table-column>
</el-table-column>
<el-table-column
label=
"创建人"
align=
"center"
width=
"110"
>
<el-table-column
label=
"创建人"
align=
"center"
width=
"110"
>
...
@@ -76,7 +112,7 @@
...
@@ -76,7 +112,7 @@
</div>
</div>
</template>
</template>
</el-table-column>
</el-table-column>
<el-table-column
label=
"创建时间"
align=
"center"
>
<el-table-column
label=
"创建时间"
align=
"center"
width=
"160"
>
<template
slot-scope=
"scope"
>
<template
slot-scope=
"scope"
>
<div>
<div>
[[ scope.row.create_date ]]
[[ scope.row.create_date ]]
...
@@ -91,7 +127,7 @@
...
@@ -91,7 +127,7 @@
</el-table>
</el-table>
<div
style=
"margin-top: 10px; text-align: center;"
>
<div
style=
"margin-top: 10px; text-align: center;"
>
<el-pagination
:current-page=
"currentPageNo"
:total=
"paginationTotal"
@
current-change=
"handleCurrentChangee"
<el-pagination
:current-page=
"currentPageNo"
:total=
"paginationTotal"
@
current-change=
"handleCurrentChangee"
:page-size=
"
2
0"
layout=
"prev, pager, next,total"
>
:page-size=
"
1
0"
layout=
"prev, pager, next,total"
>
</el-pagination>
</el-pagination>
</div>
</div>
</div>
</div>
...
@@ -104,63 +140,57 @@
...
@@ -104,63 +140,57 @@
data
()
{
data
()
{
return
{
return
{
TableHeight
:
0
,
TableHeight
:
0
,
input
:
''
,
dateValue
:
''
,
currentPageNo
:
1
,
currentPageNo
:
1
,
paginationTotal
:
10
0
,
paginationTotal
:
10
,
loading
:
false
,
loading
:
false
,
dataList
:
[],
dataList
:
[],
user_name
:
''
,
user_name
:
''
,
user_id
:
null
user_id
:
null
,
createList
:
[
{
business_date
:
''
,
abstract
:
''
,
income
:
''
,
expenditure
:
''
,
user_name
:
''
,
user_id
:
null
,
}
],
datePickerValue
:
[
''
,
''
]
};
};
},
},
created
()
{
created
()
{
this
.
user_name
=
this
.
getUrlSearch
(
'user_name'
)
//截取url后面的参数
this
.
user_name
=
this
.
getUrlSearch
(
'user_name'
)
//截取url后面的参数
this
.
user_id
=
this
.
getUrlSearch
(
'user_id'
)
this
.
user_id
=
this
.
getUrlSearch
(
'user_id'
)
this
.
createList
[
0
].
user_name
=
this
.
user_name
this
.
createList
[
0
].
business_date
=
moment
().
format
(
"YYYY-MM-DD"
)
this
.
createList
[
0
].
user_id
=
this
.
user_id
this
.
TableHeight
=
window
.
innerHeight
;
this
.
TableHeight
=
window
.
innerHeight
;
// axios.request({
// url: "/roke/mes/client_login",
// method: "post",
// headers: {
// "Content-Type": "application/json",
// },
// data: {
// "login": "admin",
// "password": "admin"
// },
// }).then((res) => {
// });
this
.
getDataList
()
this
.
getDataList
()
},
},
methods
:
{
methods
:
{
// 收入-支出 = 结余
// 列表 时间过滤
calculationFormula
(
e
)
{
datePickerChange
(
e
)
{
e
.
balance
=
e
.
income
-
e
.
expenditure
console
.
log
(
e
);
},
if
(
!
e
)
{
// table样式
this
.
datePickerValue
=
[
''
,
''
]
tableCellStyle
()
{
}
return
"border-color:black;"
this
.
getDataList
()
},
// 修改 table header cell的背景色
tableHeaderCellStyle
()
{
return
'background: #eef1f6;border-color: black;color:black'
},
},
// 分页请求数据
// 分页请求数据
handleCurrentChangee
(
val
,
condition
)
{
handleCurrentChangee
(
val
)
{
this
.
currentPageNo
=
val
;
this
.
currentPageNo
=
val
;
this
.
getDataList
(
condition
)
this
.
getDataList
()
},
},
// 获取列表数据
// 获取列表数据
getDataList
(
condition
)
{
getDataList
()
{
console
.
log
(
condition
);
this
.
loading
=
true
;
if
(
!
condition
){
this
.
loading
=
true
;
}
let
parameter
=
{
let
parameter
=
{
limit
:
20
,
//每页数量 非必填
limit
:
10
,
//每页数量 非必填
page
:
this
.
currentPageNo
,
//当前页码 非必填
page
:
this
.
currentPageNo
,
//当前页码
start_date
:
this
.
datePickerValue
[
0
],
end_date
:
this
.
datePickerValue
[
1
]
}
}
axios
.
request
({
axios
.
request
({
url
:
"/roke/product/product_income_expense/get"
,
url
:
"/roke/product/product_income_expense/get"
,
...
@@ -173,19 +203,6 @@
...
@@ -173,19 +203,6 @@
if
(
res
.
data
.
result
.
code
===
0
)
{
if
(
res
.
data
.
result
.
code
===
0
)
{
this
.
paginationTotal
=
res
.
data
.
result
.
count
this
.
paginationTotal
=
res
.
data
.
result
.
count
this
.
dataList
=
res
.
data
.
result
.
data
this
.
dataList
=
res
.
data
.
result
.
data
if
(
condition
==
'addData'
)
{
const
now
=
moment
();
this
.
dataList
.
unshift
({
business_date
:
now
.
format
(
"YYYY-MM-DD"
),
//业务日期
abstract
:
''
,
//摘要
income
:
''
,
//收入
expenditure
:
''
,
//支出
balance
:
0
,
//结余
user_name
:
this
.
user_name
,
//创建人
user_id
:
this
.
user_id
,
create_date
:
''
//创建时间
})
}
}
else
{
}
else
{
this
.
$message
({
this
.
$message
({
type
:
"error"
,
type
:
"error"
,
...
@@ -195,10 +212,6 @@
...
@@ -195,10 +212,6 @@
this
.
loading
=
false
;
this
.
loading
=
false
;
});
});
},
},
// 加载更多数据的函数
loadMoreData
()
{
// 添加更多数据到 tableData 中
},
// 删除
// 删除
deleteItem
(
item
,
index
)
{
deleteItem
(
item
,
index
)
{
if
(
item
.
row
.
id
)
{
if
(
item
.
row
.
id
)
{
...
@@ -218,7 +231,7 @@
...
@@ -218,7 +231,7 @@
type
:
"success"
,
type
:
"success"
,
message
:
res
.
data
.
result
.
message
||
"删除成功"
,
message
:
res
.
data
.
result
.
message
||
"删除成功"
,
});
});
this
.
dataList
.
splice
(
item
.
$index
,
1
)
this
.
getDataList
(
)
}
else
{
}
else
{
this
.
$message
({
this
.
$message
({
type
:
"error"
,
type
:
"error"
,
...
@@ -232,33 +245,9 @@
...
@@ -232,33 +245,9 @@
}
}
},
},
// 添加
addData
()
{
if
(
this
.
currentPageNo
==
1
)
{
const
now
=
moment
();
this
.
dataList
.
unshift
({
business_date
:
now
.
format
(
"YYYY-MM-DD"
),
//业务日期
abstract
:
''
,
//摘要
income
:
''
,
//收入
expenditure
:
''
,
//支出
balance
:
0
,
//结余
user_name
:
this
.
user_name
,
//创建人
user_id
:
this
.
user_id
,
create_date
:
''
//创建时间
})
}
else
{
this
.
handleCurrentChangee
(
1
,
'addData'
)
}
},
// 保存
// 保存
saveListData
()
{
saveListData
()
{
let
parameterList
=
[]
if
(
this
.
createList
[
0
].
income
!=
''
||
this
.
createList
[
0
].
expenditure
!=
''
)
{
this
.
dataList
.
forEach
(
item
=>
{
if
(
!
item
.
id
)
{
parameterList
.
push
(
item
)
}
});
if
(
parameterList
.
length
!=
0
)
{
this
.
loading
=
true
;
this
.
loading
=
true
;
axios
.
request
({
axios
.
request
({
url
:
"/roke/product/product_income_expense/create"
,
url
:
"/roke/product/product_income_expense/create"
,
...
@@ -267,7 +256,7 @@
...
@@ -267,7 +256,7 @@
"Content-Type"
:
"application/json"
,
"Content-Type"
:
"application/json"
,
},
},
data
:
{
data
:
{
data_list
:
parameter
List
data_list
:
this
.
create
List
}
}
}).
then
((
res
)
=>
{
}).
then
((
res
)
=>
{
if
(
res
.
data
.
result
.
code
===
0
)
{
if
(
res
.
data
.
result
.
code
===
0
)
{
...
@@ -276,6 +265,16 @@
...
@@ -276,6 +265,16 @@
message
:
res
.
data
.
result
.
message
||
"创建成功"
,
message
:
res
.
data
.
result
.
message
||
"创建成功"
,
});
});
this
.
currentPageNo
=
1
this
.
currentPageNo
=
1
this
.
createList
=
[
{
business_date
:
moment
().
format
(
"YYYY-MM-DD"
),
abstract
:
''
,
income
:
''
,
expenditure
:
''
,
user_name
:
this
.
user_name
,
user_id
:
this
.
user_id
}
]
this
.
getDataList
()
this
.
getDataList
()
}
else
{
}
else
{
this
.
$message
({
this
.
$message
({
...
@@ -288,10 +287,18 @@
...
@@ -288,10 +287,18 @@
}
else
{
}
else
{
this
.
$message
({
this
.
$message
({
type
:
"warning"
,
type
:
"warning"
,
message
:
"请
添加新记录
后保存"
,
message
:
"请
填写收入或支出
后保存"
,
});
});
}
}
},
},
// table样式
tableCellStyle
()
{
return
"border-color:black;"
},
// 修改 table header cell的背景色
tableHeaderCellStyle
()
{
return
'background: #eef1f6;border-color: black;color:black'
},
// 通过网址跳转过来的页面,截取后面的参数
// 通过网址跳转过来的页面,截取后面的参数
getUrlSearch
(
name
)
{
getUrlSearch
(
name
)
{
// 未传参,返回空
// 未传参,返回空
...
@@ -321,17 +328,13 @@
...
@@ -321,17 +328,13 @@
}
}
body
{
body
{
padding
:
15px
50px
30px
50
px
;
padding
:
15px
35px
30px
35
px
;
}
}
.el-table
.el-table__cell
{
.el-table
.el-table__cell
{
padding
:
4
px
0
;
padding
:
3
px
0
;
}
}
/* .el-input {
width: 120px;
} */
.el-date-editor.el-input
{
.el-date-editor.el-input
{
width
:
140px
;
width
:
140px
;
}
}
...
...
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