Commit 7cdd772c authored by tianhongyang's avatar tianhongyang

fix

parent 8a7112f6
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
<div class="custom-table-item"> <div class="custom-table-item">
<el-table v-if="tableDataTotal>0" class="custom-table" v-loading="comTableLoading" :data="tableData" element-loading-text="加载中" <el-table v-if="tableDataTotal>0" class="custom-table" v-loading="comTableLoading" :data="tableData" element-loading-text="加载中"
ref="customTableRef" border fit highlight-current-row :default-sort="defaultSort?defaultSort:{}" @sort-change="sortChange" ref="customTableRef" border fit highlight-current-row :default-sort="defaultSort?defaultSort:{}" @sort-change="sortChange"
@selection-change="selectionChange" :cell-class-name="cellClassName" :cell-style="cellStyle" :row-class-name="rowClassName" @selection-change="selectionChange" @expand-change="expandChange" :cell-class-name="cellClassName" :cell-style="cellStyle"
:row-style="rowStyle" :row-key="rowKey" :lazy="lazy" :load="loadFn" :tree-props="treeOptions" :height="height" :maxHeight="comMaxHeight" :row-class-name="rowClassName" :row-style="rowStyle" :row-key="rowKey" :lazy="lazy" :load="loadFn" :tree-props="treeOptions"
v-sticky-header="stickyHeader"> :default-expand-all="defaultExpandAll" :indent="indent" :height="height" :maxHeight="comMaxHeight" v-sticky-header="stickyHeader">
<!-- 列二次封装 --> <!-- 列二次封装 -->
<template v-for="(item,index) of formColum"> <template v-for="(item,index) of formColum">
...@@ -87,6 +87,20 @@ export default { ...@@ -87,6 +87,20 @@ export default {
type: Object, type: Object,
default: () => ({}) default: () => ({})
}, },
// 树形结构默认展开行
defaultExpandAll: {
type: Boolean,
default: false
},
// 树形结构展示事件
expandChange: {
type: Function,
default: () => { }
},
indent: {
type: Number,
default: 16
},
// 吸顶偏移量 // 吸顶偏移量
stickyHeader: { stickyHeader: {
type: Object, type: Object,
...@@ -443,7 +457,7 @@ export default { ...@@ -443,7 +457,7 @@ export default {
padding-right: 12px; padding-right: 12px;
padding-left: 12px; padding-left: 12px;
line-height: 21px; line-height: 21px;
font-size: 14px; font-size: 12px;
font-weight: 400; font-weight: 400;
} }
......
...@@ -33,10 +33,10 @@ ...@@ -33,10 +33,10 @@
<!-- 数据列表部分 --> <!-- 数据列表部分 -->
<div class="project-feedsummary-list-container"> <div class="project-feedsummary-list-container">
<dsk-skeleton v-if="tableLoading"></dsk-skeleton> <dsk-skeleton v-if="tableLoading"></dsk-skeleton>
<!-- 非实体工程材料列表 --> <el-form :model="dataForm" ref="costSummaryForm" :show-message="false" v-else-if="!tableLoading" class="feed-summary-form">
<el-form :model="dataForm" ref="feedSummaryForm" :show-message="false" v-else-if="!tableLoading" class="feed-summary-form"> <custom-table ref="costSummaryTable" :tableData="dataForm.tableDataList" :formColum="formColum" :max-height="true" :row-key="rowKey"
<custom-table :tableData="dataForm.tableDataList" :formColum="formColum" :max-height="true" :row-key="rowKey" :lazy="true" :lazy="true" :load-fn="tableLazyLoad" :tree-options="treeOptions" :default-expand-all="true" :indent="8" :tableDataTotal="total"
:load-fn="tableLazyLoad" :tree-options="treeOptions" :tableDataTotal="total" :paging="false" :cell-class-name="cellClassName"> :paging="false" :cell-class-name="cellClassName">
</custom-table> </custom-table>
</el-form> </el-form>
</div> </div>
...@@ -125,8 +125,8 @@ export default { ...@@ -125,8 +125,8 @@ export default {
total: 0, total: 0,
// 列表表头 // 列表表头
formColum: [ formColum: [
{ label: '序号', prop: "number", width: "53", uid: v4() }, { label: '序号', prop: "number", minWidth: "53", uid: v4() },
{ label: '名称', prop: "cbName", width: "303", uid: v4() }, { label: '名称', prop: "cbName", width: "303", uid: v4(), showOverflowTooltip: true },
], ],
monthList: [], monthList: [],
rowKey: "id", rowKey: "id",
...@@ -171,9 +171,13 @@ export default { ...@@ -171,9 +171,13 @@ export default {
methods: { methods: {
cellClassName({ row, column, rowIndex, columnIndex }) { cellClassName({ row, column, rowIndex, columnIndex }) {
// console.log(column); // console.log(column);
const { property } = column; if (columnIndex == 0) {
if (editPropNames.includes(property)) { return "number-index-td";
return `can-edit-column-${property}`; } else {
const { property } = column;
if (editPropNames.includes(property)) {
return `can-edit-column-${property}`;
}
} }
return ""; return "";
}, },
...@@ -338,32 +342,73 @@ export default { ...@@ -338,32 +342,73 @@ export default {
const list = await getCostSummaryListApi(params); const list = await getCostSummaryListApi(params);
if (list.code == 200 && list.data instanceof Array) { if (list.code == 200 && list.data instanceof Array) {
let _temp = list.data; let _temp = list.data;
const _mapList = new Map();
// 如果有长度循环处理字段 // 如果有长度循环处理字段
if (_temp.length) { if (_temp.length) {
_temp = _temp.map(item => { _temp = _temp.map(item => {
if (!item.hasChildren) { if (!item.hasChildren) {
item.hasChildren = false; item.hasChildren = false;
} else { } else {
// 有children
item.hasChildren = true; item.hasChildren = true;
}; };
// 储存将子级储存到map 主动调用展开菜单
_mapList.set(item.id, item.children ? cloneDeep(item.children) : []);
delete item.children;
return item; return item;
}); });
} }
console.log(_temp);
this.$set(this.dataForm, "tableDataList", cloneDeep(_temp)); this.$set(this.dataForm, "tableDataList", cloneDeep(_temp));
this.originTableDataList = cloneDeep(_temp); this.originTableDataList = cloneDeep(_temp);
this.total = _temp.length; this.total = _temp.length;
this.tableLoading = false;
await this.$nextTick();
const tableIns = this.$refs["costSummaryTable"].$refs["customTableRef"];
if (tableIns) {
_mapList.forEach((child, id) => {
child = child.map(item => {
item.hasChildren = item.hasChildren ? true : false;
return item;
});
// 打开一级菜单
this.customResolve(id, child, tableIns);
});
}
} }
} catch (error) { } catch (error) {
console.log(error);
} finally {
this.tableLoading = false; this.tableLoading = false;
console.log(error);
} }
}, },
// 模拟 resolve 懒加载
customResolve(id, child, tableIns, level = 1) {
let children = child;
let newKey = id;
let treeNodeMap = tableIns.store.states.lazyTreeNodeMap;
let treeData = tableIns.store.states.treeData;
//treeData 添加父子关系和状态
let childrenids = Array.from(children).map(item => item.id);
let metaInfo = {
children: childrenids,
display: true,
expanded: true,//这里设置展开
lazy: true,
level,
loaded: true,
loading: false
};
this.$set(treeData, newKey, metaInfo);
//lazyTreeNodeMap中 添加数据
this.$set(treeNodeMap, newKey, children);
console.log(treeData);
},
async getCostSummaryListLazy(params = {}) { async getCostSummaryListLazy(params = {}) {
try { try {
const list = await getCostSummaryListApi(params); const list = await getCostSummaryListApi(params);
if (list.code == 200 && list.data instanceof Array) { if (list.code == 200 && list.data instanceof Array) {
let _temp = list.data; let _temp = list.data?.length ? list.data[0] : {};
_temp = _temp.children?.length ? _temp.children : [];
// 如果有长度循环处理字段 // 如果有长度循环处理字段
if (_temp.length) { if (_temp.length) {
_temp = _temp.map(item => { _temp = _temp.map(item => {
...@@ -384,6 +429,7 @@ export default { ...@@ -384,6 +429,7 @@ export default {
// 列表懒加载 // 列表懒加载
async tableLazyLoad(row, treeNode, resolve) { async tableLazyLoad(row, treeNode, resolve) {
try { try {
console.log(treeNode);
const { id } = row; const { id } = row;
const { cbType, expenseDate } = this.createRequestConditions(); const { cbType, expenseDate } = this.createRequestConditions();
const params = { const params = {
...@@ -392,8 +438,7 @@ export default { ...@@ -392,8 +438,7 @@ export default {
}; };
expenseDate ? params["expenseDate"] = expenseDate : null; expenseDate ? params["expenseDate"] = expenseDate : null;
const _lazyResult = await this.getCostSummaryListLazy(params); const _lazyResult = await this.getCostSummaryListLazy(params);
resolve(_lazyResult ? _lazyResult : null);
resolve([]);
} catch (error) { } catch (error) {
} }
...@@ -571,7 +616,7 @@ export default { ...@@ -571,7 +616,7 @@ export default {
} }
::v-deep .custom-table-list-com-ins { ::v-deep .custom-table-list-com-ins {
.table-item { .custom-table-item {
.el-table { .el-table {
th { th {
height: 40px; height: 40px;
...@@ -580,6 +625,15 @@ export default { ...@@ -580,6 +625,15 @@ export default {
font-size: 14px; font-size: 14px;
font-weight: 350; font-weight: 350;
} }
.number-index-td {
.cell {
display: flex;
align-items: center;
.el-table__expand-icon {
margin-right: 5px;
}
}
}
.inner-edit-input-item { .inner-edit-input-item {
margin-bottom: 0px; margin-bottom: 0px;
......
...@@ -851,7 +851,7 @@ export default { ...@@ -851,7 +851,7 @@ export default {
} }
::v-deep .custom-table-list-com-ins { ::v-deep .custom-table-list-com-ins {
.table-item { .custom-table-item {
.el-table { .el-table {
th { th {
height: 40px; height: 40px;
......
...@@ -467,7 +467,7 @@ export default { ...@@ -467,7 +467,7 @@ export default {
} }
::v-deep .custom-table-list-com-ins { ::v-deep .custom-table-list-com-ins {
.table-item { .custom-table-item {
.el-table { .el-table {
th { th {
height: 40px; height: 40px;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment