<!--
 * @Descripttion:
 * @version:
 * @Author: kBank
 * @Date: 2022-10-24 10:45:39
-->
<template>
  <div class="page">
    <topBar
      v-if="topList.length > 0 && userInfo.userType != 9"
      :topList="topList"
      :moren="moren"
      :waitApprovalNum="waitApprovalNum"
      :receiveApprovalNum="receiveApprovalNum"
    ></topBar>
    <div class="main" v-if="userInfo.userType != 9">
      <div>
        <div class="form_all">
          <el-form ref="select" :model="select" label-width="auto">
            <el-row :gutter="10">
              <el-col :span="6">
                <el-form-item label="签呈编号">
                  <el-input
                    clearable
                    v-model="select.approvalCode"
                    :placeholder="'请输入'"
                  ></el-input>
                </el-form-item>
              </el-col>
              <!-- 一层 -->
              <el-col :span="6">
                <el-form-item :label="'业务类型'">
                  <el-select
                    clearable
                    filterable
                    v-model="select.approvalBusiness"
                  >
                    <el-option
                      v-for="item in ywsqList"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="业务类型内容">
                  <el-input
                    clearable
                    v-model="select.approvalBusinessVal"
                    :placeholder="'请输入'"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="情况说明">
                  <el-input
                    clearable
                    v-model="select.remark"
                    :placeholder="'请输入'"
                  ></el-input>
                </el-form-item>
              </el-col>

              <!-- <el-col :span="6">
              <el-form-item :label="'签呈状态'">
                <el-select clearable
                           v-model="select.approveStatus">
                  <el-option v-for="item in approveStatusList"
                             :key="item.value"
                             :label="item.label"
                             :value="item.value"></el-option>
                </el-select>
              </el-form-item>
            </el-col> -->
              <el-col :span="12">
                <el-form-item :label="'创建日期'">
                  <el-date-picker
                    v-model="select.creationTime"
                    value-format="yyyy-MM-dd"
                    type="daterange"
                    :range-separator="'至'"
                    :start-placeholder="'开始日期'"
                    :end-placeholder="'结束日期'"
                  >
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <!-- <el-col :span="8">
              <el-form-item :label="'终审日期'">
                <el-date-picker v-model="select.endTime"
                                value-format="yyyy-MM-dd"
                                type="daterange"
                                :range-separator="'至'"
                                :start-placeholder="'开始日期'"
                                :end-placeholder="'结束日期'">
                </el-date-picker>
              </el-form-item>
            </el-col> -->
              <el-col :span="4">
                <el-button type="primary" @click="getDataList">
                  {{ '搜索' }}</el-button
                >
                <el-button @click="reset"> {{ '重置' }}</el-button>
              </el-col>
            </el-row>
          </el-form>
        </div>
        <el-table
          :data="tableData"
          height="700px"
          v-loading="loading"
          :element-loading-text="'正在加载'"
          :header-cell-style="{ background: '#EEEEEE' }"
          :row-class-name="tableRowClassName"
        >
          <el-table-column
            align="center"
            prop="creation"
            :label="'发起人'"
          >
          </el-table-column>
          <el-table-column align="center" prop="approvalCode" label="签呈编号">
          </el-table-column>

          <el-table-column
            align="center"
            prop="approvalBusinessVal"
            :label="'业务类型'"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="parentClassifyName"
            :min-width="320"
            :label="'签呈进度'"
          >
            <template slot-scope="scope">
              <div class="bz_a">
                <div
                  class="bz_i"
                  v-for="(item, index) in scope.row.detailList"
                  :key="index"
                >
                  <div
                    :class="item.useTime == undefined ? 'qiu' : 'quan'"
                  ></div>
                  <div
                    :class="
                      scope.row.detailList[index + 1].useTime == undefined
                        ? 'gun1'
                        : 'gun'
                    "
                    v-if="index != scope.row.detailList.length - 1"
                  ></div>
                  <div class="time">{{ item.useTime }}</div>
                  <div class="zhi">
                    <div>{{ item.nickName }}</div>
                    <div>({{ item.deptName }})</div>
                  </div>
                </div>
              </div>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="approveStatusVal"
            width="100"
            :label="'审核状态'"
          >
            <template slot-scope="scope">
              <el-button
                v-show="scope.row.approvalFlag == 0"
                @click="toFixed(scope.row.approvalCode, 0)"
                type="text"
                size="small"
              >
                {{ '审核' }}
              </el-button>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="creationTime"
            width="100"
            :label="'创建日期'"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="time"
            :label="'操作'"
            width="100"
            fixed="right"
          >
            <template slot-scope="scope">
              <el-button
                @click="toFixed(scope.row.approvalCode, 0)"
                type="text"
                size="small"
              >
                {{ '查看签呈' }}
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="notice">
        <div class="not_top">
          <div>{{ '公告' }}</div>
          <div class="not_t" @click="openNotice">{{ '发布公告' }}</div>
        </div>
        <div class="not_btm">
          <div v-for="item in tableList" class="not_i" @click="goNotice(item)">
            <div>{{ item.title }}</div>
            <div class="hui">{{ item.creationTime }}</div>
          </div>
        </div>
      </div>
    </div>
    <el-dialog
      :title="'公告'"
      :visible.sync="isNotice"
      width="35%"
      center
      :before-close="handleClose"
    >
      <div class="title">
        {{ noticeObj.title }}
      </div>
      <div v-html="noticeObj.content" class="img-auto"></div>
      <!--      <span slot="footer"-->
      <!--            class="dialog-footer">-->
      <!--        <el-button type="primary"-->
      <!--                   @click="isNotice = false">{{'确认'}}</el-button>-->
      <!--      </span>-->
    </el-dialog>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import * as api from "@/api/manage.js";
