<template>
  <el-card
    shadow="never"
    class="aui-card--fill"
  >
    <div class="mod-fhjw__fhjwfeedback}">
      <el-form
        :inline="true"
        :model="dataForm"
        @keyup.enter.native="getDataList()"
      >
        <el-form-item>
          <el-input
            v-model="dataForm.content"
            placeholder="意见、申诉内容"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
          <!-- <el-input
            v-model="dataForm.feedbackType"
            placeholder="意见、申诉内容"
            clearable
          ></el-input> -->
          <el-select
            v-model="dataForm.feedbackType"
            placeholder="请选择反馈类型"
            clearable
          >
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">{{ $t('query') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button
            type="info"
            @click="exportHandle()"
          >{{ $t('export') }}</el-button>
        </el-form-item>
        <!-- <el-form-item>
          <el-button
            v-if="$hasPermission('fhjw:fhjwfeedback:save')"
            type="primary"
            @click="addOrUpdateHandle()"
          >{{ $t('add') }}</el-button>
        </el-form-item> -->
        <el-form-item>
          <el-button
            v-if="$hasPermission('fhjw:fhjwfeedback:delete')"
            type="danger"
            @click="deleteHandle()"
          >{{ $t('deleteBatch') }}</el-button>
        </el-form-item>
      </el-form>
      <el-table
        v-loading="dataListLoading"
        :data="dataList"
        border
        @selection-change="dataListSelectionChangeHandle"
        style="width: 100%;"
      >
        <el-table-column
          type="selection"
          header-align="center"
          align="center"
          width="50"
        ></el-table-column>
        <!--    <el-table-column prop="id" label="id" header-align="center" align="center"></el-table-column> -->
        <el-table-column
          prop="content"
          label="意见、申诉内容"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="feedbackType"
          label="反馈类型"
          header-align="center"
          align="center"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.feedbackType==1">反馈意见</span>
            <span v-if="scope.row.feedbackType==2">控告申诉</span>
            <span v-if="scope.row.feedbackType==3">代表委员有话说</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="optionStatus"
          label="意见类别"
          header-align="center"
          align="center"
        ></el-table-column>

        <el-table-column
          prop="userName"
          label="用户"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="createDate"
          label="创建时间"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          :label="$t('handle')"
          fixed="right"
          header-align="center"
          align="center"
          width="150"
        >
          <template slot-scope="scope">
            <el-button
              type="text"
              size="small"
              @click="detailHandle(scope.row.id)"
            >详情</el-button>
            <el-button
              v-if="$hasPermission('fhjw:fhjwfeedback:delete')"
              type="text"
              size="small"
              @click="deleteHandle(scope.row.id)"
            >{{ $t('delete') }}</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle"
      >
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update
        v-if="addOrUpdateVisible"
        ref="addOrUpdate"
        @refreshDataList="getDataList"
      ></add-or-update>
      <detail
        v-if="detailVisible"
        ref="detail"
        @refreshDataList="getDataList"
      ></detail>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from "@/mixins/view-module";
import AddOrUpdate from "./fhjwfeedback-add-or-update";
import Detail from "./fhjwfeedback-detail";
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: "/fhjw/fhjwfeedback/page",
        getDataListIsPage: true,
        exportURL: "/fhjw/fhjwfeedback/export",
        deleteURL: "/fhjw/fhjwfeedback",
        deleteIsBatch: true,
      },
      detailVisible: false,
      dataForm: {
        id: "",
        content: "",
        feedbackType: "",
      },
      options: [
        {
          value: 1,
          label: "反馈意见",
        },
        {
          value: 2,
          label: "控告申诉",
        },
        {
          value: 3,
          label: "代表委员有话说",
        },
      ],
      value: "",
    };
  },
  methods: {
    detailHandle(id) {
      console.log(id);
      this.detailVisible = true;
      this.$nextTick(() => {
        this.$refs.detail.dataForm.id = id;
        this.$refs.detail.init();
      });
    },
  },
  components: {
    AddOrUpdate,
    Detail,
  },
};
</script>
