<template>
  <div class="content-box">
    <div class="left">
      <!-- <el-icon :size="23" class="camera"><VideoCameraFilled /></el-icon> -->
      <span class="cameratxt">订单评价</span>
    </div>
    <div class="scroll">
      <div class="middle">
        <div class="filter">
          <div class="condition">
            <span>关键字 : </span>
            <el-input
              :clearable="true"
              @clear="searchBtn"
              v-model="searchInput.keyWord"
              class="w-50 m-2"
              placeholder="请输入关键字"
              style="width: 180px"
            />
          </div>
          <div class="condition">
            <span>退房日期 : </span>
            <el-date-picker
              v-model="searchInput.createTime"
              type="daterange"
              range-separator="-"
              start-placeholder="起始时间"
              end-placeholder="结束时间"
              format="YYYY-MM-DD"
              value-format="YYYY-MM-DD"
              :prefix-icon="Calendar"
              placeholder="请选择退房日期"
            />
          </div>
          <div class="condition">
            <span>评价日期 : </span>
            <el-date-picker
              v-model="searchInput.evaluate"
              type="daterange"
              range-separator="-"
              start-placeholder="起始时间"
              end-placeholder="结束时间"
              format="YYYY-MM-DD"
              value-format="YYYY-MM-DD"
              :prefix-icon="Calendar"
              placeholder="请选择评价日期"
            />
          </div>
          <div class="condition">
            <span>评分 : </span>
            <el-select
              :clearable="true"
              v-model="searchInput.score"
              class="m-2"
              placeholder="请选择评分"
              @clear="searchBtn"
            >
              <el-option label="1星" :value="1" />
              <!-- <el-option label="1星半" :value="1.5" /> -->
              <el-option label="2星" :value="2" />
              <!-- <el-option label="2星半" :value="2.5" /> -->
              <el-option label="3星" :value="3" />
              <!-- <el-option label="3星半" :value="3.5" /> -->
              <el-option label="4星" :value="4" />
              <!-- <el-option label="4星半" :value="4.5" /> -->
              <el-option label="5星" :value="5" />
            </el-select>
          </div>
          <div class="condition">
            <span>状态 : </span>
            <el-select
              :clearable="true"
              v-model="searchInput.status"
              class="m-2"
              placeholder="请选择状态"
              @clear="searchBtn"
            >
              <el-option label="待回复" :value="1" />
              <el-option label="已回复" :value="2" />
            </el-select>
          </div>
          <el-button
            style="margin-left: 20px"
            color="rgba(9, 101, 98, 1)"
            type="primary"
            class="search"
            @click="searchBtn"
            ><el-icon>
              <Search />
            </el-icon>
            <span>查询</span></el-button
          >
          <!-- <el-button
            style="margin-left: 20px"
            color="rgba(9, 101, 98, 1)"
            type="primary"
            class="search"
            @click="importExcel"
            ><span>导出订单</span></el-button
          > -->
        </div>
      </div>
      <div class="footer" v-loading="loading">
        <el-table
          :row-class-name="tableRowClassName"
          :data="tableData.list"
          @selection-change="handleSelectionChange"
          style="width: 100%"
          :header-cell-style="{
            background: 'rgba(240, 243, 247, 1)',
            height: '50px',
            border: 0,
          }"
        >
          <!-- <el-table-column align="center" type="selection" width="80" /> -->
          <!-- <el-table-column
                width="150"
                align="center "
                type="index"
                label="序号"
              /> -->
          <el-table-column align="center" prop="bookingId" label="关联订单">
            <template #default="{ row }">
              <div class="orderNum" @click="orderInfo(row)">
                {{ row.order_num }}
              </div>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="checkOutTime" label="退房日期">
          </el-table-column>
          <el-table-column align="center" prop="createName" label="评价人" />
          <el-table-column align="center" prop="createDate" label="评价日期" />
          <el-table-column align="center" prop="score" label="评分" />

          <el-table-column align="center" prop="commentStatus" label="状态">
            <template #default="{ row }">
              <div>
                {{ row.commentStatus == 1 ? "待回复" : "已回复" }}
              </div>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            fixed="right"
            label="操作"
            width="150"
          >
            <template #default="scope">
              <div class="look looks" @click="chat(scope.row)">回复</div>
            </template>
          </el-table-column>
        </el-table>
        <!-- 添加耗材弹窗 -->
        <!-- <el-dialog
            class="addStaff"
            v-model="addDialogVisible"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
            :title="dialongTitle"
            align-center
            width="700"
            :before-close="handleVideoClose"
          >
            <el-form
              ref="ruleFormRef"
              :model="ruleForm"
              :rules="rules"
              label-width="120px"
              class="demo-ruleForm"
              size="default"
              label-position="left"
              status-icon
            >
              <el-form-item label="姓名 :" prop="userName">
                <el-input
                  v-model="ruleForm.userName"
                  placeholder="请输入姓名"
                  clearable
                />
              </el-form-item>
              <el-form-item label="维修班 :" prop="teamId">
                <el-select
                  v-model="ruleForm.teamId"
                  class="m-2"
                  placeholder="请选择维修班"
                >
                  <el-option label="校方人员" :value="0" />
                  <el-option label="第三方人员" :value="1" />
                </el-select>
              </el-form-item>
              <el-form-item label="微校卡号 :" prop="cardNumber">
                <el-input
                  v-model="ruleForm.cardNumber"
                  placeholder="请输入微校卡号"
                  clearable
                />
              </el-form-item>
              <el-form-item label="身份 :" prop="userzzId">
                <el-select
                  v-model="ruleForm.userzzId"
                  class="m-2"
                  placeholder="请选择身份"
                >
                  <el-option
                    v-for="item in userzzIdsList"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="手机号码 :" prop="userPhone">
                <el-input
                  v-model="ruleForm.userPhone"
                  placeholder="请输入手机号码"
                  clearable
                />
              </el-form-item>
              <el-form-item label="校区 :" prop="schoolId">
                <el-select
                  v-model="ruleForm.schoolId"
                  class="m-2"
                  placeholder="请选择校区"
                  @change="changeSchool"
                >
                  <el-option label="黄家湖校区" :value="1" />
                  <el-option label="墨轩湖校区" :value="2" />
                </el-select>
              </el-form-item>
              <el-form-item label="工种 :" prop="workType">
                <el-select
                  v-model="ruleForm.workType"
                  class="m-2"
                  placeholder="请选择工种"
                >
                  <el-option
                    v-for="item in workTypeList"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
              <el-form-item
                label="关联报修类型 :"
                prop="articleIds"
                class="checkbox"
              >
                <el-tree
                  :data="articleIdsList"
                  :props="{ label: 'name', children: 'children', value: 'id' }"
                  node-key="id"
                  show-checkbox
                  ref="articleIdsRef"
                  @check-change="handleArticleIds"
                />
              </el-form-item>
              <el-form-item label="关联楼栋 :" prop="buildIds">
                <el-tree
                  :data="treeValue.list"
                  :props="{ label: 'name', children: 'children', value: 'id' }"
                  node-key="id"
                  show-checkbox
                  ref="buildIdsRef"
                  @check-change="handleCheckChange"
                />
              </el-form-item>
              <el-form-item label="接单考核时间 :" prop="acceptanceTime">
                <div class="kaohe">
                  <el-input
                    v-model="ruleForm.acceptanceTime"
                    :clearable="false"
                    placeholder="考核时间"
                    style="width: 150px"
                  >
                    <template #suffix>
                      <img
                        src="@/assets/timer.png"
                        alt=""
                        style="width: 15px; height: 15px"
                      />
                    </template>
                  </el-input>
                  <span style="margin-left: 5px">分钟</span>
                </div>
              </el-form-item>
              <el-form-item
                style="
                  padding-bottom: 40px;
                  border-bottom: 1px solid rgba(230, 230, 230, 1);
                "
                label="维修考核时间 :"
                prop="maintenanceTime"
              >
                <div class="kaohe">
                  <el-input
                    v-model="ruleForm.maintenanceTime"
                    :clearable="false"
                    placeholder="考核时间"
                    style="width: 150px"
                  >
                    <template #suffix>
                      <img
                        src="@/assets/timer.png"
                        alt=""
                        style="width: 15px; height: 15px"
                      />
                    </template>
                  </el-input>
                  <span style="margin-left: 5px">分钟</span>
                </div>
              </el-form-item>
  
              <el-form-item class="options">
                <el-button
                  color="rgba(111, 182, 184, 1)"
                  class="queding"
                  type="primary"
                  @click="submitAdd(ruleFormRef)"
                >
                  确定
                </el-button>
                <el-button @click="cancelAdd(ruleFormRef)">取消</el-button>
              </el-form-item>
            </el-form>
          </el-dialog> -->

        <!-- 订单详情 -->
        <el-dialog
          class="addStaff"
          v-model="addDialogVisible"
          :close-on-click-modal="false"
          :close-on-press-escape="false"
          title="订单详情"
          align-center
          width="600"
          :before-close="cancelInfo"
        >
          <div class="order_info">
            <h2>
              订单状态 :
              <span
                v-if="ruleForm.orderStatus == 1"
                style="color: rgba(9, 101, 98, 1)"
                >待支付</span
              >
              <span
                v-if="ruleForm.orderStatus == 2"
                style="color: rgba(9, 101, 98, 1)"
                >已支付</span
              >
              <span
                v-if="ruleForm.orderStatus == 3"
                style="color: rgba(9, 101, 98, 1)"
                >待入住</span
              >
              <span
                v-if="ruleForm.orderStatus == 4"
                style="color: rgba(9, 101, 98, 1)"
                >已入住</span
              >
              <span
                v-if="ruleForm.orderStatus == 5"
                style="color: rgba(9, 101, 98, 1)"
                >已消费</span
              >
              <span
                v-if="ruleForm.orderStatus == 6"
                style="color: rgba(9, 101, 98, 1)"
                >支付超时</span
              >
              <span
                v-if="ruleForm.orderStatus == 7"
                style="color: rgba(9, 101, 98, 1)"
                >已取消</span
              >
              <span
                v-if="ruleForm.orderStatus == 8"
                style="color: rgba(9, 101, 98, 1)"
                >已退单</span
              >
              <span
                v-if="ruleForm.orderStatus == 9"
                style="color: rgba(9, 101, 98, 1)"
                >已退款</span
              >
              <span
                v-if="ruleForm.orderStatus == 10"
                style="color: rgba(9, 101, 98, 1)"
                >退款中</span
              >
            </h2>
            <div class="workNum">
              <span class="titles">订单号:</span
              ><span>{{ ruleForm.orderNum }}</span>
            </div>
            <div class="workNum">
              <span class="titles">订房时间</span>
              <span
                >{{ ruleForm.orderStartTime }} &nbsp;—&nbsp;
                {{ ruleForm.orderEndTime }}&nbsp;&nbsp; 共{{
                  ruleForm.orderLiveTime
                }}</span
              >
            </div>
            <div class="workNum">
              <span class="titles">大床型</span>
              <span>{{ ruleForm.hName }}</span>
            </div>
            <div class="workNum">
              <span class="titles">住客姓名 </span
              ><span>{{ ruleForm.userName }}</span>
            </div>
            <div class="workNum">
              <span class="titles">联系电话 </span
              ><span>{{ ruleForm.userPhone }}</span>
            </div>
            <!-- <div class="workNum">
              <span class="titles">预计到店 </span
              ><span>7月26日 14:00之前</span>
            </div> -->
            <div class="workNum">
              <span class="titles">订单金额 </span
              ><span>￥ {{ ruleForm.payAccount }}</span>
            </div>
            <div class="workNum">
              <span class="titles">支付时间 </span
              ><span>{{ ruleForm.payTime }}</span>
            </div>
          </div>
        </el-dialog>
        <!-- 回复内容界面 -->
        <el-dialog
          class="chat"
          v-model="chatVisible"
          :close-on-click-modal="false"
          :close-on-press-escape="false"
          title="回复"
          align-center
          width="900"
          :before-close="cancelChat"
        >
          <div class="order_info">
            <h3>关联订单</h3>
            <div class="workNum">
              <span class="titles">订单号:</span
              ><span>{{ ruleForm.orderNum }}</span>
            </div>

            <div class="workNum">
              <span class="titles">订房时间:</span
              ><span>{{ ruleForm.orderLiveTime }}</span>
            </div>
            <div class="workNum">
              <span class="titles">房型:</span><span>{{ ruleForm.hName }}</span>
            </div>
            <div class="workNum">
              <span class="titles">住客姓名:</span
              ><span>{{ ruleForm.userName }}</span>
            </div>
            <div class="workNum">
              <span class="titles">联系电话:</span
              ><span>{{ ruleForm.userPhone }}</span>
            </div>

            <div class="workNum">
              <span class="titles">订单金额:</span
              ><span>{{ ruleForm.payAccount }}</span>
            </div>
            <h3>评价</h3>
            <div class="chatContent">
              <div class="info">
                <img :src="ruleForm.headPhoto" alt="" />
                <div class="title">
                  <div class="name1">
                    {{ ruleForm.bookingCommentList.createName }}
                  </div>
                  <div class="name2">
                    {{ ruleForm.bookingCommentList.createDate }}
                  </div>
                </div>
                <span class="reply" @click="reply(1)">回复</span>
              </div>
              <div class="star">
                <el-rate
                  :model-value="ruleForm.bookingCommentList.score"
                  allow-half
                  color="rgba(234, 149, 24, 1)"
                  size="large"
                  disabled
                  disabled-void-color="rgba(179, 179, 179, 1)"
                  show-score
                  score-template="非常棒"
                />
              </div>
              <div class="imglist">
                <img
                  v-for="i in ruleForm.fileInfos"
                  :key="i.id"
                  :src="i.url"
                  alt=""
                />
              </div>
              <div class="replyCont">
                {{ ruleForm.bookingCommentList.content }}
              </div>
              <!-- <div class="replyImg">
                <img src="@/assets/login.png" alt="" />
                <img src="@/assets/login.png" alt="" />
                <img src="@/assets/login.png" alt="" />
                <img src="@/assets/login.png" alt="" />
              </div> -->
              <el-collapse v-model="activeNames" @change="handleChange">
                <el-collapse-item name="1">
                  <template #title>
                    <div class="comment">
                      <img src="@/assets/comment.png" alt="" />
                      <span>评论（{{ ruleForm.lowCommentLists.length }}）</span>
                    </div>
                  </template>
                  <div
                    class="chatContent"
                    v-for="(i, index) in ruleForm.lowCommentLists"
                    :key="i.id"
                  >
                    <!-- 商家头像 -->
                    <div>
                      <div class="info client">
                        <img v-if="i.headPhoto" :src="i.headPhoto" alt="" />
                        <img v-else src="@/assets/photo.png" alt="" />
                        <div class="title">
                          <div class="name1" v-if="i.createName">
                            {{ i.createName }}
                          </div>
                          <div class="name1" v-else>商家</div>
                          <div class="name2">{{ i.createDate }}</div>
                        </div>
                        <span
                          class="reply"
                          @click="reply(i)"
                          v-if="i.status == 1"
                          >回复</span
                        >
                      </div>

                      <div class="replyCont clientCont">
                        <el-collapse-item title="Consistency" :name="index">
                          <template #title>
                            <span>{{ i.content }}</span>
                          </template>
                          <div v-for="item in i.lowCommentList" :key="item.id">
                            <div class="info merchant">
                              <img
                                v-if="item.headPhoto"
                                :src="item.headPhoto"
                                alt=""
                              />
                              <img v-else src="@/assets/photo.png" alt="" />
                              <div class="title">
                                <div class="name1" v-if="item.createName">
                                  {{ item.createName }}
                                </div>
                                <div class="name1" v-else>商家</div>
                                <div class="name2">{{ item.createDate }}</div>
                              </div>
                              <span class="reply" @click="reply(item)"
                                >回复</span
                              >
                            </div>
                            <div class="replyCont merchantCont">
                              <span v-if="item.createName"
                                >用户 回复 商家 :</span
                              >
                              <span v-else
                                >商家 回复 {{ item.commentName }} :</span
                              >
                              {{ item.content }}
                            </div>
                          </div>
                        </el-collapse-item>
                      </div>
                    </div>
                    <!-- 客户头像 -->
                    <!-- <el-collapse-item title="Consistency" :name="index">
                      <template #title>
                        <span>加载更多</span>
                      </template>
                      <div v-for="item in i.lowCommentList" :key="item.id">
                        <div class="info merchant">
                          <img v-if="item.headPhoto" :src="item.headPhoto" alt="" />
                          <img v-else src="@/assets/photo.png" alt="" />
                          <div class="title">
                            <div class="name1" v-if="item.createName">{{ item.createName }}</div>
                            <div class="name1" v-else>商家</div>
                            <div class="name2">{{ item.createDate }}</div>
                          </div>
                          <span class="reply" @click="reply(item)">回复</span>
                        </div>
                        <div class="replyCont merchantCont">
                          <span v-if="item.createName">用户回复商家 :</span>
                          <span v-else>商家 回复 {{ item.commentName }} :</span>
                          {{ item.content }}
                        </div>
                      </div>
                    </el-collapse-item> -->
                    <!-- <div v-for="item in i.lowCommentList" :key="item.id">
                      <div class="info merchant">
                        <img v-if="item.headPhoto" :src="item.headPhoto" alt="" />
                        <img v-else src="@/assets/photo.png" alt="" />
                        <div class="title">
                          <div class="name1" v-if="item.createName">{{ item.createName }}</div>
                          <div class="name1" v-else>商家</div>
                          <div class="name2">{{ item.createDate }}</div>
                        </div>
                        <span class="reply" @click="reply(item)">回复</span>
                      </div>
                      <div class="replyCont merchantCont">
                        <span v-if="item.createName">用户回复商家 :</span>
                        <span v-else>商家 回复 {{ item.commentName }} :</span>
                        {{ item.content }}
                      </div>
                    </div> -->
                  </div>
                </el-collapse-item>
              </el-collapse>
            </div>
          </div>
        </el-dialog>
        <!-- 回复弹窗 -->
        <el-dialog
          class="reply"
          v-model="replyVisible"
          :close-on-click-modal="false"
          :close-on-press-escape="false"
          title="回复"
          align-center
          width="500"
          :before-close="cancelReply"
        >
          <div class="reply">
            <div class="content">
              <el-input
                v-model="replycontent.content"
                :rows="6"
                type="textarea"
                show-word-limit
                placeholder="请输入你要回复的文字"
              />
            </div>
            <div class="options">
              <el-button
                color="rgba(111, 182, 184, 1)"
                class="queding"
                type="primary"
                @click="replycontentYes()"
              >
                回复
              </el-button>
              <el-button @click="cancelReply">取消</el-button>
            </div>
          </div>
        </el-dialog>
      </div>

      <!-- 分页组件 -->
      <div class="pageSize">
        <span></span>
        <el-pagination
          background
          :current-page="currentPage"
          :page-size="pageSize"
          layout="total, prev, pager, next, jumper, slot"
          :total="total"
          @update:current-page="handleCurrentChange"
        />
      </div>
    </div>
  </div>
