zhaoke 1 жил өмнө
parent
commit
5dd0398c3b

+ 55 - 15
src/views/userManagement/account/auth.vue

@@ -25,18 +25,29 @@
           <div class="manageTitle">登录策略</div>
           <div class="manageTitle">登录策略</div>
           <div class="strategy-content">
           <div class="strategy-content">
             <el-scrollbar>
             <el-scrollbar>
-              <el-checkbox-group v-model="checkboxGroup" @change="strategyChange" size="default">
+              <el-radio-group style="display: block;" v-model="checkboxGroup" @change="strategyChange" size="default">
+                <el-row :gutter="16">
+                  <el-col :span="8" v-for="item in strategyData" :key="item.id">
+                    <div class="strategy-content-list">
+                      <el-radio class="ck" :title="item.name" :label="item.id">
+                        {{ item.name }}
+                      </el-radio>
+                    </div>
+                  </el-col>
+                </el-row>
+              </el-radio-group>
+              <!-- <el-checkbox-group v-model="checkboxGroup" @change="strategyChange" size="default">
                 <el-row :gutter="16">
                 <el-row :gutter="16">
                   <el-col :span="8" v-for="item in strategyData" :key="item.id">
                   <el-col :span="8" v-for="item in strategyData" :key="item.id">
                     <div class="strategy-content-list">
                     <div class="strategy-content-list">
                       <el-checkbox class="ck" :title="item.name" :label="item.id">
                       <el-checkbox class="ck" :title="item.name" :label="item.id">
                         {{ item.name }}
                         {{ item.name }}
                       </el-checkbox>
                       </el-checkbox>
-                      <!-- <el-button style="margin-top:8px" size="default" type="primary" link>查看</el-button> -->
+                      <el-button style="margin-top:8px" size="default" type="primary" link>查看</el-button>
                     </div>
                     </div>
                   </el-col>
                   </el-col>
                 </el-row>
                 </el-row>
-              </el-checkbox-group>
+              </el-checkbox-group> -->
             </el-scrollbar>
             </el-scrollbar>
           </div>
           </div>
         </div>
         </div>
@@ -205,10 +216,11 @@ const hasStrategyData = async () => {
     returnData.map((i) => {
     returnData.map((i) => {
       nwords.push(i.logintacid);
       nwords.push(i.logintacid);
     });
     });
-    checkboxGroup.value = [...nwords];
-    strateKeys.value.push([...nwords]);
+    checkboxGroup.value = [...nwords][0];
+    strateKeys.value.push([...nwords][0]);
   } else {
   } else {
-    ElMessage.error(res.message);
+    checkboxGroup.value = [];
+    // ElMessage.error(res.message);
   }
   }
 };
 };
 //获取列表
 //获取列表
@@ -261,18 +273,21 @@ const strategyChange = (arr) => {
   strateKeys.value.push(arr);
   strateKeys.value.push(arr);
   const data1 = strateKeys.value[strateKeys.value.length - 1]; //最后一条数据
   const data1 = strateKeys.value[strateKeys.value.length - 1]; //最后一条数据
   const data2 = strateKeys.value[strateKeys.value.length - 2]; //倒数第二条数据
   const data2 = strateKeys.value[strateKeys.value.length - 2]; //倒数第二条数据
-  console.log(strateKeys.value);
-  console.log(data1);
-  console.log(data2);
   if (strateKeys.value?.length < 2) {
   if (strateKeys.value?.length < 2) {
-    strategyBoxTs(data1, [], "add");
+    submitBox(data1, "add");
   } else {
   } else {
-    if (data1.length > data2.length) {
-      strategyBoxTs(data1, data2, "add");
-    } else {
-      strategyBoxTs(data1, data2, "del");
-    }
+    submitBox(data1, "add");
+    submitBox(data2, "del");
   }
   }
+  // if (strateKeys.value?.length < 2) {
+  //   strategyBoxTs(data1, [], "add");
+  // } else {
+  //   if (data1.length > data2.length) {
+  //     strategyBoxTs(data1, data2, "add");
+  //   } else {
+  //     strategyBoxTs(data1, data2, "del");
+  //   }
+  // }
 };
 };
 
 
 //当前点击的角色
 //当前点击的角色
@@ -367,6 +382,28 @@ const strategyBoxTs = async (datas, arr, type) => {
     ElMessage.error("未选中数据");
     ElMessage.error("未选中数据");
   }
   }
 };
 };
+
+const submitBox = async (id: number | string, type: string) => {
+  const obj = <any>{
+    userid: role_id,
+  };
+  if (type == "add") {
+    obj.event = 1;
+    obj.logintacid = id;
+  } else {
+    obj.event = 3;
+    obj.logintacid = id;
+  }
+  const result = await GeneralDataReception({
+    serviceId: SERVICE_ID.rolePolicyAddId,
+    dataContent: JSON.stringify(obj),
+  });
+  if (result.code == 0) {
+    ElMessage.success(result.message || "操作成功");
+  } else {
+    ElMessage.error(result.message || "操作失败");
+  }
+};
 const submitForm = () => {
 const submitForm = () => {
   editDialogVisible.value = false;
   editDialogVisible.value = false;
 };
 };
@@ -404,6 +441,9 @@ onBeforeMount(() => {
       margin-top: 24px;
       margin-top: 24px;
       &-content {
       &-content {
         height: calc(100% - 24px);
         height: calc(100% - 24px);
+        ::deep .el-radio-group {
+          display: block;
+        }
         &-list {
         &-list {
           padding: 8px 16px 16px 16px;
           padding: 8px 16px 16px 16px;
           height: 80px;
           height: 80px;