From 5d397555769c6f7f2c86a2a2d7b56727422eb160 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 07 十一月 2025 13:50:39 +0800
Subject: [PATCH] 合同管理加下载合同功能
---
src/views/personnelManagement/contractManagement/index.vue | 103 ++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 81 insertions(+), 22 deletions(-)
diff --git a/src/views/personnelManagement/contractManagement/index.vue b/src/views/personnelManagement/contractManagement/index.vue
index b52e083..10cd508 100644
--- a/src/views/personnelManagement/contractManagement/index.vue
+++ b/src/views/personnelManagement/contractManagement/index.vue
@@ -12,7 +12,7 @@
</div>
<div>
<!-- <el-button type="primary" @click="openForm('add')">鏂板鍏ヨ亴</el-button>-->
- <el-button type="info" @click="handleImport">瀵煎叆</el-button>
+<!-- <el-button type="info" @click="handleImport">瀵煎叆</el-button>-->
<el-button @click="handleOut">瀵煎嚭</el-button>
<!-- <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>-->
</div>
@@ -65,27 +65,26 @@
</div>
</template>
</el-dialog>
+ <files-dia ref="filesDia"></files-dia>
</div>
</template>
<script setup>
-import { Search } from "@element-plus/icons-vue";
-import { onMounted, ref } from "vue";
+import { Search, UploadFilled } from "@element-plus/icons-vue";
+import { onMounted, ref, reactive, toRefs, getCurrentInstance, nextTick } from "vue";
import FormDia from "@/views/personnelManagement/contractManagement/components/formDia.vue";
import { ElMessageBox } from "element-plus";
-import { staffOnJobListPage } from "@/api/personnelManagement/employeeRecord.js";
+import { staffOnJobListPage, staffOnJobExportCopy } from "@/api/personnelManagement/employeeRecord.js";
import dayjs from "dayjs";
import { getToken } from "@/utils/auth.js";
-
+import FilesDia from "./filesDia.vue";
+import axios from "axios";
const data = reactive({
searchForm: {
staffName: "",
- entryDate: [
- dayjs().format("YYYY-MM-DD"),
- dayjs().add(1, "day").format("YYYY-MM-DD"),
- ], // 褰曞叆鏃ユ湡
- entryDateStart: dayjs().format("YYYY-MM-DD"),
- entryDateEnd: dayjs().add(1, "day").format("YYYY-MM-DD"),
+ entryDate: null, // 褰曞叆鏃ユ湡
+ entryDateStart: undefined,
+ entryDateEnd: undefined,
},
});
const { searchForm } = toRefs(data);
@@ -126,7 +125,7 @@
prop: "sex",
},
{
- label: "绫嶈疮",
+ label: "鎴风睄浣忓潃",
prop: "nativePlace",
},
{
@@ -134,7 +133,7 @@
prop: "postJob",
},
{
- label: "瀹跺涵浣忓潃",
+ label: "鐜颁綇鍧�",
prop: "adress",
width: 200
},
@@ -146,11 +145,6 @@
label: "涓撲笟",
prop: "profession",
width: 100
- },
- {
- label: "韬唤璇佸彿",
- prop: "identityCard",
- width: 200
},
{
label: "骞撮緞",
@@ -171,10 +165,10 @@
prop: "emergencyContactPhone",
width: 150
},
- {
- label: "鍚堝悓骞撮檺",
- prop: "contractTerm",
- },
+ // {
+ // label: "鍚堝悓骞撮檺",
+ // prop: "contractTerm",
+ // },
// {
// label: "鍚堝悓寮�濮嬫棩鏈�",
// prop: "contractStartTime",
@@ -190,6 +184,7 @@
label: "鎿嶄綔",
align: "center",
fixed: 'right',
+ width: 180,
operation: [
{
name: "璇︽儏",
@@ -198,9 +193,24 @@
openForm("edit", row);
},
},
+ {
+ name: "闄勪欢",
+ type: "text",
+ clickFun: (row) => {
+ openFilesFormDia(row);
+ },
+ },
+ {
+ name: "涓嬭浇鍚堝悓",
+ type: "text",
+ clickFun: (row) => {
+ handleDownloadContract(row);
+ },
+ },
],
},
]);
+const filesDia = ref()
const tableData = ref([]);
const selectedRows = ref([]);
const tableLoading = ref(false);
@@ -220,6 +230,13 @@
searchForm.value.entryDateEnd = dayjs(value[1]).format("YYYY-MM-DD");
}
getList();
+};
+// 鎵撳紑闄勪欢寮规
+const openFilesFormDia = (row) => {
+ console.log(row)
+ nextTick(() => {
+ filesDia.value?.openDialog( row,'鍚堝悓')
+ })
};
// 鏌ヨ鍒楄〃
/** 鎼滅储鎸夐挳鎿嶄綔 */
@@ -269,6 +286,48 @@
proxy.$modal.msg("宸插彇娑�");
});
};
+// 涓嬭浇鍚堝悓
+const handleDownloadContract = (row) => {
+ const fileName = `${row.staffName || "鍚堝悓"}鍔冲姩鍚堝悓.docx`;
+ proxy.$modal?.loading?.("姝e湪鐢熸垚鍚堝悓锛岃绋嶅��...");
+ staffOnJobExportCopy({ ...row })
+ .then((res) => {
+ proxy.$modal?.closeLoading?.();
+ if (res?.code === 200 && res?.msg) {
+ const javaApi = proxy.javaApi || import.meta.env.VITE_JAVA_API || "";
+ const downloadPath = res.msg.startsWith("/") ? res.msg : `/${res.msg}`;
+ const downloadUrl = `${javaApi}${downloadPath}`;
+ axios({
+ url: downloadUrl,
+ method: "get",
+ responseType: "blob",
+ headers: { Authorization: "Bearer " + getToken() }
+ })
+ .then((resp) => {
+ const blob = new Blob([resp.data], {
+ type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
+ });
+ const url = window.URL.createObjectURL(blob);
+ const link = document.createElement("a");
+ link.href = url;
+ link.download = fileName;
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+ window.URL.revokeObjectURL(url);
+ })
+ .catch(() => {
+ proxy.$modal.msgError("鍚堝悓涓嬭浇澶辫触锛岃绋嶅悗閲嶈瘯");
+ });
+ } else {
+ proxy.$modal.msgError(res?.msg || "鍚堝悓鐢熸垚澶辫触");
+ }
+ })
+ .catch(() => {
+ proxy.$modal?.closeLoading?.();
+ proxy.$modal.msgError("鍚堝悓鐢熸垚澶辫触锛岃绋嶅悗閲嶈瘯");
+ });
+};
const upload = reactive({
// 鏄惁鏄剧ず寮瑰嚭灞傦紙鍚堝悓瀵煎叆锛�
open: false,
--
Gitblit v1.9.3