Browse Source

api-档案门类/分类

master
xuhuajiao 2 years ago
parent
commit
5401846805
  1. 12
      src/api/system/archivesClass.js
  2. 43
      src/api/system/category.js
  3. 108
      src/api/system/category/category.js
  4. 21
      src/api/system/category/filter.js
  5. 4
      src/views/collectReorganizi/collectionLibrary/index.vue
  6. 256
      src/views/system/archivesCategory/archiveSealSetting/index.vue
  7. 154
      src/views/system/archivesCategory/archiveSealSetting/module/form.vue
  8. 19
      src/views/system/archivesCategory/baseInfo/index.vue
  9. 5
      src/views/system/archivesCategory/form.vue
  10. 18
      src/views/system/archivesCategory/index.vue
  11. 47
      src/views/system/archivesCategory/publicScreening/index.vue
  12. 4
      src/views/system/archivesCategory/sortDialog.vue
  13. 169
      src/views/system/archivesClassify/index.vue
  14. 2
      src/views/system/groupManage/index.vue

12
src/api/system/archivesClass.js

@ -0,0 +1,12 @@
import request from '@/utils/request'
// 获取档案分类列表
export function FetchInitArchivesClass(params) {
return request({
url: 'api/archivesClass/initArchivesClass',
method: 'get',
params
})
}
export default { FetchInitArchivesClass }

43
src/api/system/category.js

@ -1,43 +0,0 @@
import request from '@/utils/request'
// 获取门类树状菜单
export function FetchCategoryMenu() {
return request({
url: 'api/category/menu',
method: 'get'
})
}
// 获取门类下的子门类
export function FetchCategoryMenuChildren(cid) {
return request({
url: 'api/category/getChildren?categoryId=' + cid,
method: 'get'
})
}
export function add(data) {
return request({
url: 'api/category/editCategory',
method: 'post',
data
})
}
export function edit(data) {
return request({
url: 'api/category/editCategory',
method: 'post',
data
})
}
export function del(ids) {
return request({
url: 'api/category/delete',
method: 'delete',
data: ids
})
}
export default { add, edit, del, FetchCategoryMenu }

108
src/api/system/category/category.js

@ -0,0 +1,108 @@
import request from '@/utils/request'
// 获取门类树状菜单
export function FetchCategoryMenu() {
return request({
url: 'api/category/menu',
method: 'get'
})
}
// 获取门类下的子门类
export function FetchCategoryMenuChildren(cid) {
return request({
url: 'api/category/getChildren?categoryId=' + cid,
method: 'get'
})
}
// 新增门类
export function add(data) {
return request({
url: 'api/category/editCategory',
method: 'post',
data
})
}
// 编辑门类
export function edit(data) {
return request({
url: 'api/category/editCategory',
method: 'post',
data
})
}
// 删除门类
export function del(ids) {
const params = { id: ids[0] }
return request({
url: 'api/category/delete',
method: 'delete',
params
})
}
// 修改门类树状菜单
export function sort(data) {
return request({
url: 'api/category/sort',
method: 'put',
data
})
}
// 获取归档章版式
export function FetchGetFilingsealFormat() {
return request({
url: 'api/category/getFilingsealFormat',
method: 'get'
})
}
// 获取归档章详情
export function FetchGetFilingsealFormatDtails(filingId) {
return request({
url: 'api/category/getFilingsealFormatDtails?filingId=' + filingId,
method: 'get'
})
}
// 保存归档章
export function FetchEditCategoryFilingseal(data) {
return request({
url: 'api/category/editCategoryFilingseal',
method: 'post',
data
})
}
// 启用 / 关闭归档章
export function FetchEnabledFilingseal(data) {
return request({
url: 'api/category/enabledFilingseal',
method: 'post',
data
})
}
// 新增公共筛选
export function FetchAddCategoryScreen(data) {
return request({
url: 'api/category/addCategoryScreen',
method: 'post',
data
})
}
// 删除公共筛选
export function FetchDelCategoryScreen(data) {
return request({
url: 'api/category/delCategoryScreen',
method: 'post',
data
})
}
export default { add, edit, del, FetchCategoryMenu }

