Просмотр исходного кода

增加接口管理,城市管理 ,定时任务页面的权限

yanglzh 2 лет назад
Родитель
Сommit
48301f9813
3 измененных файлов с 222 добавлено и 224 удалено
  1. 70 70
      src/views/system/api/index.vue
  2. 139 140
      src/views/system/city/index.vue
  3. 13 14
      src/views/system/task/index.vue

+ 70 - 70
src/views/system/api/index.vue

@@ -1,58 +1,58 @@
 <template>
-	<div class="page">
-		<el-card shadow="hover">
-			<div class="search">
-				<el-form :inline="true">
-					<el-form-item label="接口名称">
-						<el-input v-model="params.name" placeholder="请输入接口名称" clearablestyle="width: 240px" @keyup.enter.native="getList(1)" />
-					</el-form-item>
-					<el-form-item label="接口地址">
-						<el-input v-model="params.address" placeholder="请输入接口地址" clearablestyle="width: 240px" @keyup.enter.native="getList(1)" />
-					</el-form-item>
-					<el-form-item label="状态" prop="status" style="width: 200px">
-						<el-select v-model="params.status" placeholder="接口状态" clearablestyle="width: 240px">
-							<el-option label="全部" :value="-1" />
-							<el-option label="启用" :value="1" />
-							<el-option label="禁用" :value="0" />
-						</el-select>
-					</el-form-item>
-					<el-form-item>
-						<el-button size="default" type="primary" class="ml10" @click="getList(1)">
-							<el-icon>
-								<ele-Search />
-							</el-icon>
-							查询
-						</el-button>
-						<el-button type="success" @click="addOrEdit()">
-							<el-icon>
-								<ele-FolderAdd />
-							</el-icon>
-							新增接口
-						</el-button>
-					</el-form-item>
-				</el-form>
-			</div>
-			<el-table :data="tableData" style="width: 100%" v-loading="loading">
-				<el-table-column type="index" label="序号" width="60" align="center" />
-				<el-table-column prop="name" label="接口名称" show-overflow-tooltip></el-table-column>
-				<el-table-column prop="address" label="接口地址" show-overflow-tooltip></el-table-column>
-				<el-table-column prop="status" label="状态" min-width="100" align="center">
-					<template #default="scope">
-						<el-tag type="success" size="small" v-if="scope.row.status">启用</el-tag>
-						<el-tag type="info" size="small" v-else>禁用</el-tag>
-					</template>
-				</el-table-column>
-				<el-table-column label="操作" width="100" align="center">
-					<template #default="scope">
-						<el-button size="small" text type="warning" @click="addOrEdit(scope.row)">修改</el-button>
-						<el-button size="small" text type="danger" @click="onDel(scope.row)">删除</el-button>
-					</template>
-				</el-table-column>
-			</el-table>
-			<pagination v-if="params.total" :total="params.total" v-model:page="params.pageNum" v-model:limit="params.pageSize" @pagination="getList()" />
-		</el-card>
-		<EditForm ref="editFormRef" @getList="getList()"></EditForm>
-	</div>
+  <div class="page">
+    <el-card shadow="hover">
+      <div class="search">
+        <el-form :inline="true">
+          <el-form-item label="接口名称">
+            <el-input v-model="params.name" placeholder="请输入接口名称" clearablestyle="width: 240px" @keyup.enter.native="getList(1)" />
+          </el-form-item>
+          <el-form-item label="接口地址">
+            <el-input v-model="params.address" placeholder="请输入接口地址" clearablestyle="width: 240px" @keyup.enter.native="getList(1)" />
+          </el-form-item>
+          <el-form-item label="状态" prop="status" style="width: 200px">
+            <el-select v-model="params.status" placeholder="接口状态" clearablestyle="width: 240px">
+              <el-option label="全部" :value="-1" />
+              <el-option label="启用" :value="1" />
+              <el-option label="禁用" :value="0" />
+            </el-select>
+          </el-form-item>
+          <el-form-item>
+            <el-button size="default" type="primary" class="ml10" @click="getList(1)">
+              <el-icon>
+                <ele-Search />
+              </el-icon>
+              查询
+            </el-button>
+            <el-button type="success" @click="addOrEdit()" v-auth="'add'">
+              <el-icon>
+                <ele-FolderAdd />
+              </el-icon>
+              新增接口
+            </el-button>
+          </el-form-item>
+        </el-form>
+      </div>
+      <el-table :data="tableData" style="width: 100%" v-loading="loading">
+        <el-table-column type="index" label="序号" width="60" align="center" />
+        <el-table-column prop="name" v-col="'name'" label="接口名称" show-overflow-tooltip></el-table-column>
+        <el-table-column prop="address" v-col="'address'" label="接口地址" show-overflow-tooltip></el-table-column>
+        <el-table-column prop="status" v-col="'status'" label="状态" min-width="100" align="center">
+          <template #default="scope">
+            <el-tag type="success" size="small" v-if="scope.row.status">启用</el-tag>
+            <el-tag type="info" size="small" v-else>禁用</el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column label="操作" width="100" align="center" v-col="'handle'">
+          <template #default="scope">
+            <el-button size="small" text type="warning" @click="addOrEdit(scope.row)" v-auth="'edit'">修改</el-button>
+            <el-button size="small" text type="danger" @click="onDel(scope.row)" v-auth="'del'">删除</el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+      <pagination v-if="params.total" :total="params.total" v-model:page="params.pageNum" v-model:limit="params.pageSize" @pagination="getList()" />
+    </el-card>
+    <EditForm ref="editFormRef" @getList="getList()"></EditForm>
+  </div>
 </template>
 
 <script lang="ts" setup>
@@ -70,24 +70,24 @@ const { params, tableData, getList, loading } = useSearch<ApiRow[]>(api.api.getL
 getList();
 
 const addOrEdit = async (row?: ApiRow) => {
-	if (row) {
-		const res = await api.api.detail(row.id as number);
-		editFormRef.value.open(res);
-		return;
-	} else {
-		editFormRef.value.open();
-	}
+  if (row) {
+    const res = await api.api.detail(row.id as number);
+    editFormRef.value.open(res);
+    return;
+  } else {
+    editFormRef.value.open();
+  }
 };
 
 const onDel = (row: ApiRow) => {
-	ElMessageBox.confirm(`此操作将删除接口:“${row.name}”,是否继续?`, '提示', {
-		confirmButtonText: '确认',
-		cancelButtonText: '取消',
-		type: 'warning',
-	}).then(async () => {
-		await api.api.del(row.id as number);
-		ElMessage.success('删除成功');
-		getList();
-	});
+  ElMessageBox.confirm(`此操作将删除接口:“${row.name}”,是否继续?`, '提示', {
+    confirmButtonText: '确认',
+    cancelButtonText: '取消',
+    type: 'warning',
+  }).then(async () => {
+    await api.api.del(row.id as number);
+    ElMessage.success('删除成功');
+    getList();
+  });
 };
 </script>

+ 139 - 140
src/views/system/city/index.vue

@@ -6,7 +6,7 @@
           <el-form-item label="城市名称" prop="name">
             <el-input v-model="tableData.param.name" placeholder="请输入城市名称" clearable size="default" @keyup.enter="queryList" />
           </el-form-item>
-		  		<el-form-item label="城市编号" prop="code">
+          <el-form-item label="城市编号" prop="code">
             <el-input v-model="tableData.param.code" placeholder="请输入城市编号" clearable size="default" @keyup.enter="queryList" />
           </el-form-item>
           <el-form-item>
@@ -22,7 +22,7 @@
               </el-icon>
               重置
             </el-button>
-            <el-button size="default" type="success" class="ml10" @click="onOpenAddDic">
+            <el-button size="default" type="success" class="ml10" @click="onOpenAddDic" v-auth="'add'">
               <el-icon>
                 <ele-FolderAdd />
               </el-icon>
@@ -31,23 +31,22 @@
           </el-form-item>
         </el-form>
       </div>
-			
-      <el-table :data="tableData.data" v-loading="tableData.loading" style="width: 100%"  row-key="id" default-expand-all :indent="16" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
-	    	<el-table-column label="城市名称" prop="name" :show-overflow-tooltip="true" />
-	    	<el-table-column label="城市编号" prop="code" :show-overflow-tooltip="true" />
-	    	<el-table-column label="状态" prop="status" width="80">
-                <template #default="scope">
-					{{ scope.row.status === 1 ? '在线' : '不在线' }}
-                </template>
-            </el-table-column>
-			<el-table-column label="排序" prop="sort" align="center" />
-	    	<el-table-column label="创建时间" prop="createdAt" :show-overflow-tooltip="true" />
-            <el-table-column label="操作" width="200" align="center">
-            <template #default="scope">
-			 	<!-- <el-button size="small" text type="primary" @click="onOpenDetail(scope.row)">详情</el-button> -->
-                <el-button size="small" text type="warning" @click="onOpenEditDic(scope.row)">修改</el-button>
-                <el-button size="small" text type="danger" @click="onRowDel(scope.row)">删除</el-button>
-            </template>
+
+      <el-table :data="tableData.data" v-loading="tableData.loading" style="width: 100%" row-key="id" default-expand-all :indent="16" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
+        <el-table-column label="城市名称" v-col="'name'" prop="name" :show-overflow-tooltip="true" />
+        <el-table-column label="城市编号" v-col="'code'" prop="code" :show-overflow-tooltip="true" />
+        <el-table-column label="状态" v-col="'status'" prop="status" width="80">
+          <template #default="scope">
+            {{ scope.row.status === 1 ? '在线' : '不在线' }}
+          </template>
+        </el-table-column>
+        <el-table-column label="排序" v-col="'sort'" prop="sort" align="center" />
+        <el-table-column label="创建时间" prop="createdAt" v-col="'createdAt'" :show-overflow-tooltip="true" />
+        <el-table-column label="操作" width="200" align="center" v-col="'handle'">
+          <template #default="scope">
+            <el-button size="small" text type="warning" @click="onOpenEditDic(scope.row)" v-auth="'edit'">修改</el-button>
+            <el-button size="small" text type="danger" @click="onRowDel(scope.row)" v-auth="'del'">删除</el-button>
+          </template>
         </el-table-column>
       </el-table>
       <pagination v-show="tableData.total>0" :total="tableData.total" v-model:page="tableData.param.pageNum" v-model:limit="tableData.param.pageSize" @pagination="queryList" />
@@ -66,132 +65,132 @@ import api from '/@/api/system';
 
 // 定义接口来定义对象的类型
 interface TableDataRow {
-	id: number;
-	name: string;
-	code: string;
-	stationId: string;
-	loopTypes: number;
-	energyTypes: number;
-	heatingObject: number;
-	heatingTypes: number;
-	heatingArea: string;
-	forRealArea: string;
-	decade: string;
-	status: number;
+  id: number;
+  name: string;
+  code: string;
+  stationId: string;
+  loopTypes: number;
+  energyTypes: number;
+  heatingObject: number;
+  heatingTypes: number;
+  heatingArea: string;
+  forRealArea: string;
+  decade: string;
+  status: number;
 }
 interface TableDataState {
-	ids: number[];
-	tableData: {
-		data: Array<TableDataRow>;
-		loading: boolean;
-		param: {
-			name: string;
-			code: string;
-			status: number;
-		};
-	};
+  ids: number[];
+  tableData: {
+    data: Array<TableDataRow>;
+    loading: boolean;
+    param: {
+      name: string;
+      code: string;
+      status: number;
+    };
+  };
 }
 
 export default defineComponent({
-	name: 'cityManage',
-	components: { EditDic },
-	setup() {
-		const addDicRef = ref();
-		const editDicRef = ref();
-		// const detailRef = ref();
-		const queryRef = ref();
-		const state = reactive<TableDataState>({
-			ids: [],
-			tableData: {
-				data: [],
-				loading: false,
-				param: {
-					name: '',
-					code: '',
-					status: -1
-				},
-			},
-		});
-		// 初始化表格数据
-		const initTableData = () => {
-			queryList();
-		};
-		const queryList = () => {
-			state.tableData.loading = true
-			api.city.getList(state.tableData.param)
-				.then((res: any) => {
-					state.tableData.data = res || [];
-					state.tableData.loading = false
-				});
-		};
+  name: 'cityManage',
+  components: { EditDic },
+  setup() {
+    const addDicRef = ref();
+    const editDicRef = ref();
+    // const detailRef = ref();
+    const queryRef = ref();
+    const state = reactive<TableDataState>({
+      ids: [],
+      tableData: {
+        data: [],
+        loading: false,
+        param: {
+          name: '',
+          code: '',
+          status: -1
+        },
+      },
+    });
+    // 初始化表格数据
+    const initTableData = () => {
+      queryList();
+    };
+    const queryList = () => {
+      state.tableData.loading = true
+      api.city.getList(state.tableData.param)
+        .then((res: any) => {
+          state.tableData.data = res || [];
+          state.tableData.loading = false
+        });
+    };
 
-		// //查看详情
-		// const onOpenDetail=(row: TableDataRow)=>{
-		// 	detailRef.value.openDialog(row);
-		// }
-		// 打开新增产品弹窗
-		const onOpenAddDic = () => {
-			editDicRef.value.openDialog(null, state.tableData.data);
-		};
-		// 打开修改产品弹窗
-		const onOpenEditDic = (row: TableDataRow) => {
-			editDicRef.value.openDialog(row, state.tableData.data);
-		};
-		// 删除产品
-		const onRowDel = (row: TableDataRow) => {
-			let msg = '你确定要删除所选数据?';
-			// let ids: number[] = [];
-			// if (row) {
-			msg = `此操作将永久删除设备:“${row.name}”,是否继续?`;
-				// ids = [row.id];
-			// } else {
-			// 	ids = state.ids;
-			// }
-			// if (ids.length === 0) {
-			// 	ElMessage.error('请选择要删除的数据。');
-			// 	return;
-			// }
-			ElMessageBox.confirm(msg, '提示', {
-				confirmButtonText: '确认',
-				cancelButtonText: '取消',
-				type: 'warning',
-			})
-				.then(() => {
-					api.city.del(row.id).then(() => {
-						ElMessage.success('删除成功');
-						queryList();
-					});
-				})
-				.catch(() => {});
-		};
-		// 页面加载时
-		onMounted(() => {
-			initTableData();
-		});
-		/** 重置按钮操作 */
-		const resetQuery = (formEl: FormInstance | undefined) => {
-			if (!formEl) return;
-			formEl.resetFields();
-			queryList();
-		};
-		// 多选框选中数据
-		const handleSelectionChange = (selection: TableDataRow[]) => {
-			state.ids = selection.map((item) => item.id);
-		};
-		return {
-			addDicRef,
-			editDicRef,
-			// detailRef,
-			queryRef,
-			// onOpenDetail,
-			onOpenAddDic,
-			onOpenEditDic,
-			onRowDel,
-			queryList,
-			resetQuery,
-			handleSelectionChange,
-			...toRefs(state),
-		};
-	},
+    // //查看详情
+    // const onOpenDetail=(row: TableDataRow)=>{
+    // 	detailRef.value.openDialog(row);
+    // }
+    // 打开新增产品弹窗
+    const onOpenAddDic = () => {
+      editDicRef.value.openDialog(null, state.tableData.data);
+    };
+    // 打开修改产品弹窗
+    const onOpenEditDic = (row: TableDataRow) => {
+      editDicRef.value.openDialog(row, state.tableData.data);
+    };
+    // 删除产品
+    const onRowDel = (row: TableDataRow) => {
+      let msg = '你确定要删除所选数据?';
+      // let ids: number[] = [];
+      // if (row) {
+      msg = `此操作将永久删除设备:“${row.name}”,是否继续?`;
+      // ids = [row.id];
+      // } else {
+      // 	ids = state.ids;
+      // }
+      // if (ids.length === 0) {
+      // 	ElMessage.error('请选择要删除的数据。');
+      // 	return;
+      // }
+      ElMessageBox.confirm(msg, '提示', {
+        confirmButtonText: '确认',
+        cancelButtonText: '取消',
+        type: 'warning',
+      })
+        .then(() => {
+          api.city.del(row.id).then(() => {
+            ElMessage.success('删除成功');
+            queryList();
+          });
+        })
+        .catch(() => { });
+    };
+    // 页面加载时
+    onMounted(() => {
+      initTableData();
+    });
+    /** 重置按钮操作 */
+    const resetQuery = (formEl: FormInstance | undefined) => {
+      if (!formEl) return;
+      formEl.resetFields();
+      queryList();
+    };
+    // 多选框选中数据
+    const handleSelectionChange = (selection: TableDataRow[]) => {
+      state.ids = selection.map((item) => item.id);
+    };
+    return {
+      addDicRef,
+      editDicRef,
+      // detailRef,
+      queryRef,
+      // onOpenDetail,
+      onOpenAddDic,
+      onOpenEditDic,
+      onRowDel,
+      queryList,
+      resetQuery,
+      handleSelectionChange,
+      ...toRefs(state),
+    };
+  },
 });
 </script>

+ 13 - 14
src/views/system/task/index.vue

@@ -31,13 +31,13 @@
               </el-icon>
               重置
             </el-button>
-            <el-button size="default" type="success" class="ml10" @click="onOpenAddDic">
+            <el-button size="default" type="success" class="ml10" @click="onOpenAddDic" v-auth="'add'">
               <el-icon>
                 <ele-FolderAdd />
               </el-icon>
               新增任务
             </el-button>
-            <el-button size="default" type="danger" class="ml10" @click="onRowDel(null)">
+            <el-button size="default" type="danger" class="ml10" @click="onRowDel(null)" v-auth="'del'">
               <el-icon>
                 <ele-Delete />
               </el-icon>
@@ -48,24 +48,24 @@
       </div>
       <el-table :data="tableData.data" style="width: 100%" @selection-change="handleSelectionChange" v-loading="tableData.loading">
         <el-table-column type="selection" width="55" align="center" />
-        <el-table-column label="ID" align="center" prop="jobId" width="60" />
-        <el-table-column label="任务名称" prop="jobName" :show-overflow-tooltip="true" />
-        <el-table-column label="任务描述" prop="remark" show-overflow-tooltip />
-        <el-table-column label="任务分组" prop="jobGroup" width="120" :formatter="jobGroupFormat" />
-        <el-table-column label="任务方法名" prop="invokeTarget" />
-        <el-table-column label="cron执行表达式" prop="cronExpression" />
-        <el-table-column label="状态" align="center" prop="status" width="100">
+        <el-table-column label="ID" align="center" v-col="'jobId'" prop="jobId" width="60" />
+        <el-table-column label="任务名称" v-col="'jobName'" prop="jobName" :show-overflow-tooltip="true" />
+        <el-table-column label="任务描述" v-col="'remark'" prop="remark" show-overflow-tooltip />
+        <el-table-column label="任务分组" v-col="'jobGroup'" prop="jobGroup" width="120" :formatter="jobGroupFormat" />
+        <el-table-column label="任务方法名" v-col="'invokeTarget'" prop="invokeTarget" />
+        <el-table-column label="cron执行表达式" v-col="'cronExpression'" prop="cronExpression" />
+        <el-table-column label="状态" v-col="'status'" align="center" prop="status" width="100">
           <template #default="scope">
             <!-- {{ row.status ? '正常' : '暂停' }} -->
             <el-switch v-model="scope.row.status" inline-prompt :active-value="0" :inactive-value="1" active-text="启" inactive-text="禁" @change="handleStatusChange(scope.row)">
             </el-switch>
           </template>
         </el-table-column>
-        <el-table-column label="操作" width="180" align="center" fixed="right">
+        <el-table-column label="操作" width="180" align="center" fixed="right" v-col="'handle'">
           <template #default="scope">
-            <el-button size="small" text type="warning" @click="onOpenEditDic(scope.row)">修改</el-button>
-            <el-button size="small" text type="danger" @click="onRowDel(scope.row)">删除</el-button>
-            <el-button size="small" text type="primary" @click="onRowRun(scope.row)">执行一次</el-button>
+            <el-button size="small" text type="warning" @click="onOpenEditDic(scope.row)" v-auth="'edit'">修改</el-button>
+            <el-button size="small" text type="danger" @click="onRowDel(scope.row)" v-auth="'del'">删除</el-button>
+            <el-button size="small" text type="primary" @click="onRowRun(scope.row)" v-auth="'do'">执行一次</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -229,7 +229,6 @@ export default defineComponent({
       state.ids = selection.map((item) => item.jobId);
     };
     const jobGroupFormat = (row: TableDataRow) => {
-      console.log(row);
       return proxy.selectDictLabel(unref(sys_job_group), row.jobGroup);
     };
     return {