[update 友情链接] 完善

This commit is contained in:
danshihao
2024-07-31 18:03:27 +08:00
parent 8474599390
commit 1afa8d0c92
3 changed files with 18 additions and 76 deletions
+5 -1
View File
@@ -56,6 +56,9 @@ const getNewestEnterEnStandard = (params) => getAction('/laws/localTool/standard
// 将实施标准
const getWillImplementStandards = (params) => getAction('/laws/localTool/standardEarlyWarning/latestImplement', params)
// 友情链接列表
const getFriendlyLinkList = (params) => getAction('/sys/lawsFriendlyLinks/list', params)
export {
getSearchHistoryData,
deleteSearchHistoryById,
@@ -81,5 +84,6 @@ export {
getHomeNewStandard,
getNewestEnterStandard,
getNewestEnterEnStandard,
getWillImplementStandards
getWillImplementStandards,
getFriendlyLinkList
}
@@ -19,7 +19,8 @@
</template>
<script>
import { getAction, getFileAccessHttpUrl } from '@/api/manage'
import { getFileAccessHttpUrl } from '@/api/manage'
import { getFriendlyLinkList } from '@api/dashboard'
export default {
name: 'FriendLinkCard',
@@ -27,10 +28,7 @@ export default {
return {
defaultLogo: require('@/assets/image/dashboard/friendship-link.png'),
loading: false,
dataSource: [],
url: {
list: '/sys/lawsFriendlyLinks/list'
}
dataSource: []
}
},
mounted () {
@@ -45,7 +43,7 @@ export default {
},
loadData () {
this.loading = true
getAction(this.url.list, {}).then((res) => {
getFriendlyLinkList({ count: 6 }).then((res) => {
if (res.success) {
this.dataSource = res.result || []
} else {
@@ -14,15 +14,6 @@
</a-form-item>
</a-col>
<a-col :md="6" :sm="8">
<a-form-item :label="$t('system.friendshipLink.shelfStatus')">
<j-dict-select-tag
:placeholder="$t('pleaseSelect') + $t('system.friendshipLink.shelfStatus')"
v-model="queryParam.grounding"
dict-code="yn"></j-dict-select-tag>
</a-form-item>
</a-col>
<div style="float: right;overflow: hidden;" class="table-page-search-submitButtons">
<a-button type="primary" @click="searchQuery" icon="search" v-has="'sys:friendshipLink:search'">
{{ $t('query') }}
@@ -50,18 +41,11 @@
rowKey="id"
:columns="columns"
:dataSource="dataSource"
:pagination="false"
:pagination="ipagination"
:loading="loading"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
@change="handleTableChange">
<template v-slot:link="{text, record}">
<a-tooltip overlay-class-name="tooltip-style">
<template slot="title">{{ text || text === 0 ? text : global.emptyLine }}</template>
<a class="link-a" @click="handleLinkClick(record)">{{ text }}</a>
</a-tooltip>
</template>
<template v-slot:logoUrl="{text}">
<div class="table-image" v-viewer="{movable: false}">
<img :src="getImgView(text)">
@@ -70,6 +54,8 @@
<template v-slot:action="{text, record}">
<a @click="handleEdit(record)" v-has="'sys:friendshipLink:edit'">{{ $t('edit') }}</a>
<a-divider type="vertical" v-if="isHasPermission('sys:friendshipLink:edit') && isHasPermission('sys:friendshipLink:delete')" />
<a class="operate-del-btn" @click="handleDelete(record.id)" v-has="'sys:friendshipLink:delete'">{{ $t('delete') }}</a>
</template>
</j-table>
@@ -82,17 +68,15 @@
<script>
import JTable from '@/components/jero/JTable'
import JDictSelectTag from '@/components/dict/JDictSelectTag'
import { JeroListMixin } from '@/mixins/JeroListMixin'
import { postAction, getAction } from '@/api/manage'
import FriendshipLinkModal from './modules/FriendshipLinkModal'
import { isHasPermission } from '@/utils/hasPermission'
export default {
name: 'FriendshipLinkList',
components: {
FriendshipLinkModal,
JTable,
JDictSelectTag
JTable
},
mixins: [JeroListMixin],
data () {
@@ -144,58 +128,14 @@ export default {
}
],
url: {
list: '/sys/lawsFriendlyLinks/list',
edit: '/sys/lawsFriendlyLinks/edit'
list: '/sys/lawsFriendlyLinks/page',
edit: '/sys/lawsFriendlyLinks/edit',
delete: '/sys/lawsFriendlyLinks/delete'
}
}
},
methods: {
loadData () {
const params = Object.assign({}, this.queryParam)
this.loading = true
getAction(this.url.list, params).then((res) => {
if (res.success) {
this.dataSource = res.result ? res.result.map(item => {
return {
...item,
grounding: item.grounding !== '0'
}
}) : []
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
})
},
handleLinkClick (record) {
const href = record.link
window.open(href)
},
// 是否上架状态改变
switchChange (record) {
console.log(record)
if (!record.link) {
this.$message.warning(this.$t('system.friendshipLink.shelfWarn'))
return
}
// 1开启 0未开启
if (this.dataSource.reduce((pre, cur) => pre += (cur.grounding ? 1 : 0), 0) > 6) {
this.$message.warning('最多上架六个友情链接')
record.grounding = false
return
}
console.log(record)
const param = Object.assign({}, record)
param.grounding = record.grounding === true ? '1' : '0'
postAction(this.url.edit, param).then(res => {
if (res.success) {
this.loadData()
} else {
this.$message.warning(res.message)
}
})
}
isHasPermission
}
}
</script>