Jelajahi Sumber

修改规则引擎表格显示字段,增加 启动、停止的操作

yanglzh 3 tahun lalu
induk
melakukan
f2ab590d57
3 mengubah file dengan 48 tambahan dan 20 penghapusan
  1. 2 0
      src/api/rule/index.ts
  2. 23 10
      src/views/rule-engine/index.vue
  3. 23 10
      src/views/rule-engine/send.vue

+ 2 - 0
src/api/rule/index.ts

@@ -11,4 +11,6 @@ export default {
   add: (data: any) => post('/rule-engine/instance/add', data),
   // 编辑规则实例管理
   edit: (data: any) => put('/rule-engine/instance/edit', data),
+  // 修改规则实例流程状态
+  setStatus: (id: number, status: number) => post('/rule-engine/instance/status', { id, status }),
 }

+ 23 - 10
src/views/rule-engine/index.vue

@@ -20,18 +20,19 @@
 		</div>
 		<el-table :data="tableData" style="width: 100%" v-loading="loading">
 			<el-table-column type="index" label="序号" width="80" align="center" />
-			<el-table-column prop="flowId" label="流程ID" show-overflow-tooltip></el-table-column>
-			<el-table-column prop="name" label="项目名称" show-overflow-tooltip></el-table-column>
+			<el-table-column prop="name" label="名称" show-overflow-tooltip></el-table-column>
+			<el-table-column prop="expound" label="说明" show-overflow-tooltip></el-table-column>
 			<el-table-column prop="createdAt" label="创建时间" min-width="100" align="center"></el-table-column>
 			<el-table-column prop="status" label="状态" width="100" align="center">
-          <template #default="scope">
-            <el-tag type="success" size="small" v-if="scope.row.status==1">已启动</el-tag>
-            <el-tag type="info" size="small" v-else>已停止</el-tag>
-          </template>
-        </el-table-column>
-			<el-table-column label="操作" width="150" align="center">
 				<template #default="scope">
-					<!-- <el-button size="small" text type="primary" @click="preview(scope.row)">启动</el-button> -->
+					<el-tag type="success" size="small" v-if="scope.row.status == 1">已启动</el-tag>
+					<el-tag type="info" size="small" v-else>已停止</el-tag>
+				</template>
+			</el-table-column>
+			<el-table-column label="操作" width="200" align="center">
+				<template #default="scope">
+					<el-button size="small" text type="info" v-if="scope.row.status" @click="setStatus(scope.row.id, 0)">停止</el-button>
+					<el-button size="small" text type="primary" v-else @click="setStatus(scope.row.id, 1)">启动</el-button>
 					<el-button size="small" text type="warning" @click="edit(scope.row)">编辑</el-button>
 					<el-button size="small" text type="danger" @click="onDel(scope.row)">删除</el-button>
 				</template>
@@ -65,8 +66,20 @@ const addOrEdit = async (row?: any) => {
 	}
 };
 
+const setStatus = (id: number, status: number) => {
+	api
+		.setStatus(id, status)
+		.then(() => {
+			ElMessage.success('操作成功');
+			getList();
+		})
+		.catch(() => {
+			ElMessage.error('操作失败');
+		});
+};
+
 const edit = async (row: any) => {
-	const url = window.location.protocol + '//' +  window.location.hostname + ':1880/?access_token=' + Session.get('token') + '#/flow/' + row.flowId;
+	const url = window.location.protocol + '//' + window.location.hostname + ':1880/?access_token=' + Session.get('token') + '#/flow/' + row.flowId;
 	window.open(url);
 };
 

+ 23 - 10
src/views/rule-engine/send.vue

@@ -20,18 +20,19 @@
 		</div>
 		<el-table :data="tableData" style="width: 100%" v-loading="loading">
 			<el-table-column type="index" label="序号" width="80" align="center" />
-			<el-table-column prop="flowId" label="流程ID" show-overflow-tooltip></el-table-column>
-			<el-table-column prop="name" label="项目名称" show-overflow-tooltip></el-table-column>
+			<el-table-column prop="name" label="名称" show-overflow-tooltip></el-table-column>
+			<el-table-column prop="expound" label="说明" show-overflow-tooltip></el-table-column>
 			<el-table-column prop="createdAt" label="创建时间" min-width="100" align="center"></el-table-column>
 			<el-table-column prop="status" label="状态" width="100" align="center">
-          <template #default="scope">
-            <el-tag type="success" size="small" v-if="scope.row.status==1">已启动</el-tag>
-            <el-tag type="info" size="small" v-else>已停止</el-tag>
-          </template>
-        </el-table-column>
-			<el-table-column label="操作" width="150" align="center">
 				<template #default="scope">
-					<!-- <el-button size="small" text type="primary" @click="preview(scope.row)">启动</el-button> -->
+					<el-tag type="success" size="small" v-if="scope.row.status == 1">已启动</el-tag>
+					<el-tag type="info" size="small" v-else>已停止</el-tag>
+				</template>
+			</el-table-column>
+			<el-table-column label="操作" width="200" align="center">
+				<template #default="scope">
+					<el-button size="small" text type="info" v-if="scope.row.status" @click="setStatus(scope.row.id, 0)">停止</el-button>
+					<el-button size="small" text type="primary" v-else @click="setStatus(scope.row.id, 1)">启动</el-button>
 					<el-button size="small" text type="warning" @click="edit(scope.row)">编辑</el-button>
 					<el-button size="small" text type="danger" @click="onDel(scope.row)">删除</el-button>
 				</template>
@@ -65,8 +66,20 @@ const addOrEdit = async (row?: any) => {
 	}
 };
 
+const setStatus = (id: number, status: number) => {
+	api
+		.setStatus(id, status)
+		.then(() => {
+			ElMessage.success('操作成功');
+			getList();
+		})
+		.catch(() => {
+			ElMessage.error('操作失败');
+		});
+};
+
 const edit = async (row: any) => {
-	const url = window.location.protocol + '//' +  window.location.hostname + ':1880/?access_token=' + Session.get('token') + '#/flow/' + row.flowId;
+	const url = window.location.protocol + '//' + window.location.hostname + ':1880/?access_token=' + Session.get('token') + '#/flow/' + row.flowId;
 	window.open(url);
 };