Commit 821fc21e by 夏超

Merge branch 'jzjx_project' of https://git.rokedata.com/dws/dwsproject into jzjx_project

# Conflicts:
#	roke_product_income_expense/static/src/js/index.html
parents 6fd41d42 d95d26b3
...@@ -39,8 +39,15 @@ class ProductIncomeExpenseIframe(http.Controller): ...@@ -39,8 +39,15 @@ class ProductIncomeExpenseIframe(http.Controller):
"expenditure": v.get("expenditure", False), "expenditure": v.get("expenditure", False),
"customer": v.get("customer", 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) _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) @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):
......
...@@ -84,7 +84,8 @@ ...@@ -84,7 +84,8 @@
</el-option> </el-option>
</el-select> </el-select>
<el-select class="margin_sty" v-model="machinery_type_value" clearable placeholder="请选择类型" @change="machinery_type_change"> <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" <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>
...@@ -97,41 +98,52 @@ ...@@ -97,41 +98,52 @@
</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>
</div> </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" 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="150">
<template slot-scope="scope"> <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 ]] [[ scope.row.business_date ]]
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="摘要" align="center"> <el-table-column label="摘要" align="center">
<template slot-scope="scope"> <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 ]] [[ scope.row.abstract ]]
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="客户" align="center"> <el-table-column label="客户" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<div style="text-align: left;"> <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 ]] [[ scope.row.customer ]]
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="收入" align="center" width="120"> <el-table-column label="收入" align="center" width="100">
<template slot-scope="scope"> <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 ]] [[ scope.row.income ]]
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="支出" align="center" width="120"> <el-table-column label="支出" align="center" width="100">
<template slot-scope="scope"> <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 ]] [[ scope.row.expenditure ]]
</div> </div>
</template> </template>
...@@ -145,12 +157,18 @@ ...@@ -145,12 +157,18 @@
</el-table-column> </el-table-column>
<el-table-column label="类型" align="center" width="120"> <el-table-column label="类型" align="center" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<div> <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 ]] [[ scope.row.machinery_type ]]
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="创建人" align="center" width="110"> <el-table-column label="创建人" align="center" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<div> <div>
[[ scope.row.user_name ]] [[ scope.row.user_name ]]
...@@ -164,8 +182,11 @@ ...@@ -164,8 +182,11 @@
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" width="80"> <el-table-column label="操作" align="center" width="120">
<template slot-scope="scope"> <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> <el-button type="danger" icon="el-icon-delete" circle @click="deleteItem(scope)"></el-button>
</template> </template>
</el-table-column> </el-table-column>
...@@ -189,13 +210,14 @@ ...@@ -189,13 +210,14 @@
paginationTotal: 10, paginationTotal: 10,
loading: false, loading: false,
dataList: [], dataList: [],
table_key: false,
user_name: '', user_name: '',
user_id: null, user_id: null,
createList: [ createList: [
{ {
business_date: '', business_date: '',
abstract: '', abstract: '',
customer:'', customer: '',
income: '', income: '',
expenditure: '', expenditure: '',
user_name: '', user_name: '',
...@@ -226,8 +248,10 @@ ...@@ -226,8 +248,10 @@
}], }],
select_value: '', select_value: '',
machinery_type_value: '', machinery_type_value: '',
customer_value: '',
abstract_value: '', abstract_value: '',
customer_value:'' edit_state: false,
edit_list: []
}; };
}, },
...@@ -241,6 +265,74 @@ ...@@ -241,6 +265,74 @@
this.getDataList() this.getDataList()
}, },
methods: { 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) { machinery_type_change(e) {
this.getDataList() this.getDataList()
}, },
...@@ -258,8 +350,22 @@ ...@@ -258,8 +350,22 @@
}, },
// 分页请求数据 // 分页请求数据
handleCurrentChangee(val) { 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.currentPageNo = val;
this.getDataList() this.getDataList()
}
}, },
// 获取列表数据 // 获取列表数据
getDataList() { getDataList() {
...@@ -275,7 +381,7 @@ ...@@ -275,7 +381,7 @@
type_str: this.select_value, type_str: this.select_value,
machinery_type: this.machinery_type_value, machinery_type: this.machinery_type_value,
abstract: this.abstract_value, abstract: this.abstract_value,
customer:this.customer_value customer: this.customer_value
} }
axios.request({ axios.request({
url: "/roke/product/product_income_expense/get", url: "/roke/product/product_income_expense/get",
...@@ -287,6 +393,9 @@ ...@@ -287,6 +393,9 @@
}).then((res) => { }).then((res) => {
if (res.data.result.code === 0) { if (res.data.result.code === 0) {
this.paginationTotal = res.data.result.count this.paginationTotal = res.data.result.count
res.data.result.data.forEach(item => {
item.whether_edit = false
});
this.dataList = res.data.result.data this.dataList = res.data.result.data
} else { } else {
this.$message({ this.$message({
...@@ -303,6 +412,13 @@ ...@@ -303,6 +412,13 @@
}); });
}) })
}, },
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) { deleteItem(item, index) {
if (item.row.id) { if (item.row.id) {
...@@ -334,6 +450,13 @@ ...@@ -334,6 +450,13 @@
} else { } else {
this.dataList.splice(item.$index, 1) 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() { export_click() {
...@@ -410,7 +533,7 @@ ...@@ -410,7 +533,7 @@
business_date: moment().format("YYYY-MM-DD"), business_date: moment().format("YYYY-MM-DD"),
abstract: '', abstract: '',
income: '', income: '',
customer:'', customer: '',
expenditure: '', expenditure: '',
user_name: this.user_name, user_name: this.user_name,
user_id: this.user_id, user_id: this.user_id,
...@@ -477,7 +600,7 @@ ...@@ -477,7 +600,7 @@
} }
body { body {
padding: 15px 35px 30px 35px; padding: 15px 25px 25px 25px;
} }
.el-table .el-table__cell { .el-table .el-table__cell {
...@@ -487,9 +610,15 @@ ...@@ -487,9 +610,15 @@
.el-date-editor.el-input { .el-date-editor.el-input {
width: 140px; width: 140px;
} }
.margin_sty{
.margin_sty {
margin: 0 10px; margin: 0 10px;
} }
.el-textarea__inner {
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
"Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}
</style> </style>
</html> </html>
\ No newline at end of file
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