|
@@ -6,37 +6,54 @@
|
|
|
</t-form-item>
|
|
|
<t-form-item label="绑定权限">
|
|
|
<!-- <t-tree-select v-model="formData.d" :data="treeData" multiple /> -->
|
|
|
- <t-table
|
|
|
- row-key="id"
|
|
|
- :columns="columns"
|
|
|
- :data="treeFlatArr"
|
|
|
- bordered
|
|
|
- v-loading="loading"
|
|
|
- >
|
|
|
- <template #page="{ row }">
|
|
|
- <t-checkbox v-model="row.hasRole"></t-checkbox>
|
|
|
- </template>
|
|
|
- <template #conditions="{ row }">
|
|
|
- <div v-for="item in row.conditions" :key="item.id">
|
|
|
- <t-checkbox v-model="item.hasRole">{{ item.name }}</t-checkbox>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <template #buttons="{ row }">
|
|
|
- <div v-for="item in row.buttons" :key="item.id">
|
|
|
- <t-checkbox v-model="item.hasRole">{{ item.name }}</t-checkbox>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <template #lists="{ row }">
|
|
|
- <div v-for="item in row.lists" :key="item.id">
|
|
|
- <t-checkbox v-model="item.hasRole">{{ item.name }}</t-checkbox>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <template #links="{ row }">
|
|
|
- <div v-for="item in row.links" :key="item.id">
|
|
|
- <t-checkbox v-model="item.hasRole">{{ item.name }}</t-checkbox>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </t-table>
|
|
|
+ <div>
|
|
|
+ <div>
|
|
|
+ <t-button theme="primary" @click="allCheckHandler(true)"
|
|
|
+ >全选</t-button
|
|
|
+ >
|
|
|
+ <t-button
|
|
|
+ theme="primary"
|
|
|
+ variant="outline"
|
|
|
+ @click="allCheckHandler(false)"
|
|
|
+ class="m-l-10px"
|
|
|
+ >全不选</t-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ <t-table
|
|
|
+ row-key="id"
|
|
|
+ :columns="columns"
|
|
|
+ :data="treeFlatArr"
|
|
|
+ bordered
|
|
|
+ v-loading="loading"
|
|
|
+ >
|
|
|
+ <template #page="{ row }">
|
|
|
+ <t-checkbox
|
|
|
+ v-model="row.hasRole"
|
|
|
+ @change="pageRoleChange(row)"
|
|
|
+ ></t-checkbox>
|
|
|
+ </template>
|
|
|
+ <template #conditions="{ row }">
|
|
|
+ <div v-for="item in row.conditions" :key="item.id">
|
|
|
+ <t-checkbox v-model="item.hasRole">{{ item.name }}</t-checkbox>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <template #buttons="{ row }">
|
|
|
+ <div v-for="item in row.buttons" :key="item.id">
|
|
|
+ <t-checkbox v-model="item.hasRole">{{ item.name }}</t-checkbox>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <template #lists="{ row }">
|
|
|
+ <div v-for="item in row.lists" :key="item.id">
|
|
|
+ <t-checkbox v-model="item.hasRole">{{ item.name }}</t-checkbox>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <template #links="{ row }">
|
|
|
+ <div v-for="item in row.links" :key="item.id">
|
|
|
+ <t-checkbox v-model="item.hasRole">{{ item.name }}</t-checkbox>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </t-table>
|
|
|
+ </div>
|
|
|
</t-form-item>
|
|
|
</t-form>
|
|
|
<s-button
|
|
@@ -48,7 +65,7 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script setup name="AddRole">
|
|
|
-import { ref, computed, reactive } from 'vue';
|
|
|
+import { ref, computed, reactive, watch } from 'vue';
|
|
|
import { getAllMenuResource, addRole, getRoleDetail } from '@/api/user';
|
|
|
import { useRequest } from 'vue-request';
|
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
@@ -71,6 +88,35 @@ const rules = {
|
|
|
let loading = ref(false);
|
|
|
let treeFlatArr = ref([]);
|
|
|
|
|
|
+const allCheckHandler = (bool) => {
|
|
|
+ setAllCheckStatus(treeFlatArr.value, bool);
|
|
|
+};
|
|
|
+const setAllCheckStatus = (data, bool) => {
|
|
|
+ for (let i = 0; i < data.length; i++) {
|
|
|
+ data[i].hasRole = bool;
|
|
|
+ setAllCheckStatus(data[i].children || [], bool);
|
|
|
+ setAllCheckStatus(data[i].conditions || [], bool);
|
|
|
+ setAllCheckStatus(data[i].buttons || [], bool);
|
|
|
+ setAllCheckStatus(data[i].lists || [], bool);
|
|
|
+ setAllCheckStatus(data[i].links || [], bool);
|
|
|
+ }
|
|
|
+};
|
|
|
+const setAllCheckStatusInArr = (arr, bool) => {
|
|
|
+ for (let i = 0; i < arr.length; i++) {
|
|
|
+ arr[i].hasRole = bool;
|
|
|
+ }
|
|
|
+};
|
|
|
+const setPageRangeSubCheckStatus = (row, bool) => {
|
|
|
+ setAllCheckStatusInArr(row.children || [], bool);
|
|
|
+ setAllCheckStatusInArr(row.conditions || [], bool);
|
|
|
+ setAllCheckStatusInArr(row.buttons || [], bool);
|
|
|
+ setAllCheckStatusInArr(row.lists || [], bool);
|
|
|
+ setAllCheckStatusInArr(row.links || [], bool);
|
|
|
+};
|
|
|
+const pageRoleChange = (row) => {
|
|
|
+ console.log('rrr', row);
|
|
|
+ setPageRangeSubCheckStatus(row, row.hasRole);
|
|
|
+};
|
|
|
const getDetail = async () => {
|
|
|
let id = route.query.id;
|
|
|
loading.value = true;
|