<template>
  <div style="display: flex; justify-content: space-between">
    <div class="taskbox">
      <div class="tit">
        <span style="font-weight: bold">待办任务</span>
      </div>
      <div style="background: #fff; padding: 20px; min-height: 400px">
        <div class="tabbox">
          <el-table
            class="com-table"
            ref="multipleTable"
            :data="niticList"
            tooltip-effect="dark"
            size="small"
            border
            style="width: 100%"
            height="350px"
          >
            <el-table-column prop="woTitle" label="工单标题">
              <template slot-scope="scope">
                <span
                  :style="scope.row.woTypeDesc == '预警工单' ? 'color:red' : ''"
                  >{{ scope.row.woTitle }}</span
                >
              </template>
            </el-table-column>
            <el-table-column prop="sendTime" label="发起时间">
              <template slot-scope="scope">
                <span>{{ $formatDate(scope.row.sendTime, "YYYY-MM-DD") }}</span>
              </template>
            </el-table-column>
            <!-- <el-table-column prop="sendNo" label="发起工号">
            </el-table-column> -->
            <el-table-column prop="sendName" label="发起姓名">
              <template slot-scope="scope">
                <span>{{ $desensitization(scope.row.sendName, 1) }}</span>
              </template>
            </el-table-column>

            <el-table-column label="操作" align="center" width="120">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="primary"
                  @click="checkNotic(1, scope.row)"
                  >查看</el-button
                >
                <el-button
                  v-if="scope.row.sts == '2' || scope.row.sts == '4'"
                  size="mini"
                  type="primary"
                  @click="checkNotic(2, scope.row)"
                  >处理</el-button
                >
                <el-button
                  v-if="
                    scope.row.sts == '0' && scope.row.woTypeDesc == '预警工单'
                  "
                  size="mini"
                  type="primary"
                  @click="checkNotic(2, scope.row)"
                  >处理</el-button
                >
                <el-button
                  v-if="
                    scope.row.sts == 3 && scope.row.woTypeDesc == '信息上报'
                  "
                  size="mini"
                  type="primary"
                  @click="checkNotic(2, scope.row)"
                  >处理</el-button
                >
                <el-button
                  v-if="scope.row.sts == 0 && scope.row.woTypeDesc == '工单'"
                  size="mini"
                  type="danger"
                  @click="checkNotic(3, scope.row)"
                  >审核</el-button
                >
                <el-button
                  v-if="
                    scope.row.sts == 1 && scope.row.woTypeDesc == '预警工单'
                  "
                  size="mini"
                  type="danger"
                  @click="checkNotic(3, scope.row)"
                  >审核</el-button
                >
                <el-button
                  v-if="
                    scope.row.sts == 0 && scope.row.woTypeDesc == '信息上报'
                  "
                  size="mini"
                  type="danger"
                  @click="checkNotic(3, scope.row)"
                  >审核</el-button
                >
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </div>
    <div class="taskbox">
      <div class="tit">
        <span style="font-weight: bold">已办任务</span>
        <span style="cursor: pointer" @click="newtask">发起</span>
      </div>
      <div style="background: #fff; min-height: 400px; padding: 20px">
        <div class="tabbox">
          <el-table
            class="com-table"
            ref="tableDatayj"
            :data="tableDatayj"
            tooltip-effect="dark"
            size="small"
            border
            style="width: 100%"
            height="350px"
          >
            <el-table-column prop="woTitle" label="工单标题"> </el-table-column>
            <el-table-column prop="sendTime" label="发起时间">
              <template slot-scope="scope">
                <span>{{ $formatDate(scope.row.sendTime, "YYYY-MM-DD") }}</span>
              </template>
            </el-table-column>
            <!-- <el-table-column prop="sendNo" label="发起工号"> </el-table-column> -->
            <el-table-column prop="sendName" label="发起姓名">
              <template slot-scope="scope">
                <span>{{ $desensitization(scope.row.sendName, 1) }}</span>
              </template>
            </el-table-column>

            <el-table-column label="操作" align="center">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="primary"
                  @click="checkNotic(1, scope.row)"
                >
                  查看</el-button
                >
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </div>

    <el-dialog
      title="工单"
      :visible.sync="tasksts"
      width="70%"
      :close-on-press-escape="false"
      :show-close="true"
      :destroy-on-close="true"
      :modal-append-to-body="false"
      :close-on-click-modal="false"
      :fullscreen="true"
    >
      <div class="dialog-l">
        <el-tabs tab-position="left" v-model="activeName">
          <el-tab-pane
            v-for="item in routerList"
            :key="item.label"
            :name="item.label"
            :label="item.name"
          >
          </el-tab-pane>
        </el-tabs>
      </div>

      <div class="dialog-r">
        <el-form
          :model="infolist"
          ref="infolist"
          :rules="rules"
          style="height: calc(100vh - 180px); overflow-y: scroll"
        >
          <div class="info-line">
            <el-form-item prop="woTitle">
              <span>工单标题</span>
              <el-input v-model="infolist.woTitle" placeholder="工单标题">
              </el-input>
            </el-form-item>
            <el-form-item prop="requireTime">
              <span>反馈时间</span>
              <el-date-picker
                :append-to-body="false"
                v-model="infolist.requireTime"
                type="date"
                placeholder="要求反馈时间"
              >
              </el-date-picker>
            </el-form-item>
          </div>
          <el-form-item prop="visiblec" class="info-line online">
            <span>接收人员</span>

            <deptTreeOnly
              class="tree"
              @treeCheck="treeCheckonly"
            ></deptTreeOnly>
            <div class="tree treeUser">
              <p>{{ treeListonly.leaderAuditName }}</p>
            </div>
          </el-form-item>

          <el-form-item class="info-line online">
            <span>任务描述</span>
            <el-input
              v-model="infolist.arcDesc"
              placeholder="任务描述"
              type="textarea"
              :rows="3"
            ></el-input>
          </el-form-item>
          <div style="padding-left: 80px">
            <myUpload
              @uploadBack="uploadBack"
              :fileInfo="fileInfo"
              :fileList="fileInfo.fileList"
            >
            </myUpload>
          </div>
        </el-form>
        <div slot="footer" class="dialog-footer myfooter">
          <el-button
            @click="dialogCliadd(1)"
            type="primary"
            v-if="activeName != '2'"
            >确 定</el-button
          >
          <el-button
            type="primary"
            @click="dialogCliadd(3)"
            v-if="activeName == '2'"
            >通 过</el-button
          >
          <el-button
            type="primary"
            @click="dialogCliadd(4)"
            v-if="activeName == '2'"
            >打 回</el-button
          >
          <el-button @click="dialogCliadd(2)">取 消</el-button>
        </div>
      </div>
    </el-dialog>

    <el-dialog
      title="审核工单"
      :visible.sync="taskstsh"
      width="70%"
      :close-on-press-escape="false"
      :show-close="true"
      :destroy-on-close="true"
      :modal-append-to-body="false"
      :close-on-click-modal="false"
      :fullscreen="true"
    >
      <div class="dialog-l">
        <el-tabs tab-position="left" v-model="activeName">
          <el-tab-pane
            v-for="item in routerList"
            :key="item.label"
            :name="item.label"
            :label="item.name"
          >
          </el-tab-pane>
        </el-tabs>
      </div>

      <div class="dialog-r">
        <el-form
          :model="infolist"
          ref="infolist"
          :rules="rules"
          style="height: calc(100vh - 180px); overflow-y: scroll"
        >
          <div class="info-line" style="margin-bottom: 10px">
            <span>工单标题</span>
            <el-input
              v-model="infolist.woTitle"
              placeholder="工单标题"
              disabled
            >
            </el-input>
          </div>
          <div
            style="margin-bottom: 10px"
            class="info-line online"
            v-if="activeName == '1'"
          >
            <span>接收人员</span>

            <deptTreeOnly
              class="tree"
              @treeCheck="treeCheckonly"
            ></deptTreeOnly>
            <div class="tree treeUser">
              <p>{{ treeListonly.leaderAuditName }}</p>
            </div>
          </div>

          <el-form-item class="info-line online">
            <span>工单备注</span>
            <el-input
              v-model="infolist.dealRemark"
              placeholder="工单备注"
              type="textarea"
              :rows="3"
            >
            </el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer myfooter">
          <el-button
            @click="dialogCliup(1)"
            type="primary"
            v-if="activeName != '2'"
            >确 定</el-button
          >
          <el-button
            type="primary"
            @click="dialogCliup(3)"
            v-if="activeName == '2'"
            >通 过</el-button
          >
          <el-button
            type="primary"
            @click="dialogCliup(4)"
            v-if="activeName == '2'"
            >打 回</el-button
          >
          <el-button @click="dialogCliup(2)">取 消</el-button>
        </div>
      </div>
    </el-dialog>

    <el-dialog
      title="处理工单"
      :visible.sync="taskstcl"
      width="70%"
      :close-on-press-escape="false"
      :show-close="true"
      :destroy-on-close="true"
      :modal-append-to-body="false"
      :close-on-click-modal="false"
      :fullscreen="true"
    >
      <div class="dialog-l">
        <el-tabs tab-position="left" v-model="activeName">
          <el-tab-pane
            v-for="item in routerList"
            :key="item.label"
            :name="item.label"
            :label="item.name"
          >
          </el-tab-pane>
        </el-tabs>
      </div>

      <div class="dialog-r">
        <el-form
          :model="infolist"
          style="height: calc(100vh - 180px); overflow-y: scroll"
        >
          <div class="info-line" style="margin-bottom: 10px">
            <span>工单标题</span>
            <el-input
              v-model="infolist.woTitle"
              placeholder="工单标题"
              disabled
            >
            </el-input>
          </div>
          <div
            class="info-line online"
            style="margin-bottom: 10px"
            v-if="activeName != '3'"
          >
            <span>接收人员</span>
            <deptTreeOnly
              class="tree"
              @treeCheck="treeCheckonly"
            ></deptTreeOnly>
            <div class="tree treeUser">
              <p>{{ treeListonly.leaderAuditName }}</p>
            </div>
          </div>

          <el-form-item class="info-line online">
            <span>工单备注</span>
            <el-input
              v-model="infolist.dealRemark"
              placeholder="工单备注"
              type="textarea"
              :rows="3"
            >
            </el-input>
          </el-form-item>
          <div style="padding-left: 80px" v-if="activeName == '3'">
            <myUpload
              @uploadBack="uploadBack"
              :fileInfo="fileInfo"
              :fileList="fileInfo.fileList"
            >
            </myUpload>
          </div>
        </el-form>
        <div slot="footer" class="dialog-footer myfooter">
          <el-button type="primary" @click="dialogClicl(2)">确 定</el-button>
          <el-button @click="dialogClicl(1)">取 消</el-button>
        </div>
      </div>
    </el-dialog>

    <el-dialog
      title="查看工单"
      :visible.sync="dialogInfo"
      width="70%"
      :close-on-press-escape="false"
      :show-close="true"
      :destroy-on-close="true"
      :modal-append-to-body="false"
      :close-on-click-modal="false"
      :fullscreen="true"
    >
      <div style="height: calc(100vh - 180px); overflow-y: scroll">
        <orderCheck
          :historySts="historySts"
          :infolist="infolist"
          :datalist="datalist"
          :backlist="backlist"
          :dialogInfo="dialogInfo"
        ></orderCheck>
      </div>

      <div class="dialog-footer myfooter">
        <el-button @click="dialoginfoCli(1)" type="primary">轨 迹</el-button>

        <el-button @click="dialoginfoCli(3)">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog
      title="审核预警工单"
      :visible.sync="taskstyjsh"
      width="70%"
      :close-on-press-escape="false"
      :show-close="true"
      :destroy-on-close="true"
      :modal-append-to-body="false"
      :close-on-click-modal="false"
      :fullscreen="true"
    >
      <el-form
        :model="infolist"
        ref="infolist"
        style="height: calc(100vh - 180px); overflow-y: scroll"
      >
        <div class="info-line">
          <el-form-item>
            <span>预警规则</span>
            <el-input
              v-model="infolist.ruleName"
              placeholder="工单标题"
              disabled
            ></el-input>
          </el-form-item>
          <el-form-item>
            <span>工单标题</span>
            <el-input
              v-model="infolist.woName"
              placeholder="工单标题"
              disabled
            ></el-input>
          </el-form-item>
        </div>

        <el-form-item class="info-line online">
          <span>任务描述</span>
          <el-input
            v-model="infolist.description"
            disabled
            placeholder="任务描述"
            type="textarea"
            :rows="3"
          >
          </el-input>
        </el-form-item>
        <div
          style="padding-left: 100px; padding-right: 20px; margin-bottom: 20px"
        >
          <uploadDown
            :datalist="datalist"
            :dialogStatus="uploadstatus"
          ></uploadDown>
        </div>
        <el-form-item class="info-line online">
          <span>工单备注</span>
          <el-input
            v-model="infolist.replyDesc"
            placeholder="工单备注"
            type="textarea"
            :rows="3"
          ></el-input>
        </el-form-item>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogCliyj(3)" type="primary">通 过</el-button>
        <el-button @click="dialogCliyj(4)" type="primary">打 回</el-button>
        <el-button @click="dialogCliyj(2)">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog
      title="查看"
      :visible.sync="dialogInfoyj"
      width="70%"
      :close-on-press-escape="false"
      :show-close="true"
      :destroy-on-close="true"
      :modal-append-to-body="false"
      :close-on-click-modal="false"
      :fullscreen="true"
    >
      <div style="height: calc(100vh - 180px); overflow-y: scroll">
        <ruleCheck
          :infolist="infolist"
          :datalist="datalist"
          :dialogInfo="dialogInfo"
          :historySts="historySts"
        ></ruleCheck>
      </div>
      <div class="dialog-footer myfooter">
        <el-button @click="dialoginfoCliyj(1)" type="primary">轨 迹</el-button>
        <el-button
          @click="dialoginfoCliyj(2)"
          type="primary"
          v-if="infolist.sts == '1'"
          >处 理</el-button
        >
        <el-button @click="dialoginfoCliyj(3)">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog
      title="预警工单处理"
      :visible.sync="dialogStatusyj"
      width="60%"
      :close-on-press-escape="false"
      :show-close="true"
      :destroy-on-close="true"
      :modal-append-to-body="false"
      :close-on-click-modal="false"
      :fullscreen="true"
    >
      <div class="dialog-l">
        <el-tabs tab-position="left" v-model="activeName">
          <el-tab-pane
            v-if="item.label != '3'"
            v-for="item in routerList"
            :key="item.label"
            :name="item.label"
            :label="item.name"
          >
          </el-tab-pane>
        </el-tabs>
      </div>

      <div class="dialog-r">
        <el-form
          :model="infolist"
          ref="infolist"
          style="height: calc(100vh - 180px); overflow-y: scroll"
        >
          <div class="info-line">
            <el-form-item>
              <span>预警规则</span>
              <el-input
                v-model="infolist.ruleName"
                placeholder="工单标题"
                disabled
              ></el-input>
            </el-form-item>
            <el-form-item>
              <span>工单标题</span>
              <el-input
                v-model="infolist.woName"
                placeholder="工单标题"
              ></el-input>
            </el-form-item>
          </div>
          <el-form-item class="info-line online">
            <span>接收人员</span>
            <deptTreeOnly
              class="tree"
              @treeCheck="treeCheckonly"
            ></deptTreeOnly>
            <div class="tree treeUser">
              <p>{{ treeListonly.leaderAuditName }}</p>
            </div>
          </el-form-item>
          <el-form-item class="info-line online">
            <span>工单备注</span>
            <el-input
              v-model="infolist.replyDesc"
              placeholder="工单备注"
              type="textarea"
              :rows="3"
            ></el-input>
          </el-form-item>
        </el-form>
      </div>

      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogCliyjt(1)" type="primary">确 定</el-button>
        <el-button @click="dialogCliyjt(2)">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog
      title="信息上报审核"
      :visible.sync="taskstxxsh"
      width="50%"
      :close-on-press-escape="false"
      :show-close="true"
      :destroy-on-close="true"
      :modal-append-to-body="false"
      :close-on-click-modal="false"
      :fullscreen="true"
    >
      <div>
        <el-form :model="infolist" ref="infolist">
          <div style="height: calc(100vh - 180px); overflow-y: scroll">
            <orderCheck :infolist="infolist" :mini="1"></orderCheck>
            <div style="padding: 0 30px 0 20px" v-if="this.attList.length > 0">
              <uploadDown
                :datalist="datalist"
                :dialogStatus="uploadstatus"
              ></uploadDown>
            </div>
          </div>
        </el-form>
        <div slot="footer" class="dialog-footer myfooter">
          <el-button type="primary" @click="dialogClixx(1)">通 过</el-button>
          <el-button type="primary" @click="dialogClixx(3)">打 回</el-button>
          <el-button @click="dialogClixx(2)">取 消</el-button>
        </div>
      </div>
    </el-dialog>

    <el-dialog
      title="信息上报处理"
      :visible.sync="dialogStatusxx"
      width="50%"
      :close-on-press-escape="false"
      :show-close="true"
      :destroy-on-close="true"
      :modal-append-to-body="false"
      :close-on-click-modal="false"
      :fullscreen="true"
    >
      <div class="dialog-l">
        <el-tabs tab-position="left" v-model="activeName">
          <el-tab-pane
            v-for="item in routerListx"
            :key="item.label"
            :name="item.label"
            :label="item.name"
          >
          </el-tab-pane>
        </el-tabs>
      </div>

      <div class="dialog-r">
        <el-form
          :model="infolist"
          ref="infolist"
          :rules="rules"
          style="height: calc(100vh - 180px); overflow-y: scroll"
        >
          <div class="info-line">
            <el-form-item prop="msgTital">
              <span>上报标题</span>
              <el-input
                v-model="infolist.msgTital"
                placeholder="标题"
                :disabled="disableStatus"
              >
              </el-input>
            </el-form-item>
            <el-form-item prop="msgType">
              <span>信息分类</span>
              <el-select
                @change="changemsgType"
                v-model="infolist.msgType"
                placeholder="信息分类"
                clearable
                :disabled="disableStatus"
              >
                <el-option
                  v-for="item in typelist"
                  :key="item.id"
                  :label="item.msgType"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </div>

          <el-form-item
            prop="visiblec"
            class="info-line online"
            v-if="activeName == 1"
          >
            <span>接收人员</span>

            <deptTreeOnly
              class="tree"
              @treeCheck="treeCheckonly"
            ></deptTreeOnly>
            <div class="tree treeUser">
              <p>{{ treeListonly.leaderAuditName }}</p>
            </div>
          </el-form-item>

          <el-form-item
            prop="visiblec"
            class="info-line online"
            v-if="activeName == 2"
          >
            <span>接收人员</span>
            <div class="treedept">
              <p v-for="item in exaList" :key="item.loginNoStr">
                <el-checkbox
                  @change="exachange(item)"
                  v-model="item.sts"
                  style="margin-right: 10px"
                ></el-checkbox
                >{{ item.loginNameStr }}
              </p>
            </div>
          </el-form-item>

          <el-form-item class="info-line online" prop="msgInfo">
            <span>上报内容</span>
            <el-input
              v-model="infolist.msgInfo"
              placeholder="上报内容"
              type="textarea"
              :rows="3"
              :disabled="disableStatus"
            ></el-input>
          </el-form-item>

          <div style="padding-left: 80px" v-if="!disableStatus">
            <myUpload
              @uploadBack="uploadBack"
              :fileInfo="fileInfo"
              :fileList="fileInfo.fileList"
            >
            </myUpload>
          </div>
        </el-form>
        <div slot="footer" class="dialog-footer myfooter">
          <el-button @click="dialogCli(2)" v-if="disableStatus"
            >确 定</el-button
          >
          <el-button type="primary" @click="dialogCli(1)" v-if="!disableStatus"
            >确 定</el-button
          >
          <el-button @click="dialogCli(2)">取 消</el-button>
        </div>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import uploadDown from "../../../components/uploadDown";
