|
@@ -3,29 +3,35 @@
|
|
|
<!-- 搜索 -->
|
|
|
<el-form inline label-width="100px" size="mini">
|
|
|
<el-form-item label="设备:">
|
|
|
- <el-select placeholder="请选择设备">
|
|
|
- <el-option />
|
|
|
+ <el-select v-model="form.linkDevice" placeholder="请选择设备">
|
|
|
+ <el-option v-for="item in devOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="文章状态:">
|
|
|
- <el-select placeholder="请选择文章状态">
|
|
|
- <el-option />
|
|
|
+ <el-select v-model="form.status" placeholder="请选择文章状态">
|
|
|
+ <el-option v-for="item in statusOptions" :key="item.value" :label="item.label"
|
|
|
+ :value="item.value" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
- <el-button type="primary" icon="el-icon-search">搜索</el-button>
|
|
|
- <el-button icon="el-icon-refresh">重置</el-button>
|
|
|
- <el-button type="primary" icon="el-icon-plus" @click="getDetail">新增</el-button>
|
|
|
+ <el-button type="primary" icon="el-icon-search" @click="getSearch">搜索</el-button>
|
|
|
+ <el-button icon="el-icon-refresh" @click="getRefresh">重置</el-button>
|
|
|
+ <el-button type="primary" icon="el-icon-plus" plain @click="getDetail()">新增</el-button>
|
|
|
+ <el-button type="primary" icon="el-icon-delete" @click="getDelete(deleteList)"
|
|
|
+ :disabled="deleteList.length > 0 ? false : true">批量删除</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<!-- 列表 -->
|
|
|
- <el-table :data="tableData">
|
|
|
- <el-table-column label="文章标题" align="center" />
|
|
|
- <el-table-column label="设备" align="center" />
|
|
|
- <el-table-column label="文章状态" align="center" />
|
|
|
+ <el-table :data="tableData" v-loading="loading" @selection-change="handleSelectionChange">
|
|
|
+ <el-table-column type="selection" align="center" />
|
|
|
+ <el-table-column label="文章标题" prop="title" align="center" />
|
|
|
+ <el-table-column label="设备" prop="linkDevice" align="center" :formatter="devFormatter"
|
|
|
+ show-overflow-tooltip />
|
|
|
+ <el-table-column label="文章状态" prop="status" align="center" :formatter="statusFormatter" />
|
|
|
<el-table-column label="操作" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-button type="text" @click="getDetail(scope.row)">编辑</el-button>
|
|
|
+ <el-button type="text" @click="getDetail(scope.row.id)">编辑</el-button>
|
|
|
+ <el-button type="delete" @click="getDelete(scope.row)">删除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
@@ -33,27 +39,116 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { list, remove } from '@/api/article/list'
|
|
|
+import { devMixin } from './mixin'
|
|
|
export default {
|
|
|
+ mixins: [devMixin],
|
|
|
data() {
|
|
|
return {
|
|
|
- tableData:[{
|
|
|
- id: 1
|
|
|
- }]
|
|
|
+ // 遮罩层
|
|
|
+ loading: false,
|
|
|
+ // 表单
|
|
|
+ form: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10
|
|
|
+ },
|
|
|
+ // 列表
|
|
|
+ tableData: [],
|
|
|
+ total: 0,
|
|
|
+ // 批量删除
|
|
|
+ deleteList: [],
|
|
|
+ // 设备列表
|
|
|
+ devOptions: [],
|
|
|
+ // 状态
|
|
|
+ statusOptions: [
|
|
|
+ { value: 0, label: '上架' },
|
|
|
+ { value: 1, label: '下架' }
|
|
|
+ ]
|
|
|
}
|
|
|
},
|
|
|
- methods:{
|
|
|
- getDetail(row){
|
|
|
+ mounted() {
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 列表
|
|
|
+ getList() {
|
|
|
+ this.loading = true
|
|
|
+ list(this.form).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.tableData = res.data.records
|
|
|
+ this.total = res.data.total
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 搜索
|
|
|
+ getSearch() {
|
|
|
+ this.form.pageNum = 1
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ // 重置
|
|
|
+ getRefresh() {
|
|
|
+ this.form = {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10
|
|
|
+ }
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ // 新增 / 编辑
|
|
|
+ getDetail(id) {
|
|
|
this.$router.push({
|
|
|
path: `/article/articleList/detail`,
|
|
|
query: {
|
|
|
- id: row.id
|
|
|
+ id: id
|
|
|
}
|
|
|
})
|
|
|
+ },
|
|
|
+ // 多选
|
|
|
+ handleSelectionChange(val) {
|
|
|
+ this.deleteList = val
|
|
|
+ },
|
|
|
+ // 删除
|
|
|
+ getDelete(row) {
|
|
|
+ let title = ''
|
|
|
+ let ids = ''
|
|
|
+ if (row.length > 0) {
|
|
|
+ title = '批量删除'
|
|
|
+ row.map(i => {
|
|
|
+ ids += i.id + ','
|
|
|
+ })
|
|
|
+ if (ids.length > 0) {
|
|
|
+ ids = ids.substr(0, ids.length - 1)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ title = `删除${row.title}`
|
|
|
+ ids = row.id
|
|
|
+ }
|
|
|
+ this.$confirm(`是否${title}?`, '提示', {
|
|
|
+ 'confirmButtonText': '确定',
|
|
|
+ 'cancelButtonText': '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ remove({
|
|
|
+ ids: ids
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.$message.success('删除成功!')
|
|
|
+ this.getList()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }).catch(() => { })
|
|
|
+ },
|
|
|
+
|
|
|
+ // 字典翻译
|
|
|
+ devFormatter(row) {
|
|
|
+ return row.linkDevice ? row.linkDevice.split(',').map(i => this.selectDictLabel(this.devOptions, i)).join(',') : ''
|
|
|
+ },
|
|
|
+ statusFormatter(row) {
|
|
|
+ return this.selectDictLabel(this.statusOptions, row.status)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-
|
|
|
</style>
|