Commit 04c3b25c by 马丽华

Merge branch 'mlh_jzjx_project' into 'master'

收入支出合计

See merge request !32
parents 2d5c9ae8 28dbdfb0
...@@ -150,6 +150,10 @@ class ProductIncomeExpenseIframe(http.Controller): ...@@ -150,6 +150,10 @@ class ProductIncomeExpenseIframe(http.Controller):
_self.env.cr.execute(sql, params) _self.env.cr.execute(sql, params)
rows = _self.env.cr.dictfetchall() rows = _self.env.cr.dictfetchall()
# 计算当前页的收入合计和支出合计
total_income = round(sum(row.get('income', 0) or 0 for row in rows), 2)
total_expenditure = round(sum(row.get('expenditure', 0) or 0 for row in rows), 2)
# 查询总数 # 查询总数
sql_count = f"SELECT COUNT(*) FROM roke_product_income_expense WHERE {where_sql}" sql_count = f"SELECT COUNT(*) FROM roke_product_income_expense WHERE {where_sql}"
_self.env.cr.execute(sql_count, params[:-2]) # 去掉 limit 和 offset _self.env.cr.execute(sql_count, params[:-2]) # 去掉 limit 和 offset
...@@ -174,7 +178,7 @@ class ProductIncomeExpenseIframe(http.Controller): ...@@ -174,7 +178,7 @@ class ProductIncomeExpenseIframe(http.Controller):
"user_name": user_name, "user_name": user_name,
"create_date": create_date, "create_date": create_date,
}) })
return {"code": 0, "message": "获取成功!", "data": data, "count": count} return {"code": 0, "message": "获取成功!", "data": data, "count": count, "total_income": total_income, "total_expenditure": total_expenditure}
@http.route("/roke/product/product_income_expense/delete", type="json", auth='none', cors='*', csrf=False) @http.route("/roke/product/product_income_expense/delete", type="json", auth='none', cors='*', csrf=False)
def product_income_expense_delete(self): def product_income_expense_delete(self):
......
...@@ -4,16 +4,18 @@ ...@@ -4,16 +4,18 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<title>财务收支记录</title> <title>财务收支记录</title>
<!-- 引入element-ui CSS样式 --> <!-- 引入element-ui CSS样式、vue js、axios.js、moment.js、element-ui.js 文件 -->
<link rel="stylesheet" href="/roke_product_income_expense/static/src/js/element-ui/index.css" /> <link rel="stylesheet" href="/roke_product_income_expense/static/src/js/element-ui/index.css" />
<!-- 引入 vue js文件 -->
<script src="/roke_product_income_expense/static/src/js/js/vue.js"></script> <script src="/roke_product_income_expense/static/src/js/js/vue.js"></script>
<!-- 引入 axios js文件 -->
<script src="/roke_product_income_expense/static/src/js/js/axios.min.js"></script> <script src="/roke_product_income_expense/static/src/js/js/axios.min.js"></script>
<!-- moment.js 处理时间、日期 -->
<script src="/roke_product_income_expense/static/src/js/js/moment.js"></script> <script src="/roke_product_income_expense/static/src/js/js/moment.js"></script>
<!-- 引入 element-ui js文件 -->
<script src="/roke_product_income_expense/static/src/js/element-ui/index.js"></script> <script src="/roke_product_income_expense/static/src/js/element-ui/index.js"></script>
<!-- <link rel="stylesheet" href="./css/index.css" />
<script src="./js/vue.js"></script>
<script src="./js/axios.min.js"></script>
<script src="./js/moment.js"></script>
<script src="./js/index.js"></script> -->
</head> </head>
<body> <body>
...@@ -74,35 +76,31 @@ ...@@ -74,35 +76,31 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<div style="display: flex;justify-content: flex-end; text-align: right; margin-bottom: 5px;"> <div style="display: flex;justify-content: flex-end; text-align: right; margin-bottom: 5px;">
<el-input style="width: 15%;" v-model="abstract_value" placeholder="请填写摘要信息" @change="select_change"></el-input> <el-input style="width: 15%;" v-model="abstract_value" placeholder="请填写摘要信息"
@change="select_change"></el-input>
<el-select v-model="select_value" clearable placeholder="请选择收支类型" @change="select_change"> <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 v-for="item in select_options" :key="item.value" :label="item.label" :value="item.value">
</el-option> </el-option>
</el-select> </el-select>
<el-select class="margin_sty" v-model="machinery_type_value" clearable placeholder="请选择类型" <el-select class="margin_sty" v-model="machinery_type_value" clearable placeholder="请选择类型"
@change="machinery_type_change"> @change="machinery_type_change">
<el-option v-for="item in machinery_type_options" :key="item.value" :label="item.label" <el-option v-for="item in machinery_type_options" :key="item.value" :label="item.label"
:value="item.value"> :value="item.value">
</el-option> </el-option>
</el-select> </el-select>
<el-input style="width: 15%;" v-model="customer_value" placeholder="请填写客户名称"
<el-input style="width: 15%;" v-model="customer_value" placeholder="请填写客户名称" @change="select_change"></el-input> @change="select_change"></el-input>
<el-date-picker class="margin_sty" v-model="datePickerValue" type="daterange" range-separator="至"
<el-date-picker class="margin_sty" v-model="datePickerValue" type="daterange" range-separator="至" start-placeholder="开始日期" start-placeholder="开始日期" end-placeholder="结束日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
end-placeholder="结束日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @change="datePickerChange"> @change="datePickerChange">
</el-date-picker> </el-date-picker>
<el-button type="primary" @click="export_click">导出</el-button> <el-button type="primary" @click="export_click">导出</el-button>
<el-button v-if="edit_state" type="primary" @click="save_modifications">保存修改</el-button> <el-button v-if="edit_state" type="primary" @click="save_modifications">保存修改</el-button>
</div> </div>
<el-table :data="dataList" border height="500" :row-style="{height: '0'}" :key="table_key" <el-table ref="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" show-summary :summary-method="getSummaries" style="width: 100%;border: 1px solid black;border-color: black"
:header-cell-style="tableHeaderCellStyle"> :cell-style="tableCellStyle" :header-cell-style="tableHeaderCellStyle">
<el-table-column label="业务日期" align="center" width="150"> <el-table-column label="业务日期" align="center" width="150">
<template slot-scope="scope"> <template slot-scope="scope">
<el-date-picker v-if="scope.row.whether_edit" v-model="scope.row.business_date" type="date" <el-date-picker v-if="scope.row.whether_edit" v-model="scope.row.business_date" type="date"
...@@ -201,7 +199,7 @@ ...@@ -201,7 +199,7 @@
<script> <script>
new Vue({ new Vue({
el: "#app", el: "#app",
delimiters: ["[[", "]]"], // 替换原本vue的{{ key }}取值方式(与odoo使用的jinja2冲突问题) delimiters: ["[[", "]]"], // 替换原本vue的取值方式(与odoo使用的jinja2冲突问题)
data() { data() {
return { return {
...@@ -251,11 +249,15 @@ ...@@ -251,11 +249,15 @@
customer_value: '', customer_value: '',
abstract_value: '', abstract_value: '',
edit_state: false, edit_state: false,
edit_list: [] edit_list: [],
total_income: 0, // 收入总计
total_expenditure: 0, // 支出总计
}; };
}, },
created() { created() {
// axios.defaults.baseURL = 'http://jzjx.dws.rokecloud.com'
// axios.defaults.baseURL = 'http://192.168.8.61:8020'
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].user_name = this.user_name
...@@ -264,7 +266,31 @@ ...@@ -264,7 +266,31 @@
this.TableHeight = window.innerHeight; this.TableHeight = window.innerHeight;
this.getDataList() this.getDataList()
}, },
updated() {
this.$nextTick(() => {
this.$refs.table.doLayout()
})
},
methods: { methods: {
getSummaries(param) {
const { columns, data } = param
const sums = []
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '总价'
return
} else if (index === 3) {
sums[index] = this.total_income
return
} else if (index === 4) {
sums[index] = this.total_expenditure
return
} else {
sums[index] = ''
}
})
return sums
},
// 保存修改 // 保存修改
save_modifications() { save_modifications() {
for (let i = 0; i < this.edit_list.length; i++) { for (let i = 0; i < this.edit_list.length; i++) {
...@@ -337,8 +363,6 @@ ...@@ -337,8 +363,6 @@
this.getDataList() this.getDataList()
}, },
select_change(e) { select_change(e) {
console.log(e);
console.log(this.select_value);
this.getDataList() this.getDataList()
}, },
// 列表 时间过滤 // 列表 时间过滤
...@@ -397,6 +421,8 @@ ...@@ -397,6 +421,8 @@
item.whether_edit = false item.whether_edit = false
}); });
this.dataList = res.data.result.data this.dataList = res.data.result.data
this.total_income = res.data.result.total_income || 0
this.total_expenditure = res.data.result.total_expenditure || 0
} else { } else {
this.$message({ this.$message({
type: "error", type: "error",
...@@ -405,7 +431,6 @@ ...@@ -405,7 +431,6 @@
} }
this.loading = false; this.loading = false;
}).catch(err => { }).catch(err => {
console.log(err);
this.$message({ this.$message({
type: "error", type: "error",
message: "接口报错,获取列表数据失败", message: "接口报错,获取列表数据失败",
...@@ -413,7 +438,6 @@ ...@@ -413,7 +438,6 @@
}) })
}, },
item_edit(scope) { item_edit(scope) {
console.log(scope);
this.edit_list.push(scope.row) this.edit_list.push(scope.row)
this.edit_state = true this.edit_state = true
scope.row.whether_edit = true scope.row.whether_edit = true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment