<template>
  <div class="es-flow-list">
    <div
      class="es-flow-list-item"
      v-for="(item, index) in content"
      :key="index"
      v-show="
        (item.type == 'splitReading' &&
          splitReadingData &&
          splitReadingData.length > 0) ||
        (item.type == 'preset' &&
          presetData &&
          presetData.length > 0 &&
          currentUserHasPresetInfoAuth) ||
        (item.type != 'splitReading' && item.type != 'preset')
      "
    >
      <div
        class="es-flow-list-box"
        :ref="item.type"
        :style="`position:${height == 'auto' ? 'unset' : 'absolute'}`"
      >
        <es-data-table
          v-if="show"
          :class="{ 'es-flow-group-data-table': item.type !== 'sign' }"
          :display="display"
          @cell-click="handleCellClick"
          :full="height !== 'auto'"
          v-bind="item"
          :data="
            showDoresult
              ? returnData(item.type).filter(
                  (x) => x.doresult || x.handleInfo || x.pendstate != 2
                )
              : returnData(item.type)
          "
          @btn-click="handleBtnClick"
          @selection-change="handleSelectionChange"
        ></es-data-table>
      </div>
    </div>
    <es-dialog
      append-to-body
      :close-on-click-modal="false"
      title="查看附件"
      :visible.sync="showFileList"
      v-if="showFileList"
    >
      <FileList
        :ownId="wfpendingid"
        :code="flowTableInfo.adjunctCode"
        :deleted="false"
        :disabled="true"
        @cancel="showFileList = false"
      />
    </es-dialog>
    <es-dialog
      append-to-body
      class="es-flow-list-dialog"
      :close-on-click-modal="false"
      title="流程历史批量删除"
      :visible.sync="showBatchDelete"
      v-if="showBatchDelete"
    >
      <div style="height: 100%" v-loading="batchDeleteLoading">
        <es-data-table
          v-if="showBatchDelete"
          checkbox
          :data="batchdeleteTableList"
          :thead="batchdeleteThead"
          numbers
          full
          @selection-change="handleSelectionChange($event,'batchDelete')"
          style="width: 100%"
        />
        <div class="batch-delete-footer">
          <el-input class="batch-delete-footer-input" v-model="batchdeletereason" placeholder="请输入批量删除的原因"></el-input>
          <es-button type="primary" @click="handleBatchDelete">批量删除</es-button>
          <es-button type="primary" @click="showBatchDelete = false">取消</es-button>
        </div>
      </div>
    </es-dialog>
    <es-dialog
      append-to-body
      class="es-flow-list-dialog"
      :close-on-click-modal="false"
      title="查看删除记录"
      :visible.sync="showDelete"
      v-if="showDelete"
    >
      <div style="height: 100%" v-loading="deleteLoading">
        <es-data-table
          v-if="showDelete"
          :data="deleteTableList"
          :thead="deleteThead"
          @btn-click="handleBtnShowClick"
          @page-size-change="handleSizeChange($event, 'delete')"
          @page-current-change="handleCurrentChange($event, 'delete')"
          numbers
          full
          style="width: 100%"
          @sort-change="sortChange($event, 'delete')"
          :page="pageInfo"
        />
      </div>
    </es-dialog>
    <es-dialog
      append-to-body
      class="es-flow-list-dialog"
      :close-on-click-modal="false"
      title="查看重设记录"
      :visible.sync="showReset"
      v-if="showReset"
    >
      <div style="height: 100%" v-loading="resetLoading">
        <es-data-table
          v-if="showReset"
          :data="resetTableList"
          :thead="resetThead"
          @page-size-change="handleSizeChange($event, 'reset')"
          @page-current-change="handleCurrentChange($event, 'reset')"
          numbers
          full
          style="width: 100%"
          @sort-change="sortChange($event, 'reset')"
          :page="pageInfo"
        />
      </div>
    </es-dialog>
    <es-dialog
      append-to-body
      :close-on-click-modal="false"
      title="查看催办记录"
      :visible.sync="showPress"
      v-if="showPress"
    >
      <div style="height: 100%" v-loading="pressLoading">
        <es-data-table
          v-if="show"
          :data="pressTableList"
          :thead="pressThead"
          @page-size-change="handleSizeChange($event, 'press')"
          @page-current-change="handleCurrentChange($event, 'press')"
          stripe
          full
          style="width: 100%"
          @sort-change="sortChange($event, 'press')"
          :page="pageInfo"
        />
      </div>
    </es-dialog>
    <es-dialog
      append-to-body
      :close-on-click-modal="false"
      :title="modalType == 'del' ? '删除' : '修改意见'"
      :visible.sync="showDel"
      height="auto"
      class="del-flow"
      v-if="showDel"
    >
      <es-form
        v-loading="delLoading"
        :model="formData"
        :contents="formItemList"
        @submit="handleFormSubmit"
      >
      </es-form>
    </es-dialog>
  </div>
</template>

<script>
import {
  findCodeValues,
  deletePresetInfo,
  pendedhistoryListJson,
  toPresetInfoListIndex,
  pressListJson,
  pendedhistoryListWithCircularReadJson,
  deleteFlow,
  taskReadWithDraw,
  fyListJson,
  circularReadWithdraw,
  resetJson,
  deletedListJson,
  restoredHistory,
  batchDelete,
  modifyFlow
} from 'eoss-ui/src/config/api';
import FileList from '../../flow/src/component/FileList.vue';
import util from 'eoss-ui/src/utils/util';
export default {
  name: 'EsFlowList',
  components: {
    [FileList.name]: FileList
  },
  props: {
    businessId: {
      type: String,
      default: ''
    },
    getListCount: {
      type: Function,
      default: () => {}
    },
    flowViewType: {
      type: [Number, String],
      default: 0
    },
    hide: {
      type: String,
      default: ''
    },
    hideBtn: {
      type: Boolean,
      default: false
    },
    params: {
      type: Object,
      default: () => {
        return {};
      }
    },
    toolbar: {
      type: Array,
      default: () => []
    },
    headFields: {
      type: Array,
      default: () => []
    },
    contents: {
      type: Array,
      default() {
        return ['flow', 'splitReading', 'preset'];
      }
    },
    numbers: {
      type: Boolean,
      default: false
    },
    height: {
      type: String,
      default: ''
    },
    showDoresult: {
      type: Boolean,
      default: false
    },
    theadWidth: {
      type: Object,
      default: () => {
        return {};
      }
    },
    type: {
      type: String,
      default: ''
    },
    display: Boolean
  },
  inheritAttrs: false,
  data() {
    return {
      pressLoading: false,
      pressTableList: [],
      circularData: [],
      selectList: [],
      batchDeleteSelectList:[],
      flowHeight: '',
      presetHeight: '',
      signHeight: '',
      splitReadingHeight: '',
      circularHeight: '',
      untreatedReadHeight: '',
      processedReadHeight: '',
      untreatedReadData: [],
      processedReadData: [],
      hasCircularReadWithdrawAuthority: false,
      currentPage: 1,
      pageSize: 20,
      flowListCount: {},
      currentUserHasPresetInfoAuth: false,
      pressThead: [
        {
          title: '催办节点',
          align: 'center',
          sortable: true,
          field: 'urge_item'
        },
        {
          title: '催办人名称',
          sortable: true,
          align: 'center',
          field: 'urge_man_name'
        },
        {
          title: '催办时间',
          sortable: true,
          align: 'center',
          field: 'urge_time'
        },
        {
          title: '被催办人名称',
          align: 'center',
          sortable: true,
          field: 'urged_man_name'
        }
      ],
      wfpendingid: '',
      showFileList: false,
      flowData: [],
      splitReadingData: [],
      presetData: [],
      signData: [],
      loading: '', //加载中
      preset_type: [], //预设类型
      showPress: false, //查看催办记录弹窗
      showDelete: false, //删除记录弹窗
      showBatchDelete: false,
      deleteLoading: false,
      batchDeleteLoading: false,
      deleteTableList: [],
      batchdeleteTableList: [],
      batchdeletereason:'',
      batchdeleteThead: [
        {
          title: '步骤',
          align: 'center',
          // sortable: true,
          showOverflowTooltip: true,
          field: 'itemname'
        },
        {
          title: '办理人',
          align: 'center',
          showOverflowTooltip: true,
          width: 120,
          // sortable: true,
          field: 'userName'
        },
        {
          label: '状态',
          field: 'pendstate',
          key: 'zt',
          align: 'center',
          showOverflowTooltip: true,
          width: this.theadWidth.pendstate || 80,
          render: (h, params) => {
            return h('span', {
              style: {
                color:
                  params.row.pendstate == 0 || params.row.pendstate == 3
                    ? 'red'
                    : params.row.pendstate == 1
                    ? 'green'
                    : params.row.pendstate == -1
                    ? 'orange'
                    : 'deepskyblue'
              },
              domProps: { innerHTML: params.row.querykeywords }
            });
          }
        },
        {
          title: '办理意见',
          align: 'center',
          showOverflowTooltip: true,
          // sortable: true,
          field: 'doresult'
        },
        {
          title: '办理时间',
          align: 'center',
          showOverflowTooltip: true,
          // sortable: true,
          field: 'doetime',
          render: (h, params) => {
              return h(
                'span',
                {},
                params.row.doetime
                  ? util.formatDate(params.row.doetime, 'yyyy-MM-dd HH:mm')
                  : ''
              );
            }
        }
      ],
      deleteThead: [
        {
          title: '步骤',
          align: 'center',
          // sortable: true,
          showOverflowTooltip: true,
          field: 'itemname'
        },
        {
          title: '办理人',
          align: 'center',
          showOverflowTooltip: true,
          width: 120,
          // sortable: true,
          field: 'userName'
        },
        {
          title: '办理意见',
          align: 'center',
          showOverflowTooltip: true,
          width: 240,
          // sortable: true,
          field: 'doresult'
        },
        {
          title: '办理时间',
          align: 'center',
          width: 150,
          showOverflowTooltip: true,
          // sortable: true,
          field: 'doetime'
        },
        {
          title: '删除人',
          showOverflowTooltip: true,
          width: 120,
          align: 'center',
          // sortable: true,
          field: 'querykeywords'
        },
        {
          title: '删除原因',
          align: 'center',
          width: 240,
          showOverflowTooltip: true,
          // sortable: true,
          field: 'upstepInfo'
        },
        {
          title: '删除时间',
          align: 'center',
          width: 150,
          showOverflowTooltip: true,
          // sortable: true,
          field: 'statechangetime'
        },
        {
          title: '操作',
          type: 'handle',
          events: [
            {
              text: '恢复'
            }
          ]
        }
      ],
      showReset: false, //重设记录弹窗
      resetLoading: false,
      resetTableList: [],
      resetThead: [
        {
          title: '重设人登录名',
          align: 'center',
          // sortable: true,
          showOverflowTooltip: true,
          field: 'reset_person_login_name'
        },
        {
          title: '重设人姓名',
          align: 'center',
          showOverflowTooltip: true,
          // sortable: true,
          field: 'reset_person_name'
        },
        {
          title: '重设前节点',
          align: 'center',
          showOverflowTooltip: true,
          // sortable: true,
          field: 'reset_bf_item'
        },
        {
          title: '重设前执行人',
          align: 'center',
          showOverflowTooltip: true,
          // sortable: true,
          field: 'reset_bf_user'
        },
        {
          title: '重设后节点',
          showOverflowTooltip: true,
          align: 'center',
          // sortable: true,
          field: 'reset_af_item'
        },
        {
          title: '重设后执行人',
          align: 'center',
          showOverflowTooltip: true,
          // sortable: true,
          field: 'reset_af_user'
        },
        {
          title: '重设时间',
          align: 'center',
          showOverflowTooltip: true,
          // sortable: true,
          field: 'reset_time'
        },
        {
          title: '操作IP',
          align: 'center',
          showOverflowTooltip: true,
          // sortable: true,
          field: 'reset_ip'
        }
      ],
      modify: false,
      formData: { reason: '' },

      delLoading: false,
      showDel: false,
      attachmentPaperClipCssStyle: '',
      is_edit: [], //是否可编辑
      flowTableInfo: {
        adjunctCode: '',
        hasAgent: '1' //是否展示代办人 1：展示 0：不展示
      },
      show: false,
      taskReadName: '', //非流程列表名称
      options: [
        { label: '时间排序', value: '1' },
        { label: '部门排序', value: '2' }
        // { label: '树形排序', value: '3' }
      ],
      isShort: 0, //是否隐藏筛选
      viewType: '1', //排序方式
      flowTableList: [], //流程列表
      fyTableList: [], //分阅列表
      showSuggest: 'all', //筛选显示数据
      presetInfoListHiddenColumns: '', //隐藏表格展示数据
      canDelete: false, //是否展示操作按钮
      canBatchDelete: false, //是否可以批量删除
      isSuperRole: false, //是否管理员
      isShowReset: false, //是否显示重设记录
      historyId: '',
      sidx: '',
      sord: 'asc',
      modalType: '',
      total: 0
    };
  },
  watch: {
    flowViewType: {
      handler(val) {
        if (val) {
          this.loading = util.loading(this.$loading, '加载中...');
          this.getFlowList(val);
        }
      },
      deep: true,
      immediate: true
    }
  },

  computed: {
    formItemList() {
      return [
        {
          name: 'reason',
          label: this.modalType == 'del' ? '删除原因' : '办理意见',
          type: 'textarea',
          placeholder: `请输入${
            this.modalType == 'del' ? '删除原因' : '办理意见'
          }`,
          rules: {
            required: this.modalType == 'del',
            message: '请输入删除原因',
            trigger: 'blur'
          },
          value: '',
          rows: 5
        },
        {
          type: 'submit',
          skin: 'lay-form-btns',
          contents: [
            {
              type: 'primary',
              plain: true,
              text: '保存',
              event: 'confirm'
            }
          ]
        }
      ];
    },
    toolbars() {
      return {
        flow: [
          {
            type: 'text',
            contents: '流程列表'
          },
          {
            type: 'search',
            contents: [
              {
                name: 'showSuggest',
                type: 'radio',
                changeSearch: true,
                data: [
                  {
                    value: 'all',
                    name: '显示全部',
                    checked: true
                  },
                  { value: 'have', name: '显示已填意见' }
                ],
                events: {
                  change: (key, value) => {
                    this.handleChange(key, value);
                  }
                }
              },

              {
                type: 'select',
                placeholder: '请选择',
                name: 'viewType',
                width: '140px',
                changeSearch: true,
                events: {
                  change: (key, value) => {
                    this.handleChange(key, value);
                  }
                },
                data: [
                  {
                    value: 1,
                    selected: true,
                    name: '时间排序'
                  },
                  {
                    value: 2,
                    name: '部门排序'
                  }
                  // {
                  //   value: 3,
                  //   name: '树形排序'
                  // }
                ]
              }
            ]
          },
          {
            type: 'button',
            name: 'btn',
            width: '140px',
            contents: [
              {
                text: '删除记录',
                type: 'primary',
                hide: !this.canDelete && !this.isSuperRole,
                event: (res) => {
                  // click: (key, value) => {
                  this.showDelete = true;
                  this.currentPage = 1;
                  this.pageSize = 20;
                  this.getDeletList();
                  // }
                }
              },
              {
                text: '批量删除',
                type: 'primary',
                hide: !this.canBatchDelete && !this.isSuperRole,
                event: (res) => {
                  // click: (key, value) => {
                  this.showBatchDelete = true;
                  this.batchdeleteTableList = this.flowData.filter((x) => x.pendstate == 2);
                  // }
                }
              },
              {
                text: '重设记录',
                type: 'primary',
                hide: !this.isShowReset,
                event: (res) => {
                  // click: (key, value) => {
                  this.showReset = true;
                  this.currentPage = 1;
                  this.pageSize = 20;
                  this.getResetList();
                  // }
                }
              }
            ]
          }
        ],
        preset: [
          {
            type: 'text',
            contents: '预设列表'
          }
        ],
        sign: [
          {
            type: 'button',
            contents: [
              {
                text: '生成处理签',
                type: 'primary'
              }
            ]
          }
        ],
        splitReading: [
          {
            type: 'text',
            contents:
              (this.taskReadName ? this.taskReadName : '非流程') + '列表'
          }
        ],
        circular: [
          {
            type: 'text',
            contents: '传阅列表'
          }
        ],
        untreatedRead: [
          {
            type: 'text',
            contents: '未处理分阅列表'
          },
          {
            type: 'button',
            contents: [
              {
                text: '撤销分阅',
                fun: 'recallRead'
              }
            ]
          }
        ],
        processedRead: [
          {
            type: 'text',
            contents: '已处理分阅列表'
          }
        ]
        // Reading situation
      };
    },
    pageInfo() {
      return {
        pageNum: this.currentPage,
        pageSize: this.pageSize,
        totalCount: this.total
      };
    },
    theads() {
      const _that = this;
      let newThead = {
        flow: [
          {
            label: '经办部门',
            field: 'deptid',
            align: 'center',
            key: 'jbbm',
            showOverflowTooltip: true,
            width: this.theadWidth.deptid || 150,
            render: (h, params) => {
              return h(
                'span',
                {},
                params.row.doDeptName
                  ? params.row.doDeptName
                  : params.row.deptName
              );
            }
          },
          {
            label: '步骤',
            field: 'itemname',
            align: 'center',
            key: 'bz',
            showOverflowTooltip: true,
            width: this.theadWidth.itemname || 110
          },
          {
            label: '办理人',
            field: 'userName',
            align: 'center',
            key: 'blr',
            showOverflowTooltip: true,
            width: this.theadWidth.userName || 110
          },
          {
            label: '办理人部门',
            field: 'deptName',
            align: 'center',
            showOverflowTooltip: true,
            key: 'blrbm',
            width: this.theadWidth.deptName || 110
          },
          {
            label: '状态',
            field: 'pendstate',
            key: 'zt',
            align: 'center',
            showOverflowTooltip: true,
            width: this.theadWidth.pendstate || 80,
            render: (h, params) => {
              return h('span', {
                style: {
                  color:
                    params.row.pendstate == 0 || params.row.pendstate == 3
                      ? 'red'
                      : params.row.pendstate == 1
                      ? 'green'
                      : params.row.pendstate == -1
                      ? 'orange'
                      : 'deepskyblue'
                },
                domProps: { innerHTML: params.row.querykeywords }
              });
            }
          },
          {
            label: '办理意见',
            field: 'doresult',
            align: 'center',
            width: this.theadWidth.doresult,
            showOverflowTooltip: true,
            key: 'blyj',
            render: (h, params) => {
              if (
                params.row.doresult &&
                (params.row.doresult.startsWith('http') ||
                  params.row.doresult.startsWith('https'))
              ) {
                return h('img', {
                  attrs: { src: params.row.doresult },
                  style: { width: '100px', height: '100px' }
                });
              } else {
                return h('span', {}, [
                  params.row.doresult
                    ? params.row.doresult + (params.row.handleInfo ? '&' : '')
                    : '',
                  h(
                    'span',
                    { style: { color: '#A5A5A5', marginLeft: '2px' } },
                    params.row.handleInfo || ''
                  )
                ]);
              }
            }
          },
          {
            label: '验签',
            field: 'authTypeStr',
            align: 'center',
            key: 'yq',
            showOverflowTooltip: true,
            width: this.theadWidth.authTypeStr || 70,
            render: (h, params) => {
              return h(
                'span',
                { style: { color: 'deepskyblue' } },
                params.row.authTypeStr
              );
            }
          },
          {
            label: '附件',
            key: 'fj',
            field: 'hasAdjunct',
            align: 'center',
            showOverflowTooltip: true,
            width: this.theadWidth.hasAdjunct || 70,
            render: (h, params) => {
              if (params.row.hasAdjunct) {
                return h('span', {
                  style: _that.attachmentPaperClipCssStyle
                    ? _that.attachmentPaperClipCssStyle
                    : { color: 'red', fontSize: '20px' },
                  class: 'iconfont es-icon-fujian'
                });
              } else {
                return h('span', {}, '');
              }
            }
          },
          {
            label: '时间',
            field: 'doetime',
            align: 'center',
            key: 'sj',
            showOverflowTooltip: true,
            width: this.theadWidth.doetime || 150,
            render: (h, params) => {
              return h(
                'span',
                {},
                params.row.doetime
                  ? util.formatDate(params.row.doetime, 'yyyy-MM-dd HH:mm')
                  : ''
              );
            }
          },
          {
            label: '代办人',
            field: 'douserid',
            align: 'center',
            key: 'dbr',
            showOverflowTooltip: true,
            width: this.theadWidth.douserid || 80,
            hide: _that.flowTableInfo.hasAgent != '1'
          },
          {
            label: '催办',
            field: 'pressTimes',
            align: 'center',
            key: 'cb',
            showOverflowTooltip: true,
            width: this.theadWidth.pressTimes || 150,
            render: (h, params) => {
              return h(
                'span',
                { style: 'color:deepskyblue;cursor: pointer;' },
                params.row.pressTimes != 0 ? params.row.pressTimes : ''
              );
            }
          },
          {
            title: '操作',
            type: 'handle',
            width: this.modify ? '130' : '100',
            template: '',
            hide: this.hideBtn || (!this.canDelete && !this.modify),
            events: [
              {
                text: '删除',
                rules: (rows) => {
                  return rows.canDelete || this.canDelete;
                }
              },
              {
                text: '修改',
                rules: (rows) => {
                  return this.modify && rows.pendstate == 2;
                }
              }
            ]
          }
        ],
        preset: this.thead,
        splitReading: [
          {
            label: '经办部门',
            field: 'deptid',
            key: 'jbbm',
            align: 'center',
            showOverflowTooltip: true,
            width: this.theadWidth.deptid || 150
          },
          {
            label: '步骤',
            field: 'itemname',
            align: 'center',
            key: 'bz',
            showOverflowTooltip: true,
            width: this.theadWidth.itemname || 110
          },
          {
            label: '办理人',
            field: 'userName',
            align: 'center',
            key: 'blr',
            showOverflowTooltip: true,
            width: this.theadWidth.userName || 110
          },
          {
            label: '状态',
            field: 'pendstate',
            align: 'center',
            key: 'zt',
            showOverflowTooltip: true,
            width: this.theadWidth.pendstate || 80,
            render: (h, params) => {
              return h('span', {
                style: {
                  color:
                    params.row.pendstate == 0 || params.row.pendstate == 3
                      ? 'red'
                      : params.row.pendstate == 1
                      ? 'green'
                      : params.row.pendstate == -1
                      ? 'orange'
                      : 'deepskyblue'
                },
                domProps: { innerHTML: params.row.querykeywords }
              });
            }
          },
          {
            label: '办理意见',
            field: 'doresult',
            align: 'center',
            key: 'blyj',
            width: this.theadWidth.doresult,
            showOverflowTooltip: true,
            render: (h, params) => {
              if (
                params.row.doresult &&
                (params.row.doresult.startsWith('http') ||
                  params.row.doresult.startsWith('https'))
              ) {
                return h('img', {
                  attrs: { src: params.row.doresult },
                  style: { width: '100px', height: '100px' }
                });
              } else {
                return h('span', {}, [
                  params.row.doresult
                    ? params.row.doresult + (params.row.handleInfo ? '&' : '')
                    : '',
                  h(
                    'span',
                    { style: { color: '#A5A5A5', marginLeft: '2px' } },
                    params.row.handleInfo || ''
                  )
                ]);
              }
            }
          },
          {
            label: '验签',
            field: 'authTypeStr',
            align: 'center',
            key: 'yq',
            showOverflowTooltip: true,
            width: this.theadWidth.authTypeStr || 70,
            render: (h, params) => {
              return h(
                'span',
                { style: { color: 'deepskyblue' } },
                params.row.authTypeStr
              );
            }
          },
          {
            label: '附件',
            field: 'hasAdjunct',
            align: 'center',
            key: 'fj',
            showOverflowTooltip: true,
            width: this.theadWidth.hasAdjunct || 70,
            render: (h, params) => {
              if (params.row.hasAdjunct) {
                return h('span', {
                  style: _that.attachmentPaperClipCssStyle
                    ? _that.attachmentPaperClipCssStyle
                    : { color: 'red', fontSize: '20px' },
                  class: 'iconfont es-icon-fujian'
                });
              } else {
                return h('span', {}, '');
              }
            }
          },
          {
            label: '时间',
            field: 'doetime',
            align: 'center',
            key: 'sj',
            showOverflowTooltip: true,
            width: this.theadWidth.doetime || 150,
            render: (h, params) => {
              return h(
                'span',
                {},
                params.row.doetime
                  ? util.formatDate(params.row.doetime, 'yyyy-MM-dd HH:mm')
                  : ''
              );
            }
          },
          {
            label: '代办人',
            field: 'douserid',
            align: 'center',
            key: 'dbr',
            showOverflowTooltip: true,
            width: this.theadWidth.douserid || 80,
            hide: _that.flowTableInfo.hasAgent != '1'
          },
          {
            label: '催办',
            field: 'pressTimes',
            align: 'center',
            key: 'cb',
            showOverflowTooltip: true,
            width: this.theadWidth.pressTimes || 150,
            render: (h, params) => {
              return h(
                'span',
                { style: 'color:deepskyblue;cursor: pointer;' },
                params.row.pressTimes != 0 ? params.row.pressTimes : ''
              );
            }
          },
          {
            title: '操作',
            type: 'handle',
            width: '100',
            template: '',
            hide: this.hideBtn || (!this.canDelete && !this.modify),
            events: [
              {
                text: '删除',
                rules: (rows) => {
                  return rows.canDelete || this.canDelete;
                }
              }
            ]
          }
        ],
        circular: [
          {
            label: '发起人',
            field: 'circularReadInitiatorName',
            align: 'center',
            key: 'fqr',
            showOverflowTooltip: true,
            width: this.theadWidth.circularReadInitiatorName || 150
          },
          {
            label: '传阅部门',
            field: 'circularReadOrgName',
            align: 'center',
            key: 'cybm',
            showOverflowTooltip: true,
            width: this.theadWidth.circularReadOrgName || 110
          },
          {
            label: '传阅人',
            field: 'userName',
            align: 'center',
            key: 'cyr',
            showOverflowTooltip: true,
            width: this.theadWidth.userName || 110
          },
          {
            label: '步骤',
            field: 'itemname',
            align: 'center',
            showOverflowTooltip: true,
            key: 'bz',
            width: this.theadWidth.itemname || 110
          },
          {
            label: '状态',
            field: 'pendstate',
            key: 'zt',
            align: 'center',
            showOverflowTooltip: true,
            width: this.theadWidth.pendstate || 140,
            render: (h, params) => {
              return h('span', {
                style: {
                  color:
                    params.row.pendstate == 0 || params.row.pendstate == 3
                      ? 'red'
                      : params.row.pendstate == 1
                      ? 'green'
                      : params.row.pendstate == -1
                      ? 'orange'
                      : 'deepskyblue',
                  cursor: this.hasCircularReadWithdrawAuthority
                    ? 'pointer'
                    : 'unset'
                },
                domProps: {
                  innerHTML:
                    params.row.querykeywords +
                    (this.hasCircularReadWithdrawAuthority
                      ? `<span style="color:#7AB0D5">(撤回)</span>`
                      : '')
                }
              });
            }
          },
          {
            label: '送达时间',
            field: 'createtime',
            align: 'center',
            key: 'sdsj',
            showOverflowTooltip: true,
            width: this.theadWidth.createtime || 170
          },
          {
            label: '办理时间',
            field: 'doetime',
            align: 'center',
            key: 'blsj',
            showOverflowTooltip: true,
            width: this.theadWidth.doetime || 150
          },

          {
            label: '附件',
            key: 'fj',
            field: 'hasAdjunct',
            align: 'center',
            showOverflowTooltip: true,
            width: this.theadWidth.hasAdjunct || 70,
            render: (h, params) => {
              if (params.row.hasAdjunct) {
                return h('span', {
                  style: _that.attachmentPaperClipCssStyle
                    ? _that.attachmentPaperClipCssStyle
                    : { color: 'red', fontSize: '20px' },
                  class: 'iconfont es-icon-fujian'
                });
              } else {
                return h('span', {}, '');
              }
            }
          },
          {
            label: '提醒',
            field: 'pressTimes',
            align: 'center',
            key: 'tx',
            showOverflowTooltip: true,
            width: this.theadWidth.pressTimes || 150,
            render: (h, params) => {
              return h(
                'span',
                { style: 'color:deepskyblue;cursor: pointer;' },
                params.row.pressTimes
              );
            }
          },
          {
            label: '阅结意见 & 说明',
            field: 'doresult',
            align: 'center',
            width: this.theadWidth.doresult,
            showOverflowTooltip: true,
            key: 'blyj',
            render: (h, params) => {
              if (
                params.row.doresult &&
                (params.row.doresult.startsWith('http') ||
                  params.row.doresult.startsWith('https'))
              ) {
                return h('img', {
                  attrs: { src: params.row.doresult },
                  style: { width: '100px', height: '100px' }
                });
              } else {
                return h('span', {}, [
                  params.row.doresult
                    ? params.row.doresult + (params.row.handleInfo ? '&' : '')
                    : '',
                  h(
                    'span',
                    { style: { color: '#A5A5A5', marginLeft: '2px' } },
                    params.row.handleInfo || ''
                  )
                ]);
              }
            }
          }
        ],
        untreatedRead: [
          {
            label: '步骤',
            field: 'itemid',
            align: 'center',
            key: 'bz',
            showOverflowTooltip: true,
            width: this.theadWidth.itemid || 110
          },
          {
            label: '办理人',
            field: 'userName',
            align: 'center',
            key: 'blr',
            showOverflowTooltip: true,
            width: this.theadWidth.userName
          },
          {
            label: '办理状态',
            field: 'pendstate',
            key: 'blzt',
            align: 'center',
            showOverflowTooltip: true,
            width: this.theadWidth.pendstate || 110,
            render: (h, params) => {
              return h('span', {
                style: {
                  color:
                    params.row.pendstate == 0 || params.row.pendstate == 3
                      ? 'red'
                      : params.row.pendstate == 1
                      ? 'green'
                      : 'deepskyblue'
                },
                domProps: { innerHTML: params.row.querykeywords }
              });
            }
          },
          {
            label: '创建时间',
            field: 'createtime',
            align: 'center',
            key: 'cjsj',
            showOverflowTooltip: true,
            width: this.theadWidth.createtime || 150,
            render: (h, params) => {
              return h(
                'span',
                {},
                params.row.doetime
                  ? util.formatDate(params.row.createtime, 'yyyy-MM-dd HH:mm')
                  : ''
              );
            }
          }
        ],
        processedRead: [
          {
            label: '步骤',
            field: 'itemid',
            align: 'center',
            key: 'bz',
            showOverflowTooltip: true,
            width: this.theadWidth.itemid || 110
          },
          {
            label: '办理人',
            field: 'userName',
            align: 'center',
            key: 'blr',
            showOverflowTooltip: true,
            width: this.theadWidth.userName
          },
          {
            label: '办理状态',
            field: 'pendstate',
            key: 'blzt',
            align: 'center',
            showOverflowTooltip: true,
            width: this.theadWidth.pendstate || 110,
            render: (h, params) => {
              return h('span', {
                style: {
                  color:
                    params.row.pendstate == 0 || params.row.pendstate == 3
                      ? 'red'
                      : params.row.pendstate == 1
                      ? 'green'
                      : 'deepskyblue'
                },
                domProps: { innerHTML: params.row.querykeywords }
              });
            }
          },
          {
            label: '办理时间',
            field: 'doetime',
            align: 'center',
            key: 'blsj',
            showOverflowTooltip: true,
            width: this.theadWidth.doetime || 150,
            render: (h, params) => {
              return h(
                'span',
                {},
                params.row.doetime
                  ? util.formatDate(params.row.doetime, 'yyyy-MM-dd HH:mm')
                  : ''
              );
            }
          },
          {
            label: '代办人',
            field: 'douserid',
            align: 'center',
            key: 'dbr',
            showOverflowTooltip: true,
            width: this.theadWidth.douserid
          },
          {
            label: '意见',
            field: 'doresult',
            align: 'center',
            key: 'yj',
            showOverflowTooltip: true,
            width: this.theadWidth.doresult
          }
        ]
      };
      if (this.numbers) {
        for (let key in newThead) {
          newThead[key].unshift({
            label: '序号',
            field: 'sort',
            align: 'center',
            key: 'xh',
            showOverflowTooltip: true,
            width: 50
          });
        }
      }
      return newThead;
    },
    content() {
      const _that = this;
      let newContents = JSON.parse(JSON.stringify(this.contents));
      if (this.contents.indexOf('circular') != -1) {
        newContents = newContents.filter((item) => item != 'splitReading');
      }
      if (newContents.indexOf('readingSituation') != -1) {
        newContents = ['untreatedRead', 'processedRead'];
      }
      let contents = newContents.map((item) => {
        if (typeof item === 'string') {
          let data = [];
          if (_that.headFields.length > 0) {
            _that.headFields.map((headFiled) => {
              if (headFiled.showDefault) {
                _that.theads[item].map((theadItem) => {
                  if (theadItem.field === headFiled.field) {
                    data.push({ ...theadItem, ...headFiled });
                  }
                });
              } else {
                data.push(headFiled);
              }
            });
            _that.theads[item].map((x) => {
              if (x.type == 'handle') {
                data.push(x);
              }
            });
          }
          return {
            type: item,
            checkbox: newContents.indexOf('untreatedRead') != -1,
            toolbar: this.toolbars[item],
            thead: data.length > 0 ? data : this.theads[item],
            showFormBtn: false
          };
        } else {
          if (!Object.prototype.hasOwnProperty.call(item, 'toolbar')) {
            let toolbars = this.toolbars[item.type];
            return { ...item, toolbars };
          }
          if (!Object.prototype.hasOwnProperty.call(item, 'thead')) {
            let thead = this.theads[item.type];
            return { ...item, thead };
          }
          return item;
        }
      });
      return contents;
    },
    newToolbar() {
      if (this.toolbar && this.toolbar.length > 0) {
        return this.toolbar;
      } else {
        return [];
      }
    },
    thead() {
      let table = [
        {
          title: '步骤',
          align: 'center',
          width: this.theadWidth.nodeName || '100',
          field: 'nodeName'
        },
        {
          title: '预设办理人',
          width: this.theadWidth.presetUserName || '120',
          align: 'center',
          field: 'presetUserName'
        },
        {
          title: '是否可编辑',
          key: 'sfkbj',
          align: 'center',
          width: this.theadWidth.isEdit || '100',
          render: (h, params) => {
            return h('span', this.getCodeValue(params.row.isEdit, 'is_edit'));
          },
          field: 'isEdit'
        },
        {
          key: 'zt',
          title: '状态',
          width: this.theadWidth.statusName || '80',
          align: 'center',
          field: 'statusName'
        },
        {
          title: '预设类型',
          key: 'yslx',
          width: this.theadWidth.presetType || '120',
          align: 'center',
          render: (h, params) => {
            return h(
              'span',
              this.getCodeValue(params.row.presetType, 'preset_type')
            );
          },
          field: 'presetType'
        },
        {
          title: '流程名称',
          key: 'lcmc',
          width: this.theadWidth.processDefName,
          align: 'center',
          field: 'processDefName'
        },
        {
          title: '上一步骤',
          key: 'sybz',
          align: 'center',
          width: this.theadWidth.lastNodeName,
          field: 'lastNodeName'
        },
        {
          title: '创建步骤',
          key: 'cjbz',
          align: 'center',
          width: this.theadWidth.operationNodeName,
          field: 'operationNodeName'
        },
        {
          title: '创建人',
          key: 'cjr',
          width: this.theadWidth.creatorName || '120',
          align: 'center',
          field: 'creatorName'
        },
        {
          title: '创建时间',
          width: this.theadWidth.createTime || '150',
          key: 'cjsj',
          align: 'center',
          render: (h, params) => {
            return h(
              'span',
              util.formatDate(params.row.createTime, 'yyyy-MM-dd HH:mm')
            );
          },
          field: 'createTime'
        },
        {
          title: '操作区域',
          type: 'handle',
          align: 'center',
          width: '120',
          events: [
            {
              text: '置为失效'
            }
          ]
        }
      ];
      if (
        this.presetInfoListHiddenColumns != undefined &&
        this.presetInfoListHiddenColumns != ''
      ) {
        table = table.filter(
          (items) => this.presetInfoListHiddenColumns.indexOf(items.key) == -1
        );
      }
      if (!this.canDelete) table.splice(table.length - 1, 1);
      return table;
    }
  },
  async mounted() {
    this.loading = util.loading(this.$loading, '加载中...');
    if (this.contents.indexOf('readingSituation') != -1) {
      await this.getFyListJson(1);
      await this.getFyListJson(2);
      this.getListCount(this.flowListCount);
      this.show = true;
    } else {
      this.getFlowList();
    }
    this.getSysInfo('preset_type');
    this.getSysInfo('is_edit');
    this.getListInfo();
  },

  methods: {
     /**
     * handleBatchDelete
     * @desc:批量删除
     * @author liufan
     * @date 2025年12月31日
     **/
    handleBatchDelete(){
      if(this.batchDeleteSelectList.length == 0){
        this.$message.error('请选择需要删除的流程历史数据!');
        return;
      }
      if(!this.batchdeletereason){
        this.$message.error('请输入批量删除的原因!');
        return;
      }
      let ids = this.batchDeleteSelectList.map(item => item.id).join(',');
      let params = {
        url:batchDelete,
        method: 'POST',
        data: { ids,reason:this.batchdeletereason }
      };
      this.$confirm('您确定要批量删除勾选上的流程历史数据吗?', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            this.loading = util.loading(this.$loading, '批量删除中...');
             util
        .ajax(params)
        .then((res) => {
              this.loading.close();
           if (res.rCode == 0 || res.status == 'success') {
                this.flowData = this.flowData.filter(item => ids.indexOf(item.id) == -1);
                this.batchdeleteTableList = this.flowData.filter((x) => x.pendstate == 2)
                this.batchdeletereason='';
                this.show = false
                setTimeout(() => {
                  this.show = true;
                }, 0);
                this.$message({
                  message: '删除成功',
                  type: 'success'
                });
              }else{
                this.$message.error(res.message);
              }
        })
        .catch((err) => {
              this.loading.close();
          if (err.message && err.message !== 'canceled') {
            this.$message.error(err.message);
          }
        }); }).catch(() => {});
     
      
    },
    handleBtnShowClick(val) {
      const { handle, row } = val;
      if (handle.text == '恢复') {
        let params = {
          url: restoredHistory,
          params: {
            id: row.id
          }
        };
        this.$confirm('您确定要恢复这条办理历史吗？', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            this.loading = util.loading(this.$loading, '恢复中...');
            util.ajax(params).then((res) => {
              this.loading.close();
              if (res.rCode == 0 || res.status == 'success') {
                this.getDeletList();
                this.getFlowList();
                this.$message({
                  message: '恢复成功',
                  type: 'success'
                });
              }
            });
            // _that.subMit(res.results,type)
          })
          .catch(() => {});
      }
    },
    recallReadFun() {
      const _that = this;
      let pendingIds = _that.selectList.map((x) => x.id).join(',');
      let params = {
        url: taskReadWithDraw,
        params: {
          pendingIds
        }
      };
      _that.loading = util.loading(_that.$loading, '撤销中...');
      util.ajax(params).then(async (res) => {
        _that.loading.close();
        if (res.rCode == 0 || res.status == 'success') {
          _that.$message.success('撤销成功！');
          await _that.getFyListJson(1);
          _that.getListCount(_that.flowListCount);
        } else {
          _that.$message.error(res.message);
        }
      });
    },
    recallRead() {
      if (this.selectList.length == 0)
        return this.$message.warning('请选择需要撤销的分阅');
      this.$confirm('是否确认撤销选中的分阅?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.recallReadFun();
      });
    },
    handleSelectionChange(val,type) {
      if(type == 'batchDelete'){
        this.batchDeleteSelectList = val
      }else{
        this.selectList = val;
      }
    },
    handledraw(pendedHistoryId) {
      let params = {
        url: circularReadWithdraw,
        params: { pendedHistoryId }
      };
      this.$confirm('是否确定撤回当前传阅', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.loading = util.loading(this.$loading, '撤回中...');
          util.ajax(params).then((res) => {
            this.loading.close();
            if (res.rCode == 0) {
              this.$message({
                message: '撤回成功',
                type: 'success'
              });
              this.getCircularReadList();
            }
          });
          // _that.subMit(res.results,type)
        })
        .catch(() => {});
    },
    getCircularReadList() {
      const _that = this;
      let params = {
        url: pendedhistoryListWithCircularReadJson,
        params: { apprecordid: _that.businessId }
      };
      util.ajax(params).then((res) => {
        if (res.status == 'success' || res.rCode == 0) {
          _that.circularData = res.data.fyHistoryList;
          _that.circularData.map((x, i) => {
            x.sort = i + 1;
          });
          _that.hasCircularReadWithdrawAuthority =
            res.data.hasCircularReadWithdrawAuthority;
          _that.$nextTick(() => {
            _that.getListCount(_that.flowListCount);
          });
        }
      });
    },
    returnData(type) {
      switch (type) {
        case 'preset':
          this.flowListCount.preset = this.presetData.length;
          this.flowListCount.presetData = this.presetData;
          return this.presetData;
        case 'sign':
          this.flowListCount.sign = this.signData.length;
          this.flowListCount.signData = this.signData;
          return this.signData;
        case 'splitReading':
          this.flowListCount.splitReading = this.splitReadingData.length;
          this.flowListCount.splitReadingData = this.splitReadingData;
          return this.splitReadingData;
        case 'circular':
          this.flowListCount.circular = this.circularData.length;
          this.flowListCount.circularData = this.circularData;
          return this.circularData;
        case 'untreatedRead':
          this.flowListCount.untreatedRead = this.untreatedReadData.length;
          this.flowListCount.untreatedReadData = this.untreatedReadData;
          return this.untreatedReadData;
        case 'processedRead':
          this.flowListCount.processedRead = this.processedReadData.length;
          this.flowListCount.processedReadData = this.processedReadData;
          return this.processedReadData;
        default:
          this.flowListCount.flow = this.flowData.length;
          this.flowListCount.flowData = this.flowData;
          return this.flowData;
      }
    },
    handleCellClick(row, column) {
      if (column.property == 'hasAdjunct' && row.hasAdjunct) {
        this.showFile(row.wfpendingid);
      } else if (column.property == 'pressTimes') {
        if (row.pressTimes != 0) {
          this.goPress(row.id);
        }
      } else if (
        column.property == 'pendstate' &&
        this.hasCircularReadWithdrawAuthority
      ) {
        this.handledraw(row.id);
      }
    },
    handleBtnClick(data) {
      // recallRead
      const { handle, row } = data;
      if (handle.text == '删除' || handle.text == '修改') {
        this.formData.reason = handle.text == '修改' ? row.doresult : '';
        this.del(row.id, handle.text == '删除' ? 'del' : 'modify');
      } else if (handle.fun == 'recallRead') {
        this[handle.fun]();
      }else if(handle.text == '置为失效'){
        if (row.status == 0) {
          this.$confirm('您确定要置为失效吗?')
            .then(() => {
              this.loading = util.loading(this.$loading, '提交中...');
              let param = {
                url: deletePresetInfo,
                headers: { Accept: 'application/json,text/plain' },
                method: 'post',
                data: { id:row.id }
              };
              util
                .ajax(param)
                .then((res) => {
                  const { status, message } = res;
                  this.loading.close();
                  if (status === 'success') {
                    this.$message.success('操作成功');
                    this.getListInfo();
                  } else {
                    this.$message.error(message || '系统错误，请联系管理员！');
                  }
                })
                .catch((err) => {
                  this.loading.close();
                  if (err.message && err.message !== 'canceled') {
                    this.$message.error(err.message);
                  }
                });
            })
            .catch((e) => {
              // on cancel
            });
        } else {
          this.$message.warning('当前数据已为失效状态');
        }
      }
    },
    /**
     * handleFormSubmit
     * @desc:删除节点点击事件
     * @param {Object} formData 点击删除的form数据
     * @author liufan
     * @date 2022年11月29日
     **/
    handleFormSubmit(formData) {
      this.delLoading = true;
      let params = {
        url: this.modalType == 'del' ? deleteFlow : modifyFlow,
        method: 'POST',
        data: { id: this.historyId, reason: formData.reason }
      };
      if (this.modalType != 'del') {
        delete params.data.reason;
        params.data.doResult = formData.reason;
        params.data.doresult = formData.reason;
      }
      util
        .ajax(params)
        .then((res) => {
          const { status, message } = res;
          this.delLoading = false;
          if (status === 'success') {
            this.$message.success(
              `${this.modalType == 'del' ? '删除' : '修改'}成功`
            );
            this.showDel = false;
            this.handleChange();
          } else {
            this.$message.error(message || '系统错误，请联系管理员！');
          }
        })
        .catch((err) => {
          this.delLoading = false;
          if (err.message && err.message !== 'canceled') {
            this.$message.error(err.message);
          }
        });
    },
    /**
     * del
     * @desc:展示删除弹窗
     * @param {String} id 当前点击数据id
     * @author liufan
     * @date 2022年11月29日
     **/
    del(id, type) {
      this.modalType = type;
      this.historyId = id;
      this.showDel = true;
    },
    /**
     * handleCurrentChange
     * @desc:监听页码变化
     * @param {String} val 当前页
     * @author liufan
     * @date 2022年11月29日
     **/
    handleCurrentChange(val, type) {
      this.currentPage = val;
      if (type == 'press') {
        this.getPressList();
      }
    },
    /**
     * handleSizeChange
     * @desc:监听每页数据显示数量变化
     * @param {String} val 每页展示数量
     * @author liufan
     * @date 2022年11月29日
     **/
    handleSizeChange(val) {
      this.pageSize = val;
      if (type == 'press') {
        this.getPressList();
      }
    },
    /**
     * sortChange
     * @desc:监听排序变化
     * @param {Object} info 需要排序的字段及排序方式
     * @author liufan
     * @date 2022年11月29日
     **/
    sortChange(info, type) {
      let { prop } = info;
      this.sidx = prop;
      this.sord = this.sord == 'asc' ? 'desc' : 'asc';
      if (type == 'press') {
        this.getPressList();
      } else if (type == 'reset') {
        this.getResetList();
      } else if (type == 'delete') {
        this.getDeletList();
      }
    },
    /**
     * getDeletList
     * @desc:删除列表数据
     * @author liufan
     * @date 2025年12月30日
     **/
    getDeletList() {
      const { pageSize, sidx, sord, currentPage, businessId } = this;
      this.deleteLoading = true;
      let params = {
        url: deletedListJson + '?apprecordId=' + businessId,
        method: 'POST',
        data: { page: currentPage, rows: pageSize, sidx, sord }
      };
      util
        .ajax(params)
        .then((res) => {
          this.deleteTableList = res.data;
          this.total = res.totalrecords;
          this.deleteLoading = false;
        })
        .catch((err) => {
          this.deleteLoading = false;
          if (err.message && err.message !== 'canceled') {
            this.$message.error(err.message);
          }
        });
    },
    /**
     * getResetList
     * @desc:重设列表数据
     * @author liufan
     * @date 2025年12月30日
     **/
    getResetList() {
      const { pageSize, sidx, sord, currentPage, businessId } = this;
      this.resetLoading = true;
      let params = {
        url: resetJson + '?appRecordId=' + businessId,
        params: { appRecordId: businessId },
        method: 'POST',
        data: { page: currentPage, rows: pageSize, sidx, sord }
      };
      util
        .ajax(params)
        .then((res) => {
          this.resetTableList = res.data;
          this.total = res.totalrecords;
          this.resetLoading = false;
        })
        .catch((err) => {
          this.resetLoading = false;
          if (err.message && err.message !== 'canceled') {
            this.$message.error(err.message);
          }
        });
    },
    /**
     * getPressList
     * @desc:催办列表数据
     * @author liufan
     * @date 2022年11月29日
     **/
    getPressList() {
      const { historyId, pageSize, sidx, sord, currentPage } = this;
      this.pressLoading = true;
      let params = {
        url: pressListJson,
        params: { historyId },
        method: 'POST',
        data: { page: currentPage, rows: pageSize, sidx, sord, historyId }
      };
      util
        .ajax(params)
        .then((res) => {
          this.pressTableList = res.data;
          this.total = res.totalrecords;
          this.pressLoading = false;
        })
        .catch((err) => {
          this.pressLoading = false;
          if (err.message && err.message !== 'canceled') {
            this.$message.error(err.message);
          }
        });
    },
    /**
     * goPress
     * @desc:催办列表查看
     * @param {String} id 催办列表id
     * @author liufan
     * @date 2022年11月29日
     **/
    goPress(id) {
      this.historyId = id;
      this.showPress = true;
      this.getPressList();
    },
    /**
     * showFile
     * @desc:附件查看
     * @param {String} ownId 附件id
     * @author liufan
     * @date 2022年11月29日
     **/
    showFile(ownId) {
      this.wfpendingid = ownId;
      this.showFileList = true;
    },
    /**
     * handleChange
     * @desc:切换排序方式
     * @author liufan
     * @date 2022年11月22日
     **/
    handleChange(key, value) {
      if (value) {
        this[key] = value;
      }
      // this.show = false;
      this.loading = util.loading(this.$loading, '加载中...');
      this.getFlowList();
    },
    async getFyListJson(type) {
      let params = {
        url: fyListJson,
        params: {
          appRecordId: this.businessId,
          status: type
        }
      };
      await util.ajax(params).then((res) => {
        if (type == 1) {
          this.untreatedReadData = res.data;
          this.untreatedReadData.map((x, i) => {
            x.sort = i + 1;
          });
        } else {
          this.processedReadData = res.data;
          this.processedReadData.map((x, i) => {
            x.sort = i + 1;
          });
        }
      });
    },
    /**
     * getFlowList
     * @desc:获取流程列表
     * @author liufan
     * @date 2022年11月22日
     **/
    getFlowList(type) {
      let params = {
        url: pendedhistoryListJson,
        params: {
          apprecordid: this.businessId,
          pendingAttr: 0,
          viewType: type || this.viewType,
          showSuggest: this.showSuggest,
          ...this.params
        }
      };
      util
        .ajax(params)
        .then((res) => {
          let {
            status,
            message,
            data: {
              adjunctCode,
              wfHistoryList,
              fyHistoryList,
              hasAgent,
              isShort,
              modify,
              canDelete,
              canBatchDelete,
              isSuperRole,
              isShowReset,
              taskReadName
            }
          } = res;
          this.loading.close();
          if (status == 'success') {
            this.flowTableInfo.adjunctCode = adjunctCode;
            this.flowTableInfo.hasAgent = hasAgent;
            this.attachmentPaperClipCssStyle =
              res.data.attachmentPaperClipCssStyle;
            this.isShort = isShort;
            this.taskReadName = taskReadName;
            this.flowData = wfHistoryList;
            this.flowData.map((x, i) => {
              x.sort = i + 1;
              if (!x.deptid) {
                x.deptid = x.deptName;
              }
            });
            this.splitReadingData = fyHistoryList;
            this.splitReadingData.map((x, i) => {
              x.sort = i + 1;
            });
            this.modify = modify;
            this.canDelete = canDelete;
            this.canBatchDelete = canBatchDelete;
            this.isSuperRole = isSuperRole;
            this.isShowReset = isShowReset;
            this.show = true;
            if (this.height == 'auto') {
              this.$nextTick(() => {
                this.content.map((x) => {
                  this[`${x.type}Height`] = this.$refs[x.type][0].offsetHeight;
                });
              });
            }
            if (this.contents.indexOf('circular') != -1) {
              this.getCircularReadList();
            } else {
              this.$nextTick(() => {
                this.getListCount(this.flowListCount);
              });
            }
          } else {
            this.$message.error(message || '系统错误，请联系管理员！');
          }
        })
        .catch((err) => {
          this.loading.close();
          if (err.message && err.message !== 'canceled') {
            this.$message.error(err.message);
          }
          this.show = true;
        });
    },
    /**
     * handleClick
     * @desc:表单点击事件
     * @param {Object} val 当前点击行数据及按钮
     * @author liufan
     * @date 2022年11月10日
     **/
    handleClick(val) {
      const {
        handle: { text },
        row: { id, status }
      } = val;
      if (text === '置为失效') {
        if (status == 0) {
          this.$confirm('您确定要置为失效吗?')
            .then(() => {
              this.loading = util.loading(this.$loading, '提交中...');
              let param = {
                url: deletePresetInfo,
                headers: { Accept: 'application/json,text/plain' },
                method: 'post',
                params: { id }
              };
              util
                .ajax(param)
                .then((res) => {
                  const { status, message } = res;
                  this.loading.close();
                  if (status === 'success') {
                    this.$message.success('操作成功');
                    this.getListInfo();
                  } else {
                    this.$message.error(message || '系统错误，请联系管理员！');
                  }
                })
                .catch((err) => {
                  this.loading.close();
                  if (err.message && err.message !== 'canceled') {
                    this.$message.error(err.message);
                  }
                });
            })
            .catch((e) => {
              // on cancel
            });
        } else {
          this.$message.warning('当前数据已为失效状态');
        }
      }
    },
    /**
     * getCodeValue
     * @desc:获取代码表过滤后的值
     * @param {String} value 展示数据的代码值
     * @param {String} type 代码表类型
     * @author liufan
     * @date 2022年11月10日
     **/
    getCodeValue(value, type) {
      let val = this[type].filter((item) => item.cciValue == value);
      return val[0].shortName;
    },
    /**
     * getSysInfo
     * @desc:获取代码表
     * @param {String} code 编码code值
     * @author liufan
     * @date 2022年11月10日
     **/
    getSysInfo(code) {
      let params = {
        url: findCodeValues,
        params: { ccCode: code }
      };
      util
        .ajax(params)
        .then((res) => {
          const { status, message, data } = res;
          if (status == 'success') {
            this[code] = data;
          } else {
            this.$message.error(message || '系统错误，请联系管理员！');
          }
        })
        .catch((e) => {});
    },
    /**
     * getListInfo
     * @desc:获取预设列表数据
     * @author liufan
     * @date 2022年11月10日
     **/
    getListInfo() {
      let param = {
        url: toPresetInfoListIndex,
        params: { apprecordid: this.businessId }
      };
      util
        .ajax(param)
        .then((res) => {
          let {
            status,
            message,
            data: {
              presetInfoList,
              presetInfoListHiddenColumns,
              canDelete,
              currentUserHasPresetInfoAuth
            }
          } = res;
          this.loading.close();
          if (status == 'success') {
            if (presetInfoList) {
              this.presetData = presetInfoList;
              this.presetData.map((x, i) => {
                x.sort = i + 1;
              });
            }
            this.presetInfoListHiddenColumns = presetInfoListHiddenColumns;
            this.currentUserHasPresetInfoAuth = currentUserHasPresetInfoAuth;
            this.canDelete = canDelete;
          } else {
            this.$message.error(message || '系统错误，请联系管理员！');
          }
        })
        .catch((err) => {
          this.loading.close();
          if (err.message && err.message !== 'canceled') {
            this.$message.error(err.message);
          }
        });
    }
  }
};
</script>

<style></style>
