|
|
<template> <!-- 移动 --> <el-dialog class="move-form" append-to-body :modal-append-to-body="false" :close-on-click-modal="false" :before-close="handleClose" :visible="moveVisible" title="移动"> <span class="dialog-right-top" /> <span class="dialog-left-bottom" /> <div class="setting-dialog"> <div class="move-main"> <div class="move-left"> <el-tree ref="treeMove" v-loading="crud.loading" :data="crud.data" node-key="id" :props="defaultProps" :expand-on-click-node="false" @node-click="handleMoveNodeClick" /> </div> <div class="move-right"> <div style="padding: 10px;"> <el-select v-model="query.status" placeholder="选择状态" style="width: 100px;" :disabled="selectedCategoryMove && selectedCategoryMove.arrangeType === 1"> <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" /> </el-select> <el-input v-model="query.keyWord" placeholder="输入题名或档号搜索" style="width: 200px;" /> <el-button class="filter-item filter-search" size="mini" type="success" icon="el-icon-search">搜索</el-button> </div> <div class="raido-main"> <!-- @select="handleSelect" @selection-change="selectionChangeHandler" @row-click="clickRowHandler" --> <el-table ref="table" v-loading="crud.loading" lazy :show-header="false" :data="tableData" :row-key="getRowKey" :tree-props="{children: 'children', hasChildren: 'hasChildren'}" highlight-current-row > <el-table-column type="selection" align="center" width="55" /> <el-table-column prop="status" label="状态" /> <el-table-column :show-overflow-tooltip="true" prop="scopeName" label="名称" /> </el-table> </div> <el-pagination :current-page="currentPage" :page-sizes="[10, 20, 30, 50]" :page-size="10" layout="total, sizes, prev, pager, next, jumper" :total="30" @size-change="handleSizeChange" @current-change="handleCurrentChange" /> </div> </div> <div slot="footer" class="dialog-footer"> <el-button type="text" @click="formVisible = false">取消</el-button> <el-button type="primary" @click="formVisible = false">确定</el-button> </div> </div> </el-dialog> </template>
<script> import { preLibraryCrud } from '../mixins/index' import CRUD, { presenter, header, crud } from '@crud/crud' import Vue from 'vue' export default { name: 'MoveFile', components: { }, cruds() { return [ CRUD({ title: '移动', url: 'api/category/menu', crudMethod: {}, sort: [] }) ] }, mixins: [presenter(), header(), crud(), preLibraryCrud], data() { return { selectedCategoryMove: {}, options: [ { value: 1, label: '已整理' }, { value: 2, label: '未整理' } ], query: { status: '', keyWord: '' }, moveVisible: false, tableData: [], defaultProps: { children: 'children', label: 'cnName' }, currentPage: 1 } }, created() { }, methods: { getRowKey(row) { return row.id }, [CRUD.HOOK.afterRefresh]() { this.crud.data = this.filterData(this.crud.data) this.$nextTick(() => { if (this.$refs.treeMove) { let currentKey if (this.crud.data[0].isType === 1) { currentKey = this.findNode(this.crud.data[0].children, (node) => { return node.isType !== 1 }) } else { currentKey = this.crud.data[0] } // 设置某个节点的当前选中状态
this.$refs.treeMove.setCurrentKey(currentKey.id) this.$nextTick(() => { // 设置某个节点的父级展开
const selectedKey = this.$refs.treeMove.getCurrentNode() if (this.$refs.treeMove.getNode(selectedKey) && this.$refs.treeMove.getNode(selectedKey).parent) { this.expandParents(this.$refs.treeMove.getNode(selectedKey).parent) } // 选中节点的门类详情
this.handleMoveNodeClick(selectedKey) }) } }) }, // 选中门类后,设置门类详情数据
handleMoveNodeClick(val) { if (val) { this.selectedCategoryMove = val if (val.pid !== '0') { Vue.set(this.selectedCategoryMove, 'parentName', this.$refs.treeMove.getNode(val.pid).data.cnName) } } }, handleClose(done) { this.moveVisible = false done() }, handleSizeChange(val) { console.log(`每页 ${val} 条`) }, handleCurrentChange(val) { console.log(`当前页: ${val}`) } } } </script>
<style lang="scss" scoped> @import "~@/assets/styles/prearchive-library.scss";
.el-pagination{ padding-right: 5px; margin: 25px 0 !important; } </style>
|