</template>

<script setup>
import {
  ref,
  reactive,
  nextTick,
  watch,
  onBeforeMount,
  onUnmounted,
} from "vue";
import { useRouter } from "vue-router";
import { ElMessage, ElMessageBox } from "element-plus";
import { Calendar } from "@element-plus/icons-vue";
import vidiconsApi from "@/api/vidicons.js";
import { dayjs } from "element-plus";
import lodash, { reduce } from "lodash";
import axios from "axios";
import { useStore } from "vuex";
const store = useStore();
const api = ref("");
const router = useRouter();
const flag = ref(true);

const nowDay = ref(dayjs().format("YYYY-MM-DD HH:mm:ss"));
// 表格数据
const loading = ref(false);
const tableData = reactive({
  list: [
    // {
    //   userName: "124145523",
    //   teamName: "",
    //   schoolName: "李四",
    //   userPhone: "1455532141",
    //   userZzname: "三人房",
    //   buildName: 21,
    //   workTypeName: 2300,
    //   acceptanceTime: "2023-08-03 21:09:12",
    // },
    // {
    //   userName: "124145523",
    //   teamName: "",
    //   schoolName: "李四",
    //   userPhone: "1455532141",
    //   userZzname: "三人房",
    //   buildName: 21,
    //   workTypeName: 2300,
    //   acceptanceTime: "2023-08-03 21:09:12",
    // },
    // {
    //   userName: "124145523",
    //   teamName: "",
    //   schoolName: "李四",
    //   userPhone: "1455532141",
    //   userZzname: "三人房",
    //   buildName: 21,
    //   workTypeName: 2300,
    //   acceptanceTime: "2023-08-03 21:09:12",
    // },
  ],
});