21
src/api/system/category/filter.js

@ -0,0 +1,21 @@
import request from '@/utils/request'
// 新增公共筛选
export function add(data) {
return request({
url: 'api/category/addCategoryScreen',
method: 'post',
data
})
}
// 删除公共筛选
export function del(data) {
return request({
url: 'api/category/delCategoryScreen',
method: 'post',
data
})
}
export default { add, del }

4
src/views/collectReorganizi/collectionLibrary/index.vue

@ -80,9 +80,9 @@
import crudCategory from '@/api/category/category'
import CRUD, { presenter, header } from '@crud/crud'
import Project from './project/index.vue'
import Anjuan from './anjuan/index.vue'
import Anjuan from './anjuan/index'
import Juannei from './juannei/index.vue'
import File from './file/index.vue'
import File from './file/index'
import treeJson from './tree.json'
export default {
name: 'CollectionLibrary',

256
src/views/system/archivesCategory/archiveSealSetting/index.vue

@ -1,5 +1,5 @@
<template>
<div class="setting-contanier">
<div v-loading="infoLoading" class="setting-contanier">
<div class="chapter-tip">
<p>注意</p>
<span>档号章一般盖在归档文件首页上端居中的空白位置如果位置被占用可将盖在首页上端其他空白处居左或居右</span>
@ -8,65 +8,270 @@
<div class="chapter-format">
<div class="chapter-item">
<p class="item-title">归档章版式</p>
<span class="item-selected">默认版式</span>
<span class="item-selected">{{ filingName }}</span>
</div>
<div class="chapter-item">
<div v-if="filingName && formatData.length !== 0" class="chapter-item">
<p class="item-title">预览</p>
<div class="format-style">
<span>全宗号</span>
<span>年度</span>
<span>件号</span>
<span>机构(问题)</span>
<span>保管期限</span>
<span>页数</span>
<span v-for="item in formatData" :key="item.id">{{ item.fieldCnName }}</span>
</div>
</div>
</div>
<div class="chapter-position">
<div class="chapter-item">
<p class="item-title">归档章位置</p>
<span class="item-selected">顶部居中</span>
<span class="item-selected">{{ filingPositionName }}</span>
</div>
<div class="position-style">
<!-- top-left / top-middle / top-right / middle-left / center / middle-right / bottom-left / bottom-middle / bottom-right -->
<span class="top-middle" />
<span v-if="filingPositionNumber===0" class="top-middle" />
<span v-if="filingPositionNumber===1" class="top-left " />
<span v-if="filingPositionNumber===2" class="top-right" />
<span v-if="filingPositionNumber===3" class="center" />
<span v-if="filingPositionNumber===4" class="middle-left" />
<span v-if="filingPositionNumber===5" class="middle-right" />
<span v-if="filingPositionNumber===6" class="bottom-middle" />
<span v-if="filingPositionNumber===7" class="bottom-left" />
<span v-if="filingPositionNumber===8" class="bottom-right" />
</div>
</div>
<div class="chapter-enable">
<div class="chapter-item">
<p class="item-title">是否启用</p>
<el-switch v-model="enable" class="isEnable-chapter" />
<el-switch v-model="isFiling" class="isEnable-chapter" @change="changeStatus" />
</div>
<div class="chapter-edit">
<el-button size="mini" @click="toEdit()">
<el-button size="mini" @click="cuDialogVisible = true">
<i class="iconfont icon-bianji" />
编辑
</el-button>
</div>
</div>
</div>
<eForm ref="cuform" @refresh="initData" />
<el-dialog :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="cuDialogVisible" :title="title">
<div class="setting-dialog">
<el-form ref="form" :model="form" size="small" :rules="rules" label-width="100px">
<el-row>
<el-col :span="12">
<el-form-item label="归档章版式" prop="filingId">
<el-select v-model="form.filingId" @change="changeFormat($event)">
<el-option v-for="option in formatOptions" :key="option.id" :label="option.name" :value="option.id" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="归档章位置" prop="filingPosition">
<el-select v-model="form.filingPosition">
<el-option v-for="option in positionOptions" :key="option.value" :label="option.label" :value="option.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div v-if="form.filingId && formatData.length !== 0" class="format-style">
<span v-for="item in formatData" :key="item.id">{{ item.fieldCnName }}</span>
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="cuDialogVisible = false">取消</el-button>
<el-button v-loading="loading" type="primary" @click="save">确定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import eForm from './module/form'
import { FetchGetFilingsealFormat, FetchGetFilingsealFormatDtails, FetchEditCategoryFilingseal, FetchEnabledFilingseal } from '@/api/system/category/category'
import { form } from '@crud/crud'
const defaultForm = {
id: null,
filingId: null,
filingPosition: null
}
export default {
name: 'ArchiveSealSetting',
components: { eForm },
components: { },
mixins: [form(defaultForm)],
props: {
selectedCategory: {
type: Object,
default: function() {
return {}
}
}
},
data() {
return {
enable: true
infoLoading: false,
isFiling: true,
filingName: '',
filingPositionNumber: '',
filingPositionName: '',
title: '编辑归档章',
cuDialogVisible: false,
loading: false,
formatOptions: [],
formatData: [],
positionOptions: [
{
label: '顶部居中',
value: 0
},
{
label: '顶部居左',
value: 1
},
{
label: '顶部居右',
value: 2
},
{
label: '中部居中',
value: 3
},
{
label: '中部居左',
value: 4
},
{
label: '中部居右',
value: 5
},
{
label: '底部居中',
value: 6
},
{
label: '底部居左',
value: 7
},
{
label: '底部居右',
value: 8
}
],
rules: {
filingId: [
{ required: true, message: '请选择归档章版式', trigger: 'change' }
],
filingPosition: [
{ required: true, message: '请选择归档章位置', trigger: 'change' }
]
}
}
},
watch: {
selectedCategory: function(newValue, oldValue) {
}
},
created() {
this.getFilingsealFormat()
this.getPosition()
},
methods: {
toEdit() {
this.$refs.cuform.cuDialogVisible = true
getFilingsealFormat() {
FetchGetFilingsealFormat().then((res) => {
this.formatOptions = res
if (this.selectedCategory.filingId) {
this.form.filingId = this.selectedCategory.filingId
res.map(item => {
if (item.id === this.selectedCategory.filingId) {
this.filingName = item.name
this.changeFormat(this.selectedCategory.filingId)
}
})
}
}).catch(err => {
console.log(err)
})
},
getPosition() {
this.isFiling = this.selectedCategory.isFiling
this.positionOptions.map(item => {
if (item.value === this.selectedCategory.filingPosition) {
this.filingPositionName = item.label
this.filingPositionNumber = item.value
this.form.filingPosition = item.value
}
})
},
changeFormat(value) {
this.formatData = []
if (value) {
FetchGetFilingsealFormatDtails(value).then((res) => {
this.formatData = res.sort((a, b) => {
if (a.row === b.row) {
return a.line - b.line // row line
} else {
return a.row - b.row // row
}
})
}).catch(err => {
console.log(err)
})
}
},
//
changeStatus(data) {
this.$confirm('此操作将禁用 / 启用当前归档章' + '<span>你是否还要继续?</span>', '提示', {
confirmButtonText: '继续',
cancelButtonText: '取消',
type: 'warning',
dangerouslyUseHTMLString: true
}).then(() => {
const params = {
'id': this.selectedCategory.id,
'isFiling': data
}
FetchEnabledFilingseal(params).then(res => {
this.$message({
message: '修改成功',
type: 'success',
duration: 2500
})
this.crud.refresh()
localStorage.setItem('categoryTabIndex', 6)
}).catch(() => {
data = !data
})
}).catch(() => {
this.$message({
message: '已取消修改',
type: 'info',
duration: 2500
})
data = !data
})
},
save() {
this.$refs['form'].validate((valid) => {
if (valid) {
this.infoLoading = true
this.loading = true
const params = {
'filingId': this.form.filingId,
'filingPosition': this.form.filingPosition,
'id': this.selectedCategory.id,
'isType': this.selectedCategory.isType,
'pid': this.selectedCategory.pid
}
FetchEditCategoryFilingseal(params).then((res) => {
this.$message({
message: '保存成功',
type: 'success',
duration: 2500
})
this.cuDialogVisible = false
this.loading = false
this.infoLoading = false
this.crud.refresh()
localStorage.setItem('categoryTabIndex', 6)
})
} else {
return false
}
})
}
}
}
@ -143,4 +348,15 @@ export default {
}
}
}
::v-deep .el-dialog .el-dialog__body{
padding-bottom: 0;
.format-style{
margin-left: 100px;
}
}
.dialog-footer{
margin-top: 20px;
}
</style>