import topBar from "@/components/topBar";
import * as not from "@/api/notice.js";

export default {
  name: "Dashboard",
  components: {
    topBar,
  },
  computed: {
    ...mapGetters(["name", "user"]),
  },
  data() {
    return {
      queryParams: {
        pageNum: 1,
        pageSize: 50,
      },
      select: {
        websiteType: 2,
        functionType: 1,
      },

      approveStatusList: [],
      total: 0,
      tableData: [],
      tableData1: [],
      tabActive: 0,
      loading: false,
      select: {},
      moren: "dashboard",
      topList: [
        {
          name: "代办",
          path: "dashboard",
        },
        {
          name: "已办",
          path: "hasIndex",
        },
        {
          name: "抄送查阅/操作",
          path: "receiveIndex",
        },
        // {
        //   name: '商品审核',
        //   path: 'goodsCheck',
        // },
        // {
        //   name: '产品审核',
        //   path: 'productCheck',
        // },
      ],
      ywsqList: [],
      checkList: [],
      tableList: [],
      userInfo: "",
      isNotice: false,
      waitApprovalNum: "",
      receiveApprovalNum: "",
      noticeObj: [
        {
          title: "",
          content: "",
        },
      ],
    };
  },
  mounted() {
    // 获取列表
    this.getDataList();
    this.getApprove();
    this.getSignType();
    this.getNoticePop();
    this.getApprovalStatus();
    this.userInfo = JSON.parse(localStorage.getItem("userInfo"));
  },
  methods: {
    reset() {
      this.select = {};
      this.getDataList();
    },
    handleClose() {
      this.isNotice = false;
    },
    getNoticePop() {
      // this.getUser
      let userInfo = JSON.parse(localStorage.getItem("userInfo"));
      api
        .noticeShow({
          roles: userInfo.roleIds,
        })
        .then((res) => {
          if (res.data.length > 0) {
            this.noticeObj = res.data[0];
            this.isNotice = true;
          }
        });
    },
    getApprovalStatus() {
      api.approvalStatus().then((res) => {
        this.approveStatusList = res.data;
      });
      api.waitApprovalNum().then((res) => {
        this.waitApprovalNum = res.data;
      });
      api.receiveApprovalNum().then((res) => {
        this.receiveApprovalNum = res.data;
      });
    },
    goNotice(item) {
      this.$router.push({
        path: "/announcement/noticeList/details",
        query: {
          pkId: item.pkId,
          type: 1,
          // functionType:this.select.functionType
        },
      });
    },
    openNotice() {
      this.$router.push({
        path: "/announcement/noticeList/details",
        query: {
          isAdmin: true,
        },
      });
    },
    getApprove() {
      api.approvalBusiness().then((res) => {
        this.ywsqList = res.data;
      });
    },
    getSignType() {
      api.approvalOperation().then((res) => {
        this.checkList = res.data;
      });
    },
    getDataList() {
      this.loading = true;
      api.waitApproval(this.select).then((res) => {
        this.tableData = res.data;
        this.loading = false;
      });
      not.indexNoticeAdminList(this.select).then((res) => {
        this.tableList = res.rows;
        this.tableList.forEach((item) => {
          if (item.title.length > 20) {
            item.title = item.title.substring(0, 20) + "...";
          }
          item.creationTime = item.creationTime.substring(0, 10);
        });
      });
    },
    toFixed(id, index) {
      this.$router.push({
        path: "manageDetails",
        query: {
          id: id,
          index: index,
        },
      });
    },
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 == 1) {
        return "warning-row";
      } else if (rowIndex % 2 == 0) {
        return "success-row";
      }
      return "";
    },
  },
};
</script>

