浏览代码

上传手稿增加选择手稿二级分类

Xiahai 7 月之前
父节点
当前提交
acf4df53a0
共有 2 个文件被更改,包括 43 次插入4 次删除
  1. 34 0
      application/index/controller/User.php
  2. 9 4
      application/index/view/user/submit_manuscript.html

+ 34 - 0
application/index/controller/User.php

@@ -6,6 +6,7 @@ use addons\wechat\model\WechatCaptcha;
 use app\admin\model\Admin;
 use app\admin\model\cms\AuthorManuscript;
 use app\admin\model\cms\Channel;
+use app\admin\model\cms\ChannelAdmin;
 use app\admin\model\cms\Comment;
 use app\admin\model\cms\Comments;
 use app\admin\model\cms\InviteReviewer;
@@ -20,6 +21,7 @@ use app\common\model\Attachment;
 use app\common\model\UserRoleContent;
 use app\common\model\UserRoleLog;
 use app\manytenant\model\Manytenant;
+use fast\Tree;
 use think\Config;
 use think\Cookie;
 use think\Db;
@@ -38,6 +40,7 @@ class User extends Frontend
     protected $noNeedLogin = ['login', 'register', 'third', 'jump'];
     protected $noNeedRight = ['*'];
     protected $position = 0;
+    protected $channelIds = [];
     protected $model = null;
 
     public function _initialize()
@@ -69,6 +72,16 @@ class User extends Frontend
             Cookie::delete('token');
         });
 
+        $disabledIds = [];
+        $parentChannelIds = Channel::where(['parent_id' => 1, 'type' => 'channel'])->column('id');
+        $sonChannelIds = Channel::where(['parent_id' => ['in', $parentChannelIds]])->column('id');
+        $channelIds = array_merge($parentChannelIds, $sonChannelIds);
+        $all = collection(Channel::where(['id' => ['in', $channelIds]])->order("weigh desc,id desc")->select())->toArray();
+
+        $tree = Tree::instance()->init($all, 'parent_id');
+        $channelOptions = $tree->getTree(1, "<option model='@model_id' value=@id @selected @disabled>@spacer@name</option>", '', $disabledIds);
+        $this->view->assign('channelOptions', $channelOptions);
+
         // 根据不同用户展示不同字段
         $fieldsList = \app\admin\model\workorder\Fields::where([
             'status' => 1,
@@ -91,6 +104,17 @@ class User extends Frontend
         $this->view->assign('fields', $this->model->getFields(null, 0));
     }
 
+    function getChildren($parentId) {
+        $children = Channel::where(['parent_id' => $parentId, 'type' => 'channel'])->column('id');
+        foreach ($children as $childId) {
+            $grandChildren = getChildren($childId);
+            if ($grandChildren) {
+                $children = array_merge($children, $grandChildren);
+            }
+        }
+        return $children;
+    }
+
     /**
      * 会员中心
      */
@@ -495,6 +519,16 @@ class User extends Frontend
             $row = AuthorManuscript::where(['id' => $id])->find();
             $row->author_content = json_decode($row->author_content, true);
             $row->review_content = json_decode($row->review_content, true);
+
+            $disabledIds = [];
+            $disabledIds = array_diff($disabledIds, [$row['journal']]);
+            $parentChannelIds = Channel::where(['parent_id' => 1, 'type' => 'channel'])->column('id');
+            $sonChannelIds = Channel::where(['parent_id' => ['in', $parentChannelIds]])->column('id');
+            $channelIds = array_merge($parentChannelIds, $sonChannelIds);
+            $all = collection(Channel::where(['id' => ['in', $channelIds]])->order("weigh desc,id desc")->select())->toArray();
+            $tree = Tree::instance()->init($all, 'parent_id');
+            $channelOptions = $tree->getTree(1, "<option model='@model_id' value=@id @selected @disabled>@spacer@name</option>", $row['journal'], $disabledIds);
+            $this->view->assign('channelOptions', $channelOptions);
         }
         $this->view->assign('fields', $this->model->getFields($row, 0));
         $this->view->assign('row', $row);

+ 9 - 4
application/index/view/user/submit_manuscript.html

@@ -308,14 +308,19 @@
                                     <span style="color:#ed534b;margin-right: 10px;">*</span>Choose Journal:
                                 </label>
                                 <div class="col-xs-12 col-sm-8">
+                                    <select id="c-journal" data-rule="required" class="form-control selectpicker" data-live-search="true" name="row[journal]">
+                                        {$channelOptions}
+                                    </select>
+                                </div>
+<!--                                <div class="col-xs-12 col-sm-8">-->
 <!--                                    <select id="c-journal" data-rule="required" class="form-control" name="row[journal]">-->
 <!--                                        <option value="">Please select</option>-->
 <!--                                        {cms:channellist id="channel" type="son" typeid="1"}-->
 <!--                                        <option value="{$channel.id}" {if condition="$row.journal == $channel.id"}selected{/if}>{$channel.name}</option>-->
 <!--                                        {/cms:channellist}-->
 <!--                                    </select>-->
-                                    <input id="c-journal" data-rule="required" data-source="user/choose_journal" data-params='{"type":"author"}' data-primary-key="id" data-search-field="name" class="form-control selectpage" name="row[journal]" type="text" value="{$row.journal}">
-                                </div>
+<!--                                    <input id="c-journal" data-rule="required" data-source="user/choose_journal" data-params='{"type":"author"}' data-primary-key="id" data-search-field="name" class="form-control selectpage" name="row[journal]" type="text" value="{$row.journal}" />-->
+<!--                                </div>-->
                             </div>
                             <div class="form-group">
                                 <label class="control-label col-xs-12 col-sm-4">
@@ -442,7 +447,7 @@
                                 </div>
                                 <div class="form-group">
                                     <label class="control-label col-xs-12 col-sm-4">
-                                        <span style="color:#ed534b;margin-right: 10px;">*</span>Correspondsing Author:
+                                        <span style="color:#ed534b;margin-right: 10px;">*</span>Corresponding Author:
                                     </label>
                                     <div class="col-xs-12 col-sm-8">
                                         <div class="input-group mb-3">
@@ -547,7 +552,7 @@
                                 </div>
                                 <div class="form-group">
                                     <label class="control-label col-xs-12 col-sm-4">
-                                        <span style="color:#ed534b;margin-right: 10px;">*</span>Correspondsing Author:
+                                        <span style="color:#ed534b;margin-right: 10px;">*</span>Corresponding Author:
                                     </label>
                                     <div class="col-xs-12 col-sm-8">
                                         <div class="input-group mb-3">