const searchInput = reactive({
  keyWord: "",
  status: "",
  createTime: "", // 退房日期
  evaluate: "", // 评价日期
  score: "",
}); // 搜索按钮数据

const currentPage = ref(1); // 当前页
const pageSize = ref(10);
const total = ref(); // 当前总数

const selectData = reactive({ list: [] }); // 多选框选择的数据
const pendingOrderSum = ref(); // 待接单数
const orderSum = ref(); // 订单总数
const consumerOrderSum = ref(); // 已消费订单
const sumAccount = ref(); // 已消费订单总金额
const addDialogVisible = ref(false); // 控制添加员工弹窗

// 聊天内容
const chatVisible = ref(false);

// 回复
const replyVisible = ref(false); // 回复弹窗控制
const replycontent = reactive({
  content: "",
  commentId: "",
  commentParentId: "",
  commentName: "",
  id: "",
}); // 回复绑定数据

// 收起聊天框
const activeNames = ref(["1"]);
const handleChange = (val) => {
  console.log(val);
};

const ruleForm = reactive({
  orderNum: "", // 订单号
  orderLiveTime: "", // 订房时间
  fileInfos: [], // 评论图片
  hName: "", //房型
  orderStatus: "", // 订单状态
  payAccount: "", // 订单金额
  orderStartTime: "", //预计入住时间
  orderEndTime: "", //~预计离店时间
  hName: "", // 房间类型
  bookingCommentList: "", // 评价内容
  lowCommentLists: "", // 评价列表
  headPhoto: "", // 头像
  payTime: "", // 支付时间
  id: "", // 订单id
  // orderStatus: "", // 订单状态
  // userPhone: "", // 联系电话
  // houseTotalPrice: "", // 订单金额
  // orderLiveTime: "", // 订房时间
});
watch(
  () => searchInput.createTime,
  (newVal, oldVal) => {
    console.log("退房日期:", newVal);
    if (newVal == null) {
      searchBtn();
    }
  }
);
watch(
  () => searchInput.evaluate,
  (newVal, oldVal) => {
    console.log("评价日期:", newVal);
    if (newVal == null) {
      searchBtn();
    }
  }
);

