<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="下单医院" prop="hospitalId">
        <el-select v-model="queryParams.hospitalId" filterable placeholder="请选择下单医院" size="small" clearable style="width: 100%">
          <el-option v-for="(v,i) in shopList" :key="i" :label="v.name" :value="v.id" />
        </el-select>
      </el-form-item>
      <el-form-item label="订单号" prop="orderNo">
        <el-input v-model="queryParams.orderNo" placeholder="请输入订单号" maxlength="30" clearable size="small" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="下单手机号" prop="userMobile" label-width="90px">
        <el-input v-model="queryParams.userMobile" placeholder="请输入下单手机号" maxlength="11" clearable size="small" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="服务名称" prop="serviceName">
        <el-input v-model="queryParams.serviceName" placeholder="请输入服务名称" maxlength="30" clearable size="small" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="下单时间" prop="">
        <el-date-picker v-model="daterangeCreateTime" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="list">
      <el-table-column type="index" width="55" label="序号" align="center">
        <template slot-scope="scope">
          <div>
            {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
          </div>
        </template>
      </el-table-column>
      <el-table-column label="订单编号" align="center" prop="orderNo" />
      <el-table-column label="服务名称" align="center" prop="serviceName" />
      <el-table-column label="下单手机号" align="center" prop="userMobile" />
      <el-table-column label="下单医院" align="center" prop="hospitalName" />
      <el-table-column label="护工姓名" align="center" prop="orderWorkerChangeRecord.workerName" />
      <el-table-column label="护工手机号" align="center" prop="orderWorkerChangeRecord.workerPhoneNumber" />
      <el-table-column label="服务态度" align="center" prop="orderReviews.serviceAttitude" />
      <el-table-column label="着装仪态" align="center" prop="orderReviews.dressAppearance" />
      <el-table-column label="沟通能力" align="center" prop="orderReviews.communicationAbility" />
      <el-table-column label="文字评价" align="center" prop="orderReviews.content" show-overflow-tooltip />
      <el-table-column label="评价时间" align="center" prop="orderReviews.createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.orderReviews.createTime, '{y}-{m}-{d} {h}:{i}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="goDetails(scope.row)">查看订单</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 { orderReviewsPage } from '@/api/hospitalOrder.js'
import { hospitalSimpleList } from "@/api/hospital.js"
import { getToken } from "@/utils/auth";
export default {
  // dicts: ['ad_location', 'internal_page'],
  data () {
    return {
      //按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 测试单表表格数据
      list: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 创建时间时间范围
      daterangeCreateTime: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
      shopList: [],
    };
  },
  created () {
    this.getList();
    this.getShopList();
  },
  methods: {
    getShopList () {
      hospitalSimpleList().then(res => {
        this.shopList = res.data
      })
    },
    getList () {
      this.loading = true;
      this.queryParams["startTime"] = undefined;
      this.queryParams["endTime"] = undefined;
      if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
        this.queryParams["startTime"] = this.daterangeCreateTime[0];
        this.queryParams["endTime"] = this.daterangeCreateTime[1];
      }
      orderReviewsPage(this.queryParams).then(response => {
        this.list = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    goDetails (row) {
      this.$router.push({
        path: '/order/orderList/details',
        query: { id: row.id }
      })
    },
    //  导出
    handleExport () {
      this.download('/order/order/export', {
        ...this.queryParams
      }, `评价列表_${new Date().getTime()}.xlsx`)
    },
    /** 搜索按钮操作 */
    handleQuery () {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery () {
      this.daterangeCreateTime = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>
<style lang="scss">
.el-drawer__body {
  padding: 0 20px !important;
}
</style>
<style lang="scss" scoped>
.flex {
  display: flex;
}
.demo-drawer__footer {
  margin-left: 120px;
}
::v-deep .el-input.is-disabled .el-input__inner {
  background-color: #fff;
  color: rgb(96, 98, 102);
}
</style>
