<!-- 我的订单 -->
<template>
  <div ref="backHeight" class="right">
    <div class="showTitle">
      <el-icon>
        <document />
      </el-icon>
      <h2>我的订单</h2>
    </div>
    <div id="topNav">
      <h2 @click="orderChoose($event, '全部')">全部</h2>
      <h2 @click="orderChoose($event, '未支付')">未支付</h2>
      <h2 @click="orderChoose($event, '服务中')">服务中</h2>
      <h2 @click="orderChoose($event, '已完成')">已完成</h2>
      <h2 @click="orderChoose($event, '已取消')">已取消</h2>
    </div>
    <hr id="hr1" />
    <div id="choseMsg" class="statusMsg" v-for="item in this.list">
      <div id="topContent">
        <label>订单号:</label>
        <label class="orderId">{{ item.id }}</label>
        <label>创建时间:</label>
        <label class="orderId">{{ item.createTime }}</label>
        <img id="statusImg" src="../../img/status.png" />
        <label id="statusSpan">{{ item.status }}</label>
      </div>
      <hr id="hr" />
      <span id="employer">雇主:</span>
      <input disabled v-model="item.userName" class="theIn" type="text" />

      <span class="rightSpan">分类范围:</span>
      <input disabled v-model="item.categoryName" class="theIn" type="text" />
      <br />
      <span>联系方式:</span>
      <input disabled v-model="item.userPhone" class="theIn" type="text" />
      <span class="rightSpan">服务时间:</span>
      <input disabled v-model="item.serverTime" class="theIn" type="text" />
      <br />
      <span>雇主地址:</span>
      <input disabled v-model="item.area" class="theIn" type="text" />

      <span id="totalPrice" class="rightSpan">总价:</span>
      <input disabled v-model="item.totalPrice" class="theIn" type="text" />
      <br />
      <span id="note">备注：</span>
      <textarea disabled v-model="item.treatment"></textarea>
    </div>
    <nav v-if="this.getTotal * 1" style="text-align: -webkit-center">
      <el-pagination :page-size="this.getCurrentPageSize" style="width: max-content" :current-page="this.getCurrentPage"
        @current-change="handleCurrentChange" layout="prev, pager, next" :total="this.getTotal * 1" />
    </nav>
    <div v-if="!(this.getTotal * 1)">
      <img id="noImg" src="./img/noContent.png" />
      <h4>没有订单信息....</h4>
    </div>
  </div>
</template>

<script>
import { getServerOrder } from "@/api";
import {
  Menu as IconMenu,
  ArrowDownBold,
  ArrowUpBold,
} from "@element-plus/icons-vue";
import { mapGetters, mapMutations } from "vuex";

export default {
  name: "MyOrder",
  computed: {
    ...mapGetters("OrderStore", ['getCurrentPageSize', 'getCurrentPage', 'getStatus', 'getTotal'])
  },
  created() {
    this.init()
  },
  data() {
    return {
      list: [],
    };
  },
  methods: {
    ...mapMutations("OrderStore", ['changePageNum', 'setTotal', 'setStatus']),
    init() {
      let parmas = {
        orderStatus: this.getStatus,
        pageNum: this.getCurrentPage,
        pageSize: this.getCurrentPageSize,
      };
      getServerOrder(parmas).then((response) => {
        if (response.data.code == 200) {
          this.list = response.data.data.rows;
          console.log(response.data.data)
          this.list.forEach(e => {
            if (e.status === '服务中') {
              e.status = '工作中'
            }
          })
          this.setTotal(parseInt(response.data.data.total))
        }
      });
    },
    //筛选订单
    orderChoose(e, s) {
      for (
        let index = 0;
        index < e.currentTarget.parentNode.children.length;
        index++
      ) {
        e.currentTarget.parentNode.children[index].style.color = "black";
      }
      e.currentTarget.style.color = "#409eff";
      this.setStatus(s)
      this.init()
    },
    //选择页数
    handleCurrentChange(val) {
      this.changePageNum(val)
      this.init()
    },
  },
  components: {
    IconMenu,
    ArrowUpBold,
    ArrowDownBold,
  },
};
</script>
<style scoped>
.right {
  width: 59rem;
  background-color: rgb(255, 255, 255);
  top: 1rem;
  left: 24rem;
  border: 1px solid gray;
  border-radius: 10px;
  padding-bottom: 2rem;
  margin-left: 25rem;
}

.right:after {
  content: "";
  display: block;
  height: 0;
  clear: both;
  visibility: hidden;
}

.showTitle {
  position: relative;
  width: 100%;
  height: 3rem;
  border-bottom: 1px solid rgb(165, 162, 162);
  box-sizing: border-box;
  text-align: start;
  padding-left: 2rem;
}

.showTitle h2 {
  display: inline-block;
  font-size: 1.3rem;
  text-align: left;
}

#topNav {
  text-align: left;
}

#hr1 {
  border-width: 0.15rem;
}

#topNav h2 {
  display: inline-block;
  font-size: 1.2rem;
  font-weight: 400;
  padding: 0;
  margin: 0;
  margin-left: 2rem;
  margin-top: 1rem;
  margin-bottom: 1rem;
  cursor: pointer;
}

