From 598424b2c549a74ffea69768a4c9a0011d651c69 Mon Sep 17 00:00:00 2001 From: zhuyu Date: Wed, 21 May 2025 15:56:00 +0800 Subject: [PATCH 1/8] feature: kpi item template --- application/admin/controller/kpi/Template.php | 19 +++++++++++++++++++ application/admin/lang/zh-cn/kpi/template.php | 1 + application/admin/view/kpi/template/add.html | 6 ++++++ application/admin/view/kpi/template/edit.html | 6 ++++++ public/assets/js/backend/kpi/template.js | 1 + 5 files changed, 33 insertions(+) diff --git a/application/admin/controller/kpi/Template.php b/application/admin/controller/kpi/Template.php index e549e39..92140c0 100644 --- a/application/admin/controller/kpi/Template.php +++ b/application/admin/controller/kpi/Template.php @@ -136,7 +136,12 @@ class Template extends Backend $templateItem = []; $kpiItems = json_decode($params['kpiitem'], true); + $kpiItemIds = array_column($kpiItems, 'id'); + if (count($kpiItemIds) !== count(array_unique($kpiItemIds))) { + throw new Exception('指标有重复项'); + } + $rateAll = 0; foreach ($kpiItems as $kpiItem) { $templateItem[] = [ 'admin_id' => $this->auth->id, @@ -144,6 +149,10 @@ class Template extends Backend 'item_id' => $kpiItem['id'], 'rate' => $kpiItem['rate'], ]; + $rateAll += $kpiItem['rate']; + } + if ($rateAll != 100) { + throw new Exception('指标权重总和必须为100'); } Db::name('kpi_template_item') @@ -216,7 +225,12 @@ class Template extends Backend $templateItem = []; $kpiItems = json_decode($params['kpiitem'], true); + $kpiItemIds = array_column($kpiItems, 'id'); + if (count($kpiItemIds) !== count(array_unique($kpiItemIds))) { + throw new Exception('指标有重复项'); + } + $rateAll = 0; foreach ($kpiItems as $kpiItem) { $templateItem[] = [ 'admin_id' => $this->auth->id, @@ -224,6 +238,11 @@ class Template extends Backend 'item_id' => $kpiItem['id'], 'rate' => $kpiItem['rate'], ]; + $rateAll += $kpiItem['rate']; + } + + if ($rateAll != 100) { + throw new Exception('指标权重总和必须为100'); } Db::name('kpi_template_item') diff --git a/application/admin/lang/zh-cn/kpi/template.php b/application/admin/lang/zh-cn/kpi/template.php index 5328a56..f0f20ce 100644 --- a/application/admin/lang/zh-cn/kpi/template.php +++ b/application/admin/lang/zh-cn/kpi/template.php @@ -8,6 +8,7 @@ return [ 'Name' => '名称', 'Desc' => '描述', 'Score' => '单个绩点分', + 'Max_score' => '最高得分上限', 'Create_time' => '创建时间', 'Update_time' => '编辑时间' ]; diff --git a/application/admin/view/kpi/template/add.html b/application/admin/view/kpi/template/add.html index b280ca6..6e6dbd3 100644 --- a/application/admin/view/kpi/template/add.html +++ b/application/admin/view/kpi/template/add.html @@ -24,6 +24,12 @@ +
+ +
+ +
+
diff --git a/application/admin/view/kpi/template/edit.html b/application/admin/view/kpi/template/edit.html index 60f6585..647c897 100644 --- a/application/admin/view/kpi/template/edit.html +++ b/application/admin/view/kpi/template/edit.html @@ -24,6 +24,12 @@ +
+ +
+ +
+
diff --git a/public/assets/js/backend/kpi/template.js b/public/assets/js/backend/kpi/template.js index 0077dc3..264149a 100644 --- a/public/assets/js/backend/kpi/template.js +++ b/public/assets/js/backend/kpi/template.js @@ -42,6 +42,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin } }, {field: 'score', title: __('Score')}, + {field: 'max_score', title: __('Max_score')}, {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} From 905e6091cac7d536b09341161242bf6ded9dd0c7 Mon Sep 17 00:00:00 2001 From: zhuyu Date: Wed, 21 May 2025 16:40:32 +0800 Subject: [PATCH 2/8] feature: kpi item template --- application/admin/controller/oa/Doc.php | 23 +++++++++++++++++++++++ application/admin/view/oa/doc/add.html | 9 ++++----- application/admin/view/oa/doc/detail.html | 23 +++++++++++++++++++++++ application/admin/view/oa/doc/edit.html | 9 ++++----- public/assets/js/backend/oa/doc.js | 12 +++++++++++- 5 files changed, 65 insertions(+), 11 deletions(-) create mode 100644 application/admin/view/oa/doc/detail.html diff --git a/application/admin/controller/oa/Doc.php b/application/admin/controller/oa/Doc.php index 3329cd2..282e9f8 100644 --- a/application/admin/controller/oa/Doc.php +++ b/application/admin/controller/oa/Doc.php @@ -88,11 +88,34 @@ class Doc extends Backend ->whereRaw('JSON_OVERLAPS(group_ids, ?)', [json_encode($this->auth->getChildrenGroupIds(true))]) ->order($sort, $order) ->paginate($limit); + + foreach ($list as $k => $row) { + $list[$k]['url'] = cdnurl($row['path']); + } + $result = ['total' => $list->total(), 'rows' => $list->items()]; return json($result); } + public function detail($ids) + { + $row = $this->model->get(['id' => $ids]); + if (!$row) { + $this->error(__('No Results were found')); + } + if ($this->request->isAjax()) { + $this->success("Ajax请求成功", null, ['id' => $ids]); + } + + $row['url'] = cdnurl($row['path']); + + + $this->view->assign("row", $row->toArray()); + return $this->view->fetch(); + } + + /** * 添加 * diff --git a/application/admin/view/oa/doc/add.html b/application/admin/view/oa/doc/add.html index d412acf..63af6ea 100644 --- a/application/admin/view/oa/doc/add.html +++ b/application/admin/view/oa/doc/add.html @@ -33,16 +33,15 @@
-
+
- +
- - + +
-
    -
    +
    - +
    - - + +
    -
      + + + + + + + + + + + {foreach $kpi_items as $key => $item} + + + + + + + + {/foreach} + +
      指标名称目标值目标值(单位)指标描述权重
      {$item->name|htmlentities}{$item->target_value|htmlentities}{$item->unit_text|htmlentities}{$item->desc|htmlentities}{$item->pivot->rate|htmlentities}
      + +
      +
      diff --git a/application/admin/view/dashboard/task.html b/application/admin/view/dashboard/task.html index c3fe518..2133620 100644 --- a/application/admin/view/dashboard/task.html +++ b/application/admin/view/dashboard/task.html @@ -1,14 +1,83 @@ -
      -
      - 每日任务 -
      -
      - 每周任务 -
      -
      - 每月任务 + +
      +

      任务看板

      +
      +
      +
      +
      +

      每日任务

      + {foreach $day as $item} +

      {$item->title}

      +

      {$item->desc}

      +
      + {/foreach} +
      +
      +

      每周任务

      + {foreach $week as $item} +

      {$item->title}

      +

      {$item->desc}

      +
      + {/foreach} +
      + +
      +

      每月任务

      + {foreach $month as $item} +

      {$item->title}

      +

      {$item->desc}

      +
      + {/foreach} +
      From 8fb4af1b47381498b06e2e800c7b4dfbcfa32db3 Mon Sep 17 00:00:00 2001 From: zhuyu Date: Thu, 22 May 2025 17:53:46 +0800 Subject: [PATCH 7/8] =?UTF-8?q?feature:=20=E9=9D=A2=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Dashboard.php | 23 +++ application/admin/view/dashboard/task.html | 147 +++++++++++------- .../admin/view/dashboard/task_complete.html | 38 +++++ public/assets/js/backend/dashboard.js | 32 +++- 4 files changed, 181 insertions(+), 59 deletions(-) create mode 100644 application/admin/view/dashboard/task_complete.html diff --git a/application/admin/controller/Dashboard.php b/application/admin/controller/Dashboard.php index e206a7c..ffd2a71 100755 --- a/application/admin/controller/Dashboard.php +++ b/application/admin/controller/Dashboard.php @@ -152,5 +152,28 @@ class Dashboard extends Backend return $this->view->fetch(); } + public function task_complete($ids = null) + { + + $row = (new Task())->get($ids); + if (!$row) { + $this->error(__('No Results were found')); + } + if (false === $this->request->isPost()) { + $this->view->assign('row', $row); + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + + $task = (new Task())->where('id', '=', $ids)->where('status', 1)->find(); + + if (!$task) { + $this->error('任务状态已变更,请刷新后操作'); + } + $task->save(['status' => 3, 'prove_file_path' => $params['prove_file_path']]); + + $this->success(); + } + } diff --git a/application/admin/view/dashboard/task.html b/application/admin/view/dashboard/task.html index 2133620..41816a9 100644 --- a/application/admin/view/dashboard/task.html +++ b/application/admin/view/dashboard/task.html @@ -1,83 +1,114 @@

      任务看板

      -
      -
      -
      -

      每日任务

      - {foreach $day as $item} -

      {$item->title}

      -

      {$item->desc}

      -
      - {/foreach} -
      -
      -

      每周任务

      - {foreach $week as $item} -

      {$item->title}

      -

      {$item->desc}

      -
      - {/foreach} -
      -
      -

      每月任务

      - {foreach $month as $item} -

      {$item->title}

      -

      {$item->desc}

      -
      - {/foreach} + +
      + + +
      +

      每日任务

      + {foreach $day as $item} +
      +
      {$item->title}
      +
      {$item->desc}
      + {/foreach}
      + + +
      +

      每周任务

      + {foreach $week as $item} +
      +
      {$item->title}
      +
      {$item->desc}
      +
      + {/foreach} +
      + + +
      +

      每月任务

      + {foreach $month as $item} +
      +
      {$item->title}
      +
      {$item->desc}
      +
      + {/foreach} +
      +
      diff --git a/application/admin/view/dashboard/task_complete.html b/application/admin/view/dashboard/task_complete.html new file mode 100644 index 0000000..7030a3b --- /dev/null +++ b/application/admin/view/dashboard/task_complete.html @@ -0,0 +1,38 @@ +
      + +

      任务详情

      +
      + +
      + {$row->title|htmlentities} +
      +
      +
      + +
      + {$row->desc|htmlentities} +
      +
      + +
      + +
      +
      + +
      + + +
      + +
      +
      +
      + + +
      + diff --git a/public/assets/js/backend/dashboard.js b/public/assets/js/backend/dashboard.js index ab8409c..532506d 100755 --- a/public/assets/js/backend/dashboard.js +++ b/public/assets/js/backend/dashboard.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echarts-theme', 'template'], function ($, undefined, Backend, Datatable, Table, Echarts, undefined, Template) { +define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echarts-theme', 'template', 'form'], function ($, undefined, Backend, Datatable, Table, Echarts, undefined, Template, Form) { var Controller = { index: function () { @@ -73,6 +73,36 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echart }, 0); }); + }, + task: function () { + + $(document).on('click','.spec_add_btn', function (event) { + var url = $(this).attr('data-url'); + if(!url) return false; + var msg = $(this).attr('data-title'); + var width = $(this).attr('data-width'); + var height = $(this).attr('data-height'); + var area = [$(window).width() > 800 ? (width?width:'800px') : '95%', $(window).height() > 600 ? (height?height:'600px') : '95%']; + var options = { + shadeClose: false, + shade: [0.3, '#393D49'], + area: area, + callback:function(value){ + CallBackFun(value.id, value.name);//在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果 + } + }; + Fast.api.open(url,msg,options); + }); + + }, + task_complete: function () { + Form.api.bindevent($("form[role=form]"), function(data, ret){ + //这里是表单提交处理成功后的回调函数,接收来自php的返回数据 + Fast.api.close(data);//这里是重点 + Toastr.success("成功");//这个可有可无 + }, function(data, ret){ + Toastr.success("失败"); + }); } }; From 73700581bfd0126886ebb95eff84d617ccd54495 Mon Sep 17 00:00:00 2001 From: zhuyu Date: Thu, 22 May 2025 17:55:28 +0800 Subject: [PATCH 8/8] =?UTF-8?q?feature:=20=E9=9D=A2=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/lang/zh-cn/kpi/item.php | 2 ++ application/admin/model/kpi/Item.php | 2 +- public/assets/js/backend/kpi/item.js | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/application/admin/lang/zh-cn/kpi/item.php b/application/admin/lang/zh-cn/kpi/item.php index 5a064e6..c03ad8b 100644 --- a/application/admin/lang/zh-cn/kpi/item.php +++ b/application/admin/lang/zh-cn/kpi/item.php @@ -13,6 +13,8 @@ return [ 'Unit 1' => '%', 'Unit 2' => '元', 'Unit 3' => '单', + 'Unit 4' => '个', + 'Unit 5' => '小时', 'Create_time' => '创建时间', 'Update_time' => '编辑时间' ]; diff --git a/application/admin/model/kpi/Item.php b/application/admin/model/kpi/Item.php index 0738070..3c21c4c 100644 --- a/application/admin/model/kpi/Item.php +++ b/application/admin/model/kpi/Item.php @@ -33,7 +33,7 @@ class Item extends Model public function getUnitList() { - return ['1' => __('Unit 1'), '2' => __('Unit 2'), '3' => __('Unit 3')]; + return ['1' => __('Unit 1'), '2' => __('Unit 2'), '3' => __('Unit 3'), '4' => __('Unit 4'), '5' => __('Unit 5')]; } diff --git a/public/assets/js/backend/kpi/item.js b/public/assets/js/backend/kpi/item.js index 5093591..3990652 100644 --- a/public/assets/js/backend/kpi/item.js +++ b/public/assets/js/backend/kpi/item.js @@ -31,7 +31,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'name', title: __('Name'), operate: 'LIKE'}, {field: 'desc', title: __('Desc'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'target_value', title: __('Target_value')}, - {field: 'unit', title: __('Unit'), searchList: {"1":__('Unit 1'),"2":__('Unit 2'),"3":__('Unit 3')}, formatter: Table.api.formatter.normal}, + {field: 'unit', title: __('Unit'), searchList: {"1":__('Unit 1'),"2":__('Unit 2'),"3":__('Unit 3'),"4":__('Unit 4'),"5":__('Unit 5')}, formatter: Table.api.formatter.normal}, {field: 'score', title: __('Score')}, {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},