update 国内标准

This commit is contained in:
赵霄
2023-09-06 18:04:29 +08:00
parent 04dc0ded0c
commit c89905ae7d
13 changed files with 317 additions and 94 deletions
@@ -1,46 +1,38 @@
<template>
<a-card :bordered="false" class="page-left-right-layout">
<!-- 树部分-->
<div class="page-left-box">
<!-- $t('standardRegulationLibrary.domesticStandard.treeSearchPlaceholder')-->
<a-input-search v-model="treeInput" :placeholder="$t('standardRegulationLibrary.domesticStandard.treeSearchPlaceholder')"
@search="handleTableSearch" />
@search="handleTreeSearch" />
<a-tree :show-line="true" :show-icon="true" :tree-data=treeData>
<template #iconCustom="{title}">
<div class="tree-node">
<img src="@/assets/image/common/iconTreeFolder.png" class="tree-node-icon" alt="" />
<a-tooltip>
<template #title>
{{ title }}
</template>
<span class="tree-node-title">{{ title }}</span>
</a-tooltip>
</div>
</template>
<a-icon type="folder" slot="folder" class="tree-icon" />
<template #custom="{title, key}">
<div class="tree-operate-node" @mouseenter="handleTreeMouseover(key)" @mouseleave="handleTreeMouseout(key)">
<template #custom="record">
<div class="tree-operate-node" @mouseenter="handleTreeMouseover(record.key)" @mouseleave="handleTreeMouseout(record.key)">
<a-tooltip>
<template #title>
{{ title }}
{{ record.nodeName }}
</template>
<span class="tree-node-custom-title">{{ title }}</span>
<span class="tree-node-custom-title">{{ record.nodeName }}</span>
</a-tooltip>
<template v-if="key === mouseInNodeKey">
<template v-if="record.key === mouseInNodeKey">
<!-- 新增-->
<a-button icon="plus" class="tree-operate-node-btn"></a-button>
<a-button icon="plus" class="tree-operate-node-btn" @click="handleAddTreeNode(record)"></a-button>
<!-- 编辑-->
<a-button class="tree-operate-node-btn">
<img src="@/assets/image/common/iconTreeEdit.png" alt="" />
<a-button class="tree-operate-node-btn" @click="handleEditTreeNode(record)">
<i class="iconfont icon-bianji" />
</a-button>
<!-- 删除-->
<a-button class="tree-operate-node-btn">
<img src="@/assets/image/common/iconTreeDelete.png" alt="" />
<!-- 删除根节点不能删除-->
<a-button class="tree-operate-node-btn" v-if="record.nodeType !== StandardSystemTreeNodeType.ROOT_NODE.value">
<i class="iconfont icon-shanchu_" />
</a-button>
</template>
</div>
</template>
</a-tree>
</div>
<!-- 表格部分-->
<div class="page-right-box">
<div class="table-page-search-wrapper">
<search ref="searchRef"
@@ -54,17 +46,30 @@
<!-- 新增-->
<a-button icon="plus" type="primary" @click="handleAdd">{{ $t('newlyAdded') }}</a-button>
<!-- 导入-->
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
<a-upload name="file"
:showUploadList="false"
:multiple="false"
:headers="tokenHeader"
:action="importExcelUrl"
@change="handleImportExcel">
<a-button type="primary" icon="download" ghost>{{ $t('import') }}</a-button>
</a-upload>
<!-- 导出-->
<a-button icon="upload" type="primary" ghost @click="handleExportXls($t('standardRegulationLibrary.domesticStandard.treeSearchPlaceholder'))">
<a-button icon="upload"
type="primary"
ghost
@click="handleExportXls($t('standardRegulationLibrary.domesticStandard.exportFileName'))">
{{ $t('export') }}
</a-button>
<!-- 带文件导出-->
<a-button icon="upload" type="primary" ghost>{{ $t('exportWithFile') }}</a-button>
<a-button icon="upload"
type="primary"
ghost
@click="handleFileExport($t('standardRegulationLibrary.domesticStandard.exportFileName'))">
{{ $t('exportWithFile') }}
</a-button>
<!-- 模板下载-->
<a-button type="primary" icon="download" ghost @click="downTemplate('standardRegulationLibrary.domesticStandard.templateName')">
<a-button type="primary" icon="download" ghost @click="downTemplate($t('standardRegulationLibrary.domesticStandard.templateName'))">
{{ $t('templateDownload') }}
</a-button>
<!-- 批量删除-->
@@ -87,22 +92,26 @@
@change="tableOnChange">
<template v-slot:operation="{text, record}">
<a>{{ $t('standardRegulationLibrary.domesticStandard.collection') }}</a>
<!-- 收藏-->
<a @click="operationClick(operationList[0],record)">
<i class="iconfont icon-star1" v-show="record.collectionFlag === yesValue" />
<i class="iconfont icon-star" v-show="!record.collectionFlag || record.collectionFlag === noValue" />
</a>
<a-divider type="vertical" />
<a-dropdown>
<a-icon type="more" class="operate-icon-btn" />
<a-dropdown placement="bottomCenter">
<a-icon type="more" class="operate-icon-btn operate-icon-more" />
<a-menu slot="overlay">
<a-menu-item v-for="(operation, index) in operationList.slice(operateMaxNum)" :key="index">
<a @click="operationClick(operation,record)">
<span v-if="operation.text === $t('docLibrary.cancelCollection')" class="text">
{{ !record.collectFlag || record.collectFlag === '0' ? $t('docLibrary.collection') : $t('docLibrary.cancelCollection') }}
</span>
<span v-else-if="operation.text === $t('docLibrary.cancelSubscribe')" class="text">
{{ !record.subscribeFlag || record.subscribeFlag === '0' ? $t('docLibrary.subscribe') : $t('docLibrary.cancelSubscribe') }}
</span>
<span v-else class="text">
{{ operation.text }}
</span>
<div class="operate-btn">
<!-- 编辑图标-->
<i class="iconfont icon-bianji operate-btn-icon" v-if="operation.text === $t('edit')" />
<!-- 分享图标-->
<i class="iconfont icon-fangxingfenxiang operate-btn-icon" v-if="operation.text === $t('share')" />
<!-- 删除图标-->
<i class="iconfont icon-shanchu_ operate-btn-icon" v-if="operation.text === $t('delete')" />
{{ operation.text }}
</div>
</a>
</a-menu-item>
</a-menu>
@@ -114,6 +123,10 @@
<!-- 新增编辑-->
<domestic-standard-modal ref="modalForm" @ok="modalFormOk" />
<!-- 分享选人-->
<user-select-modal ref="userSelectModal" type="checkbox" @change="continueShare" />
<!-- 树新增编辑-->
<domestic-system-tree-modal ref="treeModal" @ok="modalFormOk" />
</a-card>
</template>
@@ -123,26 +136,29 @@ import { ConfigurableTableMixin } from '../../../mixins/ConfigurableTableMixin'
import Search from '../../../components/customField/Search.vue'
import JTable from '../../../components/jero/JTable.vue'
import DomesticStandardModal from './modules/DomesticStandardModal.vue'
import { getDomesticStandardTableHeader, getDomesticStandardSearchForm } from '../../../api/standardRegulationLibraryApi'
import { getDomesticStandardTableHeader, getDomesticStandardSearchForm, shareDomesticStandard } from '../../../api/standardRegulationLibraryApi'
import { YesOrNoEnum, StandardSystemTreeNodeType } from '../../../enums/commonEnums'
import UserSelectModal from '../../../components/selection/UserSelectModal.vue'
import DomesticSystemTreeModal from './modules/DomesticSystemTreeModal.vue'
const apiTreeData = [
{
title: 'parent 1',
nodeName: 'parent 1',
key: '0-0',
nodeType: '1',
child: [
{
title: '张晨成',
nodeName: '张晨成',
key: '0-0-0',
disabled: true,
child: [
{ title: 'leaf', key: '0-0-0-0' },
{ title: 'leaf', key: '0-0-0-1' }
{ nodeName: 'leaf', key: '0-0-0-0' },
{ nodeName: 'leaf', key: '0-0-0-1' }
]
},
{
title: 'parent 1-1',
nodeName: 'parent 1-1',
key: '0-0-1',
child: [{ key: '0-0-1-0', title: 'zcvc' }]
child: [{ key: '0-0-1-0', nodeName: 'zcvc' }]
}
]
}
@@ -150,10 +166,11 @@ const apiTreeData = [
export default {
name: 'DomesticStandardList',
components: { Search, JTable, DomesticStandardModal },
components: { Search, JTable, DomesticStandardModal, UserSelectModal, DomesticSystemTreeModal },
mixins: [ConfigurableTableMixin],
data () {
return {
StandardSystemTreeNodeType,
treeInput: null, // 树查询绑定值
treeData: [],
mouseInNodeKey: null, // 鼠标悬浮的节点key值
@@ -162,7 +179,7 @@ export default {
// 收藏
{
text: this.$t('standardRegulationLibrary.domesticStandard.cancelCollection'),
clickEvent: 'collection',
clickEvent: 'handleCollection',
has: ''
},
{
@@ -185,21 +202,42 @@ export default {
getQueryConditionFunc: getDomesticStandardSearchForm,
url: {
list: '/laws/standard/domestic/getCommonPage',
delete: '/laws/standard/domestic/deleteByIdsAndModule'
}
delete: '/laws/standard/domestic/deleteByIdsAndModule',
downTemplateUrl: '', // 下载模板
exportXlsUrl: '', // 导出
exportZipUrl: '', // 带文件导出
importExcelUrl: '' // 导入
},
dataSource: [{ id: 1, collectionFlag: '1' }],
yesValue: YesOrNoEnum.YES.value,
noValue: YesOrNoEnum.NO.value,
nowShareId: null // 当前正在分享的数据的id
}
},
computed: {
importExcelUrl () {
return `${window._CONFIG.domianURL}/${this.url.importExcelUrl}`
}
},
created () {
this.initTreeData()
},
methods: {
/**
* 获取树数据
*/
initTreeData () {
this.treeData = this.dealTreeData(apiTreeData)
},
/**
* 处理树数据,加入自定义的节点插槽
* @param treeData
* @returns {*}
*/
dealTreeData (treeData) {
return treeData.map(item => {
if (item.child && item.child.length > 0) {
item.scopedSlots = { title: 'iconCustom' }
item.scopedSlots = { icon: 'folder', title: 'custom' }
item.children = this.dealTreeData(item.child)
} else {
item.scopedSlots = { title: 'custom' }
@@ -207,23 +245,90 @@ export default {
return item
})
},
handleTableSearch () {
/**
* 树节点查询
*/
handleTreeSearch () {
},
/**
* 树节点鼠标移入
* @param key
*/
handleTreeMouseover (key) {
this.mouseInNodeKey = key
},
/**
* 树节点鼠标移出
* @param key
*/
handleTreeMouseout (key) {
if (this.mouseInNodeKey === key) {
this.mouseInNodeKey = null
}
},
/**
* 表格操作点击
* @param operation
* @param record
*/
operationClick (operation, record) {
if (operation.clickEvent === 'handleDelete') {
this.handleDelete(record.id)
} else {
this[operation.clickEvent](record)
}
},
/**
* 收藏/取消收藏
* @param record
*/
handleCollection ({ collectionFlag }) {
if (collectionFlag === this.yesValue) {
this.dataSource[0].collectionFlag = this.noValue
} else {
this.dataSource[0].collectionFlag = this.yesValue
}
},
/**
* 分享
*/
handleShare ({ id }) {
this.nowShareId = id
this.$refs.userSelectModal.open()
},
/**
* 选择分享的人之后继续分享
* @param ids
*/
continueShare (ids) {
const params = {
id: this.nowShareId, // 要分享的标准的id
userIds: ids // 分享给的用户的id
}
this.loading = true
shareDomesticStandard(params).then(res => {
if (res.success) {
this.$message.success(res.message)
} else {
this.$message.warn(res.message)
}
}).finally(() => {
this.loading = false
})
},
modalFormOk () {
this.initTreeData()
// 新增/修改 成功时,重载列表
this.loadData()
// 清空列表选中
this.onClearSelected()
},
handleAddTreeNode ({ dataRef }) {
this.$refs.treeModal.add({ parentId: dataRef.key })
},
handleEditTreeNode ({ dataRef }) {
this.$refs.treeModal.edit(dataRef)
}
}
}
@@ -237,7 +342,7 @@ export default {
}
.tree-icon {
line-height: 24px;
color: #1D2129;
}
.tree-operate-node {
@@ -262,9 +367,9 @@ export default {
color: #D52C26;
}
img {
width: 13px;
height: 13px;
i {
color: @primary-color;
height: 20px;
}
}
}
@@ -0,0 +1,101 @@
<template>
<a-modal
:title="title"
:maskClosable="false"
:width="width"
:visible="visible"
:confirm-loading="confirmLoading"
@ok="handleOk"
@cancel="handleCancel">
<a-form :form="form">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('standardRegulationLibrary.nodeName')">
<a-input :placeholder="$t('pleaseEnter') + $t('standardRegulationLibrary.nodeName')"
@change="event => event.target.value = event.target.value.trim()"
:maxLength="50"
v-decorator="[ 'nodeName', validatorRules.nodeName]" />
</a-form-item>
</a-form>
</a-modal>
</template>
<script>
import { addDomesticSystemTree, editDomesticSystemTree } from '../../../../api/standardRegulationLibraryApi'
export default {
name: 'DomesticSystemTreeModal',
data () {
return {
title: this.$t('operation'),
width: 800,
visible: false,
confirmLoading: false,
form: this.$form.createForm(this),
model: {},
labelCol: {
xs: { span: 24 },
sm: { span: 4 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 20 }
},
validatorRules: {
// 上级节点
nodeName: {
rules: [{ required: true, message: this.$t('pleaseEnter') + this.$t('standardRegulationLibrary.nodeName') }],
validateTrigger: 'blur'
}
}
}
},
methods: {
add (parentInfo) {
this.edit(parentInfo)
},
edit (record) {
this.model = Object.assign({}, record)
this.visible = true
this.$nextTick(() => {
this.form.setFieldsValue(this.model)
})
},
close () {
this.visible = false
},
handleOk () {
this.form.validateFields((err, values) => {
if (!err) {
this.confirmLoading = true
const formData = Object.assign(this.model, values)
let submitFunc
if (this.model.id) {
submitFunc = editDomesticSystemTree
} else {
submitFunc = addDomesticSystemTree
}
submitFunc(formData).then(res => {
if (res.success) {
this.$message.success(res.message)
this.$emit('ok')
this.close()
} else {
this.$message.warn(res.message)
}
}).finally(() => {
this.confirmLoading = false
})
}
})
},
handleCancel () {
this.close()
}
}
}
</script>
<style scoped lang="less">
</style>
@@ -5,17 +5,7 @@
<a-input-search v-model="treeInput" :placeholder="$t('standardRegulationLibrary.domesticStandard.treeSearchPlaceholder')"
@search="handleTableSearch" />
<a-tree :show-line="true" :show-icon="true" :tree-data=treeData>
<template #iconCustom="{title}">
<div class="tree-node">
<img src="@/assets/image/common/iconTreeFolder.png" class="tree-node-icon" alt="" />
<a-tooltip>
<template #title>
{{ title }}
</template>
<span class="tree-node-title">{{ title }}</span>
</a-tooltip>
</div>
</template>
<a-icon type="folder" slot="folder" class="tree-icon" />
<template #custom="{title, key}">
<div class="tree-operate-node" @mouseenter="handleTreeMouseover(key)" @mouseleave="handleTreeMouseout(key)">
@@ -30,11 +20,11 @@
<a-button icon="plus" class="tree-operate-node-btn"></a-button>
<!-- 编辑-->
<a-button class="tree-operate-node-btn">
<img src="@/assets/image/common/iconTreeEdit.png" alt="" />
<i class="iconfont icon-bianji" />
</a-button>
<!-- 删除-->
<a-button class="tree-operate-node-btn">
<img src="@/assets/image/common/iconTreeDelete.png" alt="" />
<i class="iconfont icon-shanchu_" />
</a-button>
</template>
</div>