import myUpload from "../../../components/upload.vue";
import deptTree from "../../../components/deptTreeUser.vue";
import deptTreeOnly from "../../../components/deptTreeOnly.vue";
import orderCheck from "../workOrderManage/orderCheck.vue";
import ruleCheck from "../warnManage/ruleCheck.vue";

export default {
  components: {
    uploadDown,
    myUpload,
    deptTree,
    deptTreeOnly,
    orderCheck,
    ruleCheck,
  },
  data() {
    const woTitle = (rule, value, callback) => {
      if (!this.infolist.woTitle) {
        callback(new Error("不能为空"));
      } else {
        callback();
      }
    };
    const requireTime = (rule, value, callback) => {
      if (!this.infolist.requireTime) {
        callback(new Error("不能为空"));
      } else {
        callback();
      }
    };
    return {
      rules: {
        woTitle: [
          {
            required: true,
            trigger: "blur",
            validator: woTitle,
          },
        ],
        requireTime: [
          {
            required: true,
            trigger: "change",
            validator: requireTime,
          },
        ],
      },
      noticeData: [],
      knowledgeData: [],
      srcsc: "",
      ifrshow: false,
      infolist: {},
      infolistyj: {},
      dialogStatus: false,
      dialogStatusyj: false,
      dialogStatusxx: false,
      diaKnowStatus: false,
      uploadstatus: false,
      datalist: {
        url: "/sysmgr/noticeatt/downfile",
        type: 1,
      },
      backlist: {
        url: "/sysmgr/noticeatt/downfile",
        type: 1,
      },
      datalistk: {
        url: "/market/compatt/downfile",
        type: 1,
      },
      attList: [],
      niticList: [],
      datalistn: {
        url: "/sysmgr/noticeatt/downfile",
        type: 1,
      },
      noticStatus: false,
      typelist: [],
      userInfo: {},
      knowledgeData: [],
      tableDatayj: [],
      btnsts: null,
      disableStatus: false,
      visiblec: [],
      typeOptions: [],
      fileInfo: {
        limit: 10,
        url: "/market/cwo/upload",
        fileList: [],
      },
      btnctrlStatus: false,
      tasksts: false,
      taskstsh: false,
      taskstyjsh: false,
      taskstxxsh: false,
      taskstcl: false,
      dialogInfo: false,
      treeList: [],
      treeListonly: [],
      activeName: "1",
      routerList: [
        {
          name: "其他人办理",
          label: "1",
        },
        {
          name: "领导审批",
          label: "2",
        },
        {
          name: "办理结束",
          label: "3",
        },
      ],
      routerListx: [
        {
          name: "上报",
          label: "1",
        },
        {
          name: "审批",
          label: "2",
        },
      ],
      historySts: false,
      dialogInfoyj: false,
      exaList: [],
    };
  },
  methods: {
    dialoginfoCli(v) {
      if (v == 1) {
        this.historySts = !this.historySts;
      } else if (v == 3) {
        this.dialogInfo = false;
        this.historySts = false;
        this.infolist = {};
      }
    },
    //新增待办工单
    dialogCliadd(v) {
      if (v === 2) {
        this.tasksts = false;
        return;
      } else if (v === 1) {
        let _this = this;
        let params = {};
        if (this.activeName == "1") {
          params.sts = "2";
          params.stsDesc = "待处理";
          params.auditName = this.treeListonly.leaderAuditName;
          params.auditNo = this.treeListonly.leaderAuditNo;
          params.leaderAuditName = this.treeListonly.leaderAuditName;
          params.leaderAuditNo = this.treeListonly.leaderAuditNo;
          if (!this.treeListonly.leaderAuditName) {
            this.$message({
              message: "请选择接单人！",
              type: "error",
            });
            return;
          }
        } else if (this.activeName == "2") {
          params.sts = "0";
          params.stsDesc = "待审核";
          params.auditName = this.userInfo.loginName;
          params.auditNo = this.userInfo.loginNo;
          params.leaderAuditName = this.treeListonly.leaderAuditName;
          params.leaderAuditNo = this.treeListonly.leaderAuditNo;
          if (!this.treeListonly.leaderAuditName) {
            this.$message({
              message: "请选择接单人！",
              type: "error",
            });
            return;
          }
        } else if (this.activeName == "3") {
          params.sts = "1";
          params.stsDesc = "已处理";
        }
        params.stepSts = this.activeName;
        params.sendNo = this.userInfo.loginNo;
        params.sendName = this.userInfo.loginName;
        params.woTitle = this.infolist.woTitle;
        params.arcDesc = this.infolist.arcDesc;
        params.sendTime = this.$formatDate(new Date(), "YYYY-MM-DD");
        params.requireTime = this.$formatDate(
          this.infolist.requireTime,
          "YYYY-MM-DD"
        );
        let attList = [];
        for (let i = 0; i < this.attList.length; i++) {
          attList.push({
            id: this.attList[i].id,
            fileCode: this.attList[i].fileCode,
            fileName: this.attList[i].fileName,
            opName: this.attList[i].opName,
            opNo: this.attList[i].opNo,
            opTime: this.attList[i].opTime,
            woNo: this.infolist.woNo,
          });
        }
        params.attList = attList;
        this.$http({
          url: "/market/cwo/add",
          method: "post",
          headers: {
            "Content-Type": "application/json",
          },
          data: params,
        }).then((res) => {
          if (res.data.result === 1) {
            _this.$message({
              message: res.data.desc,
              type: "error",
            });
          } else {
            _this.$message({
              message: "成功",
              type: "success",
            });
          }
          _this.tasksts = false;
          _this.treeListonly = {};
          _this.attList = [];
          _this.infolist = {};
        });
      }
    },
    //待办任务查询
    daiban() {
      this.$http({
        url: "/market/cwo/queryQaToDoList",
        method: "post",
        headers: {
          "Content-Type": "application/json",
          page: '{"pageNo":"' + 1 + '","pageSize":"100"}',
        },
        data: {},
      }).then((res) => {
        this.niticList = res.data.data;
      });
    },
    //待办任务详情
    checkNotic(n, v) {
      let u = "";
      let params = {};
      if (v.woTypeDesc == "工单") {
        u = "/market/cwo/queryInfo";
        params.woNo = v.woNo;
      } else if (v.woTypeDesc == "预警工单") {
        u = "/market/alarmCWo/Cquery";
        params.woNo = v.woNo;
      } else {
        u = "/market/cqamsg/queryInfo";
        params.id = v.woNo;
      }
      this.$http({
        url: u,
        method: "post",
        headers: {
          "Content-Type": "application/json",
        },
        data: params,
      }).then((res) => {
        this.activeName = v.stepSts;
        this.infolist = res.data;
        if (v.woTypeDesc == "信息上报") {
          this.infolist.id = res.data.id;
        } else {
          this.infolist.id = v.id;
        }
        if (n === 1) {
          this.datalist.attList = res.data.attList;
          if (v.woTypeDesc == "工单") {
            this.backlist.attList = res.data.revertAttList;
            this.dialogInfo = true;
          } else if (v.woTypeDesc == "预警工单") {
            this.infolist.attList = res.data.attList;
            this.dialogInfoyj = true;
          } else if (v.woTypeDesc == "信息上报") {
            this.infolist.id = res.data.id;
            this.infolist.attList = res.data.attList;
            this.dialogInfoyj = true;
          }
        } else if (n === 2) {
          this.activeName = "3";
          if (v.woTypeDesc == "工单") {
            this.taskstcl = true;
          } else if (v.woTypeDesc == "预警工单") {
            this.infolist.attList = res.data.attList;
            this.datalist.attList = res.data.attList;
            this.dialogStatusyj = true;
          } else if (v.woTypeDesc == "信息上报") {
            this.infolist.id = res.data.id;
            this.infolist.attList = res.data.attList;
            this.datalist.attList = res.data.attList;
            this.dialogStatusxx = true;
          }
        } else if (n === 3) {
          if (v.woTypeDesc == "工单") {
            this.taskstsh = true;
          } else if (v.woTypeDesc == "预警工单") {
            this.taskstyjsh = true;
            this.infolist.attList = res.data.attList;
            this.datalist.attList = res.data.attList;
          } else if (v.woTypeDesc == "信息上报") {
            this.infolist.id = res.data.id;
            this.taskstxxsh = true;
            this.infolist.attList = res.data.attList;
            this.datalist.attList = res.data.attList;
          }
          this.activeName = "2";
        }
        this.attList = [];
        this.fileInfo.fileList = [];
        if (res.data.attList) {
          res.data.attList.forEach((item) => {
            this.fileInfo.fileList.push({
              name: item.fileName,
              url: "",
              id: item.id,
              fileName: item.fileName,
              fileCode: item.fileCode,
            });
            this.attList.push({
              name: item.fileName,
              url: "",
              id: item.id,
              fileName: item.fileName,
              fileCode: item.fileCode,
            });
          });
        }
      });
    },
    //审核待办工单
    dialogCliup(v) {
      if (v === 2) {
        this.taskstsh = false;
        return;
      }
      let params = {
        woNo: this.infolist.woNo,
        taskId: this.infolist.taskId,
        woTitle: this.infolist.woTitle,
        sts: "4",
        stsDesc: v === 3 ? "通过" : "打回",
      };
      params.leaderAuditName = this.infolist.auditName;
      params.leaderAuditNo = this.infolist.auditNo;
      params.stepSts = this.activeName;
      if (this.infolist.auditNo != this.infolist.sendNo) {
        params.sts = "2";
        params.stsDesc = "待处理";
      }
      if (this.activeName == "1") {
        params.sts = "0";
        params.stsDesc = "待审核";
        params.leaderAuditName = this.treeListonly.leaderAuditName;
        params.leaderAuditNo = this.treeListonly.leaderAuditNo;
        if (!this.treeListonly.leaderAuditName) {
          this.$message({
            message: "请选择接单人！",
            type: "error",
          });
          return;
        }
      } else if (this.activeName == "3") {
        params.sts = "1";
        params.stsDesc = "已处理";
      }
      this.submitdaiban("/market/cwo/chkWoInfo", params);
    },
    //回复待办工单
    dialogClicl(v) {
      if (v == 1) {
        this.infolist = {};
        this.taskstcl = false;
        return;
      } else if (v == 2) {
        let params = {
          woNo: this.infolist.woNo,
          woTitle: this.infolist.woTitle,
          dealRemark: this.infolist.dealRemark,
          revertAttList: [],
        };
        if (this.activeName == "1") {
          params.sts = "2";
          params.stsDesc = "待处理";
          params.auditName = this.treeListonly.leaderAuditName;
          params.auditNo = this.treeListonly.leaderAuditNo;
          if (!this.treeListonly.leaderAuditName) {
            this.$message({
              message: "请选择接单人！",
              type: "error",
            });
            return;
          }
        } else if (this.activeName == "2") {
          params.sts = "0";
          params.stsDesc = "待审核";
          params.leaderAuditName = this.treeListonly.leaderAuditName;
          params.leaderAuditNo = this.treeListonly.leaderAuditNo;
          if (!this.treeListonly.leaderAuditName) {
            this.$message({
              message: "请选择接单人！",
              type: "error",
            });
            return;
          }
        } else if (this.activeName == "3") {
          params.sts = "1";
          params.stsDesc = "已处理";
        }
        let attList = [];
        for (let i = 0; i < this.attList.length; i++) {
          attList.push({
            id: this.attList[i].id,
            fileCode: this.attList[i].fileCode,
            fileName: this.attList[i].fileName,
          });
        }
        params.revertAttList = attList;
        params.stepSts = this.activeName;
        this.submitdaiban("/market/cwo/recWoInfo", params);
      }
    },
    //调用接口
    submitdaiban(u, params) {
      let _this = this;
      this.$http({
        url: u,
        method: "post",
        headers: {
          "Content-Type": "application/json",
        },
        data: params,
      }).then((res) => {
        if (res.data.result === 1) {
          _this.$message({
            message: res.data.desc,
            type: "error",
          });
        } else {
          _this.$message({
            message: "成功",
            type: "success",
          });
          _this.infolist = {};
          _this.taskstsh = false;
          _this.taskstcl = false;
          _this.treeListonly = {};
          _this.daiban();
        }
      });
    },

    //已办列表
    getListyj() {
      let _this = this;
      this.$http({
        url: "/market/cwo/queryQaFinishList",
        method: "post",
        headers: {
          "Content-Type": "application/json",
          page: '{"pageNo":"' + 1 + '","pageSize":"100"}',
        },
        data: {},
      }).then((res) => {
        this.tableDatayj = res.data.data;
      });
    },
    dialogCliyj(v) {
      if (v === 2) {
        this.infolist = {};
        this.taskstyjsh = false;
        return;
      }
      let info = {};
      info.woNo = this.infolist.woNo;
      info.auditRemarks = this.infolist.auditRemarks;
      info.auditTime = this.$formatDate(new Date(), "YYYY-MM-DD");
      info.auditName = this.userInfo.loginName;
      info.auditNo = this.userInfo.loginNo;
      info.auditRemarks = this.infolist.auditRemarks;
      if (v == 3) {
        info.sts = "1";
        info.stsDesc = "通过";
      } else {
        info.sts = "2";
        info.stsDesc = "打回";
      }
      this.submitInfoyj("/market/alarmCWo/examineAlarmWo", info);
    },
    submitInfoyj(u, v) {
      let _this = this;
      this.$refs.infolist.validate((valid) => {
        if (valid) {
          this.$http({
            url: u,
            method: "post",
            headers: {
              "Content-Type": "application/json",
            },
            data: v,
          }).then((res) => {
            if (res.data.result === 1) {
              _this.$message({
                message: res.data.desc,
                type: "error",
              });
            } else {
              _this.$message({
                message: "成功",
                type: "success",
              });

              _this.infolist = {};
              _this.taskstyjsh = false;
              _this.daiban();
            }
          });
        }
      });
    },
    dialoginfoCliyj(v) {
      if (v == 1) {
        this.historySts = !this.historySts;
      } else if (v == 2) {
        this.btnsts = 3;
        this.titname = "审核";
        this.dialogInfoyj = false;
        this.dialogStatus = true;
        this.historySts = false;
      } else if (v == 3) {
        this.dialogInfoyj = false;
        this.infolist = {};
        this.fileInfo.fileList = [];
        this.historySts = false;
      }
    },
    dialogCliyjt(v) {
      if (v === 2) {
        this.infolist = {};
        this.dialogStatusyj = false;
        return;
      }
      let info = {};
      info.woNo = this.infolist.woNo;
      info.woName = this.infolist.woName;
      info.replyDesc = this.infolist.replyDesc;
      let attList = [];
      for (let i = 0; i < this.attList.length; i++) {
        attList.push({
          id: this.attList[i].id,
          fileCode: this.attList[i].fileCode,
          fileName: this.attList[i].fileName,
          woNo: this.infolist.woNo,
        });
      }
      info.attList = attList;
      if (this.activeName == "1") {
        info.sts = "0";
        info.stsDesc = "待回复";
        info.receiveName = this.treeListonly.leaderAuditName;
        info.receiveNo = this.treeListonly.leaderAuditNo;
        this.submitInfot("/market/alarmCWo/redeploySQaAlarmWo", info);
      } else if (this.activeName == "2") {
        info.sts = "1";
        info.stsDesc = "待审核";
        info.auditName = this.treeListonly.leaderAuditName;
        info.auditNo = this.treeListonly.leaderAuditNo;
        this.submitInfot("/market/alarmCWo/replyAlarmWo", info);
      }
    },
    submitInfot(u, v) {
      let _this = this;
      this.$refs.infolist.validate((valid) => {
        if (valid) {
          this.$http({
            url: u,
            method: "post",
            headers: {
              "Content-Type": "application/json",
            },
            data: v,
          }).then((res) => {
            if (res.data.result === 1) {
              _this.$message({
                message: res.data.desc,
                type: "error",
              });
            } else {
              _this.$message({
                message: "成功",
                type: "success",
              });

              _this.infolist = {};
              _this.dialogStatusyj = false;
              _this.daiban();
            }
          });
        }
      });
    },

    dialogClixx(v) {
      this.datalist.attList = [];
      if (v === 2) {
        this.fileInfo.fileList = [];
        this.infolist = {};
        this.taskstxxsh = false;
        return;
      }
      let info = {};
      info.auditTime = this.$formatDate(new Date(), "YYYY-MM-DD");
      info.auditNo = this.userInfo.loginNo;
      info.auditName = this.userInfo.loginName;
      info.id = this.infolist.id;
      info.auditResultRemark = this.infolist.auditResultRemark;
      if (v === 1) {
        info.dealType = "2";
        info.stsDesc = "通过";
      } else {
        info.dealType = "3";
        info.stsDesc = "打回";
      }
      this.submitInfoxx("/market/cqamsg/chkQaMsg", info);
    },
    submitInfoxx(u, v) {
      let _this = this;
      this.$refs.infolist.validate((valid) => {
        if (valid) {
          this.loadinged = true;
          this.$http({
            url: u,
            method: "post",
            headers: {
              "Content-Type": "application/json",
            },
            data: v,
          }).then((res) => {
            this.loadinged = false;
            if (res.data.result === 1) {
              _this.$message({
                message: res.data.desc,
                type: "error",
              });
            } else {
              _this.$message({
                message: "成功",
                type: "success",
              });
              _this.fileInfo.fileList = [];
              _this.infolist = {};
              _this.infolist.deptCode = "";
              _this.taskstxxsh = false;
              _this.daiban();
            }
          });
        }
      });
    },

    //文件返回值
    uploadBack(v) {
      this.attList = v;
    },
    treeCheckonly(v) {
      this.treeListonly = v;
    },
    //发起工单
    newtask() {
      this.tasksts = true;
    },
    changemsgType() {
      for (let i = 0; i < this.typelist.length; i++) {
        if (this.infolist.msgType === this.typelist[i].id) {
          this.infolist.msgTypeName = this.typelist[i].msgType;
        }
      }
    },
    getType() {
      this.$http({
        url: "/market/qatype/queryPage",
        method: "post",
        headers: {
          "Content-Type": "application/json",
          page: '{"pageNo":"' + 1 + '","pageSize":"100"}',
        },
        data: {
          sts: 0,
        },
      }).then((res) => {
        this.typelist = res.data.data;
      });
    },
    exachange(v) {
      for (let i = 0; i < this.exaList.length; i++) {
        this.exaList[i].sts = false;
        if (this.exaList[i].id == v.id) {
          this.exaList[i].sts = true;
          let opt = {
            leaderAuditNo: this.exaList[i].loginNoStr,
            leaderAuditName: this.exaList[i].loginNameStr,
            displayname: this.exaList[i].groupName,
          };
          this.treeListonly = opt;
        }
      }
      this.$forceUpdate();
    },
    //获取人员
    getDepot() {
      this.$http({
        url: "/sysmgr/csysuserinfo/queryOwnDeptUserListByLoginNo",
        method: "post",
        headers: {
          "Content-Type": "application/json",
        },
        data: {},
      }).then((res) => {
        this.exaList = res.data;
      });
    },
  },
  mounted() {
    this.daiban();
    this.getType();
    this.getListyj();
    this.userInfo = JSON.parse(window.sessionStorage.userInfo);
  },
  created() {},
};
</script>

