feat: 需求报名后台完善

master
yin5th 2023-08-18 10:55:12 +08:00
parent cd0725c55e
commit 39afee861d
8 changed files with 817 additions and 0 deletions

View File

@ -0,0 +1,145 @@
<?php
namespace app\admin\controller\content;
use app\admin\logic\content\HelpCategoryLogic;
use app\admin\logic\content\HelpLogic;
use app\admin\validate\content\HelpValidate;
use app\common\basics\AdminBase;
use app\common\server\JsonServer;
use app\common\model\Demand As thisModel;
use think\facade\Validate;
class Demand extends AdminBase
{
/**
* @NOTES: 列表
* @author: 张无忌
*/
public function lists()
{
if ($this->request->isAjax()) {
try {
$page = input('page/d', 1);
$limit = input('limit/d', 10);
$keyword = input('keyword/s');
$page = $page ?: 1;
$limit = $limit ?: 10;
$where = [];
$order = [
'id' => 'desc'
];
if (!empty($keyword)) {
$where[] = ['name', 'like', '%'.trim($keyword).'%'];
}
$count = thisModel::where($where)->count();
$list = thisModel::withCount(['reports'])->field(['id', 'name', 'create_time'])
->where($where)
->order($order)
->page($page,$limit)
->select()
->toArray();
$data = [
'lists' => $list,
'page_no' => $page,
'page_size' => $limit,
'count' => $count,
];
return JsonServer::success('获取成功', $data);
} catch (\Exception $e) {
return JsonServer::error('获取失败');
}
}
return view();
}
/**
* @NOTES: 添加
* @author: 张无忌
*/
public function add()
{
if ($this->request->isAjax()) {
$input = input('post.');
$rule = [
'name|需求名称' => 'require|min:2',
'content|介绍' => 'require',
];
$validate = Validate::rule($rule);
if (!$validate->check($input)) {
return JsonServer::error($validate->getError());
}
thisModel::create([
'name' => $input['name'],
'content' => $input['content'],
'create_time' => time(),
]);
return JsonServer::success('添加成功');
}
return view();
}
/**
* @NOTES: 编辑
* @author: 张无忌
*/
public function edit()
{
$id = input('id');
$item = thisModel::where('id', $id)->find();
if ($this->request->isAjax()) {
$input = input('post.');
$rule = [
'name|需求名称' => 'require|min:2',
'content|介绍' => 'require',
];
$validate = Validate::rule($rule);
if (!$validate->check($input)) {
return JsonServer::error($validate->getError());
}
$item->save([
'name' => $input['name'],
'content' => $input['content'],
]);
return JsonServer::success('编辑成功');
}
return view('', [
'detail' => $item,
]);
}
/**
* @NOTES: 删除
* @author: 张无忌
*/
public function del()
{
if ($this->request->isAjax()) {
thisModel::where('id', input('id/d'))->delete();
return JsonServer::success('删除成功');
}
return JsonServer::error('异常');
}
}

View File

@ -0,0 +1,107 @@
<?php
namespace app\admin\controller\content;
use app\common\basics\AdminBase;
use app\common\server\JsonServer;
use app\common\model\DemandReport As thisModel;
use think\facade\Validate;
class DemandReport extends AdminBase
{
/**
* @NOTES: 列表
* @author: 张无忌
*/
public function lists()
{
$demandId = input('demand_id/d');
if ($this->request->isAjax()) {
try {
$page = input('page/d', 1);
$limit = input('limit/d', 10);
$keyword = input('keyword/s');
$status = input('status');
$page = $page ?: 1;
$limit = $limit ?: 10;
$where = [];
$order = [
'id' => 'desc'
];
$where[] = ['demand_id', '=', $demandId];
if (!empty($keyword)) {
$where[] = ['name|phone|company|price', 'like', '%'.trim($keyword).'%'];
}
if (isset($status) && $status != '') {
$where[] = ['status', '=', $status];
}
$count = thisModel::where($where)->count();
$list = thisModel::where($where)
->order($order)
->page($page,$limit)
->select()
->toArray();
$data = [
'lists' => $list,
'page_no' => $page,
'page_size' => $limit,
'count' => $count,
];
return JsonServer::success('获取成功', $data);
} catch (\Exception $e) {
return JsonServer::error('获取失败');
}
}
return view('', ['demandId' => $demandId]);
}
/**
* @NOTES: 编辑
* @author: 张无忌
*/
public function edit()
{
$id = input('id');
$item = thisModel::where('id', $id)->find();
if ($this->request->isAjax()) {
$input = input('post.');
$item->save([
'remarks' => $input['remarks'],
'status' => $input['status'],
]);
return JsonServer::success('编辑成功');
}
return view('', [
'detail' => $item,
]);
}
/**
* @NOTES: 删除
* @author: 张无忌
*/
public function del()
{
if ($this->request->isAjax()) {
thisModel::where('id', input('id/d'))->delete();
return JsonServer::success('删除成功');
}
return JsonServer::error('异常');
}
}

