<template>
  <div class="app-container">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="未受理投诉单" name="first">
        <div class="filter-container">
        <el-input size="mini" v-model="search.keyWord" placeholder="关键字" style="width: 200px;" class="filter-item"/>
          <el-select style="width: 240px;" size="mini" v-model="billFlag" multiple class="filter-item" @change="search.billFlagStr = ''">
            <el-option
            label="未受理"
            :value="1"></el-option>
            <el-option
              label="未分配"
              :value="2"></el-option>
            <el-option
              label="已分配"
              :value="3"></el-option>
          </el-select>
          <el-input size="mini" v-model="search.orderCode" placeholder="订单编号" style="width: 200px;" class="filter-item"/>
          <el-input size="mini" v-model="search.clientName" placeholder="客户名称" style="width: 200px;" class="filter-item"/>
          <el-input size="mini" v-model="search.tsTitle" placeholder="投诉标题" style="width: 200px;" class="filter-item"/>
          <el-input size="mini" v-model="search.crePerson" placeholder="登记人" style="width: 200px;" class="filter-item"/>
          <el-input size="mini" v-model="search.billCode" placeholder="投诉单号" style="width: 200px;" class="filter-item"/>
          <el-input size="mini" v-model="search.sevPerson" placeholder="客服追踪人" style="width: 200px;" class="filter-item"/>
          <el-date-picker
            size="mini"
            v-model="searchTime1"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd">
          </el-date-picker>
        <el-button size="mini" class="filter-item" type="primary" icon="el-icon-search" @click="searchData">
          搜索
        </el-button>
          <div class="top-right-btn">
            <el-tooltip class="item" effect="dark" content="刷新" placement="top">
              <el-button size="mini" circle icon="el-icon-refresh" @click="getInfo" />
            </el-tooltip>
          </div>
      </div>
        <el-table
        :data="tableData"
        v-loading="listLoading"
        :row-style="customRowStyle"
        style="width: 100%;margin-bottom: 20px;"
        ref="table"
        row-key="id"
        size="mini"
        border
        default-expand-all>
        <el-table-column label="操作" align="center" width="230" class-name="small-padding fixed-width">
          <template slot-scope="{row}">
            <template v-if="row.billFlag == 1">
              <template v-if="row.lockFlag == 1">
                <template v-if="row.idLockMan == $store.state.user.userId">
                  <el-button @click="lockBill(row)" type="warning" size="mini">
                    解锁
                  </el-button>
                  <el-button @click="acceptBillBtn(row)" type="green" size="mini">
                    受理
                  </el-button>
                </template>
                <template v-else>
                  <el-button @click="seeDetails(row)" type="primary" size="mini">
                    查看
                  </el-button>
                </template>
              </template>
              <template v-else-if="row.lockFlag == 0">
                <el-button @click="lockBill(row)" type="danger" size="mini">
                  锁定
                </el-button>
              </template>
            </template>
            <template v-else-if="row.billFlag >1">
              <el-button @click="acceptBillBtn(row)" type="green" size="mini">
                分配
              </el-button>

