From c99b4166febfde47d5b350d30bac443a11de42f5 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 31 十月 2025 15:11:21 +0800
Subject: [PATCH] 协同审批-添加导出功能
---
src/views/collaborativeApproval/rpaManagement/index.vue | 214 ++++++++++++++++++++++-------------------------------
1 files changed, 90 insertions(+), 124 deletions(-)
diff --git a/src/views/collaborativeApproval/rpaManagement/index.vue b/src/views/collaborativeApproval/rpaManagement/index.vue
index 51cef73..9e5b504 100644
--- a/src/views/collaborativeApproval/rpaManagement/index.vue
+++ b/src/views/collaborativeApproval/rpaManagement/index.vue
@@ -22,6 +22,7 @@
</el-button>
</div>
<div>
+ <el-button @click="handleExport" style="margin-right: 10px">瀵煎嚭</el-button>
<el-button type="primary" @click="openForm('add')">鏂板</el-button>
<el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
</div>
@@ -89,10 +90,10 @@
<script setup>
import { Search } from "@element-plus/icons-vue";
-import { onMounted, ref, reactive, toRefs } from "vue";
+import { onMounted, ref, reactive, toRefs, getCurrentInstance } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import PIMTable from "@/components/PIMTable/PIMTable.vue";
-
+import {listRpa, addRpa, updateRpa, delRpa, delRpaBatch} from "@/api/collaborativeApproval/rpaManagement.js";
// 鍝嶅簲寮忔暟鎹�
const data = reactive({
searchForm: {
@@ -100,20 +101,17 @@
status: "",
},
form: {
- id: "",
programName: "",
- status: "stopped",
- description: "",
- createTime: "",
+ status: "",
+ description: ""
},
dialogVisible: false,
dialogTitle: "",
dialogType: "add",
- selectedIds: [],
tableLoading: false,
page: {
current: 1,
- size: 100,
+ size: 20,
total: 0,
},
tableData: [],
@@ -123,6 +121,8 @@
// 琛ㄥ崟寮曠敤
const formRef = ref();
+// 閫夋嫨鐨勮鏁版嵁
+const selectedRows = ref([]);
// 琛ㄥ崟楠岃瘉瑙勫垯
const rules = {
@@ -179,7 +179,7 @@
label: "鎿嶄綔",
align: "center",
fixed: "right",
- width: 230,
+ width: 150,
operation: [
{
name: "缂栬緫",
@@ -188,50 +188,26 @@
openForm("edit", row);
}
},
- {
- name: "寮�濮�",
- type: "text",
- clickFun: (row) => {
- handleStart(row);
- },
- disabled: (row) => row.status !== 'stopped'
- },
- {
- name: "鍋滄",
- type: "text",
- clickFun: (row) => {
- handleStop(row);
- },
- disabled: (row) => row.status === 'stopped'
- }
+ // {
+ // name: "寮�濮�",
+ // type: "text",
+ // clickFun: (row) => {
+ // handleStart(row);
+ // },
+ // disabled: (row) => row.status !== 'stopped'
+ // },
+ // {
+ // name: "鍋滄",
+ // type: "text",
+ // clickFun: (row) => {
+ // handleStop(row);
+ // },
+ // disabled: (row) => row.status === 'stopped'
+ // }
]
}
]);
-// 妯℃嫙鏁版嵁
-const mockData = [
- {
- id: "1",
- programName: "璁㈠崟澶勭悊RPA",
- status: "running",
- description: "鑷姩澶勭悊瀹㈡埛璁㈠崟锛屽寘鎷獙璇併�佸垎閰嶅拰纭",
- createTime: "2024-01-15 10:30:00"
- },
- {
- id: "2",
- programName: "搴撳瓨鍚屾RPA",
- status: "stopped",
- description: "鍚屾澶氫釜浠撳簱鐨勫簱瀛樻暟鎹紝纭繚鏁版嵁涓�鑷存��",
- createTime: "2024-01-14 15:20:00"
- },
- {
- id: "3",
- programName: "鎶ヨ〃鐢熸垚RPA",
- status: "error",
- description: "鑷姩鐢熸垚姣忔棩閿�鍞姤琛ㄥ拰搴撳瓨鎶ヨ〃",
- createTime: "2024-01-13 09:15:00"
- }
-];
// 鐢熷懡鍛ㄦ湡
onMounted(() => {
@@ -240,32 +216,20 @@
// 鏌ヨ鏁版嵁
const handleQuery = () => {
- page.value.current = 1;
+ // page.value.current = 1;
getList();
};
const getList = () => {
tableLoading.value = true;
-
- // 妯℃嫙API璋冪敤寤惰繜
- setTimeout(() => {
- let filteredData = [...mockData];
-
- // 鏍规嵁鎼滅储鏉′欢杩囨护鏁版嵁
- if (searchForm.value.programName) {
- filteredData = filteredData.filter(item =>
- item.programName.toLowerCase().includes(searchForm.value.programName.toLowerCase())
- );
- }
-
- if (searchForm.value.status) {
- filteredData = filteredData.filter(item => item.status === searchForm.value.status);
- }
-
- tableData.value = filteredData;
- page.value.total = filteredData.length;
+ listRpa({...page.value, ...searchForm.value})
+ .then(res => {
tableLoading.value = false;
- }, 500);
+ tableData.value = res.data.records
+ page.total = res.data.total;
+ }).catch(err => {
+ tableLoading.value = false;
+ })
};
// 鍒嗛〉澶勭悊
@@ -277,23 +241,16 @@
// 閫夋嫨鍙樺寲澶勭悊
const handleSelectionChange = (selection) => {
- selectedIds.value = selection.map(item => item.id);
+ selectedRows.value = selection;
};
// 鎵撳紑琛ㄥ崟
const openForm = (type, row) => {
dialogType.value = type;
dialogVisible.value = true;
-
+
if (type === "add") {
dialogTitle.value = "娣诲姞RPA";
- form.value = {
- id: "",
- programName: "",
- status: "stopped",
- description: "",
- createTime: "",
- };
} else {
dialogTitle.value = "缂栬緫RPA";
form.value = { ...row };
@@ -303,33 +260,38 @@
// 鎻愪氦琛ㄥ崟
const submitForm = async () => {
if (!formRef.value) return;
-
+
try {
await formRef.value.validate();
-
+
if (dialogType.value === "add") {
// 娣诲姞鏂癛PA
- const newRPA = {
- id: Date.now().toString(),
- programName: form.value.programName,
- status: form.value.status,
- description: form.value.description,
- createTime: new Date().toLocaleString(),
- };
-
- mockData.unshift(newRPA);
- ElMessage.success("RPA娣诲姞鎴愬姛");
+ addRpa({...form.value}).then(res => {
+ if(res.code == 200){
+ ElMessage.success("娣诲姞鎴愬姛");
+ form.value = {
+ programName: "",
+ status: "",
+ description: ""
+ },
+ dialogVisible.value = false;
+ getList();
+ }
+ }).catch(err => {
+ ElMessage.error(err.msg);
+ })
} else {
// 缂栬緫RPA
- const index = mockData.findIndex(item => item.id === form.value.id);
- if (index !== -1) {
- mockData[index] = { ...form.value };
- ElMessage.success("RPA鏇存柊鎴愬姛");
- }
+ updateRpa({...form.value}).then(res => {
+ if(res.code == 200){
+ ElMessage.success("鏇存柊鎴愬姛");
+ dialogVisible.value = false;
+ getList();
+ }
+ }).catch(err => {
+ ElMessage.error(err.msg);
+ })
}
-
- dialogVisible.value = false;
- getList();
} catch (error) {
console.error("琛ㄥ崟楠岃瘉澶辫触:", error);
}
@@ -368,33 +330,37 @@
// 鍒犻櫎RPA
const handleDelete = () => {
let ids = [];
- if (selectedIds.value.length > 0) {
- ids = selectedIds.value.map((item) => item.id);
- } else {
- ElMessage.warning("璇烽�夋嫨瑕佸垹闄ょ殑RPA");
- return;
- }
-
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- }).then(() => {
- // 浠庢ā鎷熸暟鎹腑鍒犻櫎閫変腑鐨勯」
- ids.forEach(id => {
- const index = mockData.findIndex(item => item.id === id);
- if (index !== -1) {
- mockData.splice(index, 1);
- }
- });
-
- ElMessage.success("鍒犻櫎鎴愬姛");
- selectedIds.value = [];
- getList();
- }).catch(() => {
- // 鐢ㄦ埛鍙栨秷
- });
+ if (selectedRows.value.length > 0) {
+ ids = selectedRows.value.map((item) => item.id);
+ } else {
+ proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+ return;
+ }
+ ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(() => {
+ delRpa(ids).then((res) => {
+ if(res.code == 200){
+ ElMessage.success("鍒犻櫎鎴愬姛");
+ getList();
+ }
+ }).catch(err => {
+ ElMessage.error(err.msg);
+ })
+ })
+ .catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
};
+
+// 瀵煎嚭鍔熻兘
+const { proxy } = getCurrentInstance()
+const handleExport = () => {
+ proxy.download('/rpaProcessAutomation/export', { ...searchForm.value }, 'RPA绠$悊.xlsx')
+}
</script>
<style scoped></style>
--
Gitblit v1.9.3