Переглянути джерело

增加证书管理列表中的状态显示及启用停用操作

yanglzh 2 роки тому
батько
коміт
c4aa8d3356

+ 3 - 1
src/api/certificateManagement/index.ts

@@ -5,8 +5,10 @@ const baseUrl = getOrigin(import.meta.env.VITE_SERVER_URL);
 export default {
   certificateManagement: {
     getList: (params: object) => get('/system/certificate/list', params),
+    getAll: () => get('/system/certificate/getAll'),
     add: (data: object) => post('/system/certificate/add', data),
     edit: (data: object) => put('/system/certificate/edit', data),
     del: (id: number) => del('/system/certificate/delete', { id }),
+    editStatus: (data: object) => post('/system/certificate/editStatus', data),
   }
-}
+}

+ 80 - 63
src/views/iot/certificate/index.vue

@@ -1,67 +1,66 @@
 <template>
-  <div class="system-dic-container">
-    <el-card shadow="hover">
-      <div class="system-user-search mb15">
-        <el-form :model="state.tableData.param" ref="queryRef" :inline="true" label-width="60px">
-          <el-form-item label="关键字" prop="keyWord">
-            <el-input v-model="state.tableData.param.name" placeholder="请输入关键字" clearable size="default" @keyup.enter="queryList" />
-          </el-form-item>
-          <el-form-item>
-            <el-button v-auth="'query'" size="default" type="primary" class="ml10" @click="queryList">
-              <el-icon>
-                <ele-Search />
-              </el-icon>
-              查询
-            </el-button>
-            <el-button v-auth="'reset'" size="default" @click="resetQuery(queryRef)">
-              <el-icon>
-                <ele-Refresh />
-              </el-icon>
-              重置
-            </el-button>
-			<el-button v-auth="'add'" size="default" type="success" class="ml10" @click="operate('add')">
-				<el-icon>
-					<ele-FolderAdd />
-				</el-icon>
-				新增证书
-			</el-button>
-          </el-form-item>
-        </el-form>
-      </div>
+	<div class="system-dic-container">
+		<el-card shadow="hover">
+			<div class="system-user-search mb15">
+				<el-form :model="state.tableData.param" ref="queryRef" :inline="true" label-width="60px">
+					<el-form-item label="关键字" prop="keyWord">
+						<el-input v-model="state.tableData.param.name" placeholder="请输入关键字" clearable size="default" @keyup.enter="queryList" />
+					</el-form-item>
+					<el-form-item>
+						<el-button v-auth="'query'" size="default" type="primary" class="ml10" @click="queryList">
+							<el-icon>
+								<ele-Search />
+							</el-icon>
+							查询
+						</el-button>
+						<el-button v-auth="'reset'" size="default" @click="resetQuery(queryRef)">
+							<el-icon>
+								<ele-Refresh />
+							</el-icon>
+							重置
+						</el-button>
+						<el-button v-auth="'add'" size="default" type="success" class="ml10" @click="operate('add')">
+							<el-icon>
+								<ele-FolderAdd />
+							</el-icon>
+							新增证书
+						</el-button>
+					</el-form-item>
+				</el-form>
+			</div>
 			<!--  -->
