|
@@ -0,0 +1,266 @@
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+ <div class="title-container">
|
|
|
+ <breadcrumb id="breadcrumb-container" class="breadcrumb-container" />
|
|
|
+ </div>
|
|
|
+ <y-page-list-layout :page-list="pageData" :page-para="listQuery" :get-page-list="selectPage">
|
|
|
+ <template slot="left">
|
|
|
+ <el-input style="width: 250px;float: left;margin-right:10px" class="filter-item" v-model="listQuery.recipientEmail" placeholder="收件人邮箱" clearable></el-input>
|
|
|
+ <el-input style="width: 250px;float: left;" class="filter-item" v-model="listQuery.recipientName" placeholder="收件人姓名" clearable></el-input>
|
|
|
+ <el-button class="filter-item" style="margin-left: 10px;float: left;" type="primary" @click="searchList" round>搜索</el-button>
|
|
|
+ <el-button class="filter-item" style="float: left;" round type="success" @click="resetParams()">重置</el-button>
|
|
|
+ <el-button class="filter-item" style="float: left;" round type="warning" @click="sendEmailDialogVisible = true">发送邮件</el-button>
|
|
|
+ </template>
|
|
|
+ <parentTable ref="table" v-loading="listLoading" :data="pageData.records" slot="table" style="width: 100%;">
|
|
|
+ <el-table-column label="发件人邮箱" align="senderEmail" min-width="11%" prop="senderEmail"></el-table-column>
|
|
|
+ <el-table-column label="收件人邮箱" align="recipientEmail" min-width="11%" prop="recipientEmail"></el-table-column>
|
|
|
+ <el-table-column label="收件人姓名" align="recipientName" min-width="11%" prop="recipientName"></el-table-column>
|
|
|
+ <el-table-column label="身份证号" align="idNo" min-width="15%" prop="idNo"></el-table-column>
|
|
|
+ <el-table-column label="部门" align="department" min-width="11%" prop="department"></el-table-column>
|
|
|
+ <el-table-column label="发送时间" align="sendTime" min-width="11%" prop="sendTime"></el-table-column>
|
|
|
+ <el-table-column label="发送状态" align="sendingStatus" min-width="11%" prop="sendingStatus">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span v-if="row.sendingStatus" style="color:#5CB87A">发送成功</span>
|
|
|
+ <span v-if="!row.sendingStatus" style="color:red">发送失败</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="失败原因" align="failureReason" min-width="15%" prop="failureReason">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span style="color:red">{{ row.failureReason }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </parentTable>
|
|
|
+ </y-page-list-layout>
|
|
|
+ <el-dialog title="发送薪资邮件" :visible.sync="sendEmailDialogVisible" width="30%" @close="clearForm">
|
|
|
+ <el-form :model="fileData" :rules="fileDataRules" ref="sendEmailForm">
|
|
|
+ <el-row>
|
|
|
+ <el-col>
|
|
|
+ <el-form-item label="操作人:" prop="operator" label-width="140px">
|
|
|
+ <el-input v-model="fileData.operator" disabled style="width:100%"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col>
|
|
|
+ <el-form-item label="薪资年份:" prop="year" label-width="140px">
|
|
|
+ <el-input v-model="fileData.year" type="number">
|
|
|
+ <template slot="append">年</template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col>
|
|
|
+ <el-form-item label="薪资月份:" prop="month" label-width="140px">
|
|
|
+ <el-input v-model="fileData.month" type="number">
|
|
|
+ <template slot="append">月</template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col>
|
|
|
+ <el-form-item label="邮件标题:" prop="subject" label-width="140px">
|
|
|
+ <el-input v-model="fileData.subject"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col>
|
|
|
+ <el-form-item label="选取薪资明细:" prop="file" label-width="140px">
|
|
|
+ <el-upload
|
|
|
+ ref="upload"
|
|
|
+ style="width:100%;"
|
|
|
+ drag
|
|
|
+ action
|
|
|
+ :before-upload="beforeUploadHandle"
|
|
|
+ :http-request="handleUploadForm"
|
|
|
+ :auto-upload="false"
|
|
|
+ multiple
|
|
|
+ :limit="1"
|
|
|
+ accept=".xls, .xlsx"
|
|
|
+ :file-list="fileList"
|
|
|
+ :on-change="onFileChange"
|
|
|
+ :before-remove="beforeRemove"
|
|
|
+ :on-exceed="onExceed"
|
|
|
+ >
|
|
|
+ <i class="el-icon-upload"></i>
|
|
|
+ <div class="el-upload__text">
|
|
|
+ 将文件拖到此处,或
|
|
|
+ <em>点击上传</em>
|
|
|
+ </div>
|
|
|
+ <template #tip>
|
|
|
+ <div class="el-upload__tip" style="margin-top: 0">只能上传xls/xlsx文件</div>
|
|
|
+ </template>
|
|
|
+ </el-upload>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="sendEmailDialogVisible = false">取 消</el-button>
|
|
|
+ <el-button style="margin-left: 10px;" size="small" type="success" @click="sendEmail">确认发送</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import YPageListLayout from '@/components/YPageListLayout';
|
|
|
+import Breadcrumb from '@/components/Breadcrumb';
|
|
|
+import PermissionButton from '@/components/PermissionButton/PermissionButton';
|
|
|
+import { getCookie, setCookie, removeCookie } from '@/utils/auth';
|
|
|
+import axios from 'axios';
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'hrPayslipEmailList',
|
|
|
+ components: {
|
|
|
+ Breadcrumb,
|
|
|
+ YPageListLayout,
|
|
|
+ PermissionButton,
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ var checkFile = (rule, value, callback) => {
|
|
|
+ if (this.fileList !== undefined && this.fileList !== null) {
|
|
|
+ if (this.fileList.length <= 0) {
|
|
|
+ return callback(new Error('未选择薪资明细文件'));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ return {
|
|
|
+ pageData: { records: [] },
|
|
|
+ listLoading: false,
|
|
|
+ listQuery: {
|
|
|
+ page: 1,
|
|
|
+ size: 10,
|
|
|
+ current: 1,
|
|
|
+ },
|
|
|
+ sendEmailDialogVisible: false,
|
|
|
+ // 上传文件附带参数
|
|
|
+ fileData: {
|
|
|
+ operator: this.$store.getters.userInfo.name,
|
|
|
+ subject: null,
|
|
|
+ year: null,
|
|
|
+ month: null,
|
|
|
+ },
|
|
|
+ fileDataRules: {
|
|
|
+ subject: [{ required: true, message: '邮件标题不能为空', trigger: 'blur' }],
|
|
|
+ file: [{ required: true, validator: checkFile, trigger: 'change' }],
|
|
|
+ year: [{ required: true, message: '薪资发放年份不能为空', trigger: 'blur' }],
|
|
|
+ month: [{ required: true, message: '薪资发放月份不能为空', trigger: 'blur' }],
|
|
|
+ },
|
|
|
+ fileList: [],
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.selectPage();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 无条件分页查询
|
|
|
+ selectPage() {
|
|
|
+ this.listLoading = true;
|
|
|
+ this.$api.hrPayslipEmail.page(this.listQuery).then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.pageData = res.data;
|
|
|
+ }
|
|
|
+ this.listLoading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 条件查询
|
|
|
+ searchList() {
|
|
|
+ // 重置分页
|
|
|
+ this.listQuery.page = 1;
|
|
|
+ this.listQuery.size = 10;
|
|
|
+ this.listQuery.current = 1;
|
|
|
+ this.selectPage();
|
|
|
+ },
|
|
|
+ // 重置搜索条件
|
|
|
+ resetParams() {
|
|
|
+ this.$router.push({ query: {} });
|
|
|
+ this.listQuery = {
|
|
|
+ page: 1,
|
|
|
+ size: 10,
|
|
|
+ current: 1,
|
|
|
+ };
|
|
|
+ this.selectPage();
|
|
|
+ },
|
|
|
+ // 上传前校验
|
|
|
+ beforeUploadHandle(file) {
|
|
|
+ const fileSuffix = file.name.substring(file.name.lastIndexOf('.') + 1);
|
|
|
+ const whiteList = ['xls', 'xlsx'];
|
|
|
+ if (whiteList.indexOf(fileSuffix) === -1) {
|
|
|
+ this.$notify({
|
|
|
+ title: '错误',
|
|
|
+ message: '上传文件只能是 xls、xlsx格式',
|
|
|
+ type: 'error',
|
|
|
+ duration: 2000,
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 上传
|
|
|
+ handleUploadForm(param) {
|
|
|
+ console.log(this.fileData);
|
|
|
+ let thisInfo = this;
|
|
|
+ let formData = new FormData();
|
|
|
+ // 在formData中加入我们需要的参数
|
|
|
+ formData.append('file', param.file);
|
|
|
+ formData.append('subject', this.fileData.subject);
|
|
|
+ formData.append('year', this.fileData.year);
|
|
|
+ formData.append('month', this.fileData.month);
|
|
|
+ // 向后端发送数据
|
|
|
+ this.$api.hrPayslipEmail.sendEmailBatch(formData).then((res) => {
|
|
|
+ if (res.code === 200 && res.data) {
|
|
|
+ this.$notify({
|
|
|
+ title: '成功',
|
|
|
+ message: '邮件发送成功。',
|
|
|
+ type: 'success',
|
|
|
+ duration: 2000,
|
|
|
+ });
|
|
|
+ this.clearForm();
|
|
|
+ } else {
|
|
|
+ this.$notify({
|
|
|
+ title: '失败',
|
|
|
+ message: res.message,
|
|
|
+ type: 'error',
|
|
|
+ duration: 2000,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ onFileChange() {
|
|
|
+ this.$refs['sendEmailForm'].clearValidate(['file']); //移除表单某个字段的校验
|
|
|
+ this.fileList = this.$refs.upload.uploadFiles;
|
|
|
+ },
|
|
|
+ beforeRemove() {
|
|
|
+ this.fileList = [];
|
|
|
+ },
|
|
|
+ onExceed() {
|
|
|
+ this.$notify({
|
|
|
+ title: '错误',
|
|
|
+ message: '最多上传一个文件',
|
|
|
+ type: 'error',
|
|
|
+ duration: 2000,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ sendEmail() {
|
|
|
+ this.$refs.sendEmailForm.validate((valid) => {
|
|
|
+ console.log(valid);
|
|
|
+ if (valid) {
|
|
|
+ this.$refs.upload.submit();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ clearForm() {
|
|
|
+ this.fileList = [];
|
|
|
+ this.sendEmailDialogVisible = false;
|
|
|
+ this.$refs.sendEmailForm.resetFields();
|
|
|
+ this.selectPage();
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped></style>
|