index.vue 6.96 KB
Newer Older
sunhongwei's avatar
sunhongwei committed
1 2
<template>
  <div class="app-container">
Marcus's avatar
Marcus committed
3
    <doc-alert :title="$t('工作流')" url="https://doc.iocoder.cn/bpm" />
sunhongwei's avatar
sunhongwei committed
4 5 6

    <!-- 搜索工作栏 -->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
Marcus's avatar
Marcus committed
7 8
      <el-form-item :label="$t('请假类型')" prop="type">
        <el-select v-model="queryParams.type" :placeholder="$t('请选择请假类型')" clearable>
sunhongwei's avatar
sunhongwei committed
9 10 11
          <el-option v-for="dict in leaveTypeDictData" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
Marcus's avatar
Marcus committed
12
      <el-form-item :label="$t('申请时间')">
sunhongwei's avatar
sunhongwei committed
13 14 15
        <el-date-picker v-model="dateRangeCreateTime" style="width: 240px" value-format="yyyy-MM-dd"
                        type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
      </el-form-item>
Marcus's avatar
Marcus committed
16 17
      <el-form-item :label="$t('结果')" prop="result">
        <el-select v-model="queryParams.result" :placeholder="$t('请选择流结果')" clearable>
sunhongwei's avatar
sunhongwei committed
18 19 20 21
          <el-option v-for="dict in this.getDictDatas(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT)"
                     :key="dict.value" :label="dict.label" :value="dict.value"/>
        </el-select>
      </el-form-item>
Marcus's avatar
Marcus committed
22 23
      <el-form-item :label="$t('原因')" prop="reason">
        <el-input v-model="queryParams.reason" :placeholder="$t('请输入原因')" clearable @keyup.enter.native="handleQuery"/>
sunhongwei's avatar
sunhongwei committed
24 25
      </el-form-item>
      <el-form-item>
Marcus's avatar
Marcus committed
26 27
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">{{ $t('搜索') }}</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">{{ $t('重置') }}</el-button>
sunhongwei's avatar
sunhongwei committed
28 29 30 31 32 33 34
      </el-form-item>
    </el-form>

    <!-- 操作工具栏 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini"
Marcus's avatar
Marcus committed
35
                   v-hasPermi="['bpm:oa-leave:create']" @click="handleAdd">{{ $t('发起请假') }}</el-button>
sunhongwei's avatar
sunhongwei committed
36 37 38 39 40 41
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 列表 -->
    <el-table v-loading="loading" :data="list">
Marcus's avatar
Marcus committed
42 43
      <el-table-column :label="$t('申请编号')" align="center" prop="id" />
      <el-table-column :label="$t('状态')" align="center" prop="result">
sunhongwei's avatar
sunhongwei committed
44 45 46 47
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT" :value="scope.row.result"/>
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
48
      <el-table-column :label="$t('开始时间')" align="center" prop="startTime" width="180">
sunhongwei's avatar
sunhongwei committed
49 50 51 52
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.startTime) }}</span>
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
53
      <el-table-column :label="$t('结束时间')" align="center" prop="endTime" width="180">
sunhongwei's avatar
sunhongwei committed
54 55 56 57
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.endTime) }}</span>
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
58
      <el-table-column :label="$t('请假类型')" align="center" prop="type">
sunhongwei's avatar
sunhongwei committed
59 60 61 62
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.BPM_OA_LEAVE_TYPE" :value="scope.row.type"/>
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
63 64
      <el-table-column :label="$t('原因')" align="center" prop="reason" />
      <el-table-column :label="$t('申请时间')" align="center" prop="applyTime" width="180">
sunhongwei's avatar
sunhongwei committed
65 66 67 68
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
69
      <el-table-column :label="$t('操作')" align="center" class-name="small-padding fixed-width" width="200">
sunhongwei's avatar
sunhongwei committed
70 71
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleCancel(scope.row)"
Marcus's avatar
Marcus committed
72
                     v-hasPermi="['bpm:oa-leave:create']" v-if="scope.row.result === 1">{{ $t('取消请假') }}</el-button>
sunhongwei's avatar
sunhongwei committed
73
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleDetail(scope.row)"
Marcus's avatar
Marcus committed
74 75
                     v-hasPermi="['bpm:oa-leave:query']">{{ $t('详情') }}</el-button>
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleProcessDetail(scope.row)">{{ $t('审批进度') }}</el-button>
sunhongwei's avatar
sunhongwei committed
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>

  </div>
</template>

<script>
import { getLeavePage } from "@/api/bpm/leave"
import { getDictDatas, DICT_TYPE } from '@/utils/dict'
import {cancelProcessInstance} from "@/api/bpm/processInstance";

export default {
  name: "Leave",
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 请假申请列表
      list: [],
      //审批进度弹出层
      dateRangeCreateTime: [],
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        result: null,
        type: null,
        reason: null,
      },

      leaveTypeDictData: getDictDatas(DICT_TYPE.BPM_OA_LEAVE_TYPE),
      leaveResultData: getDictDatas(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT),
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      // 处理查询参数
      let params = {...this.queryParams};
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
      // 执行查询
      getLeavePage(params).then(response => {
        this.list = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRangeCreateTime = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.$router.push({ path: "/bpm/oa/leave/create"});
    },
    /** 详情按钮操作 */
    handleDetail(row) {
      this.$router.push({ path: "/bpm/oa/leave/detail", query: { id: row.id}});
    },
    /** 查看审批进度的操作 */
    handleProcessDetail(row) {
      this.$router.push({ path: "/bpm/process-instance/detail", query: { id: row.processInstanceId}});
    },
    /** 取消请假 */
    handleCancel(row) {
      const id = row.processInstanceId;
Marcus's avatar
Marcus committed
163
      this.$prompt('请输入取消原因?', this.$t("取消流程"), {
sunhongwei's avatar
sunhongwei committed
164
        type: 'warning',
Marcus's avatar
Marcus committed
165 166
        confirmButtonText: this.$t("确定"),
        cancelButtonText: this.$t("取消"),
sunhongwei's avatar
sunhongwei committed
167
        inputPattern: /^[\s\S]*.*[^\s][\s\S]*$/, // 判断非空,且非空格
Marcus's avatar
Marcus committed
168
        inputErrorMessage: this.$t("取消原因不能为空"),
sunhongwei's avatar
sunhongwei committed
169 170 171 172 173 174 175 176 177 178
      }).then(({ value }) => {
        return cancelProcessInstance(id, value);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("取消成功");
      })
    }
  }
};
</script>