154
src/views/system/archivesCategory/archiveSealSetting/module/form.vue

@ -1,154 +0,0 @@
<template>
<el-dialog :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="cuDialogVisible" :title="title">
<div class="setting-dialog">
<el-form ref="formData" :model="form" size="small" label-width="100px">
<el-row>
<el-col :span="12">
<el-form-item label="归档章版式">
<el-select v-model="form.format">
<el-option v-for="option in formatOptions" :key="option.value" :label="option.label" :value="option.value" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="归档章位置">
<el-select v-model="form.position">
<el-option v-for="option in positionOptions" :key="option.value" :label="option.label" :value="option.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div class="format-style">
<span v-for="item in formatData" :key="item.id">{{ item.value }}</span>
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="cuDialogVisible = false">取消</el-button>
<el-button type="primary" :loading="loading" @click="save">确定</el-button>
</div>
</el-dialog>
</template>
<script>
import { form } from '@crud/crud'
const defaultForm = {
id: null,
format: '默认版式',
position: '顶部居左'
}
export default {
mixins: [form(defaultForm)],
data() {
return {
title: '编辑归档章',
cuDialogVisible: false,
loading: false,
formatOptions: [{
label: '默认版式',
value: '0'
}],
formatData: [
{
id: 1,
value: '全宗号'
},
{
id: 2,
value: '年度'
},
{
id: 3,
value: '件号'
},
{
id: 4,
value: '机构(问题)'
},
{
id: 5,
value: '保管期限'
},
{
id: 6,
value: '页数'
}
],
positionOptions: [
{
label: '顶部居左',
value: 'topLeft'
},
{
label: '顶部居中',
value: 'topCenter'
},
{
label: '顶部居右',
value: 'topRight'
},
{
label: '中部居左',
value: 'centerLeft'
},
{
label: '中部居中',
value: 'center'
},
{
label: '中部居右',
value: 'centerRight'
},
{
label: '底部居左',
value: 'bottomLeft'
},
{
label: '底部居中',
value: 'bottomCenter'
},
{
label: '底部居右',
value: 'bottomRight'
}
]
}
},
methods: {
save() {
this.$refs['formData'].validate((valid) => {
if (valid) {
this.loading = true
// edit(this.formData.fields).then((res) => {
// this.$message({
// message: '',
// type: 'success',
// duration: 2500
// })
// this.cuDialogVisible = false
// this.loading = false
// this.$emit('refresh')
// })
this.cuDialogVisible = false
this.loading = false
this.$emit('refresh')
} else {
return false
}
})
}
}
}
</script>
<style lang="scss" scoped>
::v-deep .el-dialog .el-dialog__body{
padding-bottom: 0;
}
.dialog-footer{
margin-top: 20px;
}
.format-style{
margin-left: 100px;
}
</style>