#topNav :first-child {
  color: #409eff;
}

#serveArea {
  margin-bottom: 2rem;
}

#tipsMsg {
  transition: all 0.4s ease;
  display: none;
  height: auto;
  padding-left: 2rem;
  padding-bottom: 1rem;
  padding-top: 1.5rem;
}

#arrow {
  padding-left: 46rem !important;
}

/* 填写信息样式
 */
#choseMsg {
  width: 90%;
  border: 1px solid rgb(112, 110, 110);
  border-radius: 2rem;
  text-align: start;
  margin: 0 auto;
  margin-top: 2rem;
  padding-left: 2.5rem;
  margin-bottom: 1rem;
}

#choseMsg span {
  display: inline-block;
  font-size: 1.2rem;
  font-weight: 400;
  padding-right: 1rem;
  margin-top: 0.8rem;
}

#choseMsg select {
  width: 7rem;
  height: 1.7em;
  font-size: 1rem;
  margin-top: 1rem;
  margin-right: 3rem;
}

#choseMsg .theIn {
  width: 17rem;
  height: 1.6rem;
  border: none;
  font-size: 1.1rem;
  padding-left: 0.5rem;
}

#choseMsg input {
  height: 1rem;
  margin-top: 1rem;
}

#emType {
  margin-left: 5.5rem;
}

#contact {
  margin-left: 2rem;
}

#residence {
  margin-bottom: 1rem;
}

#salaryIn {
  width: 3rem;
  margin-left: -1rem;
  margin-right: 0.5rem;
}

#salary {
  margin-left: 4.4rem;
}

/*
我的状态 */
#myStatus {
  padding: 0;
  margin: 0;
  text-align: start;
  margin-top: 2rem;
}

#myStatus #statusTitle {
  margin-left: 3rem;
  font-size: 1.2rem;
  font-weight: 700;
}

#statusRight {
  display: inline-block;
  height: 3rem;
  width: auto;
  overflow: hidden;
  background-color: aqua;
  margin: 0 auto;
  margin-bottom: 0;
  margin-left: 9rem;
}

#statusRight img {}

#msgStatus {
  margin-left: 1rem;
  font-weight: 600;
}

#private {
  margin-left: 42rem;
  font-weight: 500;
  display: inline-block;
  padding-right: 1rem;
  margin-bottom: 2rem;
}

input[type="button"] {
  background-color: #409eff;
  width: 6rem;
  height: 2rem;
  border-radius: 1rem;
  position: absolute;
  right: 2rem;
  border: none;
  top: 0.5rem;
  color: white;
  text-align: center;
  letter-spacing: 0.3rem;
  cursor: pointer;
}

::v-deep .el-cascader .el-input {
  display: flex;
  cursor: pointer;
  border: 1px solid black;
}

::v-deep .el-input__wrapper {
  display: inline-flex;
  flex-grow: 1;
  align-items: center;
  justify-content: center;
  padding: 1px 11px;
  background-color: var(--el-input-bg-color, var(--el-fill-color-blank));
  background-image: none;
  border-radius: 0;
  transition: var(--el-transition-box-shadow);
  box-shadow: 0 0 0 1px var(--el-input-border-color, var(--el-border-color)) inset;
}

#areaStyle {
  width: 15rem;
  margin-left: 0.1rem;
  height: 1.3rem !important;
  vertical-align: inherit;
}

::v-deep .el-input__wrapper {
  display: inline-flex;
  flex-grow: 1;
  align-items: center;
  justify-content: center;
  padding: 1px 11px;
  background-image: none;
  border-radius: var(--el-input-border-radius, var(--el-border-radius-base));
  transition: var(--el-transition-box-shadow);
}

#topContent {
  margin: 0;
  padding: 0;
  text-align: left;
}

#topContent label {
  font-size: 1.1rem;
  margin-top: 1rem;
}

#hr {
  position: absolute;
  left: 29rem;
  width: 55rem;
}

/* 备注 */
textarea {
  resize: none;
  width: 83%;
  height: 4rem;
  border: none;
  /* outline: none; */
  color: rgb(63, 62, 62);
  font-size: 1.1rem;
  font-weight: bold;
  margin-top: -1rem;
  /* border: none; */
  margin-left: 6.3rem;
  margin-bottom: 1rem;
  padding-left: 0.5rem;
}

/* 状态图片 */
#statusImg {
  margin: 0;
  padding: 0;
  width: 3%;
  height: auto;
}

/* 订单头部 */
.orderId {
  width: 18rem;
  text-align: left;
  padding: 0.2rem;
  display: inline-block;
}

/* 雇主 */
#employer {
  margin-right: 2.2rem;
}

.rightSpan {
  margin-left: 3.5rem;
  text-align: start;
}

/*
总价 */
#totalPrice {
  margin-right: 2.5rem;
}

/* 备注 */
#note {
  position: relative;
  top: 0.2rem;
  left: 0.2rem;
}

#statusSpan {
  vertical-align: text-bottom;
  margin-left: 0.3rem;
}

/* 缺省页样式 */
#noImg {
  width: 20rem;
}

/* 最外层 */
#backColor {
  padding-bottom: -10rem !important;
}
</style>
