فهرست منبع

自动化权限

q 11 ماه پیش
والد
کامیت
ccead13cf2

+ 34 - 1
webmain/flow/input/inputjs/mode_dcs_auth.js

@@ -1,4 +1,37 @@
 //流程模块【dcs_auth.查看权限】下录入页面自定义js页面,初始函数
 function initbodys(){
-	
+
+    if (mid == 1) {
+
+        var selectedValues = form('range').value.split(',');
+        // console.log(selectedValues);
+
+        // 遍历所有的复选框
+        $('input[name="range_set[]"]').each(function() {
+            // console.log('Current checkbox value:', $(this).val());
+            // 如果复选框的值在 selectedValues 数组中,则设置为选中状态
+            if (selectedValues.includes($(this).val())) {
+                // console.log('Checkbox checked:', $(this).val());
+                try {
+                    // $(this).prop('checked', true);
+                    $(this).attr('checked', 'checked');
+                } catch (e) {
+                    console.error('Error setting checkbox:', e);
+                }
+            }
+        });
+
+    }
+
+    // 监听复选框的改变事件
+    $('input[name="range_set[]"]').blur(function () {
+        // console.log(form('range_set').value);
+        var checkedValues = []; // 存放选中复选框的值的数组
+        $('input[name="range_set[]"]:checked').each(function() {
+            checkedValues.push($(this).val());
+        });
+        form('range').value = checkedValues.join(',');
+        // console.log(checkedValues);
+    })
+
 }

+ 43 - 1
webmain/flow/input/mode_dcs_authAction.php

@@ -26,5 +26,47 @@ class mode_dcs_authClassAction extends inputAction{
 	protected function saveafter($table, $arr, $id, $addbo){
 		
 	}
+
+
+    public function getGroup()
+    {
+        $groupArr = m('dcs_group')->getall('1=1 and pid != 0');
+
+        $arr = [];
+        $html = '<span id="div_range" class="divinput">';
+        for ($i = 0; $i < count($groupArr); $i++) {
+            $group = $groupArr[$i];
+            $arr[] = array("name"=>$group['name'],"value"=>$group['id']);
+            $html .= '<label><input name="range_set[]" value="'.$group['id'].'" type="checkbox">'.$group['name'].'<br></label>';
+        }
+        $html .= '</span>';
+
+        // new
+        $rows = m('dcs_group')->getall('1=1');
+        $newRowArr = [];
+        $html = '';
+        for ($i = 0; $i < count($rows); $i++) {
+            $row = $rows[$i];
+            if ($row['pid'] == 0) {
+                // 一级
+                $newRowArr[] = $row;
+                $html .= "<label class='group_name'>".$row['name']."</label><br>";
+                $html .= '<span class="group_box">';
+                // 找二级
+                for ($j = 0; $j <count($rows); $j++) {
+                    $crow = $rows[$j];
+                    if ($crow['pid'] == $row['id']) {
+                        $newRowArr[] = $crow;
+                        $html .= '<label class="group_box_label"><input name="range_set[]" value="'.$crow['id'].'" type="checkbox">'.$crow['name'].'  </label>';
+                    }
+                }
+                $html .= '</span><br><div style="height:1px;background-color:#ddd;"></div>';
+            }
+        }
+
+
+        return $html;
+
+    }
+
 }	
-			

+ 18 - 6
webmain/flow/page/input_dcs_auth.html

@@ -2,15 +2,27 @@
     <tbody>
     <tr class="autoyijianview">
         <td height="34" width="15%" align="right" class="ys1">*^name^</td>
-        <td width="35%" class="ys2">{name}</td>
+        <td width="35%" class="ys2">{name}<span>{range}</span></td>
         <td height="34" width="15%" align="right" class="ys1">*^users^</td>
         <td width="35%" class="ys2">{users}</td>
     </tr>
     <tr>
-        <td height="34" width="15%" align="right" class="ys1">*^range^</td>
-        <td width="35%" class="ys2">{range}</td>
-        <td height="34" align="right" class="ys1"></td>
-        <td class="ys2"></td>
+        <td height="34" width="15%" align="right" class="ys1">^range^</td>
+        <td width="35%" class="ys2" colspan="3">{range_set}</td>
     </tr>
     </tbody>
-</table>
+</table>
+
+<style>
+    .group_name {
+        font-size: 14px;
+        font-weight: bold;
+        color: #333;
+        line-height: 30px;
+    }
+
+    .group_box .group_box_label {
+        line-height: 30px;
+        padding: 5px;
+    }
+</style>

+ 4 - 0
webmain/flow/page/input_dcs_group.html

@@ -28,5 +28,9 @@
         <td height="34" align="right" class="ys1"></td>
         <td class="ys2"></td>
     </tr>
+    <tr>
+        <td height="34" width="15%" align="right" class="ys1">^url^</td>
+        <td width="35%" class="ys2" colspan="3">{url}</td>
+    </tr>
     </tbody>
 </table>

+ 21 - 0
webmain/model/flow/dcs_authModel.php

@@ -0,0 +1,21 @@
+<?php
+
+class flow_dcs_authClassModel extends flowModel
+{
+    protected $flowcompanyidfieds	= 'none';
+
+    public function initModel()
+	{
+
+	}
+
+	public function flowrsreplace($rs, $lx=0)
+	{
+        $groupInfo = m("dcs_group")->getall("id in (".$rs['range'].")");
+
+        $rs['range'] = array_column($groupInfo, 'name');
+
+        return $rs;
+	}
+
+}

+ 1 - 1
webmain/model/flow/dcs_groupModel.php

@@ -20,7 +20,7 @@ class flow_dcs_groupClassModel extends flowModel
     protected function flowbillwhere($lx, $uid)
     {
         return [
-            'order'=>'sort',
+            'order'=>'sort, id, pid',
         ];
     }
 }

+ 23 - 0
webmain/task/openapi/openDcsApiAction.php

@@ -68,6 +68,7 @@ class openDcsApiClassAction extends openapiAction
                     $crow = $groupArr[$j];
                     if ($crow['pid'] == $row['id']) {
                         $rowArr["nav"][$pcon]["list"][] = [
+                            "id" => $crow['id'],
                             "icon" => URL.(empty($crow['icon']) ? $row['icon'] : $crow['icon']),
                             "module"=>$row['key'],
                             "name"=>$crow['name'],
@@ -81,4 +82,26 @@ class openDcsApiClassAction extends openapiAction
         return $rowArr;
     }
 
+    public function dcs_auth_checkAction() {
+        $staffNum = $this->get('staff_num');
+        $sys_id = $this->get('sys_id');
+
+        if (empty($staffNum) || empty($sys_id)) {
+            $this->showreturn('', '参数错误!', 201);
+        }
+
+        $uInfo = m("admin")->getone("user='{$staffNum}'");
+
+        $checkAuth = m("dcs_auth")->getall("FIND_IN_SET($sys_id, `range`) and FIND_IN_SET({$uInfo['id']}, `user_ids`)  ");
+
+        // 找到权限
+        if (!empty($checkAuth) && count($checkAuth) > 0) {
+            $urlInfo = m("dcs_group")->getone("id={$sys_id}");
+            $this->showreturn([url=>trim($urlInfo['url'])], '成功!', 200);
+        } else {
+            $this->showreturn('', '暂无权限访问,请联系管理员!', 202);
+        }
+
+    }
+
 }