// 查看员工列表
const getList = async () => {
  loading.value = true;
  let data = {
    page: currentPage.value, // 当前页
    rows: pageSize.value, // 一页数据条数
    managerId: sessionStorage.getItem("token"),
    keywords: searchInput.keyWord,
    status: searchInput.status,
  };
  if (searchInput.createTime) {
    data.checkoutStartTime = searchInput.createTime[0];
    data.checkoutEndTime = searchInput.createTime[1];
  }
  if (searchInput.evaluate) {
    data.commentStartTime = searchInput.evaluate[0];
    data.commentEndTime = searchInput.evaluate[1];
  }

  if (searchInput.score) {
    data.score = searchInput.score;
  }
  let res = await axios({
    method: "get",
    url: api.value + "/mhotel/CommentqueryPage.action",
    headers: {
      // token: sessionStorage.getItem("token"),
      // user_head: sessionStorage.getItem("userhead"),
    },
    params: data,
  });
  console.log(res, "订单评价列表");
  if (res.data.code == 200) {
    loading.value = false;
    tableData.list = res.data.data.pageList;
    total.value = res.data.data.total;
    // ElMessage({
    //   type: "success",
    //   showClose: true,
    //   message: res.data.message,
    //   center: true,
    // });
  } else {
    loading.value = false;
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};

// 搜索功能
const searchBtn = lodash.debounce(async () => {
  getList();
}, 300);

// 详情弹窗 （--------------------------------------）
const orderInfo = async (row) => {
  console.log(row);
  addDialogVisible.value = true;
  let data = {
    bookId: row.bookingId,
  };
  let res = await axios({
    method: "get",
    url: api.value + "/mhotel/CommentgetByBookId.action",
    headers: {
      // token: sessionStorage.getItem("token"),
      // user_head: sessionStorage.getItem("userhead"),
    },
    params: data,
  });
  if (res.data.code == 200) {
    ruleForm.orderNum = res.data.data.book.orderNum;
    ruleForm.orderLiveTime = res.data.data.book.orderLiveTime;
    ruleForm.hName = res.data.data.house.hName;
    ruleForm.userName = res.data.data.book.userName;
    ruleForm.userPhone = res.data.data.book.userPhone;
    ruleForm.payAccount = res.data.data.book.payAccount;
    ruleForm.payTime = res.data.data.book.payTime;
    ruleForm.orderStatus = res.data.data.book.orderStatus;
    ruleForm.orderStartTime = res.data.data.book.orderStartTime;
    ruleForm.orderEndTime = res.data.data.book.orderEndTime;
    ruleForm.hName = res.data.data.house.hName;
  }
  console.log(res, "详情");
};
// 取消详情
const cancelInfo = () => {
  addDialogVisible.value = false;
};

// 聊天内容弹窗（---------------------------）
const chat = async (row) => {
  chatVisible.value = true;
  if (row) {
    ruleForm.id = row.bookingId;
  }
  let datas = {
    id: ruleForm.id,
  };
  let res = await axios({
    method: "get",
    url: api.value + "/mhotel/CommentgetById.action",
    headers: {
      // token: sessionStorage.getItem("token"),
      // user_head: sessionStorage.getItem("userhead"),
    },
    params: datas,
  });
  if (res.data.code == 200) {
    ruleForm.orderNum = res.data.data.book.orderNum;
    ruleForm.orderLiveTime = res.data.data.book.orderLiveTime;
    ruleForm.hName = res.data.data.book.houseName;
    ruleForm.fileInfos = res.data.data.fileInfos;
    ruleForm.userPhone = res.data.data.book.userPhone;
    ruleForm.payAccount = res.data.data.book.payAccount;
    ruleForm.userName = res.data.data.book.userName;
    ruleForm.headPhoto = res.data.data.bookingCommentList[0].headPhoto;
    ruleForm.bookingCommentList = res.data.data.bookingCommentList[0];
    ruleForm.lowCommentLists =
      res.data.data.bookingCommentList[0].lowCommentList;
    // ruleForm.userName = res.data.data.bookingCommentList[0].userName;
    // ruleForm.id = res.data.data.bookingCommentList[0].id;
  } else {
    ruleForm.orderNum = "";
    ruleForm.orderLiveTime = "";
    ruleForm.hName = "";
    ruleForm.userPhone = "";
    ruleForm.headPhoto = "";
    ruleForm.payAccount = "";
    ruleForm.userName = "";
    ruleForm.bookingCommentList = "";
    ruleForm.lowCommentLists = "";
    ElMessage({
      type: "error",
      showClose: true,
      message: "获取内容失败",
      center: true,
    });
  }
  console.log(res, "聊天内容");
};
// 关闭聊天内容
const cancelChat = () => {
  chatVisible.value = false;
  ruleForm.orderNum = "";
  ruleForm.orderLiveTime = "";
  ruleForm.hName = "";
  ruleForm.userPhone = "";
  ruleForm.headPhoto = "";
  ruleForm.payAccount = "";
  ruleForm.userName = "";
  ruleForm.bookingCommentList = "";
  ruleForm.lowCommentLists = "";
};

// 回复弹窗  （回复-------------------------------）
const reply = async (row) => {
  replyVisible.value = true;
  console.log(row);
  // console.log(ruleForm.bookingCommentList);
  if (row == 1) {
    replycontent.commentId = ruleForm.bookingCommentList.id;
    replycontent.commentParentId = ruleForm.bookingCommentList.id;
    replycontent.content = replycontent.content;
    replycontent.commentName = ruleForm.bookingCommentList.createName;
  } else {
    replycontent.commentId = row.id;
    replycontent.commentParentId = row.commentParentId;
    replycontent.content = replycontent.content;
    if (row.createName) {
      replycontent.commentName = row.createName;
    } else {
      replycontent.commentName = row.createUsername;
    }
  }
};
// 关闭回复弹窗
const cancelReply = () => {
  replyVisible.value = false;
  replycontent.content = "";
};
// 确定回复
const replycontentYes = async () => {
  let data = {
    commentId: replycontent.commentId,
    commentParentId: replycontent.commentParentId,
    content: replycontent.content,
    commentName: replycontent.commentName,
  };
  console.log(data);
  let res = await axios({
    method: "post",
    url: api.value + "/mhotel/CommentinsterCommpent.action",
    headers: {
      // token: sessionStorage.getItem("token"),
      // user_head: sessionStorage.getItem("userhead"),
    },
    params: data,
  });
  console.log(res, "回复成功");
  if (res.data.code == 200) {
    chat();
    replyVisible.value = false;
    replycontent.content = "";
    ElMessage({
      type: "success",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};

// 多选框功能
const handleSelectionChange = (val) => {
  console.log(val);
  selectData.list = val;
};

// 表格斑马纹颜色修改
const tableRowClassName = ({ row, rowIndex }) => {
  if (rowIndex % 2 === 0) {
    return "even";
  } else if (rowIndex % 2 !== 0) {
    return "odd";
  }
  return "";
};
// 分页
const handleCurrentChange = (value) => {
  // console.log(value);
  currentPage.value = value;
  getList();
};

onBeforeMount(async () => {
  api.value = store.state.user.api;
  flag.value = sessionStorage.getItem("isLogin");

  if (sessionStorage.getItem("isLogin") != 1) {
    getList();
  }
});
onUnmounted(() => {
  // document.removeEventListener("keyup", Enters);
});
</script>

<style scoped lang="scss">
.content-box {
  min-width: 1000px;
  width: calc(100vw - 240px);
  height: calc(100vh - 105px);
  margin: 20px auto;
  background-color: #fff;
  color: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: 0px 3px 10px rgba(0, 97, 255, 0.2);

  .left {
    // width: calc(100wh - 40px);
    display: flex;
    align-items: center;
    height: 60px;
    margin: 0 30px;
    border-bottom: 1px solid #ccc;
    color: rgb(0, 0, 0);
    font-size: 18px;
    font-weight: 600;

    span {
      display: inline-block;
      height: 60px;
      line-height: 60px;
      margin-right: 20px;
      cursor: pointer;
    }

    .is_active {
      color: rgba(111, 182, 184, 1);
    }
  }
  .scroll {
    height: calc(100% - 61px);
    overflow: auto;
  }
  .top {
    width: 96%;
    height: 150px;
    margin: 20px auto;

    ul {
      padding: 0;
      margin: 0;
      height: 100%;
      list-style: none;
      display: flex;

      li {
        background-color: rgba(242, 242, 242, 1);
        border-radius: 10px;
        flex: 1;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;

        p {
          font-size: 40px;
          font-weight: 700;
          color: #000;
          margin: 0;
        }

        span {
          color: #000;
          font-size: 18px;
          font-weight: 400;
        }
      }

      li:not(:last-child) {
        margin-right: 36px;
      }
    }
  }

  .middle {
    width: 96%;
    margin: 0 auto;

    color: #000;

    // border-bottom: 1px solid rgb(231, 231, 231);
    .filter {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      margin: 10px 0 0 0;

      .search {
        color: #fff;
      }

      .condition {
        display: flex;
        align-items: center;
        margin: 10px 30px 10px 0;

        :deep(.el-input .el-input__inner) {
          font-size: 14px;
        }

        span {
          margin: 0 10px 0 0;
        }
      }
    }

    .gongneng {
      margin: 10px 0 20px 0;

      span {
        color: #fff;
      }
    }

    :deep(.cont) {
      width: 60%;
      margin: 20px auto;
    }

    :deep(.download) {
      display: flex;
      align-items: center;
      margin: 10px;
    }

    :deep(.download span) {
      font-size: 16px;
      margin-left: 20px;
    }

    :deep(.cont .el-button) {
      margin-left: 60px;
      margin-bottom: 30px;
    }

    :deep(.cont .accomplish) {
      width: 100%;
      display: flex;
      justify-content: center;
    }

    :deep(.cont .accomplish .el-button) {
      width: 50%;
      margin: 0;
    }
  }

  .footer {
    width: calc(100% - 40px);
    // height: 552px;
    margin: 10px auto 30px;

    .el-table--fit {
      // height: 100%;

      // :deep(.el-table__header-wrapper) {
      //   background-color: #000;
      //   font-size: 15px;

      //   tr {
      //     color: #000;
      //   }
      // }

      :deep(.el-table__row) {
        height: 50px;
        font-size: 15px;
        color: #000;

        .orderNum {
          color: rgba(111, 182, 184, 1);
          cursor: pointer;
        }
      }

      :deep(.el-table__row):nth-child(2n) {
        .el-table-fixed-column--right {
          background-color: rgba(240, 243, 247, 1);
        }
      }

      :deep(.el-table__row td) {
        padding: 0;
      }

      .el-button--primary {
        margin-left: 5px;
      }

      :deep(.el-table__body .even) {
        background-color: #fff;
      }

      :deep(.el-table__body .odd) {
        background-color: rgba(240, 243, 247, 1);
      }

      :deep(.edit) {
        display: flex;
        align-items: center;
        justify-content: center;
        color: rgba(111, 182, 184, 1);
      }

      :deep(.look) {
        padding: 0 10px;
        cursor: pointer;
        border: 1px solid transparent;
      }

      :deep(.looks) {
        color: red;
      }

      // :deep(.look):hover {
      //   border: 1px solid rgba(111, 182, 184, 1);
      // }
    }

    // 添加员工弹窗样式
    :deep(.addStaff) {
      height: 550px;
      overflow: hidden;
      border-radius: 11px;

      .el-dialog__header {
        border-radius: 11px 11px 0 0;
        background: rgba(237, 241, 245, 1);
        font-weight: 600;
        margin: 0;

        .el-dialog__headerbtn {
          outline: none;
        }
      }

      .el-dialog__body {
        overflow: auto;
        padding: 0px 20px 10px 20px;

        .order_info {
          margin: 20px 0;

          .title {
            display: flex;
            align-items: center;
            margin: 25px 0 10px 0;

            img {
              width: 20px;
              height: 20px;
              margin-right: 10px;
            }

            span {
              color: #000;
              font-size: 18px;
              font-weight: 800;
            }
          }

          h2 {
            color: #000;
          }

          // 排列模式样式
          .workNum {
            display: flex;
            align-items: center;
            margin-bottom: 20px;
            font-size: 16px;

            .titles {
              color: rgba(128, 128, 128, 1);
              margin-right: 12px;
              font-weight: 200;
              width: 80px;
            }

            span {
              color: #000;
              font-weight: 600;
            }
          }

          .workNums {
            padding: 10px 0 15px 0;
            border-bottom: 1px solid #ccc;
          }
        }
      }
    }

    // 聊天弹窗样式
    :deep(.chat) {
      //   height: 420px;
      border-radius: 11px;

      .el-dialog__header {
        border-radius: 11px 11px 0 0;
        background: rgba(237, 241, 245, 1);
        font-weight: 600;
        margin: 0;

        .el-dialog__headerbtn {
          outline: none;
        }
      }

      .el-dialog__body {
        padding: 0px 30px 10px 23px;
        height: 800px;
        overflow: auto;

        .order_info {
          margin: 20px 0 15px 0;

          h3 {
            color: #000;
          }

          // 排列模式样式
          .workNum {
            display: flex;
            align-items: center;
            margin-bottom: 12px;
            font-size: 16px;

            .titles {
              color: rgba(128, 128, 128, 1);
              margin-right: 12px;
              font-weight: 200;
              width: 80px;
            }

            span {
              color: #000;
              font-weight: 600;
            }

            ul {
              list-style: none;
              display: flex;
              flex-wrap: wrap;
              margin: 0;
              padding: 0;

              li {
                border: 1px solid rgba(166, 166, 166, 1);
                margin-right: 10px;
                padding: 1px 4px;
                border-radius: 6px;
              }

              li:nth-child(1) {
                background-color: rgba(9, 101, 98, 1);
                color: #fff;
              }
            }
          }

          .chatContent {
            // border: 1px solid red;
            // 头像和名字
            .info {
              display: flex;
              align-items: center;
              padding: 0 0 15px 0;
              border-bottom: 1px solid rgba(230, 230, 230, 1);

              img {
                width: 50px;
                height: 50px;
                object-fit: cover;
                border-radius: 50%;
                margin-right: 10px;
              }

              .title {
                flex: 1;

                .name1 {
                  color: #000;
                  font-size: 16px;
                }

                .name2 {
                  font-size: 10px;
                  color: rgba(166, 166, 166, 1);
                }
              }

              .reply {
                color: rgba(9, 101, 98, 1);
                cursor: pointer;
              }
            }

            .star {
              display: flex;
              align-items: center;

              .el-rate {
                .el-icon {
                  //   border: 1px solid red;
                  font-size: 22px;
                  margin: 0;
                }

                .el-rate__text {
                  margin-left: 5px;
                  font-size: 12px;
                  color: rgba(166, 166, 166, 1);
                  transform: translateY(1px);
                }
              }
            }

            .imglist {
              width: 100%;
              display: flex;
              flex-wrap: wrap;

              img {
                height: 200px;
                margin: 10px 10px;
              }
            }

            .replyCont {
              //   text-indent: 2em;
              letter-spacing: 1px;
              color: #000;
            }

            // 评价图片
            .replyImg {
              margin: 10px 0;

              img {
                width: 90px;
                height: 135px;
                margin-right: 20px;
              }
            }

            // 评论条数
            .comment {
              display: flex;
              align-items: center;

              img {
                width: 18.94px;
                height: 16.27px;
              }

              span {
                display: inline-block;
                flex: 1;
                margin-left: 15px;
              }

              .pickUp {
                color: rgba(9, 101, 98, 1);
              }
            }

            .el-collapse {
              border-top: 0;

              .el-collapse-item__header {
                // border-bottom: 1px solid rgba(230, 230, 230, 1);
              }

              .el-collapse-item__wrap {
                border: 0;

                .info {
                  margin-top: 15px;
                }

                .replyCont {
                  margin: 10px 0 0 60px;
                }

                // 商家评论
                .merchant {
                  // padding-left: 60px;
                }

                .merchantCont {
                  // padding-left: 60px;

                  span {
                    color: rgba(128, 128, 128, 1);
                  }
                }
              }
            }
          }
        }

        .options {
          display: flex;
          flex-direction: row-reverse;
          margin: 20px 0 25px 0;

          .queding {
            margin-left: 20px;
            color: #fff;
          }
        }
      }
    }

    // 回复弹窗样式
    :deep(.reply) {
      //   height: 420px;
      border-radius: 11px;

      .el-dialog__header {
        border-radius: 11px 11px 0 0;
        background: rgba(237, 241, 245, 1);
        font-weight: 600;
        margin: 0;

        .el-dialog__headerbtn {
          outline: none;
        }
      }

      .el-dialog__body {
        padding: 0px 30px 10px 20px;

        .content {
          margin: 25px 0;
        }

        .options {
          display: flex;
          flex-direction: row-reverse;
          margin: 20px 0 25px 0;

          .queding {
            margin-left: 20px;
            color: #fff;
          }
        }
      }
    }
  }

  .pageSize {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 30px;

    span {
      color: #000;
    }

    .el-pagination {
      // width: 1600px;
      :deep(.el-pagination__total) {
        color: #000;
      }

      :deep(.el-pagination__goto) {
        color: #000;
      }

      :deep(.el-pagination__classifier) {
        color: #000;
      }

      :deep(.el-input__wrapper) {
        border: 1px solid rgba(0, 0, 0, 1);
        border-radius: 5px;
        box-shadow: none;
      }

      :deep(.el-pager li) {
        margin: 0 5px;
        border: 1px solid rgba(0, 0, 0, 1);
        border-radius: 5px;
        background-color: transparent;
      }

      :deep(.el-pager li.is-active) {
        background-color: rgba(111, 182, 184, 1);
      }

      :deep(.btn-prev) {
        margin-right: 5px;
        border: 1px solid rgba(0, 0, 0, 1);
        border-radius: 5px;
        background-color: transparent;
      }

      :deep(.btn-next) {
        margin-left: 5px;
        border: 1px solid rgba(0, 0, 0, 1);
        border-radius: 5px;
        background-color: transparent;
      }
    }
  }
}

.el-input {
  width: 192px;
}

.firstLogin {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(100vh);
  background-color: rgba(0, 0, 0, 0.2);
  z-index: 1000000;
  display: flex;
  justify-content: center;
  align-items: center;

  .goInfo {
    width: 655px;
    height: 408px;
    background-color: #fff;
    border-radius: 9px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #000;

    h2 {
      margin: 0;
      font-size: 28px;
    }

    p {
      margin: 60px 0;
      padding: 0;
      font-size: 18px;
    }
  }
}
</style>
