chore: 调整导入Excel,日期选择器的样式

This commit is contained in:
2025-12-18 09:32:04 +08:00
parent ac21c6c32e
commit befdd0dbb9
3 changed files with 181 additions and 41 deletions

View File

@@ -31,6 +31,7 @@ class Project extends Base {
/*会员中心数据表*/
$this->project_db = Db::name('project'); //
$this->service_db = Db::name('service'); //
$this->projectQueryPasswordDb = Db::name('project_query_password'); // 查询密码表
// 是否开启支付功能设置
$this->userConfig = getUsersConfigData('all');
@@ -106,7 +107,6 @@ class Project extends Base {
// 添加表信息
$data = array(
'name' => $post['name'],
'pwd' => $post['pwd'],
'enterprise' => $post['enterprise'],
'filing' => $post['filing'],
'sid' =>$post['sid'],
@@ -400,19 +400,18 @@ class Project extends Base {
$rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE)[0];
// 确保行数据完整
if (count($rowData) >= 6) {
if (count($rowData) >= 5) {
// 验证必要字段不为空
if (empty(trim($rowData[0])) || empty(trim($rowData[1]))) {
if (empty(trim($rowData[0]))) {
continue; // 跳过必填字段为空的行
}
$data[] = [
'name' => trim($rowData[0]),
'pwd' => trim($rowData[1]),
'enterprise' => trim($rowData[2]),
'filing' => trim($rowData[3]),
'sid' => trim($rowData[4]),
'limitationdate' => trim($rowData[5]),
'enterprise' => trim($rowData[1]),
'filing' => trim($rowData[2]),
'sid' => trim($rowData[3]),
'limitationdate' => trim($rowData[4]),
'createtime' => getTime()
];
}
@@ -487,4 +486,138 @@ class Project extends Base {
imagedestroy($target);
echo '<img src="../../uploads/imgs/'.$id.'.jpg">';
}
// 查询密码列表
public function password_index()
{
$list = array();
$param = input('param.');
$condition = array();
// 应用搜索条件
foreach (['keywords'] as $key) {
if (isset($param[$key]) && $param[$key] !== '') {
if ($key == 'keywords') {
$condition['password'] = array('LIKE', "%{$param[$key]}%");
}
}
}
/**
* 数据查询
*/
$count = $this->projectQueryPasswordDb->where($condition)->count();// 查询满足要求的总记录数
$Page = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
$list = $this->projectQueryPasswordDb
->where($condition)
->order('id desc')
->limit($Page->firstRow.','.$Page->listRows)
->select();
$show = $Page->show();// 分页显示输出
$this->assign('page',$show);// 赋值分页输出
$this->assign('list',$list);// 赋值数据集
$this->assign('pager',$Page);// 赋值分页集
return $this->fetch('password_index');
}
// 新增/编辑查询密码
public function password_add()
{
$id = input('id/d', 0);
if ($id > 0) {
$info = $this->projectQueryPasswordDb->where(['id' => $id])->find();
if (empty($info)) {
$this->error('数据不存在');
}
$this->assign('info', $info);
}
if (IS_POST) {
$post = input('post.');
// 验证数据
if (empty($post['password'])) {
$this->error('查询密码不能为空');
}
// 准备数据
$data = [
'password' => trim($post['password']),
'allow_keywords' => trim($post['allow_keywords']),
'deny_keywords' => trim($post['deny_keywords']),
'status' => !empty($post['status']) ? 1 : 0,
'updatetime' => time()
];
if (empty($info)) {
// 新增
$data['createtime'] = time();
$result = $this->projectQueryPasswordDb->insert($data);
$msg = '新增';
} else {
// 编辑
$result = $this->projectQueryPasswordDb->where(['id' => $id])->update($data);
$msg = '编辑';
}
if ($result !== false) {
$this->success($msg . "成功", url('Project/password_index'));
} else {
$this->error($msg . "失败");
}
}
$this->assign('id', $id);
return $this->fetch('password_add');
}
// 删除查询密码
public function password_del()
{
$id = input('del_id/d', 0);
if (IS_AJAX_POST && !empty($id)) {
$result = $this->projectQueryPasswordDb->where(['id' => $id])->delete();
if ($result) {
$this->success('删除成功');
} else {
$this->error('删除失败');
}
}
$this->error('参数有误');
}
// 批量删除查询密码
public function password_batch_del()
{
$ids = input('del_id/a');
if (IS_AJAX_POST && !empty($ids)) {
$result = $this->projectQueryPasswordDb->where(['id' => ['IN', $ids]])->delete();
if ($result) {
$this->success('批量删除成功');
} else {
$this->error('批量删除失败');
}
}
$this->error('参数有误');
}
// 修改状态
public function password_change_status()
{
$id = input('id/d', 0);
$status = input('status/d', 0);
if (IS_AJAX_POST && !empty($id)) {
$result = $this->projectQueryPasswordDb->where(['id' => $id])->update(['status' => $status, 'updatetime' => time()]);
if ($result) {
$this->success('状态修改成功');
} else {
$this->error('状态修改失败');
}
}
$this->error('参数有误');
}
}

View File

@@ -8,24 +8,16 @@
<form class="form-horizontal" id="post_form" action="{:url('AdPosition/add')}" method="post">
<div class="ncap-form-default">
<dl class="row">
<dt class="tit"> <label for="title"><em>*</em>名称</label> </dt>
<dt class="tit"> <label for="title"><em>*</em>应用名称</label> </dt>
<dd class="opt">
<input type="text" name="name" id="name" class="input-txt" value="{$item['name']}" autocomplete="off">
<span class="err"></span>
<p class="notic2 red" id="title_tips"></p>
</dd>
</dl>
<dl class="row" style="display: none">
<dt class="tit"> <label for="title"><em>*</em>密码</label> </dt>
<dd class="opt">
<input type="text" name="pwd" id="pwd" class="input-txt" value="123123" autocomplete="off">
<span class="err"></span>
<p class="notic2 red" id="title_tips"></p>
</dd>
</dl>
<input type="hidden" value="{$id}" name="id">
<dl class="row">
<dt class="tit"> <label for="title"><em>*</em>个人/企业</label> </dt>
<dt class="tit"> <label for="title"><em>*</em>所属个人/企业</label> </dt>
<dd class="opt">
<input type="text" name="enterprise" id="enterprise" value="{$item['enterprise']}" class="input-txt" autocomplete="off">
<span class="err"></span>
@@ -51,9 +43,9 @@
<dl class="row">
<dt class="tit"> <label for="title"><em>*</em>有效期</label> </dt>
<dd class="opt">
<input type="text" name="limitationdate" value="{$item['limitationdate']}" id="limitationdate" class="input-txt" autocomplete="off">
<input type="text" name="limitationdate" value="{$item['limitationdate']}" id="limitationdate" class="input-txt" autocomplete="off" readonly>
<span class="err"></span>
<p class="notic2 red" id="title_tips"></p>
<p class="notic2 red" id="title_tips">格式YYYY-MM-DD</p>
</dd>
</dl>
@@ -64,23 +56,30 @@
</form>
</div>
<style>
</style>
<script type="text/javascript">
var parentObj = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
// 初始化layui日期选择器
layui.use('laydate', function(){
var laydate = layui.laydate;
// 日期选择器
laydate.render({
elem: '#limitationdate',
theme: '#3398CC'
});
});
// 判断输入框是否为空
function checkForm(){
if($('input[name=title]').val() == ''){
layer.msg('名称不能为空!', {icon: 2,time: 1000});
return false;
}
if($('input[name=pwd]').val() == ''){
layer.msg('密码不能为空!', {icon: 2,time: 1000});
layer.msg('应用名称不能为空!', {icon: 2,time: 1000});
return false;
}
if($('input[name=enterprise]').val() == ''){
layer.msg('个人/企业不能为空!', {icon: 2,time: 1000});
layer.msg('所属个人/企业不能为空!', {icon: 2,time: 1000});
return false;
}
if($('input[name=filing]').val() == ''){

View File

@@ -3,6 +3,16 @@
<body class="bodystyle" style="overflow-y: scroll; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<style>
.custom-import-btn {
background-color: #3398CC;
border-color: #3398CC;
}
.custom-import-btn:hover {
background-color: #2a80ae;
border-color: #2a80ae;
}
</style>
<div class="page">
<div class="flexigrid">
@@ -49,7 +59,7 @@
</div>
<div class="fbutton">
<a href="javascript:void(0);" onclick="importExcel();">
<div class="add">
<div class="add custom-import-btn">
<span><i class="fa fa-upload"></i>导入Excel</span>
</div>
</a>
@@ -68,13 +78,10 @@
<div class="tc">证书</div>
</th>
<th abbr="article_title" axis="col4" style="width: 15%">
<div class="tc">名称</div>
</th>
<th abbr="article_title" axis="col4" style="width: 15%">
<div class="tc">密码</div>
<div class="tc">应用名称</div>
</th>
<th abbr="ac_id" axis="col4" class="" style="width: 15%">
<div class="tl text-l10">个人/企业</div>
<div class="tl text-l10">所属个人/企业</div>
</th>
<th abbr="ac_id" axis="col4" class="" style="width: 15%">
<div class="tc">备案号</div>
@@ -114,9 +121,6 @@
<td abbr="article_title" axis="col4" style="width: 15%">
<div class="tc">{$vo.name}</div>
</td>
<td abbr="article_title" axis="col4" style="width: 15%">
<div class="tc">{$vo.pwd}</div>
</td>
<td abbr="ac_id" axis="col4" class="" style="width: 15%">
<div class="tl text-l10">{$vo.enterprise}</div>
</td>
@@ -264,19 +268,23 @@
layer.open({
type: 1,
title: '导入Excel数据',
area: ['500px', '300px'],
area: ['600px', '400px'],
content: '<div style="padding: 20px;">' +
'<style>' +
'.custom-layui-btn { background-color: #3398CC !important; border-color: #3398CC !important; }' +
'.custom-layui-btn:hover { background-color: #2a80ae !important; border-color: #2a80ae !important; }' +
'</style>' +
'<form id="importForm" enctype="multipart/form-data">' +
'<div class="layui-form-item">' +
'<label class="layui-form-label">选择文件:</label>' +
'<div class="layui-input-block">' +
'<input type="file" name="excel_file" accept=".xls,.xlsx" class="layui-input" style="height: 38px;" required>' +
'<input type="file" name="excel_file" accept=".xls,.xlsx" class="layui-input" style="height: 38px; padding-left: 0px; border-style: none; padding-top: 5px;" required>' +
'<div class="layui-form-mid layui-word-aux">只支持Excel文件(.xls, .xlsx)</div>' +
'</div>' +
'</div>' +
'<div class="layui-form-item" style="margin-top: 20px;">' +
'<div class="layui-input-block">' +
'<button type="button" class="layui-btn" onclick="submitImport()">上传并导入</button>' +
'<button type="button" class="layui-btn custom-layui-btn" onclick="submitImport()">上传并导入</button>' +
'<button type="button" class="layui-btn layui-btn-primary" onclick="layer.closeAll()">取消</button>' +
'<a href="../../../data/project_template.xlsx" style="margin-left: 10px;" download="project_template.xlsx">下载模板</a>' +
'</div>' +
@@ -285,8 +293,8 @@
'<div style="margin-top: 20px; color: #999; font-size: 12px;">' +
'<p><strong>Excel文件格式要求</strong></p>' +
'<p>1. 第一行为列标题(会被自动忽略)</p>' +
'<p>2. 列顺序必须为:名称、密码、个人/企业、备案号、证件号码、有效期</p>' +
'<p>3. 名称和密码为必填项</p>' +
'<p>2. 列顺序必须为:应用名称、所属个人/企业、备案号、证件号码、有效期</p>' +
'<p>3. 应用名称为必填项</p>' +
'<p>4. 支持.xls和.xlsx格式</p>' +
'<p>5. 日期格式YYYY-MM-DD</p>' +
'</div>' +