//投诉举报
<template>
  <div class="center">
    <div class="center_css">
      <div class="top_css">
        <el-row>
          <el-col :span="14" style="height: 45px">
            <!-- <el-button type="primary">添加</el-button> -->
          </el-col>
          <el-col :span="10">
            <div class="screen">
              <el-input placeholder="可按工单编号、姓名、账号和反馈信息查找" v-model="searchkeyWord" clearable @change="find"></el-input>
              <el-button class="search" @click="find"><img width="16" height="16" style="margin-left: -8px"
                  src="../../../public/img/sousuo.png" /></el-button><span
                class="count_css">共{{ deptBudgetTotal }}条</span>
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <div class="search_btn">
              <div :class="search == '' ? 'search' : 'searchNo'" class="search_item search_block"
                @click="searchBtn('')">
                全部
              </div>
              <div :class="search == 1 ? 'search' : 'searchNo'" class="search_item" @click="searchBtn(1)">
                举报
              </div>
              <div :class="search == 2 ? 'search' : 'searchNo'" class="search_item" @click="searchBtn(2)">
                投诉
              </div>
            </div>
          </el-col>
        </el-row>
      </div>
      <el-table :data="tableData" style="width: 98%; margin: 0 auto; border-radius: 10px" height="55.8vh" border>
        <el-table-column prop="number" label="工单编号"></el-table-column>
        <el-table-column prop="initiator" label="发起方"></el-table-column>
        <el-table-column prop="initiatorNumber" label="发起方账号"></el-table-column>
        <el-table-column prop="passive" label="被动方"></el-table-column>
        <el-table-column prop="passiveNumber" label="被动方账号"></el-table-column>
        <el-table-column prop="content" label="内容"></el-table-column>
        <el-table-column prop="authenticationStatus" label="附图">
          <template scope="scope">
            <span  class="btn_css" @click="seeUrl(scope.row)">查看</span>
          </template>
        </el-table-column>
        <el-table-column prop="updateDate" label="时间"></el-table-column>
        <el-table-column prop="status" label="状态"></el-table-column>
        <el-table-column prop="authenticationStatus" label="满意度">
          <template slot-scope="scope">
            <span v-if="scope.row.processingResultsSatisfaction == 1">极不满意</span>
            <span v-if="scope.row.processingResultsSatisfaction == 2">不满意</span>
            <span v-if="scope.row.processingResultsSatisfaction == 3">一般</span>
            <span v-if="scope.row.processingResultsSatisfaction == 4">满意</span>
            <span v-if="scope.row.processingResultsSatisfaction == 5">非常满意</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" min-width="300">
          <template slot-scope="scope">
            <el-link target="_blank" type="primary" :underline="false" @click="lookInfo(scope.row)">查看</el-link>
            <el-divider direction="vertical"></el-divider>
            <el-link target="_blank" type="primary" :underline="false" @click="reply(scope.row)">回复</el-link>
            <!-- <el-divider direction="vertical"></el-divider> -->
            <!-- <el-link target="_blank" type="primary" :underline="false">消息</el-link>
            <el-divider direction="vertical"></el-divider> -->
            <!-- <el-dropdown>
              <span class="btn_css">•••</span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item><span @click="switchChange(scope.row,'1')">禁用</span>
                </el-dropdown-item>
                <el-dropdown-item><span @click="switchChange(scope.row,'2')">启用</span>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown> -->
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
      style="text-align: center; margin-top: 10px" :page-size="deptCircularPage.pageSize"
      layout="total, sizes, prev, pager, next, jumper" :total="deptBudgetTotal">
    </el-pagination>
    <!-- //消息 -->
    <el-dialog :close-on-click-modal='false' :title="titleInfo" :visible.sync="sendInfo" width="400px" :before-close="sendInfoClose">
      <div class="Info_css">
        <div class="Info_title">
          {{ Info.initiator }}
          <span>{{ Info.flag == 1 ? "投诉" : "举报" }} {{ Info.passive }}</span>
        </div>
        <!-- <div class="Info_item">
          <el-input placeholder="输入消息标题，不超过4-20个字。" v-model="Info.newsTitle" maxlength="20"></el-input>
        </div> -->
        <div class="Info_title">处理结果</div>
        <div class="Info_item" v-if="Info.status == '未处理' ">
          <el-input type="textarea" :rows="3" resize="none" placeholder="输入处理结果" maxlength="100"
            v-model="Info.processingResults"></el-input>
        </div>
        <div class="Info_item" v-else>
          {{ Info.processingResults }}
        </div>
        <div class="Info_btn">
          <el-button @click="sendInfoClose" v-if=" Info.status == '已处理' && titleInfo == '投诉处理结果' ||  titleInfo == '举报处理结果' ">关闭</el-button>
          <el-button @click="submitInfo" type="primary" v-else-if="Info.status == '未处理' && (titleInfo == '投诉处理' ||titleInfo == '举报处理')">提交</el-button>
          <el-button @click="sendInfoClose" type="primary" v-else>关闭</el-button>
        </div>
      </div>
    </el-dialog>
    <!-- //附图 -->
     <el-dialog :close-on-click-modal='false' title="附图" :visible.sync="seePicture" width="500px" :before-close="seePictureClose">
        <img :src="dataInfo.url" class="user_item" style="width:100%;" @click="enlarge(dataInfo.url)"/>
    </el-dialog>
    <el-image-viewer v-if="imgsVisible" :on-close="closeImgViewer" :url-list="srcList" style="z-index:9999" />
  </div>