<!--              <template v-else>-->
<!--                <el-button @click="seeDetails(row)" type="primary" size="mini">-->
<!--                  查看-->
<!--                </el-button>-->
<!--              </template>-->
            </template>
          </template>
        </el-table-column>
        <el-table-column
          type="index"
          label="序号"
          width="50">
          <template slot-scope="scope">
            <span>{{ (listData.page - 1) * listData.pageSize + scope.$index + 1 }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="投诉标题"
          prop="tsTitle"
          width="100"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="tsType"
          label="投诉类型">
          <template slot-scope="{row}">
            <span v-if="row.tsType == 1">内部投诉</span>
            <span v-else-if="row.tsType == 2">外部投诉</span>
          </template>
        </el-table-column>
          <el-table-column prop="crePerson" width="100px" label="登记人"></el-table-column>
          <el-table-column prop="creDept" label="登记部门"></el-table-column>
        <el-table-column
          prop="maxPaperSize"
          label="投诉单状态"
          width="100">
          <template slot-scope="{row}">
            <el-tag v-if="row.billFlag==0" type="primary" size="mini">
              新建
            </el-tag>
            <el-tag v-else-if="row.billFlag==1" type="warning" size="mini">
              待受理
            </el-tag>
            <el-tag v-else-if="row.billFlag==2" type="danger" size="mini">
              待分配
            </el-tag>
            <el-tag v-else-if="row.billFlag==3" type="info" size="mini">
              调查中
            </el-tag>
            <el-tag v-else-if="row.billFlag==4" type="success" size="mini">
              调查完成
            </el-tag>
            <el-tag v-else-if="row.billFlag==5" type="danger" size="mini">
              登记人结单
            </el-tag>
            <el-tag v-else-if="row.billFlag==6" type="green" size="mini">
              行政审核完成
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column
          prop="billCode"
          label="投诉单号"
          width="125">
          <template slot-scope="{row}">
            <el-link type="primary" @click="openStep(row,1)">{{row.billCode}}</el-link>
          </template>
        </el-table-column>
        <el-table-column
          prop="lockMan"
          label="锁定人"
          width="91">
          <template slot-scope="{row}">
            <span
              :class="(row.lockFlag == 1 && row.idLockMan == $store.state.user.userId) ?'text-blue':''">{{
                row.lockMan
              }}</span>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="clientName"
          label="客户名称"></el-table-column>
        <el-table-column
          prop="orderCode"
          label="订单编号"
          width="125"></el-table-column>
        <el-table-column
          prop="sevPerson"
          label="客服跟踪人"
          width="91"></el-table-column>
        <el-table-column
          prop="creDate"
          label="登记时间"
          width="160">
          <template slot-scope="{row}">
            <span v-if="row.creDate!= null">{{ row.creDate | getTime }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="tsLimitDate"
          label="到期时间"
          width="160">
          <template slot-scope="{row}">
            <span v-if="row.tsLimitDate != null">{{ row.tsLimitDate | getTime }}</span>
          </template>
        </el-table-column>
      </el-table>
        <pagination
        v-show="listData.total>0"
        :total="listData.total"
        :page.sync="listData.page"
        :limit.sync="listData.pageSize"
        @pagination="getInfo"/>
      </el-tab-pane>
      <el-tab-pane label="外部调查单" name="second">
        <div class="filter-container">
          <el-input size="mini" v-model="surveySearch.keyWord" placeholder="关键字" style="width: 200px;" class="filter-item"/>
          <el-input size="mini" v-model="surveySearch.orderCode" placeholder="订单编号" style="width: 200px;" class="filter-item"/>
          <el-input size="mini" v-model="surveySearch.clientName" placeholder="客户名称" style="width: 200px;" class="filter-item"/>
          <el-input size="mini" v-model="surveySearch.tsTitle" placeholder="投诉标题" style="width: 200px;" class="filter-item"/>
          <el-input size="mini" v-model="surveySearch.crePerson" placeholder="登记人" style="width: 200px;" class="filter-item"/>
          <el-input size="mini" v-model="surveySearch.billCode" placeholder="投诉单号" style="width: 200px;" class="filter-item"/>
          <el-input size="mini" v-model="surveySearch.sevPerson" placeholder="客服追踪人" style="width: 200px;" class="filter-item"/>
<!--          <el-select size="mini" v-model="surveySearch.billFlag" placeholder="投诉单状态" class="filter-item">-->
<!--            <el-option-->
<!--              v-for="item in billFlagOptions"-->
<!--              :label="item.label"-->
<!--              :value="item.value"-->
<!--            ></el-option>-->
<!--          </el-select>-->
          <el-select size="mini" multiple v-model="surveyState" placeholder="状态" class="filter-item">
            <el-option
              v-for="item in surveyStateOptions"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
<!--          <el-date-picker-->
<!--            size="mini"-->
<!--            v-model="searchTime"-->
<!--            type="daterange"-->
<!--            range-separator="-"-->
<!--            start-placeholder="开始日期"-->
<!--            end-placeholder="结束日期"-->
<!--            value-format="yyyy-MM-dd">-->
<!--          </el-date-picker>-->
          <el-date-picker
            size="mini"
            v-model="surveySearchTime"
            type="daterange"
            range-separator="-"
            start-placeholder="调查单开始日期"
            end-placeholder="调查单结束日期"
            value-format="yyyy-MM-dd">
          </el-date-picker>
          <el-button size="mini" class="filter-item" type="primary" icon="el-icon-search" @click="searchData1">
            搜索
          </el-button>
          <div class="top-right-btn">
            <el-tooltip class="item" effect="dark" content="刷新" placement="top">
              <el-button size="mini" circle icon="el-icon-refresh" @click="getSurveyList" />
            </el-tooltip>
          </div>
        </div>
        <el-table
          :data="surveyTableData"
          v-loading="surveyListLoading"
          :row-style="customRowStyle"
          style="width: 100%;margin-bottom: 20px;"
          max-height="700"
          size="mini"
          ref="table"
          row-key="id"
          border
          default-expand-all>
          <el-table-column label="操作" align="center" width="200px" class-name="small-padding fixed-width">
            <template slot-scope="{row}">
              <el-button
                v-if="row.surveyState < 3"
                @click="surveyBill(row)"
                type="primary"
                size="mini">
                调查
              </el-button>
              <el-button
                v-if="row.surveyState == 0 || row.surveyState == 1"
                @click="deleteBill(row)"
                type="danger"
                size="mini">
                删除
              </el-button>
            </template>
          </el-table-column>
          <el-table-column
            type="index"
            label="序号"
            width="50">
            <template slot-scope="scope">
              <span>{{ (listData.page - 1) * listData.pageSize + scope.$index + 1 }}</span>
            </template>
          </el-table-column>
          <el-table-column label="投诉标题" prop="tsTitle" width="130">
            <template slot-scope="{row}">
              <el-link size="mini" @click="seeDetails(row,2)" type="primary">{{row.tsTitle}}</el-link>
            </template>
          </el-table-column>
          <el-table-column
            prop="tsType"
            label="投诉类型">
            <template slot-scope="{row}">
              <span v-if="row.tsType == '1'">内部投诉</span>
              <span v-else-if="row.tsType == '2'">外部投诉</span>
            </template>
          </el-table-column>
          <el-table-column label="调查单号" prop="surveyBillCode" width="130">
          </el-table-column>
          <el-table-column
            label="投诉单号"
            prop="complaintBillCode"
            width="125"
          >
            <template slot-scope="{row}">
              <el-link type="primary" @click="openStep(row,2)">{{row.complaintBillCode}}</el-link>
            </template>
          </el-table-column>
              <el-table-column
                prop="clientName"
                show-overflow-tooltip
                label="客户名称">
              </el-table-column>
              <el-table-column
                prop="orderCode"
                width="95"
                label="订单编号">
              </el-table-column>
          <el-table-column
            prop="surveyDept"
            label="涉及金额">
          </el-table-column>
              <el-table-column
                prop="sevMoneyOut"
                label="损失金额">
              </el-table-column>
          <el-table-column
            prop="sevPerson"
            label="客服跟踪人"
            width="91"></el-table-column>
          <el-table-column
            label="调查状态"
            width="85">
            <template slot-scope="{row}">
              <el-tag v-if="row.surveyState==0" type="primary" size="mini">
                初始
              </el-tag>
              <el-tag v-else-if="row.surveyState==1" type="warning" size="mini">
                待反馈
              </el-tag>
              <el-tag v-else-if="row.surveyState==2" type="warning" size="mini">
                待审核
              </el-tag>
              <el-tag v-else-if="row.surveyState==3" type="warning" size="mini">
                待结单
              </el-tag>
              <el-tag v-else-if="row.surveyState==4" type="warning" size="mini">
                待行政审核
              </el-tag>
              <el-tag v-else-if="row.surveyState==5" type="success" size="mini">
                行政审核完成
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column
            prop="surveyPerson"
            label="调查人"
            width="125">
          </el-table-column>
          <el-table-column
            prop="feedBackDate"
            label="调查时间"
            width="160">
            <template slot-scope="{row}">
              <span v-if="row.feedBackDate != null">{{ row.feedBackDate | getTime }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="crePerson"
            label="投诉单登记人"
            width="125">
          </el-table-column>
          <el-table-column
            prop="creDate"
            label="登记时间"
            width="160">
            <template slot-scope="{row}">
              <span v-if="row.creDate!= null">{{ row.creDate | getTime }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="tsLimitDate"
            label="到期时间"
            width="160">
            <template slot-scope="{row}">
              <span v-if="row.tsLimitDate != null">{{ row.tsLimitDate | getTime }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="createTime"
            label="调查单生成时间"
            width="160">
            <template slot-scope="{row}">
              <span v-if="row.createTime != null">{{ row.createTime | getTime }}</span>
            </template>
          </el-table-column>
        </el-table>
        <pagination
          v-show="surveyListData.total>0"
          :total="surveyListData.total"
          :page.sync="surveyListData.page"
          :limit.sync="surveyListData.pageSize"
          @pagination="getSurveyList"/>
      </el-tab-pane>
    </el-tabs>
    <cancledialog @tableRefresh="tableRefresh" ref="confirmDialog"></cancledialog>
<!--    <el-dialog title="投诉单" :visible.sync="complaintDialog" width="1250px" top="20px">-->
      <complaint-details ref="complaintDetail" :type="detailsType" @tableReload='acceptSuccess'></complaint-details>
<!--    </el-dialog>-->
    <el-dialog title="投诉单" :visible.sync="lockListDialog" width="1250px">
      <el-table
        :data="billListData"
        v-loading="billListLoading"
        style="width: 100%;margin-bottom: 20px;"
        ref="table"
        row-key="id"
        border
        default-expand-all>
        <el-table-column label="操作" align="center" width="230" class-name="small-padding fixed-width">
          <template slot-scope="{row}">
            <el-button type="green" size="mini" @click="seeDetails(row)">查看</el-button>
          </template>
        </el-table-column>
        <el-table-column
          type="index"
          label="序号"
          width="50">
          <template slot-scope="scope">
            <span>{{ (listData.page - 1) * listData.pageSize + scope.$index + 1 }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="投诉标题"
          prop="tsTitle"
        >
        </el-table-column>
        <el-table-column
          prop="tsType"
          label="投诉类型">
          <template slot-scope="{row}">
            <span v-if="row.tsType == 1">内部投诉</span>
            <span v-else-if="row.tsType == 2">外部投诉</span>
          </template>
        </el-table-column>
        <el-table-column prop="crePerson" label="登记人"></el-table-column>
        <el-table-column prop="creDept" label="登记部门"></el-table-column>
        <el-table-column
          prop="maxPaperSize"
          label="投诉单状态"
          width="100">
          <template slot-scope="{row}">
            <el-tag v-if="row.billFlag==0" type="primary" size="mini">
              新建
            </el-tag>
            <el-tag v-else-if="row.billFlag==1" type="warning" size="mini">
              待受理
            </el-tag>
            <el-tag v-else-if="row.billFlag==2" type="danger" size="mini">
              待分配
            </el-tag>
            <el-tag v-else-if="row.billFlag==3" type="info" size="mini">
              调查中
            </el-tag>
            <el-tag v-else-if="row.billFlag==4" type="success" size="mini">
              调查完成
            </el-tag>
            <el-tag v-else-if="row.billFlag==5" type="danger" size="mini">
              登记人结单
            </el-tag>
            <el-tag v-else-if="row.billFlag==6" type="green" size="mini">
              行政审核完成
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column
          prop="billCode"
          label="投诉单号"
          width="125">
        </el-table-column>
        <el-table-column
          prop="lockMan"
          label="锁定人"
          width="91">
          <template slot-scope="{row}">
            <span
              :class="(row.lockFlag == 1 && row.idLockMan == $store.state.user.userId) ?'text-blue':''">{{
                row.lockMan
              }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="clientName"
          label="客户名称"></el-table-column>
        <el-table-column
          prop="orderCode"
          label="订单编号"
          width="125"></el-table-column>
        <el-table-column
          prop="sevPerson"
          label="客服跟踪人"
          width="91"></el-table-column>
        <el-table-column
          prop="creDate"
          label="登记时间"
          width="160">
          <template slot-scope="{row}">
            <span v-if="row.creDate!= null">{{ row.creDate | getTime }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="tsLimitDate"
          label="到期时间"
          width="160">
          <template slot-scope="{row}">
            <span v-if="row.tsLimitDate != null">{{ row.tsLimitDate | getTime }}</span>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
    <complaint-step ref="complaintStep"></complaint-step>
  </div>
</template>

<script>
import {
  customerPage, lockComplaintBill, getSurveyBillList, getComplaintbillListByIdOrder, voidSurveyBill
} from '@/api/complaint/customerPage'
import Cancledialog from '@/components/Dialog/Cancledialog.vue'
import Pagination from '@/components/Pagination'
import ComplaintDetails from '@/components/complaintDetails/complaintDetails'
import ComplaintStep from "@/components/complaintStep/complaintStep";
import {ifPermission} from "@/api/order/orderList";

const form = {}
export default {
  name: 'customerPage',
  components: {
    ComplaintStep,
    ComplaintDetails,
    Cancledialog, Pagination
  },
  data() {
    return {
      activeName: 'first',
      detailsType: 0,
      form: Object.assign({}, form),
      billFlag: [1,2],
      search: {
        'keyWord': '',
        'billFlagStr': '1,2',
         billFlag: '',
        'orderCode': '',
        'clientName': '',
        'tsTitle': '',
        'crePerson': '',
        'billCode': '',
        'sevPerson': '',
        'beginTime': '',
        'endTime': '',
      },
      searchTime1: [],
      search1: {
        'keyWord': '',
      },
      tableData: [],
      listData: {
        total: 0,
        page: 1,
        pageSize: 10
      },
      listLoading: false,
      // 外部调查单表格
      surveySearch: {
        'keyWord': '',
        'surveyType': 2,
        // 'surveyStateStr': '3',
        'surveyState': '',
        complaintBeginTime: '',
        complaintEndTime: '',
        surveyBeginTime: '',
        surveyEndTime: '',
        orderCode: '',
        clientName: '',
        tsTitle: '',
        crePerson: '',
        billCode: '',
        sevPerson: '',
        billFlag: '',
      },
      surveyState:[0,1,2],
      searchTime: [],
      surveySearchTime: [],
      surveyStateOptions: [
        {
          label: '初始',
          value: 0
        },
        {
          label: '待反馈',
          value: 1
        },
        {
          label: '待审核',
          value: 2
        },
        {
          label: '待结单',
          value: 3
        },
        {
          label: '待行政审核',
          value: 4
        },
        {
          label: '行政审核完成',
          value: 5
        },
      ],
      billFlagOptions: [
        {
          label: '新建',
          value: 0
        },
        {
          label: '待受理',
          value: 1
        },
        {
          label: '待分配',
          value: 2
        },
        {
          label: '调查中',
          value: 3
        },
        {
          label: '调查完成',
          value: 4
        },
        {
          label: '登记人结单',
          value: 5
        },
        {
          label: '行政审核完成',
          value: 6
        },
      ],
      surveyTableData: [],
      surveyListData: {
        total: 0,
        page: 1,
        pageSize: 20
      },
      surveyListLoading: false,

      // 弹窗投诉单详情
      complaintDialog: false,
      // 关联投诉单
      lockListDialog: false,
      billListLoading: false,
      billListData: [],

      permissionFlag: false
    }
  },
  mounted() {
    this.getInfo()
    this.checkPermission()
  },
  watch: {
    lockListDialog(val) {
      // console.log(val);
      if (!val) {
        this.getInfo()
      }
    },
    complaintDialog(val) {
      // console.log(val);
      if (!val) {
        if(this.activeName == 'first'){
          this.getInfo()
        }else {
          this.getSurveyList()
        }
      }
    }
  },
  methods: {
    handleClick(tab, event) {
      if (tab.name == 'second') {
        this.getSurveyList()
      } else {
        this.getInfo()
      }
    },
    // 获取列表
    getInfo() {
      const _that = this
      _that.listLoading = true

      if (_that.searchTime1 == null || _that.searchTime1 < 0) {
        _that.search.beginTime = ''
        _that.search.endTime = ''
      } else {
        _that.search.beginTime = _that.searchTime1[0]
        _that.search.endTime = _that.searchTime1[1]
      }
      _that.search.billFlag = _that.billFlag.join(',')
      var params = _that.search
      var page = {
        pageIndex: _that.listData.page,
        pageSize: _that.listData.pageSize
      }
      var data = {
        'params': JSON.stringify(params),
        'page': JSON.stringify(page)
      }

      customerPage(data).then(response => {
        console.log('customerPage', response)
        const data = response.data
        // //  组合表单数据
        _that.tableData = data
        // console.log(_that.tableData)
        _that.listData.total = response.total
        _that.listLoading = false
      }).catch(err => {
        _that.$message.error(err)
        _that.listLoading = false
      })
    },

    customRowStyle({row, rowIndex}) {
      if (row.tsLimitDate) {
        var times = row.tsLimitDate.substring(0, 19)
        var nowTime = new Date() // 当前时间
        var endD = new Date(times) // 对比时间
        if (nowTime.getTime() > endD.getTime()) {
          return {
            color: 'red'
          }
        }
      }
    },

    // 判断权限
    checkPermission() {
      const _that = this
      var data = {
        permission: 'complaint:survey:checkKf'
      }
      ifPermission(data).then(res => {
        if (res.data == 1) {
          _that.permissionFlag = true
        }
      })
    },
    getSurveyList() {
      const _that = this
      _that.surveyListLoading = true
      _that.surveySearch.surveyState = _that.surveyState.join(',')
      if (_that.searchTime == null || _that.searchTime < 0) {
        _that.surveySearch.complaintBeginTime = ''
        _that.surveySearch.complaintEndTime = ''
      } else {
        _that.surveySearch.complaintBeginTime = _that.searchTime[0]
        _that.surveySearch.complaintEndTime = _that.searchTime[1]
      }
      if (_that.surveySearchTime == null || _that.surveySearchTime < 0) {
        _that.surveySearch.surveyBeginTime = ''
        _that.surveySearch.surveyEndTime = ''
      } else {
        _that.surveySearch.surveyBeginTime = _that.surveySearchTime[0]
        _that.surveySearch.surveyEndTime = _that.surveySearchTime[1]
      }
      var params = _that.surveySearch
      var page = {
        pageIndex: _that.surveyListData.page,
        pageSize: _that.surveyListData.pageSize
      }
      var data = {
        'params': JSON.stringify(params),
        'page': JSON.stringify(page)
      }

      getSurveyBillList(data).then(response => {
        console.log('getSurveyBillList', response)
        const data = response.data
        // //  组合表单数据
        _that.surveyTableData = data
        // console.log(_that.tableData)
        _that.surveyListData.total = response.total
        _that.surveyListLoading = false
      }).catch(err => {
        _that.$message.error(err)
        _that.surveyListLoading = false
      })
    },
    // 搜索
    searchData() {
      this.listData.page = 1
      this.getInfo()
    },
    // 搜索
    searchData1() {
      this.surveyListData.page = 1
      this.getSurveyList()
    },
    // 调查单脚印
    openStep(row,type) {
      const _that = this
      if (type == 1) {
        _that.$refs.complaintStep.idComplaintBill = row.id
      } else {
        _that.$refs.complaintStep.idComplaintBill = row.idComplaintBill
      }
      _that.$refs.complaintStep.getComplaintStep()
    },
    // 对比时间
    timeContrast(time) {
      if (time == null) {
        return false
      }
      var times = time.substring(0, 19)
      var nowTime = new Date() // 当前时间
      var endD = new Date(times) // 对比时间
      if (nowTime.getTime() > endD.getTime()) { // getTime() 方法可返回距 1970 年 1 月 1 日之间的毫秒数。
        // alert('当前时间大于对比时间')
        return true
      } else {
        // alert('当前时间小于对比时间')
        return false
      }
    },
    // 刷新表格
    tableRefresh() {
      this.getInfo()
    },
    // 锁定
    lockBill(row) {
      const _that = this
      var text = ''
      if (row.lockFlag == 0) {
        if(row.orderFlag == 0){
          text = '此操作将锁定投诉单, 是否继续?'
        } else {
          text = '已关联过投诉单，是否继续投诉?'
        }
      } else {
        text = '此操作将解锁投诉单, 是否继续?'
      }
      if (row.orderFlag == 0) {
        _that.$confirm(text, '提示', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning'
        }).then(() => {
          _that.lockFun(row,1)
        }).catch(() => {
        })
      } else {
        _that.$confirm(text, '提示', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning'
        }).then(() => {
          _that.lockFun(row,2)
        }).catch(() => {
        })
      }
    },
    lockFun(row, type) {
      console.log(row);
      var _that = this
      var data = {
        'id': row.id
      }
      // return;
      lockComplaintBill(data).then(response => {
        console.log('customerPage', response)
        if (response.httpCode == 200) {
          if(type == 1){
            _that.$message.success('操作成功')
            _that.tableRefresh()
          } else {
            if(row.lockFlag == 0){
              _that.lockListDialog = true
              _that.getLockList(row)
            }else {
              _that.$message.success('操作成功')
              _that.tableRefresh()
            }
          }
        }
      }).catch(err => {
        _that.$message.error(err)
      })
    },
    getLockList(row){
      var _that = this
      var data = {
        'idOrder': row.idOrder
      }
      getComplaintbillListByIdOrder(data).then(response => {
        console.log('customerPage', response)
        var data = response.data
        _that.billListData = data
        _that.billListLoading = false
      }).catch(err => {
        _that.$message.error(err)
      })
    },
    // 受理
    acceptBillBtn(row) {
      const _that = this
      _that.detailsType = 1
      _that.complaintDialog = true
      _that.$nextTick(() => {
        _that.$refs.complaintDetail.complaintDialog = true
        _that.$refs.complaintDetail.complaintId = row.id
        _that.$refs.complaintDetail.deptList = []
        _that.$refs.complaintDetail.complaintBill.sevPersonDoc = ''
        _that.$refs.complaintDetail.getInfo()
      })
    },
    // 受理成功
    acceptSuccess() {
      this.complaintDialog = false
      this.getInfo()
    },
    // 调查
    surveyBill(row) {
      const _that = this
      _that.detailsType = 2
      _that.complaintDialog = true

      _that.$nextTick(() => {
        _that.$refs.complaintDetail.complaintDialog = true
        _that.$refs.complaintDetail.examineFlag = _that.permissionFlag
        _that.$refs.complaintDetail.complaintId = row.idComplaintBill
        _that.$refs.complaintDetail.currentDeptName = '外部调查'
        _that.$refs.complaintDetail.surveyId = row.id
        _that.$refs.complaintDetail.surveyType = 2
        // _that.$refs.complaintDetail.currentDeptId = row.idSurveyDept
        _that.$refs.complaintDetail.getInfo()
      })
    },
    // 查看
    seeDetails(row, type=1) {
      const _that = this
      _that.detailsType = 0
      _that.complaintDialog = true
      _that.$nextTick(() => {
        if (type == 1) {
          _that.$refs.complaintDetail.complaintId = row.id
        } else {
          _that.$refs.complaintDetail.complaintId = row.idComplaintBill
          _that.$refs.complaintDetail.surveyId = row.id
        }
        _that.$refs.complaintDetail.complaintDialog = true
        _that.$refs.complaintDetail.deptList = []
        _that.$refs.complaintDetail.complaintBill.sevPersonDoc = ''
        _that.$refs.complaintDetail.getInfo()
      })
    },
    // 删除
    deleteBill(row) {
      var _that = this
      var data = {
        'id': row.id
      }
      voidSurveyBill(data).then(response => {
        console.log('customerPage', response)
        var data = response.data
        _that.billListData = data
        _that.billListLoading = false
      }).catch(err => {
        _that.$message.error(err)
      })
    }
  }
}
</script>

<style scoped>

.textRed {
  color: red;
}

.text-blue {
  color: dodgerblue;
}
</style>
