717 lines
29 KiB
Vue
717 lines
29 KiB
Vue
<template>
|
|
<a-card :bordered="false" class="page-left-right-layout">
|
|
<div class="page-left-box">
|
|
<a-input-search v-model="treeInput"
|
|
class="tree-search"
|
|
:placeholder="$t('pleaseEnterTreeSystem')"
|
|
@search="handleTreeSearch" />
|
|
<div class="page-tree-box page-tree-box-has-search">
|
|
<a-spin :spinning="treeLoading">
|
|
<a-tree
|
|
v-if="treeData.length > 0"
|
|
:show-line="true"
|
|
:show-icon="true"
|
|
:tree-data="treeData"
|
|
:expanded-keys.sync="expandedKeys"
|
|
:selectedKeys="currentTreeNode"
|
|
:default-expand-all="defaultExpandAll">
|
|
<template #title="record">
|
|
<div class="tree-operate-node"
|
|
@mouseenter="handleTreeMouseover(record.key)"
|
|
@mouseleave="handleTreeMouseout(record.key)"
|
|
@click="treeSelect(record)">
|
|
<a-icon class="parent-node-icon" type="folder" v-if="record.dataRef.children && record.dataRef.children.length > 0" />
|
|
<a-tooltip placement="topLeft">
|
|
<template #title>
|
|
{{ record.title }}
|
|
</template>
|
|
<span class="tree-node-custom-title">{{ record.title }}</span>
|
|
</a-tooltip>
|
|
<div class="tree-operate-node-btn-box" :class="{'tree-operate-node-btn-box-hide': record.key !== mouseInNodeKey || record.key === 'myCollect'}">
|
|
<!-- 新增 -->
|
|
<a-button icon="plus" class="tree-operate-node-btn" v-has="'enterpriseStandard:tree:add'"
|
|
@click="handleTreeAdd(record)"></a-button>
|
|
<!-- 编辑 -->
|
|
<a-button v-if="record.nodeType !== StandardSystemTreeNodeType.ROOT_NODE.value"
|
|
v-has="'enterpriseStandard:tree:edit'"
|
|
class="tree-operate-node-btn" @click="handleTreeEdit(record)">
|
|
<i class="iconfont icon-bianji"></i>
|
|
</a-button>
|
|
<!-- 删除 -->
|
|
<a-button v-if="record.nodeType !== StandardSystemTreeNodeType.ROOT_NODE.value"
|
|
v-has="'enterpriseStandard:tree:delete'"
|
|
class="tree-operate-node-btn" @click="handleTreeDelete(record.id)">
|
|
<i class="iconfont icon-shanchu_"></i>
|
|
</a-button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</a-tree>
|
|
</a-spin>
|
|
</div>
|
|
</div>
|
|
<div class="page-right-box">
|
|
<div class="table-page-search-wrapper">
|
|
<search ref="searchRef"
|
|
:flag="flag"
|
|
:get-query-condition-func="getQueryConditionFunc"
|
|
:default-search-params="defaultSearchParams"
|
|
search-has="enterpriseStandard:search"
|
|
@search="searchQuery"
|
|
@reset="searchReset" />
|
|
</div>
|
|
<div class="table-operator">
|
|
<!-- 新增 -->
|
|
<a-button icon="plus" type="primary" @click="handleAdd" v-has="'enterpriseStandard:add'">{{ $t('newlyAdded') }}</a-button>
|
|
<!-- 导入 -->
|
|
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
|
|
<a-button icon="download" type="primary" ghost v-has="'enterpriseStandard:upload'">{{ $t('import') }}</a-button>
|
|
</a-upload>
|
|
<!-- 导出 -->
|
|
<a-button icon="upload" type="primary" ghost @click="handleExportXls($t('enterpriseStandardLibrary.standard.exportExcelFile'))" v-has="'enterpriseStandard:export'">{{ $t('export') }}</a-button>
|
|
<!-- 带文件导出 -->
|
|
<a-button icon="upload" type="primary" ghost @click="handleFileExport($t('enterpriseStandardLibrary.standard.exportZipFile'))" v-has="'enterpriseStandard:fileExport'">{{ $t('exportWithFile') }}</a-button>
|
|
<!-- 模板下载 -->
|
|
<a-button icon="download" type="primary" ghost @click="downTemplate($t('enterpriseStandardLibrary.standard.templateExport'))" v-has="'enterpriseStandard:templateDownload'">{{ $t('templateDownload') }}</a-button>
|
|
<!-- 批量删除 -->
|
|
<a-button icon="delete" type="danger" ghost @click="batchDel" v-has="'enterpriseStandard:batchDel'">{{ $t('batchDelete') }}</a-button>
|
|
<!-- 配置标准 -->
|
|
<a-button icon="setting" type="primary" ghost @click="handleAllocationStandard" v-has="'enterpriseStandard:allocationStandard'">{{ $t('enterpriseStandardLibrary.standard.allocationStandard') }}</a-button>
|
|
<!-- 移出标准 -->
|
|
<a-button icon="minus-circle" type="primary" ghost @click="handleShiftOutStandard" v-has="'enterpriseStandard:shiftOutStandard'">{{ $t('enterpriseStandardLibrary.standard.shiftOutStandard') }}</a-button>
|
|
</div>
|
|
<div>
|
|
<j-table
|
|
v-if="columns && columns.length > 0"
|
|
ref="tableRef"
|
|
:columns="columns"
|
|
:dataSource="dataSource"
|
|
:can-drag="true"
|
|
rowKey="id"
|
|
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
|
|
:pagination="ipagination"
|
|
:scroll="{x: '100%'}"
|
|
:loading="loading"
|
|
@change="tableOnChange">
|
|
<!-- 在混入里已经过滤过没有权限的按钮了 -->
|
|
<template slot="operation" slot-scope="{text, record}">
|
|
<template v-if="operationList.length > operateMaxNum + 1">
|
|
<!-- 收藏-->
|
|
<a @click="operationClick(operationList[0],record)"
|
|
v-if="operationList[0].text === $t('enterpriseStandardLibrary.standard.collection')">
|
|
<i class="iconfont icon-star1" v-show="record.collectionFlag" />
|
|
<i class="iconfont icon-star" v-show="!record.collectionFlag" />
|
|
</a>
|
|
<a v-else @click="operationClick(operationList[0],record)">
|
|
<div class="operate-btn">
|
|
<!-- 查看图标-->
|
|
<i class="iconfont icon-link operate-btn-icon" v-if="operationList[0].text === $t('viewDetail')" />
|
|
<!-- 编辑图标-->
|
|
<i class="iconfont icon-bianji operate-btn-icon" v-if="operationList[0].text === $t('edit')" />
|
|
<!-- 删除图标-->
|
|
<i class="iconfont icon-shanchu_ operate-btn-icon" v-if="operationList[0].text === $t('delete')" />
|
|
{{ operationList[0].text }}
|
|
</div>
|
|
</a>
|
|
<a-divider type="vertical" />
|
|
<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)">
|
|
<div class="operate-btn" :class="operation.text === $t('delete') ? 'operate-del-btn' : ''">
|
|
<!-- 查看图标-->
|
|
<i class="iconfont icon-link operate-btn-icon" v-if="operation.text === $t('viewDetail')" />
|
|
<!-- 编辑图标-->
|
|
<i class="iconfont icon-bianji operate-btn-icon" v-if="operation.text === $t('edit')" />
|
|
<!-- 删除图标-->
|
|
<i class="iconfont icon-shanchu_ operate-btn-icon" v-if="operation.text === $t('delete')" />
|
|
{{ operation.text }}
|
|
</div>
|
|
</a>
|
|
</a-menu-item>
|
|
</a-menu>
|
|
</a-dropdown>
|
|
</template>
|
|
<template v-else-if="operationList.length > 0">
|
|
<template v-for="(operation, index) in operationList">
|
|
<!-- 收藏-->
|
|
<a :key="index" @click="operationClick(operationList[0],record)"
|
|
v-if="operation.text === $t('enterpriseStandardLibrary.standard.collection')">
|
|
<i class="iconfont icon-star1" v-show="record.collectionFlag" />
|
|
<i class="iconfont icon-star" v-show="!record.collectionFlag" />
|
|
</a>
|
|
<a v-else @click="operationClick(operation,record)" style="display: inline-block">
|
|
<div class="operate-btn">
|
|
<!-- 编辑图标-->
|
|
<i class="iconfont icon-bianji operate-btn-icon" v-if="operation.text === $t('edit')" />
|
|
<!-- 删除图标-->
|
|
<i class="iconfont icon-shanchu_ operate-btn-icon" v-if="operation.text === $t('delete')" />
|
|
{{ operation.text }}
|
|
</div>
|
|
</a>
|
|
<a-divider type="vertical" v-if="index !== operationList.length - 1" />
|
|
</template>
|
|
</template>
|
|
</template>
|
|
|
|
<!-- 企标编号 -->
|
|
<template v-slot:standard_number="{text, record}">
|
|
<a-tooltip overlay-class-name="tooltip-style">
|
|
<template slot="title">{{ text || text === 0 ? text : global.emptyLine }}</template>
|
|
<a class="link-a" @click="detailClick(record)" v-if="(text || text === 0)">{{ text }}</a>
|
|
<div class="table-text" v-else>{{ global.emptyLine }}</div>
|
|
</a-tooltip>
|
|
</template>
|
|
|
|
<!-- 企标名称 -->
|
|
<template v-slot:standard_name="{text, record}">
|
|
<a-tooltip overlay-class-name="tooltip-style">
|
|
<template slot="title">{{ text || text === 0 ? text : global.emptyLine }}</template>
|
|
<a class="link-a" @click="detailClick(record)" v-if="(text || text === 0)">{{ text }}</a>
|
|
<div class="table-text" v-else>{{ global.emptyLine }}</div>
|
|
</a-tooltip>
|
|
</template>
|
|
|
|
</j-table>
|
|
</div>
|
|
</div>
|
|
<!-- 新增、编辑弹框 -->
|
|
<enterprise-standard-modal ref="modalForm" @ok="modalFormOk"></enterprise-standard-modal>
|
|
<!-- 配置标准-标准选择弹框 -->
|
|
<allocation-standard-drawer ref="allocationStandardDrawer" @ok="modalOkDoNotRefreshTree"></allocation-standard-drawer>
|
|
<!-- 左侧树节点的新增和编辑 -->
|
|
<tree-node-modal ref="treeNodeModal" @ok="treeNodeModalOk"></tree-node-modal>
|
|
</a-card>
|
|
</template>
|
|
|
|
<script>
|
|
import { StandardSystemTreeNodeType, EnterpriseStandardStatus } from '@/enums/commonEnums'
|
|
import JTable from '@/components/jero/JTable'
|
|
// 搜索组件
|
|
import Search from '@/components/customField/Search'
|
|
import { ConfigurableTableMixin } from '@/mixins/ConfigurableTableMixin'
|
|
import {
|
|
getTreeList,
|
|
getEnterpriseStandardTableHeader,
|
|
getEnterpriseStandardSearchForm,
|
|
shiftStandard,
|
|
collectStandard,
|
|
cancelCollectStandard,
|
|
deleteTreeNode
|
|
} from '@api/enterpriseStandardLibraryApi'
|
|
// 添加、编辑弹框
|
|
import EnterpriseStandardModal from './modules/EnterpriseStandardModal'
|
|
import TreeNodeModal from './modules/TreeNodeModal'
|
|
// 配置标准弹框
|
|
import AllocationStandardDrawer from './modules/AllocationStandardDrawer'
|
|
import { postDownFile, downloadFile, postAction } from '@/api/manage'
|
|
import { mapGetters } from 'vuex'
|
|
import { isHasPermission } from '@/utils/hasPermission'
|
|
|
|
export default {
|
|
name: 'EnterpriseStandardList',
|
|
components: { AllocationStandardDrawer, TreeNodeModal, EnterpriseStandardModal, JTable, Search },
|
|
mixins: [ConfigurableTableMixin],
|
|
data () {
|
|
return {
|
|
StandardSystemTreeNodeType,
|
|
flag: '3',
|
|
treeInput: '', // 左侧树搜索框内容
|
|
treeData: [], // 左侧树数据
|
|
treeLoading: false,
|
|
collectionFlag: false,
|
|
defaultExpandAll: false, // 左侧树默认展开所有
|
|
currentTreeNode: null, // 当前选中的树节点key值
|
|
currentTreeNodeCode: null, // 当前选中的树节点的code值
|
|
mouseInNodeKey: null, // 鼠标悬浮的节点key值
|
|
operationList: [
|
|
{ // 收藏
|
|
text: this.$t('enterpriseStandardLibrary.standard.collection'),
|
|
clickEvent: 'handleCollection',
|
|
has: 'enterpriseStandard:collection'
|
|
},
|
|
{ // 编辑
|
|
text: this.$t('edit'),
|
|
clickEvent: 'handleEdit',
|
|
has: 'enterpriseStandard:edit'
|
|
},
|
|
{ // 删除
|
|
text: this.$t('delete'),
|
|
clickEvent: 'handleDelete',
|
|
has: 'enterpriseStandard:delete'
|
|
}
|
|
],
|
|
selectedRowKeys: [],
|
|
loading: false,
|
|
getTableHeaderFunc: getEnterpriseStandardTableHeader,
|
|
getQueryConditionFunc: getEnterpriseStandardSearchForm,
|
|
tableSlotField: ['standard_number', 'standard_name'], // 表格中需要插槽的字段
|
|
// url传参严格按照当前命名
|
|
url: {
|
|
list: '/laws/standard/enterprise/getCommonPage', // 表格数据
|
|
delete: '/laws/standard/enterprise/singleDelete', // 删除
|
|
deleteBatch: '/laws/standard/enterprise/deleteByIdsAndModule', // 批量删除
|
|
importUrl: '/laws/standard/enterprise/importExcelWithData', // 导入
|
|
exportXlsUrl: '/laws/standard/enterprise/exportData', // 导出
|
|
exportZipUrl: '/laws/standard/enterprise/exportDataWithFile', // 带文件导出
|
|
downTemplateUrl: '/laws/standard/enterprise/templateDownload' // 下载导入模板
|
|
},
|
|
showAction: true, // 是否显示操作列
|
|
expandedKeys: [], // 体系展开的节点
|
|
defaultSearchParams: { // 默认查询条件
|
|
standard_state: `${EnterpriseStandardStatus.CURRENTLY_EFFECTIVE.value}`
|
|
},
|
|
disabledMixinsCreate: true
|
|
}
|
|
},
|
|
computed: {
|
|
...mapGetters(['userInfo']),
|
|
// 当前用户是否管理员
|
|
isAdmin () {
|
|
const adminRoleList = window._CONFIG.adminRoleCode.split(',')
|
|
const userRoleList = this.userInfo.roleCode.split(',')
|
|
return userRoleList.some(tt => adminRoleList.includes(tt))
|
|
}
|
|
},
|
|
watch: {
|
|
// 消息当前页跳转,需要带入参数
|
|
$route: {
|
|
deep: true,
|
|
handler (to, from) {
|
|
// 如果有消息跳转参数就带入参数查询
|
|
if (to.query.standard_number) {
|
|
this.$set(this.$refs.searchRef.queryParam, 'standard_number', to.query.standard_number)
|
|
this.searchParams = Object.assign({}, this.$refs.searchRef.queryParam)
|
|
this.loadData()
|
|
}
|
|
}
|
|
}
|
|
},
|
|
mounted () {
|
|
// 从消息跳转进来带企业编号
|
|
this.$set(this.$refs.searchRef.queryParam, 'standard_number', this.$route.query.standard_number)
|
|
this.searchParams = Object.assign({}, this.$refs.searchRef.queryParam)
|
|
this.getTableHeader()
|
|
this.loadData()
|
|
// 过滤没有权限的按钮
|
|
if (this.needFilterTableBtn) {
|
|
this.operationList = this.operationList.filter(item => !item.has || isHasPermission(item.has))
|
|
console.log(this.operationList)
|
|
}
|
|
this.initTreeData()
|
|
},
|
|
methods: {
|
|
// 获取左侧树数据
|
|
initTreeData (params) {
|
|
this.treeLoading = true
|
|
getTreeList(params).then(res => {
|
|
this.treeData = []
|
|
this.currentTreeNode = []
|
|
this.currentTreeNodeCode = []
|
|
this.filters.nodeCode = null
|
|
if (res.success) {
|
|
this.treeData = res.result || []
|
|
// this.expandedKeys = [this.treeData[0].key]
|
|
if (this.expandedKeys.length <= 0) {
|
|
// 根节点默认展开
|
|
this.expandedKeys = [this.treeData[0].key]
|
|
} else {
|
|
const treeDataList = this.getTreeDataList(this.treeData)
|
|
const treeDataListKeys = treeDataList.map(item => item.key)
|
|
// 不是叶子结点的结点
|
|
const notLeafKeys = treeDataList.filter(item => !item.leaf).map(item => item.key)
|
|
// 还存在的树节点并且还有子节点的展开节点依然展开
|
|
this.expandedKeys = this.expandedKeys.filter(item => treeDataListKeys.includes(item) && notLeafKeys.includes(item))
|
|
}
|
|
} else {
|
|
this.treeData = []
|
|
}
|
|
}).finally(() => {
|
|
this.$nextTick(() => {
|
|
this.defaultExpandAll = true
|
|
})
|
|
this.treeLoading = false
|
|
})
|
|
},
|
|
getTreeDataList (treeData) {
|
|
let treeDataList = []
|
|
for (const item of treeData) {
|
|
treeDataList.push(item)
|
|
if (item.children && item.children.length > 0) {
|
|
const list = this.getTreeDataList(item.children)
|
|
treeDataList = treeDataList.concat(list)
|
|
}
|
|
}
|
|
return treeDataList
|
|
},
|
|
// 左侧树搜索
|
|
handleTreeSearch () {
|
|
this.treeData = []
|
|
this.initTreeData({ nodeName: this.treeInput })
|
|
},
|
|
// 左侧树点击选中
|
|
treeSelect ({ dataRef }) {
|
|
this.currentTreeNode = [dataRef.key]
|
|
this.currentTreeNodeCode = [dataRef.nodeCode]
|
|
this.filters.nodeCode = dataRef.nodeCode
|
|
this.loadData(1)
|
|
},
|
|
// 左侧树点击新增
|
|
handleTreeAdd (record) {
|
|
this.$refs.treeNodeModal.title = this.$t('newlyAdded')
|
|
this.$refs.treeNodeModal.add(record)
|
|
},
|
|
// 左侧树点击编辑
|
|
handleTreeEdit (record) {
|
|
console.log(record)
|
|
this.$refs.treeNodeModal.title = this.$t('edit')
|
|
this.$refs.treeNodeModal.edit(record)
|
|
},
|
|
// 左侧树点击删除
|
|
handleTreeDelete (id) {
|
|
const param = {}
|
|
param.id = id
|
|
this.$confirm({
|
|
title: this.$t('confirmDeletion'),
|
|
content: this.$t('confirmDeleteNodes'),
|
|
onOk: () => {
|
|
deleteTreeNode(param).then(res => {
|
|
if (res.success) {
|
|
this.$message.success(res.message)
|
|
this.initTreeData()
|
|
} else {
|
|
this.$message.warning(res.message)
|
|
}
|
|
})
|
|
}
|
|
})
|
|
},
|
|
// 左侧树节点新增或编辑完成
|
|
treeNodeModalOk () {
|
|
this.initTreeData()
|
|
},
|
|
// 左侧树鼠标移入某一目录
|
|
handleTreeMouseover (key) {
|
|
this.mouseInNodeKey = key
|
|
},
|
|
// 左侧树鼠标移出某一目录
|
|
handleTreeMouseout (key) {
|
|
if (this.mouseInNodeKey === key) {
|
|
this.mouseInNodeKey = null
|
|
}
|
|
},
|
|
// 管理员直接新增企标到企标库,非管理员新增跳转到企标制修订发起页面
|
|
handleAdd () {
|
|
// todo 暂时没有要跳转的页面
|
|
// if (!this.isAdmin) {
|
|
// this.$router.push({
|
|
// path: '/workCenter/enterpriseStandardRevision/enterpriseStandardRevisionFlow'
|
|
// })
|
|
// return
|
|
// }
|
|
this.$refs.modalForm.add()
|
|
this.$refs.modalForm.title = this.$t('newlyAdded')
|
|
this.$refs.modalForm.disableSubmit = false
|
|
},
|
|
/**
|
|
* 重置查询
|
|
*/
|
|
searchReset (params) {
|
|
this.currentTreeNode = null
|
|
this.searchParams = Object.assign({}, params)
|
|
this.selectedRowKeys = []
|
|
delete this.filters.nodeCode
|
|
this.getTableHeader()
|
|
this.loadData()
|
|
},
|
|
// 导出改成用post
|
|
handleExportXls (fileName) {
|
|
if (!fileName || typeof fileName !== 'string') {
|
|
fileName = this.$t('exportFile')
|
|
}
|
|
const param = this.getQueryParams()
|
|
if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
|
|
param.selections = this.selectedRowKeys.join(',')
|
|
}
|
|
console.log('导出参数', param)
|
|
// 加一个大的提示
|
|
const modalLoading = this.$info({
|
|
title: this.$t('tips'),
|
|
content: <span>{this.$t('exportTip')} <a-spin size="small" /></span>,
|
|
keyboard: false
|
|
})
|
|
// 把知道了这个按钮去掉
|
|
this.$nextTick(() => {
|
|
document.getElementsByClassName('ant-modal-confirm-btns')[0].style = 'display:none'
|
|
})
|
|
postDownFile(this.url.exportXlsUrl, param).then((data) => {
|
|
if (!data) {
|
|
this.$message.warning(this.$t('fileDownloadFail'))
|
|
return
|
|
}
|
|
if (typeof window.navigator.msSaveBlob !== 'undefined') {
|
|
window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xlsx')
|
|
} else {
|
|
const url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
|
|
const link = document.createElement('a')
|
|
link.style.display = 'none'
|
|
link.href = url
|
|
link.setAttribute('download', fileName + '.xlsx')
|
|
document.body.appendChild(link)
|
|
link.click()
|
|
document.body.removeChild(link) // 下载完成移除元素
|
|
window.URL.revokeObjectURL(url) // 释放掉blob对象
|
|
}
|
|
}).finally(() => {
|
|
// 销毁这个提示
|
|
modalLoading.destroy()
|
|
})
|
|
},
|
|
// 带文件导出
|
|
handleFileExport (fileName) {
|
|
if (!fileName || typeof fileName !== 'string') {
|
|
fileName = this.$t('exportFile')
|
|
}
|
|
const param = this.getQueryParams()
|
|
if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
|
|
param.selections = this.selectedRowKeys.join(',')
|
|
}
|
|
console.log('导出参数', param)
|
|
// 加一个大的提示
|
|
const modalLoading = this.$info({
|
|
title: this.$t('tips'),
|
|
content: <span>{this.$t('exportTip')} <a-spin size="small" /></span>,
|
|
keyboard: false
|
|
})
|
|
// 把知道了这个按钮去掉
|
|
this.$nextTick(() => {
|
|
document.getElementsByClassName('ant-modal-confirm-btns')[0].style = 'display:none'
|
|
})
|
|
postDownFile(this.url.exportZipUrl, param).then((data) => {
|
|
if (!data) {
|
|
this.$message.warning(this.$t('fileDownloadFail'))
|
|
}
|
|
if (typeof window.navigator.msSaveBlob !== 'undefined') {
|
|
window.navigator.msSaveBlob(new Blob([data]), fileName + '.zip')
|
|
} else {
|
|
const url = window.URL.createObjectURL(new Blob([data]))
|
|
const link = document.createElement('a')
|
|
link.style.display = 'none'
|
|
link.href = url
|
|
link.setAttribute('download', fileName + '.zip')
|
|
document.body.appendChild(link)
|
|
link.click()
|
|
document.body.removeChild(link) // 下载完成移除元素
|
|
window.URL.revokeObjectURL(url) // 释放掉blob对象
|
|
}
|
|
// }
|
|
}).finally(() => {
|
|
// 销毁这个提示
|
|
modalLoading.destroy()
|
|
})
|
|
},
|
|
// 下载导入模板
|
|
downTemplate (fileName) {
|
|
if (!fileName || typeof fileName !== 'string') {
|
|
fileName = this.$t('templateFile')
|
|
}
|
|
downloadFile(this.url.downTemplateUrl, fileName + '.zip')
|
|
},
|
|
/**
|
|
* 批量删除
|
|
*/
|
|
batchDel () {
|
|
if (this.selectedRowKeys.length <= 0) {
|
|
this.$message.warning(this.$t('selectARecord'))
|
|
return
|
|
}
|
|
const ids = this.selectedRowKeys.join(',')
|
|
this.$confirm({
|
|
title: this.$t('confirmBatchDeletion'),
|
|
content: this.$t('enterpriseStandardLibrary.standard.cannotJumpAfterDeletion'),
|
|
onOk: () => {
|
|
this.loading = true
|
|
postAction(this.url.deleteBatch, { ids: ids }).then((res) => {
|
|
if (res.success) {
|
|
// 重新计算分页问题
|
|
this.reCalculatePage(this.selectedRowKeys.length)
|
|
this.$message.success(res.message)
|
|
this.loadData()
|
|
this.onClearSelected()
|
|
} else {
|
|
this.$message.warning(res.message)
|
|
}
|
|
}).finally(() => {
|
|
this.loading = false
|
|
})
|
|
}
|
|
})
|
|
},
|
|
// 配置标准
|
|
handleAllocationStandard () {
|
|
console.log(this.currentTreeNode)
|
|
// 没选择左侧树节点,需要提示“请先选择二级及以下体系”
|
|
if (!this.currentTreeNode || this.currentTreeNode.length === 0 ||
|
|
this.currentTreeNode.includes('myCollect') || this.currentTreeNode.includes('adb15f66ce174f7295ab51fbc39c15b8')) {
|
|
this.$message.warn(this.$t('enterpriseStandardLibrary.standard.pleaseSelectLeastOneNode'))
|
|
return
|
|
}
|
|
this.$refs.allocationStandardDrawer.open(this.currentTreeNodeCode[0])
|
|
},
|
|
// 移出标准
|
|
handleShiftOutStandard () {
|
|
// 没选择左侧树节点,需要提示“请先选择左侧体系”
|
|
if (!this.currentTreeNode || this.currentTreeNode.length === 0 ||
|
|
this.currentTreeNode.includes('myCollect') || this.currentTreeNode.includes('adb15f66ce174f7295ab51fbc39c15b8')) {
|
|
this.$message.warn(this.$t('enterpriseStandardLibrary.standard.pleaseSelectLeastOneNode'))
|
|
return
|
|
}
|
|
// 左侧节点选的是我的收藏,不可移出标准
|
|
if (this.currentTreeNode[0] === 'myCollect') {
|
|
this.$message.warn(this.$t('enterpriseStandardLibrary.standard.myCollectNotRemove'))
|
|
return
|
|
}
|
|
// 没有选择列表数据,需要提示“选中至少一条列表数据”
|
|
if (!this.selectedRowKeys || this.selectedRowKeys.length === 0) {
|
|
this.$message.warning(this.$t('selectAtLeastOne'))
|
|
return
|
|
}
|
|
this.loading = true
|
|
const params = {
|
|
nodeCode: this.currentTreeNodeCode[0],
|
|
ids: this.selectedRowKeys.join(',')
|
|
}
|
|
shiftStandard(params).then(res => {
|
|
if (res.success) {
|
|
this.$message.success(res.message)
|
|
// 判断当前删除的数据是否是最后一页的最后一条数据,如果是的话页码减一
|
|
if (this.ipagination.current > 1 && ((this.ipagination.current - 1) * this.ipagination.pageSize) + 1 === this.ipagination.total) {
|
|
this.ipagination.current -= 1
|
|
}
|
|
this.modalOkDoNotRefreshTree()
|
|
} else {
|
|
this.$message.warn(res.message)
|
|
}
|
|
}).finally(() => {
|
|
this.loading = false
|
|
})
|
|
},
|
|
// 操作栏的点击
|
|
operationClick (operation, record) {
|
|
if (operation.clickEvent === 'handleDelete') {
|
|
this.handleDelete(record.id)
|
|
} else {
|
|
this[operation.clickEvent](record)
|
|
}
|
|
},
|
|
handleDelete (id) {
|
|
if (!this.url.delete) {
|
|
this.$message.warning('请设置url.delete属性!')
|
|
return
|
|
}
|
|
const that = this
|
|
this.$confirm({
|
|
title: this.$t('confirmDeletion'),
|
|
content: this.$t('enterpriseStandardLibrary.standard.cannotJumpAfterDeletion'),
|
|
onOk: () => {
|
|
postAction(that.url.delete, { ids: id }).then((res) => {
|
|
if (res.success) {
|
|
that.$message.success(res.message)
|
|
// 判断当前删除的数据是否是最后一页的最后一条数据,如果是的话页码减一
|
|
if (that.ipagination.current > 1 && ((that.ipagination.current - 1) * that.ipagination.pageSize) + 1 === that.ipagination.total) {
|
|
that.ipagination.current -= 1
|
|
}
|
|
that.loadData()
|
|
} else {
|
|
that.$message.warning(res.message)
|
|
}
|
|
})
|
|
}
|
|
})
|
|
},
|
|
// 收藏
|
|
handleCollection (record) {
|
|
if (this.collectionFlag || this.loading) {
|
|
return
|
|
}
|
|
this.collectionFlag = true
|
|
if (record.collectionFlag) {
|
|
const params = {}
|
|
params.id = record.id
|
|
// 说明已收藏,调取消收藏接口
|
|
cancelCollectStandard(params).then(res => {
|
|
if (res.success) {
|
|
this.$message.success(res.message)
|
|
this.loadData()
|
|
} else {
|
|
this.$message.warning(res.message)
|
|
}
|
|
}).finally(() => {
|
|
this.collectionFlag = false
|
|
})
|
|
} else {
|
|
const params = {}
|
|
params.standardId = record.id
|
|
params.standardNumber = record.standard_number
|
|
collectStandard(params).then(res => {
|
|
if (res.success) {
|
|
this.$message.success(res.message)
|
|
this.loadData()
|
|
} else {
|
|
this.$message.warning(res.message)
|
|
}
|
|
}).finally(() => {
|
|
this.collectionFlag = false
|
|
})
|
|
}
|
|
},
|
|
// 跳转详情
|
|
detailClick (record) {
|
|
this.$openPageNewSheet({
|
|
path: '/enterpriseStandardLibrary/enterpriseStandardDetail',
|
|
query: {
|
|
id: record.id
|
|
}
|
|
})
|
|
},
|
|
// 操作完需要刷树的回调
|
|
modalFormOk () {
|
|
this.selectedTreeKeys = []
|
|
this.filters.nodeCode = null
|
|
this.initTreeData()
|
|
// 新增/修改 成功时,重载列表
|
|
this.loadData()
|
|
// 清空列表选中
|
|
this.onClearSelected()
|
|
},
|
|
modalOkDoNotRefreshTree () {
|
|
// 新增/修改 成功时,重载列表
|
|
this.loadData()
|
|
// 清空列表选中
|
|
this.onClearSelected()
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
@import '~@assets/less/common.less';
|
|
/deep/ .ant-tree li span.ant-tree-switcher.ant-tree-switcher-noop {
|
|
color: #1D2129;
|
|
}
|
|
|
|
.parent-node-icon {
|
|
color: #1D2129;
|
|
font-size: 16px;
|
|
margin-right: 10px;
|
|
}
|
|
|
|
.icon-star1 {
|
|
color: rgba(243, 129, 65);
|
|
}
|
|
.icon-star {
|
|
color: rgba(243, 129, 65, 0.50);
|
|
}
|
|
</style>
|