<template> 
 | 
    <TableLayout :permissions="['business:knowledge:query']"> 
 | 
        <!-- 搜索表单 --> 
 | 
        <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline> 
 | 
            <el-form-item label="标题" prop="title"> 
 | 
                <el-input v-model="searchForm.title" style="width: 120px"  clearable placeholder="请输入标题" @keypress.enter.native="search"></el-input> 
 | 
            </el-form-item> 
 | 
          <el-form-item label="省份" prop="area"> 
 | 
            <el-select style="width: 120px"  v-model="searchForm.provinceId" clearable filterable @change="changeProvince" placeholder="请选择"> 
 | 
              <el-option 
 | 
                  v-for="item in areas" 
 | 
                  :key="item.id" 
 | 
                  :label="item.name" 
 | 
                  :value="item.id"> 
 | 
              </el-option> 
 | 
            </el-select> 
 | 
          </el-form-item> 
 | 
          <el-form-item label="城市" prop="area"> 
 | 
            <el-select style="width: 120px" v-model="searchForm.cityId"  clearablefilterable @change="search" placeholder="请选择"> 
 | 
              <el-option 
 | 
                  v-for="item in citys" 
 | 
                  :key="item.id" 
 | 
                  :label="item.name" 
 | 
                  :value="item.id"> 
 | 
              </el-option> 
 | 
            </el-select> 
 | 
          </el-form-item> 
 | 
            <section> 
 | 
                <el-button type="primary" @click="search">搜索</el-button> 
 | 
<!--                <el-button type="primary" :loading="isWorking.export" v-permissions="['business:knowledge:exportExcel']" @click="exportExcel">导出</el-button>--> 
 | 
                <el-button @click="reset">重置</el-button> 
 | 
            </section> 
 | 
        </el-form> 
 | 
        <!-- 表格和分页 --> 
 | 
        <template v-slot:table-wrap> 
 | 
            <ul class="toolbar" v-permissions="['business:knowledge:create', 'business:knowledge:delete']"> 
 | 
                <li><el-button type="primary" @click="$refs.operaKnowledgeWindow.open('新建')" icon="el-icon-plus" v-permissions="['business:knowledge:create']">新建</el-button></li> 
 | 
<!--                <li><el-button @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:knowledge:delete']">删除</el-button></li>--> 
 | 
            </ul> 
 | 
            <div class="list" v-loading="isWorking.search" v-if="tableData.list.length > 0"> 
 | 
                <div class="list-item" v-for="(item, index) in tableData.list" :key="index"> 
 | 
                    <div class="list-item-title" @click="gourl(item.link)"> 
 | 
                        <span >{{item.title}}</span> 
 | 
                        <i class="el-icon-arrow-right"></i> 
 | 
                    </div> 
 | 
                    <div class="list-item-cates" v-if="item.labels"> 
 | 
                        <div class="list-item-cates-row" v-for="(label, index) in item.labels.split(',')" :key="index">  {{label}}</div> 
 | 
                    </div> 
 | 
                    <div class="list-item-footer"> 
 | 
                        <div class="left"> 
 | 
                            <div class="list-item-footer-row">适用地区:{{item.cityName ? item.cityName : item.provinceName}}</div> 
 | 
                            <div class="list-item-footer-row">适用年份:{{item.yearInfo}} 年</div> 
 | 
                        </div> 
 | 
                        <div class="right"> 
 | 
                            <el-button type="text" size="medium" style="margin-right: 15px; color: red;" @click="dele(item.id)">删除</el-button> 
 | 
                            <el-button type="text" size="medium" @click="$refs.operaKnowledgeWindow.open('编辑', item)">修改</el-button> 
 | 
                        </div> 
 | 
                    </div> 
 | 
                </div> 
 | 
            </div> 
 | 
            <div class="wu" v-else v-loading="isWorking.search"> 
 | 
                暂无数据 
 | 
            </div> 
 | 
            <pagination 
 | 
                @size-change="handleSizeChange" 
 | 
                @current-change="handlePageChange" 
 | 
                :pagination="tableData.pagination" 
 | 
            > 
 | 
            </pagination> 
 | 
        </template> 
 | 
        <!-- 新建/修改 --> 
 | 
        <OperaKnowledgeWindow ref="operaKnowledgeWindow" @success="handlePageChange"/> 
 | 
    </TableLayout> 
 | 
</template> 
 | 
  
 | 
<script> 
 | 
import BaseTable from '@/components/base/BaseTable' 
 | 
import TableLayout from '@/layouts/TableLayout' 
 | 
import Pagination from '@/components/common/Pagination' 
 | 
import OperaKnowledgeWindow from '@/components/business/OperaKnowledgeWindow' 
 | 
import {deleteById, findTreeList} from '@/api/business/knowledge' 
 | 