19
src/views/system/archivesCategory/baseInfo/index.vue

@ -44,7 +44,6 @@
</template>
<script>
import { getNoFormatField } from '@/api/category/fileNoFormat'
export default {
name: 'BaseInfo',
props: {
@ -68,25 +67,15 @@ export default {
},
watch: {
selectedCategory: function(newValue, oldValue) {
if (newValue && newValue.id) {
this.initData()
}
// if (newValue && newValue.id) {
// }
}
},
created() {
if (this.selectedCategory && this.selectedCategory.id) {
this.initData()
}
// if (this.selectedCategory && this.selectedCategory.id) {
// }
},
methods: {
initData() {
getNoFormatField({ categoryId: this.selectedCategory.id }).then((res) => {
this.fileNoFormatStr = ''
res.forEach((item) => {
this.fileNoFormatStr += item.fieldCnName + item.connector
})
})
}
}
}
</script>

5
src/views/system/archivesCategory/form.vue

@ -53,12 +53,9 @@
</template>
<script>
// getCategoryType
import { getCategoryTree } from '@/api/system/category'
import { getCategoryTree } from '@/api/system/category/category'
import { form } from '@crud/crud'
import CRUD from '@crud/crud'
// import Treeselect from '@riophae/vue-treeselect'
// import '@riophae/vue-treeselect/dist/vue-treeselect.css'
const defaultForm = { id: null, parentName: null, cnName: null, code: null, isCase: true, isType: null, arrangeType: null, remark: null, categorySeq: null }
export default {

18
src/views/system/archivesCategory/index.vue

@ -21,7 +21,7 @@
<i class="iconfont icon-shanchu" />
删除
</el-button>
<el-button v-permission="permission.sort" icon="el-icon-sort" size="mini" :loading="sortLoading" :disabled="brotherNodeNum <= 1 || crud.selections[0].pid === '0' || crud.selections[0].isType === 3" @click="toSort(crud.selections)">排序</el-button>
<el-button v-permission="permission.sort" icon="el-icon-sort" size="mini" :loading="sortLoading" :disabled="brotherNodeNum <= 1 || crud.selections[0].pid === '0' " @click="toSort(crud.selections)">排序</el-button>
</template>
</crudOperation>
</div>
@ -100,7 +100,7 @@
</template>
<script>
import crudCategory from '@/api/system/category'
import crudCategory from '@/api/system/category/category'
import CRUD, { presenter, header } from '@crud/crud'
import eForm from './form'
import sortDialog from './sortDialog'
@ -153,8 +153,8 @@ export default {
deleteData: {},
activeIndex: 0,
sortLoading: false,
brotherNodeNum: 0
// sortTableData: []
brotherNodeNum: 0,
sortTableData: []
}
},
computed: {
@ -180,6 +180,9 @@ export default {
}
return 'baseInfo'
}
},
created() {
},
methods: {
//
@ -240,6 +243,12 @@ export default {
if (this.$refs.tree.getNode(val.pid) && this.$refs.tree.getNode(val.pid).childNodes) {
this.brotherNodeNum = this.$refs.tree.getNode(val.pid).childNodes.length
}
if (localStorage.getItem('categoryTabIndex')) {
this.$nextTick(() => {
this.activeIndex = Number(localStorage.getItem('categoryTabIndex'))
localStorage.removeItem('categoryTabIndex')
})
}
}
},
// - /
@ -265,6 +274,7 @@ export default {
treeNodeSort(data) {
this.$refs.tree.updateKeyChildren(data[0].pid, JSON.parse(JSON.stringify(data)))
},
//
toDelete(data) {
this.deleteData = data
this.deleteVisible = true

47
src/views/system/archivesCategory/publicScreening/index.vue

@ -53,6 +53,8 @@
</template>
<script>
// import crudFilter from '@/api/system/category/filter'
import { FetchInitArchivesClass } from '@/api/system/archivesClass'
import CRUD, { presenter, header, form } from '@crud/crud'
import pagination from '@crud/Pagination'
@ -62,34 +64,26 @@ export default {
name: 'PublicScreening',
components: { pagination },
cruds() {
return CRUD({ title: '用户', url: 'api/users' })
return CRUD({ title: '公共筛选', url: 'api/category/getCategoryScreen' })
},
mixins: [
presenter(),
header(),
form(function() {
return Object.assign({ dicPid: this.dicPid }, defaultForm)
return Object.assign({}, defaultForm)
})
],
props: {
selectedCategory: {
type: Object,
default: function() {
return {}
}
}
},
data() {
return {
selectOptions: [
{
id: 1,
value: '年度',
label: '年度'
},
{
id: 2,
value: '保管期限',
label: '保管期限'
},
{
id: 3,
value: '机构(问题)',
label: '机构(问题)'
}
],
selectOptions: [],
needRefreshTree: false,
rules: {
dicName: [
@ -107,7 +101,21 @@ export default {
}
}
},
created() {
this.getInitArchivesClass()
},
methods: {
getInitArchivesClass() {
const params = {
'categoryId': this.selectedCategory.id
}
FetchInitArchivesClass(params).then((res) => {
console.log(res)
this.selectOptions = res
}).catch(err => {
console.log(err)
})
},
[CRUD.HOOK.afterSubmit]() {
this.needRefreshTree = true
},
@ -124,7 +132,6 @@ export default {
}
},
toDelete(datas) {
// his.crud.confirmDeleteMsg ? this.crud.confirmDeleteMsg : `${datas.length}?`,
console.log(this.crud)
this.$confirm('此操作将删除当前所选字段' + '<span>你是否还要继续?</span>', '提示', {
confirmButtonText: '继续',

4
src/views/system/archivesCategory/sortDialog.vue

@ -17,7 +17,7 @@
<script>
import Sortable from 'sortablejs'
import { sort } from '@/api/category/category'
import { sort } from '@/api/system/category/category'
export default {
data() {
@ -52,7 +52,7 @@ export default {
},
handleSort() {
const data = this.sortTableData.map((value, index) => {
return { id: value.id, sort: index + 1 }
return { id: value.id, categorySeq: index + 1 }
})
this.sortTableData.forEach((item, index) => {
item.categorySeq = index + 1

169
src/views/system/archivesClassify/index.vue

@ -6,7 +6,21 @@
<div class="container-left">
<span class="right-top-line" />
<span class="left-bottom-line" />
<!-- <el-tree :data="deptDatas" :load="getDeptDatas" :props="defaultProps" :expand-on-click-node="false" lazy @node-click="handleNodeClick" /> -->
<div class="tree-scroll">
<el-tree ref="tree" v-loading="crud.loading" :data="crud.data" :props="defaultProps" node-key="id" :expand-on-click-node="false" highlight-current @node-click="handleNodeClick">
<span slot-scope="{ node, data }" class="custom-tree-node">
<span v-if="data.isType === 1 " class="iconFolder">
{{ data.cnName }}
</span>
<span v-if="data.isType === 2" class="iconArch">
{{ data.cnName }}
</span>
<span v-if="data.isType === 3" class="iconFile">
{{ data.cnName }}
</span>
</span>
</el-tree>
</div>
</div>
</div>
<!--用户数据-->
@ -117,13 +131,14 @@
</template>
<script>
import crudDict from '@/api/archivesConfig/dict'
import crudCategory from '@/api/system/category/category'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
import Vue from 'vue'
const defaultForm = {
id: null,
@ -139,9 +154,9 @@ export default {
name: 'Classify',
components: { crudOperation, pagination, Treeselect },
cruds() {
return CRUD({ title: '分类', url: 'api/dictrionary/menu',
crudMethod: { ...crudDict },
sort: ['dicSequence,asc'] })
return CRUD({ title: '分类', url: 'api/category/menu',
crudMethod: { ...crudCategory },
sort: [] })
},
mixins: [presenter(), header(), form(defaultForm), crud()],
data() {
@ -156,70 +171,112 @@ export default {
isTop: [{ required: true, message: '请选择是否为顶级分类', trigger: 'change' }],
pid: [{ required: true, message: '请选择上级分类', trigger: 'change' }]
},
defaultProps: { children: 'children', label: 'name', isLeaf: 'leaf' },
permission: {
add: ['admin', 'classify:add'],
edit: ['admin', 'classify:edit'],
del: ['admin', 'classify:del']
},
props: { children: 'childMenus', hasChildren: 'hasChildren' }
defaultProps: {
children: 'children',
label: 'cnName'
}
}
},
computed: {
key() {
return (node) => node.id
},
treeProps() {
return {
lazy: true,
load: this.loadData,
props: { children: 'childMenus', label: 'hasChildren' }
}
}
},
created() {
//
// setTimeout(() => {
// const treeData = [
// { id: 1, name: '1' },
// { id: 2, name: '2' },
// { id: 3, parentId: 1, name: '1' },
// { id: 4, parentId: 1, name: '2' },
// { id: 5, parentId: 2, name: '3' },
// { id: 6, parentId: 2, name: '4' },
// { id: 7, parentId: 3, name: '5' },
// { id: 8, parentId: 3, name: '6' },
// { id: 9, parentId: 5, name: '7' },
// { id: 10, parentId: 5, name: '8' },
// { id: 11, parentId: 6, name: '9' },
// { id: 12, parentId: 6, name: '10' },
// { id: 13, parentId: 9, name: '11' },
// { id: 14, parentId: 9, name: '12' },
// { id: 15, parentId: 10, name: '13' },
// { id: 16, parentId: 11, name: '14' },
// { id: 17, parentId: 12, name: '15' }
// ]
// console.log(treeData)
// const flatData = this.flattenData(treeData)
// console.log(this.flattenData)
// console.log(flatData)
// const tableData = []
// flatData.forEach((item) => {
// const parent = flatData.find((data) => data.id === item.parentId)
// if (parent) {
// if (!parent.children) {
// parent.children = []
// }
// parent.children.push(item)
// } else {
// tableData.push(item)
// }
// })
// this.tableData = tableData
// console.log(this.tableData)
// }, 200)
},
methods: {
//
findNode(tree, func) {
for (const node of tree) {
if (func(node)) return node
if (node.children) {
const res = this.findNode(node.children, func)
if (res) return res
}
}
return null
},
//
expandParents(node) {
node.expanded = true
if (node.parent) {
this.expandParents(node.parent)
}
},
[CRUD.HOOK.afterRefresh]() {
let currentKey
if (localStorage.getItem('currentCategoryKey')) {
currentKey = JSON.parse(localStorage.getItem('currentCategoryKey'))
} else {
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.tree.setCurrentKey(currentKey.id)
this.$nextTick(() => {
//
const selectedKey = this.$refs.tree.getCurrentNode()
if (this.$refs.tree.getNode(selectedKey) && this.$refs.tree.getNode(selectedKey).parent) {
this.expandParents(this.$refs.tree.getNode(selectedKey).parent)
}
//
this.handleNodeClick(selectedKey)
})
},
//
handleNodeClick(val) {
if (val) {
this.crud.selectionChangeHandler([val])
this.$refs.eform.pid = val.id
this.selectedCategory = val
if (val.pid !== '0') {
Vue.set(this.selectedCategory, 'parentName', this.$refs.tree.getNode(val.pid).data.cnName)
}
this.changeActiveTab(0)
//
localStorage.setItem('currentCategoryKey', JSON.stringify(val))
if (this.$refs.tree.getNode(val.pid) && this.$refs.tree.getNode(val.pid).childNodes) {
this.brotherNodeNum = this.$refs.tree.getNode(val.pid).childNodes.length
}
if (localStorage.getItem('categoryTabIndex')) {
this.$nextTick(() => {
this.activeIndex = Number(localStorage.getItem('categoryTabIndex'))
localStorage.removeItem('categoryTabIndex')
})
}
}
},
// - /
[CRUD.HOOK.beforeToAdd](crud, form, btn) {
const isCanAddKey = JSON.parse(localStorage.getItem('currentCategoryKey'))
if (isCanAddKey.isType === 4 || isCanAddKey.isType === 5) {
this.$message({
message: '此门类下不可新建门类',
type: 'error',
duration: 2500
})
return false
}
this.$refs.eform.beforeToAdd()
},
// / -
[CRUD.HOOK.afterSubmit](crud, addedCategory) {
if (addedCategory) {
//
localStorage.setItem('currentCategoryKey', JSON.stringify(addedCategory))
}
},
//
loadCategorys({ action, parentNode, callback }) {
if (action === LOAD_CHILDREN_OPTIONS) {
@ -276,4 +333,8 @@ export default {
[data-theme=light] .elect-cont-right .container-right{
min-height: calc(100vh - 232px);
}
.tree-scroll{
font-size: 14px;
}
</style>

2
src/views/system/groupManage/index.vue

@ -131,7 +131,7 @@
<script>
import crudfonds from '@/api/system/fonds'
import { FetchCategoryMenuChildren } from '@/api/system/category'
import { FetchCategoryMenuChildren } from '@/api/system/category/category'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'

Loading…
Cancel
Save