1. 继承items_list的html
This commit is contained in:
彭森 2024-06-19 00:23:33 +08:00
parent 3b7b558f15
commit cd2342661a
6 changed files with 783 additions and 1095 deletions

View File

@ -101,7 +101,7 @@ def emp_list_view(request):
# 表格显示排除配置
"table_exclude_field_name": ['employee_id'],
# 筛选表单提交链接
"form_action_url": "emp_list",
"form_action_url": reverse('emp_list'),
# 修改对象提交链接
"modify_url": reverse("emp_list_modify"),
# 新增对象提交链接
@ -109,9 +109,10 @@ def emp_list_view(request):
# 删除对象提交链接
"delete_url": reverse("emp_list_delete"),
"add_button": True,
"import_excel_button": True
}
return render(request, 'emp_list_2.html', context)
return render(request, 'emp_list.html', context)
@login_required
@ -174,7 +175,9 @@ def emp_list_modify(request):
try:
instance = EmployeeInformation.objects.get(employee_id=request.GET['id'])
form = EmployeeInformationEditForm(instance=instance)
form.fields['secondary_department'].queryset = SecondaryDepartment.objects.filter(primary_department=instance.primary_department).order_by('secondary_department_name')
primary_department = PrimaryDepartment.objects.get(department_name=instance.primary_department)
form.fields['secondary_department'].queryset = SecondaryDepartment.objects.filter(
primary_department=primary_department.primary_department_id).order_by('secondary_department_name')
except EmployeeInformation.DoesNotExist:
raise Http404("对象不存在")
else:
@ -881,8 +884,6 @@ def performance_delete(request):
return JsonResponse({"message": "无效的请求方法"}, status=405)
@csrf_protect
@login_required
def save_excel_table_data(request):
@ -940,9 +941,3 @@ def save_excel_table_data(request):
except Exception as e:
return JsonResponse({'error': f'服务器内部错误: {str(e)}'}, status=500)
return JsonResponse({'error': '无效的请求方法'}, status=400)

View File

