wangting
2024-11-26 2ad2a3cdd0df63b6557789ba8a9d968984fe5da3
Source/plt-web/plt-web-ui/src/views/wel/components/UndoTaskPortlet.vue
@@ -1,199 +1,114 @@
<template>
  <!--代办任务-->
  <basic-containers  :key="loadKey">
    <div>
      <avue-crud
        ref="crud"
        :data="data"
        :option="options"
        :page.sync="pages"
        :search.sync="searchParams"
        :table-loading="loading"
        @search-change="handleSearch"
        @search-reset="handleReset"
        @current-change="currentChange"
        @size-change="sizeChange">
        <template slot="title" slot-scope="{row}">
          <el-link type="primary" @click="linkClickHandler(row)">{{ row.title }}</el-link>
        </template>
      </avue-crud>
    </div>
  </basic-containers>
  <basic-container title="待办流程任务">
    <avue-crud ref="crud" :data="todoData" :option="todoOption" :page.sync="page"
               :table-loading="loading"
               @on-load="onLoad"
               @cell-click="cellHandle">
      <template #menu="{size,row,index}">
        <el-button :size="size"
                   icon="el-icon-check"
                   type="text"
                   @click="gotodo(row,index)">执行
        </el-button>
      </template>
    </avue-crud>
  </basic-container>
</template>
<script>
export default {
  name: "UndoTaskPortlet",
  data() {
  data(){
    return {
      loadKey:0,
      data: [],
      options: {
        height: 'auto',
        calcHeight:210,
      loading: false,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0
      },
      // 代办流程任务data
      todoData: [],
      // 代办流程任务option
      todoOption: {
        height: 500,
        addBtn: false,
        header: false,
        align: 'center',
        index: true,
        menuWidth: 80,
        editBtn: false,
        delBtn: false,
        index: true,
        border: true,
        menu: false,
        refreshBtn: false,
        searchIcon: true,
        searchShow: true,
        menuWidth: 120,
        menuAlign: "center",
        column: [
        column: [{
          label: '任务名称',
          prop: 'taskName',
          sortable: true,
          headerAlign: 'center',
          align: 'left',
          html: true,
          width: 300,
          overHidden: true,
          formatter: (val) => {
            return '<a name="processname" href="javascript:;" style="color: #66b1ff;">' + val.variables.processName + '-' + val.taskName + '</a>'
          }
        },
          {
            label: "类型",
            prop: "msgClassifyText",
            label: '上一步处理时间',
            sortable: true,
            width: 100,
            width: 150,
            prop: 'createTime'
          },
          {
            label: "消息标题",
            prop: "title",
            search:true,
            minWidth: 400,
            label: '上一步操作人',
            sortable: true,
            searchSpan:6,
            width: 120,
            prop: 'historyActivityAssigneName'
          },
          {
            label: '流程描述',
            prop: 'processDesc',
            overHidden: true,
            slot:true,
            formatter: (val) => {
              return val.variables.processDesc
            }
          },
          {
            label: "发送时间",
            prop: "sendTime",
            width: 130,
            type:'datetime',
            overHidden: true,
            format:'yyyy-MM-dd HH:mm',
            sortable:true,
            slot: true
          },
          {
            label: '工号',
            prop: "sendUserCode",
            searchLabelWidth: 100,
            search:true,
            label: '所属流程模板',
            sortable: true,
            searchSpan:6,
            width: 130,
          },
          {
            label: "发送人姓名",
            prop: "sendUserName",
            searchLabelWidth: 100,
            search:true,
            searchSpan:6,
            sort: true,
            width: 130,
          },
          {
            label: "内容",
            overHidden:true,
            prop: "msgContent",
            minWidth: 300
          },
            overHidden: true,
            prop: 'categoryName'
          }
        ]
      },
      pages: {
        currentPage: 1,
        pageSize: 15,
        pageSizes: [15, 25, 45, 60, 100],
        total: 0,
        layout: "prev,pager,next,jumper,sizes,total",
      },
      loading: false,
      searchParams: {
        pageNum: 1,
        pageSize: 15,
      },
    };
    }
  },
  created() {
    this.getTableList();
  },
  mounted() {
    window.addEventListener('resize', this.handleResize); // 获取用户缩放事件
  },
  beforeDestroy() {
    window.removeEventListener('resize', this.handleResize); // 销毁绑定的方法
  },
  methods: {
    // 强制修改容器key值
    handleResize() {
      this.loadKey += 1;
    onLoad(page, params = {}) {
      this.loading = true;
      const query = {
        ...this.query,
        category: (params.category) ? flowCategory(params.category) : null
      };
      todoList(page.currentPage, page.pageSize, Object.assign(params, query)).then(res => {
        const data = res.data.data;
        this.page.total = data.total;
        this.todoData = data.records;
        this.loading = false;
      }).catch(error => {
        this.$message.error(error);
        this.loading = false;
      })
    },
    // 初始化根据分辨率来决定页面初始多少条数据
    createdPageSize(){
      let windowHeight = window.outerHeight;
      if(windowHeight > 1350) this.homeTable.pages.pageSize = 25;
      if(windowHeight > 1350) this.searchParams.pageSize = 25;
    },
    getTableList() {
      this.createdPageSize(); // 判断页面分辨率
      getList(this.searchParams).then(res => {
        if (res && res.success) {
          this.homeTable.data = res.data;
          this.homeTable.pages.total = res.total;
        }
      });
    },
    linkClickHandler(row){
      if(row.msgLink != null && row.msgLink != ''){
        var link = row.msgLink.replace("inner:","").replace("?","").split("&");
        var html = link.find((val=>(val.toLowerCase().startsWith("html=")|| val.toLowerCase().startsWith("html ="))));
        if(html!=null && html!=''){
          var page = html.split("=")[1].replace("-","/");
          var single = {
            fromUndo:true
          };
          link.forEach((val)=>{
            var temp = val.split("=");
            single[temp[0]] = temp[1];
          });
          this.$router.push({
            path:"/" + page,
            query:single
          });
        }
    cellHandle(row, column, cell, event) {
      if (column.property == 'taskName') {
        this.gotodo(row)
      }
    },
    // 分页选择显示多少条
    sizeChange(val) {
      this.searchParams.pageSize = val;
      this.searchParams.pageNum = 1;
      this.getTableList();
    },
    // 分页页码
    currentChange(val) {
      this.searchParams.pageNum = val;
      this.getTableList();
    },
    // 查询
    handleSearch(params, done) {
      setTimeout(() => {
        done();
        this.searchParams = { ...params };
        this.getTableList();
      }, 300);
    },
    // 清空搜索
    handleReset() {
      this.searchParams = this.defaultSearch;
      this.getTableList();
    },
    // 刷新数据
    handleRefresh() {
      this.getTableList();
    },
    gotodo(row, index) {
      this.$router.push({path: `/work/process/${flowRoute(this.flowRoutes, row.category)}/handle/${row.taskId}/${row.processInstanceId}/${row.businessId}`});
    }
  }
}
</script>