index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <div class="p-2">
  3. <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
  4. <div v-show="showSearch" class="search">
  5. <el-form ref="queryFormRef" :model="queryParams" :inline="true">
  6. <el-form-item label="请假天数" prop="startLeaveDays">
  7. <el-input v-model="queryParams.startLeaveDays" placeholder="请输入请假天数" clearable @keyup.enter="handleQuery" />
  8. </el-form-item>
  9. <el-form-item prop="endLeaveDays"> 至 </el-form-item>
  10. <el-form-item prop="endLeaveDays">
  11. <el-input v-model="queryParams.endLeaveDays" placeholder="请输入请假天数" clearable @keyup.enter="handleQuery" />
  12. </el-form-item>
  13. <el-form-item>
  14. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  15. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  16. </el-form-item>
  17. </el-form>
  18. </div>
  19. </transition>
  20. <el-card shadow="never">
  21. <template #header>
  22. <el-row :gutter="10" class="mb8">
  23. <el-col :span="1.5">
  24. <el-button v-hasPermi="['demo:leave:add']" type="primary" plain icon="Plus" @click="handleAdd">新增</el-button>
  25. </el-col>
  26. <el-col :span="1.5">
  27. <el-button v-hasPermi="['demo:leave:export']" type="warning" plain icon="Download" @click="handleExport">导出</el-button>
  28. </el-col>
  29. <right-toolbar v-model:showSearch="showSearch" @query-table="getList"></right-toolbar>
  30. </el-row>
  31. </template>
  32. <el-table v-loading="loading" :data="leaveList" @selection-change="handleSelectionChange">
  33. <el-table-column type="selection" width="55" align="center" />
  34. <el-table-column v-if="false" label="主键" align="center" prop="id" />
  35. <el-table-column label="请假类型" align="center">
  36. <template #default="scope">
  37. <el-tag>{{ options.find((e) => e.value === scope.row.leaveType)?.label }}</el-tag>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="开始时间" align="center" prop="startDate">
  41. <template #default="scope">
  42. <span>{{ parseTime(scope.row.startDate, '{y}-{m}-{d}') }}</span>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="结束时间" align="center" prop="endDate">
  46. <template #default="scope">
  47. <span>{{ parseTime(scope.row.endDate, '{y}-{m}-{d}') }}</span>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="请假天数" align="center" prop="leaveDays" />
  51. <el-table-column label="请假原因" align="center" prop="remark" />
  52. <el-table-column align="center" label="流程状态" min-width="70">
  53. <template #default="scope">
  54. <dict-tag :options="wf_business_status" :value="scope.row.processInstanceVo.businessStatus"></dict-tag>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  58. <template #default="scope">
  59. <el-button
  60. v-if="
  61. scope.row.processInstanceVo.businessStatus === 'draft' ||
  62. scope.row.processInstanceVo.businessStatus === 'cancel' ||
  63. scope.row.processInstanceVo.businessStatus === 'back'
  64. "
  65. v-hasPermi="['demo:leave:edit']"
  66. size="small"
  67. link
  68. type="primary"
  69. icon="Edit"
  70. @click="handleUpdate(scope.row)"
  71. >修改</el-button
  72. >
  73. <el-button
  74. v-if="
  75. scope.row.processInstanceVo.businessStatus === 'draft' ||
  76. scope.row.processInstanceVo.businessStatus === 'cancel' ||
  77. scope.row.processInstanceVo.businessStatus === 'back'
  78. "
  79. v-hasPermi="['demo:leave:remove']"
  80. size="small"
  81. link
  82. type="primary"
  83. icon="Delete"
  84. @click="handleDelete(scope.row)"
  85. >删除</el-button
  86. >
  87. <el-button link type="primary" size="small" icon="View" @click="handleView(scope.row)">查看</el-button>
  88. <el-button
  89. v-if="scope.row.processInstanceVo.businessStatus === 'waiting'"
  90. link
  91. size="small"
  92. type="primary"
  93. icon="Notification"
  94. @click="handleCancelProcessApply(scope.row.id)"
  95. >撤销</el-button
  96. >
  97. </template>
  98. </el-table-column>
  99. </el-table>
  100. <pagination v-show="total > 0" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" :total="total" @pagination="getList" />
  101. </el-card>
  102. </div>
  103. </template>
  104. <script setup name="Leave" lang="ts">
  105. import { delLeave, listLeave } from '@/api/workflow/leave';
  106. import { cancelProcessApply } from '@/api/workflow/processInstance';
  107. import { LeaveForm, LeaveQuery, LeaveVO } from '@/api/workflow/leave/types';
  108. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  109. const { wf_business_status } = toRefs<any>(proxy?.useDict('wf_business_status'));
  110. const leaveList = ref<LeaveVO[]>([]);
  111. const loading = ref(true);
  112. const showSearch = ref(true);
  113. const ids = ref<Array<string | number>>([]);
  114. const single = ref(true);
  115. const multiple = ref(true);
  116. const total = ref(0);
  117. const options = [
  118. {
  119. value: '1',
  120. label: '事假'
  121. },
  122. {
  123. value: '2',
  124. label: '调休'
  125. },
  126. {
  127. value: '3',
  128. label: '病假'
  129. },
  130. {
  131. value: '4',
  132. label: '婚假'
  133. }
  134. ];
  135. const queryFormRef = ref<ElFormInstance>();
  136. const data = reactive<PageData<LeaveForm, LeaveQuery>>({
  137. form: {},
  138. queryParams: {
  139. pageNum: 1,
  140. pageSize: 10,
  141. startLeaveDays: undefined,
  142. endLeaveDays: undefined
  143. },
  144. rules: {}
  145. });
  146. const { queryParams } = toRefs(data);
  147. /** 查询请假列表 */
  148. const getList = async () => {
  149. loading.value = true;
  150. const res = await listLeave(queryParams.value);
  151. leaveList.value = res.rows;
  152. total.value = res.total;
  153. loading.value = false;
  154. };
  155. /** 搜索按钮操作 */
  156. const handleQuery = () => {
  157. queryParams.value.pageNum = 1;
  158. getList();
  159. };
  160. /** 重置按钮操作 */
  161. const resetQuery = () => {
  162. queryFormRef.value?.resetFields();
  163. handleQuery();
  164. };
  165. /** 多选框选中数据 */
  166. const handleSelectionChange = (selection: LeaveVO[]) => {
  167. ids.value = selection.map((item) => item.id);
  168. single.value = selection.length != 1;
  169. multiple.value = !selection.length;
  170. };
  171. /** 新增按钮操作 */
  172. const handleAdd = () => {
  173. proxy.$tab.closePage(proxy.$route);
  174. proxy.$router.push(`/workflow/leaveEdit/index/add/add`);
  175. proxy.$router.push({
  176. path: `/workflow/leaveEdit/index`,
  177. query: {
  178. type: 'add'
  179. }
  180. });
  181. };
  182. /** 修改按钮操作 */
  183. const handleUpdate = (row?: LeaveVO) => {
  184. proxy.$tab.closePage(proxy.$route);
  185. proxy.$router.push({
  186. path: `/workflow/leaveEdit/index`,
  187. query: {
  188. id: row.id,
  189. type: 'update'
  190. }
  191. });
  192. };
  193. /** 查看按钮操作 */
  194. const handleView = (row?: LeaveVO) => {
  195. proxy.$tab.closePage(proxy.$route);
  196. proxy.$router.push({
  197. path: `/workflow/leaveEdit/index`,
  198. query: {
  199. id: row.id,
  200. type: 'view'
  201. }
  202. });
  203. };
  204. /** 删除按钮操作 */
  205. const handleDelete = async (row?: LeaveVO) => {
  206. const _ids = row?.id || ids.value;
  207. await proxy?.$modal.confirm('是否确认删除请假编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
  208. await delLeave(_ids);
  209. proxy?.$modal.msgSuccess('删除成功');
  210. await getList();
  211. };
  212. /** 导出按钮操作 */
  213. const handleExport = () => {
  214. proxy?.download(
  215. 'workflow/leave/export',
  216. {
  217. ...queryParams.value
  218. },
  219. `leave_${new Date().getTime()}.xlsx`
  220. );
  221. };
  222. /** 撤销按钮操作 */
  223. const handleCancelProcessApply = async (id: string) => {
  224. await proxy?.$modal.confirm('是否确认撤销当前单据?');
  225. loading.value = true;
  226. await cancelProcessApply(id).finally(() => (loading.value = false));
  227. await getList();
  228. proxy?.$modal.msgSuccess('撤销成功');
  229. };
  230. onMounted(() => {
  231. getList();
  232. });
  233. </script>