Newer
Older
smartcity_video / src / views / case / caseList.vue
wangxitong on 11 Sep 5 KB Default Changelist
<template>
  <app-container>
    <search-area :need-clear="true" :need-search-more="false" type="seperate" size="small" search-more-type="default" @search="fetchData(false)" @clear="clearInput">
      <!--一般查询条件-->
      <search-item>
        <el-select v-model="listQuery.caseStatus" placeholder="案卷状态" clearable @change="fetchData(false)">
          <el-option
            v-for="item in caseStatusList"
            :key="item.code"
            :label="item.name"
            :value="item.code"
          />
        </el-select>
      </search-item>
    </search-area>
    <normal-table
      :data="list"
      :head="tableOption.head"
      :query="listQuery"
      :total="total"
      :columns="columns"
      :list-loading="listLoading"
      :options="tableOption.options"
      :tools-option="tableOption.toolsOption"
      @change="changePage"
      @selectionChange="handleSelectionChange">
      <template slot="btns"/>
      <template slot="columns">
        <el-table-column label="案卷照片" align="center" width="120">
          <template slot-scope="scope">
            <el-image :src="scope.row.imgUrl ? `${scope.row.imgUrl}`: defaultPhoto" :preview-src-list="srcList" width="50" height="50" style="width: 50px; height: 50px;margin-top: 10px" @error="errorImg"/>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="130">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click.stop="edit(scope.row)">
              详情
            </el-button>
          </template>
        </el-table-column>
      </template>
    </normal-table>
    <edit-case v-show="dialogFormVisible" ref="editCase" @watchChild="fetchData"/>
  </app-container>
</template>

<script>
import { getDictByCode } from '@/api/system/dict'
import NormalTable from '@/components/NormalTable'
import AppContainer from '@/components/layout/AppContainer'
import SearchArea from '@/components/SearchArea/SearchArea'
import SearchItem from '@/components/SearchArea/SearchItem'
import { getCaseListPage } from '@/api/case'
import EditCase from '@/views/case/editCase'
export default {
  name: 'CaseList',
  components: {EditCase, SearchItem, SearchArea, AppContainer, NormalTable },
  data() {
    return {
      defaultPhoto: require('@/assets/global_images/photo_error.png'),
      errorImg: require('@/assets/global_images/photo_error.png'),
      srcList: [],
      listQuery: {
        caseStatus: '',
        offset: 1,
        limit: 20
      }, // 筛选条件
      columns: [
        {
          text: '案卷编号',
          value: 'regCaseId',
          align: 'center'
        },
        {
          text: '案卷状态',
          value: 'caseStatusName',
          align: 'center'
        },
        {
          text: '小类',
          value: 'caseSubTypeName',
          align: 'center'
        },
        {
          text: '备注',
          value: 'remarks',
          align: 'center'
        },
        {
          text: '创建时间',
          value: 'createTime',
          align: 'center'
        }
      ], // 显示列
      caseStatusList: [],
      dialogFormVisible: false, // 是否显示编辑框
      timeRange: [], // 时间范围
      multipleSelection: [], // 多选选中项
      list: [], // 列表数据
      total: 0, // 数据总数
      listLoading: true, // 列表加载动画
      tableOption: {
        head: {
          show: true, // 是否需要标题栏,
          text: '数据列表' // 标题名称
        },
        options: {
          needIndex: true // 是否需要序号列
        },
        toolsOption: {
          selectColumns: false, // 是否需要筛选列
          refresh: false, // 是否需要刷新按钮
          needCheckBox: false
        }
      } // 表格属性
    }
  },
  created() {
    this.fetchOptions()
    this.fetchData()
  },
  methods: {
    checkCell(val) {
      switch (val.levelName) {
        case '重大':
          return 'hard-state'
        case '较大':
          return 'medium-state'
        default:
          return 'low-state'
      }
    },
    fetchOptions() {
      getDictByCode('videoCaseStatus').then(response => {
        if (response.code === 200) {
          this.caseStatusList = response.data
        }
      })
    },
    fetchData(isNowPage = true) {
      this.listLoading = true
      if (!isNowPage) { // 是否显示当前页,否则跳转第一页
        this.listQuery.offset = 1
      }
      getCaseListPage(this.listQuery).then(response => {
        if (response.code === 200) {
          console.log(this.baseURL)
          this.list = response.data.rows.map(item => {
            if (item.imgPath !== '') {
              item.imgUrl = 'http://117.45.27.131:20601/video/static/' + item.imgPath
            }
            return item
          })
          this.srcList = this.list.map(item => item.imgUrl)
          this.total = parseInt(response.data.total)
          this.listLoading = false
        }
      })
    },
    // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写
    changePage(val) {
      if (val && val.size) {
        this.listQuery.limit = val.size
      }
      if (val && val.page) {
        this.listQuery.offset = val.page
      }
      this.fetchData()
    },
    edit(row) {
      this.$refs.editCase.initDialog('update', row)
    },
    handleSelectionChange(val) {
      this.multipleSelection = val
    },
    clearInput() {
      this.listQuery = {
        caseStatus: '',
        offset: 1,
        limit: 20
      }
      this.fetchData()
    }
  }
}
</script>

<style scoped>
.hard-state{
  color:red;
  font-weight: bold;
}
.medium-state{
  color: #ea9700;
  font-weight: bold;
}
.low-state{
  color: #409EFF;
  font-weight: bold;
}
</style>