@ -1,939 +0,0 @@
{% extends 'base.html' %}
{% load static tags %}
{% block content %}
<section class="pcoded-main-container">
<div class="pcoded-wrapper">
<div class="pcoded-content">
<div class="pcoded-inner-content">
<div class="main-body">
<div class="page-wrapper">
{% include 'breadcrumb.html' %}
<div class="row mb-3">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-8">
<!-- 筛选表单 开始 -->
<form action="{{ form_action_url }}" method="get">
{% csrf_token %}
<div class="row">
{% for filter in filters %}
{% if filter.type == 'text' %}
<div class="col">
<label for="{{ filter.id }}"
class="form-label">{{ filter.label }}</label>
<input type="text" class="form-control"
id="{{ filter.id }}"
name="{{ filter.name }}"
placeholder="{{ filter.placeholder }}">
</div>
{% elif filter.type == 'select' %}
<div class="col">
<label class="form-label"
for="{{ filter.id }}">{{ filter.label }}</label>
<select class="form-control"
id="{{ filter.id }}"
name="{{ filter.name }}">
<option value="">请选择</option>
{% for option in filter.options %}
<option value="{{ option.value }}"
{% if request.GET|get_value:filter.name == option.value %}selected{% endif %}>{{ option.display }}
</option>
{% endfor %}
</select>
</div>
{% elif filter.type == 'date' %}
<div class="col">
<label for="{{ filter.id }}"
class="form-label">{{ filter.label }}</label>
<input type="date" class="form-control"
id="{{ filter.id }}"
name="{{ filter.name }}"
value="{{ request.GET|get_value:filter.name }}">
</div>
{% elif filter.type == 'month' %}
<div class="col">
<label for="{{ filter.id }}"
class="form-label">{{ filter.label }}</label>
<input type="month" class="form-control"
id="{{ filter.id }}"
name="{{ filter.name }}"
value="{{ request.GET|get_value:filter.name }}">
</div>
{% endif %}
{% endfor %}
<div class="col mt-4 d-flex align-items-center">
<button type="submit" class="btn btn-primary">查询
</button>
</div>
</div>
</form>
<!-- 筛选表单 结束 -->
</div>
<!-- 按钮组 开始 -->
<div class="col-md-4 mt-4 text-end">
{% render_button 'modify_records_button' %}
{% render_button 'add_button' %}
{% render_button 'report_excel_button' %}
{# {% render_button 'import_excel_button' %}#}
<button id="importExcelBtnTest" class="btn btn-outline-primary"
data-bs-toggle="modal" data-bs-target="#uploadModal">
上传Excel(测试)
</button>
</div>
<!-- 按钮组 结束 -->
</div>
</div>
</div>
</div>
</div>
<div class="row mb-3">
<div class="col-sm-12">
<div class="card">
<div class="card-body table-border-style">
<div class="table-responsive">
<!-- 表格 开始 -->
<table class="table">
{% get_verbose_field_names_from_model model_config table_exclude_field_name as columns %}
<thead>
<tr>
{% for column in columns %}
<th class="text-center">{{ column }}</th>
{% endfor %}
<th class="text-center">操作</th>
</tr>
</thead>
<tbody id="result" style="color: white;">
{% for item in items %}
<tr>
{% for field in item|get_fields:table_exclude_field_name %}
{% if field.verbose_name|is_in_list:"营业范围,注册地址" %}
<td class="text-center"
title="{{ field.value }}">{{ field.value|truncatechars:10 }}</td>
{% elif field.verbose_name == '股东姓名及持股比例' %}
<td class="text-center">
<span style="color: red; cursor: pointer"
title="{{ field.value }}"
onclick="showShareholdersModal('{{ field.value }}')">详情</span>
</td>
{% elif field.verbose_name == '历史沿革' %}
<td class="text-center">
<span style="color: blueviolet; cursor: pointer"
onclick="showHistoryModal({{ item.entity_id }})">查看</span>
</td>
{% elif field.verbose_name == '相关银行账户信息' %}
<td class="text-center">
<span style="color: green; cursor: pointer"
onclick="showBanksModal({{ item.entity_id }})">查看</span>
</td>
{% else %}
{% if '(元)' in field.verbose_name %}
<td class="text-center">{{ field.value|thousands_separator }}</td>
{% else %}
<td class="text-center">{{ field.value }}</td>
{% endif %}
{% endif %}
{% endfor %}
<td class="text-center">
<a href="#"
id="editBtn"
class="edit-btn"
data-id="{{ item|get_pk_value }}"
data-bs-toggle="modal"
data-bs-target="#addEditModal">编辑</a>
<a href="#"
id="deleteBtn"
class="edit-btn"
style="color: red"
data-id="{{ item|get_pk_value }}"
data-bs-toggle="modal"
data-bs-target="#deleteModal">删除</a>
</td>
</tr>
{% empty %}
<tr>
<td class="text-center"
colspan="{{ table_columns|length }}">暂无数据
</td>
</tr>
{% endfor %}
</tbody>
</table>
<!-- 表格 结束 -->
</div>
</div>
</div>
</div>
</div>
{% include 'pagination_ps.html' with page_obj=items query_params=query_params %}
</div>
</div>
</div>
</div>
</div>
</section>
<div id="shareholdersModal" class="modal fade bd-example-modal-sm" tabindex="-1" role="dialog"
aria-labelledby="formModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-sm" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="formModalTitle">股东姓名及持股比例</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table class="table">
<thead>
<tr>
<th>股东姓名</th>
<th>持股比例</th>
</tr>
</thead>
<tbody id="shareholdersTableBody">
</tbody>
</table>
</div>
</div>
</div>
</div>
<div id="showHistoryModal" class="modal fade bd-example-modal-xl" tabindex="-1" role="dialog"
aria-labelledby="formModalCenterTitle" 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="formModalTitle">历史沿革</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table class="table">
<thead>
<tr>
<th class="text-center">变更日期</th>
<th class="text-center">变更类型</th>
<th class="text-center">变更前内容</th>
<th class="text-center">变更后内容</th>
<th class="text-center">变更原因</th>
<th class="text-center">变更执行人</th>
</tr>
</thead>
<tbody id="historyTableBody">
</tbody>
</table>
<div id="paginationControls" class="text-center mt-3">
<!-- Pagination controls will be inserted here by JavaScript -->
</div>
</div>
</div>
</div>
</div>
<div id="showBanksModal" class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog"
aria-labelledby="formModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="formModalTitle">银行账户信息</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table class="table">
<thead>
<tr>
<th class="text-center">开户行名称</th>
<th class="text-center">账号</th>
<th class="text-center">账户类型</th>
<th class="text-center">账户状态</th>
<th class="text-center">操作</th>
</tr>
</thead>
<tbody id="banksTableBody">
</tbody>
</table>
<div class="d-flex justify-content-between align-items-center mt-3">
<button class="btn btn-outline-dark" onclick="openAddBankAccountModal({{ item.entity_id }})">
新增银行账户
</button>
<div id="banksPaginationControls">
<!-- Pagination controls will be inserted here by JavaScript -->
</div>
</div>
</div>
</div>
</div>
</div>
<div id="addBankAccountModal" class="modal fade" tabindex="-1" role="dialog"
aria-labelledby="addBankAccountModalTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addBankAccountModalTitle">新增银行账户</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form id="addBankAccountForm">
<input type="hidden" id="addBankAccountEntityId">
<div class="mb-3">
<label for="addBankName" class="form-label">开户行名称</label>
<input type="text" class="form-control" id="addBankName" required>
</div>
<div class="mb-3">
<label for="addAccountNumber" class="form-label">账号</label>
<input type="text" class="form-control" id="addAccountNumber" required>
</div>
<div class="mb-3">
<label for="addAccountType" class="form-label">账户类型</label>
<select class="form-control" id="addAccountType" required>
<option value="基本户">基本户</option>
<option value="一般户">一般户</option>
</select>
</div>
<div class="mb-3">
<label for="addAccountStatus" class="form-label">账户状态</label>
<select class="form-control" id="addAccountStatus" required>
<option value="活跃">活跃</option>
<option value="不活跃">不活跃</option>
<option value="已关闭">已关闭</option>
<option value="暂停">暂停</option>
<option value="待处理">待处理</option>
<option value="冻结">冻结</option>
</select>
</div>
<div class="text-end">
<button type="submit" class="btn btn-primary" onclick="addBankAccount()">保存</button>
</div>
</form>
</div>
</div>
</div>
</div>
<div id="deleteBankAModal" class="modal fade" tabindex="-1" role="dialog"
aria-labelledby="deleteBankModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="deleteBankModalLabel">提示
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"
aria-label="Close"></button>
</div>
<div class="modal-body">
<p>此操作会删除当前数据,是否继续?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">取消</button>
<button type="button" class="btn btn-danger" id="confirmDeleteBtn">删除</button>
</div>
</div>
</div>
</div>
<div id="editBankAccountModal" class="modal fade" tabindex="-1" role="dialog"
aria-labelledby="editBankAccountModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="editBankAccountModalLabel">编辑银行账户</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form id="editBankAccountForm">
<div class="mb-3">
<label for="editBankName" class="form-label">开户行名称</label>
<input type="text" class="form-control" id="editBankName" required>
</div>
<div class="mb-3">
<label for="editAccountNumber" class="form-label">账号</label>
<input type="text" class="form-control" id="editAccountNumber" required>
</div>
<div class="mb-3">
<label for="editAccountType" class="form-label">账户类型</label>
<select class="form-control" id="editAccountType" required>
<option value="基本户">基本户</option>
<option value="一般户">一般户</option>
</select>
</div>
<div class="mb-3">
<label for="editAccountStatus" class="form-label">账户状态</label>
<select class="form-control" id="editAccountStatus" required>
<option value="活跃">活跃</option>
<option value="不活跃">不活跃</option>
<option value="已关闭">已关闭</option>
<option value="暂停">暂停</option>
<option value="待处理">待处理</option>
<option value="冻结">冻结</option>
</select>
</div>
<div class="text-end">
<button type="button" class="btn btn-primary" onclick="submitEditBankAccount()">保存
</button>
</div>
</form>
</div>
</div>
</div>
</div>
<div id="addEditModal" class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog"
aria-labelledby="formModalCenterTitle" 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="formModalTitle">{{ form_title }}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
</div>
</div>
</div>
</div>
<div id="deleteModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="deleteModalLabel">提示</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>此操作会删除当前数据,是否继续?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">取消</button>
<button type="button" class="btn btn-danger" id="confirmDeleteBtn">删除</button>
</div>
</div>
</div>
</div>
<div id="uploadModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="uploadModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form id="upload-form" method="post" enctype="multipart/form-data">
{% csrf_token %}
<div class="modal-header">
<h5 class="modal-title" id="uploadModalLabel">上传Excel文件</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<input id="inputFile" type="file" name="excel_file" class="form-control" hidden accept=".xlsx">
<label class="btn btn-outline-primary" for="inputFile">选择文件</label>
<span id="file-chosen" style="font-size: 12px; margin-left: 10px;">未选择文件</span>
</div>
<div class="modal-footer">
<button id="downloadExcelBtn" type="button" class="btn btn-secondary" onclick="#!">
下载填报模板
</button>
<button id="uploadBtn" type="button" class="btn btn-primary">上传Excel</button>
</div>
</form>
</div>
</div>
</div>
{% include 'modify_record_modal.html' with modify_records_url=modify_records_url %}
{% block item_list_custom_content %}
{% endblock %}
<script>
const add_url = "{{ add_url }}";
const modify_url = "{{ modify_url }}";
const deleteUrl = "{{ delete_url }}";
let targetIdToDelete = null;
var templateName = "{{ excel_upload_config.template_name }}";
var modelConfig = "{{ model_config }}";
var list_url = "{{ form_action_url }}"
let accountIdToDelete;
let accountIdToEdit;
$(document).ready(function () {
function getCookie(name) {
let cookieValue = null;
if (document.cookie && document.cookie !== '') {
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i].trim();
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
const csrftoken = getCookie('csrftoken');
// 处理添加按钮点击事件
$('#addItemBtn').click(function () {
$.ajax({
url: add_url,
type: 'get',
success: function (response) {
// 将新的表单 HTML 插入到模态框中
$('#addEditModal .modal-body').html(response.form_html);
// 动态设置模态框标题
$('#formModalTitle').text('新增');
// 动态设置表单提交URL
$('#addEditForm').attr('action', add_url);
// 显示模态框
$('#addEditModal').modal('show');
// 绑定表单提交事件
bindFormSubmit();
},
error: function () {
$('#addEditModal').modal('hide');
showAlert('danger', '获取表单请求出错');
}
});
});
// 处理编辑按钮点击事件
$('#editBtn').click(function () {
var itemId = $(this).data('id');
$.ajax({
url: modify_url,
type: 'get',
data: {id: itemId},
success: function (response) {
// 将表单 HTML 插入到模态框中
$('#addEditModal .modal-body').html(response.form_html);
$('#formModalTitle').text('编辑');
// 动态设置表单提交URL
$('#addEditForm').attr('action', modify_url);
// 显示模态框
$('#addEditModal').modal('show');
// 绑定表单提交事件
bindFormSubmit();
},
error: function () {
$('#addEditModal').modal('hide');
showAlert('danger', '获取表单请求出错');
}
});
});
// 保存
function bindFormSubmit() {
$('#addEditForm').submit(function (e) {
e.preventDefault();
$.ajax({
url: $(this).attr('action'), // 动态获取URL
type: 'post', // 使用 POST 请求来提交表单
data: $(this).serialize(),
success: function (response) {
// 关闭模态框并显示成功消息
$('#addEditModal').modal('hide');
showAlert('success', response.message);
location.reload();
},
error: function (xhr) {
// 处理表单错误并显示错误消息
var response = xhr.responseJSON;
$('#addEditModal .modal-body').html(response.form_html);
bindFormSubmit();
}
});
});
}
// 删除和确认删除
$(document).on('click', '#deleteBtn, #confirmDeleteBtn', function (event) {
if (event.target.id === 'deleteBtn') {
// 打开删除模态框
targetIdToDelete = $(this).data('id');
$('#deleteModal').modal('show');
} else if (event.target.id === 'confirmDeleteBtn') {
// 确认删除
if (targetIdToDelete !== null) {
$.ajax({
type: 'GET',
url: deleteUrl,
data: {
'id': targetIdToDelete
},
success: function (response) {
showAlert('success', "删除成功");
location.reload();
},
error: function (response) {
showAlert('danger', "删除失败");
}
});
}
$('#deleteModal').modal('hide');
}
});
// 点击下载Excel模板按钮
$('#downloadExcelBtn').on('click', function () {
window.location.href = excel_upload_config.template_url;
});
// 当上传模态框显示时,清空文件输入框和文件名显示
$('#uploadModal').on('show.bs.modal', function () {
$('#inputFile').val('');
$('#file-chosen').text('未选择文件');
});
// 当选择文件变化时,更新文件名显示
$('#inputFile').on('change', function () {
var fileName = $(this).val().split('\\').pop();
$('#file-chosen').text(fileName || '未选择文件');
});
// 处理上传按钮的点击事件
$('#uploadBtn').on('click', function () {
var inputFile = $('#inputFile').get(0).files[0];
if (!inputFile) {
showAlert('danger', '未选择文件');
$('#uploadModal').modal('show');
return;
}
var formData = new FormData();
formData.append('file', inputFile); // 将文件添加到 FormData 中
formData.append('template_name', templateName);
formData.append('excel_valid_model', modelConfig);
formData.append('list_url', list_url)
$.ajax({
url: '{{ excel_upload_config.parse_url }}',
type: 'POST',
data: formData,
headers: {'X-CSRFToken': csrftoken},
contentType: false,
processData: false,
success: function (response) {
window.location.href = response.redirect_url;
},
error: function (xhr, status, error) {
var errorMsg = "解析Excel文件失败。";
if (xhr.responseJSON && xhr.responseJSON.error) {
errorMsg = xhr.responseJSON.error;
}
showAlert('danger', errorMsg);
}
});
});
});
function showShareholdersModal(data) {
// 将数据转换为数组
const shareholders = data.split(''); // 假设每个股东信息之间用中文分号分隔
// 清空表格
const tableBody = document.getElementById('shareholdersTableBody');
tableBody.innerHTML = '';
// 填充表格
shareholders.forEach(shareholder => {
const [name, ratio] = shareholder.match(/(.+?)(\d+%)/).slice(1, 3);
const row = document.createElement('tr');
const nameCell = document.createElement('td');
const ratioCell = document.createElement('td');
nameCell.textContent = name.trim();
ratioCell.textContent = ratio.trim();
row.appendChild(nameCell);
row.appendChild(ratioCell);
tableBody.appendChild(row);
});
// 显示模态框
const modal = new bootstrap.Modal(document.getElementById('shareholdersModal'));
modal.show();
}
function createCell(content) {
const cell = document.createElement('td');
cell.textContent = content.trim();
cell.className = 'text-center'; // 设置 class 属性为 text-center
return cell;
}
function showHistoryModal(entityId, page = 1) {
fetch(`/basic_data/om/entities/${entityId}/change_records/?page=${page}`)
.then(response => response.json())
.then(data => {
const records = data.results;
// Clear the table body
const tableBody = document.getElementById('historyTableBody');
tableBody.innerHTML = '';
// Populate the table
records.forEach(record => {
const row = document.createElement('tr');
row.appendChild(createCell(record.change_date));
row.appendChild(createCell(record.change_type));
row.appendChild(createCell(record.content_before_change));
row.appendChild(createCell(record.content_after_change));
row.appendChild(createCell(record.change_reason));
row.appendChild(createCell(record.change_executed_by));
tableBody.appendChild(row);
});
// Add pagination controls
const paginationControls = document.getElementById('paginationControls');
paginationControls.innerHTML = ''; // Clear existing controls
if (data.previous) {
const prevButton = document.createElement('button');
prevButton.textContent = '上一页';
prevButton.className = 'btn btn-primary';
prevButton.onclick = () => showHistoryModal(entityId, data.previous_page);
paginationControls.appendChild(prevButton);
}
if (data.next) {
const nextButton = document.createElement('button');
nextButton.textContent = '下一页';
nextButton.className = 'btn btn-primary';
nextButton.onclick = () => showHistoryModal(entityId, data.next_page);
paginationControls.appendChild(nextButton);
}
// Show the modal
const modal = new bootstrap.Modal(document.getElementById('showHistoryModal'));
modal.show();
})
.catch(error => console.error('Error fetching change records:', error));
}
function showBanksModal(entityId, page = 1) {
fetch(`/basic_data/om/entities/${entityId}/bank_accounts/?page=${page}`)
.then(response => response.json())
.then(data => {
const accounts = data.results;
// Clear the table body
const tableBody = document.getElementById('banksTableBody');
tableBody.innerHTML = '';
// Populate the table
accounts.forEach(account => {
const row = document.createElement('tr');
row.appendChild(createCell(account.bank_name));
row.appendChild(createCell(account.account_number));
row.appendChild(createCell(account.account_type));
row.appendChild(createCell(account.account_status));
const actionsCell = document.createElement('td');
actionsCell.className = 'text-center';
const editButton = document.createElement('button');
editButton.textContent = '编辑';
editButton.className = 'btn btn-outline-primary btn-sm me-2';
editButton.onclick = () => editBankAccount(account.account_id);
const deleteButton = document.createElement('button');
deleteButton.textContent = '删除';
deleteButton.className = 'btn btn-outline-danger btn-sm';
deleteButton.onclick = () => {
accountIdToDelete = account.account_id;
const deleteModal = new bootstrap.Modal(document.getElementById('deleteBankModal'));
deleteModal.show();
};
actionsCell.appendChild(editButton);
actionsCell.appendChild(deleteButton);
row.appendChild(actionsCell);
tableBody.appendChild(row);
});
// Add pagination controls
const paginationControls = document.getElementById('banksPaginationControls');
paginationControls.innerHTML = ''; // Clear existing controls
if (data.previous_page) {
const prevButton = document.createElement('button');
prevButton.textContent = '上一页';
prevButton.className = 'btn btn-primary';
prevButton.onclick = () => showBanksModal(entityId, data.previous_page);
paginationControls.appendChild(prevButton);
}
if (data.next_page) {
const nextButton = document.createElement('button');
nextButton.textContent = '下一页';
nextButton.className = 'btn btn-primary';
nextButton.onclick = () => showBanksModal(entityId, data.next_page);
paginationControls.appendChild(nextButton);
}
// Show the modal
const showBanksModalElement = document.getElementById('showBanksModal');
const modalInstance = bootstrap.Modal.getInstance(showBanksModalElement);
if (!modalInstance) {
const modal = new bootstrap.Modal(showBanksModalElement);
modal.show();
} else {
modalInstance.show();
}
document.getElementById('addBankAccountEntityId').value = entityId;
})
.catch(error => console.error('Error fetching bank accounts:', error));
}
function openAddBankAccountModal(entityId) {
const showBanksModalElement = document.getElementById('showBanksModal');
const showBanksModal = bootstrap.Modal.getInstance(showBanksModalElement);
if (showBanksModal) {
showBanksModal.hide(); // 关闭 showBanksModal 模态框
}
const modal = new bootstrap.Modal(document.getElementById('addBankAccountModal'));
modal.show();
}
function addBankAccount() {
const entityId = document.getElementById('addBankAccountEntityId').value;
const data = {
bank_name: document.getElementById('addBankName').value,
account_number: document.getElementById('addAccountNumber').value,
account_type: document.getElementById('addAccountType').value,
account_status: document.getElementById('addAccountStatus').value
};
fetch(`/basic_data/om/entities/${entityId}/bank_accounts/add/`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': getCookie('csrftoken')
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => {
if (data.account_id) {
// Refresh the bank accounts list
showAlert('success', '新增成功');
} else {
showAlert('warning', '新增失败');
}
})
.catch(error => console.error('Error adding bank account:', error));
}
function editBankAccount(accountId) {
accountIdToEdit = accountId;
// 先获取列表模态框的实例并关闭它
const showBanksModalElement = document.getElementById('showBanksModal');
const showBanksModal = bootstrap.Modal.getInstance(showBanksModalElement);
if (showBanksModal) {
showBanksModal.hide();
}
fetch(`/basic_data/om/bank_account/${accountId}/`)
.then(response => response.json())
.then(data => {
document.getElementById('editBankName').value = data.bank_name;
document.getElementById('editAccountNumber').value = data.account_number;
document.getElementById('editAccountType').value = data.account_type;
const editModal = new bootstrap.Modal(document.getElementById('editBankAccountModal'));
editModal.show();
})
.catch(error => console.error('Error fetching bank account details:', error));
}
function submitEditBankAccount() {
const bankName = document.getElementById('editBankName').value;
const accountNumber = document.getElementById('editAccountNumber').value;
const accountType = document.getElementById('editAccountType').value;
const accountStatus = document.getElementById('editAccountStatus').value;
fetch(`/basic_data/om/bank_accounts/${accountIdToEdit}/update/`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': getCookie('csrftoken')
},
body: JSON.stringify({
bank_name: bankName,
account_number: accountNumber,
account_type: accountType,
account_status: accountStatus,
})
})
.then(response => {
if (response.ok) {
// 更新成功后刷新表格
const showBanksModalElement = document.getElementById('showBanksModal');
const entityId = document.getElementById('addBankAccountEntityId').value;
showBanksModal(entityId);
const editModal = bootstrap.Modal.getInstance(document.getElementById('editBankAccountModal'));
editModal.hide();
showAlert('success', '修改成功');
} else {
return response.json().then(data => {
showAlert('warning', data);
});
}
})
.catch(error => console.error('Error updating bank account:', error));
}
function deleteBankAccount(accountId) {
fetch(`/basic_data/om/bank_accounts/${accountId}/delete/`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': getCookie('csrftoken')
}
})
.then(response => {
if (response.ok) {
// 删除成功后刷新表格
const showBanksModalElement = document.getElementById('showBanksModal');
const entityId = document.getElementById('addBankAccountEntityId').value;
showBanksModal(entityId);
showAlert('success', '删除成功');
} else {
showAlert('warning', '删除失败');
}
})
.catch(error => console.error('Error deleting bank account:', error));
}
document.getElementById('confirmDeleteBtn').addEventListener('click', () => {
deleteBankAccount(accountIdToDelete);
});
function getCookie(name) {
let cookieValue = null;
if (document.cookie && document.cookie !== '') {
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i].trim();
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
</script>
{% endblock %}

View File

@ -0,0 +1,611 @@
{% extends 'items_List.html' %}
{% load static tags %}
{% block fields_list_content %}
<div class="row mb-3">
<div class="col-sm-12">
<div class="card">
<div class="card-body table-border-style">
<div class="table-responsive">
<!-- 表格 开始 -->
<table class="table">
{% get_verbose_field_names_from_model model_config table_exclude_field_name as columns %}
<thead>
<tr>
{% for column in columns %}
<th class="text-center">{{ column }}</th>
{% endfor %}
<th class="text-center">操作</th>
</tr>
</thead>
<tbody id="result" style="color: white;">
{% for item in items %}
<tr>
{% for field in item|get_fields:table_exclude_field_name %}
{% if field.verbose_name|is_in_list:"营业范围,注册地址" %}
<td class="text-center"
title="{{ field.value }}">{{ field.value|truncatechars:10 }}</td>
{% elif field.verbose_name == '股东姓名及持股比例' %}
<td class="text-center">
<span style="color: red; cursor: pointer"
title="{{ field.value }}"
onclick="showShareholdersModal('{{ field.value }}')">详情</span>
</td>
{% elif field.verbose_name == '历史沿革' %}
<td class="text-center">
<span style="color: blueviolet; cursor: pointer"
onclick="showHistoryModal({{ item.entity_id }})">查看</span>
</td>
{% elif field.verbose_name == '相关银行账户信息' %}
<td class="text-center">
<span style="color: green; cursor: pointer"
onclick="showBanksModal({{ item.entity_id }})">查看</span>
</td>
{% else %}
{% if '(元)' in field.verbose_name %}
<td class="text-center">{{ field.value|thousands_separator }}</td>
{% else %}
<td class="text-center">{{ field.value }}</td>
{% endif %}
{% endif %}
{% endfor %}
<td class="text-center">
<a href="#"
id="editBtn"
class="edit-btn"
data-id="{{ item|get_pk_value }}"
data-bs-toggle="modal"
data-bs-target="#addEditModal">编辑</a>
<a href="#"
id="deleteBtn"
class="edit-btn"
style="color: red"
data-id="{{ item|get_pk_value }}"
data-bs-toggle="modal"
data-bs-target="#deleteModal">删除</a>
</td>
</tr>
{% empty %}
<tr>
<td class="text-center"
colspan="{{ table_columns|length }}">暂无数据
</td>
</tr>
{% endfor %}
</tbody>
</table>
<!-- 表格 结束 -->
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block item_list_custom_content %}
<div id="shareholdersModal" class="modal fade bd-example-modal-sm" tabindex="-1" role="dialog"
aria-labelledby="formModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-sm" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="formModalTitle">股东姓名及持股比例</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table class="table">
<thead>
<tr>
<th>股东姓名</th>
<th>持股比例</th>
</tr>
</thead>
<tbody id="shareholdersTableBody">
</tbody>
</table>
</div>
</div>
</div>
</div>
<div id="showHistoryModal" class="modal fade bd-example-modal-xl" tabindex="-1" role="dialog"
aria-labelledby="formModalCenterTitle" 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="formModalTitle">历史沿革</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table class="table">
<thead>
<tr>
<th class="text-center">变更日期</th>
<th class="text-center">变更类型</th>
<th class="text-center">变更前内容</th>
<th class="text-center">变更后内容</th>
<th class="text-center">变更原因</th>
<th class="text-center">变更执行人</th>
</tr>
</thead>
<tbody id="historyTableBody">
</tbody>
</table>
<div id="paginationControls" class="text-center mt-3">
<!-- Pagination controls will be inserted here by JavaScript -->
</div>
</div>
</div>
</div>
</div>
<div id="showBanksModal" class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog"
aria-labelledby="formModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="formModalTitle">银行账户信息</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table class="table">
<thead>
<tr>
<th class="text-center">开户行名称</th>
<th class="text-center">账号</th>
<th class="text-center">账户类型</th>
<th class="text-center">账户状态</th>
<th class="text-center">操作</th>
</tr>
</thead>
<tbody id="banksTableBody">
</tbody>
</table>
<div class="d-flex justify-content-between align-items-center mt-3">
<button class="btn btn-outline-dark" onclick="openAddBankAccountModal({{ item.entity_id }})">
新增银行账户
</button>
<div id="banksPaginationControls">
<!-- Pagination controls will be inserted here by JavaScript -->
</div>
</div>
</div>
</div>
</div>
</div>
<div id="addBankAccountModal" class="modal fade" tabindex="-1" role="dialog"
aria-labelledby="addBankAccountModalTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addBankAccountModalTitle">新增银行账户</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form id="addBankAccountForm">
<input type="hidden" id="addBankAccountEntityId">
<div class="mb-3">
<label for="addBankName" class="form-label">开户行名称</label>
<input type="text" class="form-control" id="addBankName" required>
</div>
<div class="mb-3">
<label for="addAccountNumber" class="form-label">账号</label>
<input type="text" class="form-control" id="addAccountNumber" required>
</div>
<div class="mb-3">
<label for="addAccountType" class="form-label">账户类型</label>
<select class="form-control" id="addAccountType" required>
<option value="基本户">基本户</option>
<option value="一般户">一般户</option>
</select>
</div>
<div class="mb-3">
<label for="addAccountStatus" class="form-label">账户状态</label>
<select class="form-control" id="addAccountStatus" required>
<option value="活跃">活跃</option>
<option value="不活跃">不活跃</option>
<option value="已关闭">已关闭</option>
<option value="暂停">暂停</option>
<option value="待处理">待处理</option>
<option value="冻结">冻结</option>
</select>
</div>
<div class="text-end">
<button type="submit" class="btn btn-primary" onclick="addBankAccount()">保存</button>
</div>
</form>
</div>
</div>
</div>
</div>
<div id="deleteBankAModal" class="modal fade" tabindex="-1" role="dialog"
aria-labelledby="deleteBankModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="deleteBankModalLabel">提示
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"
aria-label="Close"></button>
</div>
<div class="modal-body">
<p>此操作会删除当前数据,是否继续?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">取消</button>
<button type="button" class="btn btn-danger" id="confirmDeleteBtn">删除</button>
</div>
</div>
</div>
</div>
<div id="editBankAccountModal" class="modal fade" tabindex="-1" role="dialog"
aria-labelledby="editBankAccountModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="editBankAccountModalLabel">编辑银行账户</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form id="editBankAccountForm">
<div class="mb-3">
<label for="editBankName" class="form-label">开户行名称</label>
<input type="text" class="form-control" id="editBankName" required>
</div>
<div class="mb-3">
<label for="editAccountNumber" class="form-label">账号</label>
<input type="text" class="form-control" id="editAccountNumber" required>
</div>
<div class="mb-3">
<label for="editAccountType" class="form-label">账户类型</label>
<select class="form-control" id="editAccountType" required>
<option value="基本户">基本户</option>
<option value="一般户">一般户</option>
</select>
</div>
<div class="mb-3">
<label for="editAccountStatus" class="form-label">账户状态</label>
<select class="form-control" id="editAccountStatus" required>
<option value="活跃">活跃</option>
<option value="不活跃">不活跃</option>
<option value="已关闭">已关闭</option>
<option value="暂停">暂停</option>
<option value="待处理">待处理</option>
<option value="冻结">冻结</option>
</select>
</div>
<div class="text-end">
<button type="button" class="btn btn-primary" onclick="submitEditBankAccount()">保存
</button>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
{% block js_content %}
<script>
document.addEventListener('DOMContentLoaded', function () {
let accountIdToDelete;
let accountIdToEdit;
function showShareholdersModal(data) {
// 将数据转换为数组
const shareholders = data.split(''); // 假设每个股东信息之间用中文分号分隔
// 清空表格
const tableBody = document.getElementById('shareholdersTableBody');
tableBody.innerHTML = '';
// 填充表格
shareholders.forEach(shareholder => {
const [name, ratio] = shareholder.match(/(.+?)(\d+%)/).slice(1, 3);
const row = document.createElement('tr');
const nameCell = document.createElement('td');
const ratioCell = document.createElement('td');
nameCell.textContent = name.trim();
ratioCell.textContent = ratio.trim();
row.appendChild(nameCell);
row.appendChild(ratioCell);
tableBody.appendChild(row);
});
// 显示模态框
const modal = new bootstrap.Modal(document.getElementById('shareholdersModal'));
modal.show();
}
function createCell(content) {
const cell = document.createElement('td');
cell.textContent = content.trim();
cell.className = 'text-center'; // 设置 class 属性为 text-center
return cell;
}
function showHistoryModal(entityId, page = 1) {
fetch(`/basic_data/om/entities/${entityId}/change_records/?page=${page}`)
.then(response => response.json())
.then(data => {
const records = data.results;
// Clear the table body
const tableBody = document.getElementById('historyTableBody');
tableBody.innerHTML = '';
// Populate the table
records.forEach(record => {
const row = document.createElement('tr');
row.appendChild(createCell(record.change_date));
row.appendChild(createCell(record.change_type));
row.appendChild(createCell(record.content_before_change));
row.appendChild(createCell(record.content_after_change));
row.appendChild(createCell(record.change_reason));
row.appendChild(createCell(record.change_executed_by));
tableBody.appendChild(row);
});
// Add pagination controls
const paginationControls = document.getElementById('paginationControls');
paginationControls.innerHTML = ''; // Clear existing controls
if (data.previous) {
const prevButton = document.createElement('button');
prevButton.textContent = '上一页';
prevButton.className = 'btn btn-primary';
prevButton.onclick = () => showHistoryModal(entityId, data.previous_page);
paginationControls.appendChild(prevButton);
}
if (data.next) {
const nextButton = document.createElement('button');
nextButton.textContent = '下一页';
nextButton.className = 'btn btn-primary';
nextButton.onclick = () => showHistoryModal(entityId, data.next_page);
paginationControls.appendChild(nextButton);
}
// Show the modal
const modal = new bootstrap.Modal(document.getElementById('showHistoryModal'));
modal.show();
})
.catch(error => console.error('Error fetching change records:', error));
}
function showBanksModal(entityId, page = 1) {
fetch(`/basic_data/om/entities/${entityId}/bank_accounts/?page=${page}`)
.then(response => response.json())
.then(data => {
const accounts = data.results;
// Clear the table body
const tableBody = document.getElementById('banksTableBody');
tableBody.innerHTML = '';
// Populate the table
accounts.forEach(account => {
const row = document.createElement('tr');
row.appendChild(createCell(account.bank_name));
row.appendChild(createCell(account.account_number));
row.appendChild(createCell(account.account_type));
row.appendChild(createCell(account.account_status));
const actionsCell = document.createElement('td');
actionsCell.className = 'text-center';
const editButton = document.createElement('button');
editButton.textContent = '编辑';
editButton.className = 'btn btn-outline-primary btn-sm me-2';
editButton.onclick = () => editBankAccount(account.account_id);
const deleteButton = document.createElement('button');
deleteButton.textContent = '删除';
deleteButton.className = 'btn btn-outline-danger btn-sm';
deleteButton.onclick = () => {
accountIdToDelete = account.account_id;
const deleteModal = new bootstrap.Modal(document.getElementById('deleteBankModal'));
deleteModal.show();
};
actionsCell.appendChild(editButton);
actionsCell.appendChild(deleteButton);
row.appendChild(actionsCell);
tableBody.appendChild(row);
});
// Add pagination controls
const paginationControls = document.getElementById('banksPaginationControls');
paginationControls.innerHTML = ''; // Clear existing controls
if (data.previous_page) {
const prevButton = document.createElement('button');
prevButton.textContent = '上一页';
prevButton.className = 'btn btn-primary';
prevButton.onclick = () => showBanksModal(entityId, data.previous_page);
paginationControls.appendChild(prevButton);
}
if (data.next_page) {
const nextButton = document.createElement('button');
nextButton.textContent = '下一页';
nextButton.className = 'btn btn-primary';
nextButton.onclick = () => showBanksModal(entityId, data.next_page);
paginationControls.appendChild(nextButton);
}
// Show the modal
const showBanksModalElement = document.getElementById('showBanksModal');
const modalInstance = bootstrap.Modal.getInstance(showBanksModalElement);
if (!modalInstance) {
const modal = new bootstrap.Modal(showBanksModalElement);
modal.show();
} else {
modalInstance.show();
}
document.getElementById('addBankAccountEntityId').value = entityId;
})
.catch(error => console.error('Error fetching bank accounts:', error));
}
function openAddBankAccountModal(entityId) {
const showBanksModalElement = document.getElementById('showBanksModal');
const showBanksModal = bootstrap.Modal.getInstance(showBanksModalElement);
if (showBanksModal) {
showBanksModal.hide(); // 关闭 showBanksModal 模态框
}
const modal = new bootstrap.Modal(document.getElementById('addBankAccountModal'));
modal.show();
}
function addBankAccount() {
const entityId = document.getElementById('addBankAccountEntityId').value;
const data = {
bank_name: document.getElementById('addBankName').value,
account_number: document.getElementById('addAccountNumber').value,
account_type: document.getElementById('addAccountType').value,
account_status: document.getElementById('addAccountStatus').value
};
fetch(`/basic_data/om/entities/${entityId}/bank_accounts/add/`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': getCookie('csrftoken')
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => {
if (data.account_id) {
// Refresh the bank accounts list
showAlert('success', '新增成功');
} else {
showAlert('warning', '新增失败');
}
})
.catch(error => console.error('Error adding bank account:', error));
}
function editBankAccount(accountId) {
accountIdToEdit = accountId;
// 先获取列表模态框的实例并关闭它
const showBanksModalElement = document.getElementById('showBanksModal');
const showBanksModal = bootstrap.Modal.getInstance(showBanksModalElement);
if (showBanksModal) {
showBanksModal.hide();
}
fetch(`/basic_data/om/bank_account/${accountId}/`)
.then(response => response.json())
.then(data => {
document.getElementById('editBankName').value = data.bank_name;
document.getElementById('editAccountNumber').value = data.account_number;
document.getElementById('editAccountType').value = data.account_type;
const editModal = new bootstrap.Modal(document.getElementById('editBankAccountModal'));
editModal.show();
})
.catch(error => console.error('Error fetching bank account details:', error));
}
function submitEditBankAccount() {
const bankName = document.getElementById('editBankName').value;
const accountNumber = document.getElementById('editAccountNumber').value;
const accountType = document.getElementById('editAccountType').value;
const accountStatus = document.getElementById('editAccountStatus').value;
fetch(`/basic_data/om/bank_accounts/${accountIdToEdit}/update/`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': getCookie('csrftoken')
},
body: JSON.stringify({
bank_name: bankName,
account_number: accountNumber,
account_type: accountType,
account_status: accountStatus,
})
})
.then(response => {
if (response.ok) {
// 更新成功后刷新表格
const showBanksModalElement = document.getElementById('showBanksModal');
const entityId = document.getElementById('addBankAccountEntityId').value;
showBanksModal(entityId);
const editModal = bootstrap.Modal.getInstance(document.getElementById('editBankAccountModal'));
editModal.hide();
showAlert('success', '修改成功');
} else {
return response.json().then(data => {
showAlert('warning', data);
});
}
})
.catch(error => console.error('Error updating bank account:', error));
}
function deleteBankAccount(accountId) {
fetch(`/basic_data/om/bank_accounts/${accountId}/delete/`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': getCookie('csrftoken')
}
})
.then(response => {
if (response.ok) {
// 删除成功后刷新表格
const showBanksModalElement = document.getElementById('showBanksModal');
const entityId = document.getElementById('addBankAccountEntityId').value;
showBanksModal(entityId);
showAlert('success', '删除成功');
} else {
showAlert('warning', '删除失败');
}
})
.catch(error => console.error('Error deleting bank account:', error));
}
document.getElementById('confirmDeleteBtn').addEventListener('click', () => {
deleteBankAccount(accountIdToDelete);
});
function getCookie(name) {
let cookieValue = null;
if (document.cookie && document.cookie !== '') {
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i].trim();
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
// 将函数绑定到全局对象
window.showShareholdersModal = showShareholdersModal;
window.showHistoryModal = showHistoryModal;
window.showBanksModal = showBanksModal;
window.openAddBankAccountModal = openAddBankAccountModal;
window.addBankAccount = addBankAccount;
window.editBankAccount = editBankAccount;
window.submitEditBankAccount = submitEditBankAccount;
window.deleteBankAccount = deleteBankAccount;
})
</script>
{% endblock %}

