<template>
|
<div class="app-container">
|
<!-- 工具栏 -->
|
<div class="head-container">
|
<div v-if="crud.props.searchToggle">
|
<!-- 搜索 -->
|
<el-select v-model="query.projectId" filterable clearable placeholder="所属项目" style="width: 185px;">
|
<el-option v-for="item in projects" :key="`project_${item.id}`" :label="item.name" :value="item.id" />
|
</el-select>
|
<el-select v-model="query.reimburseType" filterable clearable placeholder="报销类型" style="width: 185px;">
|
<el-option v-for="item in dict[dictReimburseType]" :key="item.value" :label="item.label" :value="item.value" />
|
</el-select>
|
<el-select v-model="query.expenseType" filterable clearable placeholder="费用类型" style="width: 185px;">
|
<el-option v-for="item in dict[dictReimburseExpenseType]" :key="item.value" :label="item.label" :value="item.value" />
|
</el-select>
|
<el-select v-model="query.userId" filterable clearable placeholder="申请人" style="width: 185px;">
|
<el-option v-for="item in users" :key="item.id" :label="item.nickName" :value="item.id" />
|
</el-select>
|
<el-date-picker
|
v-model="query.startTime"
|
type="daterange"
|
clearable
|
range-separator=" ~ "
|
value-format="yyyy-MM-dd 00:00:00"
|
start-placeholder="开始时间"
|
end-placeholder="结束时间"
|
style="width: 285px;"
|
class="filter-item"
|
/>
|
<!-- <el-date-picker
|
v-model="query.endTime"
|
type="daterange"
|
clearable
|
range-separator=" ~ "
|
value-format="yyyy-MM-dd 00:00:00"
|
start-placeholder="开始时间"
|
end-placeholder="结束时间"
|
style="width: 285px;"
|
class="filter-item"
|
/> -->
|
<rrOperation :crud="crud" />
|
</div>
|
<!-- 如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right' -->
|
<crudOperation :permission="permission">
|
<el-button
|
slot="right"
|
class="filter-item"
|
size="mini"
|
type="primary"
|
icon="el-icon-circle-check"
|
:disabled="crud.selections.length < 1 || !crud.selections.every(item => item.approvalStatus === dictReimburseApproveStatusReviewed)"
|
style="margin-left: 4px !important;"
|
@click="batchApprove(1, crud.selections)"
|
>
|
批量同意
|
</el-button>
|
<el-button
|
slot="right"
|
class="filter-item"
|
size="mini"
|
type="primary"
|
icon="el-icon-error"
|
:disabled="crud.selections.length < 1 || !crud.selections.every(item => item.approvalStatus === dictReimburseApproveStatusReviewed)"
|
style="margin-left: 4px !important;"
|
@click="batchApprove(2, crud.selections)"
|
>
|
批量拒绝
|
</el-button>
|
</crudOperation>
|
<!-- 表单组件 -->
|
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
|
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
|
<el-form-item label="申请人" prop="userId">
|
<el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 370px;" :disabled="disabledUser(form) || form.wecomSpNo !== null">
|
<el-option
|
v-for="item in users"
|
:key="item.id"
|
:label="item.nickName"
|
:value="item.id"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="审批者" prop="approvalUserId" :hidden="form.wecomSpNo !== null || (form.id == null && wecomApprovalVisible)">
|
<el-select v-model="form.approvalUserId" filterable clearable placeholder="请选择" style="width: 370px;" :disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null">
|
<el-option
|
v-for="item in approvalUsers"
|
:key="item.id"
|
:label="item.nickName"
|
:value="item.id"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="所属项目" prop="projectId">
|
<el-select v-model="form.projectId" filterable clearable placeholder="请选择" style="width: 370px;" :disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null">
|
<el-option v-for="item in projects" :key="`project_${item.id}`" :label="item.name" :value="item.id" />
|
</el-select>
|
</el-form-item>
|
<el-form-item label="报销类型" prop="reimburseTypes">
|
<el-select v-model="form.reimburseTypes" multiple filterable clearable placeholder="请选择" style="width: 370px;" :disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null">
|
<el-option v-for="item in dict[dictReimburseType]" :key="item.value" :label="item.label" :value="item.value" />
|
</el-select>
|
</el-form-item>
|
<el-form-item label="报销原因" prop="reimburseReason">
|
<el-input v-model="form.reimburseReason" placeholder="请输入" type="textarea" rows="3" style="width: 370px;" :disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null" />
|
</el-form-item>
|
<el-form-item label="费用类型" prop="expenseTypes">
|
<el-select v-model="form.expenseTypes" multiple filterable clearable placeholder="请选择" style="width: 370px;" :disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null">
|
<el-option v-for="item in dict[dictReimburseExpenseType]" :key="item.value" :label="item.label" :value="item.value" />
|
</el-select>
|
</el-form-item>
|
<el-form-item label="开始时间" prop="startTime">
|
<el-date-picker
|
v-model="form.startTime"
|
type="date"
|
placeholder="选择日期"
|
value-format="yyyy-MM-dd 00:00:00"
|
style="width: 370px;"
|
align="right"
|
:picker-options="{
|
disabledDate(time) {
|
return form.endTime ? time.getTime() > new Date(form.endTime).getTime() - 8.64e7 : false;
|
}
|
}"
|
:disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null"
|
/>
|
</el-form-item>
|
<el-form-item label="结束时间" prop="endTime">
|
<el-date-picker
|
v-model="form.endTime"
|
type="date"
|
placeholder="选择日期"
|
style="width: 370px;"
|
value-format="yyyy-MM-dd 23:59:59"
|
align="right"
|
:picker-options="{
|
disabledDate(time) {
|
return form.startTime ? time.getTime() < new Date(form.startTime).getTime() - 8.64e7 : false;
|
}
|
}"
|
:disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null"
|
/>
|
</el-form-item>
|
<el-form-item label="费用金额" prop="expenseAmount">
|
<el-input-number v-model="form.expenseAmount" placeholder="请输入" style="width: 370px;" :disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null" />
|
</el-form-item>
|
<el-form-item label="费用说明" prop="expenseComment">
|
<el-input v-model="form.expenseComment" placeholder="请输入" type="textarea" rows="3" style="width: 370px;" :disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null" />
|
</el-form-item>
|
<el-form-item label="附件">
|
<div style="line-height: 16px; margin: 8px 0;">
|
<span class="upload-tips">*最多支持上传6个文件,每个文件大小限制10M以内。</span>
|
<el-link type="primary" :href="locationOrigin + '/file/Template/projectReimburse.xlsx'" target="_blank">下载模版</el-link>
|
</div>
|
<file-upload key="file_key" ref="fileUpload" :file-url="form.filePath == null || form.filePath === '' ? null : form.filePath" :limit="6" :disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null" @fileInfo="getFileInfo" />
|
</el-form-item>
|
<el-form-item label="审批说明" prop="approvalDescription">
|
<el-input v-model="form.approvalDescription" type="textarea" rows="3" disabled style="width: 370px;" />
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
<el-button :loading="crud.status.cu === 2 || fileUploadLoading" type="primary" @click="formSubmit">确认</el-button>
|
</div>
|
</el-dialog>
|
<!-- 审批组件 -->
|
<el-dialog :close-on-click-modal="false" :before-close="cancelApprove" :visible.sync="approveModal.visible" :title="approveModal.title" width="500px">
|
<el-form ref="approveForm" :model="form" :rules="approveRules" size="small" label-width="80px">
|
<el-form-item label="申请人">
|
{{ form.userName }}
|
</el-form-item>
|
<el-form-item label="所属项目">
|
{{ form.projectName }}
|
</el-form-item>
|
<el-form-item label="报销类型">
|
{{ batchConversion(form.reimburseType, dict.label[dictReimburseType]) }}
|
</el-form-item>
|
<el-form-item label="报销原因">
|
{{ form.reimburseReason }}
|
</el-form-item>
|
<el-form-item label="费用类型">
|
{{ batchConversion(form.expenseType, dict.label[dictReimburseExpenseType]) }}
|
</el-form-item>
|
<el-form-item label="开始时间">
|
{{ form.startTime }}
|
</el-form-item>
|
<el-form-item label="结束时间">
|
{{ form.endTime }}
|
</el-form-item>
|
<el-form-item label="费用金额">
|
{{ form.expenseAmount }}
|
</el-form-item>
|
<el-form-item label="费用说明">
|
{{ form.expenseComment }}
|
</el-form-item>
|
<el-form-item v-if="form.approvalStatus === dictReimburseApproveStatusRefuse" label="退回原因" prop="approvalDescription">
|
<div style="color: red;">*审核退回需要填写退回原因,请填写后再次点击审核退回</div>
|
<el-input v-model="form.approvalDescription" type="textarea" :rows="3" style="width: 370px;" />
|
</el-form-item>
|
</el-form>
|
|
<div slot="footer" class="dialog-footer">
|
<el-button type="danger" style="margin-right: 10px;" :loading="approveModal.approveLoading" @click="handleApprove(1, form)">审核退回</el-button>
|
<el-button v-if="form.approvalStatus !== dictReimburseApproveStatusRefuse" :loading="approveModal.approveLoading" type="success" @click="handleApprove(2, form)">审核通过</el-button>
|
</div>
|
</el-dialog>
|
<!-- 表格渲染 -->
|
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
<el-table-column type="selection" width="55" />
|
<el-table-column prop="userName" label="申请人">
|
<template slot-scope="scope">
|
<el-tag>{{ scope.row.userName }}</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column prop="appUserName" label="审批者">
|
<template slot-scope="scope">
|
<el-popover
|
v-if="scope.row.wecomSpNo && scope.row.event"
|
placement="right-start"
|
width="600"
|
trigger="click"
|
>
|
<approvalLine :event-data="scope.row.event" :user-list="users" />
|
<el-tag slot="reference" effect="dark">
|
<i class="el-icon-search" />
|
<span>详细</span>
|
</el-tag>
|
</el-popover>
|
|
<el-tag v-else-if="scope.row.appUserName">{{ scope.row.appUserName }}</el-tag>
|
<el-tag v-else>暂无</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column prop="projectName" label="所属项目" min-width="140">
|
<template slot-scope="scope">
|
<el-tag>{{ scope.row.projectName }}</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column prop="reimburseType" label="报销类型" min-width="140" show-overflow-tooltip>
|
<template slot-scope="scope">
|
{{ batchConversion(scope.row.reimburseType, dict.label[dictReimburseType]) }}
|
</template>
|
</el-table-column>
|
<el-table-column prop="expenseType" label="费用类型" min-width="140" show-overflow-tooltip>
|
<template slot-scope="scope">
|
{{ batchConversion(scope.row.expenseType, dict.label[dictReimburseExpenseType]) }}
|
</template>
|
</el-table-column>
|
<el-table-column prop="startTime" label="开始时间" min-width="100">
|
<template slot-scope="scope">
|
{{ crud.toDate(scope.row.startTime) }}
|
</template>
|
</el-table-column>
|
<el-table-column prop="endTime" label="结束时间" min-width="100">
|
<template slot-scope="scope">
|
{{ crud.toDate(scope.row.endTime) }}
|
</template>
|
</el-table-column>
|
<el-table-column prop="expenseAmount" label="费用金额" />
|
<el-table-column prop="approvalStatus" label="审批状态">
|
<template slot-scope="scope">
|
<el-tag v-if="scope.row.approvalStatus === dictReimburseApproveStatusReviewed" type="warning">{{ dict.label[dictReimburseApproveStatus][scope.row.approvalStatus] }}</el-tag>
|
<el-tag v-if="scope.row.approvalStatus === dictReimburseApproveStatusAgree" type="success">{{ dict.label[dictReimburseApproveStatus][scope.row.approvalStatus] }}</el-tag>
|
<el-tag v-if="scope.row.approvalStatus === dictReimburseApproveStatusRefuse" type="danger">{{ dict.label[dictReimburseApproveStatus][scope.row.approvalStatus] }}</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column prop="approvalDescription" label="审批说明" show-overflow-tooltip />
|
<el-table-column prop="createTime" label="创建时间" min-width="140" />
|
<el-table-column v-if="checkPer(permission.approve)" label="审核操作" width="180px" align="center" fixed="right">
|
<template slot-scope="scope">
|
<el-button
|
v-if="scope.row.approvalUserId === $store.state.user.user.id && !scope.row.wecomSpNo"
|
v-permission="permission.approve"
|
:loading="crud.status.cu === 2"
|
size="mini"
|
type="primary"
|
icon="el-icon-s-check"
|
:disabled="!(scope.row.approvalStatus === dictReimburseApproveStatusReviewed)"
|
@click="toApprove(scope.row)"
|
>
|
审核
|
</el-button>
|
<el-popover :ref="`popover_${scope.row.id}`" width="200">
|
<p>确定撤销该记录?</p>
|
<div style="text-align: right; margin: 0">
|
<el-button size="mini" type="primary" @click="handleCanel(scope.row.id)">取消</el-button>
|
<el-button :loading="revokeLoading" type="primary" size="mini" @click="handleRevoke(scope.row)">确定</el-button>
|
</div>
|
<el-button
|
v-if="scope.row.approvalUserId === $store.state.user.user.id && !scope.row.wecomSpNo"
|
slot="reference"
|
v-permission="permission.approve"
|
type="danger"
|
icon="el-icon-edit-outline"
|
size="mini"
|
:disabled="scope.row.approvalStatus === dictReimburseApproveStatusReviewed"
|
>
|
撤销
|
</el-button>
|
</el-popover>
|
<el-link v-if="scope.row.wecomSpNo" type="primary">请前往企微审核</el-link>
|
</template>
|
</el-table-column>
|
<el-table-column v-if="checkPer(['admin','projectReimburse:edit','projectReimburse:del'])" label="操作" width="150px" align="center" fixed="right">
|
<template slot-scope="scope">
|
<udOperation
|
v-if="!scope.row.wecomSpNo"
|
:data="scope.row"
|
:permission="permission"
|
/>
|
<el-button
|
v-if="scope.row.wecomSpNo && user.id === scope.row.userId && scope.row.approvalStatus === dictReimburseApproveStatusRefuse"
|
size="mini"
|
type="primary"
|
icon="el-icon-refresh-right"
|
@click="reAdd(scope.row)"
|
/>
|
</template>
|
</el-table-column>
|
</el-table>
|
<!--分页组件-->
|
<pagination />
|
|
<cp-approval-del-dialog ref="cpApprovalDelDialog" />
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import crudProjectReimburse from '@/api/project/projectReimburse'
|
import crudUser from '@/api/system/user'
|
import crudTask from '@/api/task/task'
|
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
import rrOperation from '@crud/RR.operation'
|
import crudOperation from '@crud/CRUD.operation'
|
import udOperation from '@crud/UD.operation'
|
import pagination from '@crud/Pagination'
|
import approvalLine from '@/components/ApprovalLine'
|
import cpApprovalDelDialog from '@/components/CpApprovalDelDialog'
|
import fileUpload from '@/views/assembly/fileUpload'
|
import { mapGetters } from 'vuex'
|
import constant from '@/utils/constant'
|
|
const defaultForm = { id: null, userId: null, approvalUserId: null, projectId: null, reimburseType: null, reimburseReason: null, expenseType: null, startTime: null, endTime: null, expenseAmount: null, expenseComment: null, originFileName: null, filePath: null, approvalStatus: null, approvalDescription: null, createTime: null, createBy: null, updateTime: null, updateBy: null, wecomSpNo: null, event: null, userName: null, appUserName: null, projectName: null, reimburseTypes: null, expenseTypes: null }
|
export default {
|
name: 'ProjectReimburse',
|
components: { pagination, crudOperation, rrOperation, udOperation, approvalLine, fileUpload, cpApprovalDelDialog },
|
mixins: [presenter(), header(), form(defaultForm), crud()],
|
dicts: [constant.REIMBURSE_APPROVE_STATUS, constant.REIMBURSE_TYPE, constant.REIMBURSE_EXPENSE_TYPE, constant.APPROVAL_SITE_TYPE],
|
cruds() {
|
return CRUD({ title: '项目报销', url: 'api/projectReimburse', idField: 'id', sort: 'id,desc', crudMethod: { ...crudProjectReimburse }})
|
},
|
data() {
|
return {
|
permission: {
|
add: ['admin', 'projectReimburse:add'],
|
edit: ['admin', 'projectReimburse:edit'],
|
del: ['admin', 'projectReimburse:del'],
|
download: ['admin', 'projectReimburse:download'],
|
approve: ['admin', 'projectReimburse:approve']
|
},
|
rules: {
|
userId: [
|
{ required: true, message: '申请人不能为空', trigger: 'change' }
|
],
|
approvalUserId: [
|
{ required: true, message: '审批者不能为空', trigger: 'change' }
|
],
|
projectId: [
|
{ required: true, message: '所属项目不能为空', trigger: 'change' }
|
],
|
reimburseTypes: [
|
{ required: true, message: '报销类型不能为空', trigger: 'blur' }
|
],
|
expenseTypes: [
|
{ required: true, message: '费用类型不能为空', trigger: 'blur' }
|
],
|
startTime: [
|
{ required: true, message: '开始时间不能为空', trigger: 'blur' }
|
],
|
endTime: [
|
{ required: true, message: '结束时间不能为空', trigger: 'blur' }
|
],
|
expenseAmount: [
|
{ required: true, message: '费用金额不能为空', trigger: 'blur' }
|
]
|
},
|
approveRules: {
|
approvalDescription: [
|
{ required: true, message: '退回原因不能为空', trigger: 'blur' }
|
]
|
},
|
queryTypeOptions: [
|
{ key: 'projectId', display_name: '所属项目' },
|
{ key: 'reimburseType', display_name: '报销类型' },
|
{ key: 'expenseType', display_name: '费用类型' },
|
{ key: 'userId', display_name: '申请人' }
|
],
|
approveModal: {
|
title: '报销审批',
|
visible: false,
|
approveLoading: false
|
},
|
// 撤销Loading
|
revokeLoading: false,
|
dictReimburseApproveStatus: constant.REIMBURSE_APPROVE_STATUS,
|
dictReimburseApproveStatusReviewed: constant.REIMBURSE_APPROVE_STATUS_REVIEWED,
|
dictReimburseApproveStatusAgree: constant.REIMBURSE_APPROVE_STATUS_AGREE,
|
dictReimburseApproveStatusRefuse: constant.REIMBURSE_APPROVE_STATUS_REFUSE,
|
dictReimburseType: constant.REIMBURSE_TYPE,
|
dictReimburseExpenseType: constant.REIMBURSE_EXPENSE_TYPE,
|
users: [],
|
approvalUsers: [],
|
projects: [],
|
userRolesLevelMin: null,
|
// 角色级别: 总经理
|
roleLevelGenerl: constant.ROLE_LEVEL_GENERAL,
|
// 企微审核判断
|
wecomApprovalVisible: false,
|
fileUploadLoading: false
|
}
|
},
|
computed: {
|
...mapGetters([
|
'user'
|
]),
|
locationOrigin() {
|
return window.location.origin
|
}
|
},
|
created() {
|
const that = this
|
that.getUsers()
|
that.getApprovalUsers()
|
that.getProjects()
|
that.$on('dictReady', () => {
|
const dictData = { ...that.dict }
|
const filterData = dictData[constant.APPROVAL_SITE_TYPE].filter(item => item.value.toLowerCase() === 'wecom')
|
if (filterData.length > 0) {
|
that.wecomApprovalVisible = true
|
}
|
})
|
},
|
methods: {
|
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
[CRUD.HOOK.beforeRefresh]() {
|
const that = this
|
// 用户角色级别数组
|
const userRolesLevel = that.user.roles.map(({ level }) => level)
|
// 用户最大角色级别
|
that.userRolesLevelMin = Math.min(...userRolesLevel)
|
return true
|
},
|
// 钩子:新建 - 之前
|
[CRUD.HOOK.beforeToAdd]() {
|
const that = this
|
// 转换报销类型和费用类型
|
that.$set(that.form, 'reimburseTypes', [])
|
that.$set(that.form, 'expenseTypes', [])
|
// 判断用户最大角色级别是否大于总经理角色:赋值
|
if (that.userRolesLevelMin > that.roleLevelGenerl) {
|
// 表单赋值
|
that.form.userId = that.user.id
|
}
|
if (that.wecomApprovalVisible) {
|
that.form.approvalUserId = 0
|
}
|
return true
|
},
|
// 钩子:编辑 - 之前
|
[CRUD.HOOK.beforeToEdit]() {
|
const that = this
|
// 转换报销类型和费用类型
|
that.$set(that.form, 'reimburseTypes', that.form.reimburseType.split(','))
|
that.$set(that.form, 'expenseTypes', that.form.expenseType.split(','))
|
return true
|
},
|
// 钩子:提交 - 之前
|
[CRUD.HOOK.beforeSubmit]() {
|
const that = this
|
// 解除文件上传Loading
|
that.fileUploadLoading = false
|
// 转换报销类型和费用类型
|
that.$set(that.form, 'reimburseType', that.form.reimburseTypes.join(','))
|
that.$set(that.form, 'expenseType', that.form.expenseTypes.join(','))
|
return true
|
},
|
// 钩子:提交 - 之后
|
[CRUD.HOOK.afterSubmit]() {
|
const that = this
|
that.$set(that.form, 'reimburseTypes', undefined)
|
that.$set(that.form, 'expenseTypes', undefined)
|
return true
|
},
|
// 钩子:删除 - 之前
|
[CRUD.HOOK.beforeDelete]() {
|
const that = this
|
if (that.crud.selections.some(selection => selection.wecomSpNo !== null && selection.wecomSpNo !== undefined && selection.wecomSpNo !== '')) {
|
that.$refs.cpApprovalDelDialog.handleOpen()
|
that.crud.delAllLoading = false
|
return false
|
}
|
return true
|
},
|
// 钩子:新增取消 - 之前
|
[CRUD.HOOK.afterAddCancel]() {
|
const that = this
|
that.$refs.fileUpload.clearFiles()
|
return true
|
},
|
// 钩子:编辑取消 - 之前
|
[CRUD.HOOK.afterEditCancel]() {
|
const that = this
|
that.$refs.fileUpload.clearFiles()
|
return true
|
},
|
|
// 查询员工
|
getUsers() {
|
const that = this
|
crudUser.getAll().then(res => {
|
that.users = res
|
})
|
},
|
// 查询审核人
|
getApprovalUsers() {
|
const that = this
|
crudUser.getApprovalUsers().then(res => {
|
that.approvalUsers = res
|
})
|
},
|
// 获取项目列表
|
getProjects() {
|
const that = this
|
// 获取项目列表
|
crudTask.getProjects().then(res => {
|
that.projects = res
|
})
|
},
|
|
// 提交数据
|
formSubmit() {
|
const that = this
|
|
that.$refs['form'].validate(valid => {
|
if (!valid) {
|
return
|
}
|
that.fileUploadLoading = true
|
that.$refs.fileUpload.submit()
|
})
|
},
|
|
// 禁用
|
disabledUser(data) {
|
const that = this
|
if (that.userRolesLevelMin > that.roleLevelGenerl) {
|
return true
|
}
|
if (data.approvalStatus !== null && data.approvalStatus === that.dictReimburseApproveStatusAgree || data.approvalStatus === that.dictReimburseApproveStatusRefuse) {
|
return true
|
}
|
},
|
|
// 批量转换字符串
|
batchConversion(str, dictData) {
|
const finalStrArr = []
|
str && str.split(',').forEach(item => {
|
finalStrArr.push(dictData[item] || item)
|
})
|
|
return finalStrArr.join(',')
|
},
|
|
// 启动审批
|
toApprove(data) {
|
const that = this
|
|
const form = JSON.parse(JSON.stringify(data))
|
const approveFrom = that.form
|
for (const key in form) {
|
if (approveFrom.hasOwnProperty(key)) {
|
approveFrom[key] = form[key]
|
} else {
|
that.$set(approveFrom, key, form[key])
|
}
|
}
|
if (that.$refs['approveForm']) {
|
that.$refs['approveForm'].clearValidate()
|
}
|
that.approveModal.visible = true
|
},
|
|
// 执行审批
|
handleApprove(type, data) {
|
const that = this
|
|
const msg = type === 2 ? '通过' : '拒绝'
|
that.$refs['approveForm'].validate(valid => {
|
if (!valid) {
|
return
|
}
|
// 判断通过状态
|
if (type === 2) {
|
that.form.approvalStatus = that.dictReimburseApproveStatusAgree
|
} else {
|
// 退回改状态显示退回原因
|
that.form.approvalStatus = that.dictReimburseApproveStatusRefuse
|
if (that.form.approvalDescription == null) {
|
return
|
}
|
}
|
|
that.approveModal.approveLoading = true
|
that.crud.crudMethod.approve(that.form).then(() => {
|
that.crud.refresh()
|
that.$message({
|
type: 'success',
|
message: '审核' + msg + '成功'
|
})
|
that.cancelApprove()
|
}).catch(() => {
|
that.approveModal.approveLoading = false
|
})
|
})
|
},
|
|
// 取消撤销
|
handleCanel(id) {
|
const that = this
|
that.$refs[`popover_${id}`].showPopper = false
|
},
|
|
// 执行撤销
|
handleRevoke(data) {
|
const that = this
|
|
that.revokeLoading = true
|
const form = JSON.parse(JSON.stringify(data))
|
form.approvalStatus = that.dictReimburseApproveStatusReviewed
|
that.crud.crudMethod.approve(form).then(() => {
|
that.crud.refresh()
|
that.revokeLoading = false
|
that.$message({ type: 'success', message: '撤销成功' })
|
that.$refs[`popover_${data.id}`].showPopper = false
|
}).catch(err => {
|
that.$message({
|
type: 'error',
|
message: err.response.data.message
|
})
|
})
|
},
|
|
// 取消审批
|
cancelApprove() {
|
const that = this
|
that.approveModal.approveLoading = false
|
if (that.$refs['approveForm']) {
|
that.$refs['approveForm'].resetFields()
|
}
|
that.crud.resetForm()
|
that.approveModal.visible = false
|
},
|
|
// 批量审核
|
batchApprove(type, data) {
|
const that = this
|
|
const msg = type === 2 ? '批量拒绝' : '批量同意'
|
const msgType = type === 2 ? 'error' : 'success'
|
const msgConfig = type === 2 ? {
|
showInput: true,
|
inputValidator: (val) => {
|
return val !== null && val.trim() !== ''
|
},
|
inputErrorMessage: '请输入拒绝原因'
|
} : {
|
showInput: false
|
}
|
// 确认框
|
that.$prompt('此操作将' + msg + '审核内容是否继续?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: msgType,
|
...msgConfig
|
}).then(reasonVal => {
|
const ids = []
|
// 循环数据
|
for (let i = 0; i < data.length; i++) {
|
// ID列表
|
if (data[i].wecomSpNo) {
|
continue
|
}
|
ids.push(data[i].id)
|
}
|
const paramType = type === 2 ? that.dictReimburseApproveStatusRefuse : that.dictReimburseApproveStatusAgree
|
that.crud.crudMethod.batchApprove({ type: paramType, ids: ids, reason: reasonVal.value ? reasonVal.value.trim() : undefined }).then(res => {
|
// 消息提示
|
that.$message({
|
type: 'success',
|
message: msg + '!'
|
})
|
// 刷新数据
|
that.crud.refresh()
|
})
|
})
|
},
|
|
// 获取文件信息
|
getFileInfo(info) {
|
const that = this
|
// 判断返回数据
|
if (info.length === 0) {
|
// 表单文件路径赋值
|
that.crud.form.filePath = null
|
// 解除附件上传Loading
|
that.fileUploadLoading = false
|
// 表单提交
|
that.crud.submitCU()
|
// 终止
|
return
|
}
|
// 循环返回数据
|
for (let i = 0; i < info.length; i++) {
|
// 判断循环下标
|
if (i === 0) {
|
// 表单文件路径赋值
|
that.crud.form.filePath = info[i].response == null || info[i].response === '' ? info[i].url.substring(info[i].url.indexOf('/file/'), info[i].url.length) : '/file/' + info[i].response.type + '/' + info[i].response.realName
|
} else {
|
// 表单文件路径赋值
|
that.crud.form.filePath += info[i].response == null || info[i].response === '' ? ',' + info[i].url.substring(info[i].url.indexOf('/file/'), info[i].url.length) : ',/file/' + info[i].response.type + '/' + info[i].response.realName
|
}
|
// 判断循环是否结束
|
if (i === info.length - 1) {
|
// 解除附件上传Loading
|
that.fileUploadLoading = false
|
// 表单提交
|
that.crud.submitCU()
|
return
|
}
|
}
|
},
|
// 再新增(企微)
|
reAdd(data) {
|
const that = this
|
that.crud.toAdd()
|
that.$set(that.form, 'userId', data.userId)
|
that.$set(that.form, 'approvalUserId', data.approvalUserId)
|
that.$set(that.form, 'projectId', data.projectId)
|
that.$set(that.form, 'reimburseTypes', data.reimburseType.split(','))
|
that.$set(that.form, 'reimburseReason', data.reimburseReason)
|
that.$set(that.form, 'expenseTypes', data.expenseType.split(','))
|
that.$set(that.form, 'startTime', data.startTime)
|
that.$set(that.form, 'endTime', data.endTime)
|
that.$set(that.form, 'expenseAmount', data.expenseAmount)
|
that.$set(that.form, 'expenseComment', data.expenseComment)
|
that.$set(that.form, 'filePath', data.filePath)
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.upload-tips {
|
color: red;
|
}
|
</style>
|