index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索工作栏 -->
  4. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  5. <el-form-item label="流程id" prop="processInstanceId">
  6. <el-input v-model="queryParams.processInstanceId" placeholder="请输入流程id" clearable size="small" @keyup.enter.native="handleQuery"/>
  7. </el-form-item>
  8. <el-form-item label="状态" prop="status">
  9. <el-select v-model="queryParams.status" placeholder="请选择状态">
  10. <el-option
  11. v-for="dict in leaveStatusData"
  12. :key="parseInt(dict.value)"
  13. :label="dict.label"
  14. :value="parseInt(dict.value)"
  15. />
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="开始时间">
  19. <el-date-picker v-model="dateRangeStartTime" size="small" style="width: 240px" value-format="yyyy-MM-dd"
  20. type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
  21. </el-form-item>
  22. <el-form-item label="结束时间">
  23. <el-date-picker v-model="dateRangeEndTime" size="small" style="width: 240px" value-format="yyyy-MM-dd"
  24. type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
  25. </el-form-item>
  26. <el-form-item label="请假类型" prop="leaveType">
  27. <el-select v-model="queryParams.leaveType" placeholder="请选择请假类型">
  28. <el-option
  29. v-for="dict in leaveTypeDictData"
  30. :key="dict.value"
  31. :label="dict.label"
  32. :value="dict.value"
  33. />
  34. </el-select>
  35. </el-form-item>
  36. <el-form-item label="原因" prop="reason">
  37. <el-input v-model="queryParams.reason" placeholder="请输入原因" clearable size="small" @keyup.enter.native="handleQuery"/>
  38. </el-form-item>
  39. <el-form-item label="申请时间">
  40. <el-date-picker v-model="dateRangeApplyTime" size="small" style="width: 240px" value-format="yyyy-MM-dd"
  41. type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
  42. </el-form-item>
  43. <el-form-item>
  44. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  45. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  46. </el-form-item>
  47. </el-form>
  48. <!-- 操作工具栏 -->
  49. <el-row :gutter="10" class="mb8">
  50. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  51. </el-row>
  52. <!-- 列表 -->
  53. <el-table v-loading="loading" :data="list">
  54. <el-table-column label="请假表单主键" align="center" prop="id" />
  55. <el-table-column label="状态" align="center" prop="status" :formatter="statusFormat" />
  56. <el-table-column label="申请人id" align="center" prop="userId" />
  57. <el-table-column label="开始时间" align="center" prop="startTime" width="180">
  58. <template slot-scope="scope">
  59. <span>{{ parseTime(scope.row.startTime) }}</span>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="结束时间" align="center" prop="endTime" width="180">
  63. <template slot-scope="scope">
  64. <span>{{ parseTime(scope.row.endTime) }}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="请假类型" align="center" prop="leaveType" :formatter="leaveTypeFormat" />
  68. <el-table-column label="原因" align="center" prop="reason" />
  69. <el-table-column label="申请时间" align="center" prop="applyTime" width="180">
  70. <template slot-scope="scope">
  71. <span>{{ parseTime(scope.row.applyTime) }}</span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  75. <template slot-scope="scope">
  76. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleStep(scope.row)">审批进度</el-button>
  77. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleDetail(scope.row)">详情</el-button>
  78. </template>
  79. </el-table-column>
  80. </el-table>
  81. <!-- 分页组件 -->
  82. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  83. @pagination="getList"/>
  84. <!-- 对话框(添加 / 修改) -->
  85. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  86. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  87. <el-form-item label="开始时间" prop="startTime">
  88. <el-date-picker clearable size="small" v-model="form.startTime" type="date" value-format="timestamp" placeholder="选择开始时间" />
  89. </el-form-item>
  90. <el-form-item label="结束时间" prop="endTime">
  91. <el-date-picker clearable size="small" v-model="form.endTime" type="date" value-format="timestamp" placeholder="选择结束时间" />
  92. </el-form-item>
  93. <el-form-item label="请假类型" prop="leaveType">
  94. <el-select v-model="form.leaveType" placeholder="请选择">
  95. <el-option
  96. v-for="dict in leaveTypeDictData"
  97. :key="dict.value"
  98. :label="dict.label"
  99. :value="dict.value"
  100. />
  101. </el-select>
  102. </el-form-item>
  103. <el-form-item label="原因" prop="reason">
  104. <el-input v-model="form.reason" placeholder="请输入原因" />
  105. </el-form-item>
  106. <el-form-item label="申请时间" prop="applyTime">
  107. <el-date-picker clearable size="small" v-model="form.applyTime" type="date" value-format="timestamp" placeholder="选择申请时间" />
  108. </el-form-item>
  109. </el-form>
  110. <div slot="footer" class="dialog-footer">
  111. <el-button type="primary" @click="submitForm">确 定</el-button>
  112. <el-button @click="cancel">取 消</el-button>
  113. </div>
  114. </el-dialog>
  115. <el-dialog :title="title" :visible.sync="dialogDetailVisible" width="500px" append-to-body>
  116. <el-form ref="form" :model="form" label-width="80px">
  117. <el-form-item label="状态" >
  118. {{ getDictDataLabel(DICT_TYPE.OA_LEAVE_STATUS, form.status) }}
  119. </el-form-item>
  120. <el-form-item label="申请人id" >{{form.userId}}</el-form-item>
  121. <el-form-item label="开始时间" >{{ parseTime(form.startTime) }}</el-form-item>
  122. <el-form-item label="结束时间" prop="endTime">{{ parseTime(form.endTime) }}</el-form-item>
  123. <el-form-item label="请假类型" prop="leaveType">
  124. {{ getDictDataLabel(DICT_TYPE.OA_LEAVE_TYPE, form.leaveType) }}
  125. </el-form-item>
  126. <el-form-item label="原因" prop="reason">{{form.reason}}</el-form-item>
  127. <el-form-item label="申请时间" prop="applyTime">{{ parseTime(form.applyTime) }}</el-form-item>
  128. </el-form>
  129. <div slot="footer" class="dialog-footer">
  130. <el-button type="primary" @click="dialogDetailVisible = false">确 定</el-button>
  131. <el-button @click="dialogDetailVisible = false">取 消</el-button>
  132. </div>
  133. </el-dialog>
  134. <el-dialog :title="title" :visible.sync="dialogStepsVisible" width="600px" append-to-body>
  135. <el-steps :active="stepActive" finish-status="success" >
  136. <el-step :title="stepTitle(item)" :description="stepAssignee(item.assignee)" icon="el-icon-edit" v-for="(item) in handleTask.historyTask"></el-step>
  137. </el-steps>
  138. <br/>
  139. <el-steps direction="vertical" :active="stepActive">
  140. <el-step :title="stepTitle(item)" :description="stepDes(item)" v-for="(item) in handleTask.historyTask"></el-step>
  141. </el-steps>
  142. <div slot="footer" class="dialog-footer">
  143. <el-button type="primary" @click="dialogStepsVisible = false">确 定</el-button>
  144. <el-button @click="dialogStepsVisible = false">取 消</el-button>
  145. </div>
  146. </el-dialog>
  147. </div>
  148. </template>
  149. <script>
  150. import { createLeave, updateLeave, deleteLeave, getLeave, getLeavePage, exportLeaveExcel } from "@/api/oa/leave"
  151. import { getDictDataLabel, getDictDatas, DICT_TYPE } from '@/utils/dict'
  152. import { processHistorySteps } from '@/api/oa/todo'
  153. export default {
  154. name: "Leave",
  155. components: {
  156. },
  157. data() {
  158. return {
  159. // 遮罩层
  160. loading: true,
  161. // 显示搜索条件
  162. showSearch: true,
  163. // 总条数
  164. total: 0,
  165. // 请假申请列表
  166. list: [],
  167. // 弹出层标题
  168. title: "",
  169. // 是否显示弹出层
  170. open: false,
  171. //进度弹出层
  172. dialogDetailVisible: false,
  173. //审批进度弹出层
  174. dialogStepsVisible: false,
  175. dateRangeStartTime: [],
  176. dateRangeEndTime: [],
  177. dateRangeApplyTime: [],
  178. // 查询参数
  179. queryParams: {
  180. pageNo: 1,
  181. pageSize: 10,
  182. processInstanceId: null,
  183. status: null,
  184. userId: null,
  185. leaveType: null,
  186. reason: null,
  187. },
  188. // 表单参数
  189. form: {},
  190. handleTask: {
  191. historyTask:[],
  192. taskVariable: "",
  193. formObject: {}
  194. },
  195. steps:[{
  196. stepName:"步骤一"
  197. }],
  198. // 表单校验
  199. rules: {
  200. startTime: [{ required: true, message: "开始时间不能为空", trigger: "blur" }],
  201. endTime: [{ required: true, message: "结束时间不能为空", trigger: "blur" }],
  202. applyTime: [{ required: true, message: "申请时间不能为空", trigger: "blur" }],
  203. },
  204. statusFormat(row, column) {
  205. return getDictDataLabel(DICT_TYPE.OA_LEAVE_STATUS, row.status)
  206. },
  207. leaveTypeFormat(row, column) {
  208. return getDictDataLabel(DICT_TYPE.OA_LEAVE_TYPE, row.leaveType)
  209. },
  210. leaveTypeDictData: getDictDatas(DICT_TYPE.OA_LEAVE_TYPE),
  211. leaveStatusData: getDictDatas(DICT_TYPE.OA_LEAVE_STATUS)
  212. };
  213. },
  214. created() {
  215. this.getList();
  216. },
  217. computed: {
  218. stepActive: function () {
  219. let idx = 0;
  220. for (let i = 0; i < this.handleTask.historyTask.length; i++) {
  221. if (this.handleTask.historyTask[i].status === 1) {
  222. idx = idx + 1;
  223. } else {
  224. break;
  225. }
  226. }
  227. return idx;
  228. },
  229. stepTitle() {
  230. return function (item) {
  231. let name = item.stepName;
  232. if (item.status === 1) {
  233. name += '(已完成)'
  234. }
  235. if (item.status === 0) {
  236. name += '(进行中)'
  237. }
  238. return name;
  239. }
  240. },
  241. stepDes() {
  242. return function (item) {
  243. let desc = "";
  244. if (item.status === 1) {
  245. desc += "审批人:[" + item.assignee + "] 审批意见: [" + item.comment + "] 审批时间: " + this.parseTime(item.endTime);
  246. }
  247. return desc;
  248. }
  249. },
  250. stepAssignee() {
  251. return function (assignee) {
  252. let desc = "";
  253. if(assignee){
  254. desc += "办理人:[" + assignee + "]";
  255. }else{
  256. desc += "办理人未签收";
  257. }
  258. return desc;
  259. }
  260. }
  261. },
  262. methods: {
  263. /** 查询列表 */
  264. getList() {
  265. this.loading = true;
  266. // 处理查询参数
  267. let params = {...this.queryParams};
  268. this.addBeginAndEndTime(params, this.dateRangeStartTime, 'startTime');
  269. this.addBeginAndEndTime(params, this.dateRangeEndTime, 'endTime');
  270. this.addBeginAndEndTime(params, this.dateRangeApplyTime, 'applyTime');
  271. // 执行查询
  272. getLeavePage(params).then(response => {
  273. this.list = response.data.list;
  274. this.total = response.data.total;
  275. this.loading = false;
  276. });
  277. },
  278. /** 取消按钮 */
  279. cancel() {
  280. this.open = false;
  281. this.reset();
  282. },
  283. /** 表单重置 */
  284. reset() {
  285. this.form = {
  286. id: undefined,
  287. processInstanceId: undefined,
  288. status: undefined,
  289. userId: undefined,
  290. startTime: undefined,
  291. endTime: undefined,
  292. leaveType: undefined,
  293. reason: undefined,
  294. applyTime: undefined,
  295. };
  296. this.resetForm("form");
  297. },
  298. /** 搜索按钮操作 */
  299. handleQuery() {
  300. this.queryParams.pageNo = 1;
  301. this.getList();
  302. },
  303. /** 重置按钮操作 */
  304. resetQuery() {
  305. this.dateRangeStartTime = [];
  306. this.dateRangeEndTime = [];
  307. this.dateRangeApplyTime = [];
  308. this.resetForm("queryForm");
  309. this.handleQuery();
  310. },
  311. /** 新增按钮操作 */
  312. handleAdd() {
  313. this.reset();
  314. this.open = true;
  315. this.title = "添加请假申请";
  316. },
  317. /** 详情按钮操作 */
  318. handleDetail(row) {
  319. this.reset();
  320. const id = row.id;
  321. getLeave(id).then(response => {
  322. this.form = response.data;
  323. this.dialogDetailVisible = true
  324. this.title = "请假详情";
  325. });
  326. },
  327. /** 提交按钮 */
  328. submitForm() {
  329. this.$refs["form"].validate(valid => {
  330. if (!valid) {
  331. return;
  332. }
  333. // 修改的提交
  334. if (this.form.id != null) {
  335. updateLeave(this.form).then(response => {
  336. this.msgSuccess("修改成功");
  337. this.open = false;
  338. this.getList();
  339. });
  340. return;
  341. }
  342. // 添加的提交
  343. createLeave(this.form).then(response => {
  344. this.msgSuccess("新增成功");
  345. this.open = false;
  346. this.getList();
  347. });
  348. });
  349. },
  350. /** 审批进度 */
  351. handleStep(row) {
  352. const id = row.processInstanceId;
  353. processHistorySteps(id).then(response => {
  354. this.handleTask.historyTask = response.data;
  355. this.dialogStepsVisible = true
  356. this.title = "审批进度";
  357. });
  358. },
  359. /** 导出按钮操作 */
  360. handleExport() {
  361. // 处理查询参数
  362. let params = {...this.queryParams};
  363. params.pageNo = undefined;
  364. params.pageSize = undefined;
  365. this.addBeginAndEndTime(params, this.dateRangeStartTime, 'startTime');
  366. this.addBeginAndEndTime(params, this.dateRangeEndTime, 'endTime');
  367. this.addBeginAndEndTime(params, this.dateRangeApplyTime, 'applyTime');
  368. // 执行导出
  369. this.$confirm('是否确认导出所有请假申请数据项?', "警告", {
  370. confirmButtonText: "确定",
  371. cancelButtonText: "取消",
  372. type: "warning"
  373. }).then(function() {
  374. return exportLeaveExcel(params);
  375. }).then(response => {
  376. this.downloadExcel(response, '请假申请.xls');
  377. })
  378. }
  379. }
  380. };
  381. </script>