You've already forked guangan
Dept
This commit is contained in:
@ -38,7 +38,6 @@ class Category extends Controller
|
||||
public function add()
|
||||
{
|
||||
$this->title = '添加栏目';
|
||||
$this->_applyFormToken();
|
||||
CmsCategory::mForm('form');
|
||||
}
|
||||
|
||||
@ -53,7 +52,6 @@ class Category extends Controller
|
||||
{
|
||||
$this->title = '编辑栏目';
|
||||
$this->id = $this->request->param('id', 0, 'intval'); //当前栏目ID
|
||||
$this->_applyFormToken();
|
||||
CmsCategory::mForm('form');
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ class Service extends Plugin
|
||||
'name' => '工单管理',
|
||||
'subs' => [
|
||||
['name' => '工单分类', 'icon' => 'layui-icon layui-icon-template-1', 'node' => "{$code}/type/index"],
|
||||
['name' => '部门管理', 'icon' => 'layui-icon layui-icon-template-1', 'node' => "{$code}/dept/index"],
|
||||
['name' => '随手拍列表', 'icon' => 'layui-icon layui-icon-template-1', 'node' => "{$code}/user_share/index"],
|
||||
['name' => '工单列表', 'icon' => 'layui-icon layui-icon-template-1', 'node' => "{$code}/ticket/index"],
|
||||
['name' => '内部工单列表', 'icon' => 'layui-icon layui-icon-template-1', 'node' => "{$code}/ticket_inter/index"],
|
||||
|
47
plugs/think-plugs-ticket/src/controller/Dept.php
Normal file
47
plugs/think-plugs-ticket/src/controller/Dept.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\ticket\controller;
|
||||
|
||||
use plugin\ticket\model\TicketDept;
|
||||
use think\admin\Controller;
|
||||
use think\admin\helper\QueryHelper;
|
||||
|
||||
class Dept extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$this->title = '部门管理';
|
||||
TicketDept::mQuery()->layTable(function () {
|
||||
|
||||
}, function (QueryHelper $query) {
|
||||
$query->like('name')->equal('status');
|
||||
});
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
$this->title = '添加部门';
|
||||
TicketDept::mForm('form');
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
$this->title = '编辑部门';
|
||||
TicketDept::mForm('form');
|
||||
}
|
||||
|
||||
public function remove()
|
||||
{
|
||||
$this->_applyFormToken();
|
||||
TicketDept::mDelete('id');
|
||||
}
|
||||
|
||||
public function status()
|
||||
{
|
||||
TicketDept::mSave($this->_vali([
|
||||
'id.require' => '部门ID不能为空',
|
||||
'status.in:0,1' => '状态值范围异常!',
|
||||
'status.require' => '状态值不能为空!',
|
||||
]), 'id');
|
||||
}
|
||||
}
|
10
plugs/think-plugs-ticket/src/model/TicketDept.php
Normal file
10
plugs/think-plugs-ticket/src/model/TicketDept.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\ticket\model;
|
||||
|
||||
use think\admin\Model;
|
||||
|
||||
class TicketDept extends Model
|
||||
{
|
||||
|
||||
}
|
@ -69,6 +69,16 @@ class TicketTicket extends Model
|
||||
}
|
||||
}
|
||||
|
||||
public function getDeptNameAttr($value, $data)
|
||||
{
|
||||
$dept = $this->dept()->find();
|
||||
if (!empty($dept)) {
|
||||
return $dept['name'];
|
||||
} else {
|
||||
return '未知';
|
||||
}
|
||||
}
|
||||
|
||||
private function getStatusList()
|
||||
{
|
||||
return [
|
||||
@ -88,6 +98,11 @@ class TicketTicket extends Model
|
||||
return $this->hasMany(TicketUserShare::class, 'linked_ticket_id');
|
||||
}
|
||||
|
||||
public function dept()
|
||||
{
|
||||
return $this->belongsTo(TicketDept::class, 'dept_id');
|
||||
}
|
||||
|
||||
public function scopeUnConf($query)
|
||||
{
|
||||
return $query->where('state', '=', '0');
|
||||
|
@ -4,7 +4,7 @@ namespace plugin\ticket\model;
|
||||
|
||||
class TicketTicketInter extends TicketTicket
|
||||
{
|
||||
protected $append = ['status_text', 'type_name'];
|
||||
protected $append = ['status_text', 'type_name', 'dept_name'];
|
||||
protected $globalScope = ['inter'];
|
||||
protected $table = 'ticket_ticket';
|
||||
public function type()
|
||||
|
@ -4,7 +4,7 @@ namespace plugin\ticket\model;
|
||||
|
||||
class TicketTicketOuter extends TicketTicket
|
||||
{
|
||||
protected $append = ['status_text', 'type_name'];
|
||||
protected $append = ['status_text', 'type_name', 'dept_name'];
|
||||
protected $globalScope = ['outer'];
|
||||
protected $table = 'ticket_ticket';
|
||||
public function type()
|
||||
|
33
plugs/think-plugs-ticket/src/view/dept/form.html
Normal file
33
plugs/think-plugs-ticket/src/view/dept/form.html
Normal file
@ -0,0 +1,33 @@
|
||||
<form class="layui-form layui-card" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-row layui-col-space15">
|
||||
<!--<div class="layui-form-item">
|
||||
<label class="layui-form-label label-required-next">所属分类</label>
|
||||
<div class="layui-input-block">
|
||||
<select class="layui-input" name="pid" required>
|
||||
<option value="0">作为一级分类</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>-->
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">部门名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="name" value='{$vo.name|default=""}' required placeholder="请输入部门名称" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
{notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
|
||||
<div class="layui-form-item text-center">
|
||||
<button class="layui-btn layui-btn-normal" type='submit'>保存数据</button>
|
||||
<button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗?" data-close>取消编辑</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
<script>
|
||||
</script>
|
82
plugs/think-plugs-ticket/src/view/dept/index.html
Normal file
82
plugs/think-plugs-ticket/src/view/dept/index.html
Normal file
@ -0,0 +1,82 @@
|
||||
{extend name="table"}
|
||||
|
||||
{block name="button"}
|
||||
<!--{if auth("add")}-->
|
||||
<button data-modal='{:url("add")}' data-title="添加部门" class='layui-btn layui-btn-sm layui-btn-primary'>添加部门</button>
|
||||
<!--{/if}-->
|
||||
{/block}
|
||||
|
||||
{block name="content"}
|
||||
<div class="layui-tab layui-tab-card think-bg-white">
|
||||
<div class="layui-tab-content think-box-shadow">
|
||||
{include file='dept/index_search'}
|
||||
<table class="layui-table margin-top-10" data-url="{$request->url()}" data-target-search="form.form-search" lay-skin="line" id="deptTable"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="toolbar">
|
||||
|
||||
<!--{if auth("edit")}-->
|
||||
<a data-modal="{:url('edit')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-normal" title="修改">修改</a>
|
||||
<!--{/if}-->
|
||||
|
||||
<!--{if auth("status")}-->
|
||||
{{# if(d.status == 0){ }}
|
||||
<a class="layui-btn layui-btn-xs layui-btn-normal" data-title="显示部门" data-modal='{:url("status")}?id={{ d.id }}&status=1'>显 示</a>
|
||||
{{# } else { }}
|
||||
<a class="layui-btn layui-btn-xs layui-btn-primary" data-title="隐藏部门" data-modal='{:url("status")}?id={{ d.id }}&status=0'>隐 藏</a>
|
||||
{{# } }}
|
||||
<!--{/if}-->
|
||||
|
||||
<!--{if auth("remove")}-->
|
||||
<a data-confirm="确定要永久删除此部门吗?" data-action="{:url('remove')}" data-value="id#{{ d.id }}" data-csrf="{:systoken('remove')}" class="layui-btn layui-btn-xs layui-btn-danger" title="删除">删除</a>
|
||||
<!--{/if}-->
|
||||
</script>
|
||||
{/block}
|
||||
|
||||
{block name='style'}
|
||||
<style>
|
||||
</style>
|
||||
{/block}
|
||||
|
||||
{block name='script'}
|
||||
<script>
|
||||
$(function () {
|
||||
$('#deptTable').layTable({
|
||||
height: 'full-240',
|
||||
toolbar: true,
|
||||
sort: {field: 'sort', type: 'asc'},
|
||||
cols: [[
|
||||
{type: 'numbers'},
|
||||
{field: 'sort', title: '排序', width: 80, sort: true, edit: 'text'},
|
||||
{field: 'name', title: '部门名称', minWidth: 165},
|
||||
{field: 'status', title: '状态', width: 60,templet:function(item){
|
||||
if(item.status == 0){
|
||||
return '<span style="color:red;">隐藏</span>';
|
||||
}else if(item.status == 1){
|
||||
return '<span style="color:green;">显示</span>';
|
||||
}
|
||||
}},
|
||||
{field: 'create_at', title: '创建时间', width: 150},
|
||||
{align: 'center', toolbar: '#toolbar', title: '操作', width: 240}
|
||||
]]
|
||||
})
|
||||
layui.use(['table'], function(){
|
||||
var table = layui.table,
|
||||
layer = layui.layer;
|
||||
table.on('edit(deptTable)', function(obj) {
|
||||
if (obj.field == 'sort') {
|
||||
if (obj.value == '') {
|
||||
obj.value = obj.oldValue
|
||||
return false;
|
||||
} else {
|
||||
$.form.load("{:url('sort')}", {sort: obj.value, id: obj.data.id}, 'post', function (ret) {
|
||||
$('#deptTable').trigger('reload');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
})
|
||||
</script>
|
||||
{/block}
|
16
plugs/think-plugs-ticket/src/view/dept/index_search.html
Normal file
16
plugs/think-plugs-ticket/src/view/dept/index_search.html
Normal file
@ -0,0 +1,16 @@
|
||||
<fieldset>
|
||||
<legend>条件搜索</legend>
|
||||
<form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
|
||||
<div class="layui-form-item layui-inline">
|
||||
<label class="layui-form-label">部门名称</label>
|
||||
<div class="layui-input-inline">
|
||||
<input name="name" value="{:input('get.name')}" placeholder="请输入分类名称" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-inline">
|
||||
<button class="layui-btn layui-btn-primary" lay-submit lay-filter="searchData"><i class="layui-icon"></i> 搜 索</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</fieldset>
|
Reference in New Issue
Block a user