123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780 |
- <template>
- <div :class="$style.wrapHeight">
- <div :class="$style.rowHeight">
- <audit-tree
- :checkable="false"
- :draggable="false"
- :is-search="false"
- :show-line="true"
- :top-node-text="'审计知识'"
- :treeparams="{
- configId: 81,
- }"
- :default-expanded-keys="['0']"
- :is-select-dep="true"
- :dep-options="categorys"
- manager-type="view"
- @treeSelect="treeSelectd"
- >
- </audit-tree>
- <div :class="$style.rightcard">
- <a-card>
- <div :class="$style.wrapper">
- <audit-advanced-query
- :expand="expand"
- :search-data="formData"
- :ref-name="'searchform'"
- :search-style="{ height: '170px', left: '20px', top: '64px', width: '100%' }"
- :search-fun="handleSearch"
- @searchedClick="searchedClick"
- >
- <template>
- <a-col :span="12">
- <a-form-model-item :label="'标\u2002\u2002\u2002\u2002题'" prop="title">
- <a-input v-model="formData.title" allow-clear />
- </a-form-model-item>
- </a-col>
- <a-col :span="12">
- <a-form-model-item :label="'标\u2002\u2002\u2002\u2002签'" prop="label">
- <a-input v-model="formData.label" allow-clear />
- </a-form-model-item>
- </a-col>
- <a-col :span="12">
- <a-form-model-item :label="'编制人员'" prop="cUser">
- <a-input v-model="formData.cUser" allow-clear />
- </a-form-model-item>
- </a-col>
- </template>
- </audit-advanced-query>
- <div :class="[$style.btns]">
- <audit-advanced-export
- v-if="true"
- ref="exportBtn"
- :class-style="[$style.buttonSpacing]"
- :exclebxh="false"
- :expressions="expressions"
- :config-id="51"
- :v-show="false"
- />
- </div>
- <sd-data-table-ex
- ref="oaTable"
- :editnode="editnode"
- :form-id="formId"
- :columns="columns"
- :actions="actions"
- :show-advance-query="true"
- :filter-expressions="expressions"
- :show-selection="true"
- :search-fields="['title']"
- :data-url="dataUrl"
- :row-selection="{ type: 'radio' }"
- @searchbtnClick="searchbtnClick"
- @recordsDeleted="onRecordsDeleted"
- >
- <a
- slot="fldSubject"
- slot-scope="text, record"
- :title="text"
- @click="fnReadDoc(record)"
- >{{ text }}</a
- >
- <a v-show="editnode" slot="opt" slot-scope="text, record" @click="fnEditDoc(record)"
- >编辑</a
- >
- </sd-data-table-ex>
- </div>
- </a-card>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { message, Modal } from 'ant-design-vue'
- import KmKnowledageService from '../km-knowledage-service'
- import auditAdvancedQueryMixins from '../../../../components/audit-advanced-query-mixins'
- import auditAdvancedQuery from '../../../../components/audit-advanced-query.vue'
- import auditAdvancedExport from '../../../../components/audit-advanced-export.vue'
- import auditTree from '../../../../components/audit-tree.vue'
- import components from './_import-components/km-knowledage-base-import'
- import PageService from '@/common/services/page-service'
- import { getUserInfo, getUserPerms } from '@/common/store-mixin'
- import TableActionTypes from '@/common/services/table-action-types'
- import TableColumnTypes from '@/common/services/table-column-types'
- import crossWindowWatcher from '@/common/services/cross-window-watcher'
- import openAsTrustId from '@/common/services/open-as-trust-id'
- export default {
- name: 'KmKnowledageBase',
- metaInfo: {
- title: '知识库',
- },
- components: {
- auditTree,
- auditAdvancedQuery,
- auditAdvancedExport,
- ...components,
- },
- mixins: [auditAdvancedQueryMixins],
- props: {
- // 是不是用于选择知识
- isSelectd: {
- type: Boolean,
- default: false,
- },
- },
- data() {
- return {
- editnode: true,
- dataUrl: 'api/xcoa-mobile/v1/kmknowledge/all-list',
- formData: {
- title: '',
- label: '',
- cUser: '',
- },
- expand: false,
- // 左侧树用,用于创建对应分类数据
- parentId: 0,
- categorys: [],
- activeKey: 'textlist',
- // isKmAdmin: false,
- expressions: [],
- columns: [
- {
- title: '序号',
- dataIndex: 'sortNumber',
- width: '80px',
- customRender: (text, record, index) => `${index + 1}`,
- },
- {
- title: '标题',
- dataIndex: 'title',
- scopedSlots: { customRender: 'fldSubject' },
- width: '25%',
- },
- {
- title: '标签',
- dataIndex: 'label',
- },
- {
- title: '阅读次数',
- dataIndex: 'readTimes',
- },
- {
- title: '编制人员',
- dataIndex: 'creatorName',
- },
- {
- title: '发布状态',
- dataIndex: 'releaseType',
- sdHidden: true,
- },
- {
- title: '编制日期',
- dataIndex: 'creationTime',
- sdRender: TableColumnTypes.date,
- sorter: true,
- defaultSortOrder: 'desc',
- },
- ],
- actions: [
- {
- label: '删除',
- permission: null, // 纯前端操作,不需要权限控制
- type: TableActionTypes.oa.delete,
- // callback: this.deleteRows,
- },
- {
- label: '新建',
- permission: null, // 纯前端操作,不需要权限控制
- callback: () => {
- this.fnCreatDoc()
- },
- type: TableActionTypes.primary,
- },
- ],
- businessTypeId: null,
- typeId: null,
- typeName: '',
- formId: 'kmKnowledge',
- // 图文列表参数
- showCreateBtn: false,
- showDeleteBtn: false,
- pictureData: [],
- pagination: {
- onChange: (page) => {
- this.paginationChange(page)
- },
- current: 1,
- pageSize: 8,
- showTotal(total) {
- return `共${total}条`
- },
- },
- loading: false, // 图文列表数据的loading
- pictureExpressions: [],
- orderType: 'creationTime',
- creationTimeDesc: true,
- pictureRowSelection: [],
- searchText: '',
- picList: '',
- }
- },
- // 图文列表参数变化更新数据
- watch: {
- pictureExpressions() {
- this.pictureListRefresh(true)
- },
- orderType() {
- this.pictureListRefresh()
- },
- creationTimeDesc() {
- this.pictureListRefresh()
- },
- },
- created() {
- // if (getUserInfo().roles.findIndex((item) => item.code === 'KM_ADMIN') !== -1) {
- // this.isKmAdmin = true
- // }
- // 图文列表获取数据
- this.treeSelectd({}, { id: 0 })
- if (getUserPerms()['kmKnowledge-update']) {
- this.columns = [
- {
- title: '序号',
- dataIndex: 'sortNumber',
- width: '80px',
- customRender: (text, record, index) => `${index + 1}`,
- },
- {
- title: '标题',
- dataIndex: 'title',
- scopedSlots: { customRender: 'fldSubject' },
- width: '25%',
- },
- {
- title: '标签',
- dataIndex: 'label',
- },
- {
- title: '阅读次数',
- dataIndex: 'readTimes',
- },
- {
- title: '编制人员',
- dataIndex: 'creatorName',
- },
- {
- title: '发布状态',
- dataIndex: 'releaseType',
- sdHidden: true,
- },
- {
- title: '编制日期',
- dataIndex: 'creationTime',
- sdRender: TableColumnTypes.date,
- sorter: true,
- defaultSortOrder: 'desc',
- },
- {
- title: '操作',
- dataIndex: 'id',
- scopedSlots: { customRender: 'opt' },
- },
- ]
- }
- },
- methods: {
- searchedClick() {
- this.expand = false
- },
- // 查询
- handleSearch() {
- this.expressions = [
- {
- dataType: 'str',
- name: 'categoryId',
- op: 'eq',
- stringValue: this.typeId,
- },
- ]
- // if (!this.isKmAdmin) {
- // this.expressions.push({
- // dataType: 'long',
- // name: 'releaseType',
- // op: 'eq',
- // longValue: 1,
- // })
- // }
- // 资料名称
- if (this.formData.title) {
- this.expressions.push({
- dataType: 'str',
- name: 'title',
- op: 'like',
- stringValue: `%${this.formData.title}%`,
- })
- }
- // 资料名称
- if (this.formData.label) {
- this.expressions.push({
- dataType: 'str',
- name: 'label',
- op: 'like',
- stringValue: `%${this.formData.label}%`,
- })
- }
- // 资料名称
- if (this.formData.cUser) {
- this.expressions.push({
- dataType: 'str',
- name: 'creatorName',
- op: 'like',
- stringValue: `%${this.formData.cUser}%`,
- })
- }
- },
- // 获取知识分类树
- loadTreeData(parentCatId) {
- const params = {
- pageId: 'kmKnowledge',
- categoryId: parentCatId || 0,
- }
- return KmKnowledageService.getKnowledgeTree(params).then((res) => {
- return res.data
- })
- },
- // 树选择节点后获取列表数据
- treeSelectd(key, item) {
- debugger
- if (item.selectedNodes?.length > 0) {
- let parentId = ''
- let parentName = ''
- if (item.id !== undefined) {
- parentId = item.id
- parentName = item.text
- } else {
- parentId = item.selectedNodes[0].data.props.id
- parentName = item.selectedNodes[0].data.props.text
- this.editnode = item.selectedNodes[0].data.props.edit
- var actionsId = null
- if (this.editnode) {
- this.actions.forEach((item) => {
- if (item.id === 'auditMattersCatalog') {
- actionsId = item.id
- }
- })
- if (actionsId == null) {
- this.actions.push({
- label: '分类配置',
- id: 'auditMattersCatalog',
- permission: null,
- callback: () => {
- const url = '/sd-frame/km-knowledge-category' // 新页面要打开的路由地址
- openAsTrustId(url, null)
- },
- })
- }
- }
- if (!this.editnode) {
- // 判断是不是分类管理员
- const params = {
- parentId: parentId,
- }
- KmKnowledageService.getKnowledgeCategoryAdmin(params).then((res) => {
- const datas = res.data
- if (datas) {
- this.editnode = true
- var actionsId = null
- if (this.editnode) {
- this.actions.forEach((item) => {
- if (item.id === 'auditMattersCatalog') {
- actionsId = item.id
- }
- })
- if (actionsId == null) {
- this.actions.push({
- label: '分类配置',
- id: 'auditMattersCatalog',
- permission: null,
- callback: () => {
- const url = '/sd-frame/km-knowledge-category' // 新页面要打开的路由地址
- openAsTrustId(url, null)
- },
- })
- }
- }
- }
- })
- }
- }
- this.typeId = parentId
- this.typeName = parentName
- this.selectdParentName = parentName
- const filter = [
- {
- dataType: 'str',
- name: 'categoryId',
- op: 'eq',
- stringValue: this.typeId,
- },
- ]
- // if (!this.isKmAdmin) {
- // filter.push({
- // dataType: 'long',
- // name: 'releaseType',
- // op: 'eq',
- // longValue: 1,
- // })
- // }
- this.expressions = filter
- this.pictureExpressions = filter
- } else {
- this.editnode = false
- const filter = [
- {
- dataType: 'str',
- name: 'categoryId',
- op: 'eq',
- stringValue: -1,
- },
- ]
- this.expressions = filter
- this.pictureExpressions = filter
- }
- },
- // 获取businessTypeId,选中的节点要是没有businessTypeId就向上找,直至找到根节点,如果没有就返回null
- fnGetBusinessTypeId(item) {
- let businessTypeId
- if (item === null) {
- // 如果找到根节点都没找到flowId就返回null
- businessTypeId = null
- } else {
- if (item.selectedNodes && item.selectedNodes[0].data.props.props.businessTypeId) {
- businessTypeId = item.selectedNodes[0].data.props.props.businessTypeId
- } else if (item.props && item.props.businessTypeId) {
- businessTypeId = item.props.businessTypeId
- } else {
- const key = item.id ? item.id : item.selectedNodes[0].data.key
- const parentNode = this.getParentNode(key, this.$refs.tree.treeData)
- businessTypeId = this.fnGetBusinessTypeId(parentNode)
- }
- }
- return businessTypeId
- },
- // 查找父节点
- getParentNode(key, tree) {
- let parentNode = null
- for (let i = 0; i < tree.length; i++) {
- const node = tree[i]
- if (node.children) {
- if (node.children.some((item) => item.id === key)) {
- parentNode = node
- } else if (this.getParentNode(key, node.children)) {
- parentNode = this.getParentNode(key, node.children)
- }
- }
- }
- return parentNode
- },
- // 知识投稿
- fnCreatDoc() {
- // 根据businessTypeId获取知识管理业务类型文档,没有businessTypeId的话弹出提示语
- if (this.businessTypeId) {
- window.open(
- '#/km-flow-guide?businessId=' +
- this.businessTypeId +
- '&typeId=' +
- this.typeId +
- '&typeName=' +
- this.typeName
- )
- }
- var url =
- '/km-knowledage-form?' +
- '&typeId=' +
- this.typeId +
- '&typeName=' +
- this.typeName +
- `&editNode=${this.editnode}`
- crossWindowWatcher.waitForChanged(url).then((refreshFlag) => {
- debugger
- if (refreshFlag) {
- return this.$refs.oaTable.refresh(true)
- }
- })
- },
- fnEditDoc(record) {
- debugger
- setTimeout(() => {
- this.$refs.oaTable.refresh()
- this.loadData()
- }, 5000)
- var url = `/km-knowledage-form?&typeId=${this.typeId}&typeName=${this.typeName}&record=${record.id}&editNode=${this.editnode}&releaseType=${record.releaseType}`
- crossWindowWatcher.waitForChanged(url).then((refreshFlag) => {
- if (refreshFlag) {
- return this.$refs.oaTable.refresh(true)
- }
- })
- },
- // 查看知识
- fnReadDoc(record) {
- debugger
- setTimeout(() => {
- this.$refs.oaTable.refresh()
- this.loadData()
- }, 5000)
- if (record.releaseType === 0) {
- this.fnEditDoc(record)
- } else {
- window.open(`#/km-knowledage-view?id=${record.id}&title=${record.title}`, '_blank')
- }
- },
- // 下面是图文列表相关
- // 图片列表页面翻页
- paginationChange(page) {
- this.pagination.current = page
- this.loadData()
- },
- pictureListRefresh(toFirstPage) {
- if (toFirstPage) this.pagination.current = 1
- if (!this.isSelectd) {
- return this.loadData()
- }
- },
- loadData() {
- debugger
- const pagination = this.pagination
- this.loading = true
- const param = {
- columns: 'title,creatorName,categoryName,readTimes,creationTime,cover',
- maxResults: pagination.pageSize,
- startPosition: pagination.pageSize * (pagination.current - 1),
- formId: this.formId,
- }
- let orderBy = ''
- if (this.orderType === 'creationTime') {
- if (this.creationTimeDesc) {
- orderBy = 'creationTime desc'
- } else {
- orderBy = 'creationTime asc'
- }
- } else {
- orderBy = 'readTimes desc'
- }
- param.orderBy = orderBy
- if (this.searchText) {
- const searchExpressions = [
- {
- dataType: 'exps',
- op: 'or',
- expressionsValue: [
- {
- dataType: 'str',
- name: 'title',
- op: 'like',
- stringValue: `%${this.searchText}%`,
- },
- ],
- },
- ]
- param.expressions = [...searchExpressions, ...this.pictureExpressions]
- } else {
- param.expressions = this.pictureExpressions
- }
- KmKnowledageService.getAllList(param).then((res) => {
- this.pagination.total = res.data.totalSize
- this.pictureData = res.data.data
- this.loading = false
- const newInfo = { ...this.pagination }
- newInfo.total = res.data.totalSize
- this.pagination = newInfo
- })
- },
- // 处理排序
- fnSetOrderType(type) {
- if (type === 'creationTime') {
- if (this.orderType === 'creationTime') {
- this.creationTimeDesc = !this.creationTimeDesc
- }
- }
- this.orderType = type
- },
- // 图文列表选中
- fnPictureSelect(e) {
- if (e.target.checked) {
- if (this.pictureRowSelection.indexOf(e.target.value) === -1) {
- this.pictureRowSelection.push(e.target.value)
- }
- } else {
- this.pictureRowSelection.splice(
- this.pictureRowSelection.findIndex((it) => it.value === e.target.value),
- 1
- )
- }
- },
- // 列表删除数据时图文也刷新一下
- onRecordsDeleted() {
- this.pictureListRefresh()
- this.$refs.tree.refresh() // 刷新树
- },
- // 图文列表删除数据
- deleteRows() {
- const selectedRowKeys = this.$refs.oaTable.getSelectedRowKeys()
- if (selectedRowKeys.length === 0) {
- Modal.info({
- content: '请选择需要删除的文件',
- })
- return
- }
- Modal.confirm({
- title: '你确定删除这项内容吗?',
- content: '删除这条数据后,就无法恢复初始的状态。',
- okText: '删除',
- okType: 'danger',
- onOk: () => {
- this.loading = true
- const params = {
- ids: selectedRowKeys.join(','),
- }
- PageService.delete(params, this.formId).then((res) => {
- if (res.status === 200) {
- this.$refs.oaTable.clearSelection()
- this.$refs.oaTable.refresh()
- this.loading = false
- }
- })
- },
- })
- },
- onSearchChange(text) {
- if (this.searchText === text) return
- this.searchText = text.trim()
- const pagination = this.pagination
- pagination.current = 1
- this.localPagination = { ...pagination }
- this.loadData()
- },
- },
- }
- </script>
- <style module lang="scss">
- @use '@/common/design' as *;
- .wrap-height {
- height: 100%;
- .row-height {
- display: flex;
- flex: auto;
- height: 100%;
- .rightcard {
- flex: 1;
- width: calc(100% - 20%);
- height: 100%;
- }
- }
- }
- .sider-content {
- padding: 0 0;
- .sider-title {
- position: relative;
- margin-left: 23px;
- i {
- position: absolute;
- top: 3px;
- left: -27px;
- font-size: 18px;
- color: #1890ff;
- }
- font-weight: bold;
- }
- .sider-li {
- :global(.ant-timeline-item-content) {
- margin: 0 0 0 23px;
- }
- :global(.ant-timeline-item-head-blue) {
- color: #9f9f9f;
- border-color: #9f9f9f;
- }
- :global(.ant-timeline-item-tail) {
- height: calc(100% - -18px);
- border-left: 2px solid #f5f5f5;
- }
- }
- .sider-title-div-first {
- padding: 0 0 10px 20px;
- margin-bottom: 10px;
- border-bottom: 3px solid #e8e8e8;
- }
- .sider-title-div {
- padding: 10px 0 10px 20px;
- margin-bottom: 20px;
- border-top: 3px solid #e8e8e8;
- border-bottom: 3px solid #e8e8e8;
- }
- ul {
- margin-bottom: 30px;
- margin-left: 0;
- }
- .sider-ul-div {
- width: 90%;
- padding: 13px 0 0 5px;
- margin: 10px auto;
- cursor: pointer;
- border-radius: 5px;
- :global(.ant-timeline-item) {
- padding: 0;
- margin-left: 3px;
- }
- }
- :global(.checked) {
- color: #fff;
- background: linear-gradient(to right, #13c2c2, #2db7f5);
- :global(.ant-timeline-item-head-blue) {
- background-color: #13c2c2;
- border-color: #fff !important;
- }
- }
- :global(.ant-timeline-item-last .ant-timeline-item-tail) {
- display: none;
- }
- }
- </style>
|