<template>
  <div>
    <el-button
      size="mini"
      type="text"
      :icon="icon"
      @click="_handleView"
    >{{ type === '0' ? '办理' : '详情' }}</el-button>
<!--    <el-button-->
<!--      size="mini"-->
<!--      type="text"-->
<!--      icon="el-icon-user"-->
<!--      @click="handleViewUserList"-->
<!--      v-show="type === 'todo'"-->
<!--    >转办</el-button>-->
<!--    <el-button-->
<!--      size="mini"-->
<!--      type="text"-->
<!--      icon="el-icon-time"-->
<!--      @click="handleViewHistoryList"-->
<!--      v-show="row.taskId !== '-2'"-->
<!--    >审批历史</el-button>-->
    <el-button
      size="mini"
      type="text"
      icon="el-icon-search"
      @click="handleViewProcessImg"
      v-show="row.taskId !== '-2'"
    >进度查看</el-button>
<!--    <el-button-->
<!--      size="mini"-->
<!--      type="text"-->
<!--      icon="el-icon-back"-->
<!--      @click="handleCancel"-->
<!--      v-show="row.taskId !== '-1' && row.taskId !== '-2' && type === 'none'"-->
<!--    >撤销</el-button>-->
<!--    <el-button-->
<!--      size="mini"-->
<!--      type="text"-->
<!--      icon="el-icon-sort"-->
<!--      @click="handleState"-->
<!--      v-show="row.taskId !== '-1' && row.taskId !== '-2' && type === 'none'"-->
<!--    >{{ row.suspendState === '2' ? '激活' : '挂起' }}</el-button>-->

    <!--业务表单子组件-->
    <demo-form
      v-if="row.processKey === 'exampleDemo'"
      :row="row"
      :taskId="taskId"
      :taskName="taskName"
      :type="type"
      ref="demoForm"
    ></demo-form>
    <leave-form
      v-if="row.processKey === 'leave'"
      :row="row"
      :taskId="taskId"
      :taskName="taskName"
      :type="type"
      ref="leaveForm"
    ></leave-form>
