| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- <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">
- <img :src="getImage(scope.row.IMAGE)" width="100%" height="100%" :alt="scope.row.TITLE">
- </template>
- </el-table-column>
- <el-table-column type="selection" width="55"></el-table-column>
- <el-table-column label="广告标题" 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="广告位" 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="类型">
- <template slot-scope="scope">
- <template v-if="scope.row.TYPE === '1'">
- <el-tag type="success">外链</el-tag>
- </template>
- <template v-else-if="scope.row.TYPE === '2'">
- <el-tag>文章</el-tag>
- </template>
- </template>
- </el-table-column>
- <el-table-column label="连接或文章ID" prop="CONTENT" width="120"></el-table-column>
- <el-table-column label="排序" 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="创建人">
- <template slot-scope="scope">
- {{scope.row.CREATE_ADMIN_NAME}}
- </template>
- </el-table-column>
- <el-table-column label="创建时间" width="180">
- <template slot-scope="scope">
- {{tool.formatDate(scope.row.CREATED_AT)}}
- </template>
- </el-table-column>
- <el-table-column label="修改人">
- <template slot-scope="scope">
- {{scope.row.UPDATE_ADMIN_NAME}}
- </template>
- </el-table-column>
- <el-table-column label="修改时间" width="180">
- <template slot-scope="scope">
- {{tool.formatDate(scope.row.UPDATED_AT)}}
- </template>
- </el-table-column>
- <el-table-column fixed="right" label="操作" 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="">
- 操作该数据<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`)">编辑</el-dropdown-item>
- <el-dropdown-item command="delete" @click.native="handleDelete(scope.row)" v-if="permission.hasPermission(`ad/ad-delete`)">删除</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">
- 所选数据<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()">删除</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`)">添加广告</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'
- 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,
- }
- },
- 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)
- },
- handleMuliDel () {
- this.delData()
- },
- 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
- })
- },
- delData (id = null) {
- let obj = this
- obj.$confirm('确定删除选定的数据?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- 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 => {
- })
- },
- getImage(imageUrl) {
- return tool.getLocaleLink(imageUrl, '/files/');
- },
- }
- }
- </script>
- <style scoped>
- </style>
|