View File

@ -0,0 +1,57 @@
{layout name="layout2" /}
<style>
.layui-form-item .layui-input-inline { width: 340px; }
</style>
<div class="layui-card layui-form" style="box-shadow:none;">
<div class="layui-card-body">
<div class="layui-form-item">
<label for="title" class="layui-form-label"><span style="color:red;">*</span>需求名称:</label>
<div class="layui-input-block">
<input type="text" name="name" id="title" lay-verType="tips" lay-verify="required" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label for="content" class="layui-form-label">帮助内容:</label>
<div class="layui-input-block">
<textarea name="content" id="content" lay-verify="content"></textarea>
</div>
</div>
<div class="layui-form-item layui-hide">
<input type="button" lay-submit lay-filter="addSubmit" id="addSubmit" value="确认">
</div>
</div>
</div>
<script>
layui.config({
base: "/static/lib/"
}).extend({
likeedit: "likeedit/likeedit"
}).use(["likeedit", "form"], function(){
var form = layui.form;
var likeedit = layui.likeedit;
var content = likeedit.build("content", {
uploadImage: {
url: '{:url("file/lists")}?type=10'
}
});
form.verify({
content: function() {
likeedit.sync(content)
}
});
like.delUpload();
$(document).on("click", ".add-upload-image", function () {
like.imageUpload({
limit: 1,
field: "image",
that: $(this)
});
});
})
</script>

View File

@ -0,0 +1,57 @@
{layout name="layout2" /}
<style>
.layui-form-item .layui-input-inline { width: 340px; }
</style>
<div class="layui-card layui-form" style="box-shadow:none;">
<div class="layui-card-body">
<div class="layui-form-item">
<label for="title" class="layui-form-label"><span style="color:red;">*</span>需求名称:</label>
<div class="layui-input-block">
<input type="text" name="name" id="title" value="{$detail.name}" lay-verType="tips" lay-verify="required" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label for="content" class="layui-form-label">帮助内容:</label>
<div class="layui-input-block">
<textarea name="content" id="content" lay-verify="content">{$detail.content|raw}</textarea>
</div>
</div>
<div class="layui-form-item layui-hide">
<input type="button" lay-submit lay-filter="addSubmit" id="addSubmit" value="确认">
</div>
</div>
</div>
<script>
layui.config({
base: "/static/lib/"
}).extend({
likeedit: "likeedit/likeedit"
}).use(["likeedit", "form"], function(){
var form = layui.form;
var likeedit = layui.likeedit;
var content = likeedit.build("content", {
uploadImage: {
url: '{:url("file/lists")}?type=10'
}
});
form.verify({
content: function() {
likeedit.sync(content)
}
});
like.delUpload();
$(document).on("click", ".add-upload-image", function () {
like.imageUpload({
limit: 1,
field: "image",
that: $(this)
});
});
})
</script>

View File

