<template>
|
<div class="app-container">
|
<!--工具栏-->
|
<div class="head-container">
|
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
<crudOperation :permission="permission" />
|
<!--表单组件-->
|
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="600px">
|
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px">
|
<el-form-item label="费用类型" prop="expenseType">
|
<el-select v-model="form.expenseType" placeholder="请选择" filterable clearable style="width: 440px;">
|
<el-option
|
v-for="item in dict[expenseType]"
|
:key="item.id"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="所属营业计划" prop="businessPlanId">
|
<el-select v-model="form.businessPlanId" placeholder="请选择" filterable clearable style="width: 440px;">
|
<el-option
|
v-for="item in businessPlanList"
|
:key="item.id"
|
:label="item.businessContent"
|
:value="item.id"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="所属项目">
|
<el-select v-model="form.projectId" placeholder="请选择" filterable clearable style="width: 440px;">
|
<el-option
|
v-for="item in projectList"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-button size="mini" type="primary" icon="el-icon-plus" style="position: relative; left: 464px;" @click="reimbursementAdd()" />
|
<el-table ref="table" :data="form.businessExpenseReimbursementDtoList" size="small" style="width: 100%;">
|
<el-table-column :show-overflow-tooltip="true" prop="reimbursementContent" label="报销内容" />
|
<el-table-column :show-overflow-tooltip="true" prop="reimbursementAmount" label="报销金额">
|
<template slot-scope="scope">
|
{{ crud.toMoney(scope.row.reimbursementAmount) }}
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="reimbursementVoucher" label="报销凭证">
|
<template slot-scope="scope">
|
<el-image
|
:src="scope.row.reimbursementVoucher != null && scope.row.reimbursementVoucher !== '' ? baseApi + scope.row.reimbursementVoucher.split(',')[0] : ''"
|
:preview-src-list="scope.row.reimbursementVoucher != null && scope.row.reimbursementVoucher !== '' ? scope.row.reimbursementVoucher.split(',').map(item => { return baseApi + item }) : []"
|
style="width: 100px;"
|
>
|
<div slot="placeholder" class="image-slot">
|
加载中...
|
</div>
|
<div slot="error" class="image-slot">
|
暂无图片
|
</div>
|
</el-image>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" width="150px" align="center">
|
<template slot-scope="scope">
|
<el-button size="mini" type="primary" icon="el-icon-edit" @click="reimbursementEdit(scope.row)" />
|
<el-button size="mini" type="danger" icon="el-icon-delete" @click="reimbursementDelete(scope.row)" />
|
</template>
|
</el-table-column>
|
</el-table>
|
<el-form-item label="备注" style="margin-top: 20px;">
|
<el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 440px;" />
|
</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" type="primary" @click="crud.submitCU">确认</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 type="expand">
|
<template slot-scope="props">
|
<el-table :data="props.row.businessExpenseReimbursementDtoList" style="margin: 10px 20px 10px 105px; width: calc(100% - 20px - 105px);">
|
<el-table-column :show-overflow-tooltip="true" prop="reimbursementContent" label="报销内容" />
|
<el-table-column :show-overflow-tooltip="true" prop="reimbursementAmount" label="报销金额">
|
<template slot-scope="scope">
|
{{ crud.toMoney(scope.row.reimbursementAmount) }}
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="reimbursementVoucher" label="报销凭证">
|
<template slot-scope="scope">
|
<el-image
|
:src="scope.row.reimbursementVoucher != null && scope.row.reimbursementVoucher !== '' ? baseApi + scope.row.reimbursementVoucher.split(',')[0] : ''"
|
:preview-src-list="scope.row.reimbursementVoucher != null && scope.row.reimbursementVoucher !== '' ? scope.row.reimbursementVoucher.split(',').map(item => { return baseApi + item }) : []"
|
style="width: 100px;"
|
>
|
<div slot="placeholder" class="image-slot">
|
加载中...
|
</div>
|
<div slot="error" class="image-slot">
|
暂无图片
|
</div>
|
</el-image>
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="remarks" label="备注" />
|
</el-table>
|
</template>
|
</el-table-column>
|
<el-table-column prop="expenseType" label="费用类型">
|
<template slot-scope="scope">
|
{{ dict.label[expenseType][scope.row.expenseType] }}
|
</template>
|
</el-table-column>
|
<el-table-column prop="businessPlanContent" label="所属营业计划" />
|
<el-table-column prop="projectName" label="所属项目" />
|
<el-table-column prop="amountReimbursementAmount" label="报销总金额">
|
<template slot-scope="scope">
|
{{ crud.toMoney(scope.row.amountReimbursementAmount) }}
|
</template>
|
</el-table-column>
|
<el-table-column prop="remarks" label="备注" />
|
<el-table-column prop="createTime" label="创建时间" />
|
<el-table-column label="操作" width="150px" align="center">
|
<template slot-scope="scope">
|
{{ scope.row.id }}
|
</template>
|
</el-table-column>
|
</el-table>
|
<!--分页组件-->
|
<pagination />
|
<!--表单组件-->
|
<el-dialog :close-on-click-modal="false" :before-close="reimbursementCancel" :visible.sync="reimbursementStatus" :title="reimbursementTitle" width="600px">
|
<el-form ref="reimbursementForm" :model="reimbursementForm" :rules="reimbursementRules" size="small" label-width="140px">
|
<el-form-item label="报销内容" prop="reimbursementContent">
|
<el-input v-model="reimbursementForm.reimbursementContent" style="width: 340px;" />
|
</el-form-item>
|
<el-form-item label="报销金额" prop="reimbursementAmount">
|
<money-input :key="random" v-model="reimbursementForm.reimbursementAmount" :width="340" />
|
</el-form-item>
|
<el-form-item label="报销凭证">
|
<image-upload ref="imageUpload" :key="random" :image-url="reimbursementForm.reimbursementVoucher == null || reimbursementForm.reimbursementVoucher === '' ? null : reimbursementForm.reimbursementVoucher" :limit="3" @imageInfo="getImageInfo" />
|
</el-form-item>
|
<el-form-item label="备注">
|
<el-input v-model="reimbursementForm.remarks" :rows="3" type="textarea" style="width: 340px;" />
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="text" @click="reimbursementCancel">取消</el-button>
|
<el-button :loading="reimbursementLoading" type="primary" @click="reimbursementSubmit('reimbursementForm')">确认</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import crudBusinessExpenseFlowable from '@/api/business/expenseFlowable'
|
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
import crudOperation from '@crud/CRUD.operation'
|
import pagination from '@crud/Pagination'
|
import constant from '../../../utils/constant'
|
import crudBusinessPlan from '@/api/business/plan'
|
import crudProject from '@/api/project/project'
|
import moneyInput from '../../assembly/moneyInput/index.vue'
|
import imageUpload from '../../assembly/imageUpload/index.vue'
|
import { mapGetters } from 'vuex'
|
|
const defaultForm = { id: null, expenseType: null, businessPlanId: null, projectId: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null, businessExpenseReimbursementDtoList: [] }
|
export default {
|
name: 'BusinessExpenseFlowableReport',
|
components: { pagination, crudOperation, moneyInput, imageUpload },
|
mixins: [presenter(), header(), form(defaultForm), crud()],
|
dicts: [constant.EXPENSE_TYPE],
|
cruds() {
|
return CRUD({ title: '营业费用', url: 'api/businessExpenseFlowable', idField: 'id', sort: 'id,desc', crudMethod: { ...crudBusinessExpenseFlowable }})
|
},
|
data() {
|
return {
|
permission: {
|
add: ['admin', 'businessExpenseFlowable:add'],
|
edit: ['admin', 'businessExpenseFlowable:edit'],
|
del: ['admin', 'businessExpenseFlowable:del'],
|
download: ['admin', 'businessExpenseFlowable:download']
|
},
|
rules: {
|
expenseType: [
|
{ required: true, message: '费用类型不能为空', trigger: 'change' }
|
],
|
businessPlanId: [
|
{ required: true, message: '所属营业计划不能为空', trigger: 'change' }
|
]
|
},
|
// 字典:费用类型
|
expenseType: constant.EXPENSE_TYPE,
|
// 随机数
|
random: 0,
|
// 营业计划列表
|
businessPlanList: [],
|
// 项目列表
|
projectList: [],
|
// 营业费用明细弹窗状态
|
reimbursementStatus: false,
|
// 营业费用明细弹窗标题
|
reimbursementTitle: '营业费用明细',
|
// 营业费用明细弹窗表单
|
reimbursementForm: {},
|
// 营业费用明细弹窗验证
|
reimbursementRules: {
|
businessExpenseId: [
|
{ required: true, message: '所属营业费用不能为空', trigger: 'change' }
|
],
|
reimbursementContent: [
|
{ required: true, message: '报销内容不能为空', trigger: 'blur' },
|
{ min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
|
],
|
reimbursementAmount: [
|
{ required: true, message: '报销金额不能为空', trigger: 'blur' }
|
]
|
},
|
// 营业费用明细弹窗操作
|
reimbursementExecute: {},
|
// 营业费用明细弹窗加载
|
reimbursementLoading: false
|
}
|
},
|
computed: {
|
...mapGetters([
|
'baseApi'
|
])
|
},
|
created() {
|
this.crud.optShow = {
|
add: true,
|
edit: false,
|
del: false,
|
download: false
|
}
|
},
|
methods: {
|
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
[CRUD.HOOK.beforeRefresh]() {
|
// 获取营业计划
|
this.getBusinessPlan()
|
// 获取项目
|
this.getProject()
|
return true
|
},
|
// 获取营业计划
|
getBusinessPlan() {
|
// 获取营业计划
|
crudBusinessPlan.getAll().then(res => {
|
// 营业计划列表
|
this.businessPlanList = res
|
})
|
},
|
// 获取项目
|
getProject() {
|
// 获取项目
|
crudProject.getAll().then(res => {
|
// 项目列表
|
this.projectList = res
|
})
|
},
|
// 营业费用明细弹窗新增
|
reimbursementAdd() {
|
// 指针重定义
|
const _this = this
|
// 营业费用明细弹窗表单
|
this.reimbursementForm = {}
|
// 营业费用明细弹窗状态
|
this.reimbursementStatus = true
|
// 营业费用明细弹窗操作
|
this.reimbursementExecute = {}
|
// 表单清空
|
setTimeout(function() {
|
_this.$refs['reimbursementForm'].clearValidate()
|
}, 3)
|
// 随机数
|
this.random = Math.random()
|
},
|
// 营业费用明细弹窗修改
|
reimbursementEdit(data) {
|
// 营业费用明细弹窗表单
|
this.reimbursementForm = JSON.parse(JSON.stringify(data))
|
// 营业费用明细弹窗状态
|
this.reimbursementStatus = true
|
// 营业费用明细弹窗操作
|
this.reimbursementExecute = JSON.parse(JSON.stringify(data))
|
// 随机数
|
this.random = Math.random()
|
},
|
// 营业费用明细弹窗删除
|
reimbursementDelete(data) {
|
// 筛选费用明细人员
|
const reimbursementInfo = this.crud.form.businessExpenseReimbursementDtoList.filter(function(item) {
|
return item.reimbursementContent === data.reimbursementContent && item.reimbursementAmount === data.reimbursementAmount
|
})
|
// 获取下标
|
const subscript = this.crud.form.businessExpenseReimbursementDtoList.indexOf(reimbursementInfo[0])
|
// 营业费用明细移除元素
|
this.crud.form.businessExpenseReimbursementDtoList.splice(subscript, 1)
|
},
|
// 营业费用明细弹窗关闭
|
reimbursementCancel() {
|
// 营业费用明细弹窗状态
|
this.reimbursementStatus = false
|
},
|
// 营业费用明细弹窗提交
|
reimbursementSubmit(formName) {
|
this.$refs[formName].validate((valid) => {
|
if (valid) {
|
// 通过“this.$refs.imageUpload”找到子页面,“submit”是子页面的方法。
|
this.$refs.imageUpload.submit()
|
} else {
|
return false
|
}
|
})
|
},
|
// 获取图片信息
|
getImageInfo(info) {
|
// 判断返回数据
|
if (info.length === 0) {
|
// 表单图片路径赋值
|
this.reimbursementForm.reimbursementVoucher = null
|
// 表单提交
|
this.reimbursementSubmitCU()
|
// 终止
|
return
|
}
|
// 循环返回数据
|
for (let i = 0; i < info.length; i++) {
|
// 判断循环下标
|
if (i === 0) {
|
// 表单图片路径赋值
|
this.reimbursementForm.reimbursementVoucher = 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 {
|
// 表单图片路径赋值
|
this.reimbursementForm.reimbursementVoucher += 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) {
|
// 表单提交
|
this.reimbursementSubmitCU()
|
}
|
}
|
},
|
// 表单提交
|
reimbursementSubmitCU() {
|
// 判断营业费用明细弹窗操作
|
if (this.reimbursementExecute.reimbursementContent !== undefined) {
|
// 营业费用明细弹编辑
|
// 指针重定义
|
const _this = this
|
// 筛选营业费用明细弹
|
const reimbursementInfo = this.crud.form.businessExpenseReimbursementDtoList.filter(function(item) {
|
return item.reimbursementContent === _this.reimbursementExecute.reimbursementContent && item.reimbursementAmount === _this.reimbursementExecute.reimbursementAmount
|
})
|
// 营业费用明细弹更新
|
reimbursementInfo[0].reimbursementContent = this.reimbursementForm.reimbursementContent
|
reimbursementInfo[0].reimbursementAmount = this.reimbursementForm.reimbursementAmount
|
reimbursementInfo[0].reimbursementVoucher = this.reimbursementForm.reimbursementVoucher
|
reimbursementInfo[0].remarks = this.reimbursementForm.remarks
|
} else {
|
// 营业费用明细新增
|
this.crud.form.businessExpenseReimbursementDtoList.push(this.reimbursementForm)
|
}
|
// 营业费用明细弹窗关闭
|
this.reimbursementCancel()
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
|
</style>
|