<template>
  <el-dialog width="95%" title="督办事项" v-model="superVisionDialog">
    <div
      style="
        background-color: #f4f7fc;
        height: 75vh;
        padding: 20px;
        overflow: auto;
      "
    >
      <el-row>
        <el-col :span="3">
          <div class="grid-content ep-bg-purple" />
        </el-col>
        <el-col :span="18">
          <div
            class="grid-content ep-bg-purple-light"
            style="
              background-color: white;
              width: 100%;
              border: 1px solid #e4e7ed;
            "
          >
            <div
              style="
                height: 60px;
                line-height: 60px;
                text-align: center;
                color: red;
                font-weight: 700;
                font-size: 20px;
                border-bottom: 1px solid #e4e7ed;
              "
            >
              督办事项
            </div>
            <div style="padding: 20px">
              <el-form
                style="padding: 20px"
                ref="supervisionRef"
                :model="form"
                :rules="rules"
                label-width="110px"
              >
                <el-form-item label="督办事项" prop="title">
                  <el-input
                    :disabled="editInfo"
                    v-model="form.title"
                    placeholder="请输入督办事项"
                  />
                </el-form-item>
                <el-form-item label="发起时间" prop="submitTime">
                  <el-input disabled v-model="form.submitTime" placeholder="" />
                </el-form-item>
                <el-row type="flex" justify="">
                  <el-col :span="12">
                    <el-form-item label="督办来源" prop="infoSource">
                      <el-select
                        :disabled="editInfo"
                        v-model="form.infoSource"
                        placeholder="请输入督办来源"
                        clearable
                        style="width: 100%"
                      >
                        <el-option
                          v-for="dict in infoSourceData"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                        /> </el-select></el-form-item
                  ></el-col>
                  <el-col :span="12">
                    <el-form-item label="完成时限" prop="doneTime">
                      <el-date-picker
                        :disabled="editInfo"
                        clearable
                        style="width: 100%"
                        v-model="form.doneTime"
                        type="date"
                        value-format="YYYY-MM-DD"
                        placeholder="请选择完成时限"
                      >
                      </el-date-picker>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-form-item label="督办内容" prop="infoSourceContent">
                  <el-input
                    :disabled="editInfo"
                    rows="3"
                    type="textarea"
                    v-model="form.infoSourceContent"
                    :min-height="192"
                  />
                </el-form-item>

                <el-form-item label="责任处室" prop="prersonLiable">
                  <el-input
                    disabled
                    rows="4"
                    style="width: 80%; display: inline-block"
                    type="textarea"
                    v-model="form.prersonLiable"
                    placeholder="请选择责任处室"
                  />
                  <el-button
                    :disabled="editInfo == 'true'"
                    style="margin-left: 20px"
                    type="primary"
                    @click="handleSelect"
                    >选择</el-button
                  >
                </el-form-item>
                <el-form-item label="进度评价" v-if="jindu">
                  <el-select
                    v-model="form.progressEva"
                    placeholder="请选择进度评价"
                    clearable
                    style="width: 240px"
                  >
                    <el-option
                      v-for="dict in progress_eva"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    />
                  </el-select>
                </el-form-item>
                <el-form-item label="各处室进度详情">
                  <el-table
                    v-if="showDel != 0"
                    :data="form.ywSupervisionItemList"
                    border
                    style="width: 100%"
                  >
                    <el-table-column
                      align="center"
                      width="100"
                      prop="deptName"
                      label="部门"
                    >
                    </el-table-column>
                    <el-table-column
                      align="center"
                      width="68"
                      prop="userName"
                      label="姓名"
                    >
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="progress"
                      width="268"
                      label="进展情况"
                    >
                      <template #default="scope">
                        <el-input
                          v-if="
                            scope.row.submitState == '0' &&
                            this.userId == scope.row.userId
                          "
                          v-model="scope.row.progress"
                          type="textarea"
                          :autosize="{ minRows: 2, maxRows: 4 }"
                          placeholder="请输入进展情况"
                        ></el-input>
                        <span v-else>{{ scope.row.progress }}</span>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="left"
                      prop=""
                      width="208"
                      label="完成佐证材料"
                    >
                      <template #default="scope">
                        <el-upload
                          v-if="
                            this.userId == scope.row.userId &&
                            scope.row.submitState != '1'
                          "
                          style="width: 100%"
                          ref="fujianUpload"
                          v-model:file-list="scope.row.ywFileList"
                          :action="upload.url"
                          :headers="upload.headers"
                          :on-success="uploadFuJianFiles(scope.row)"
                          @handleRemove="romveFile"
                          multiple
                        >
                          <el-button type="primary">上传</el-button>
                        </el-upload>
                        <el-link
                          v-else
                          v-for="(item, index) in scope.row.ywFileList"
                          :key="index"
                          type="primary"
                        >
                          <div v-if="item != null">
                            <div
                              style="display: flex"
                              @click="openFujianFile(item.url, item.name)"
                            >
                              <el-icon
                                style="display: inline-block"
                                class="el-icon--left"
                              >
                                <Document />
                              </el-icon>
                              <span
                                style="
                                  display: inline-block;
                                  margin-left: 5px;
                                  overflow: hidden;
                                  white-space: nowrap;
                                  text-overflow: ellipsis;
                                  width: 9vw;
                                  height: 18px;
                                  line-height: 18px;
                                "
                              >
                                {{ item.name }}</span
                              >
                            </div>
                            <!-- <el-popconfirm
                              v-if="!isEdit"
                              @confirm="confirmEvent(item, index)"
                              @cancel="cancelEvent"
                              title="确认删除该文件吗?"
                            >
                              <template #reference>
                                <span
                                  @click="delFile(item, index)"
                                  style="
                                    display: inline-block;
                                    margin-top: 5px;
                                    margin-left: 10px;
                                  "
                                  ><el-icon><Close /></el-icon
                                ></span>
                              </template>
                            </el-popconfirm> -->
                          </div>
                        </el-link>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="submitTime"
                      align="center"
                      label="提交时间"
                      width="160"
                    ></el-table-column>
                    <el-table-column
                      align="center"
                      prop=""
                      width="100"
                      label="审核领导"
                    >
                      <template #default="scope">
                        <span>{{ scope.row.leaderName }}</span>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="approveTime"
                      align="center"
                      width="160"
                      label="审核时间"
                    ></el-table-column>
                    <el-table-column
                      align="center"
                      width="268"
                      prop=""
                      label="领导意见"
                    >
                      <template #default="scope">
                        <el-input
                          v-if="
                            this.userId == scope.row.leaderUserId &&
                            scope.row.submitState == '1' &&
                            scope.row.leaderApprove == '0'
                          "
                          v-model="scope.row.leaderMsg"
                          type="textarea"
                          :autosize="{ minRows: 2, maxRows: 4 }"
                          placeholder="请输入领导意见"
                        ></el-input>
                        <span v-else>{{ scope.row.leaderMsg }}</span>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      width="110"
                      prop=""
                      label="领导审核结果"
                    >
                      <template #default="scope">
                        <span
                          >{{
                            selectDictLabel(
                              leader_approve,
                              scope.row.leaderApprove
                            )
                          }}
                        </span>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      fixed="right"
                      label="操作"
                      width="83"
                    >
                      <template #default="scope">
                        <span v-if="scope.row.leaderApprove == '0'">
                          <el-button
                            v-if="
                              this.userId == scope.row.leaderUserId &&
                              scope.row.submitState == '1'
                            "
                            icon="back"
                            size="small"
                            @click="sendBackInfo(scope.row)"
                            type="text"
                            >退回
                          </el-button>
                          <el-button
                            v-if="
                              this.userId == scope.row.leaderUserId &&
                              scope.row.submitState == '1'
                            "
                            icon="check"
                            size="small"
                            @click="pass(scope.row)"
                            type="text"
                            >通过
                          </el-button>
                        </span>
                      </template>
                    </el-table-column>
                  </el-table>
                  <div v-else>暂无</div>
                </el-form-item>
                <!-- <el-form-item label="佐证材料:">
                  <el-upload
                    style="width: 100%"
                    ref="fujianUpload"
                    v-model:file-list="fujianListNew"
                    :action="upload.url"
                    :headers="upload.headers"
                    :on-success="uploadFuJianFiles"
                    @handleRemove="romveFile"
                    multiple
                  >
                    <el-button type="primary">点击上传佐证材料</el-button>
                  </el-upload>
                  <el-link
                    v-for="(item, index) in fujianList"
                    :key="index"
                    type="primary"
                  >
                    <div v-if="item != null">
                      <div
                        style="display: inline-block"
                        @click="openFujianFile(item.url, item.name)"
                      >
                        <el-icon class="el-icon--left">
                          <Document />
                        </el-icon>
                        <span
                          style="
                            display: inline-block;
                            margin-left: 5px;
                            overflow: hidden;
                            white-space: nowrap;
                            text-overflow: ellipsis;
                            width: 9vw;
                            height: 18px;
                            line-height: 18px;
                          "
                        >
                          {{ item.name }}</span
                        >
                      </div>
                      <el-popconfirm
                        v-if="!isEdit"
                        @confirm="confirmEvent(item, index)"
                        @cancel="cancelEvent"
                        title="确认删除该文件吗?"
                      >
                        <template #reference>
                          <span
                            @click="delFile(item, index)"
                            style="
                              display: inline-block;
                              margin-top: 5px;
                              margin-left: 10px;
                            "
                            ><el-icon><Close /></el-icon
                          ></span>
                        </template>
                      </el-popconfirm>
                    </div>
                  </el-link>
                </el-form-item> -->
                <el-form-item label="进展情况" prop="progress" v-if="isCsfk">
                  <el-input
                    rows="12"
                    type="textarea"
                    v-model="formData.progress"
                    placeholder="请输入进展情况"
                  />
                </el-form-item>
                <div style="text-align: center; width: 100%">
                  <el-button
                    v-if="jindu"
                    :loading="loadingWebLoad"
                    @click="baocun"
                    type="primary"
                    >保存
                  </el-button>
                </div>
              </el-form>
              <!--  下一步提交            -->
              <div v-if="liucheng">
                <!-- <el-divider></el-divider> -->
                <el-form v-show="submitShow" label-width="120px">
                  <div style="width: 100%" v-show="guidangBt != true">
                    <!-- <el-form-item v-if="optionsInfo" label="审核意见">
                      <el-col :span="24">
                        <el-input
                          style="width: 16vw"
                          type="textarea"
                          :rows="2"
                          placeholder="请输入审核意见"
                          v-model="formData.reviewMsg"
                        />
                      </el-col>
                    </el-form-item> -->
                    <div
                      v-if="showTijiao"
                      style="text-align: center; width: 100%"
                    >
                      <el-button
                        v-if="tijiaoBtn"
                        :loading="loadingWebLoad"
                        @click="sendNext"
                        type="primary"
                        >提交
                      </el-button>

                      <!-- <el-button v-if="backInfo" @click="sendBack" type="danger"
                        >退回
                      </el-button> -->
                    </div>
                    <div style="text-align: center; width: 100%" v-else>
                      <el-button
                        v-if="showSub == true"
                        :loading="loadingWebLoad"
                        @click="guanbidialog"
                        >提交
                      </el-button>
                    </div>
                  </div>
                </el-form>
              </div>
            </div>
          </div>
        </el-col>
        <el-col :span="3">
          <div class="grid-content ep-bg-purple" />
        </el-col>
      </el-row>

      <select-user
        ref="selectRef"
        @ok="handleQuerySel"
        @closeDialogf="closeSelUser"
      ></select-user>

      <!-- 进展情况 -->
      <el-dialog
        title="进展情况"
        style="height: 460px"
        v-model="dialogEdit"
        width="60%"
      >
        <el-form style="padding: 0 30px">
          <el-form-item label-width="6vw" label="进展情况：">
            <el-input v-model="progress" :rows="14" type="textarea" />
          </el-form-item>
        </el-form>
        <span style="float: right" slot="footer">
          <el-button @click="dialogEdit = false">取 消</el-button>
          <el-button style="margin-left: 10px" type="primary" @click="jinDuSub"
            >确 定</el-button
          >
        </span>
      </el-dialog>
      <el-dialog
        v-model="dialogVisibleSel"
        title="请选择责任处室"
        width="1050px"
        style="height: 820px"
        :before-close="handleClose"
      >
        <el-row :gutter="20">
          <el-col
            style="
              padding: 0;
              width: 250px;
              border: 1px solid #e7eaec;
              border-radius: 5px;
              min-height: 650px;
            "
            :span="4.5"
            :xs="24"
          >
            <div
              style="
                display: flex;
                width: 250px;
                height: 40px;
                line-height: 40px;
                border-bottom: 1px solid #e7eaec;
                margin-bottom: 10px;
              "
            >
              <div
                @click="toggle(0)"
                :class="{ selected: fontIndex === 0 }"
                style="
                  font-size: 17px;
                  margin-left: 15px;
                  padding-left: 10px;
                  height: 40px;
                  width: 110px;
                  border-right: 1px solid #e7eaec;
                  cursor: pointer;
                "
              >
                所属部门
              </div>
            </div>
            <div class="head-container"></div>
            <!-- 部门 -->
            <div class="head-container">
              <el-tree
                :data="deptOptions"
                :props="{ label: 'label', children: 'children' }"
                :expand-on-click-node="false"
                :filter-node-method="filterNode"
                ref="dept"
                node-key="id"
                highlight-current
                default-expand-all
                @node-click="handleNodeClick"
                :current-node-key="currentNodeKey"
                :default-expanded-keys="expandedKeys"
              />
            </div>
          </el-col>
          <!-- 所属部门 -->
          <el-col style="margin-left: 40px; margin-top: 5px" :span="15">
            <el-form
              :model="queryParams"
              ref="queryRef"
              :inline="true"
              label-width="68px"
            >
              <el-form-item label="用户姓名" prop="nickName">
                <el-input
                  v-model="queryParams.nickName"
                  placeholder="请输入用户姓名"
                  clearable
                  style="width: 15vw"
                />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" icon="Search" @click="handleQuery"
                  >搜索</el-button
                >
                <el-button
                  style="margin-left: 10px"
                  icon="RefreshRight"
                  @click="resetQuery"
                  >重置</el-button
                >
              </el-form-item>
            </el-form>

            <el-table
              style="height: 500px"
              ref="multipleTable1"
              :row-key="getRowKeys"
              :data="userList"
              @selection-change="handleSelectionChange"
            >
              <el-table-column
                :selectable="getSelectable"
                :reserve-selection="true"
                type="selection"
                width="50"
                align="center"
              />
              <el-table-column
                label="用户姓名"
                align="center"
                key="nickName"
                prop="nickName"
                v-if="columns[2].visible"
                :show-overflow-tooltip="true"
              />
              <el-table-column
                :show-overflow-tooltip="true"
                align="center"
                prop="phonenumber"
                label="联系方式"
              ></el-table-column>
              <el-table-column
                label="所属部门"
                align="center"
                key="deptName"
                prop="dept.deptName"
                v-if="columns[3].visible"
                :show-overflow-tooltip="true"
              />
            </el-table>
            <div style="float: right; margin-top: 20px; margin-right: 20px">
              <el-pagination
                v-model:current-page="queryParams.pageNum"
                v-model:page-size="queryParams.pageSize"
                :page-sizes="[10, 20, 30, 50, 100]"
                :small="small"
                :disabled="disabled"
                :background="background"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
              />
            </div>
          </el-col>
        </el-row>

        <span style="float: right">
          <el-button @click="this.dialogVisibleSel = false">取消</el-button>
          <el-button
            style="margin-left: 10px"
            type="primary"
            @click="submitUserList"
          >
            确认
          </el-button>
        </span>
      </el-dialog>
    </div>
  </el-dialog>
