<!--
  @description: 反馈管理---受理人---反馈管理列表
  @Modifier: zcy
  @routerPath: complaintsSuggestions/complaintsSuggestions-add.vue
  @date: 2021-11-18 15:02
-->
<template>
  <div>
    <table-crud
      ref="tableCrud"
      :menu="true"
      :search-form.sync="searchForm"
      search-label-width="100px"
      @on-load="loadData"
    >
      <!--标题-->
      <template v-slot:header>
        <span>供应商反馈</span>
      </template>
      <!--查询条件-->

      <template v-slot:search="search">
        <el-form-item ref="complaintsType" label="反馈类型" prop="complaintsType">
          <el-select v-model="searchForm.complaintsType" placeholder="--请选择--">
            <el-option
              v-for="item in complaintsTypeList"
              :key="item.typename"
              :label="item.typename"
              :value="item.typecode"
            />
          </el-select>
        </el-form-item>
        <!-- 反馈名称 -->
        <el-form-item ref="complaintsDepartmentName" label="反馈名称" prop="complaintsDepartmentName">
          <gx-input
            v-model.trim="searchForm.complaintsDepartmentName"
            @keyup.enter.native="search.onSearch"
          />
        </el-form-item>
        <el-form-item ref="complaintsUserName" label="联系人" prop="complaintsUserName">
          <gx-input
            v-model.trim="searchForm.complaintsUserName"
            @keyup.enter.native="search.onSearch"
          />
        </el-form-item>
        <el-form-item ref="complaintsState" label="状态" prop="complaintsState">
          <el-select v-model="searchForm.complaintsState" placeholder="--请选择--">
            <el-option label="待受理" value="00" />
            <el-option label="已受理" value="01" />
          </el-select>
        </el-form-item>
      </template>
<!--      <template v-slot:menuLeft>-->
<!--        <div class="mb10">-->
<!--          <el-button type="primary">-->
<!--            导出-->
<!--          </el-button>-->
<!--        </div>-->
<!--      </template>-->
      <template v-slot:GXTable>
        <el-table ref="smallTable" v-loading="loading" :data="tableData">
          <el-table-column
            type="index"
            label="序号"
            align="center"
            width="60"
          />
          <el-table-column
            prop="complaintsType"
            label="反馈类型"
            width="130"
            header-align="center"
            align="center"
          >
            <template slot-scope="scope">
              {{ filterDictText(complaintsTypeList,scope.row.complaintsType) }}
            </template>
          </el-table-column>
          <el-table-column
            prop="supplierName"
            label="反馈名称"
            min-width="150"
            header-align="center"
            align="left"
          />
          <el-table-column
            prop="complaintsUserName"
            label="联系人"
            header-align="center"
            align="center"
            width="120"
          />
          <el-table-column
            prop="createTime"
            label="提交时间"
            header-align="center"
            align="center"
            width="130"
          >
            <template slot-scope="scope">
              {{ scope.row.createTime && $Moment(scope.row.createTime).format(momentDateTime) }}
            </template>
          </el-table-column>
          <el-table-column
            prop="complaintsState"
            label="状态"
            header-align="center"
            align="center"
            width="120"
          >
            <template slot-scope="scope">
              {{ filterDictText(complaintsStateList,scope.row.complaintsState) }}
            </template>
          </el-table-column>
          <el-table-column
            label="操作"
            align="center"
            width="150"
            fixed="right"
          >
            <template slot-scope="scope">
              <el-link v-if="scope.row.complaintsState === '00'" type="primary" @click.stop="toDetail(scope.row)">
                受理
              </el-link>
              <el-link v-if="scope.row.complaintsState === '01'" type="primary" @click.stop="toDetail(scope.row)">
                查看
              </el-link>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </table-crud>
  </div>
</template>

<script>
/* API */
import { queryListByReplyUser } from '@/api/procurement/procurementProject'
/* 公用方法*/
import { filterDictText } from '@/assets/js/utils' // 常用方法
import { compaintsSuggestionsGroupMixins } from '../mixins/complaintsSuggestionsGroupMixins' // 公共字典
export default {
  mixins: [compaintsSuggestionsGroupMixins],
  data() {
    return {
      searchForm: {
        complaintsState: '', // 筛选 00未回复(提交) 01已回复 02草稿
        complaintsType: '', // 筛选 00项目；01订单；02其他
        complaintsDepartmentName: '', // 反馈名称
        complaintsUserName: ''// 联系人
      },
      tableData: [], // 列表数据
      loading: true // 是否开启加载动画
    }
  },
  mounted() {
  },
  methods: {
    filterDictText,
    // 获取数据
    loadData(params, callback, tabData) {
      queryListByReplyUser(params).then(res => {
        this.loading = false
        this.tableData = res.data.records
        callback(res.data.total)
      })
    },
    // 受理详情
    toDetail(row) {
      this.$router.push({
        name: 'SuggestionsAcceptorAudit-detail',
        params: {
          id: row.id, // 主键id
          complaintsState: row.complaintsState // 状态 00待受理 01已受理
        }
      })
    }
  }
}
</script>
