|
@@ -45,7 +45,7 @@
|
|
|
|
|
|
<script>
|
|
|
import {
|
|
|
- // getSalaryCalculateTemplate,
|
|
|
+ getSalaryCalculateTemplate,
|
|
|
uploadSalaryCalculateFiles,
|
|
|
getSalaryCalculateFiles
|
|
|
} from '@/api/salary'
|
|
@@ -55,18 +55,15 @@ export default {
|
|
|
data () {
|
|
|
return {
|
|
|
searchValues: {
|
|
|
- month: dateFormat('YYYY-mm', new Date()),
|
|
|
- category: null
|
|
|
+ month: dateFormat('YYYY-mm', new Date())
|
|
|
},
|
|
|
queryValues: {},
|
|
|
filesValues: {},
|
|
|
- // categoryItems: [],
|
|
|
- items: [],
|
|
|
+ categoryItems: [],
|
|
|
historyItems: [],
|
|
|
formItems: [],
|
|
|
headers: [
|
|
|
{ label: '月份', prop: 'month', width: 100 },
|
|
|
- // { label: '绩效方案', prop: 'category' },
|
|
|
{ label: '文件类型', prop: 'fileName' },
|
|
|
{ label: '已上传文件', prop: 'history' },
|
|
|
{ label: '待上传文件', prop: 'file' },
|
|
@@ -74,22 +71,25 @@ export default {
|
|
|
],
|
|
|
loading: false,
|
|
|
submitLoading: false,
|
|
|
- runLoading: false
|
|
|
+ runLoading: false,
|
|
|
+ categoryType: null
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
- // items () {
|
|
|
- // const items = this.categoryItems.find(e => e.category === this.queryValues.category)?.files
|
|
|
- // if (!items) {
|
|
|
- // return []
|
|
|
- // }
|
|
|
- // return items.map(e => {
|
|
|
- // return {
|
|
|
- // ...e,
|
|
|
- // history: this.historyItems.find(h => h.fileType === e.fileType)?.fileOriginalFilename
|
|
|
- // }
|
|
|
- // })
|
|
|
- // },
|
|
|
+ items () {
|
|
|
+ const items = this.categoryItems.reduce((res, v) => {
|
|
|
+ return res.concat(v.files)
|
|
|
+ }, [])
|
|
|
+ if (!items) {
|
|
|
+ return []
|
|
|
+ }
|
|
|
+ return items.map(e => {
|
|
|
+ return {
|
|
|
+ ...e,
|
|
|
+ history: this.historyItems.find(h => h.fileType === e.fileType)?.fileOriginalFilename
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
searchItems () {
|
|
|
return [
|
|
|
{
|
|
@@ -104,21 +104,6 @@ export default {
|
|
|
placeholder: '选择更新月份'
|
|
|
}
|
|
|
}
|
|
|
- // {
|
|
|
- // label: '绩效方案',
|
|
|
- // prop: 'category',
|
|
|
- // type: 'select',
|
|
|
- // options: {
|
|
|
- // clearable: false,
|
|
|
- // placeholder: '选择业务线',
|
|
|
- // items: this.categoryItems.map(e => {
|
|
|
- // return {
|
|
|
- // label: e.category,
|
|
|
- // value: e.category
|
|
|
- // }
|
|
|
- // })
|
|
|
- // }
|
|
|
- // }
|
|
|
]
|
|
|
}
|
|
|
},
|
|
@@ -127,6 +112,26 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
async onInit () {
|
|
|
+ try {
|
|
|
+ const { data } = await getSalaryCalculateTemplate()
|
|
|
+ this.categoryItems = data
|
|
|
+ if (!data.length) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.categoryType = data[0].category
|
|
|
+ this.queryValues = { ...this.searchValues }
|
|
|
+ this.filesValues = {
|
|
|
+ ...this.items.reduce((res, v) => {
|
|
|
+ res[v.fileType] = null
|
|
|
+ return res
|
|
|
+ }, {})
|
|
|
+ }
|
|
|
+ this.onGetHistory()
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async onGetHistory () {
|
|
|
try {
|
|
|
this.loading = true
|
|
|
const { data } = await getSalaryCalculateFiles(this.queryValues)
|
|
@@ -138,25 +143,9 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
onSearch (query) {
|
|
|
- // if (!query.category) {
|
|
|
- // this.searchValues.category = this.categoryItems[0]?.category ?? null
|
|
|
- // }
|
|
|
this.queryValues = { ...this.searchValues }
|
|
|
this.onInit()
|
|
|
},
|
|
|
- // onChange () {
|
|
|
- // const items = this.categoryItems.find(e => e.category === this.queryValues.category)?.files ?? []
|
|
|
- // if (!items.length) {
|
|
|
- // this.filesValues = {}
|
|
|
- // return
|
|
|
- // }
|
|
|
- // this.filesValues = {
|
|
|
- // ...items.reduce((res, v) => {
|
|
|
- // res[v.fileType] = null
|
|
|
- // return res
|
|
|
- // }, {})
|
|
|
- // }
|
|
|
- // },
|
|
|
onExceed (files, fileList, key) {
|
|
|
this.filesValues[key] = files[0]
|
|
|
},
|
|
@@ -179,7 +168,6 @@ export default {
|
|
|
this.$confirm(h('div', [
|
|
|
h('p', undefined, '确定要更新文件吗?'),
|
|
|
h('p', undefined, `更新月份:${this.queryValues.month}`),
|
|
|
- h('p', undefined, `更新物业线:${this.queryValues.category}`),
|
|
|
h('p', { style: 'color: red' }, '上传文件后,将覆盖之前的文件,请谨慎操作!')
|
|
|
]), '提示').then(async () => {
|
|
|
this.submitLoading = true
|
|
@@ -191,9 +179,10 @@ export default {
|
|
|
}
|
|
|
formData.append('files', this.filesValues[key])
|
|
|
formData.append('fileTypes', key)
|
|
|
+ // this.items.find()
|
|
|
})
|
|
|
formData.append('month', this.queryValues.month)
|
|
|
- formData.append('category', this.queryValues.category)
|
|
|
+ formData.append('category', this.categoryType)
|
|
|
await uploadSalaryCalculateFiles(formData)
|
|
|
this.$message.success('保存成功')
|
|
|
this.onInit()
|