ソースを参照

优化查询效率

sandm 1 年間 前
コミット
8b0effc156

+ 1 - 1
DingTalkToken

@@ -1 +1 @@
-{"errcode":0,"access_token":"2c6beccd0d39301dbd263ff5e2c0ef86","errmsg":"ok","expires_in":1653448622}
+{"errcode":0,"access_token":"be82f96a88e034c2adee74c235fbb7ac","errmsg":"ok","expires_in":1681966448}

+ 12 - 4
app/Http/Controllers/Api/ProjectController.php

@@ -8,6 +8,7 @@ use App\Module\Base;
 use App\Module\BillExport;
 use App\Module\Project;
 use App\Module\Users;
+use App\Task;
 use DB;
 use Madzipper;
 use Request;
@@ -303,16 +304,22 @@ class ProjectController extends Controller
         if ($projectSetting['complete_show'] == 'show') {
             unset($whereArray['complete']);
         }
-        $task = Base::DBC2A(DB::table('project_task')->where($whereArray)->orderByDesc('inorder')->orderByDesc('id')->get());
+        //$task = Base::DBC2A(DB::table('project_task')->where($whereArray)->orderByDesc('inorder')->orderByDesc('id')->get());
+
+        $taskModel = new Task();
+
+        $list = $taskModel->with('subtask')->where($whereArray)->orderByDesc('inorder')->orderByDesc('id')->get()->toArray();
+
+
         //任务归类
         foreach ($label AS $index => $temp) {
             $taskLists = [];
-            foreach ($task AS $info) {
+            foreach ($list AS $info) {
                 if ($temp['id'] == $info['labelid']) {
                     $info['persons'] = Project::taskPersons($info);
                     $info['overdue'] = Project::taskIsOverdue($info);
-                    $subtask = Base::DBC2A(DB::table('project_sub_task')->where(['taskid'=>$info['id'], 'delete' => 0])->orderByDesc('id')->get());
-                    $info['subtask'] = $subtask;
+                    //$subtask = Base::DBC2A(DB::table('project_sub_task')->where(['taskid'=>$info['id'], 'delete' => 0])->orderByDesc('id')->get());
+                    //$info['subtask'] = $subtask;
                     $info['follower'] = Base::string2array($info['follower']);
                     $info['plantime'] = ($info['startdate'] > 0 ? date("Y-m-d",$info['startdate']) : "未设置") . "-" . ($info['enddate'] > 0 ? date("Y-m-d",$info['enddate']) : "未设置");
                     $taskLists[] = array_merge($info, Users::username2basic($info['username']));
@@ -2133,6 +2140,7 @@ class ProjectController extends Controller
                     return $inRes;
                 }
             }
+
             if (!in_array($act, ['comment', 'attention'])) {
                 $checkRole = Project::role('edit_role', $task['projectid'], $task['id']);
                 if (Base::isError($checkRole)) {

+ 48 - 15
app/Http/Controllers/IndexController.php

@@ -46,23 +46,56 @@ class IndexController extends Controller
     }
 
     public function test(){
-        $list = DB::table("project_task")->where('delete',0)->get()->toArray();
-        foreach ($list as $k => $v){
-            $subtasks = Base::string2array($v->subtask);
-            if(count($subtasks) > 0){
-                $subtasks_data = [];
-                foreach ($subtasks as $key => $value){
-                    $item = [
-                        'taskid' => $v->id,
-                        'uname' => $value['uname'],
-                        'indate' => $value['time'],
-                        'status' => $value['status'],
-                        'detail' => $value['detail']
+        $list = Base::DBC2A(DB::table("project_log")->where('taskid',640)->orderBy('id','asc')->get());
+        $project = [];
+        $task = [];
+        foreach ($list as $item) {
+            switch ($item['detail']){
+                case '添加任务':
+                    $project = Base::DBC2A(DB::table("project_lists")->where('id',$item['projectid'])->first());
+                    $other = Base::string2array($item['other']);
+                    $task['createuser'] = $task['username'] = $item['username'];
+                    $task['title'] = $other['title'];
+                    $task['indate'] = $item['indate'];
+                    $task['sub_task'] = [];
+                    break;
+                case '增加子任务':
+                    $other = Base::string2array($item['other']);
+                    $subtask = [
+                        'taskid' => 640,
+                        'uname' => $task['username'],
+                        'indate' => $other['subtask'][0]['time'],
+                        'status' => $other['subtask'][0]['status'],
+                        'detail' => $other['subtask'][0]['detail']
                     ];
-                    array_push($subtasks_data,$item);
-                }
-                DB::table('project_sub_task')->insert($subtasks_data);
+                    $task['sub_task'][$other['subtask'][0]['detail']] = $subtask;
+                    break;
+                case '修改子任务负责人':
+                case '修改子任务':
+                    $other = Base::string2array($item['other']);
+                    $subtask = Base::string2array($other['subtask']);
+                    $old_subtask = Base::string2array($other['old_subtask']);
+                    if(array_key_exists($old_subtask['detail'],$task['sub_task'])){
+                        $task['sub_task'][$old_subtask['id']] = $subtask[0];
+                        unset($task['sub_task'][$old_subtask['detail']]);
+                    }else{
+                        $task['sub_task'][$old_subtask['id']] = $subtask[0];
+                    }
+                    break;
+                case '标记已完成':
+                    $task['complete'] = 1;
+                    $task['completedate'] = $item['indate'];
+                    break;
+                case '上传文件':
+                    if(!array_key_exists('files',$task)){
+                        $task['files'] = [];
+                    }
+                    $task['files'][] = Base::string2array($item['other']);
+                    break;
+
             }
         }
+        echo "<pre>";
+        var_dump($task);
     }
 }

+ 7 - 0
app/Module/Project.php

@@ -181,6 +181,13 @@ class Project
             }
             $username = $user['username'];
         }
+
+        //超级管理员最高权限  zmw修改
+        $admins = Base::DBC2A(DB::table('users')->where('identity', 'like' , '%admin%')->pluck('username'));
+        if(in_array($username, $admins)){
+            return Base::retSuccess('success', $project);
+        }
+
         //
         $project = Base::DBC2A(DB::table('project_lists')->select(['username', 'title', 'setting'])->where('id', $projectid)->where('delete', 0)->first());
         if (empty($project)) {

+ 1 - 1
app/Task.php

@@ -25,6 +25,6 @@ class Task extends Model
      */
     public function subtask()
     {
-        return $this->hasMany(SubTask::class,'taskid');
+        return $this->hasMany(SubTask::class,'taskid','id');
     }
 }

ファイルの差分が大きいため隠しています
+ 0 - 0
public/css/app.css


+ 2 - 1
public/index.php

@@ -1,5 +1,6 @@
 <?php
-
+ini_set('display_errors',1);
+error_reporting(E_ALL);
 /**
  * Laravel - A PHP Framework For Web Artisans
  *

ファイルの差分が大きいため隠しています
+ 0 - 0
public/js/app.js


ファイルの差分が大きいため隠しています
+ 0 - 0
public/js/build/0.js


ファイルの差分が大きいため隠しています
+ 0 - 0
public/js/build/1.js


ファイルの差分が大きいため隠しています
+ 0 - 0
public/js/build/10.js


ファイルの差分が大きいため隠しています
+ 0 - 0
public/js/build/11.js


ファイルの差分が大きいため隠しています
+ 0 - 0
public/js/build/12.js


ファイルの差分が大きいため隠しています
+ 0 - 0
public/js/build/13.js


ファイルの差分が大きいため隠しています
+ 0 - 0
public/js/build/14.js


ファイルの差分が大きいため隠しています
+ 0 - 0
public/js/build/15.js


ファイルの差分が大きいため隠しています
+ 0 - 0
public/js/build/2.js


ファイルの差分が大きいため隠しています
+ 0 - 0
public/js/build/3.js


ファイルの差分が大きいため隠しています
+ 0 - 0
public/js/build/4.js


ファイルの差分が大きいため隠しています
+ 0 - 0
public/js/build/5.js


ファイルの差分が大きいため隠しています
+ 0 - 0
public/js/build/6.js


ファイルの差分が大きいため隠しています
+ 0 - 0
public/js/build/7.js


ファイルの差分が大きいため隠しています
+ 0 - 0
public/js/build/8.js


+ 131 - 1
public/js/build/9.js

@@ -1 +1,131 @@
-webpackJsonp([9],{858:function(e,t,i){var a=i(859);"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);i(1)("e7cda57c",a,!0,{})},859:function(e,t,i){(e.exports=i(0)(!1)).push([e.i,".page-404[data-v-2d950362]{background-color:#fff;color:#636b6f;font-weight:400;height:100vh;margin:0}.page-404 .full-height[data-v-2d950362]{height:100vh}.page-404 .flex-center[data-v-2d950362]{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.page-404 .position-ref[data-v-2d950362]{position:relative}.page-404 .code[data-v-2d950362]{border-right:2px solid;font-size:26px;padding:0 15px;text-align:center}.page-404 .message[data-v-2d950362]{font-size:18px;padding:10px;text-align:center}",""])},860:function(e,t){e.exports={render:function(){this.$createElement;this._self._c;return this._m(0)},staticRenderFns:[function(){var e=this.$createElement,t=this._self._c||e;return t("div",{staticClass:"page-404"},[t("div",{staticClass:"flex-center position-ref full-height"},[t("div",{staticClass:"code"},[this._v("404")]),this._v(" "),t("div",{staticClass:"message"},[this._v("Not Found")])])])}]}},870:function(e,t,i){var a=i(2)(null,i(860),!1,function(e){i(858)},"data-v-2d950362",null);e.exports=a.exports}});
+webpackJsonp([9],{
+
+/***/ 296:
+/***/ (function(module, exports, __webpack_require__) {
+
+var disposed = false
+function injectStyle (ssrContext) {
+  if (disposed) return
+  __webpack_require__(987)
+}
+var normalizeComponent = __webpack_require__(2)
+/* script */
+var __vue_script__ = null
+/* template */
+var __vue_template__ = __webpack_require__(989)
+/* template functional */
+var __vue_template_functional__ = false
+/* styles */
+var __vue_styles__ = injectStyle
+/* scopeId */
+var __vue_scopeId__ = "data-v-e45a6a6e"
+/* moduleIdentifier (server only) */
+var __vue_module_identifier__ = null
+var Component = normalizeComponent(
+  __vue_script__,
+  __vue_template__,
+  __vue_template_functional__,
+  __vue_styles__,
+  __vue_scopeId__,
+  __vue_module_identifier__
+)
+Component.options.__file = "resources/assets/js/main/pages/404.vue"
+
+/* hot reload */
+if (false) {(function () {
+  var hotAPI = require("vue-hot-reload-api")
+  hotAPI.install(require("vue"), false)
+  if (!hotAPI.compatible) return
+  module.hot.accept()
+  if (!module.hot.data) {
+    hotAPI.createRecord("data-v-e45a6a6e", Component.options)
+  } else {
+    hotAPI.reload("data-v-e45a6a6e", Component.options)
+  }
+  module.hot.dispose(function (data) {
+    disposed = true
+  })
+})()}
+
+module.exports = Component.exports
+
+
+/***/ }),
+
+/***/ 987:
+/***/ (function(module, exports, __webpack_require__) {
+
+// style-loader: Adds some css to the DOM by adding a <style> tag
+
+// load the styles
+var content = __webpack_require__(988);
+if(typeof content === 'string') content = [[module.i, content, '']];
+if(content.locals) module.exports = content.locals;
+// add the styles to the DOM
+var update = __webpack_require__(1)("2712dff7", content, false, {});
+// Hot Module Replacement
+if(false) {
+ // When the styles change, update the <style> tags
+ if(!content.locals) {
+   module.hot.accept("!!../../../../../node_modules/css-loader/index.js!../../../../../node_modules/vue-loader/lib/style-compiler/index.js?{\"vue\":true,\"id\":\"data-v-e45a6a6e\",\"scoped\":true,\"hasInlineConfig\":true}!../../../../../node_modules/sass-loader/lib/loader.js!../../../../../node_modules/vue-loader/lib/selector.js?type=styles&index=0!./404.vue", function() {
+     var newContent = require("!!../../../../../node_modules/css-loader/index.js!../../../../../node_modules/vue-loader/lib/style-compiler/index.js?{\"vue\":true,\"id\":\"data-v-e45a6a6e\",\"scoped\":true,\"hasInlineConfig\":true}!../../../../../node_modules/sass-loader/lib/loader.js!../../../../../node_modules/vue-loader/lib/selector.js?type=styles&index=0!./404.vue");
+     if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
+     update(newContent);
+   });
+ }
+ // When the module is disposed, remove the <style> tags
+ module.hot.dispose(function() { update(); });
+}
+
+/***/ }),
+
+/***/ 988:
+/***/ (function(module, exports, __webpack_require__) {
+
+exports = module.exports = __webpack_require__(0)(false);
+// imports
+
+
+// module
+exports.push([module.i, "\n.page-404[data-v-e45a6a6e] {\n  background-color: #fff;\n  color: #636b6f;\n  font-weight: 400;\n  height: 100vh;\n  margin: 0;\n}\n.page-404 .full-height[data-v-e45a6a6e] {\n    height: 100vh;\n}\n.page-404 .flex-center[data-v-e45a6a6e] {\n    -webkit-box-align: center;\n        -ms-flex-align: center;\n            align-items: center;\n    display: -webkit-box;\n    display: -ms-flexbox;\n    display: flex;\n    -webkit-box-pack: center;\n        -ms-flex-pack: center;\n            justify-content: center;\n}\n.page-404 .position-ref[data-v-e45a6a6e] {\n    position: relative;\n}\n.page-404 .code[data-v-e45a6a6e] {\n    border-right: 2px solid;\n    font-size: 26px;\n    padding: 0 15px 0 15px;\n    text-align: center;\n}\n.page-404 .message[data-v-e45a6a6e] {\n    font-size: 18px;\n    padding: 10px;\n    text-align: center;\n}\n", ""]);
+
+// exports
+
+
+/***/ }),
+
+/***/ 989:
+/***/ (function(module, exports, __webpack_require__) {
+
+var render = function() {
+  var _vm = this
+  var _h = _vm.$createElement
+  var _c = _vm._self._c || _h
+  return _vm._m(0)
+}
+var staticRenderFns = [
+  function() {
+    var _vm = this
+    var _h = _vm.$createElement
+    var _c = _vm._self._c || _h
+    return _c("div", { staticClass: "page-404" }, [
+      _c("div", { staticClass: "flex-center position-ref full-height" }, [
+        _c("div", { staticClass: "code" }, [_vm._v("404")]),
+        _vm._v(" "),
+        _c("div", { staticClass: "message" }, [_vm._v("Not Found")])
+      ])
+    ])
+  }
+]
+render._withStripped = true
+module.exports = { render: render, staticRenderFns: staticRenderFns }
+if (false) {
+  module.hot.accept()
+  if (module.hot.data) {
+    require("vue-hot-reload-api")      .rerender("data-v-e45a6a6e", module.exports)
+  }
+}
+
+/***/ })
+
+});

+ 33 - 0
resources/assets/js/main/components/project/task/detail/detail.vue

@@ -128,6 +128,26 @@
                                             </div>
                                         </div>
                                     </Poptip>
+                                    <div v-if="subitem.uname!='' && isAdmin" class="detail-subtask-ricon">
+                                        <Poptip
+                                            class="detail-subtask-ricon"
+                                            transfer
+                                            @on-popper-show="$set(subitem, 'stip', 'show')"
+                                            @on-popper-hide="[$set(subitem, 'stip', ''), handleTask('subtaskBlur', subindex, 'uname')]">
+                                            <Icon type="md-link" />
+                                            <div slot="content">
+                                                <div style="width:280px">
+                                                    {{$L('任务关联')}}
+                                                    <Cascader :data="linkData" :load-data="linkLoadData" v-width="200" />
+                                                    <div class="user-id-input-bottom">
+                                                        <Button type="default" size="small" >{{$L('取消')}}</Button>
+                                                        <Button type="primary" size="small" >{{$L('确定')}}</Button>
+                                                    </div>
+
+                                                </div>
+                                            </div>
+                                        </Poptip>
+                                    </div>
                                     <div v-if="subitem.detail==''" class="detail-subtask-ricon">
                                         <Icon type="md-trash" @click="handleTask('subtaskDelete', subindex, 'delete')"/>
                                     </div>
@@ -255,6 +275,10 @@
                 timeOptions: {},
 
                 openMenu: false,
+
+                isAdmin: false,
+
+                linkData:[],
             }
         },
         beforeCreate() {
@@ -327,6 +351,7 @@
                 return   year+"-"+month+"-"+date+"   "+hour+":"+minute+":"+second;
             },
             initLanguage() {
+                this.isAdmin = $A.identity('admin');
                 let lastSecond = (e) => {
                     return new Date($A.formatDate("Y-m-d 23:59:29", Math.round(e / 1000)))
                 };
@@ -650,6 +675,10 @@
                         this.handleTask('subtask', eve, type);
                         return;
 
+                    case 'subtaskLink':
+                        this.handleTask('subtask', eve, type);
+                        return;
+
                     case 'subtask':
                         if(type === 'all'){//批量
                             let tempArray = cloneDeep(this.detail[act]);
@@ -938,6 +967,10 @@
                 } catch (e) {
                     this.visible = true;
                 }
+            },
+
+            linkLoadData(item, callback){
+
             }
         }
     }

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません