|
|
@@ -7,7 +7,7 @@
|
|
|
row-key="id"
|
|
|
:columns="columns"
|
|
|
:data-source="dataSource"
|
|
|
- :pagination="ipagination"
|
|
|
+ :pagination="false"
|
|
|
:loading="loading"
|
|
|
@change="handleTableChange"
|
|
|
/>
|
|
|
@@ -42,15 +42,34 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- this.loadTree()
|
|
|
+ this.getData()
|
|
|
},
|
|
|
+
|
|
|
methods: {
|
|
|
- loadTree() {
|
|
|
- this.treeData = []
|
|
|
- getAction(this.url.tree).then((res) => {
|
|
|
- if (res.code === 200) {
|
|
|
- this.treeData = res.data
|
|
|
- }
|
|
|
+ getData() {
|
|
|
+ this.columns[this.columns.length - 1].title = dayjs().format('M') + '月'
|
|
|
+ getAction(this.url.list).then((res) => {
|
|
|
+ const basicDataSource = res.data || []
|
|
|
+ const typeArr = []
|
|
|
+ basicDataSource.forEach(itemRow => {
|
|
|
+ const find = typeArr
|
|
|
+ .find(typeItem => typeItem.deptName === itemRow.deptName && typeItem.teamName === itemRow.teamName)
|
|
|
+ if (!find) {
|
|
|
+ const newTypeItem = {
|
|
|
+ deptName: itemRow.deptName,
|
|
|
+ teamName: itemRow.teamName,
|
|
|
+ children: [itemRow]
|
|
|
+ }
|
|
|
+ typeArr.push(newTypeItem)
|
|
|
+ } else {
|
|
|
+ find.children.push(itemRow)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ const newList = typeArr.reduce((arr, cur) => {
|
|
|
+ arr = arr.concat(cur.children)
|
|
|
+ return arr
|
|
|
+ }, [])
|
|
|
+ this.dataSource = newList || basicDataSource
|
|
|
})
|
|
|
}
|
|
|
}
|