- 在成本详情、支出详情和分摊详情页面中重新启用年份和月份选择功能 -优化日期选择器的格式和价值格式 - 在搜索时去除月份参数的前置0,确保正确传递参数 - 调整搜索表单的样式,移除多余的样式属性
326 lines
8.1 KiB
Vue
326 lines
8.1 KiB
Vue
<template>
|
|
<fvSearchForm :searchConfig="searchConfig" @search="search" ></fvSearchForm>
|
|
<!-- <el-button color="#DED0B2" style="float: left;margin: 0 10px 10px 0" @click="exportTable">导出</el-button>-->
|
|
|
|
<fvTable ref="tableIns" :tableConfig="tableConfig" @headBtnClick="headBtnClick" @selectionChange="selectionChange">
|
|
<template #empty>
|
|
<el-empty description="暂无数据"/>
|
|
</template>
|
|
</fvTable>
|
|
</template>
|
|
|
|
<script setup lang="jsx">
|
|
import fvSelect from '@/fvcomponents/fvSelect/index.vue'
|
|
|
|
import { getSubCompOpt } from '@/api/user/user.js';
|
|
import {reactive, ref} from "vue";
|
|
import {shareDetailExport, shareExportExcel} from "@/api/expense-manage";
|
|
import {ElMessage} from "element-plus";
|
|
import {
|
|
getCostMasterProjectNameOption, getCostSubprojectNameOption,
|
|
getMasterProjectNameOption,
|
|
getSubprojectNameOption
|
|
} from "@/api/project-demand/summary/index.js";
|
|
const router = useRouter()
|
|
const route = useRoute()
|
|
const searchConfig = ref([
|
|
{
|
|
label: '年份',
|
|
prop: 'paymentYear',
|
|
component: 'el-date-picker',
|
|
props: {
|
|
placeholder: '请选择年份',
|
|
clearable: true,
|
|
type: 'year',
|
|
format: 'YYYY',
|
|
valueFormat: 'YYYY',
|
|
},
|
|
colProps: {}
|
|
},
|
|
{
|
|
label: '月份',
|
|
prop: 'paymentMonth',
|
|
component: 'el-date-picker',
|
|
props: {
|
|
placeholder: '请选择月份',
|
|
clearable: true,
|
|
type: 'month',
|
|
format: 'M',
|
|
valueFormat: 'M',
|
|
},
|
|
colProps: {}
|
|
},
|
|
{
|
|
label: '主项目',
|
|
prop: 'masterProjectName',
|
|
component: shallowRef(fvSelect),
|
|
props: {
|
|
placeholder: '请输入主项目',
|
|
clearable: true,
|
|
filterable: true,
|
|
options: [],
|
|
remote: true,
|
|
remoteMethod:async (val)=>{
|
|
console.log('val',val)
|
|
searchConfig.value.find(item => item.prop == 'masterProjectName').props.options= JSON.parse(localStorage.getItem("masterProjectNameOption"))
|
|
|
|
if(val){
|
|
|
|
await getMasterProjectName( val)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
{
|
|
label: '子项目',
|
|
prop: 'subProjectName',
|
|
component: shallowRef(fvSelect),
|
|
props: {
|
|
placeholder: '请输入子项目',
|
|
clearable: true,
|
|
filterable: true,
|
|
options: [],
|
|
remote: true,
|
|
remoteMethod:async (val)=>{
|
|
searchConfig.value.find(item => item.prop == 'subProjectName').props.options= JSON.parse(localStorage.getItem("subprojectNameOption"))
|
|
|
|
if(val){
|
|
await getSubprojectName(val)
|
|
|
|
}
|
|
}
|
|
},
|
|
},
|
|
// {
|
|
// label: '支付月份',
|
|
// prop: 'apportionmentMonth',
|
|
// component: 'el-date-picker',
|
|
// props: {
|
|
// placeholder: '请选择支付月份',
|
|
// clearable: true,
|
|
// type:'month',
|
|
// format: 'YYYY-MM',
|
|
// valueFormat:"YYYY-MM"
|
|
// },
|
|
// colProps: {}
|
|
// },
|
|
// {
|
|
// label: '人员性质',
|
|
// prop: 'personnelNature',
|
|
// component: shallowRef(fvSelect),
|
|
// props: {
|
|
// placeholder: '请选择人员性质',
|
|
// clearable: true,
|
|
// filterable: true,
|
|
// cacheKey: 'nature_of_personnel'
|
|
// }
|
|
// },
|
|
])
|
|
const tableIns = ref()
|
|
const selectData = ref([])
|
|
const tableConfig = reactive({
|
|
columns: [
|
|
{
|
|
type: 'selection',
|
|
prop: 'selection',
|
|
},
|
|
// {
|
|
// prop: 'name',
|
|
// type: 'index',
|
|
// label: '序号',
|
|
// align: 'center',
|
|
// width:85,
|
|
// index: index => {
|
|
// return (tableIns.value.getQuery().pageNum - 1) * tableIns.value.getQuery().pageSize + index + 1
|
|
// }
|
|
// },
|
|
{
|
|
prop: 'paymentYear',
|
|
label: '支付年份',
|
|
align: 'center'
|
|
},
|
|
{
|
|
prop: 'paymentMonth',
|
|
label: '支付月份',
|
|
align: 'center'
|
|
},
|
|
|
|
{
|
|
prop: 'masterProjectName',
|
|
label: '主项目',
|
|
align: 'center',
|
|
},
|
|
|
|
{
|
|
prop: 'subProjectName',
|
|
label: '子项目',
|
|
align: 'center',
|
|
},
|
|
{
|
|
prop: 'researchPersonnel',
|
|
label: '研发人员',
|
|
align: 'center',
|
|
showOverflowTooltip: false,
|
|
},
|
|
{
|
|
prop: 'personnelNature',
|
|
label: '人员性质',
|
|
align: 'center',
|
|
width: 120,
|
|
showOverflowTooltip: false,
|
|
currentRender: ({row, index}) => {
|
|
if (row.personnelNature&&row.personnelNature !== null&&row.personnelNature!==undefined) {
|
|
return (<Tag dictType={'nature_of_personnel'} value={row.personnelNature}/>)
|
|
} else {
|
|
return '--'
|
|
}
|
|
}
|
|
},
|
|
{
|
|
prop: 'researchDuration',
|
|
label: '当月研发工时(天)',
|
|
align: 'center',
|
|
// currentRender:({row})=>{
|
|
// return <span>{toThousands(row.afterTax)}</span>
|
|
// }
|
|
},
|
|
{
|
|
prop: 'workday',
|
|
label: '当月总工时(天)',
|
|
align: 'center',
|
|
showOverflowTooltip: false,
|
|
},
|
|
{
|
|
prop: 'subtotal',
|
|
label: '人工成本分摊(元)',
|
|
align: 'center',
|
|
},
|
|
|
|
],
|
|
api: '/workflow/mosr/cost/share',
|
|
params: {},
|
|
btns: [
|
|
{name: '添加分摊', key: 'add', color: '#DED0B2'},
|
|
{name: '导出', key: 'export', color: '#DED0B2'}
|
|
],
|
|
export:{
|
|
open :false,
|
|
}
|
|
})
|
|
const getMasterProjectName =async (val) => {
|
|
const res=await getCostMasterProjectNameOption(val)
|
|
if(res.code==1000){
|
|
let optionObj={}
|
|
let optionsMap = new Map();
|
|
res.data.forEach(item=>{
|
|
optionObj={
|
|
value:item.label,
|
|
label:item.label
|
|
}
|
|
optionsMap.set(optionObj.value, optionObj);
|
|
})
|
|
if(!val){
|
|
localStorage.setItem('masterProjectNameOption', JSON.stringify(Array.from(optionsMap.values())))
|
|
}
|
|
// 将 Map 转换为数组
|
|
searchConfig.value.find(item => item.prop == 'masterProjectName').props.options = Array.from(optionsMap.values())
|
|
}
|
|
}
|
|
const getSubprojectName =async (val) => {
|
|
const res=await getCostSubprojectNameOption(val)
|
|
if(res.code==1000){
|
|
let optionObj={}
|
|
let optionsMap = new Map();
|
|
res.data.forEach(item=>{
|
|
optionObj={
|
|
value:item.label,
|
|
label:item.label
|
|
}
|
|
optionsMap.set(optionObj.value, optionObj);
|
|
})
|
|
if(!val){
|
|
localStorage.setItem('subprojectNameOption', JSON.stringify(Array.from(optionsMap.values())))
|
|
}
|
|
// 将 Map 转换为数组
|
|
searchConfig.value.find(item => item.prop == 'subProjectName').props.options = Array.from(optionsMap.values())
|
|
}
|
|
}
|
|
getMasterProjectName()
|
|
getSubprojectName()
|
|
|
|
const search = (val) => {
|
|
let param={
|
|
...val
|
|
}
|
|
if (param.paymentMonth) {
|
|
param.paymentMonth = parseInt(param.paymentMonth, 10).toString();
|
|
}
|
|
tableConfig.params = {...param}
|
|
tableIns.value.refresh()
|
|
}
|
|
const headBtnClick = (key) => {
|
|
switch (key) {
|
|
case 'add':
|
|
handleAdd()
|
|
break;
|
|
case 'export':
|
|
exportTable()
|
|
break;
|
|
}
|
|
}
|
|
|
|
const selectionChange = (data) => {
|
|
console.log('data', data)
|
|
selectData.value=data.map(item=>item.id)
|
|
}
|
|
const exportTable = () => {
|
|
console.log('selectData',selectData.value)
|
|
if (selectData.value.length === 0) {
|
|
ElMessage.warning('请选择要导出的费用分摊')
|
|
return
|
|
}
|
|
shareDetailExport(selectData.value).then(res => {
|
|
console.log(res)
|
|
let fileName = `科技研发项目工时及成本分摊汇总表.xlsx`
|
|
const blob = new Blob([res.data])
|
|
let a = document.createElement('a')
|
|
a.href = URL.createObjectURL(blob)
|
|
a.download = fileName
|
|
a.click()
|
|
})
|
|
}
|
|
const handleAdd = () => {
|
|
router.push({
|
|
name: 'Sharedetail/add',
|
|
query: {}
|
|
})
|
|
}
|
|
const init = async () => {
|
|
const res = await getSubCompOpt()
|
|
searchConfig.value.find(item=>item.prop == 'affiliatedCompanyIds').props.data = res.data
|
|
}
|
|
|
|
// init()
|
|
|
|
</script>
|
|
<style scoped lang="scss">
|
|
:deep(.el-table__header) {
|
|
.is-leaf:first-child {
|
|
.cell {
|
|
//margin-left: -25px !important;
|
|
}
|
|
}
|
|
}
|
|
|
|
:deep(.el-table__body) {
|
|
.el-table__cell:first-child {
|
|
.cell {
|
|
//margin-left: -13px !important;
|
|
}
|
|
}
|
|
}
|
|
:deep(.el-date-editor--month){
|
|
width: 100%;
|
|
}
|
|
</style>
|