@ -0,0 +1,163 @@
{layout name="layout1" /}
<div class="wrapper">
<div class="layui-card">
<!-- 搜索区域 -->
<div class="layui-card-body layui-form">
<div class="layui-form-item">
<div class="layui-inline">
<label for="title" class="layui-form-label">需求名称:</label>
<div class="layui-input-inline">
<input type="text" id="title" name="keyword" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<a class="layui-btn layui-btn-sm layui-btn-normal" lay-submit lay-filter="search">搜索</a>
<a class="layui-btn layui-btn-sm layui-btn-primary" lay-submit lay-filter="clear-search">重置</a>
</div>
</div>
</div>
<!-- 主体区域 -->
<div class="layui-card-body">
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm layEvent" lay-event="add">新增需求</button>
<table id="like-table-lists" lay-filter="like-table-lists"></table>
<script type="text/html" id="table-operation">
<a class="layui-btn layui-btn-info layui-btn-sm" data-id="ss-{{d.id}}" data-href="/admin/content.demandReport/lists?demand_id={{d.id}}" data-title="【{{d.name}}】报名列表" lay-event="report">报名列表</a>
<a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>
</script>
</div>
</div>
</div>
<script>
layui.use(["table", "form"], function(){
var table = layui.table;
var form = layui.form;
like.tableLists("#like-table-lists", "{:url()}", [
{field:"id", title:"ID"}
,{field:"name", align:"center", title:"帮助标题"}
,{field:"create_time", align:"center", title:"创建时间"}
,{title:"操作",align:"center", fixed:"right", toolbar:"#table-operation"}
]);
var active = {
add: function() {
layer.open({
type: 2
,title: "新增需求"
,content: "{:url('content.Demand/add')}"
,area: ["90%", "90%"]
,btn: ["确定", "取消"]
,yes: function(index, layero){
var iframeWindow = window["layui-layer-iframe" + index];
var submit = layero.find("iframe").contents().find("#addSubmit");
iframeWindow.layui.form.on("submit(addSubmit)", function(data){
like.ajax({
url: "{:url('content.Demand/add')}",
data: data.field,
type: "POST",
success:function(res) {
if(res.code === 1) {
layui.layer.msg(res.msg);
layer.close(index);
table.reload("like-table-lists", {
where: {},
page: { cur: 1 }
});
}
}
});
});
submit.trigger("click");
}
});
},
edit: function(obj) {
layer.open({
type: 2
,title: "编辑需求"
,content: "{:url('content.Demand/edit')}?id=" + obj.data.id
,area: ["90%", "90%"]
,btn: ["确定", "取消"]
,yes: function(index, layero){
var iframeWindow = window["layui-layer-iframe" + index];
var submit = layero.find("iframe").contents().find("#addSubmit");
iframeWindow.layui.form.on("submit(addSubmit)", function(data){
data.field['id'] = obj.data.id;
like.ajax({
url: "{:url('content.Demand/edit')}",
data: data.field,
type: "POST",
success:function(res) {
if(res.code === 1) {
layui.layer.msg(res.msg);
layer.close(index);
table.reload("like-table-lists", {
where: {},
page: { cur: 1 }
});
}
}
});
});
submit.trigger("click");
}
});
},
del: function(obj) {
layer.confirm("确定删除需求:"+obj.data.title, function(index) {
like.ajax({
url: "{:url('content.Demand/del')}",
data: {id: obj.data.id},
type: "POST",
success: function (res) {
if (res.code === 1) {
layui.layer.msg(res.msg);
layer.close(index);
obj.del();
}
}
});
layer.close(index);
})
},
report: function (obj) {
let that = $(this);
layer.open({
type: 2
,title: that.data('title')
,content: that.data('href')
,area: ["100%", "100%"]
});
// openTabsPage(that.data('href'), that.data('title'), that.data('id'));
}
};
like.eventClick(active);
form.on("submit(search)", function(data){
table.reload("like-table-lists", {
where: data.field,
page: {
curr: 1
}
});
});
form.on("submit(clear-search)", function(){
$("#title").val("");
form.render("select");
table.reload("like-table-lists", {
where: {},
page: {
curr: 1
}
});
});
})
</script>

View File

@ -0,0 +1,57 @@
{layout name="layout2" /}
<style>
.layui-form-item .layui-input-inline { width: 340px; }
</style>
<div class="layui-card layui-form" style="box-shadow:none;">
<div class="layui-card-body">
<div class="layui-form-item">
<label for="title" class="layui-form-label"><span style="color:red;">*</span>需求名称:</label>
<div class="layui-input-inline">
<input type="text" name="name" id="title" lay-verType="tips" lay-verify="required" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label for="content" class="layui-form-label">帮助内容:</label>
<div class="layui-input-inline">
<textarea name="content" id="content" lay-verify="content"></textarea>
</div>
</div>
<div class="layui-form-item layui-hide">
<input type="button" lay-submit lay-filter="addSubmit" id="addSubmit" value="确认">
</div>
</div>
</div>
<script>
layui.config({
base: "/static/lib/"
}).extend({
likeedit: "likeedit/likeedit"
}).use(["likeedit", "form"], function(){
var form = layui.form;
var likeedit = layui.likeedit;
var content = likeedit.build("content", {
uploadImage: {
url: '{:url("file/lists")}?type=10'
}
});
form.verify({
content: function() {
likeedit.sync(content)
}
});
like.delUpload();
$(document).on("click", ".add-upload-image", function () {
like.imageUpload({
limit: 1,
field: "image",
that: $(this)
});
});
})
</script>

View File

