commit 1. 修改静态资源位置
|
@ -1,13 +0,0 @@
|
|||
任务规划:
|
||||
1. 集团经营目标表
|
||||
1.1 完成添加接口
|
||||
1.2 完成查询接口(分页,筛选:一级部门、年度、项目性质,一级部门数据使用数据字典,所以先完成一级部门相关接口的开发)
|
||||
1.3 完成修改接口(修改接口与修改记录表有关联,相当于修改记录表的新增接口需完成)
|
||||
1.4 修改记录查询接口
|
||||
1.5 导出接口
|
||||
2. 员工业绩目标表
|
||||
2.1 完成添加接口
|
||||
2.2 完成查询接口(分页,筛选:姓名、一级部门、年度、项目性质)
|
||||
2.3 完成修改接口(修改接口与修改记录表有关联,相当于修改记录表的新增接口需完成)
|
||||
2.4 修改记录查询接口
|
||||
2.5 导出接口
|
|
@ -185,5 +185,5 @@ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
|||
|
||||
|
||||
STATICFILES_DIRS = [
|
||||
os.path.join(BASE_DIR, 'assets'),
|
||||
os.path.join(BASE_DIR, 'static'),
|
||||
]
|
|
@ -1,9 +1,8 @@
|
|||
<div class="row mb-3 justify-content-end">
|
||||
<!-- [ 数量统计 ] 开始 -->
|
||||
<div class="col-sm-12 col-md-5">
|
||||
<div class="dataTables_info" id="single-select_info" role="status"
|
||||
aria-live="polite">
|
||||
显示第 1 到第 10 项,共 57 项
|
||||
<div class="dataTables_info" id="single-select_info" role="status" aria-live="polite">
|
||||
显示第 {{ start_index }} 到第 {{ end_index }} 项,共 {{ total }} 项
|
||||
</div>
|
||||
</div>
|
||||
<!-- [ 数量统计 ] 结束 -->
|
||||
|
@ -11,41 +10,25 @@
|
|||
<div class="col-sm-12 col-md-7">
|
||||
<div class="dataTables_paginate paging_simple_numbers" id="single-select_paginate">
|
||||
<ul class="pagination justify-content-end">
|
||||
<li class="paginate_button page-item previous disabled"
|
||||
id="single-select_previous">
|
||||
<a href="#" aria-controls="single-select" data-dt-idx="0" tabindex="0"
|
||||
class="page-link">上一页</a>
|
||||
</li>
|
||||
<li class="paginate_button page-item active">
|
||||
<a href="#" aria-controls="single-select" data-dt-idx="1" tabindex="0"
|
||||
class="page-link">1</a>
|
||||
</li>
|
||||
<li class="paginate_button page-item ">
|
||||
<a href="#" aria-controls="single-select" data-dt-idx="2" tabindex="0"
|
||||
class="page-link">2</a>
|
||||
</li>
|
||||
<li class="paginate_button page-item ">
|
||||
<a href="#" aria-controls="single-select" data-dt-idx="3" tabindex="0"
|
||||
class="page-link">3</a>
|
||||
</li>
|
||||
<li class="paginate_button page-item ">
|
||||
<a href="#" aria-controls="single-select" data-dt-idx="4" tabindex="0"
|
||||
class="page-link">4</a>
|
||||
</li>
|
||||
<li class="paginate_button page-item ">
|
||||
<a href="#" aria-controls="single-select" data-dt-idx="5" tabindex="0"
|
||||
class="page-link">5</a>
|
||||
</li>
|
||||
<li class="paginate_button page-item ">
|
||||
<a href="#" aria-controls="single-select" data-dt-idx="6" tabindex="0"
|
||||
class="page-link">6</a>
|
||||
</li>
|
||||
<li class="paginate_button page-item next" id="single-select_next">
|
||||
<a href="#" aria-controls="single-select" data-dt-idx="7" tabindex="0"
|
||||
class="page-link">下一页</a>
|
||||
</li>
|
||||
{% if has_previous %}
|
||||
<li class="paginate_button page-item previous">
|
||||
<a href="#" aria-controls="single-select" data-page="{{ page|add:"-1" }}"
|
||||
class="page-link">上一页</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% for i in range %}
|
||||
<li class="paginate_button page-item {% if i == page %}active{% endif %}">
|
||||
<a href="#" aria-controls="single-select" data-page="{{ i }}" class="page-link">{{ i }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% if has_next %}
|
||||
<li class="paginate_button page-item next">
|
||||
<a href="#" aria-controls="single-select" data-page="{{ page|add:"1" }}"
|
||||
class="page-link">下一页</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<!-- [ 分页 ] 结束 -->
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -78,8 +78,8 @@
|
|||
<button type="submit" class="btn btn-primary">查询
|
||||
</button>
|
||||
<span style="margin-bottom: 5px; color: grey; cursor: pointer; margin-left: 10px;"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#editModal">
|
||||
data-bs-toggle="modal" class="view-modify-records-btn"
|
||||
data-bs-target="#modifyRecordsModal">
|
||||
修改记录
|
||||
</span>
|
||||
</div>
|
||||
|
@ -129,6 +129,7 @@
|
|||
<th>毛利润(元)</th>
|
||||
<th>费用限额(元)</th>
|
||||
<th>营业利润(元)</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="result" style="color: white;">
|
||||
|
@ -142,7 +143,7 @@
|
|||
<!-- [ 数据表 ] 结束 -->
|
||||
|
||||
<!-- [ 分页&统计 ] 开始 -->
|
||||
{% include 'pagination.html' %}
|
||||
<div id="pagination"></div>
|
||||
<!-- [ 分页&统计 ] 结束 -->
|
||||
|
||||
<!-- [ 主内容 ] 结束 -->
|
||||
|
@ -155,7 +156,7 @@
|
|||
<!-- [ 主内容页 ] 结束 -->
|
||||
|
||||
<!-- 模态框 -->
|
||||
<div id="editModal" class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog"
|
||||
<div id="modifyRecordsModal" class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog"
|
||||
aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-xl" role="document">
|
||||
<div class="modal-content">
|
||||
|
@ -181,23 +182,20 @@
|
|||
</thead>
|
||||
<tbody class="text-center" style="color: white;">
|
||||
<tr>
|
||||
<td>2024年</td> <!-- 修改字段 -->
|
||||
<td>星河</td> <!-- 修改字段 -->
|
||||
<td>收入总目标</td> <!-- 修改字段 -->
|
||||
<td>200000</td> <!-- 旧值 -->
|
||||
<td>250000</td> <!-- 新值 -->
|
||||
<td>2023-05-13</td> <!-- 修改日期 -->
|
||||
<td>张齐</td> <!-- 修改人 -->
|
||||
</tr>
|
||||
<!-- 您可以添加更多的行,作为其他修改记录的数据 -->
|
||||
</tbody>
|
||||
</table>
|
||||
<nav>
|
||||
<ul class="pagination justify-content-end">
|
||||
<!-- 分页按钮将由JS代码动态填充 -->
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-light"
|
||||
data-bs-dismiss="modal">确定
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -515,6 +513,91 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="modifyModal" class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog"
|
||||
aria-labelledby="modifyModal" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-xl" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="addModalCenterTitle">修改</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="groupBusinessTargetForm">
|
||||
{% csrf_token %}
|
||||
<!-- 使用row和col来控制标签的布局 -->
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="primary_department">一级部门</label>
|
||||
<input class="form-control" id="primary_department_modify" name="primary_department"
|
||||
required disabled>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="year">年度</label>
|
||||
<input class="form-control" id="year_modify" name="year"
|
||||
required disabled>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="project_nature">项目性质</label>
|
||||
<input class="form-control" id="project_nature_modify" name="project_nature"
|
||||
required disabled>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="modified_field">修改字段</label>
|
||||
<select class="form-control" id="modified_field" name="modified_field" required>
|
||||
<option value="">选择修改字段</option>
|
||||
<option value="销售额">销售额</option>
|
||||
<option value="收入总目标">收入总目标</option>
|
||||
<option value="新增收入目标">新增收入目标</option>
|
||||
<option value="存量收入目标">存量收入目标</option>
|
||||
<option value="成本限额">成本限额</option>
|
||||
<option value="毛利润">毛利润</option>
|
||||
<option value="费用限额">费用限额</option>
|
||||
<option value="营业利润">营业利润</option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="old_value">旧值</label>
|
||||
<input class="form-control" id="old_value" name="old_value"
|
||||
required disabled>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="new_value">新值</label>
|
||||
<input class="form-control" id="new_value" name="new_value"
|
||||
required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="modified_by">修改人</label>
|
||||
<input class="form-control" id="modified_by" name="modified_by"
|
||||
required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" id="submitModifyForm">确定
|
||||
</button>
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 模态框结束 -->
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
|
@ -544,8 +627,94 @@
|
|||
}
|
||||
});
|
||||
|
||||
// 添加接口
|
||||
// 查询接口
|
||||
$(document).ready(function () {
|
||||
// Fetch data when page loads
|
||||
fetchData();
|
||||
|
||||
// 查询
|
||||
$('#queryForm').on('submit', function (event) {
|
||||
event.preventDefault();
|
||||
fetchData();
|
||||
});
|
||||
|
||||
// 分页
|
||||
$(document).on('click', '.pagination a', function (event) {
|
||||
event.preventDefault();
|
||||
const page = $(this).data('page');
|
||||
fetchData(page);
|
||||
});
|
||||
|
||||
$(document).on('click', '#modifyBtn', function (event) {
|
||||
event.preventDefault();
|
||||
const row = $(this).closest('tr');
|
||||
const columns = row.find('td');
|
||||
|
||||
// Store row ID in modal for future reference
|
||||
$('#modifyModal').data('row-id', row.data('row-id'));
|
||||
|
||||
// Get data from table cells
|
||||
const primary_department = columns.eq(1).text();
|
||||
const year = columns.eq(2).text();
|
||||
const project_nature = columns.eq(3).text();
|
||||
|
||||
// Populate modal form with data
|
||||
$('#primary_department_modify').val(primary_department);
|
||||
$('#year_modify').val(year);
|
||||
$('#project_nature_modify').val(project_nature);
|
||||
|
||||
// Open modal
|
||||
$('#modifyModal').modal('show');
|
||||
|
||||
});
|
||||
|
||||
|
||||
function fetchData(page = 1) {
|
||||
const primary_department = $('#primary_department').val();
|
||||
const year = $('#year').val();
|
||||
const project_nature = $('#project_nature').val();
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/pm/query/",
|
||||
data: {
|
||||
primary_department: primary_department,
|
||||
year: year,
|
||||
project_nature: project_nature,
|
||||
page: page
|
||||
},
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
$('#result').empty();
|
||||
response.targets.forEach(function (target, index) {
|
||||
$('#result').append(
|
||||
`<tr data-row-id="${index + 1}">
|
||||
<td>${index + 1}</td>
|
||||
<td>${target.primary_department}</td>
|
||||
<td>${target.year}</td>
|
||||
<td>${target.project_nature}</td>
|
||||
<td>${target.sales}</td>
|
||||
<td>${target.total_revenue_target}</td>
|
||||
<td>${target.new_revenue_target}</td>
|
||||
<td>${target.existing_revenue_target}</td>
|
||||
<td>${target.cost_limit}</td>
|
||||
<td>${target.gross_profit}</td>
|
||||
<td>${target.expense_limit}</td>
|
||||
<td>${target.operating_profit}</td>
|
||||
<td><a href="#" data-bs-toggle="modal" id="modifyBtn"
|
||||
data-bs-target="#modifyModal" style="color: #0d6efd">编辑</a></td>
|
||||
</tr>`
|
||||
);
|
||||
});
|
||||
$('#pagination').html(response.pagination_html);
|
||||
},
|
||||
error: function (error) {
|
||||
console.error("Error: ", error);
|
||||
alert("查询失败,请重试。");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('#submitForm').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
|
@ -580,67 +749,172 @@
|
|||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// 查询接口
|
||||
$(document).ready(function () {
|
||||
// Fetch data when page loads
|
||||
fetchData();
|
||||
$('#modified_field').on('change', function () {
|
||||
const modifiedField = $(this).val();
|
||||
const rowId = $('#modifyModal').data('row-id');
|
||||
const row = $(`tr[data-row-id="${rowId}"]`);
|
||||
const columns = row.find('td');
|
||||
|
||||
// Fetch data when form is submitted
|
||||
$('#queryForm').on('submit', function (event) {
|
||||
event.preventDefault();
|
||||
fetchData();
|
||||
let oldValue = '';
|
||||
|
||||
switch (modifiedField) {
|
||||
case '销售额':
|
||||
oldValue = columns.eq(4).text();
|
||||
break;
|
||||
case '收入总目标':
|
||||
oldValue = columns.eq(5).text();
|
||||
break;
|
||||
case '新增收入目标':
|
||||
oldValue = columns.eq(6).text();
|
||||
break;
|
||||
case '存量收入目标':
|
||||
oldValue = columns.eq(7).text();
|
||||
break;
|
||||
case '成本限额':
|
||||
oldValue = columns.eq(8).text();
|
||||
break;
|
||||
case '毛利润':
|
||||
oldValue = columns.eq(9).text();
|
||||
break;
|
||||
case '费用限额':
|
||||
oldValue = columns.eq(10).text();
|
||||
break;
|
||||
case '营业利润':
|
||||
oldValue = columns.eq(11).text();
|
||||
break;
|
||||
}
|
||||
|
||||
$('#old_value').val(oldValue);
|
||||
});
|
||||
|
||||
$(document).on('click', '.pagination a', function (event) {
|
||||
event.preventDefault();
|
||||
const page = $(this).data('page');
|
||||
fetchData(page);
|
||||
// 修改modal关闭后初始化数据
|
||||
$('#modifyModal').on('hidden.bs.modal', function () {
|
||||
// Reset form fields
|
||||
$('#groupBusinessTargetForm')[0].reset();
|
||||
// Clear data attributes
|
||||
$('#modifyModal').removeData('row-id');
|
||||
// Reset modified field dropdown to default
|
||||
$('#modified_field').val('');
|
||||
// Clear old and new values
|
||||
$('#old_value').val('');
|
||||
$('#new_value').val('');
|
||||
});
|
||||
|
||||
function fetchData(page = 1) {
|
||||
const primary_department = $('#primary_department').val();
|
||||
const year = $('#year').val();
|
||||
const project_nature = $('#project_nature').val();
|
||||
$('#submitModifyForm').on('click', function () {
|
||||
const target_id = $('#modifyModal').data('row-id');
|
||||
const modified_field = $('#modified_field').val();
|
||||
const old_value = $('#old_value').val();
|
||||
const new_value = $('#new_value').val();
|
||||
const modified_by = $('#modified_by').val();
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/pm/query/",
|
||||
data: {
|
||||
primary_department: primary_department,
|
||||
year: year,
|
||||
project_nature: project_nature,
|
||||
page: 1
|
||||
},
|
||||
dataType: "json",
|
||||
type: 'POST',
|
||||
url: '/pm/add_target_audit/',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
target_id: target_id,
|
||||
modified_field: modified_field,
|
||||
old_value: parseFloat(old_value),
|
||||
new_value: parseFloat(new_value),
|
||||
modified_by: modified_by
|
||||
}),
|
||||
dataType: 'json',
|
||||
success: function (response) {
|
||||
$('#result').empty();
|
||||
response.targets.forEach(function (target, index) {
|
||||
$('#result').append(
|
||||
`<tr>
|
||||
<td>${index + 1}</td>
|
||||
<td>${target.primary_department}</td>
|
||||
<td>${target.year}</td>
|
||||
<td>${target.project_nature}</td>
|
||||
<td>${target.sales}</td>
|
||||
<td>${target.total_revenue_target}</td>
|
||||
<td>${target.new_revenue_target}</td>
|
||||
<td>${target.existing_revenue_target}</td>
|
||||
<td>${target.cost_limit}</td>
|
||||
<td>${target.gross_profit}</td>
|
||||
<td>${target.expense_limit}</td>
|
||||
<td>${target.operating_profit}</td>
|
||||
</tr>`
|
||||
);
|
||||
});
|
||||
if (response.status === 'success') {
|
||||
alert('修改记录已保存');
|
||||
$('#modifyModal').modal('hide');
|
||||
// Optionally, refresh the data here
|
||||
fetchData();
|
||||
} else {
|
||||
alert('保存失败,请重试');
|
||||
}
|
||||
},
|
||||
error: function (error) {
|
||||
console.error("Error: ", error);
|
||||
alert("查询失败,请重试。");
|
||||
console.error('Error:', error);
|
||||
alert('保存失败,请重试');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.view-modify-records-btn', function (event) {
|
||||
event.preventDefault();
|
||||
// Fetch and display modify records for the first page
|
||||
fetchModifyRecords(1);
|
||||
});
|
||||
|
||||
// Fetch modify records function
|
||||
function fetchModifyRecords(page) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/pm/get_target_audit_records/',
|
||||
data: {
|
||||
page: page
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function (response) {
|
||||
const records = response.records;
|
||||
const tbody = $('#modifyRecordsModal tbody');
|
||||
tbody.empty(); // Clear previous records
|
||||
|
||||
records.forEach(function (record) {
|
||||
tbody.append(`
|
||||
<tr>
|
||||
<td>${record.year}</td>
|
||||
<td>${record.primary_department}</td>
|
||||
<td>${record.modified_field}</td>
|
||||
<td>${record.old_value}</td>
|
||||
<td>${record.new_value}</td>
|
||||
<td>${record.modification_date}</td>
|
||||
<td>${record.modified_by}</td>
|
||||
</tr>
|
||||
`);
|
||||
});
|
||||
|
||||
// Update pagination
|
||||
const pagination = $('#modifyRecordsModal .pagination');
|
||||
pagination.empty(); // Clear previous pagination
|
||||
|
||||
if (response.has_previous) {
|
||||
pagination.append(`
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#" data-page="${response.page - 1}">上一页</a>
|
||||
</li>
|
||||
`);
|
||||
}
|
||||
|
||||
for (let i = 1; i <= response.num_pages; i++) {
|
||||
pagination.append(`
|
||||
<li class="page-item ${response.page === i ? 'active' : ''}">
|
||||
<a class="page-link" href="#" data-page="${i}">${i}</a>
|
||||
</li>
|
||||
`);
|
||||
}
|
||||
|
||||
if (response.has_next) {
|
||||
pagination.append(`
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#" data-page="${response.page + 1}">下一页</a>
|
||||
</li>
|
||||
`);
|
||||
}
|
||||
|
||||
// Open modal
|
||||
$('#modifyRecordsModal').modal('show');
|
||||
},
|
||||
error: function (error) {
|
||||
console.error('Error fetching modify records:', error);
|
||||
alert('无法获取修改记录,请稍后重试。');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Handle pagination click
|
||||
$(document).on('click', '#modifyRecordsModal .pagination a', function (event) {
|
||||
event.preventDefault();
|
||||
const page = $(this).data('page');
|
||||
fetchModifyRecords(page);
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -4,6 +4,8 @@ from .views import *
|
|||
urlpatterns = [
|
||||
path('create/', create_group_business_target, name='create_group_business_target'),
|
||||
path('query/', GroupBusinessTargetListView.as_view(), name='group_business_target_list'),
|
||||
path('add_target_audit/', add_target_audit, name='add_target_audit'),
|
||||
path('get_target_audit_records/', get_target_audit_records, name='get_target_audit_records'),
|
||||
path('group_business_objectives/', group_business_objectives, name='group_business_objectives'),
|
||||
path('employee_performance_targets/', employee_performance_targets, name='employee_performance_targets'),
|
||||
]
|
||||
]
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
import json
|
||||
|
||||
from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage
|
||||
from django.http import JsonResponse
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from django.views import View
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.views.decorators.http import require_POST, require_GET
|
||||
from rest_framework import status
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.decorators import api_view
|
||||
from .models import GroupBusinessTarget
|
||||
from .models import GroupBusinessTarget, TargetAudit
|
||||
from .serializers import GroupBusinessTargetSerializer
|
||||
|
||||
|
||||
|
@ -62,16 +66,99 @@ class GroupBusinessTargetListView(View):
|
|||
'operating_profit': target.operating_profit,
|
||||
} for target in targets]
|
||||
|
||||
# 返回JSON响应
|
||||
return JsonResponse({
|
||||
'targets': target_list,
|
||||
pagination_html = render(request, 'pagination.html', {
|
||||
'page': targets.number,
|
||||
'pages': paginator.num_pages,
|
||||
'has_next': targets.has_next(),
|
||||
'has_previous': targets.has_previous(),
|
||||
'total': paginator.count,
|
||||
'start_index': targets.start_index(),
|
||||
'end_index': targets.end_index(),
|
||||
'range': range(1, paginator.num_pages + 1)
|
||||
}).content.decode('utf-8')
|
||||
|
||||
# 返回JSON响应
|
||||
return JsonResponse({
|
||||
'targets': target_list,
|
||||
'pagination_html': pagination_html,
|
||||
})
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
def add_target_audit(request):
|
||||
if request.method == 'POST':
|
||||
data = json.loads(request.body)
|
||||
target_id = data.get('target_id')
|
||||
modified_field = data.get('modified_field')
|
||||
old_value = data.get('old_value')
|
||||
new_value = data.get('new_value')
|
||||
modified_by = data.get('modified_by')
|
||||
|
||||
target = get_object_or_404(GroupBusinessTarget, pk=target_id)
|
||||
|
||||
# Update the target with the new value
|
||||
field_map = {
|
||||
'销售额': 'sales',
|
||||
'收入总目标': 'total_revenue_target',
|
||||
'新增收入目标': 'new_revenue_target',
|
||||
'存量收入目标': 'existing_revenue_target',
|
||||
'成本限额': 'cost_limit',
|
||||
'毛利润': 'gross_profit',
|
||||
'费用限额': 'expense_limit',
|
||||
'营业利润': 'operating_profit'
|
||||
}
|
||||
|
||||
if modified_field in field_map:
|
||||
setattr(target, field_map[modified_field], new_value)
|
||||
target.save()
|
||||
|
||||
# Create audit record
|
||||
audit_record = TargetAudit.objects.create(
|
||||
target_id=target,
|
||||
modified_field=modified_field,
|
||||
old_value=old_value,
|
||||
new_value=new_value,
|
||||
modified_by=modified_by
|
||||
)
|
||||
|
||||
return JsonResponse({
|
||||
'status': 'success',
|
||||
'audit_id': audit_record.audit_id
|
||||
})
|
||||
|
||||
return JsonResponse({'status': 'fail', 'message': 'Invalid request'}, status=400)
|
||||
|
||||
|
||||
def get_target_audit_records(request):
|
||||
page_number = request.GET.get('page', 1)
|
||||
per_page = 4 # 每页显示的记录数
|
||||
|
||||
audit_records = TargetAudit.objects.all().order_by('-modification_date')
|
||||
|
||||
paginator = Paginator(audit_records, per_page)
|
||||
page_obj = paginator.get_page(page_number)
|
||||
|
||||
records = []
|
||||
for record in page_obj:
|
||||
records.append({
|
||||
'year': record.target_id.year, # Assuming the ForeignKey relation name is `target_id`
|
||||
'primary_department': record.target_id.primary_department,
|
||||
'modified_field': record.modified_field,
|
||||
'old_value': record.old_value,
|
||||
'new_value': record.new_value,
|
||||
'modification_date': record.modification_date.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'modified_by': record.modified_by
|
||||
})
|
||||
|
||||
return JsonResponse({
|
||||
'records': records,
|
||||
'page': page_obj.number,
|
||||
'num_pages': paginator.num_pages,
|
||||
'has_previous': page_obj.has_previous(),
|
||||
'has_next': page_obj.has_next(),
|
||||
})
|
||||
|
||||
|
||||
# 集团经营目标表
|
||||
def group_business_objectives(request):
|
||||
return render(request, 'perf_mgnt/group_business_objectives.html')
|
||||
|
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 187 KiB After Width: | Height: | Size: 187 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 265 B After Width: | Height: | Size: 265 B |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 764 B After Width: | Height: | Size: 764 B |
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 234 B After Width: | Height: | Size: 234 B |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 245 B After Width: | Height: | Size: 245 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 544 B |
Before Width: | Height: | Size: 501 B After Width: | Height: | Size: 501 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 616 B After Width: | Height: | Size: 616 B |
Before Width: | Height: | Size: 195 B After Width: | Height: | Size: 195 B |
Before Width: | Height: | Size: 293 B After Width: | Height: | Size: 293 B |
Before Width: | Height: | Size: 386 B After Width: | Height: | Size: 386 B |
Before Width: | Height: | Size: 297 B After Width: | Height: | Size: 297 B |
Before Width: | Height: | Size: 572 B After Width: | Height: | Size: 572 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 502 B After Width: | Height: | Size: 502 B |
Before Width: | Height: | Size: 295 B After Width: | Height: | Size: 295 B |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 117 KiB |
Before Width: | Height: | Size: 231 B After Width: | Height: | Size: 231 B |
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 571 B After Width: | Height: | Size: 571 B |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 585 B After Width: | Height: | Size: 585 B |
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 257 B |
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 712 B After Width: | Height: | Size: 712 B |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 510 B After Width: | Height: | Size: 510 B |