houzhongjian
2024-07-11 759b1c71011abd6b58c37d2566f3f3c208c2f1b2
提交 | 用户 | 时间
759b1c 1 <template>
H 2   <div class="app-container">
3     <!-- 搜索工作栏 -->
4     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
5       <el-form-item label="请假类型" prop="type">
6         <el-select v-model="queryParams.type" placeholder="请选择请假类型" clearable>
7           <el-option v-for="dict in leaveTypeDictData" :key="dict.value" :label="dict.label" :value="dict.value" />
8         </el-select>
9       </el-form-item>
10       <el-form-item label="申请时间" prop="createTime">
11         <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
12                         range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
13       </el-form-item>
14       <el-form-item label="结果" prop="result">
15         <el-select v-model="queryParams.result" placeholder="请选择流结果" clearable>
16           <el-option v-for="dict in this.getDictDatas(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT)"
17                      :key="dict.value" :label="dict.label" :value="dict.value"/>
18         </el-select>
19       </el-form-item>
20       <el-form-item label="原因" prop="reason">
21         <el-input v-model="queryParams.reason" placeholder="请输入原因" clearable @keyup.enter.native="handleQuery"/>
22       </el-form-item>
23       <el-form-item>
24         <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
25         <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
26       </el-form-item>
27     </el-form>
28
29     <!-- 操作工具栏 -->
30     <el-row :gutter="10" class="mb8">
31       <el-col :span="1.5">
32         <el-button type="primary" plain icon="el-icon-plus" size="mini"
33                    v-hasPermi="['bpm:oa-leave:create']" @click="handleAdd">发起请假</el-button>
34       </el-col>
35       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
36     </el-row>
37
38     <!-- 列表 -->
39     <el-table v-loading="loading" :data="list">
40       <el-table-column label="申请编号" align="center" prop="id" />
41       <el-table-column label="状态" align="center" prop="result">
42         <template v-slot="scope">
43           <dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT" :value="scope.row.result"/>
44         </template>
45       </el-table-column>
46       <el-table-column label="开始时间" align="center" prop="startTime" width="180">
47         <template v-slot="scope">
48           <span>{{ parseTime(scope.row.startTime) }}</span>
49         </template>
50       </el-table-column>
51       <el-table-column label="结束时间" align="center" prop="endTime" width="180">
52         <template v-slot="scope">
53           <span>{{ parseTime(scope.row.endTime) }}</span>
54         </template>
55       </el-table-column>
56       <el-table-column label="请假类型" align="center" prop="type">
57         <template v-slot="scope">
58           <dict-tag :type="DICT_TYPE.BPM_OA_LEAVE_TYPE" :value="scope.row.type"/>
59         </template>
60       </el-table-column>
61       <el-table-column label="原因" align="center" prop="reason" />
62       <el-table-column label="申请时间" align="center" prop="applyTime" width="180">
63         <template v-slot="scope">
64           <span>{{ parseTime(scope.row.createTime) }}</span>
65         </template>
66       </el-table-column>
67       <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
68         <template v-slot="scope">
69           <el-button size="mini" type="text" icon="el-icon-delete" @click="handleCancel(scope.row)"
70                      v-hasPermi="['bpm:oa-leave:create']" v-if="scope.row.result === 1">取消请假</el-button>
71           <el-button size="mini" type="text" icon="el-icon-view" @click="handleDetail(scope.row)"
72                      v-hasPermi="['bpm:oa-leave:query']">详情</el-button>
73           <el-button size="mini" type="text" icon="el-icon-edit" @click="handleProcessDetail(scope.row)">审批进度</el-button>
74         </template>
75       </el-table-column>
76     </el-table>
77     <!-- 分页组件 -->
78     <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
79                 @pagination="getList"/>
80
81   </div>
82 </template>
83
84 <script>
85 import { getLeavePage } from "@/api/bpm/leave"
86 import { getDictDatas, DICT_TYPE } from '@/utils/dict'
87 import {cancelProcessInstance} from "@/api/bpm/processInstance";
88
89 export default {
90   name: "BpmOALeave",
91   components: {
92   },
93   data() {
94     return {
95       // 遮罩层
96       loading: true,
97       // 显示搜索条件
98       showSearch: true,
99       // 总条数
100       total: 0,
101       // 请假申请列表
102       list: [],
103       // 查询参数
104       queryParams: {
105         pageNo: 1,
106         pageSize: 10,
107         result: null,
108         type: null,
109         reason: null,
110         createTime: []
111       },
112
113       leaveTypeDictData: getDictDatas(DICT_TYPE.BPM_OA_LEAVE_TYPE),
114       leaveResultData: getDictDatas(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT),
115     };
116   },
117   created() {
118     this.getList();
119   },
120   methods: {
121     /** 查询列表 */
122     getList() {
123       this.loading = true;
124       // 执行查询
125       getLeavePage(this.queryParams).then(response => {
126         this.list = response.data.list;
127         this.total = response.data.total;
128         this.loading = false;
129       });
130     },
131     /** 搜索按钮操作 */
132     handleQuery() {
133       this.queryParams.pageNo = 1;
134       this.getList();
135     },
136     /** 重置按钮操作 */
137     resetQuery() {
138       this.resetForm("queryForm");
139       this.handleQuery();
140     },
141     /** 新增按钮操作 */
142     handleAdd() {
143       this.$router.push({ name: "BpmOALeaveCreate"});
144     },
145     /** 详情按钮操作 */
146     handleDetail(row) {
147       this.$router.push({ name: "BpmOALeaveDetail", query: { id: row.id}});
148     },
149     /** 查看审批进度的操作 */
150     handleProcessDetail(row) {
151       this.$router.push({ name: "BpmProcessInstanceDetail", query: { id: row.processInstanceId}});
152     },
153     /** 取消请假 */
154     handleCancel(row) {
155       const id = row.processInstanceId;
156       this.$prompt('请输入取消原因?', "取消流程", {
157         type: 'warning',
158         confirmButtonText: "确定",
159         cancelButtonText: "取消",
160         inputPattern: /^[\s\S]*.*\S[\s\S]*$/, // 判断非空,且非空格
161         inputErrorMessage: "取消原因不能为空",
162       }).then(({ value }) => {
163         return cancelProcessInstance(id, value);
164       }).then(() => {
165         this.getList();
166         this.$modal.msgSuccess("取消成功");
167       })
168     }
169   }
170 };
171 </script>