Merge pull request 'master' (#16) from master into prod

Reviewed-on: http://git.feashow.cn/clay/mosr-web/pulls/16
This commit is contained in:
2024-03-18 07:43:36 +00:00
2 changed files with 43 additions and 5 deletions

View File

@@ -14,13 +14,18 @@
<el-button type="primary" @click="handleReset(queryInstance)" :icon="Refresh">重置</el-button> <el-button type="primary" @click="handleReset(queryInstance)" :icon="Refresh">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div class="table-header-btn">
<el-button type="info" @click="handleExpand" :icon="Sort">{{ isExpand ? '全部收起' : '全部展开' }}</el-button>
</div>
<el-table <el-table
:data="list" :data="list"
ref="tableTree" ref="tableTree"
:default-expand-all="isExpand"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
row-key="departmentId" row-key="departmentId"
:lazy="true" :lazy="true"
v-loading="loading" v-loading="loading"
@expand-change="expandChange"
@cell-click="cellClick" @cell-click="cellClick"
v-tabh v-tabh
> >
@@ -32,7 +37,7 @@
</template> </template>
<script setup> <script setup>
import {Search, Refresh} from "@element-plus/icons-vue"; import {Search, Refresh,Sort} from "@element-plus/icons-vue";
import {getDepartmentList} from "@/api/subsidiary"; import {getDepartmentList} from "@/api/subsidiary";
const queryInstance = ref() const queryInstance = ref()
const queryParams = reactive({ const queryParams = reactive({
@@ -41,12 +46,27 @@ const queryParams = reactive({
departmentName: '' departmentName: ''
}) })
const loading = ref(true) const loading = ref(true)
const isExpand = ref(true)
const list = ref([]) const list = ref([])
const tableTree = ref() const tableTree = ref()
const cellClick = (row,column) => { const cellClick = (row,column) => {
// if ("operation" !== column.property){ if ("operation" !== column.property){
// tableTree.value.toggleRowExpansion(row) tableTree.value.toggleRowExpansion(row)
// } }
}
const handleExpand = () => {
isExpand.value = !isExpand.value
expandChange(list.value, isExpand)
getList()
}
//
const expandChange = (data, isExpansion) => {
for (let i = 0; i < data.length; i++) {
tableTree.value.toggleRowExpansion(data[i], isExpansion);
if (data[i].children !== null) {
expandChange(data[i].children, isExpansion);
}
}
} }
const handleReset = (instance) => { const handleReset = (instance) => {
if (!instance) return if (!instance) return

View File

@@ -14,6 +14,9 @@
<el-button type="primary" @click="handleReset(queryInstance)" :icon="Refresh">重置</el-button> <el-button type="primary" @click="handleReset(queryInstance)" :icon="Refresh">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div class="table-header-btn">
<el-button type="info" @click="handleExpand" :icon="Sort">{{ isExpand ? '全部收起' : '全部展开' }}</el-button>
</div>
<el-table <el-table
:data="list" :data="list"
ref="tableTree" ref="tableTree"
@@ -22,6 +25,7 @@
row-key="subCompanyId" row-key="subCompanyId"
:lazy="true" :lazy="true"
v-loading="loading" v-loading="loading"
@expand-change="expandChange"
@cell-click="cellClick" @cell-click="cellClick"
v-tabh v-tabh
> >
@@ -33,7 +37,7 @@
</template> </template>
<script setup> <script setup>
import {Search, Refresh} from "@element-plus/icons-vue"; import {Search, Refresh,Sort} from "@element-plus/icons-vue";
import {getSubCompanyList} from "@/api/subsidiary"; import {getSubCompanyList} from "@/api/subsidiary";
const queryInstance = ref() const queryInstance = ref()
const queryParams = reactive({ const queryParams = reactive({
@@ -50,6 +54,20 @@ const cellClick = (row,column) => {
tableTree.value.toggleRowExpansion(row) tableTree.value.toggleRowExpansion(row)
} }
} }
const handleExpand = () => {
isExpand.value = !isExpand.value
expandChange(list.value, isExpand)
getList()
}
//
const expandChange = (data, isExpansion) => {
for (let i = 0; i < data.length; i++) {
tableTree.value.toggleRowExpansion(data[i], isExpansion);
if (data[i].children !== null) {
expandChange(data[i].children, isExpansion);
}
}
}
const handleReset = (instance) => { const handleReset = (instance) => {
if (!instance) return if (!instance) return
instance.resetFields() instance.resetFields()