<template>
  <div
    v-loading="loading"
    class="es-flow-form"
    element-loading-text="加载中..."
    element-loading-spinner="el-icon-loading"
    element-loading-background="rgba(255, 255,255, 0.8)"
    style="height: 100%"
  >
    <el-form
      ref="nextNode"
      :model="nextNode"
      class="es-reset-flow demo-dynamic"
      label-width="100px"
      label-position="left"
    >
      <div class="es-reset-flow-form-box">
        <el-form-item prop="nodeName" label="标题">
          <el-input v-model="pendtitle" disabled />
        </el-form-item>
        <el-form-item prop="nodeName" label="当前步骤">
          <el-input v-model="nextNode.nodeName" disabled />
        </el-form-item>
        <el-form-item prop="newOpinion" label="意见">
          <CommonOpinions class="opinions" :rows="3" @change="changeOpinion" />
        </el-form-item>
        <el-form-item
          prop="nextNode"
          label="下步节点"
          :rules="[
            { required: true, message: `请选择下步节点`, trigger: 'blur' }
          ]"
        >
          <el-select
            v-if="nextNodeCheckType == 'select'"
            v-model="nextNode.nextNode"
            :placeholder="`请选择下步节点`"
            @change="changeSel"
          >
            <el-option
              v-for="items in nextNode.nodeInfo"
              :key="items.nodeId"
              :label="items.nodeName"
              :value="items.nodeId"
            ></el-option>
          </el-select>
          <es-radio-group
            v-else-if="nextNodeCheckType == 'radio'"
            v-model="nextNode.nextNode"
            :data="nextNode.nodeInfo"
            @change="changeSel"
            value-key="nodeId"
            label-key="nodeName"
          ></es-radio-group>
        </el-form-item>
        <el-form-item
          v-if="countersignaturetypeCode != 0"
          prop="countersignaturetypeText"
          label="处理方式"
        >
          <el-input
            v-model="nextNode.countersignaturetypeText"
            placeholder="请输入内容"
            disabled
          />
        </el-form-item>
        <el-form-item prop="nextNode" label="办理角色" v-if="showRoleUser">
          <SelectUser
            :nextUser="nextNode.nextRoleId"
            :radioList="radioList"
            :multiple="multiple"
            :showTooltip="showTooltip"
            :isCustomUser="isCustomUser"
            :options="options"
            :presetEdit="presetEdit"
            :isDefSelectedObj="isDefSelectedObj"
            :selectUserList="selectUserList"
            @change="changeSelectUser"
            :types="nextUserTypes"
            :params="params"
          />
        </el-form-item>
        <!-- showRoleUser -->
        <el-form-item
          v-if="
            !showRoleUser &&
            nodeInfoExtAttr.nodeType != 1 &&
            nodeInfoExtAttr.nodeType != 2
          "
          :prop="isShowNextUser ? 'nextUser' : 'nextOrgId'"
          :label="isShowNextUser ? `${flowLabelConfig.nextUser||'下步办理人'}` : '办理对象'"
        >
          <SelectUser
            :nextUser="isShowNextUser ? nextNode.nextUser : nextNode.nextOrgId"
            :radioList="radioList"
            :multiple="multiple"
            :showTooltip="showTooltip"
            :isCustomUser="!isShowNextUser ? 1 : isCustomUser"
            :options="options"
            :presetEdit="presetEdit"
            :mix="multiple"
            :isDefSelectedObj="isDefSelectedObj"
            :selectUserList="selectUserList"
            @change="
              changeSelectUser(
                $event,
                isShowNextUser ? 'nextUser' : 'nextOrgId'
              )
            "
            :types="
              !isShowNextUser
                ? nextUserTypes
                : isCdjxjTaskHandle != 'true'
                ? ['employee', 'persongroup']
                : ['employee']
            "
            :params="isShowNextUser ? params : {}"
            :tabs="nextUserTabs"
          />
        </el-form-item>
        <el-form-item
          prop="nextReadUserId"
          v-if="isTaskread == 1"
          label="
             分阅用户
            "
        >
          <SelectUser
            :nextUser="nextNode.nextReadUserId"
            :multiple="true"
            :selectUserList="selectReadUserList"
            :showTooltip="showTooltip"
            :options="userOptions"
            title="分阅用户"
            :mix="true"
            :types="types"
            @change="changeSelectReadUser($event, 'nextReadUserId')"
            :tabs="tabs"
          />
        </el-form-item>
        <el-form-item
          prop="presetReadUserId"
          v-if="canPresetRead"
          label="
             自动分阅
            "
        >
          <SelectUser
            :nextUser="nextNode.presetReadUserId"
            :multiple="true"
            :selectUserList="selectPresetUserList"
            :options="presetOptions"
            :showTooltip="showTooltip"
            title="分阅用户"
            :radioList="presetReadUserId"
            :presetEdit="1"
            :mix="true"
            :types="types"
            @change="changeSelectReadUser($event, 'presetReadUserId')"
            :tabs="tabs"
          />
        </el-form-item>
        <el-form-item
          v-if="isHandleExplain == 1"
          prop="handleExplain"
          label="办理说明"
        >
          <el-input
            placeholder="请输入办理说明"
            v-model="nextNode.handleExplain"
          />
        </el-form-item>
        <el-form-item
          v-if="
            currentNodeEnableItemHandleDescription &&
            nextNode.nodeInfo.length != 0
          "
          prop="nextItemHandleDescription"
          label="办理说明"
        >
          <el-input
            placeholder="请输入办理说明"
            type="textarea"
            :autosize="{ minRows: 2 }"
            v-model="nextItemHandleDescription"
          />
        </el-form-item>
        <el-form-item v-show="nextNode.noticeList.length != 0 &&  !hideMessage" prop="noticeType" label="通知方式">
          <el-checkbox-group
            v-if="showNoticeType"
            v-model="nextNode.noticeType"
          >
            <el-checkbox
              v-for="item of nextNode.noticeList"
              :key="item.cciValue"
              :label="item.cciValue"
              :disabled="
                readOnlyNotificationType
                  ? readOnlyNotificationType.indexOf(item.cciValue) != -1
                  : false
              "
            >
              {{ item.shortName }}
            </el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item
          v-show="nextNode.noticeType.length != 0"
          prop="nextNode"
          label="通知消息"
        >
          <es-input
            style="
              border-color: #ccc;
              padding: 5px;
              border-radius: 5px;
              font-size: 13px;
            "
            type="textarea"
            v-model="nextNode.noticeInfo"
            :readonly="notificationMessageReadOnly"
          />
        </el-form-item>
      </div>
      <el-form-item style="margin-bottom: 0px">
        <div style="text-align: right">
          <el-button
            type="primary"
            @click="subProcess('nextNode')"
          >
            确认
          </el-button>
          <el-button  @click="quit"> 取消 </el-button>
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import {
  toResetProcessIndex,
  toTaskContinuationIndex,
  taskContinuation,
  getNodeInfo,
  findSysCodes,
  getNotificationMsg,
  findCodeValues,
  loginUserInfo,
  resetProcess
} from 'eoss-ui/src/config/api';
import util from 'eoss-ui/src/utils/util';
import SelectUser from './selectUser.vue';
import CommonOpinions from './component/CommonOpinions.vue';
export default {
  name: 'resetForm',

  components: {
    [Option.name]: Option,
    [SelectUser.name]: SelectUser,
    [CommonOpinions.name]: CommonOpinions
  },
  props: {
    flowParams: {
      type: Object,
      default: () => {}
    },
    showTooltip: { type: Boolean, default: true },
    subParams: {
      type: Object,
      default: () => {}
    },
    appId: {
      type: String,
      default: ''
    },
    type: { type: String },
    flowLabelConfig: { 
      type:Object,
      default: () => {return {}}
    },
    hideMessage: { type: Boolean, default: false },
  },
  data() {
    return {
      loading: false,
      isCustomUser: 0,
      selectUser: false,
      nextItemHandleDescription: '',
      nextNodeCheckType: 'select',
      currentNodeEnableItemHandleDescription: false,
      multiple: false,
      showNoticeType: false,
      readMultiple: true,
      customPresetHintMessage: '', //流程预设标题
      notificationMessageReadOnly: false,
      readOnlyNotificationType: '',
      show: true,
      radioList: [],
      activeNames: '',
      selectUserList: [],
      defaultNextNode: '',
      presetUserJson: [],
      isTaskread: 0, //是否显示分阅用户
      isHandleExplain: 0, //是否展示办理说明
      isOpinionRequired: 0,
      options: [],
      presetList: [],
      presetReadUserId: [], //自动分阅
      canPresetRead: false, //是否展示自动分阅
      nextUserTypes: ['employee', 'persongroup'],
      isSinglePage: false,
      presetEdit: 0,
      taskExamine: {},
      isDefSelectedObj: 0,
      isChooseNextNode: 0,
      isHideDefaultOperation: 0,
      countersignaturetypeCode: 0,
      presetTaskNodeKeyStr: '', //预设办理人顺序
      presetTaskNodeMap: {}, //预设办理人
      params: {
        filid: 'all', //选择范围(my:本单位/ "" or all:全部)
        selectmix: 'true1',
        deptid: '' //指定部门(my:本部门)
      },
      newOpinion: '',
      operationList: [],
      tabs: {
        employee: {
          param: {
            filid: JSON.parse(util.getStorage('mainConfig')).userModel.orgId,
            name: '本单位用户'
          }
        },
        department: {
          param: {
            filid: JSON.parse(util.getStorage('mainConfig')).userModel.orgId
          }
        }
      },
      userModel: {},
      nextUserTabs: {},
      selectPresetUserList: [],
      presetOptions: [],
      selectReadUserList: [],
      userOptions: [],
      mixReadList: [],
      mixPresetList: [],
      nodeInfoExtAttr: {},
      isCdjxjTaskHandle: '',
      isShowNextUser: true,
      showRoleUser: false,
      pendtitle: '',
      mixOrgIdList: [], //办理对象混选
      nextNode: {
        nodeName: '',
        newOpinion: '',
        countersignaturetypeText: '',
        nextNode: '',
        nextReadUserId: [],
        nextOrgId: [],
        noticeType: [],
        nextOperate: '1',
        nextUser: [],
        presetReadUserId: [], //自动分阅
        noticeInfo: '',
        nodeInfo: [],
        userInfo: [],
        handleExplain: '',
        noticeList: []
      }
    };
  },
  computed: {
    types() {
      if (this.isCdjxjTaskHandle == 'true') {
        return ['employee', 'enterprise', 'department'];
      } else {
        return ['employee', 'enterprise', 'department', 'persongroup'];
      }
    }
  },
  created() {
    this.getUserInfo();
    this.getResetFlow();
  },
  mounted() {},
  methods: {
    changeOpinion(val) {
      this.nextNode.newOpinion = val;
    },
    getUserInfo() {
      let mainConfig = util.getStorage('mainConfig');
      if (mainConfig) {
        this.userModel = JSON.parse(mainConfig).userModel;
      } else {
        util
          .ajax({ url: loginUserInfo })
          .then((res) => {
            const { status, data } = res;
            if (status == 'success') {
              this.userModel = data;
            } else {
              let msg = res.msg || '系统错误，请联系管理员！';
              this.$message.error(msg);
            }
          })
          .catch((err) => {
            if (err.message && err.message !== 'canceled') {
              this.$message.error(err.message);
            }
          });
      }
    },
    getIsShowNextUser(val) {
      if (
        val == 7 ||
        val == 8 ||
        val == 9 ||
        val == 10 ||
        val == 11 ||
        val == 12
      ) {
        this.isShowNextUser = false;
        //设置办理角色
        // $("#orgRoleCode").val(handleRoleId);
        if (val == 7 || val == 8) {
          this.nextUserTypes = ['department'];
          this.nextUserTabs = {
            department: {
              param: {
                filid: JSON.parse(util.getStorage('mainConfig')).userModel.orgId
              }
            }
          };
          this.multiple = true;
        } else if (val == 9 || val == 10) {
          this.nextUserTypes = ['enterprise'];
          this.nextUserTabs = { enterprise: { param: { filid: 'other' } } };
          this.multiple = true;
        } else if (val == 11 || val == 12) {
          this.nextUserTypes = ['department', 'enterprise'];
          this.nextUserTabs = {
            enterprise: { param: { filid: 'other' } },
            department: {
              param: {
                filid: JSON.parse(util.getStorage('mainConfig')).userModel.orgId
              }
            }
          };
          this.multiple = true;
        }
      }
      if (val == 7 || val == 9 || val == 11) {
        this.multiple = false;
      }
    },
    // 分阅是否多选
    isReadMultiple(nextReadUserSelectType) {
      if (nextReadUserSelectType == 1) {
        this.readMultiple = false;
      } else if (nextReadUserSelectType == 2) {
        this.readMultiple = true;
      } else if (nextReadUserSelectType == 3) {
        this.readMultiple = false;
      } else if (nextReadUserSelectType == 4) {
        this.readMultiple = true;
      } else if (nextReadUserSelectType == 5) {
        this.readMultiple = false;
      } else if (nextReadUserSelectType == 6) {
        this.readMultiple = true;
      }
    },
    changeSelectReadUser(val, type) {
      const { nextUser, mixList } = val;
      this.nextNode[type] = nextUser;
      if (type === 'presetReadUserId') {
        this.mixPresetList = mixList;
      } else {
        this.mixReadList = mixList;
      }
    },
    changeSelectUser(val, type) {
      const { nextUser, options, mixList } = val;
      this.nextNode[type] = nextUser;
      this.mixOrgIdList = mixList;
    },
    getNodeType() {
      util
        .ajax({
          url: findCodeValues,
          params: {
            ccCode: 'notification_type',
            userId: util.getStorage('userId')
          }
        })
        .then((res) => {
          const { status, data } = res;
          if (status === 'success') {
            this.nextNode.noticeList = data;
            this.getFind();
          }
        })
        .catch((err) => {
          this.loading = false;
          if (err.message && err.message !== 'canceled') {
            this.$message.error(err.message);
          }
        });
    },
    //获取通知信息
    getMessage() {
      let params = {
        processDefinitionId: this.processDefinitionId,
        nodeId: this.nextNode.nextNode,
        businessId: this.taskExamine.businessId
      };
      util
        .ajax({ url: getNotificationMsg, params, methods: 'post' })
        .then((res) => {
          if (res.status === 'success') {
            this.nextNode.noticeInfo = res.message;
          }
        })
        .catch((err) => {
          this.loading = false;
          if (err.message && err.message !== 'canceled') {
            this.$message.error(err.message);
          }
        });
    },
    // 提交表单
    subProcess(formName) {
      this.saveProcess(formName);
    },
    saveProcess(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          const {
            nextNode,
            nextUser,
            noticeInfo,
            noticeType,
            handleExplain,
            presetReadUserId,
            nextReadUserId,
            nextOrgId,
            nextRoleId,
            nextOperate,
            newOpinion
          } = this.nextNode;
          // if (noticeType.length === 0) {
          //   return this.$message.warning('请选择通知方式');
          // }
          if (
            this.nodeInfoExtAttr.nodeType != 1 &&
            this.nodeInfoExtAttr.nodeType != 2 &&
            !this.showRoleUser
          ) {
            if (this.isShowNextUser) {
              if (nextUser == '' || (this.multiple && nextUser.length == 0)) {
                return this.$message.warning(`请选择${this.flowLabelConfig.nextUser || '下步办理人'}`);
              }
            } else {
              if (nextOrgId == '' || (this.multiple && nextOrgId.length == 0)) {
                return this.$message.warning('请选择办理对象');
              }
            }
          }
          if (
            (this.showRoleUser && nextRoleId == '') ||
            (this.multiple && nextUser.length == 0)
          ) {
            return this.$message.warning('请选择办理角色');
          }
          if (this.isOpinionRequired && !this.newOpinion && !newOpinion) {
            return this.$message.warning('请选择输入审批意见');
          }
          this.loading = true;
          let newNextUser = [];
          if (this.multiple) {
            nextUser && nextUser.map((item) => newNextUser.push(item));
          }
          let newNoticeType = '';
          if (noticeType) {
            newNoticeType = noticeType.join(',');
          }
          let params = {
            processDefinitionId: this.processDefinitionId,
            nextUserId: this.multiple ? newNextUser.join(',') : nextUser,
            nextNodeId: nextNode,
            appId: this.appId,
            nextOperate: nextOperate,
            businessId: this.taskExamine.businessId,
            pendingId: this.taskExamine.pendingId,
            notificationType: newNoticeType,
            userId: util.getStorage('userId'),
            notificationMsg: noticeInfo,
            customPresetUserJson: JSON.stringify(this.presetList),
            presetUserJson: JSON.stringify(this.presetUserJson),
            nextReadUserId: this.readMultiple
              ? this.mixReadList && this.mixReadList.join('|')
              : nextReadUserId,
            nextOrgId: !this.isShowNextUser
              ? this.multiple
                ? this.mixOrgIdList && this.mixOrgIdList.join('|')
                : nextOrgId
              : '',
            handleExplain: handleExplain,
            presetReadUserId:
              this.mixPresetList && this.mixPresetList.length > 0
                ? this.mixPresetList.join('|')
                : presetReadUserId.join(','),
            opinion: this.newOpinion || newOpinion,
            nextItemHandleDescription: this.nextItemHandleDescription,
            ...this.subParams
          };
          if (!this.currentNodeEnableItemHandleDescription) {
            delete params.nextItemHandleDescription;
          }
          if (this.activeNames != '1') delete params.customPresetUserJson;
          util
            .ajax({
              url: this.type == 'reset' ? resetProcess : taskContinuation,
              method: 'post',
              data: params
            })
            .then((res) => {
              const { status, message } = res;
              this.loading = false;
              if (status === 'success') {
                this.quit(true);
                this.$message.success('操作成功');
              } else {
                this.$message.error(message || '系统错误，请联系管理员！');
              }
            })
            .catch((err) => {
              this.loading = false;
              if (err.message && err.message !== 'canceled') {
                this.$message.error(err.message);
              }
            });
        } else {
          return false;
        }
      });
    },
    getNodeInfos(nodeId, index) {
      let params = {
        processDefinitionId: this.processDefinitionId,
        nextNodeId: nodeId ? nodeId : this.nextNode.nextNode,
        businessId: this.taskExamine.businessId,
        pendingId: this.taskExamine.pendingId,
        taskAction: this.type == 'reset' ? 'resetProcess' : this.type == 'continuation' ? 'continuation' : ''
      };
      util
        .ajax({ url: getNodeInfo, params })
        .then((res) => {
          const {
            status,
            message,
            data: {
              nextUserList,
              nodeExtAttr,
              countersignaturetypeText,
              countersignaturetypeCode
            }
          } = res;
          this.loading = false;
          if (status === 'success') {
            if (this.type == 'reset') {
              this.currentNodeEnableItemHandleDescription =
                nodeExtAttr.currentNodeEnableItemHandleDescription == 1;
            }
            this.nextNode.userInfo = nextUserList;
            this.countersignaturetypeCode = countersignaturetypeCode;
            this.nextNode.countersignaturetypeText = countersignaturetypeText;
            this.isTaskread = nodeExtAttr.isTaskread;
            this.isHandleExplain = nodeExtAttr.isHandleExplain;
            this.isCustomUser = nodeExtAttr.isCustomUser; //是否展示选人组件按钮
            this.presetEdit = nodeExtAttr.presetEdit; //是否展示备选人
            this.nodeInfoExtAttr = nodeExtAttr;
            this.isDefSelectedObj = nodeExtAttr.isDefSelectedObj; //是否默认选中

            if (
              nodeExtAttr.userSelectionType == 7 ||
              nodeExtAttr.userSelectionType == 8 ||
              nodeExtAttr.userSelectionType == 9 ||
              nodeExtAttr.userSelectionType == 10 ||
              nodeExtAttr.userSelectionType == 11 ||
              nodeExtAttr.userSelectionType == 12
            ) {
              this.getIsShowNextUser(
                nodeExtAttr && nodeExtAttr.userSelectionType
              );
            } else if (
              nodeExtAttr.userSelectionType == 13 ||
              nodeExtAttr.userSelectionType == 14
            ) {
              this.showRoleUser = true;
              if (data.nextRole) {
                this.radioList = [
                  { showid: data.nextRole.id, showname: data.nextRole.rolename }
                ];
                if (this.isDefSelectedObj == 1) {
                  this.nextNode.nextRoleId.push(data.nextRole.id);
                  this.selectUserList.push({
                    showname: data.nextRole.rolename,
                    showid: data.nextRole.id
                  });
                }
              }
            } else {
              const { multiple, params } = this.isMultiple(
                nodeExtAttr.userSelectionType
              );
              this.multiple = multiple;
              this.params = params;
            }
            // this.isReadMultiple(nodeExtAttr.userSelectionType);

            nextUserList.map((item) => {
              if (
                this.multiple &&
                nodeExtAttr.isDefSelectedObj == 1 &&
                nextUserList !== undefined
              ) {
                this.nextNode.nextUser.push(item.userId);
                this.selectUserList.push({
                  showname: item.username,
                  showid: item.userId
                });
              }

              this.options.push({
                showname: item.username,
                showid: item.userId
              });
            });
            if (this.multiple) {
              this.nextNode.nextReadUserId = [];
            } else {
              this.nextNode.nextReadUserId = '';
            }
            if (
              nextUserList.length > 0 &&
              nodeExtAttr.isDefSelectedObj == 1 &&
              !this.multiple
            ) {
              this.nextNode.nextUser = nextUserList[0].userId;
              this.selectUserList.push({
                showname: nextUserList[0].username,
                showid: nextUserList[0].userId
              });
            }
            this.radioList = this.options;
          } else {
            this.$message.error(message || '系统错误，请联系管理员！');
          }
          nodeId && this.$refs.selectUser[index].changeInfo();
        })
        .catch((err) => {
          this.loading = false;
          if (err.message && err.message !== 'canceled') {
            this.$message.error(err.message);
          }
        });
    },
    changeSel(val) {
      this.nextNode.nextUser = [];
      this.options = [];
      this.selectUserList = [];
      this.radioList = [];
      this.loading = true;
      this.getNodeInfos();
    },
    // 取消
    quit(val) {
      if (val === true) return this.$emit('cancel', val);
      this.$emit('cancel', false);
    },
    getFind() {
      util
        .ajax({
          url: findSysCodes
        })
        .then((res) => {
          const { status, message } = res;
          if (status === 'success') {
            if(this.hideMessage) return;
            this.nextNode.noticeType = message.split(',');
            let arr = [];
            this.nextNode.noticeList.map((item) => {
              this.nextNode.noticeType.map((x) => {
                if (x == item.cciValue) {
                  arr.push(x);
                }
              });
            });
            this.nextNode.noticeType = arr;
            this.showNoticeType = true;
          } else {
            this.$message.error(message || '系统错误，请联系管理员！');
          }
        })
        .catch((err) => {
          this.loading = false;
          if (err.message && err.message !== 'canceled') {
            this.$message.error(err.message);
          }
        });
    },
    /**
     * isMultiple
     * @desc:是否多选
     * @author liufan
     * @date 2022年9月13日
     **/
    isMultiple(val, choiceOrgId, choiceDeptId, pOrgId) {
      let multiple = false;
      let params = {};
      if (val == 2 || val == 4 || val == 6 || val == 16 || val == 12) {
        multiple = true;
      }
      if (val == 1 || val == 2 || val == 5) {
        params.filid = this.userModel.orgId;
        params.only_filid = true;
        if (choiceOrgId) {
          params.filid = choiceOrgId;
        }
      }
      if (val == 5 || val == 6) {
        params.filid = this.userModel.orgId;
        params.mydeptid = this.userModel.depId;
        if (choiceDeptId) {
          params.mydeptid = choiceDeptId;
        }
        if (choiceOrgId) {
          params.filid = choiceOrgId;
        }
      }
      if (val == 15 || val == 16) {
        params.filid = this.userModel.orgId;
        if (pOrgId) {
          params.filid = pOrgId;
        }
      }
      return { multiple, params };
    },
    getResetFlow() {
      let params = {
        url:
          this.type == 'continuation'
            ? toTaskContinuationIndex
            : toResetProcessIndex,
        params: {
          appId: this.appId,
          ...this.flowParams
        }
      };
      this.loading = true;
      // 获取节点
      util
        .ajax(params)
        .then((res) => {
          //pc接口返回数据处理
          this.loading = false;
          const { status, message, data } = res;
          if (status == 'success') {
            data.nextNodeCheckType &&
              (this.nextNodeCheckType = data.nextNodeCheckType);
            this.pendtitle = data.pendtitle || data.taskExamine.businessName;
            this.customPresetHintMessage = data.customPresetHintMessage;
            this.readOnlyNotificationType = data.readOnlyNotificationType;
            this.notificationMessageReadOnly =
              data.notificationMessageReadOnly == 'true';
            let flowList = [];
            if (data.taskNodeList && data.taskNodeList.length > 0) {
              for (let key in data.taskNodeList[0]) {
                flowList.push({
                  nodeName: data.taskNodeList[0][key],
                  nodeId: key
                });
              }
            } else {
              for (let key in data.taskNodeMap) {
                flowList.push({
                  nodeName: data.taskNodeMap[key],
                  nodeId: key
                });
              }
            }

            this.nextNode.nodeInfo = flowList;
            this.nextNode.nextNode = flowList[0].nodeId;
            this.taskExamine = data.taskExamine;
            this.processDefinitionId = data.taskExamine.processDefinitionId;
            this.isOpinionRequired =
              data.nodeInfoMap.nodeExtAttr.isOpinionRequired;
            this.isHideDefaultOperation =
              data.nodeInfoMap.nodeExtAttr.isHideDefaultOperation;
            this.defaultNextNode = data.nodeInfoMap.nodeExtAttr.defaultNextNode;
            this.isChooseNextNode =
              data.nodeInfoMap.nodeExtAttr.isChooseNextNode;
            this.isCdjxjTaskHandle = data.isCdjxjTaskHandle;
            this.presetTaskNodeKeyStr = data.presetTaskNodeKeyStr;
            this.presetTaskNodeMap = data.presetTaskNodeMap;
            this.isSinglePage = data.taskExamine.isSinglePage;
            this.isSinglePage &&
              (this.nextNode.opinion = data.taskExamine.opinion);
            // this.nextNode.noticeInfo = data.taskExamine.notificationMsg;
            this.nextNode.nodeName = data.taskExamine.nodeName;
            this.canPresetRead = data.canPresetRead;
            if (data.canPresetRead) {
              let ids =
                data.nodeInfoMap.nodeExtAttr.presetReadCandinateIds.split(',');
              let names =
                data.nodeInfoMap.nodeExtAttr.presetReadCandinateNames.split(
                  ','
                );
              ids.map((item, index) => {
                this.presetReadUserId.push({
                  showid: item,
                  showname: names[index]
                });
                this.selectPresetUserList.push({
                  showid: item,
                  showname: names[index]
                });
                this.nextNode.presetReadUserId.push(item);
              });
            }
            this.getNodeInfos();
            // this.getPresetFlowInfo();

            this.getNodeType();
            this.getMessage();
          } else {
            this.$message.error(message || '系统错误，请联系管理员！');
          }
        })
        .catch((err) => {
          this.loading = false;
          if (err.message && err.message !== 'canceled') {
            this.$message.error(err.message);
          }
        });
    }
  }
};
</script>