View File

@ -103,13 +103,15 @@ def eir_list_view(request):
"save_url": reverse("save_excel_table_data")
},
"query_params": query_params,
"form_action_url": 'eir_list',
"form_action_url": reverse('eir_list'),
"modify_url": reverse("eir_list_modify"),
"add_url": reverse("eir_list_add"),
"delete_url": reverse("eir_list_delete"),
"add_button": True,
"import_excel_button": True
}
return render(request, 'ce_list.html', context)
return render(request, 'ce_list_inherit.html', context)
@custom_permission_required('org_mgnt.add_companyentity')

View File

@ -19,7 +19,7 @@ from rest_framework.serializers import ModelSerializer
from application import fac_mgnt
from application.fac_mgnt.models import InvoiceRecord
from application.org_mgnt.models import SecondaryDepartment
from application.org_mgnt.models import SecondaryDepartment, PrimaryDepartment
from application.pjt_mgnt.models import ProjectLedger
@ -234,8 +234,9 @@ def save_excel_table_data(request):
@login_required
def load_secondary_departments(request):
primary_department_id = request.GET.get('primary_department_id')
secondary_departments = SecondaryDepartment.objects.filter(primary_department_id=primary_department_id).order_by(
primary_department_name = request.GET.get('primary_department_name')
primary_department = PrimaryDepartment.objects.get(department_name=primary_department_name)
secondary_departments = SecondaryDepartment.objects.filter(primary_department_id=primary_department.primary_department_id).order_by(
'secondary_department_name')
return JsonResponse(list(secondary_departments.values('secondary_department_id', 'secondary_department_name')),
safe=False)

View File

@ -23,7 +23,8 @@
{% for filter in filters %}
{% if filter.type == 'text' %}
<div class="col">
<label for="{{ filter.id }}" class="form-label">{{ filter.label }}</label>
<label for="{{ filter.id }}"
class="form-label">{{ filter.label }}</label>
<input type="text" class="form-control"
id="{{ filter.id }}"
name="{{ filter.name }}"
@ -32,7 +33,8 @@
</div>
{% elif filter.type == 'select' %}
<div class="col">
<label class="form-label" for="{{ filter.id }}">{{ filter.label }}</label>
<label class="form-label"
for="{{ filter.id }}">{{ filter.label }}</label>
<select class="form-control"
id="{{ filter.id }}"
name="{{ filter.name }}">
@ -47,7 +49,8 @@
</div>
{% elif filter.type == 'date' %}
<div class="col">
<label for="{{ filter.id }}" class="form-label">{{ filter.label }}</label>
<label for="{{ filter.id }}"
class="form-label">{{ filter.label }}</label>
<input type="date" class="form-control"
id="{{ filter.id }}"
name="{{ filter.name }}"
@ -55,7 +58,8 @@
</div>
{% elif filter.type == 'month' %}
<div class="col">
<label for="{{ filter.id }}" class="form-label">{{ filter.label }}</label>
<label for="{{ filter.id }}"
class="form-label">{{ filter.label }}</label>
<input type="month" class="form-control"
id="{{ filter.id }}"
name="{{ filter.name }}"
@ -65,7 +69,9 @@
{% endfor %}
{% if filters %}
<div class="col mt-4 d-flex align-items-center">
<button type="submit" class="btn btn-primary">查询</button>
<button type="submit" class="btn btn-primary">
查询
</button>
</div>
{% endif %}
</div>
@ -75,14 +81,18 @@
{% render_button 'modify_records_button' %}
{% render_button 'add_button' %}
{% render_button 'report_excel_button' %}
{# {% render_button 'import_excel_button' %}#}
<button id="importExcelBtnTest" class="btn btn-outline-primary" data-bs-toggle="modal" data-bs-target="#uploadModal">上传Excel(测试)</button>
{# {% render_button 'import_excel_button' %}#}
<button id="importExcelBtnTest" class="btn btn-outline-primary"
data-bs-toggle="modal" data-bs-target="#uploadModal">
上传Excel(测试)
</button>
</div>
</div>
</div>
</div>
</div>
</div>
{% block fields_list_content %}
<div class="row mb-3">
<div class="col-sm-12">
<div class="card">
@ -138,6 +148,7 @@
</div>
</div>
</div>
{% endblock %}
{% include 'pagination_ps.html' with page_obj=items query_params=query_params %}
</div>
</div>
@ -161,7 +172,8 @@
</div>
</div>
<div id="deleteModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
<div id="deleteModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
@ -182,7 +194,8 @@
</div>
</div>
<div id="uploadModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="uploadModalLabel" aria-hidden="true">
<div id="uploadModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="uploadModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form id="upload-form" method="post" enctype="multipart/form-data">
@ -197,7 +210,9 @@
<span id="file-chosen" style="font-size: 12px; margin-left: 10px;">未选择文件</span>
</div>
<div class="modal-footer">
<button id="downloadExcelBtn" type="button" class="btn btn-secondary" onclick="#!">下载填报模板</button>
<button id="downloadExcelBtn" type="button" class="btn btn-secondary" onclick="#!">
下载填报模板
</button>
<button id="uploadBtn" type="button" class="btn btn-primary">上传Excel</button>
</div>
</form>
@ -393,5 +408,8 @@
});
});
</script>
{% block js_content %}
{% endblock %}
{% endblock %}