<!--    <leave-form-->
<!--      v-if="row.processKey === 'customerSignKey'"-->
<!--      :row="row"-->
<!--      :rowData="rowData"-->
<!--      :taskId="taskId"-->
<!--      :imgList="imgList"-->
<!--      :previewsrcList="previewsrcList"-->
<!--      :taskName="taskName"-->
<!--      :type="type"-->
<!--      ref="leaveForm"-->
<!--    ></leave-form>-->
    <el-dialog :title="title" :visible.sync="openAPP" width="1000px" append-to-body class="mbt0 zDialogpd">
      <div style="width: 100%;padding-bottom: 26px;">
        <el-form ref="form" v-loading="loadings" :inline="true" label-width="120px">
          <div v-if="row.itemType=='dkhqy'">
            <el-form-item label="签约门店:" prop="storeName">{{rowData.storeName}}</el-form-item>
            <el-form-item label="门店类型:" prop="storeCategory">{{selectDictLabel(storeCategoryOptions,rowData.storeCategory)}}</el-form-item>
            <el-form-item label="申请人:" prop="signYear">{{rowData.nickName}}</el-form-item>
            <el-form-item label="签约年份:" prop="signYear">{{rowData.signYear}}</el-form-item>
            <el-form-item label="申请时间:" prop="signYear">{{rowData.createTime}}</el-form-item>
          </div>
          <div v-else>
            <el-row>
              <el-col :span="16">
                <el-form-item label="门店名称:">
                  <span>{{rowData.storeName}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="门店组织:">
                  <span>{{rowData.deptName}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="上级门店组织:">
                  <span>{{rowData.parentDeptName}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="拜访人:">
                  <span>{{rowData.nickName}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="拜访日期:">
                  <span>{{rowData.visitsTime}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="进店:" >
                  <span>{{rowData.startTime}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="离店:">
                  <span>{{rowData.stopTime}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="拜访用时(分钟):">
                  <span>{{rowData.dwellTime}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="定位城市:">
                  <span>{{rowData.locationCity}}</span>
                </el-form-item>
              </el-col>
              <!--        <el-col :span="8">-->
              <!--          <el-form-item label="时间来源:">-->
              <!--            <span>{{visitForm.userName}}</span>-->
              <!--          </el-form-item>-->
              <!--        </el-col>-->
              <el-col :span="24">
                <el-form-item label="定位描述:" class="w85">
                  <span>{{rowData.locationRemark}}</span>
                </el-form-item>
              </el-col>
              <!--        <el-col :span="8">-->
              <!--          <el-form-item label="定位状态:">-->
              <!--            <span>{{visitForm.userName}}</span>-->
              <!--          </el-form-item>-->
              <!--        </el-col>-->
              <el-col :span="24">
                <el-form-item label="异常事由:" class="w85">
                  <span>{{rowData.abnormalReasonStr}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="24" v-if="updateTimeShow">
                <el-form-item label="更新时间:" class="w85">
                  <span>{{rowData.updateTime}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="备注:" class="w85">
                  <span>{{rowData.remark}}</span>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <div style="border-bottom: 3px solid #dfe4ed;height: 40px;margin-bottom: 24px;">
            <el-tabs v-model="activeName"  style="width:300px;margin: 0 auto">
              <el-tab-pane label="采集项" name="first"></el-tab-pane>
              <el-tab-pane label="坎级类型" name="second" v-if="rowData.kjCollectionAnswers!=null"></el-tab-pane>
<!--              <el-tab-pane label="历史签约" name="three" v-if="visitForm.kjCollectionAnswers!=null"></el-tab-pane>-->
            </el-tabs>
          </div>
<!--          <div v-if="activeName=='three'">-->
<!--            <el-table v-loading="loading" :data="historyList" v-if="historyList.length>0">-->
<!--              <el-table-column label="审批人" align="center" prop="assigneeName" width="150" />-->
<!--              <el-table-column label="审批意见" align="center" prop="comment"/>-->
<!--              <el-table-column label="审批时间" align="center" prop="endTime" width="150">-->
<!--                <template slot-scope="scope">-->
<!--                  <span>{{scope.row.endTime}}</span>-->
<!--                </template>-->
<!--              </el-table-column>-->
<!--            </el-table>-->
<!--          </div>-->
          <div v-if="activeName=='second'">
            <div v-for="(item,index) in rowData.kjCollectionAnswers" :key="index">
              <div class="title" style="text-align: center;margin: 0;padding: 20px;font-weight: bold;">{{item.kjTaskName}}</div>
              <el-table   :data="item.groupInfos">
                <el-table-column label="坎级名称" align="left" prop="storeGroupName" />
              </el-table>
              <el-table  :data="item.collectionAnswers">
                <el-table-column label="任务" align="left" prop="taskName" />
                <el-table-column label="采集项名称" align="left" prop="itemName"></el-table-column>
                <el-table-column label="采集项说明" align="left" prop="optionName"/>
                <el-table-column label="回答值" align="left" prop="answerValue" />
              </el-table>
            </div>
            <div class="title mt10" >
              照片类型
              <el-select v-model="type1" multiple collapse-tags placeholder="请选择" size="mini" style="margin-left: 10px;" @change="getQueryPhoto1">
                <el-option label="铺货任务" value="1"></el-option>
                <el-option label="陈列任务" value="2"></el-option>
                <el-option label="奖励任务" value="3"></el-option>
              </el-select>
            </div>
            <el-row class="mt10" :gutter="20" style="padding: 0 20px;">
              <el-col :span="4" v-for="(item,index) in imgList1" :key="index">
                <el-image
                  :src="item.fileUrl"
                  :preview-src-list="previewsrcList1" class="imagePic">
                </el-image>
              </el-col>
            </el-row>
          </div>
          <div v-if="activeName=='first'">
          <el-table   :data="rowData.itemCollectionAnswers" height="200px">
            <el-table-column label="签约项" align="center" prop="taskName" />
            <el-table-column label="签约项名称" align="center" prop="itemName"></el-table-column>
            <el-table-column label="签约项说明" align="center" prop="optionName"/>
<!--            <el-table-column label="签约结果" align="center" prop="answerValue" width="100"/>-->
          </el-table>
            <div class="title mt10" v-if="rowData.productCollectionAnswers">
              <span v-if="!isCW">竞品采集项</span> <span v-if="isCW">库存议入</span></div>
            <el-table v-loading="loading" :data="rowData.productCollectionAnswers" v-if="rowData.productCollectionAnswers">
              <el-table-column label="任务" align="center" prop="taskName" />
              <!--      <el-table-column label="页签" align="center" prop="nickName" width="100" />-->
              <el-table-column label="采集项名称" align="center" prop="itemName"></el-table-column>
              <el-table-column label="采集项说明" align="center" prop="optionName">
                <template slot-scope="scope">
                  <span>{{optionNameFormat(scope.row,scope.column)}}</span>
                </template>
              </el-table-column>
              <el-table-column label="回答值" align="center" prop="answerValue" />
            </el-table>
          <div >
            <span style="font-size: 14px;color: #606266;font-weight: bold">签约照片</span>
            <el-select v-model="photoType" clearable  placeholder="请选择" size="mini" style="margin-left: 10px;" @change="getQueryPhoto">
              <el-option
                v-for="item in photoTypeOptions"
                :key="item.dictValue"
                :label="item.dictLabel"
                :value="item.dictValue">
              </el-option>
            </el-select>
          </div>
          <el-row class="mt10" :gutter="20">
            <el-col :span="4" v-for="(item,index) in imgList" :key="index">
              <el-image
                :src="item.fileUrl"
                :preview-src-list="previewsrcList" class="imagePic">
              </el-image>
            </el-col>
          </el-row>
          </div>
          <div style="margin-bottom: 10px;" v-if="historyList.length>0">
            <span style="font-size: 14px;color: #606266;font-weight: bold;padding-bottom: 10px;">历史审批</span>
          </div>
          <el-table v-loading="loading" :data="historyList" v-if="historyList.length>0">
            <el-table-column label="审批人" align="center" prop="assigneeName" width="150" />
            <el-table-column label="审批意见" align="center" prop="comment"/>
            <el-table-column label="审批时间" align="center" prop="endTime" width="150">
              <template slot-scope="scope">
                <span>{{scope.row.endTime}}</span>
              </template>
            </el-table-column>
          </el-table>
          <!--v-show="total>0"-->
          <pagination
            v-show="false"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getHistoryList"
          />
        </el-form>
      </div>
      <view-verify
        :open.sync="openAPP"
        :row="row"
        :taskId="taskId"
        :type="type"
      />
<!--      <div slot="footer" class="dialog-footer" style="text-align: right;">-->
<!--        <el-button @click="openAPP=false">关闭</el-button>-->
<!--      </div>-->

    </el-dialog>
    <!--进度查看对话框-->
    <el-dialog title="进度查看" :visible.sync="open" width="1000px" append-to-body>
      <div style="width: 100%; text-align: center;">
        <el-image
          :src="src"
          :preview-src-list="srcList">
        </el-image>
      </div>
      <div slot="footer" class="dialog-footer" style="text-align: right;">
        <el-button @click="close">关闭</el-button>
      </div>
    </el-dialog>

    <!--审批历史对话框-->
    <el-dialog title="审批历史" :visible.sync="showHistoryTable" width="1000px" append-to-body>
      <!--审批历史表格-->
      <div>
        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="70px">
          <el-form-item label="任务名称" prop="activityName">
            <el-input
              v-model="queryParams.activityName"
              placeholder="请输入任务名称"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="办理人ID" prop="assignee">
            <el-input
              v-model="queryParams.assignee"
              placeholder="请输入办理人ID"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item>
            <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getHistoryList"></right-toolbar>
        </el-row>

        <el-table v-loading="loading" :data="historyList">
          <el-table-column label="申请人" align="center" prop="applyUserName" width="150" />
          <el-table-column label="门店名称" align="center" prop="storeName" width="230"/>
          <el-table-column label="流程类型" align="center" prop="itemType">
            <template slot-scope="scope">
              <span>{{itemTypeFormat(scope.row,scope.column)}}</span>
            </template>
          </el-table-column>
          <el-table-column label="审批节点" align="center" prop="nodeName" width="150" />
          <el-table-column label="待办人" align="center" prop="todoUserName" width="150" />
        </el-table>

        <!--v-show="total>0"-->
        <pagination
          v-show="false"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getHistoryList"
        />
      </div>

      <div slot="footer" class="dialog-footer" style="text-align: right;">
        <el-button @click="showHistoryTable=false">关闭</el-button>
      </div>
    </el-dialog>

    <!--用户列表对话框-->
    <el-dialog title="选择用户" :visible.sync="showUserTable" width="900px" append-to-body>
      <!--用户列表表格-->
      <div>
        <el-form :model="queryUserParams" ref="queryUserForm" :inline="true" v-show="showUserSearch" label-width="68px">
          <el-form-item label="用户名称" prop="userName">
            <el-input
              v-model="queryUserParams.userName"
              placeholder="请输入用户名称"
              clearable
              size="small"
              style="width: 240px"
              @keyup.enter.native="handleUserQuery"
            />
          </el-form-item>
          <el-form-item label="手机号码" prop="phonenumber">
            <el-input
              v-model="queryUserParams.phonenumber"
              placeholder="请输入手机号码"
              clearable
              size="small"
              style="width: 240px"
              @keyup.enter.native="handleUserQuery"
            />
          </el-form-item>
          <el-form-item>
            <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleUserQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetUserQuery">重置</el-button>
          </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
          <right-toolbar :showSearch.sync="showUserSearch" @queryTable="getUserList"></right-toolbar>
        </el-row>

        <el-table v-loading="userLoading" :data="userList" @selection-change="handleUserSelectionChange">
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column label="用户编号" align="center" prop="userId" />
          <el-table-column label="用户名称" align="center" prop="userName" :show-overflow-tooltip="true" />
          <el-table-column label="用户昵称" align="center" prop="nickName" :show-overflow-tooltip="true" />
          <el-table-column label="部门" align="center" prop="dept.deptName" :show-overflow-tooltip="true" />
          <el-table-column label="手机号码" align="center" prop="phonenumber" width="120" />
          <el-table-column label="创建时间" align="center" prop="createTime" width="160">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime) }}</span>
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="userTotal>0"
          :total="userTotal"
          :page.sync="queryUserParams.pageNum"
          :limit.sync="queryUserParams.pageSize"
          @pagination="getUserList"
        />
      </div>
      <div slot="footer" class="dialog-footer" style="text-align: right;">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="showUserTable=false">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import request from '@/utils/request'
  import { format, formatTotalDateSub } from "@/utils/activiti/myUtil.js"
  import { listUser } from "@/api/system/user";
  import { getStoreCustomerSign} from "@/api/sfa/storeCustomerSign";
  import DemoForm from "@/views/example/demo/demoForm";
  import LeaveForm from "@/views/leave/leave/leaveForm";
  import ViewVerify from "@/components/Activiti/ViewVerify/index";
  import { getVisitResultsDetail,getQueryPhoto } from "@/api/sfa/visitResults";
  export default {
    name: "ApplyAfter",
    components: {DemoForm, LeaveForm,ViewVerify},
    props: {
      /* 表格行数据 */
      row: {
        type: Object,
      },
      taskId: {
        type: String,
      },
      taskName: {
        type: String,
      },
      type: {
        type: String,
        default: 'none',
      },
    },
    data() {
      return {
        open: false,
        loadings:true,
        src: '',
        srcList: [],
        photoTypeOptions:[],
        type1:['1'],
        previewsrcList1:[],imgList1:[],
        showHistoryTable: false,
        // 遮罩层
        loading: false,
        activeName: 'first',
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 999,
          processInstanceId: null,
          activityName: null,
          assignee: null,
        },
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        historyList: [],
        rowData:{},
        icon: this.type === '0' ? 'el-icon-check' : 'el-icon-document',
        // 选中行
        selectedRow: null,
        // 状态数据字典
        statusOptions: [],
        showUserTable: false,
        // 遮罩层
        title:"",
        userLoading: false,
        // 查询参数
        queryUserParams: {
          pageNum: 1,
          pageSize: 10,
          userName: undefined,
          phonenumber: undefined,
          status: undefined,
        },
        // 显示搜索条件
        showUserSearch: true,
        // 总条数
        userTotal: 0,
        userList: [],
        imgList:[],
        updateTimeShow:false,
        previewsrcList:[],
        storeCategoryOptions:[],
        openAPP:false,
        photoType:'',
        isCW:false,
        productAnswerOptions:[]
      }
    },
    create() {

      this.getDicts("sys_normal_disable").then(response => {
        this.statusOptions = response.data;
      });
      this.getDicts("activity_apply_form").then(response => {
        this.activityApplyFormOptions = response.data;
      });
      this.getDicts("activity_apply_type").then(response => {
        this.activityApplyTypeOptions = response.data;
      });
      this.getDicts("cw_store_type").then(response => {
        this.storeCategoryOptions = response.data;
      });
    },
    methods: {
      optionNameFormat(row, column){
        return this.selectDictLabel(this.productAnswerOptions, row.optionName);
      },
      statusFormat(row, column) {
        return this.selectDictLabel(this.activityApplyFormOptions, row.status);
      },
      itemTypeFormat(row, column) {
        return this.selectDictLabel(this.activityApplyTypeOptions, row.itemType);
      },
      // storeCategoryFormatters(val){
      //   return this.selectDictLabel(this.storeCategoryOptions, val);
      // },
      _handleView: function () {
        this.getDicts("cw_store_type").then(response => {
          this.storeCategoryOptions = response.data;
        });
        if("5,6,7,8".indexOf(this.$store.state.user.type)!=-1){
          this.isCW = true;
          this.getDicts("cw_product_answer_type").then(response => {
            this.productAnswerOptions = response.data;
          });
        }else{
          this.getDicts("sfa_product_answer_type").then(response => {
            this.productAnswerOptions = response.data;
          });
          this.isCW = false;
        }
        if(this.type==1){
          if(this.row.itemType=="dkhqy"){
          this.title="大户签约详情"
            var rowData={}
            getStoreCustomerSign(this.row.signId).then(res=>{
              rowData=res.data;
              this.rowData=res.data;
              this.imgList = res.data.sysFileInfoList;
              this.loadings=false;
              this.imgList.forEach((item,index)=>{
                item.fileUrl = item.fileUrl;
                this.previewsrcList.push(item.fileUrl);
              })
            })
          }else{
            this.title="陈列任务详情"
            getVisitResultsDetail(this.row.visitsId).then(res=>{
              this.rowData=res.data
              if(res.data.stopTime!=res.data.updateTime){
                this.updateTimeShow=true
              }else{
                this.updateTimeShow=false
              }
              this.loadings=false;
              if(this.rowData.visitRemarks!=null&&this.rowData.visitRemarks.length>0){
                this.rowData.visitRemarks[0].remarkContent=this.rowData.visitRemarks[0].remarkContent.replace(/\n/g,'<br>');
              }
            })
          }
        }else{
          if(this.row.itemType=="dkhqy"){
           this.title="大户签约审批"
            var rowData={}
            getStoreCustomerSign(this.row.signId).then(res=>{
              rowData=res.data;
              this.rowData=res.data;
              this.imgList = res.data.sysFileInfoList;
              this.loadings=false;
              this.imgList.forEach((item,index)=>{
                item.fileUrl = item.fileUrl;
                this.previewsrcList.push(item.fileUrl);
              })
            })
          }else{
            getVisitResultsDetail(this.row.visitsId).then(res=>{
              this.rowData=res.data
              this.loadings=false;
              if(res.data.stopTime!=res.data.updateTime){
                this.updateTimeShow=true
              }else{
                this.updateTimeShow=false
              }
              if(this.rowData.visitRemarks!=null&&this.rowData.visitRemarks.length>0){
                this.rowData.visitRemarks[0].remarkContent=this.rowData.visitRemarks[0].remarkContent.replace(/\n/g,'<br>');
              }
            })
            this.title="陈列任务审批"
          }
        }


        this.queryParams.processInstanceId = this.row.instanceId;
        this.queryParams.pageNum=1
        this.getHistoryList();
        this.getQueryPhoto();
        this.getQueryPhoto1();
        this.getDicts("sfa_task_photo_type").then(response => {
          this.photoTypeOptions = response.data;
        });
        switch (this.row.itemType) {
          case 'exampleDemo':
            this.$refs.demoForm.form = this.row;
            this.$refs.demoForm.open = true;
            break;
          case 'leave':
            this.$refs.leaveForm.form = this.row;
            this.$refs.leaveForm.open = true;
            break;
          case 'jlff':
            this.openAPP = true;
          case 'cljl':
            // this.$refs.leaveForm.form = rowData;
            this.openAPP = true;
            break;
          case 'ph':
            // this.$refs.leaveForm.form = rowData;
            this.openAPP = true;
            break;
          case 'dkhqy':
            // this.$refs.leaveForm.form = rowData;
            this.openAPP = true;
            break;
          default:
            break;
        }
      },
      handleState: function () {
        const instanceId = this.row.instanceId;
        const suspendState = this.row.suspendState;
        const opt = this.row.suspendState === '2' ? '激活': '挂起';
        this.$confirm('是否确认' + opt + 'ID为"' + instanceId + '"的流程实例?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function () {
          const data = { "instanceId": instanceId, "suspendState": suspendState };
          return request({
            url: '/activiti/process/suspendOrActiveApply',
            method: 'post',
            params: data
          });
        }).then(response => {
          this.$emit('getList');
          this.msgSuccess("操作成功");
        }).catch(function () {
        });
      },
      handleCancel: function () {
        const instanceId = this.row.instanceId;
        this.$confirm('是否确认撤销ID为"' + instanceId + '"的流程实例?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function () {
          const data = { "instanceId": instanceId };
          return request({
            url: '/activiti/process/cancelApply',
            method: 'post',
            params: data
          });
        }).then(response => {
          this.$emit('getList');
          this.msgSuccess("操作成功");
        }).catch(function () {
        });
      },
      handleViewProcessImg: function() {
        const baseURL = process.env.VUE_APP_BASE_API;
        this.src = baseURL + '/activiti/process/read-resource?pProcessInstanceId=' + this.row.instanceId + '&_=' + new Date().getTime();
        this.srcList = [];
        this.srcList.push(this.src);
        this.open = true;
      },
      close: function () {
        this.open = false;
      },
      handleViewHistoryList() {
        this.queryParams.processInstanceId = this.row.instanceId;
        this.showHistoryTable = true;
        this.getHistoryList();
      },
      getHistoryList: function () {
        this.loading = true;
        return request({
          url: '/activiti/process/listHistory',
          method: 'post',
          data: this.queryParams
        }).then(response => {
          this.historyList = response.rows;
          this.historyList.forEach(row => {
            row.startTime = format(row.startTime, 'yyyy-MM-dd HH:mm:ss');
            row.endTime = format(row.endTime, 'yyyy-MM-dd HH:mm:ss');
            row.durationInMillis = formatTotalDateSub(row.durationInMillis / 1000);
          });
          this.total = response.total;
          this.loading = false;
        }).then(() => {
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getHistoryList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      handleViewUserList() {
        this.showUserTable = true;
        this.getUserList();
      },
      /** 查询用户列表 */
      getUserList() {
        this.loading = true;
        listUser(this.queryUserParams).then(response => {
            this.userList = response.rows;
            this.userTotal = response.total;
            this.userLoading = false;
          }
        );
      },
      /** 搜索按钮操作 */
      handleUserQuery() {
        this.queryUserParams.page = 1;
        this.getUserList();
      },
      /** 重置按钮操作 */
      resetUserQuery() {
        this.resetForm("queryUserForm");
        this.handleUserQuery();
      },
      // 多选框选中数据
      handleUserSelectionChange(selection) {
        this.selectedRow = selection[0];
      },
      /** 提交按钮 */
      submitForm() {
        const taskId = this.taskId;
        const selectedRow = this.selectedRow;
        if (!selectedRow) {
          this.msgError('请先选择要转办的用户');
          return;
        }
        if (selectedRow.userName === this.$store.state.user.name) {
          this.msgError('不能转办给自己');
          return;
        }
        this.$confirm('是否确认转办给' + selectedRow.nickName + '?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return request({
            url: '/activiti/process/delegate',
            method: 'post',
            params: { "taskId": taskId, "delegateToUser": selectedRow.userName },
          });
        }).then(() => {
          this.$emit('getList');
          this.msgSuccess("操作成功");
          this.showUserTable = false;
        })
      },
      getQueryPhoto(){
        let obj = {
          visitId:this.row.visitsId,
          photoType:this.photoType,
          type:"0"
        };
        this.previewsrcList = [];
        this.imgList = [];
        getQueryPhoto(obj).then(response => {
          this.imgList = response.data;
          // let url = '';
          // process.env.NODE_ENV == 'development' ? url = process.env.VUE_APP_Target : url = process.env.VUE_APP_BASE_API;
          this.imgList.forEach((item,index)=>{
            item.fileUrl = item.fileUrl;
            this.previewsrcList.push(item.fileUrl);
          })
        });
      },
      getQueryPhoto1(){
        let query = this.$route.query;
        let obj = {
          visitId:query.id,
          photoType:"",
          types:this.type1.join(",")
        };
        this.previewsrcList1 = [];
        this.imgList1 = [];
        getQueryPhoto(obj).then(response => {
          console.log(response)
          this.imgList1 = response.data;
          // let url = '';
          // process.env.NODE_ENV == 'development' ? url = process.env.VUE_APP_Target : url = process.env.VUE_APP_BASE_API;
          this.imgList1.forEach((item,index)=>{
            item.fileUrl = item.fileUrl;
            this.previewsrcList1.push(item.fileUrl);
          })
        });
      },
    },
  }
</script>

<style scoped>

</style>