<style lang="scss" scoped>
.title {
  color: #333;
  font-weight: bold;
  margin: 10px auto 10px 0;
  font-size: 16px;
  text-align: center;
}
::v-deep .el-dialog__header {
  text-align: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  padding-bottom: 20px;
}
::v-deep .el-dialog__title {
  font-size: 32px;
  color: #333;
  font-weight: bold;
}
::v-deep .el-dialog__headerbtn i {
  font-size: 24px;
  //visibility: hidden;
  color: #333;
}
.img-auto {
  text-align: center;
  height: 615px;
  overflow-y: auto;
  ::v-deep p {
    font-size: 14px;
  }
  ::v-deep img {
    max-width: 100%;
    height: auto;
  }
}
::v-deep .el-dialog {
  margin-top: 105px !important;
  height: 820px;
  margin-bottom: 0;
}
::v-deep .el-dialog__body {
  padding-bottom: 20px;
}
.page {
  padding: 20px;
  background: #f9f9f9;
  font-size: 14px;
}
.main {
  display: flex;
  padding: 0px;
  // flex-direction: column;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);
  .notice {
    width: 556px;
    height: 100%;
    margin: 0 0 0 20px;
    background: #ffffff;
    box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);
    border-radius: 8px 8px 8px 8px;
    .not_top {
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-bottom: 1px solid rgba(0, 0, 0, 0.1);
      font-size: 16px;
      font-family: PingFang SC-Semibold, PingFang SC;
      font-weight: 600;
      color: #333333;

      padding: 10px 10px 10px 10px;
      .not_t {
        font-size: 12px;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #1678ff;
        cursor: pointer;
      }
    }
    .not_btm {
      padding: 10px;
      font-size: 14px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #333333;
      .not_i {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 5px;
        cursor: pointer;
        .hui {
          font-size: 10px;
          font-family: PingFang SC-Regular, PingFang SC;
          font-weight: 400;
          color: #999999;
        }
      }
    }
  }
}
.form_all {
  padding: 0px 20px 0 0px;
  // margin-bottom: 20px;
  background: #fff;
  border-radius: 8px;
}
.topbox {
  align-items: center;
  padding: 0px 0 3px 0;
  display: flex;
  //   background: skyblue;
  .levelList_i {
    margin-left: 20px;
    position: relative;
    cursor: pointer;
    padding: 0 5px;
    width: 88px;
    height: 34px;
    border-radius: 17px;
    border: 1px solid #cccccc;
    font-size: 14px;
    font-family: MicrosoftYaHei;
    text-align: center;
    line-height: 34px;
  }
  .act {
    color: #ffffff;
    background: #08143f;
  }
  .act1 {
    border-bottom: 3px solid #1890ff !important;
  }
  .cha {
    font-size: 16px;
    color: #606266;
    position: absolute;
    top: 10px;
  }
  .li {
    width: 40px;
    margin: 0 auto;
    border-bottom: 3px solid transparent;
  }
}
.bz_a {
  display: flex;
  // justify-content: center;
  // padding-left: 80px;
  // padding:0px 0 45px 80px;
  padding-bottom: 45px;
  padding-top: 20px;
  // padding-left: 30px;
  display: flex;
  justify-content: center;
  .bz_i {
    display: flex;
    // flex-direction: column;
    align-items: center;
    position: relative;
    // padding: 20px 0;
    .quan {
      width: 14px;
      height: 14px;
      border: 2px solid #1678ff;
      border-radius: 50%;
    }
    .qiu {
      width: 14px;
      height: 14px;
      background: #ccc;
      border-radius: 50%;
    }
    .gun {
      width: 80px;
      height: 2px;
      background: #1678ff;
    }
    .gun1 {
      width: 80px;
      height: 2px;
      background: #ccc;
    }
    .time {
      position: absolute;
      top: -15px;
      transform: translateX(-120%);
      font-size: 10px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #999999;
    }
    .zhi {
      line-height: 14px;
      font-size: 8px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #999999;
      position: absolute;
      left: 3px;
      // right: 0;
      transform: translateX(-45%);
      bottom: -30px;
      white-space: nowrap;
    }
  }
  .bz_i:last-child {
    // width: 100px;
  }
}
::v-deep .el-date-editor {
  width: 100% !important;
}
::v-deep .el-table {
  overflow: auto;
}
::v-deep .el-select {
  width: 100%;
}
/* 这个是为了解决前面样式覆盖之后伪类带出来的竖线 */
::v-deep .el-table::after {
  position: relative;
}
</style>