<style lang="scss" scoped>
.dialog-footer {
  padding-right: 20px;
  text-align: right;
  margin-top: 20px;
}

.taskbox {
  width: 49.5%;
  display: inline-block;
}

.tit {
  margin-top: 10px;
  clear: both;
  height: 47px;
  background: #fff;
  line-height: 47px;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid black;
}

.info-line {
  width: 100%;
  display: block;
  padding-left: 20px;

  div {
    width: 50%;
    display: inline-block;
    overflow: hidden;
  }

  .mytxt {
    height: 40px;
    padding-left: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    width: calc(100% - 100px);
    float: left;
  }

  .mytxtinfo {
    line-height: 40px;
    height: auto;
    padding-left: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    width: calc(100% - 100px);
  }

  span {
    width: 80px;
    display: inline-block;
    text-align: left;
    float: left;

    i {
      color: red;
      display: inline-block;
      padding-right: 5px;
    }
  }

  .el-select,
  .el-input {
    width: calc(100% - 100px);
  }
}

.online {
  width: 100%;

  .el-select {
    width: calc(100% - 100px);
  }

  span {
    vertical-align: top;
  }

  .el-textarea {
    width: calc(100% - 100px);
  }

  .tree {
    width: calc(50% - 60px);
    display: inline-block;
    margin-right: 20px;
    height: 300px;
    overflow-y: scroll;
  }

  .treeUser {
    margin: 0;
    border: 1px solid #ddd;

    p {
      background: #f4f4f4;
      padding: 0 20px;
      margin-bottom: 5px;
    }
  }

  .treeUserb {
    width: calc(100% - 100px);
    border: 1px solid #ddd;
    background: #f4f4f4;
    border-radius: 3px;
    height: auto;
    overflow: hidden;

    p {
      display: inline-block;
      padding: 0 20px;
      margin-bottom: 5px;
    }
  }
  .treedept {
    width: calc(100% - 100px);
    // display: inline-block;
    margin-right: 20px;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 0 20px;

    p {
      display: inline-block;
      margin-right: 20px;
    }
  }
}
</style>
