1、优化知识评论展示,取消编辑器模式评论。

2、新增工作汇报点评功能,接收人可以点评某工作汇报,汇报人可查看点评
3、合同api接口新增合同编码,客户名称字段展现
This commit is contained in:
hdm 2023-05-21 10:57:56 +08:00
parent fc81cf6f45
commit 18b2d60920
10 changed files with 266 additions and 75 deletions
app
article/view/index
contract/controller
install/data
oa
public

@ -22,11 +22,13 @@
.text-detial-content li {list-style: initial;margin-left: 20px;}
:not(pre)>code[class*=language-], pre[class*=language-]{background:#fff!important;border:1px solid #e8e8e8!important; border-radius:3px;}
.comment-box{border-top:1px solid #eee; background-color:#fff;width:100%; overflow:hidden}
.comment-name{font-size:16px; margin-bottom:8px;}
.comment-img{width:100px; height:100px; padding:3px; background-color:#fff;}
.comment-img img{border-radius:3px;}
.comment-tips{line-height:25px; color:#999;font-size:12px;}
.comment-input .comment-image{width:40px; height:40px; border-radius:50%}
.comment-item .comment-avatar{width:50px; float:left}
.comment-item .comment-image{width:36px; height:36px; border-radius:50%}
.comment-item .comment-body{margin-left:50px;}
.comment-item .comment-content blockquote{border-left:3px solid #f1f1f1; padding:4px 8px;}
.comment-item .comment-actions a{color:#8c95a8; cursor:pointer; font-size:12px;}
.comment-item .comment-actions a:hover{color:#3582fb;}
</style>
{/block}
<!-- 主体 -->
@ -54,22 +56,29 @@
<div class="px-4" id="commentBox">
<h3 class="py-3">相关评论</h3>
{volist name="$detail.comment" id="vo"}
<div class="comment-box py-3">
<div style="float:left;">
<p class="comment-name">{$vo.name}</p>
<img src="{$vo.thumb}" alt="{vo.name}" class="comment-img">
</div>
<div style="margin-left:128px;">
<p class="comment-tips">发表于:{$vo.create_time}{$vo.update_time} {eq name="$vo.admin_id" value="$login_admin"} <button class="layui-btn layui-btn-xs layui-btn-danger layui-del" data-cid="{$vo.id}">删除</button>{/eq}</p>
<div class="py-2">{$vo.content|raw}</div>
<div class="pt-3">
<div class="comment-item py-3 border-t">
<div class="comment-avatar" title="{vo.name}">
<img src="{$vo.thumb}" alt="{vo.name}" class="comment-image">
</div>
<div class="comment-body">
<div class="comment-meta">
<strong class="comment-name">{$vo.name}</strong><span class="ml-2 gray">{$vo.create_time}{$vo.update_time}</span>
{eq name="$vo.admin_id" value="$login_admin.id"}
<button class="layui-btn layui-btn-xs layui-btn-danger layui-del" data-cid="{$vo.id}">删除</button>
{/eq}
</div>
<div class="comment-content py-2">{$vo.content}</div>
</div>
</div>
</div>
{/volist}
{/volist}
<form class="layui-form">
<textarea name="content" placeholder="请输入内容" class="layui-textarea" id="container" style="border:0;padding:0"></textarea>
<textarea name="content" placeholder="请输入内容" class="layui-textarea" id="container"></textarea>
<input type="hidden" name="article_id" value="{$detail.id}">
<div class="py-3">
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">评论回复</button>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交评论</button>
</div>
</form>
</div>
@ -80,23 +89,11 @@
{block name="script"}
<script src="{__GOUGU__}/third_party/prism/prism.js"></script>
<script>
const moduleInit = ['tool','tinymce','oaTool'];
const moduleInit = ['tool','oaTool'];
function gouguInit() {
var form = layui.form,tool=layui.tool;
//编辑器初始化
var editor = layui.tinymce;
var edit = editor.render({
menubar:false,
toolbar: 'code undo redo removeformat | alignleft aligncenter alignright alignjustify outdent indent | bullist numlist link image',
selector: "#container",
images_upload_url: '/api/index/upload/sourse/tinymce',//图片上传接口
height: 200
});
var form = layui.form,tool=layui.tool;
//监听提交
form.on('submit(webform)', function (data) {
data.field.content = tinyMCE.editors['container'].getContent();
if (data.field.content == '') {
layer.msg('请先输入评论内容');
return false;

@ -37,7 +37,7 @@ class Api extends BaseController
}
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
$list = Db::name('Contract')
->field('id,name,customer_id,sign_uid,sign_time')
->field('id,name,code,customer_id,sign_uid,sign_time')
->order('id desc')
->where($where)
->where(function ($query) use($whereOr) {
@ -46,6 +46,7 @@ class Api extends BaseController
->paginate($rows, false)->each(function($item, $key){
$item['sign_name'] = Db::name('Admin')->where('id',$item['sign_uid'])->value('name');
$item['sign_time'] = date('Y-m-d', $item['sign_time']);
$item['customer'] = Db::name('Customer')->where('id',$item['customer_id'])->value('name');
return $item;
});
table_assign(0, '', $list);

@ -1302,6 +1302,21 @@ CREATE TABLE `oa_work_record` (
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '汇报工作发送记录表';
-- ----------------------------
-- Table structure for oa_work_comment
-- ----------------------------
DROP TABLE IF EXISTS `oa_work_comment`;
CREATE TABLE `oa_work_comment` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`work_id` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '工作汇报id',
`admin_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建人',
`content` text NULL COMMENT '点评内容',
`create_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '添加时间',
`update_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '修改时间',
`delete_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '工作汇报点评表';
-- ----------------------------
-- Table structure for oa_customer_grade
-- ----------------------------

66
app/oa/controller/Api.php Normal file

@ -0,0 +1,66 @@
<?php
/**
* @copyright Copyright (c) 2022 勾股工作室
* @license https://opensource.org/licenses/GPL-3.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\oa\controller;
use app\api\BaseController;
use app\oa\model\WorkComment;
use think\facade\Db;
use think\facade\View;
class Api extends BaseController
{
//获取评论列表
public function work_comment()
{
$param = get_params();
$list = new WorkComment();
$content = $list->get_list($param);
return to_assign(0, '', $content);
}
//添加修改评论内容
public function add_comment()
{
$param = get_params();
if (!empty($param['id']) && $param['id'] > 0) {
$param['update_time'] = time();
unset($param['pid']);
unset($param['padmin_id']);
$res = WorkComment::where(['admin_id' => $this->uid,'id'=>$param['id']])->strict(false)->field(true)->update($param);
if ($res) {
add_log('edit', $param['id'], $param,'评论');
return to_assign();
}
} else {
$param['create_time'] = time();
$param['admin_id'] = $this->uid;
$cid = WorkComment::strict(false)->field(true)->insertGetId($param);
if ($cid) {
add_log('add', $cid, $param,'评论');
return to_assign();
}
}
}
//删除评论内容
public function delete_comment()
{
if (request()->isDelete()) {
$id = get_params("id");
$res = WorkComment::where('id',$id)->strict(false)->field(true)->update(['delete_time'=>time()]);
if ($res) {
add_log('delete', $id,[],'评论');
return to_assign(0, "删除成功");
} else {
return to_assign(1, "删除失败");
}
}else{
return to_assign(1, "错误的请求");
}
}
}

@ -208,6 +208,29 @@ class Work extends BaseController
if($detail['update_time']>0){
$detail['update_time_str'] = date('Y-m-d H:i:s',$detail['update_time']);
}
$comment = Db::name('WorkComment')
->field('a.*,u.name,u.thumb')
->alias('a')
->join('Admin u', 'u.id = a.admin_id')
->order('a.create_time desc')
->where(['a.work_id'=>$detail['id'],'a.delete_time' => 0])
->select()->toArray();
foreach ($comment as $k => &$v) {
$v['times'] = time_trans($v['create_time']);
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
if($v['update_time']>0){
$v['update_time'] = ',最后编辑时间:'.time_trans($v['update_time']);
}
else{
$v['update_time'] = '';
}
}
$detail['comment_auth'] = 0;
$type_user_array = explode(",", $detail['type_user']);
if (in_array($this->uid, $type_user_array)) {
$detail['comment_auth'] = 1;
}
$detail['comment'] = $comment;
View::assign('detail', $detail);
return view();
}

@ -0,0 +1,40 @@
<?php
/**
* @copyright Copyright (c) 2022 勾股工作室
* @license https://opensource.org/licenses/GPL-3.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\oa\model;
use think\Model;
class WorkComment extends Model
{
public function get_list($param = [])
{
$where = array();
$where['a.article_id'] = $param['tid'];
$where['a.delete_time'] = 0;
$content = \think\facade\Db::name('WorkComment')
->field('a.*,u.name,u.thumb,pu.name as pname')
->alias('a')
->join('Admin u', 'u.id = a.admin_id')
->leftjoin('Admin pu', 'pu.id = a.padmin_id')
->order('a.create_time desc')
->where($where)
->select()->toArray();
foreach ($content as $k => &$v) {
$v['times'] = time_trans($v['create_time']);
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
if($v['update_time']>0){
$v['update_time'] = ',最后编辑时间:'.time_trans($v['update_time']);
}
else{
$v['update_time'] = '';
}
}
return $content;
}
}

@ -155,9 +155,9 @@
<!-- 脚本 -->
{block name="script"}
<script>
const moduleInit = ['tool','formSelects','employeepicker','oaTool'];
const moduleInit = ['tool','employeepicker','oaTool'];
function gouguInit() {
var form = layui.form,tool=layui.tool, table = layui.table, employeepicker = layui.employeepicker, oaTool = layui.oaTool;
var form = layui.form,tool=layui.tool, oaTool = layui.oaTool;
oaTool.addFile({
btn: 'upFile',
box: 'fileList'
@ -202,42 +202,6 @@ const moduleInit = ['tool','formSelects','employeepicker','oaTool'];
return false;
});
upload.render({ //允许上传的文件后缀
elem: '#testList'
,url: '/api/index/upload' //此处配置你自己的上传接口即可
,accept: 'file' //普通文件
,exts: 'jpeg|jpg|png|gif|doc|docx|ppt|pptx|xls|xlsx|pdf|zip|rar|7z' //只允许上传文件
,before: function(obj){ //obj参数包含的信息跟 choose回调完全一致可参见上文。
layer.msg('上传中...',{time: 3600000});
}
,done: function(res, index, upload){
layer.msg(res.msg);
if(res.code==0){
var timestamp=new Date().getTime();
var tr = '<tr data-id="'+res.data.id+'" id="tr_'+timestamp+'">\
<td>'+ res.data.name +'</td>\
<td align="center">'+ (res.data.filesize/(1024*1024)).toFixed(2) +'MB</td>\
<td align="center">\
<span class="layui-btn layui-btn-xs layui-btn-danger demo-delete" data-id="'+timestamp+'">删除</span>\
</td>\
</tr>';
$('.layui-upload-list').show();
$('#demoList').append(tr);
}
}
,error: function(index, upload){
layer.msg('上传失败');
}
});
$('#demoList').on('click','.demo-delete',function(){
let id = $(this).data('id');
layer.confirm('确定要删除该附件吗?', {icon: 3, title:'提示'}, function(index){
$('#tr_'+id).remove()
layer.close(index);
});
})
}
</script>
{/block}

@ -100,7 +100,7 @@
//日期范围
laydate.render({
elem: '#date',
range: ['#start_time', '#end_time'].
range: ['#start_time', '#end_time'],
rangeLinked:true
});

@ -1,7 +1,19 @@
{extend name="../../base/view/common/base" /}
{block name="style"}
<style>
.comment-input .comment-image{width:40px; height:40px; border-radius:50%}
.comment-item .comment-avatar{width:50px; float:left}
.comment-item .comment-image{width:36px; height:36px; border-radius:50%}
.comment-item .comment-body{margin-left:50px;}
.comment-item .comment-content blockquote{border-left:3px solid #f1f1f1; padding:4px 8px;}
.comment-item .comment-actions a{color:#8c95a8; cursor:pointer; font-size:12px;}
.comment-item .comment-actions a:hover{color:#3582fb;}
.comment-meta span{font-size:12px;}
</style>
{/block}
{block name="body"}
<form class="layui-form p-4">
<h3 class="pb-3">汇报详情</h3>
<div class="p-4">
<h3 class="pb-1">汇报详情</h3>
<table class="layui-table">
<tr>
<td class="layui-td-gray">汇报人</td>
@ -55,12 +67,85 @@
{gt name="$detail.update_time" value="0"}
<div style="color:#999; padding:10px 0">该汇报于 {$detail.update_time_str} 进行过编辑</div>
{/gt}
</form>
<div class="pt-1" id="commentBox">
<h3 class="pb-1">工作点评</h3>
{empty name="$detail.comment"}
<div class="layui-data-none">暂无工作点评</div>
{/empty}
{volist name="$detail.comment" id="vo"}
<div class="mt-3 bg-white">
<div class="comment-item p-3 border">
<div class="comment-avatar" title="{vo.name}">
<img src="{$vo.thumb}" alt="{vo.name}" class="comment-image">
</div>
<div class="comment-body">
<div class="comment-meta">
<strong class="comment-name">{$vo.name}</strong><span class="ml-2 gray">{$vo.create_time}{$vo.update_time}</span>
{eq name="$vo.admin_id" value="$login_admin.id"}
<button class="layui-btn layui-btn-xs layui-btn-danger layui-del" data-cid="{$vo.id}">删除</button>
{/eq}
</div>
<div class="comment-content pt-2">{$vo.content}</div>
</div>
</div>
</div>
{/volist}
{eq name="$detail.comment_auth" value="1"}
<form class="layui-form mt-3">
<textarea name="content" placeholder="请输入内容" class="layui-textarea" id="container"></textarea>
<input type="hidden" name="work_id" value="{$detail.id}">
<div class="py-3">
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交点评</button>
</div>
</form>
{/eq}
</div>
</div>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
const moduleInit = ['tool','formSelects','employeepicker','oaTool'];
const moduleInit = ['tool','oaTool'];
function gouguInit() {
var form = layui.form,tool=layui.tool;
//监听提交
form.on('submit(webform)', function (data) {
if (data.field.content == '') {
layer.msg('请先输入点评内容');
return false;
}
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
setTimeout(function () {
location.reload();
}, 1000)
}
}
tool.post("/oa/api/add_comment", data.field, callback);
return false;
});
$('#commentBox').on('click','.layui-del', function () {
let cid =$(this).data('cid');
layer.confirm('确定要删除该评论吗?', { icon: 3, title: '提示' }, function (index) {
let callback = function (e) {
layer.closeAll();
layer.msg(e.msg);
if(e.code==0){
setTimeout(function () {
location.reload();
}, 1000)
}
}
let postData = { "id": cid };
tool.delete("/oa/api/delete_comment", postData, callback);
});
})
}
</script>
</script>
{/block}

@ -18,7 +18,7 @@ require __DIR__ . '/../vendor/autoload.php';
define('CMS_VERSION','4.50.05');
// 定义Layui版本号
define('LAYUI_VERSION','2.8.2');
define('LAYUI_VERSION','2.8.3');
// 定义项目目录
define('CMS_ROOT', __DIR__ . '/../');