</template>
<script>
import { addCar } from "@/api/car";
import {
  generNextStepNode1,
  node_ReturnWork,
  getReviewMsg,
  getReturnWorkNode,
  getSelfParas,
  getWfGenerWorkList,
} from "@/api/liucheng";
import { ElMessage } from "element-plus";
import selectUser from "@/views/liucheng/selectUserDB.vue";
import { getJToken } from "@/utils/auth";
import { getInfo } from "@/api/login";
import { useDict } from "@/utils/dict";
import { deptTreeSelect } from "@/api/system/user";
import {
  selSuperVisionByWorkId,
  sendFlowToUsers1,
  updatemyselfDetail,
  getSupervision,
  editItem,
  leaderApprove,
  updateSupervision,
} from "@/api/offcial/supervision";
import Cookies from "js-cookie";
import { listType } from "@/api/archive/type";
import { saveArchive } from "@/api/archive/archive";

// import { updateSupervision } from "../../../../api/offcial/supervision";
import { listUser2, deptTreeSelect2 } from "@/api/system/user";
import { getToken } from "@/utils/auth";
export default {
  name: "YinetoaLeaveApplication",
  props: [
    "dialogVisible",
    "name",
    "showTable",
    "WorkId",
    "FK_Flow",
    "nodeName",
    "trueLeave",
    "closeDialog",
    "editInfo",
    "showSub",
  ],
  components: { selectUser },
  data() {
    return {
      jindu: null,
      tijiaoBtn: false,
      showTijiao: false,
      upload: {
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: import.meta.env.VITE_APP_BASE_API + "/system/file/fileupload",
      },
      fujianList: [],
      fujianListNew: [],
      uploadNot: false,
      dialogVisibleSel: false,
      total: 0,
      columns: [
        { key: 0, label: `用户编号`, visible: true },
        { key: 1, label: `用户名称`, visible: true },
        { key: 2, label: `用户昵称`, visible: true },
        { key: 3, label: `部门`, visible: true },
        { key: 4, label: `手机号码`, visible: true },
        { key: 5, label: `状态`, visible: true },
        { key: 6, label: `创建时间`, visible: true },
      ],
      loading: false,
      selection: [],
      deptOptions: [],
      userList: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName: undefined,
        phonenumber: undefined,
        status: undefined,
        deptId: undefined,
        nickName: undefined,
      },
      isEval: false,
      iconStyle: {
        large: "8px",
        default: "6px",
        small: "4px",
      },
      LS: {
        color: "#000",
        "text-align": "center",
        "font-weight": "600",
        height: "40px",
        "background-color": "rgba(255, 97, 2, 0.1)",
        "min-width": "110px",
        "word-break": "keep-all",
      },
      descriptionstype: "default",
      isCsfk: false,
      form: { ywSupervisionStartUserList: [] },
      leader_approve: useDict("leader_approve").leader_approve,
      infoSourceData: useDict("info_source").info_source,
      sys_yes_no: useDict("sys_yes_no").sys_yes_no,
      progress_eva: useDict("progress_eva").progress_eva,
      optionsInfo: true,
      rules: {},
      returnMsg: null,
      formData: {
        reviewMsg: "同意",
        optionName: null,
        toNodeId: null,
        users: null,
        workid: null,
        progress: "",
      },
      liuzhuanData: [],
      tripFlowData: {},
      NextStepNode: [],
      guidangData: {
        archiveNo: null,
        workId: null,
        archiveFormNo: null,
        printNum: null,
        levels: null,
        typeId: null,
        name: null,
      },
      nodeValue: null,
      isEdit: true,
      tuurl: "",
      dialogBack: false,
      selNextNode: "",
      superVisionDialog: false,
      submitShow: true,
      guidangBt: false,
      nodeData: [],
      typeList: [],
      showDel: null,
      liucheng: true,
      userId: null,
      dialogEdit: false,
      progress: "",
      id: "",
      nowProgress: "",
      userIdAll: [],
      idNow: null,
      dataSubmit: { ywFileList: [], leaderUserName: "" },
      rowThis: {},
      backInfo: false,
      dataInfo: {},
    };
  },

  created() {
    this.getInfo();
  },
  watch: {},

  mounted() {},

  methods: {
    guanbidialog() {
      this.superVisionDialog = false;
      this.$emit("guanbi");
    },
    baocun() {
      this.$modal.loading("保存中...");
      updateSupervision(this.form).then((response) => {
        this.$modal.msgSuccess("保存成功");
        this.$nextTick(() => {
          // this.reset();
          // this.$refs.ruleFormRef.resetFields();
          this.$emit("guanbi");
        });
        this.$modal.closeLoading();
      });
    },
    sendBackInfo(row) {
      if (
        row.leaderMsg == "" ||
        row.leaderMsg == null ||
        row.leaderMsg == undefined
      ) {
        this.$modal.msgWarning("请填写领导意见");
        return;
      } else {
        this.dataInfo.id = row.id;
        this.dataInfo.leaderMsg = row.leaderMsg;
        this.dataInfo.leaderApprove = "1";
        // this.dataInfo.supervisionId
        const _dataInfo = this.dataInfo;
        const _row = row;
        this.$modal
          .confirm("是否确认退回")
          .then(function () {
            _row.leaderApprove = "1";
            return leaderApprove(_dataInfo);
          })
          .then(() => {
            this.$modal.msgSuccess("退回成功");
          });
      }
    },
    pass(row) {
      if (
        row.leaderMsg == "" ||
        row.leaderMsg == null ||
        row.leaderMsg == undefined
      ) {
        this.$modal.msgWarning("请填写领导意见");
        return;
      } else {
        this.dataInfo.id = row.id;
        this.dataInfo.leaderMsg = row.leaderMsg;
        this.dataInfo.leaderApprove = "2";
        console.log(this.dataInfo);
        const _dataInfo = this.dataInfo;
        const _row = row;
        this.$modal
          .confirm("是否确认通过")
          .then(function () {
            _row.leaderApprove = "1";
            return leaderApprove(_dataInfo);
          })
          .then(() => {
            this.$modal.msgSuccess("通过成功");
          });
      }
    },

    openFujianFile(url) {
      window.open(url, "_blank");
    },
    uploadFuJianFiles(row) {
      console.log("row", row);
      this.dataSubmit.id = row.id;
      this.rowThis = row;
    },
    sendNext() {
      // if (this.formData.reviewMsg == "" || this.formData.reviewMsg == null) {
      //   this.$modal.msgWarning("请填写审核意见");
      //   return;
      // }
      this.openSelectUser();
    },
    submitUserList() {
      // console.log("selection", this.selection);
      this.form.ywSupervisionStartUserList = [];
      this.form.prersonLiable = "";
      let arr = [];
      for (let i = 0; i < this.selection.length; i++) {
        let obj = {
          userName: this.selection[i].userName,
          userId: this.selection[i].userId,
          nickName: this.selection[i].nickName,
        };
        this.form.ywSupervisionStartUserList.push(obj);
        arr.push(
          this.selection[i].dept.deptName + "--" + this.selection[i].nickName
        );
        console.log("arr", arr);
        this.form.prersonLiable = arr.join(" , ");
      }
      console.log(
        "ywSupervisionStartUserList",
        this.form.ywSupervisionStartUserList
      );
      // let arr = this.selection.map((item) => {
      //   console.log(item);
      //   return item.dept.deptName + "--" + item.nickName;
      // });
      // this.form.prersonLiable = arr.join(" , ");
      console.log("this.form.prersonLiable", this.form.prersonLiable);
      this.dialogVisibleSel = false;
    },
    // // 多选框选中数据  常用联系人
    handleSelectionChange(selection) {
      console.log(selection);
      this.selection = [];
      this.selection = selection;

      this.single = this.selection.length !== 1;
      this.multiple = !this.selection.length;
    },
    // /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryRef");
      this.queryParams.deptId = undefined;
      this.$nextTick(() => {
        this.$refs.deptTreeRef.setCurrentKey(null);
      });
      this.handleQuery();
    },
    // /** 节点单击事件 */
    handleNodeClick(data) {
      this.queryParams.deptId = data.id;
      this.handleQuery();
    },
    getRowKeys(row) {
      return row.userId;
    },
    getSelectable(row) {
      return row.status !== "REJECT";
    },
    //分页
    handleSizeChange(newPage) {
      this.queryParams.pageSize = newPage;
      this.getList();
    },
    handleCurrentChange(val) {
      this.queryParams.pageNum = val;
      this.getList();
    },
    // /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    // /** 查询部门下拉树结构 */
    async getDeptTree() {
      await deptTreeSelect2().then((response) => {
        this.deptOptions = response.data;
      });
    },
    async getList() {
      this.loading = true;
      await listUser2(this.addDateRange(this.queryParams, this.dateRange)).then(
        (res) => {
          this.loading = false;
          this.userList = res.rows;
          //console.log("this.userList", this.userList);
          this.total = res.total;
        }
      );
      this.selection = [];
    },
    handleSelect() {
      // this.mailUserIds = [];
      // this.getContactsTree();
      this.queryParams = {
        deptId: undefined,
        pageNum: 1,
        pageSize: 120,
        userName: undefined,
        phonenumber: undefined,
        status: undefined,
        postIds: undefined,
        beginTime: undefined,
        endTime: undefined,
      };
      this.getList();
      this.getDeptTree();

      // 回显
      console.log("回显", this.form.ywSupervisionStartUserList);
      if (this.form.ywSupervisionStartUserList.length > 0) {
        this.$nextTick(() => {
          this.$refs.multipleTable1.clearSelection();
          this.userIdAll = [];
          for (
            let i = 0;
            i < this.form.ywSupervisionStartUserList.length;
            i++
          ) {
            this.userIdAll.push(this.form.ywSupervisionStartUserList[i].userId);
          }
          console.log("this.userIdAll", this.userIdAll);
          setTimeout(() => {
            this.userIdAll.forEach((item) => {
              this.userList.forEach((item1) => {
                if (item == item1.userId) {
                  console.log("item1", item1);
                  this.$refs.multipleTable1.toggleRowSelection(item1, true);
                }
              });
            });
          }, 300);
        });
      }
      this.dialogVisibleSel = true;
    },
    jinDuSub() {
      this.dialogEdit = false;

      updatemyselfDetail({ progress: this.progress, id: this.id }).then(
        (res) => {
          this.$message.success("修改进度评价成功");
          getSupervision(this.idNow).then((res) => {
            console.log("res", res);
            this.form = res.data;
            this.jindu = this.form.submitState == "2" ? true : false;
            this.showDel = res.data.ywSupervisionItemList.length;
          });
        }
      );
    },
    getInfo() {
      getInfo().then((res) => {
        console.log(res);
        this.userId = res.user.userId;
      });
    },
    editJinDu(row) {
      this.getInfo();
      console.log("edit", row);
      this.progress = row.progress;

      this.id = row.id;
      this.dialogEdit = true;
    },
    async submitNodeBack() {
      if (this.nodeValue == null) {
        this.$message.error("请选择退回节点信息");
        return;
      }
      if (this.returnMsg == null) {
        this.$message.error("请输入退回原因");
        return;
      }
      this.$modal.loading("退回中，请稍后...");
      let res = await node_ReturnWork({
        workid: this.formData.workid,
        returnToNodeID: this.nodeValue,
        returnMsg: this.returnMsg,
      });
      this.$message.success(res);
      this.dialogBack = false;
      // this.superVisionDialog = false;
      this.$emit("closeViewLeave");
      this.nodeValue = null;
      this.returnMsg = null;
      this.valDate = null;
      this.selNextNode = null;
      this.$modal.closeLoading();
      this.colsedialog();
    },
    getDeptTree() {
      deptTreeSelect().then((response) => {
        this.deptOptions = response.data;
      });
    },
    sumbitSupervise() {
      sendFlowToNext;
    },
    changeDate(val) {
      var d1 = new Date(val[0]);
      var d2 = new Date(val[1]);
      var diff = d2 - d1;
      var days = diff / (1000 * 60 * 60 * 24);
      this.form1.dayNum = Math.floor(days) + 1;
    },

    showDetail1(flowData) {
      console.log("flowData", flowData);
      this.superVisionDialog = true;
      this.showBack = true;
      // if (flowData.FK_Node == "1601") {
      //   this.showBack = false;
      // }
      // if (flowData.FK_Node == "1605") {
      //   console.log(flowData.FK_Node);
      //   this.isCsfk = true;
      //   this.optionsInfo = false;
      // }
      // if (flowData.FK_Node == "1606") {
      //   console.log(flowData.FK_Node);
      //   this.isEval = true;
      // }
      // var workid_1 = flowData.workId;
      // if (flowData.workId == undefined) {
      //   workid_1 = flowData.WorkID;
      // }
      // getSupervision(flowData.id).then((res) => {
      //   console.log("是否可编辑原信息", res);
      //   if (res.data.SelfParas == "isEdit") {
      //     this.isEdit = false;
      //   }
      // });
      this.idNow = flowData.id || flowData.workId;
      getSupervision(this.idNow).then((res) => {
        console.log("res", res);
        this.form = res.data;
        this.dataInfo.supervisionId = res.data.id;
        this.backInfo = res.data.submitState == "1" ? true : false;
        this.tijiaoBtn = res.data.submitState == "1" ? true : false;
        this.showDel = res.data.ywSupervisionItemList.length;
        this.showTijiao = false;
        for (let i = 0; i < this.form.ywSupervisionItemList.length; i++) {
          if (
            this.form.ywSupervisionItemList[i].userId == this.userId &&
            this.form.ywSupervisionItemList[i].submitState == "0"
          ) {
            this.showTijiao = true;
          }
        }
      });
    },
    closeSendNext() {
      this.liucheng = false;
    },
    handleQuerySel(selUsers) {
      console.log("selUsers", selUsers);
      if (selUsers != undefined && selUsers != "") {
        this.dataSubmit.leaderUserName = selUsers;
        this.editItem();
      }
    },
    editItem() {
      if (this.rowThis.ywFileList.length != 0) {
        for (let i = 0; i < this.rowThis.ywFileList.length; i++) {
          if (this.rowThis.ywFileList[i].response != undefined) {
            this.dataSubmit.ywFileList.push(
              this.rowThis.ywFileList[i].response.data
            );
          } else {
            this.dataSubmit.ywFileList.push(this.rowThis.ywFileList[i]);
          }
        }
      } else {
        this.$modal.msgWarning("请上传佐证材料");
        return;
      }
      this.dataSubmit.progress = this.rowThis.progress;

      editItem(this.dataSubmit).then((res) => {
        console.log(res);
        this.superVisionDialog = false;
        this.$message({
          type: "success",
          message: "提交成功",
        });
        this.$emit("guanbi");
      });
    },
    colsedialog() {
      this.$emit("guanbi");
      this.superVisionDialog = false;
    },
    /** 查询归档类型列表 */
    getTypeList() {
      listType({}).then((response) => {
        this.typeList = this.handleTree(
          response.data,
          "archiveTypeId",
          "parentId"
        );
      });
    },
    // sendNext() {
    //   if (this.formData.reviewMsg == "" || this.formData.reviewMsg == null) {
    //     this.$modal.msgWarning("请填写审核意见");
    //     return;
    //   }
    //   this.formData.toNodeId = this.selNextNode;
    //   let DeliveryWay = "";
    //   //查看当前是选择的那个节点
    //   this.NextStepNode.forEach((item, index) => {
    //     if (item.NodeID == this.selNextNode) {
    //       DeliveryWay = item.DeliveryWay;
    //     }
    //   });
    //   //判断当前节点是哪一个节点
    //   //DeliveryWay 3:绑定人员计算 7:发送给开始节点
    //   if (DeliveryWay == "3" || DeliveryWay == "7") {
    //     this.onSubmit();
    //   }
    //   //4:由发送人选择发送
    //   else if (DeliveryWay == "4" || DeliveryWay == "1" || DeliveryWay == "9") {
    //     this.openSelectUser();
    //     return;
    //   } else {
    //     this.onSubmit();
    //   }
    // },
    sendBack() {
      this.dialogBack = true;
      this.getReturnWorkNode();
    },
    async getReturnWorkNode() {
      console.log(this.formData.workid);
      let nodeData = await getReturnWorkNode({ workid: this.formData.workid });
      this.nodeData = nodeData;
    },
    openSelectUser() {
      this.$refs["selectRef"].show1();
    },
    async onSubmit() {
      if (this.guidangBt) {
        this.guidangData.archiveFormNo = this.tripFlowData.FK_Flow;
        this.guidangData.workId = this.tripFlowData.WorkID;
        let { upresult } = await updateSupervision(this.form);
        let { archiveRes } = await saveArchive(this.guidangData);
      }
      sendFlowToUsers1(this.formData).then((response) => {
        if (response.code == 200) {
          if (
            response.data.VarAcceptersName != "" &&
            response.data.VarAcceptersName != "结束"
          ) {
            ElMessage({
              message:
                "已发送到" +
                response.data.VarToNodeName +
                "节点，接收人：" +
                response.data.VarAcceptersName,
              type: "success",
            });
          } else if (response.data.VarAcceptersName == "结束") {
            ElMessage({
              message: response.data.Message,
              type: "success",
            });
          } else {
            ElMessage({
              message: response.data.Message.replaceAll("@", ""),
              type: "success",
            });
          }
          this.colsedialog();
        } else {
          this.colsedialog();
        }
      });
    },

    reset() {
      this.form1 = {
        createBy: this.form.createBy,
        phone: this.form.phone,
      };
    },
    SubmitSelect(selUsers) {
      this.form.params["toEmps"] = selUsers;
      if (selUsers != undefined && selUsers != "") {
        console.log(this.form);
        addCar(this.form).then((res) => {
          this.$modal.msgSuccess(
            "已发送到" +
              res.data.VarToNodeName +
              "节点," +
              "处理人:" +
              res.data.VarAcceptersName
          );
          this.$nextTick(() => {
            this.reset();
            this.$refs.ruleFormRef.resetFields();
          });
          this.$emit("change1");
          this.$modal.closeLoading();
        });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-button + .el-button {
  margin-left: 0px;
}
::v-deep .el-button--small {
  --el-button-size: 24px;
  height: var(--el-button-size);
  padding: 5px 5px;
  font-size: 12px;
  border-radius: calc(var(--el-border-radius-base) - 1px);
}
</style>