@ -0,0 +1,86 @@
{layout name="layout2" /}
<style>
.layui-form-item .layui-input-inline { width: 340px; }
</style>
<div class="layui-card layui-form" style="box-shadow:none;">
<div class="layui-card-body">
<div class="layui-form-item">
<label class="layui-form-label">姓名:</label>
<div class="layui-input-block">
<input type="text" readonly value="{$detail.name}" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">电话:</label>
<div class="layui-input-block">
<input type="text" readonly value="{$detail.phone}" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">公司:</label>
<div class="layui-input-block">
<input type="text" readonly value="{$detail.company}" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">价格:</label>
<div class="layui-input-block">
<input type="text" readonly value="{$detail.price}" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">状态:</label>
<div class="layui-input-block">
<input type="radio" name="status" value="0" title="待处理" {if $detail.status == 0} checked {/if}>
<input type="radio" name="status" value="1" title="已处理" {if $detail.status == 1} checked {/if}>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">备注:</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="remarks" lay-verify="content">{$detail.remarks}</textarea>
</div>
</div>
<div class="layui-form-item layui-hide">
<input type="button" lay-submit lay-filter="addSubmit" id="addSubmit" value="确认">
</div>
</div>
</div>
<script>
layui.config({
base: "/static/lib/"
}).extend({
likeedit: "likeedit/likeedit"
}).use(["likeedit", "form"], function(){
var form = layui.form;
var likeedit = layui.likeedit;
var content = likeedit.build("content", {
uploadImage: {
url: '{:url("file/lists")}?type=10'
}
});
form.verify({
content: function() {
likeedit.sync(content)
}
});
like.delUpload();
$(document).on("click", ".add-upload-image", function () {
like.imageUpload({
limit: 1,
field: "image",
that: $(this)
});
});
})
</script>

View File

@ -0,0 +1,145 @@
{layout name="layout1" /}
<div class="wrapper">
<div class="layui-card">
<!-- 搜索区域 -->
<div class="layui-card-body layui-form">
<div class="layui-form-item">
<div class="layui-inline">
<label for="title" class="layui-form-label">关键词:</label>
<div class="layui-input-inline">
<input type="text" id="title" name="keyword" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">状态:</label>
<div class="layui-input-inline">
<select name="status" id="status">
<option value="">全部</option>
<option value="1">已处理</option>
<option value="0">待处理</option>
</select>
</div>
</div>
<div class="layui-inline">
<a class="layui-btn layui-btn-sm layui-btn-normal" lay-submit lay-filter="search">搜索</a>
<a class="layui-btn layui-btn-sm layui-btn-primary" lay-submit lay-filter="clear-search">重置</a>
</div>
</div>
</div>
<!-- 主体区域 -->
<div class="layui-card-body">
<table id="like-table-lists" lay-filter="like-table-lists"></table>
<script type="text/html" id="table-operation">
<a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>
</script>
</div>
</div>
</div>
<script type="text/html" id="status-div">
{{# if (d.status == 1) { }}
已处理
{{# } else { }}
待处理
{{# } }}
</script>
<script>
layui.use(["table", "form"], function(){
var table = layui.table;
var form = layui.form;
like.tableLists("#like-table-lists", "{:url()}?demand_id={$demandId}", [
{field:"id", title:"ID"}
,{field:"name", align:"center", title:"姓名"}
,{field:"phone", align:"center", title:"电话"}
,{field:"company", align:"center", title:"公司"}
,{field:"price", align:"center", title:"价格"}
,{field:"status", align:"center", title:"状态", templet: '#status-div'}
,{field:"create_time", align:"center", title:"报名时间"}
,{title:"操作",align:"center", fixed:"right", toolbar:"#table-operation"}
]);
var active = {
edit: function(obj) {
layer.open({
type: 2
,title: "编辑"
,content: "{:url('content.DemandReport/edit')}?id=" + obj.data.id
,area: ["90%", "90%"]
,btn: ["确定", "取消"]
,yes: function(index, layero){
var iframeWindow = window["layui-layer-iframe" + index];
var submit = layero.find("iframe").contents().find("#addSubmit");
iframeWindow.layui.form.on("submit(addSubmit)", function(data){
data.field['id'] = obj.data.id;
like.ajax({
url: "{:url('content.DemandReport/edit')}",
data: data.field,
type: "POST",
success:function(res) {
if(res.code === 1) {
layui.layer.msg(res.msg);
layer.close(index);
table.reload("like-table-lists", {
where: {},
page: { cur: 1 }
});
}
}
});
});
submit.trigger("click");
}
});
},
del: function(obj) {
layer.confirm("确定删除报名:"+obj.data.title, function(index) {
like.ajax({
url: "{:url('content.DemandReport/del')}",
data: {id: obj.data.id},
type: "POST",
success: function (res) {
if (res.code === 1) {
layui.layer.msg(res.msg);
layer.close(index);
obj.del();
}
}
});
layer.close(index);
})
}
};
like.eventClick(active);
form.on("submit(search)", function(data){
table.reload("like-table-lists", {
where: data.field,
page: {
curr: 1
}
});
});
form.on("submit(clear-search)", function(){
$("#title").val("");
form.render("select");
table.reload("like-table-lists", {
where: {},
page: {
curr: 1
}
});
});
})
</script>