-      <el-table :data="state.tableData.data" v-loading="state.tableData.loading" style="width: 100%">
-        <!-- <el-table-column type="selection" width="55" align="center" /> -->
-        <el-table-column v-col="'id'" label="ID" align="center" prop="id" width="60" />
-	    	<el-table-column v-col="'name'" label="证书名称" prop="name" min-width="120" :show-overflow-tooltip="true" />
-	    	<el-table-column v-col="'standard'" label="证书标准" prop="standard" min-width="120" :show-overflow-tooltip="true">
-				<template #default="scope">
-					{{filterStandard(scope.row.standard)}}
-                <!-- <el-button size="small" text type="primary" @click="operate('editParams', scope.row)">编辑</el-button> -->
-                <!-- <el-button size="small" text type="danger" @click="operate('delete', scope.row)">删除</el-button> -->
-            	</template>
-            </el-table-column>
-			<el-table-column v-col="'description'" label="说明" prop="description" min-width="120" :show-overflow-tooltip="true" />
-			<el-table-column v-col="'handle'"  label="操作" width="280" align="center" fixed="right">
-            <template #default="scope">
-                <el-button size="small" v-auth="'edit'" text type="primary" @click="operate('editParams', scope.row)">编辑</el-button>
-                <el-button size="small" v-auth="'del'" text type="danger" @click="operate('delete', scope.row)">删除</el-button>
-            </template>
-            </el-table-column>
-      </el-table>
-      <pagination
-				v-show="state.tableData.total>0"
-				:total="state.tableData.total"
-				v-model:page="state.tableData.param.pageNum"
-				v-model:limit="state.tableData.param.pageSize"
-				@pagination="queryList"
-			/>
-    </el-card>
-	<EditParams ref="editParamsRef" @update="queryList"/>
-  </div>
+			<el-table :data="state.tableData.data" v-loading="state.tableData.loading" style="width: 100%">
+				<!-- <el-table-column type="selection" width="55" align="center" /> -->
+				<el-table-column v-col="'id'" label="ID" align="center" prop="id" width="60" />
+				<el-table-column v-col="'name'" label="证书名称" prop="name" min-width="120" :show-overflow-tooltip="true" />
+				<el-table-column v-col="'standard'" label="证书标准" prop="standard" min-width="120" :show-overflow-tooltip="true">
+					<template #default="scope">
+						{{ filterStandard(scope.row.standard) }}
+						<!-- <el-button size="small" text type="primary" @click="operate('editParams', scope.row)">编辑</el-button> -->
+						<!-- <el-button size="small" text type="danger" @click="operate('delete', scope.row)">删除</el-button> -->
+					</template>
+				</el-table-column>
+				<el-table-column v-col="'description'" label="说明" prop="description" min-width="120" :show-overflow-tooltip="true" />
+				<el-table-column label="状态" width="120" align="center">
+					<template #default="scope">
+						<el-switch v-model="scope.row.status" inline-prompt :active-value="1" :inactive-value="0" active-text="启" inactive-text="禁" @change="handleStatusChange(scope.row)"></el-switch>
+					</template>
+				</el-table-column>
+				<el-table-column v-col="'handle'" label="操作" width="180" align="center" fixed="right">
+					<template #default="scope">
+						<el-button size="small" v-auth="'edit'" text type="primary" @click="operate('editParams', scope.row)">编辑</el-button>
+						<el-button size="small" v-auth="'del'" text type="danger" @click="operate('delete', scope.row)">删除</el-button>
+					</template>
+				</el-table-column>
+			</el-table>
+			<pagination v-show="state.tableData.total > 0" :total="state.tableData.total" v-model:page="state.tableData.param.pageNum" v-model:limit="state.tableData.param.pageSize" @pagination="queryList" />
+		</el-card>
+		<EditParams ref="editParamsRef" @update="queryList" />
+	</div>
 </template>
 
 <script lang="ts" setup>
-import {  reactive, onMounted, ref, getCurrentInstance } from 'vue';
+import { reactive, onMounted, ref, getCurrentInstance } from 'vue';
 import { ElMessageBox, ElMessage, FormInstance } from 'element-plus';
 import api from '/@/api/certificateManagement';
 import EditParams from './component/editParams.vue';
@@ -81,10 +80,10 @@ const state = reactive({
 		param: {
 			pageNum: 1,
 			PageSize: 10,
-            status: -1,
+			status: -1,
 			name: ""
 		},
-        total: 0
+		total: 0
 	},
 });
 // 初始化表格数据
@@ -106,6 +105,24 @@ const filterStandard = (type: any) => {
 	})
 	return opt[0]?.label
 }
+// 状态修改
+const handleStatusChange = (row: any) => {
+	let text = row.status === 1 ? '启用' : '停用';
+	ElMessageBox.confirm('确认要"' + text + '":"' + row.name + '"楼宇吗?', '警告', {
+		confirmButtonText: '确定',
+		cancelButtonText: '取消',
+		type: 'warning',
+	})
+		.then(function () {
+			return api.certificateManagement.editStatus({ id: row.id, status: row.status });
+		})
+		.then(() => {
+			ElMessage.success(text + '成功');
+		})
+		.catch(function () {
+			row.status = row.status === 0 ? 1 : 0;
+		});
+};
 
 // 页面加载时
 onMounted(() => {
@@ -119,7 +136,7 @@ const resetQuery = (formEl: FormInstance | undefined) => {
 };
 
 const operate = (type: string, row: any) => {
-	switch(type) {
+	switch (type) {
 		case 'preview':
 			console.log(previewRef.value)
 			previewRef.value.openDialog(row)
@@ -146,7 +163,7 @@ const operate = (type: string, row: any) => {
 						queryList();
 					});
 				})
-				.catch(() => {});
+				.catch(() => { });
 			break
 	}
 }

+ 1 - 6
src/views/iot/device/product/component/editPro.vue

@@ -199,13 +199,8 @@ export default defineComponent({
 			});
 
 			// 证书列表
-			certApi.certificateManagement.getList({
-				pageNum: 1,
-				PageSize: 50,
-				status: -1,
-			}).then((res: any) => {
+			certApi.certificateManagement.getAll().then((res: any) => {
 				certList.value = res.Info || []
-				console.log(res.Info[0])
 			});
 			// api.product.trunsport_protocol_list({ status: -1 }).then((res: any) => {
 			//   state.tranData = res.data || [];