</template>
<script>
  import {
    getList,
    submitResult
  } from "@/api/feedbackManagement";
  export default {
    components: {
      "el-image-viewer": () =>
        import("element-ui/packages/image/src/image-viewer"),
    },
    data() {
      return {
        tableData: [],
        //分页
        searchkeyWord: "",
        currentPage: 1,
        pageSize: 10,
        deptBudgetTotal: 0,
        deptCircularPage: {},
        search: "",
        Info: {},
        sendInfo: false,
        titleInfo: "",
        dataInfo:{},
        seePicture:false,
        //图片预览
        srcList: [],
        imgsVisible: false,
      };
    },

    mounted() {
      this.getList();
    },
    methods: {
      closeImgViewer() {
        this.srcList = []
        this.imgsVisible = false;
      },
      enlarge(url) {
        this.imgsVisible = true;
        this.srcList.push(url)
      },
      seeUrl(val){
        this.seePicture = true
        this.dataInfo = val

      },
      seePictureClose(){
        this.seePicture = false

      },
      searchBtn(val) {
        this.search = val;
        this.getList();
      },
      lookInfo(val) {
        this.sendInfo = true;
        this.Info = val;
        if (val.flag == 1) {
          this.titleInfo = "投诉处理结果";
        } else if (val.flag == 2) {
          this.titleInfo = "举报处理结果";
        }
      },
      reply(val) {
        this.sendInfo = true;
        this.Info = val;
        if (val.flag == 1) {
          this.titleInfo = "投诉处理";
        } else if (val.flag == 2) {
          this.titleInfo = "举报处理";
        }
      },
      getList() {
        this.listLoading = true;
        getList({
            searchType: this.search,
            searchKeyWord: this.searchkeyWord,
            currentPage: this.currentPage,
            pageSize: this.pageSize,
          })
          .then((response) => {
            this.tableData = response.data.records;
            this.deptBudgetTotal = response.data.total;
            this.listLoading = false;
          })
          .catch(() => {
            this.listLoading = false;
          });
      },
      find() {
        this.getList();
      },
      sendInfoClose() {
        this.sendInfo = false;
      },
      submitInfo() {
        if(!this.Info.processingResults){
          this.$message.error("处理结果不能为空！")
          return
        }
        this.$confirm("是否提交处理结果", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          this.listLoading = true;
          this.Info.editFlag = "2"
          submitResult(this.Info)
            .then((response) => {
              this.$notify({
                title: "成功",
                message: "提交成功！",
                type: "success",
              });
              this.listLoading = false;
            })
            .catch(() => {
              this.listLoading = false;
            });
        });
      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
        this.pageSize = val;
        this.getList();
      },
      handleCurrentChange(val) {
        this.currentPage = val;
        console.log(`当前页: ${val}`);
        this.getList();
      },
    },
  };
</script>
<style lang="scss" scoped>
  .center {
    padding: 10px 20px;
    background: #f5f6f7;
    height: calc(100vh - 5vh);

    .top_css {
      padding: 10px;

      .search_btn {
        height: 80px;
        background: linear-gradient(#fafbfb, #ffffff);
        display: flex;
        margin-top: 20px;

        .search_block {
          margin-left: 20px;
        }

        .search_item {
          text-align: center;
          font-size: 14px;
          font-weight: 600;
          line-height: 40px;
          width: 112px;
          height: 40px;
          background: #f7f8f9;
          cursor: pointer;
          margin-top: 30px;
        }

        .searchNo {
          color: #323233;
        }

        .search {
          color: #2f53eb;
          background: #ffffff;
        }
      }
    }

    .screen {
      display: flex;

      .search {
        width: 40px;
        height: 40px;
        background: #f7f8fa;
        border-radius: 0px 2px 2px 0px;
        border: 1px solid #f0f1f2;
      }

      .count_css {
        width: 80px;
        text-align: center;
        line-height: 40px;
        color: #666666;
      }
    }

    .el-button {
      padding: 10px 20px !important;
    }

    .center_css {
      background: #ffffff;
      border-radius: 1px;
      margin-top: 10px;
      padding-bottom: 10px;

      ::v-deep .el-table th,
      ::v-deep .el-table td {
        text-align: center;
      }

      .fujian {
        font-size: 24px;
        color: #409eff;
      }

      .warning {
        font-size: 14px;
        color: #ed1d1d;
      }
    }
  }

  .tips {
    color: #999999;
    font-size: 14px;
  }

  .car_item {
    width: 200px;
    height: 160px;
    border-radius: 5px;
  }

  ::v-deep .el-table--border .el-table__header th {
    background: #f7f8f9;
  }

  .btn_css {
    color: #409eff;
    cursor: pointer;
  }

  .btn_css1 {
    margin-left: -20px;
  }

  .sign {
    font-size: 14px;
    color: red;
  }

  //发送信息
  .Info_css {
    .Info_title {
      color: #323233;
      font-size: 16px;
      margin-bottom: 10px;
    }

    .Info_item {
      margin: 20px 0;
    }

    .Info_btn {
      text-align: right;
      margin-top: 10px;
    }
  }
</style>
