liuxinyang 1 жил өмнө
parent
commit
513e1ba4ef

+ 1 - 0
lxy

@@ -0,0 +1 @@
+Subproject commit 5aa2f3b462abd10b9ea6dba92f863470b1691eef

+ 9 - 9
mock/api/auth.ts

@@ -62,13 +62,13 @@ const apis: MockMethod[] = [
       const { authorization = '' } = options.headers;
       const REFRESH_TOKEN_CODE = 66666;
 
-      if (!authorization) {
-        return {
-          code: REFRESH_TOKEN_CODE,
-          message: '用户已失效或不存在!',
-          data: null
-        };
-      }
+      // if (!authorization) {
+      //   return {
+      //     code: REFRESH_TOKEN_CODE,
+      //     message: '用户已失效或不存在!',
+      //     data: null
+      //   };
+      // }
       const userInfo: Auth.UserInfo = {
         userId: '',
         userName: '',
@@ -76,14 +76,14 @@ const apis: MockMethod[] = [
       };
       const isInUser = userModel.some(item => {
         const flag = item.token === authorization;
-        if (flag) {
+        if (true) {
           const { userId: itemUserId, userName, userRole } = item;
           Object.assign(userInfo, { userId: itemUserId, userName, userRole });
         }
         return flag;
       });
 
-      if (isInUser) {
+      if (true) {
         return {
           code: 200,
           message: 'ok',

+ 9 - 21
src/service/api/crouse.ts

@@ -1,14 +1,14 @@
 import { request } from '../request';
 // 参数接口 根据相关条件进行查询课程
 export interface SelectByConditionParams {
-  id?: number;
-  name?: string;
-  description?: string;
-  categoryId?: string;
-  createTime?: Record<string, unknown>;
-  modifyTime?: Record<string, unknown>;
-  createUid?: number;
-  disabled?: string;
+  id?: number | null;
+  name?: string| null;
+  description?: string| null;
+  categoryId?: number| null;
+  createTime?: string| null;
+  modifyTime?: string| null;
+  createUid?: number| null;
+  disabled?: string| null;
 }
 
 // 响应接口
@@ -34,7 +34,7 @@ export interface SelectByConditionRes {
  * @param {string} params.disabled 状态
  * @returns
  */
-export function selectByCondition( pageNum: number | undefined, pageSize: number | undefined, params: SelectByConditionParams) {
+export function selectByCondition(pageNum: number | undefined, pageSize: number| undefined, params: SelectByConditionParams) {
   return request.post(`/subject/selectByCondition?pageNum=${pageNum}&pageSize=${pageSize}`, params);
 }
 
@@ -157,15 +157,3 @@ export function selectById(id: number) {
   return request.get(`/subject/selectById?id=${id}`);
 }
 
-// 参数接口
-export interface SelectByConditionParams {
-  id?: number;
-  name?: string;
-  description?: string;
-  categoryId?: string;
-  createTime?: Record<string, unknown>;
-  modifyTime?: Record<string, unknown>;
-  createUid?: number;
-  disabled?: string;
-}
-

+ 6 - 6
src/service/request/instance.ts

@@ -30,10 +30,10 @@ export default class CustomAxiosInstance {
   constructor(
     axiosConfig: AxiosRequestConfig,
     backendConfig: Service.BackendResultConfig = {
-      codeKey: 'code',
+      codeKey: 'status',
       dataKey: 'data',
-      msgKey: 'message',
-      successCode: 200
+      msgKey: 'msg',
+      successCode: true
     }
   ) {
     this.backendConfig = backendConfig;
@@ -51,7 +51,7 @@ export default class CustomAxiosInstance {
           const contentType = handleConfig.headers['Content-Type'] as UnionKey.ContentType;
           handleConfig.data = await transformRequestData(handleConfig.data, contentType);
           // 设置token
-          handleConfig.headers.Authorization = localStg.get('token') || '';
+          //handleConfig.headers.Authorization = localStg.get('token') || '';
         }
         return handleConfig;
       },
@@ -63,11 +63,11 @@ export default class CustomAxiosInstance {
     this.instance.interceptors.response.use(
       (async response => {
         const { status } = response;
-        if (status === 200 || status < 300 || status === 304) {
+        if (status === 200 || status < 300 || status === 304 ) {
           const backend = response.data;
           const { codeKey, dataKey, successCode } = this.backendConfig;
           // 请求成功
-          if (backend[codeKey] === successCode || response.status === 200) {
+          if (backend[codeKey] === successCode || backend.code === 200  ) {
             return handleServiceResult(null, backend[dataKey]);
           }
 

+ 0 - 24
src/typings/api1.d.ts

@@ -24,30 +24,6 @@ declare namespace ApiRoute {
 
 declare namespace ApiUserManagement1 {
   interface User {
-    // /** 用户id */
-    // id: string;
-    // /** 用户名 */
-    // userName: string | null;
-    // /** 用户年龄 */
-    // age: number | null;
-    // /**
-    //  * 用户性别
-    //  * - 0: 女
-    //  * - 1: 男
-    //  */
-    // gender: '0' | '1' | null;
-    // /** 用户手机号码 */
-    // phone: string;
-    // /** 用户邮箱 */
-    // email: string | null;
-    // /**
-    //  * 用户状态
-    //  * - 1: 启用
-    //  * - 2: 禁用
-    //  * - 3: 冻结
-    //  * - 4: 软删除
-    //  */
-    // userStatus: '1' | '2' | '3' | '4' | null;
 		id: number;
     name: string;
 		description: string;

+ 12 - 15
src/views/management/crouse/component/table-action-modal.vue

@@ -39,13 +39,14 @@
 <script setup lang="ts">
 import { ref, computed, reactive, watch } from 'vue';
 import type { FormInst, FormItemRule } from 'naive-ui';
-import { addSubject , updateSubjects } from '~/src/service/api/crouse';
+import { addSubject, updateSubjects, SelectByConditionParams } from '~/src/service/api/crouse';
 import { userStatusOptions } from '@/constants';
-// import type { UpdateSubjectsParams } from '~/src/service/api/crouse';
 import { createRequiredFormRule } from '@/utils';
-import { init } from '../index.vue'
-// import { number } from 'echarts';
+// import { defineEmits } from 'vue';
+// const { proxy } = getCurrentInstance()
+// import init from '../index.vue'
 import dayjs from 'dayjs';
+// import pageData from '../index.vue'
 
 export interface Props {
 	/** 弹窗可见性 */
@@ -57,7 +58,7 @@ export interface Props {
 	 */
 	type?: 'add' | 'edit';
 	/** 编辑的表格行数据 */
-	editData?: UserManagement1.User | null;
+	editData?: SelectByConditionParams | null;
 }
 
 export type ModalType = NonNullable<Props['type']>;
@@ -70,11 +71,11 @@ const props = withDefaults(defineProps<Props>(), {
 });
 
 interface Emits {
-	(e: 'update:visible', visible: boolean): void;
+	(e: 'update:visible', visible: boolean ): void;
 }
 
 const emit = defineEmits<Emits>();
-
+// const emits = defineEmits()
 const modalVisible = computed({
 	get() {
 		return props.visible;
@@ -110,7 +111,7 @@ const rules: Record<keyof FormModel, FormItemRule | FormItemRule[]> = {
 	modifyTime: createRequiredFormRule('请选择用户状态'),
 	createUid: createRequiredFormRule('请选择用户状态'),
 	disabled: createRequiredFormRule('请选择用户状态'),
-	inputValue:createRequiredFormRule('请选择用户状态')
+	inputValue: createRequiredFormRule('请选择用户状态')
 };
 
 function createDefaultFormModel(): FormModel {
@@ -123,7 +124,7 @@ function createDefaultFormModel(): FormModel {
 		modifyTime: '',
 		createUid: 0,
 		disabled: '',
-		inputValue:'',
+		inputValue: '',
 	};
 }
 
@@ -151,11 +152,9 @@ async function handleSubmit() {
 	await formRef.value?.validate();
 	window.$message?.success('新增成功!');
 	addSubject(formModel).then(() => {
-		// location.reload()
-		init();
+		emits('init');
 	})
 	closeModal();
-
 }
 
 async function handleupdate() {
@@ -165,9 +164,7 @@ async function handleupdate() {
 	const timer = dayjs().format('YYYY-MM-DD HH:mm:ss')
 	handleUpdateFormModel({ modifyTime: timer });
 	updateSubjects(formModel).then(() => {
-
-		// location.reload()
-		init();
+		emits('init');
 	})
 	closeModal();
 

+ 89 - 243
src/views/management/crouse/index.vue

@@ -13,87 +13,89 @@
 					</n-button>
 					<n-input-group>
 
-						<n-input :style="{ width: '50%' }" @keyup="serchForm" @change="handleChange" placeholder="输入id查询..." />
-						<n-button type="primary" ghost @click="serchForm()">
-							搜索
-						</n-button>
-					</n-input-group>
-					<n-input-group>
-						<n-input-number :style="{ width: '33%' }"  @input="handleInput1" />
-						<n-input-number :style="{ width: '33%' }"  @input="handleInput2" />
-						<n-button type="primary" @click="serchCondition()">
+
+						<n-input :style="{ width: '50%' }" :value="conditionParams.id" @input="event=>conditionParams.id = event" placeholder="输入查询..." />
+						<n-input :style="{ width: '50%' }" :value="conditionParams.name"  @input="event=>conditionParams.name = event" placeholder="输入查询..." />
+						<n-input :style="{ width: '50%' }" :value="conditionParams.description"  @input="event=>conditionParams.description = event" placeholder="输入查询..." />
+						<n-input :style="{ width: '50%' }" :value="conditionParams.disabled"  @input="event=>conditionParams.disabled = event" placeholder="输入查询..." />
+						<n-input :style="{ width: '50%' }" :value="conditionParams.createTime"  @input="event=>conditionParams.createTime = event" placeholder="输入查询..." />
+						<n-input :style="{ width: '50%' }" :value="conditionParams.categoryId"  @input="event=>conditionParams.categoryId = event" placeholder="输入查询..." />
+						<n-button type="primary" ghost @click="serchCondition()">
 							搜索
 						</n-button>
 					</n-input-group>
 				</n-space>
 			</n-space>
-			<n-data-table v-if="serchFormEr.length > 0 && inputValue !== 0" :columns="columns" :data="serchFormEr"
-				:loading="loading" :pagination="pagination" :row-key="rowKey" @update:checked-row-keys="handleCheck" />
-			<n-data-table v-if="serchFormEr.length <= 0 || inputValue === 0" :columns="columns" :data="pageDate"
-				:loading="loading" :pagination="pagination" :row-key="rowKey" @update:checked-row-keys="handleCheck" />
-			<table-action-modal v-model:visible="visible" :type="modalType" :edit-data="editData" />
+			<n-scrollbar style="max-height: 100vh" trigger="none">
+				<n-data-table :columns="columns" :data="pageDate" :loading="loading" :row-key="rowKey" :pagination="pagination" />
+				<table-action-modal @init="init" v-model:visible="visible" @update:checked-row-keys="handleCheck"
+					:type="modalType" :pagination="pagination" :edit-data="(editData as SelectByConditionParams)" />
+				<div style="width: 100%; height: 300px;"></div>
+			</n-scrollbar>
+
 		</n-card>
+
 	</div>
 </template>
 
-<script lang="tsx">
-import { reactive, ref, defineComponent } from 'vue';
+<script setup lang="tsx">
+import { reactive, ref } from 'vue';
 import type { Ref } from 'vue';
 import { useBoolean, useLoading } from '@/hooks';
 import TableActionModal from './component/table-action-modal.vue';
 import type { ModalType } from './component/table-action-modal.vue';
-import { selectAll, deleteSubjects, selectById, selectByCondition } from '~/src/service/api/crouse';
+import { deleteSubjects, selectByCondition } from '~/src/service/api/crouse';
 import type { SelectByConditionParams } from '~/src/service/api/crouse'
 import { PaginationProps, DataTableColumns, DataTableRowKey, NButton, NPopconfirm, NSpace } from 'naive-ui';
-import { fetchUserList } from '@/service';
-import { number } from 'echarts';
 
-// import { selectByCondition } from '../../../service/api/crouse.ts';
-// import AddView from '~/src/views/management/crouse/component/AddView.vue';
-// const useSelect: SelectByConditionParams = {};
-// const { loading } = useLoading(false);
-const conditionParams: SelectByConditionParams = {};
-const { loading, startLoading, endLoading } = useLoading(false);
+
+
+const conditionParams:SelectByConditionParams = reactive({
+	id: null,
+	name: null,
+	description: null,
+	categoryId: null,
+	createTime: null,
+	modifyTime: null,
+	disabled: null
+});
+
+
+// 输入值
+const form = ref('');
+console.log(form)
+const { loading } = useLoading(false);
 const { bool: visible, setTrue: openModal } = useBoolean();
-// input的值
-const inputValue = ref(0);
-// 接收查询返回的数组
-const serchInput = ref([]) as any;
-const serchFormEr = ref([]);
-// 根据条件查询
-const inputPageNum1 = ref(0);
-const inputPageNum2 = ref(0);
-console.log(inputValue.value)
+
 const pagination: PaginationProps = reactive({
-	page: 1 || number,
-	pageSize: 10 || number,
+	page: 1,
+	pageSize: 10,
 	showSizePicker: true,
-	pageSizes: [10, 15, 20, 25, 30] || number,
-	// onChange: (page: number) => {
-	// 	pagination.page = page;
-	// },
+	pageCount: 12,
+	pageSizes: [10, 15, 20, 25, 30],
 	onUpdatePageSize: (pageSize: number) => {
 		pagination.pageSize = pageSize;
 	},
-	onUpdatePage: (page: number) =>{
+	onUpdatePage: (page: number) => {
 		pagination.page = page;
 	}
 });
-
-const pageDate = ref([]);
+console.log(pagination.page, pagination.pageSize)
 type RowData = {
-	key: number;
-	id: number;
-	select: string;
-	name: string;
-	description: string;
-	categoryId: string;
-	createTime: string;
-	modifyTime: string;
-	createUid: number;
-	disabled: string;
-};
-const columns: Ref<DataTableColumns<UserManagement1.User>> = ref([
+	key: number
+	id: number
+	name: string
+	description: string
+	createTime: string
+	modifyTime: string
+	createUid: number
+	disabled: string
+}
+const rowKey = (row: RowData) => row.id
+const checkedRowKeysRef = ref<DataTableRowKey[]>([]);
+const pageDate = ref([]);
+
+const columns: Ref<DataTableColumns<SelectByConditionParams>> = ref([
 	{
 		type: 'selection',
 		align: 'center'
@@ -143,16 +145,12 @@ const columns: Ref<DataTableColumns<UserManagement1.User>> = ref([
 		title: '操作',
 		align: 'center',
 		render: row => {
-			function handleDeleteTable(value: never[]): any {
-				throw new Error('Function not implemented.');
-			}
-
 			return (
 				<NSpace justify={'center'}>
-					<NButton size={'small'} onClick={() => handleEditTable(row.id)}>
+					<NButton size={'small'} onClick={() => handleEditTable(row)}>
 						编辑
 					</NButton>
-					<NPopconfirm onPositiveClick={() => handleDeleteTable(pageDate.value)}>
+					<NPopconfirm onPositiveClick={() => handleDeleteTable(row.id.toString())}>
 						{{
 							default: () => '确认删除',
 							trigger: () => <NButton size={'small'}>删除</NButton>
@@ -162,58 +160,22 @@ const columns: Ref<DataTableColumns<UserManagement1.User>> = ref([
 			);
 		}
 	}
-]) as Ref<DataTableColumns<UserManagement1.User>>;
-// selectByCondition(pagination.page, pagination.pageSize, useSelect).then(r => {
-//   console.log(r);
-// });
-// eslint-disable-next-line import/no-duplicates
-// import { selectAll } from '../../../service/api/crouse.ts';
-// selectAll().then(r => {
-//   console.log(r);
-// });
-// const useAdd: AddSubjectParams = {
-//   id: 2,
-//   name: '物理',
-//   description: '很难',
-//   categoryId: '理学',
-//   createTime: '',
-//   modifyTime: '',
-//   createUid: 2,
-//   disabled: '1'
-// } as any;
-// 重新加载
-// function handleRefresh() {
-// 	const isCached = routeStore.cacheRoutes.includes(String(route.name));
-// 	if (isCached) {
-// 		routeStore.removeCacheRoute(route.name as AuthRoute.AllRouteKey);
-// 	}
-// 	startLoading();
-// 	app.reloadPage();
-// 	setTimeout(() => {
-// 		if (isCached) {
-// 			routeStore.addCacheRoute(route.name as AuthRoute.AllRouteKey);
-// 		}
-// 		endLoading();
-// 	}, 1000);
-// }
+]) as Ref<DataTableColumns<SelectByConditionParams>>;
+
+
 function handleAddTable() {
 	openModal();
 	setModalType('add');
 	init();
 }
+
+
 // 编辑
-const editData = ref<UserManagement1.User | null>(null);
-function setEditData(data: UserManagement1.User | null) {
+const editData = ref<SelectByConditionParams | null>(null);
+function setEditData(data: SelectByConditionParams | null) {
 	editData.value = data;
-	console.log(editData.value)
 }
-function handleEditTable(rowId: number) {
-	console.log(rowId)
-	// 	selectAll().then(r => {
-	// 	pageDate.value = r.data as [];
-	// });
-	const findItem = pageDate.value.find(item => item.id === rowId);
-	console.log(findItem, pageDate.value)
+function handleEditTable(findItem: SelectByConditionParams) {
 	if (findItem) {
 		setEditData(findItem);
 	}
@@ -221,157 +183,41 @@ function handleEditTable(rowId: number) {
 	openModal();
 }
 
+function handleDeleteTable(rowId: string) {
+	const rowIdNumber = Number(rowId);
+	deleteSubjects(rowIdNumber);
+	init();
+}
+
 const modalType = ref<ModalType>('add' || 'edit');
 function setModalType(type: ModalType) {
 	modalType.value = type;
-	console.log(modalType.value)
 }
-
-selectAll().then(r => {
-	console.log(r)
-	pageDate.value = r.data as [];
-});
-// addSubject(useAdd).then(() => {
-//   selectAll();
-// });
-// const tableData = ref<RowData[]>([]);
-// function setTableData(data: RowData[]) {
-//   tableData.value = data;
-// }
-// 删除
 const s = ref([]) as any;
-const d = ref([]) as any
-function deleteSubjectsList() {
-	if (s.value.length !== 0) {
-		for (let i = 0; i < s.value.length; i++) {
-			deleteSubjects(s.value[i]).then((r) => {
-				// handleRefresh();
-				console.log(r)
-				console.log(s.value.length)
-				d.value.id = s.value[i].id
-				// for(let j = 0;j<d.value.length;j++){
-				// 	if(d.value[j].id === s.value[j].id){
-				// 		s.value.length = 0
-				// 	}
-				// }
-				console.log(s.value[i].id)
-			});
-		}
 
+function deleteSubjectsList() {
+	const difference = checkedRowKeysRef.value.filter(item => !s.value.includes(item));
+	s.value = checkedRowKeysRef.value
+	for (let i = 0; i < difference.length; i++) {
+		deleteSubjects(Number(difference[i]));
 	}
-	s.value = [];
-	console.log(s.value.length)
-	if (s.value.length == 0) {
-		console.log(s.value.length)
-		window.$message?.success('删除成功!');
-	}
-
-
 	init();
 }
-// function handleDeleteTable(rowId) {
-//   window.$message?.info(`点击了删除,rowId为${rowId}`);
-// }
-
-async function getTableData() {
-	startLoading();
-	const { data } = await fetchUserList();
-	if (data) {
-		setTimeout(() => {
-			// setTableData(data);
-			selectAll().then((r) => [
-				pageDate.value = r.data as []
-			]);
-			endLoading();
-		}, 1000);
-	}
+function handleCheck(rowKeys: DataTableRowKey[]) {
+	checkedRowKeysRef.value = rowKeys;
 }
-
-// deleteSubjects(r: RowData)
-export default defineComponent({
-	components: { TableActionModal },
-	setup() {
-		// console.log(pageDate.value)
-		const checkedRowKeysRef = ref<DataTableRowKey[]>([]);
-		return {
-			columns,
-			inputPageNum1,
-			inputPageNum2,
-			loading,
-			inputValue,
-			NButton,
-			NPopconfirm,
-			NSpace,
-			conditionParams,
-			serchInput,
-			pageDate,
-			checkedRowKeys: checkedRowKeysRef,
-			pagination,
-			deleteSubjects,
-			deleteSubjectsList,
-			handleEditTable,
-			// handleRefresh,
-			visible,
-			serchFormEr,
-			editData,
-			modalType,
-			handleAddTable,
-			openModal,
-			setModalType,
-			useBoolean, useLoading,
-			rowKey: (row: RowData) => row.id,
-			handleCheck(rowKeys: DataTableRowKey[]) {
-				checkedRowKeysRef.value = rowKeys;
-				// rowKeys.splice(0);
-				// console.log(rowKeys)
-				s.value = checkedRowKeysRef.value
-				// rowKeys = []
-				// d.length = 0
-				// rowKeys.length = 0
-			},
-			// 根据条件查询
-			handleInput1(v: number) {
-				inputPageNum1.value = v;
-				// pagination.page = inputPageNum1.value.data;
-
-			},
-			handleInput2(v: number) {
-				inputPageNum2.value = v;
-				// pagination.pageSize = inputPageNum2.value.data;
-			},
-			// 根据id查询
-			handleChange(v: string) {
-				inputValue.value = Number(v)
-			},
-			async serchForm() {
-				await selectById(inputValue.value).then(r => {
-					console.log(inputValue.value)
-					serchInput.value = r.data as [];
-					const filteredItems = Object.values(pageDate.value.filter(item => item.id === serchInput.value.id))
-					// console.log(filteredItems,Array.isArray(filteredItems))
-					serchFormEr.value = filteredItems;
-					console.log(serchFormEr.value)
-				})
-			},
-			async serchCondition() {
-				await selectByCondition(inputPageNum1.value.data, inputPageNum2.value.data, conditionParams).then(r => {
-					console.log(r)
-					pageDate.value = r.data as [];
-					pagination.page = inputPageNum1.value.data;
-					pagination.pageSize = inputPageNum2.value.data;
-					// console.log(inputPageNum1.value.data, pagination.page)
-				})
-				// console.log(inputPageNum1.value.data, inputPageNum2.value.data)
-			}
-		};
-	}
-});
-export function init() {
-	getTableData();
+function serchCondition() {
+	selectByCondition(pagination.page, pagination.pageSize, conditionParams).then(r => {
+		pageDate.value = r.data as [];
+	}).catch(() => {
+		console.log('jdias')
+	})
+}
+function init() {
+	serchCondition();
 }
 
 // 初始化
 init();
 </script>
-
 <style scoped></style>

+ 1 - 0
src/views/management/role/index.vue

@@ -71,6 +71,7 @@ const columns: Ref<DataTableColumns<QueryParams>> = ref([
 ]) as Ref<DataTableColumns<QueryParams>>;
 query(pagination.page, pagination.pageSize, UserQuery).then(result => {
   pageDate.value = result.data as [];
+	console.log(UserQuery,'kkkk')
 });
 </script>
 

+ 1 - 1
src/views/management/user/index.vue

@@ -180,7 +180,7 @@ function handleDeleteTable(rowId: string) {
 
 const pagination: PaginationProps = reactive({
   page: 1,
-  pageSize: 10,
+  pageSize: 100,
   showSizePicker: true,
   pageSizes: [10, 15, 20, 25, 30],
   onChange: (page: number) => {