huangbin 4 年之前
父節點
當前提交
d3b8d6b9f8
共有 1 個文件被更改,包括 87 次插入66 次删除
  1. 87 66
      src/views/information/account_info/compoments/add-managers-permission/index.vue

+ 87 - 66
src/views/information/account_info/compoments/add-managers-permission/index.vue

@@ -1,71 +1,79 @@
 <template>
-    <!-- 新增角色 -->
-    <a-modal
-        class="commonModal add-roles"
-        title="新增角色"
-        v-model:visible="visible"
-        @cancel="cancel"
-        centered
-        :maskClosable="false"
-        width="100%"
-    >
-        <template #footer>
-            <a-button key="cancel" type="primary" :loading="loading" @click="cancel">取消</a-button>
-            <a-button key="submit" type="primary" :loading="loading" @click="submit">新增</a-button>
-        </template>
-        <a-form class="inlineForm" ref="formRef" :model="formState" :rules="rules">
-            <a-row :gutter="24">
-                <a-col :span="24">
-                    <a-form-item label="角色名称">
-                        <a-input
-                            class="dialogInput"
-                            style="width: 200px"
-                            v-model:value="name"
-                            placeholder="请输入角色名称"
-                        />
-                    </a-form-item>
-                </a-col>
-                <a-col :span="24">
-                    <a-form-item label="权限功能" name></a-form-item>
-                </a-col>
-                <a-col :span="24">
-                    <div class="powerTable">
-                        <!-- <a-checkbox-group class="commonCheckboxGroup"
+  <!-- 新增角色 -->
+  <a-modal class="commonModal add-roles"
+           title="新增角色"
+           v-model:visible="visible"
+           @cancel="cancel"
+           centered
+           :maskClosable="false"
+           width="100%">
+    <template #footer>
+      <a-button key="cancel"
+                type="primary"
+                :loading="loading"
+                @click="cancel">取消</a-button>
+      <a-button key="submit"
+                type="primary"
+                :loading="loading"
+                @click="submit">新增</a-button>
+    </template>
+    <a-form class="inlineForm"
+            ref="formRef"
+            :model="formState"
+            :rules="rules">
+      <a-row :gutter="24">
+        <a-col :span="24">
+          <a-form-item label="角色名称">
+            <a-input class="dialogInput"
+                     style="width: 200px"
+                     v-model:value="name"
+                     placeholder="请输入角色名称" />
+          </a-form-item>
+        </a-col>
+        <a-col :span="24">
+          <a-form-item label="权限功能"
+                       name></a-form-item>
+        </a-col>
+        <a-col :span="24">
+          <div class="powerTable">
+            <!-- <a-checkbox-group class="commonCheckboxGroup"
 
                         >-->
-                        <div class="powerRow" v-for="(item, i) in tableList" :key="i + '0'">
-                            <div class="powerLeft">
-                                <a-checkbox
-                                    v-model:checked="item.Menu.ishadrole"
-                                >{{item.Menu.resourcename}}</a-checkbox>
-                            </div>
-                            <div class="powerRight">
-                                <div class="line" v-for="(sub, j) in item.SubMenu" :key="j + '1'">
-                                    <div class="left">
-                                        <a-checkbox
-                                            v-model:checked="sub.Menu.ishadrole"
-                                            @change="secondChange(item, sub)"
-                                            :value="sub.Menu.resourcecode"
-                                        >{{sub.Menu.resourcename}}</a-checkbox>
-                                    </div>
-                                    <div class="right">
-                                        <a-checkbox
-                                            v-for="(subNext, l) in sub.SubMenu"
-                                            :key="l + '3'"
-                                            v-model:checked="subNext.Menu.ishadrole"
-                                            @change="thirdChange(item, sub, subNext)"
-                                            :value="subNext.Menu.resourcecode"
-                                        >{{subNext.Menu.resourcename}}</a-checkbox>
-                                    </div>
-                                </div>
-                            </div>
-                        </div>
-                        <!-- </a-checkbox-group> -->
-                    </div>
-                </a-col>
-            </a-row>
-        </a-form>
-    </a-modal>
+            <div class="powerRow"
+                 v-for="(item, i) in tableList"
+                 :key="i + '0'">
+              <div class="powerLeft">
+                <a-checkbox @change="firstChaneg(item)"
+                            v-model:checked="item.Menu.ishadrole">{{item.Menu.resourcename}}
+                </a-checkbox>
+              </div>
+              <div class="powerRight">
+                <div class="line"
+                     v-for="(sub, j) in item.SubMenu"
+                     :key="j + '1'">
+                  <div class="left">
+                    <a-checkbox v-model:checked="sub.Menu.ishadrole"
+                                @change="secondChange(item, sub)"
+                                :value="sub.Menu.resourcecode">{{sub.Menu.resourcename}}
+                    </a-checkbox>
+                  </div>
+                  <div class="right">
+                    <a-checkbox v-for="(subNext, l) in sub.SubMenu"
+                                :key="l + '3'"
+                                v-model:checked="subNext.Menu.ishadrole"
+                                @change="thirdChange(item, sub, subNext)"
+                                :value="subNext.Menu.resourcecode">{{subNext.Menu.resourcename}}
+                    </a-checkbox>
+                  </div>
+                </div>
+              </div>
+            </div>
+            <!-- </a-checkbox-group> -->
+          </div>
+        </a-col>
+      </a-row>
+    </a-form>
+  </a-modal>
 </template>
 
 <script lang="ts">
@@ -143,7 +151,19 @@ export default defineComponent({
                 context.emit('refresh');
             });
         }
-
+        function firstChaneg(value: ErmcpRoleMenuEx) {
+            if (value.Menu.ishadrole) {
+                value.SubMenu.forEach((el) => {
+                    el.Menu.ishadrole = true;
+                    el.SubMenu.forEach((item) => (item.Menu.ishadrole = true));
+                });
+            } else {
+                value.SubMenu.forEach((el) => {
+                    el.Menu.ishadrole = false;
+                    el.SubMenu.forEach((item) => (item.Menu.ishadrole = false));
+                });
+            }
+        }
         function secondChange(item: ErmcpRoleMenuEx, sub: ErmcpRoleMenuEx) {
             if (sub.Menu.ishadrole) {
                 item.Menu.ishadrole = true;
@@ -169,6 +189,7 @@ export default defineComponent({
             thirdChange,
             loading,
             tableList,
+            firstChaneg,
         };
     },
 });