From 076bb96b437258f0e8cdbe184040e1e302b60d4b Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 22 十二月 2025 14:10:12 +0800
Subject: [PATCH] 1.军泰伟业代码初始化

---
 src/views/personnelManagement/payrollManagement/index.vue |  219 +++++++++++++++++++++++++++++++-----------------------
 1 files changed, 125 insertions(+), 94 deletions(-)

diff --git a/src/views/personnelManagement/payrollManagement/index.vue b/src/views/personnelManagement/payrollManagement/index.vue
index 24e3dd8..a116316 100644
--- a/src/views/personnelManagement/payrollManagement/index.vue
+++ b/src/views/personnelManagement/payrollManagement/index.vue
@@ -27,9 +27,10 @@
 				>
 			</div>
 			<div>
-				<el-button @click="handleExport" style="margin-right: 10px">瀵煎嚭</el-button>
+				<el-button @click="handleImport">瀵煎叆</el-button>
 				<el-button type="primary" @click="openForm('add')">鏂板钖祫</el-button>
 				<el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
+				<el-button @click="handleExport">瀵煎嚭</el-button>
 			</div>
 		</div>
 		<div class="table_list">
@@ -46,17 +47,56 @@
 			></PIMTable>
 		</div>
 		<form-dia ref="formDia" @close="handleQuery"></form-dia>
+		
+		<!-- 瀵煎叆寮圭獥 -->
+		<el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body @close="handleUploadClose">
+			<el-upload
+				ref="uploadRef"
+				:limit="1"
+				accept=".xlsx, .xls"
+				:headers="upload.headers"
+				:action="upload.url"
+				:disabled="upload.isUploading"
+				:on-progress="upload.onProgress"
+				:on-success="upload.onSuccess"
+				:on-error="upload.onError"
+				:on-change="upload.onChange"
+				:auto-upload="false"
+				drag
+			>
+				<el-icon class="el-icon--upload"><upload-filled /></el-icon>
+				<div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
+				<template #tip>
+					<div class="el-upload__tip text-center">
+						<span>浠呭厑璁稿鍏ls銆亁lsx鏍煎紡鏂囦欢銆�</span>
+						<el-link
+							type="primary"
+							:underline="false"
+							style="font-size: 12px; vertical-align: baseline"
+							@click="importTemplate"
+						>涓嬭浇妯℃澘</el-link>
+					</div>
+				</template>
+			</el-upload>
+			<template #footer>
+				<div class="dialog-footer">
+					<el-button type="primary" @click="submitFileForm">纭� 瀹�</el-button>
+					<el-button @click="handleUploadCancel">鍙� 娑�</el-button>
+				</div>
+			</template>
+		</el-dialog>
 	</div>
 </template>
 
 <script setup>
-import { Search } from "@element-plus/icons-vue";
+import { Search, UploadFilled } from "@element-plus/icons-vue";
 import {onMounted, ref, reactive, toRefs, getCurrentInstance, nextTick} from "vue";
 import FormDia from "@/views/personnelManagement/payrollManagement/components/formDia.vue";
 import {staffJoinDel} from "@/api/personnelManagement/onboarding.js";
 import {ElMessageBox} from "element-plus";
 import dayjs from "dayjs";
 import {compensationDelete, compensationListPage} from "@/api/personnelManagement/payrollManagement.js";
