| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- <template>
- <div v-loading="loading">
- <div class="white-box">
- <el-table ref="multipleTable" :data="tableData" stripe style="width: 100%;"
- @selection-change="handleSelectionChange" @row-click="handleExpand">
- <el-table-column type="expand">
- <template slot-scope="scope">
- <a v-if="scope.row.TYPE === '1'" :href="getHref(scope.row.CONTENT)" target="_blank" class="islide">
- <img :src="getImage(scope.row.IMAGE)" width="100px" height="100px" :alt="scope.row.TITLE">
- </a>
- <router-link v-else :to="`/article/detail/${scope.row.CONTENT}`" target="_blank" class="islide">
- <img :src="getImage(scope.row.IMAGE)" width="100px" height="100px" :alt="scope.row.TITLE">
- </router-link>
- </template>
- </el-table-column>
- <el-table-column type="selection" width="55"></el-table-column>
- <el-table-column label="Ad Title" prop="TITLE" width="250"> <!-- 广告标题 -->
- <template slot-scope="scope">
- <el-tag type="" size="small" class="no-border">{{scope.row.TITLE}}</el-tag>
- </template>
- </el-table-column>
- <el-table-column label="Ad Location" width="150"> <!-- 广告位 -->
- <template slot-scope="scope">
- <el-tag type="warning" size="small" class="no-border">{{allData.allLocation[scope.row.LID].LOCATION_NAME}}</el-tag>
- </template>
- </el-table-column>
- <el-table-column label="Type"> <!-- 类型 -->
- <template slot-scope="scope">
- <template v-if="scope.row.TYPE === '1'">
- <el-tag type="success">External Links</el-tag> <!-- 外链 -->
- </template>
- <template v-else-if="scope.row.TYPE === '2'">
- <el-tag>Article</el-tag> <!-- 文章 -->
- </template>
- </template>
- </el-table-column>
- <el-table-column label="Content" prop="CONTENT" width="120">
- <template slot-scope="scope">
- <div v-if="scope.row.TYPE === '1'">
- <el-link type="primary" target="_blank" :href="getHref(scope.row.CONTENT)">{{ scope.row.CONTENT }}</el-link>
- </div><!-- 链接 -->
- <div v-else-if="scope.row.TYPE === '2'">
- <router-link :to="`/article/detail/${scope.row.CONTENT}`" target="_blank" style="cursor: pointer;">{{ getContent(scope.row.CONTENT) }}</router-link>
- </div><!-- 文章 -->
- </template>
- </el-table-column>
- <el-table-column label="Sort" width="100"> <!-- 排序 -->
- <template slot-scope="scope">
- <el-input v-model="scope.row.SORT" min="0" max="99" @change="handleChangeSort(scope.row, scope.row.SORT)"
- @click.native.stop=""></el-input>
- </template>
- </el-table-column>
- <el-table-column label="Creator"> <!-- 创建人 -->
- <template slot-scope="scope">
- {{scope.row.CREATE_ADMIN_NAME}}
- </template>
- </el-table-column>
- <el-table-column label="Created Time" width="180"> <!-- 创建时间 -->
- <template slot-scope="scope">
- {{tool.formatDate(scope.row.CREATED_AT)}}
- </template>
- </el-table-column>
- <el-table-column label="Modified By"> <!-- 修改人 -->
- <template slot-scope="scope">
- {{scope.row.UPDATE_ADMIN_NAME}}
- </template>
- </el-table-column>
- <el-table-column label="Modified Time" width="180"> <!-- 修改时间 -->
- <template slot-scope="scope">
- {{tool.formatDate(scope.row.UPDATED_AT)}}
- </template>
- </el-table-column>
- <el-table-column label="Status"> <!-- 状态 -->
- <template slot-scope="scope">
- <div v-if="scope.row.STATUS === '1'">Show</div>
- <div v-else>Hide</div>
- </template>
- </el-table-column>
- <el-table-column fixed="right" label="Action" width="180"> <!-- 操作 -->
- <template slot-scope="scope">
- <el-dropdown size="small" trigger="click" v-if="permission.hasPermission(`ad/ad-delete`) || permission.hasPermission(`ad/edit`)">
- <el-button type="primary" size="small" @click.stop="">
- Action<i class="el-icon-arrow-down el-icon--right"></i>
- </el-button>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item command="edit" @click.native="handleEdit(scope.row)" v-if="permission.hasPermission(`ad/edit`)">Edit</el-dropdown-item>
- <el-dropdown-item command="delete" @click.native="handleDelete(scope.row)" v-if="permission.hasPermission(`ad/ad-delete`)">Delete</el-dropdown-item>
- <el-dropdown-item command="hide" @click.native="handleHide(scope.row)" v-if="permission.hasPermission(`ad/ad-hide`)">Hide</el-dropdown-item>
- <el-dropdown-item command="un-hide" @click.native="handleUnHide(scope.row)" v-if="permission.hasPermission(`ad/ad-un-hide`)">UnHide</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </template>
- </el-table-column>
- </el-table>
- <div class="white-box-footer">
- <el-dropdown size="small" trigger="click" v-if="permission.hasPermission(`ad/ad-delete`)">
- <el-button type="primary" size="small">
- Selected data<!--所选数据--><i class="el-icon-arrow-down el-icon--right"></i>
- </el-button>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item command="delete" @click.native="handleMuliDel()">Delete</el-dropdown-item>
- <el-dropdown-item command="hide" @click.native="handleMultiHide()">Hide</el-dropdown-item>
- <el-dropdown-item command="un-hide" @click.native="handleMultiUnHide()">UnHide</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- <el-button type="primary" size="small" @click="handleAdd" icon="el-icon-plus" v-if="permission.hasPermission(`ad/add`)">Add Ad</el-button>
- <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange"></pagination>
- </div>
- </div>
- </div>
- </template>
- <script>
- import Vue from 'vue'
- import network from '@/utils/network'
- import tool from '@/utils/tool'
- import store from '@/utils/vuexStore'
- import permission from '@/utils/permission'
- import Pagination from '@/components/Pagination'
- import {SERVER_API_HTTP_TYPE,SERVER_API_DOMAIN} from '@/utils/config'
- import article from "../article";
- export default {
- name: 'ad_list',
- components: {Pagination},
- mounted () {
- this.getData()
- },
- data () {
- return {
- allData: null,
- tableData: null,
- loading: true,
- multipleSelection: [],
- currentPage: 1,
- totalPages: 1,
- totalCount: 1,
- pageSize: 20,
- tool: tool,
- permission: permission,
- allArticle: [],
- }
- },
- methods: {
- handleExpand (row, event, column) {
- this.$refs.multipleTable.toggleRowExpansion(row)
- },
- handleSelectionChange (val) {
- this.multipleSelection = val
- },
- handleCurrentChange (page) {
- this.getData(page, this.pageSize)
- },
- handleSizeChange (pageSize) {
- this.getData(this.currentPage, pageSize)
- },
- handleAdd () {
- this.$router.push({path: `/ad/add`})
- },
- handleEdit (row) {
- this.$router.push({path: `/ad/edit/${row.ID}`})
- },
- handleDelete (row) {
- this.delData(row.ID)
- },
- handleHide (row) {
- this.hideData(row.ID)
- },
- handleUnHide(row) {
- this.unHideData(row.ID)
- },
- handleMuliDel () {
- this.delData()
- },
- handleMultiHide () {
- this.hideData()
- },
- handleMultiUnHide () {
- this.unHideData()
- },
- handleChangeSort (row, sort) {
- network.getData('/ad/sort', {id: row.ID, sort: sort}).then(response => {
- this.getData(this.currentPage, this.pageSize)
- }).catch(response => {
- })
- },
- getData (page, pageSize) {
- let obj = this
- network.getPageData(this, `ad/list/${this.$route.params.lid}`, page, pageSize, null, function (response) {
- obj.allData = response
- obj.allArticle = response.allArticle
- })
- },
- delData (id = null) {
- let obj = this
- obj.$confirm('Are you sure to delete the selected data?', 'Notice', { // 确定删除选定的数据?
- confirmButtonText: 'confirm', // 确定
- cancelButtonText: 'cancel', // 取消
- type: 'warning'
- }).then(() => {
- let selectedIds = []
- if (id === null) {
- for (let val of obj.multipleSelection) {
- selectedIds.push(val.ID)
- }
- } else {
- selectedIds.push(id)
- }
- return network.postData(`ad/ad-delete`, {
- selected: selectedIds
- })
- }).then(response => {
- this.$message({
- message: response,
- type: 'success'
- })
- obj.getData(obj.currentPage, obj.pageSize)
- }).catch(response => {
- })
- },
- hideData (id = null) {
- let obj = this
- obj.$confirm('Are you sure to hide the selected data?', 'Notice', { // 确定删除选定的数据?
- confirmButtonText: 'confirm', // 确定
- cancelButtonText: 'cancel', // 取消
- type: 'warning'
- }).then(() => {
- let selectedIds = []
- if (id === null) {
- for (let val of obj.multipleSelection) {
- selectedIds.push(val.ID)
- }
- } else {
- selectedIds.push(id)
- }
- return network.postData(`ad/ad-hide`, {
- selected: selectedIds
- })
- }).then(response => {
- this.$message({
- message: response,
- type: 'success'
- })
- obj.getData(obj.currentPage, obj.pageSize)
- }).catch(response => {
- })
- },
- unHideData (id = null) {
- let obj = this
- obj.$confirm('Are you sure to un-hide the selected data?', 'Notice', { // 确定删除选定的数据?
- confirmButtonText: 'confirm', // 确定
- cancelButtonText: 'cancel', // 取消
- type: 'warning'
- }).then(() => {
- let selectedIds = []
- if (id === null) {
- for (let val of obj.multipleSelection) {
- selectedIds.push(val.ID)
- }
- } else {
- selectedIds.push(id)
- }
- return network.postData(`ad/ad-un-hide`, {
- selected: selectedIds
- })
- }).then(response => {
- this.$message({
- message: response,
- type: 'success'
- })
- obj.getData(obj.currentPage, obj.pageSize)
- }).catch(response => {
- })
- },
- getImage(imageUrl) {
- return imageUrl.indexOf('http') > -1 ? imageUrl : SERVER_API_HTTP_TYPE + SERVER_API_DOMAIN + '/uploads/' + imageUrl;
- },
- getContent(aid) {
- let titles = this.allArticle.filter(article => article.ID === aid).map(article => article.TITLE);
- return titles.length > 0 ? titles[0] : aid;
- },
- getHref(link) {
- return link.indexOf('http') > -1 ? link : 'http://' + link;
- },
- }
- }
- </script>
- <style scoped>
- </style>
|