<template>
  <div class="app-container">
    <el-table style="width: 100%" :data="unscrambleList">
      <el-table-column
        label="序号"
        align="center"
        type="index"
      ></el-table-column>
      <el-table-column
        label="意见反馈"
        align="center"
        prop="text"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column
        label="联系方式"
        align="center"
        prop="phone"
      ></el-table-column>
      <el-table-column
        label="创建时间"
        align="center"
        prop="createTime"
      ></el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button
            @click="handleDelete(scope.row.id)"
            type="text"
            size="small"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>
<script>
import {
  getOpinionList,
  delOpinion,
} from '@/api/feedback/opinion';
export default {
  data() {
    return {
      unscrambleList: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      total:0,
      optionList1: [
        {
          value: '1',
          label: '地级市'
        },
        {
          value: '2',
          label: '合肥区县'
        }
      ]
    };
  },
  methods: {
    getList() {
      getOpinionList(this.queryParams).then(({ data }) => {
        this.unscrambleList = data.list;
        this.total = data.total
      });
    },
    handleStatus(companyId, isOpen) {
      handleCompanyUser({ companyId, isOpen }).then(({ message }) => {
        this.msgSuccess(message);
        this.getList();
      });
    },
    // 跳转页面
    handlePage(id) {
      this.$router.push({ path: '/addCustomer', query: { id, check: true } });
    },
    /** 删除按钮操作 */
    handleDelete(id) {
      this.$confirm('确认删除该数据?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(function() {
          return delOpinion({ id });
        })
        .then(() => {
          this.getList();
          this.msgSuccess('删除成功');
        });
    },
    // 重置密码
    resetPwd(userId) {
      // resetPw
      this.$prompt('请输入新密码', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
        // inputPattern: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,
        // inputErrorMessage: '邮箱格式不正确'
      })
        .then(({ value }) => {
          resetPw({ userId, password: value }).then(({ data }) => {
            this.msgSuccess(data);
          });
        })
        .catch(() => {});
    }
  },
  created() {
    this.getList();
  }
};
</script>