+import { getToken } from "@/utils/auth.js";
 
 const data = reactive({
 	searchForm: {
@@ -73,98 +113,6 @@
 	{
 		label: "濮撳悕",
 		prop: "name",
-	},
-	{
-		label: "搴斿嚭鍕ゅぉ鏁�",
-		prop: "shouldAttendedNum",
-		width:100
-	},
-	{
-		label: "瀹為檯鍑哄嫟澶╂暟",
-		prop: "actualAttendedNum",
-		width:110
-	},
-	{
-		label: "鍩烘湰宸ヨ祫",
-		prop: "basicSalary",
-	},
-	{
-		label: "宀椾綅宸ヨ祫",
-		prop: "postSalary",
-		width:100
-	},
-	{
-		label: "鍏ョ鑱岀己鍕ゆ墸娆�",
-		prop: "deductionAbsenteeism",
-		width:130
-	},
-	{
-		label: "鐥呭亣鎵f",
-		prop: "sickLeaveDeductions",
-		width:100
-	},
-	{
-		label: "浜嬪亣鎵f",
-		prop: "deductionPersonalLeave",
-		width:100
-	},
-	{
-		label: "蹇樿鎵撳崱鎵f",
-		prop: "forgetClockDeduct",
-		width:110
-	},
-	{
-		label: "缁╂晥寰楀垎",
-		prop: "performanceScore",
-		width:150
-	},
-	{
-		label: "缁╂晥宸ヨ祫",
-		prop: "performancePay",
-		width: 120
-	},
-	{
-		label: "搴斿彂鍚堣",
-		prop: "payableWages",
-		width:150
-	},
-	{
-		label: "绀句繚涓汉",
-		prop: "socialSecurityIndividuals",
-	},
-	{
-		label: "绀句繚鍏徃",
-		prop: "socialSecurityCompanies",
-		width: 120
-	},
-	{
-		label: "绀句繚鍚堣",
-		prop: "socialSecurityTotal",
-		width: 120
-	},
-	{
-		label: "鍏Н閲戜釜浜�",
-		prop: "providentFundIndividuals",
-		width: 120
-	},
-	{
-		label: "鍏Н閲戝叕鍙�",
-		prop: "providentFundCompany",
-		width: 120
-	},
-	{
-		label: "鍏Н閲戝悎璁�",
-		prop: "providentFundTotal",
-		width: 120
-	},
-	{
-		label: "搴旂◣宸ヨ祫",
-		prop: "taxableWaget",
-	},
-	{
-		label: "涓汉鎵�寰楃◣",
-		prop: "personalIncomeTax",
-		width: 120
 	},
 	{
 		label: "瀹炲彂宸ヨ祫",
@@ -197,6 +145,56 @@
 });
 const formDia = ref()
 const { proxy } = getCurrentInstance()
+
+// 瀵煎叆鍔熻兘閰嶇疆
+const upload = reactive({
+  // 鏄惁鏄剧ず寮瑰嚭灞傦紙钖祫瀵煎叆锛�
+  open: false,
+  // 寮瑰嚭灞傛爣棰橈紙钖祫瀵煎叆锛�
+  title: "",
+  // 鏄惁绂佺敤涓婁紶
+  isUploading: false,
+  // 璁剧疆涓婁紶鐨勮姹傚ご閮�
+  headers: { Authorization: "Bearer " + getToken() },
+  // 涓婁紶鐨勫湴鍧�
+  url: import.meta.env.VITE_APP_BASE_API + "/compensationPerformance/importData",
+  // 鏂囦欢涓婁紶鍓嶇殑鍥炶皟
+  beforeUpload: (file) => {
+    // 鍙互鍦ㄦ澶勫仛鏂囦欢绫诲瀷鎴栧ぇ灏忔牎楠�
+    const isValid = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.name.endsWith('.xlsx') || file.name.endsWith('.xls');
+    if (!isValid) {
+      proxy.$modal.msgError("鍙兘涓婁紶 Excel 鏂囦欢");
+    }
+    return isValid;
+  },
+  // 鏂囦欢鐘舵�佹敼鍙樻椂鐨勫洖璋�
+  onChange: (file, fileList) => {
+    console.log('鏂囦欢鐘舵�佹敼鍙�', file, fileList);
+  },
+  // 鏂囦欢涓婁紶鎴愬姛鏃剁殑鍥炶皟
+  onSuccess: (response, file, fileList) => {
+    upload.isUploading = false;
+    if(response.code === 200){
+      proxy.$modal.msgSuccess("鏂囦欢涓婁紶鎴愬姛");
+      handleUploadClose();
+      getList();
+    }else if(response.code === 500){
+      proxy.$modal.msgError(response.msg);
+    }else{
+      proxy.$modal.msgWarning(response.msg);
+    }
+  },
+  // 鏂囦欢涓婁紶澶辫触鏃剁殑鍥炶皟
+  onError: (error, file, fileList) => {
+    console.error('涓婁紶澶辫触', error, file, fileList);
+    upload.isUploading = false;
+    proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
+  },
+  // 鏂囦欢涓婁紶杩涘害鍥炶皟
+  onProgress: (event, file, fileList) => {
+    console.log('涓婁紶涓�...', event.percent);
+  }
+});
 
 const handleDateChange = (value,type) => {
 	searchForm.value.entryDateEnd = null
@@ -299,6 +297,39 @@
 		});
 };
 
+/** 瀵煎叆鎸夐挳鎿嶄綔 */
+function handleImport() {
+  upload.title = "钖祫瀵煎叆";
+  upload.open = true;
+}
+
+/** 鎻愪氦涓婁紶鏂囦欢 */
+function submitFileForm() {
+  upload.isUploading = true;
+  proxy.$refs["uploadRef"].submit();
+}
+
+/** 涓嬭浇妯℃澘 */
+function importTemplate() {
+  proxy.download("/compensationPerformance/exportTemplate", {}, "钖祫瀵煎叆妯℃澘.xlsx");
+}
+
+// 澶勭悊涓婁紶寮规鍙栨秷
+function handleUploadCancel() {
+  upload.open = false;
+  handleUploadClose();
+}
+
+// 澶勭悊涓婁紶寮规鍏抽棴
+function handleUploadClose() {
+  upload.open = false;
+  upload.isUploading = false;
+  // 娓呯┖涓婁紶鏂囦欢缂撳瓨
+  if (proxy.$refs.uploadRef) {
+    proxy.$refs.uploadRef.clearFiles();
+  }
+}
+
 onMounted(() => {
 	getList();
 });

--
Gitblit v1.9.3