export default { 
 | 
  name: 'Knowledge', 
 | 
  extends: BaseTable, 
 | 
  components: { TableLayout, Pagination, OperaKnowledgeWindow }, 
 | 
  data () { 
 | 
    return { 
 | 
      // 搜索 
 | 
      searchForm: { 
 | 
        provinceId: '', 
 | 
        cityId: '', 
 | 
        title: '' 
 | 
      }, 
 | 
      areas: [], 
 | 
      citys: [] 
 | 
    } 
 | 
  }, 
 | 
  created () { 
 | 
    this.config({ 
 | 
      module: '知识库信息表', 
 | 
      api: '/business/knowledge', 
 | 
      'field.id': 'id', 
 | 
      'field.main': 'id' 
 | 
    }) 
 | 
    this.search() 
 | 
    this.getCityTree() 
 | 
  }, 
 | 
  methods: { 
 | 
    changeProvince (e) { 
 | 
      this.citys = [] 
 | 
      this.searchForm.cityId=null 
 | 
      this.areas.forEach(item => { 
 | 
        if (item.id === this.searchForm.provinceId) { 
 | 
          this.citys = item.childAreasList || [] 
 | 
        } 
 | 
      }) 
 | 
      this.search() 
 | 
    }, 
 | 
    gourl (url) { 
 | 
      if (url) { 
 | 
        window.open(url) 
 | 
      } 
 | 
    }, 
 | 
    dele (id) { 
 | 
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', { 
 | 
        confirmButtonText: '确定', 
 | 
        cancelButtonText: '取消', 
 | 
        type: 'warning' 
 | 
      }).then(async () => { 
 | 
        const res = await deleteById(id) 
 | 
        this.search() 
 | 
        this.$message.success('删除成功') 
 | 
      }).catch(() => { 
 | 
  
 | 
      }) 
 | 
    }, 
 | 
    async getCityTree () { 
 | 
      this.areas = await findTreeList({}) 
 | 
    } 
 | 
  } 
 | 
} 
 | 
</script> 
 | 
  
 | 
<style lang="scss" scoped> 
 | 
    .wu { 
 | 
        width: 100%; 
 | 
        height: 200px; 
 | 
        display: flex; 
 | 
        align-items: center; 
 | 
        justify-content: center; 
 | 
        color: #222222; 
 | 
        font-size: 18px; 
 | 
        font-weight: bold; 
 | 
    } 
 | 
    .list { 
 | 
        width: 100%; 
 | 
        display: flex; 
 | 
        flex-direction: column; 
 | 
        .list-item { 
 | 
            width: 100%; 
 | 
            padding: 20px; 
 | 
            border-radius: 10px; 
 | 
            box-sizing: border-box; 
 | 
            border: 1px solid #ececec; 
 | 
            margin-bottom: 15px; 
 | 
            cursor: pointer; 
 | 
            &:last-child { 
 | 
                margin: 0; 
 | 
            } 
 | 
            .list-item-title { 
 | 
                width: 100%; 
 | 
                display: flex; 
 | 
                align-items: center; 
 | 
                justify-content: space-between; 
 | 
                span { 
 | 
                    flex: 1; 
 | 
                    color: rgba(54,98,227,1); 
 | 
                    font-size: 18px; 
 | 
                } 
 | 
                i { 
 | 
                    flex-shrink: 0; 
 | 
                    margin-left: 30px; 
 | 
                    font-size: 22px; 
 | 
                    color: rgba(54,98,227,1); 
 | 
                } 
 | 
            } 
 | 
            .list-item-cates { 
 | 
                width: 100%; 
 | 
                display: flex; 
 | 
                align-items: center; 
 | 
                margin: 10px 0; 
 | 
                .list-item-cates-row { 
 | 
                    padding: 3px 8px; 
 | 
                    box-sizing: border-box; 
 | 
                    border-radius: 4px; 
 | 
                    background-color: rgba(190,190,190,1); 
 | 
                    color: rgba(255,255,255,1); 
 | 
                    font-size: 12px; 
 | 
                    margin-left: 15px; 
 | 
                    &:first-child { 
 | 
                        margin: 0 !important; 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
            .list-item-footer { 
 | 
                width: 100%; 
 | 
                display: flex; 
 | 
                align-items: center; 
 | 
                justify-content: space-between; 
 | 
                .left { 
 | 
                    display: flex; 
 | 
                    align-items: center; 
 | 
                    .list-item-footer-row { 
 | 
                        color: rgba(154,154,154,1); 
 | 
                        font-size: 14px; 
 | 
                        margin-right: 50px; 
 | 
                    } 
 | 
                } 
 | 
  
 | 
            } 
 | 
        } 
 | 
    } 
 | 
</style> 
 |