index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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="['workflow: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="['workflow: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.status"></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="scope.row.status === 'draft' || scope.row.status === 'cancel' || scope.row.status === 'back'"
  61. v-hasPermi="['workflow:leave:edit']"
  62. size="small"
  63. link
  64. type="primary"
  65. icon="Edit"
  66. @click="handleUpdate(scope.row)"
  67. >修改</el-button
  68. >
  69. <el-button
  70. v-if="scope.row.status === 'draft' || scope.row.status === 'cancel' || scope.row.status === 'back'"
  71. v-hasPermi="['workflow:leave:remove']"
  72. size="small"
  73. link
  74. type="primary"
  75. icon="Delete"
  76. @click="handleDelete(scope.row)"
  77. >删除</el-button
  78. >
  79. <el-button link type="primary" size="small" icon="View" @click="handleView(scope.row)">查看</el-button>
  80. <el-button
  81. v-if="scope.row.status === 'waiting'"
  82. link
  83. size="small"
  84. type="primary"
  85. icon="Notification"
  86. @click="handleCancelProcessApply(scope.row.id)"
  87. >撤销</el-button
  88. >
  89. </template>
  90. </el-table-column>
  91. </el-table>
  92. <pagination v-show="total > 0" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" :total="total" @pagination="getList" />
  93. </el-card>
  94. </div>
  95. </template>
  96. <script setup name="Leave" lang="ts">
  97. import { delLeave, listLeave } from '@/api/workflow/leave';
  98. import { cancelProcessApply } from '@/api/workflow/processInstance';
  99. import { LeaveForm, LeaveQuery, LeaveVO } from '@/api/workflow/leave/types';
  100. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  101. const { wf_business_status } = toRefs<any>(proxy?.useDict('wf_business_status'));
  102. const leaveList = ref<LeaveVO[]>([]);
  103. const loading = ref(true);
  104. const showSearch = ref(true);
  105. const ids = ref<Array<string | number>>([]);
  106. const single = ref(true);
  107. const multiple = ref(true);
  108. const total = ref(0);
  109. const options = [
  110. {
  111. value: '1',
  112. label: '事假'
  113. },
  114. {
  115. value: '2',
  116. label: '调休'
  117. },
  118. {
  119. value: '3',
  120. label: '病假'
  121. },
  122. {
  123. value: '4',
  124. label: '婚假'
  125. }
  126. ];
  127. const queryFormRef = ref<ElFormInstance>();
  128. const data = reactive<PageData<LeaveForm, LeaveQuery>>({
  129. form: {},
  130. queryParams: {
  131. pageNum: 1,
  132. pageSize: 10,
  133. startLeaveDays: undefined,
  134. endLeaveDays: undefined
  135. },
  136. rules: {}
  137. });
  138. const { queryParams } = toRefs(data);
  139. /** 查询请假列表 */
  140. const getList = async () => {
  141. loading.value = true;
  142. const res = await listLeave(queryParams.value);
  143. leaveList.value = res.rows;
  144. total.value = res.total;
  145. loading.value = false;
  146. };
  147. /** 搜索按钮操作 */
  148. const handleQuery = () => {
  149. queryParams.value.pageNum = 1;
  150. getList();
  151. };
  152. /** 重置按钮操作 */
  153. const resetQuery = () => {
  154. queryFormRef.value?.resetFields();
  155. handleQuery();
  156. };
  157. /** 多选框选中数据 */
  158. const handleSelectionChange = (selection: LeaveVO[]) => {
  159. ids.value = selection.map((item) => item.id);
  160. single.value = selection.length != 1;
  161. multiple.value = !selection.length;
  162. };
  163. /** 新增按钮操作 */
  164. const handleAdd = () => {
  165. proxy.$tab.closePage(proxy.$route);
  166. proxy.$router.push(`/workflow/leaveEdit/index/add/add`);
  167. proxy.$router.push({
  168. path: `/workflow/leaveEdit/index`,
  169. query: {
  170. type: 'add'
  171. }
  172. });
  173. };
  174. /** 修改按钮操作 */
  175. const handleUpdate = (row?: LeaveVO) => {
  176. proxy.$tab.closePage(proxy.$route);
  177. proxy.$router.push({
  178. path: `/workflow/leaveEdit/index`,
  179. query: {
  180. id: row.id,
  181. type: 'update'
  182. }
  183. });
  184. };
  185. /** 查看按钮操作 */
  186. const handleView = (row?: LeaveVO) => {
  187. proxy.$tab.closePage(proxy.$route);
  188. proxy.$router.push({
  189. path: `/workflow/leaveEdit/index`,
  190. query: {
  191. id: row.id,
  192. type: 'view'
  193. }
  194. });
  195. };
  196. /** 删除按钮操作 */
  197. const handleDelete = async (row?: LeaveVO) => {
  198. const _ids = row?.id || ids.value;
  199. await proxy?.$modal.confirm('是否确认删除请假编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
  200. await delLeave(_ids);
  201. proxy?.$modal.msgSuccess('删除成功');
  202. await getList();
  203. };
  204. /** 导出按钮操作 */
  205. const handleExport = () => {
  206. proxy?.download(
  207. 'workflow/leave/export',
  208. {
  209. ...queryParams.value
  210. },
  211. `leave_${new Date().getTime()}.xlsx`
  212. );
  213. };
  214. /** 撤销按钮操作 */
  215. const handleCancelProcessApply = async (id: string) => {
  216. await proxy?.$modal.confirm('是否确认撤销当前单据?');
  217. loading.value = true;
  218. await cancelProcessApply(id).finally(() => (loading.value = false));
  219. await getList();
  220. proxy?.$modal.msgSuccess('撤销成功');
  221. };
  222. onMounted(() => {
  223. getList();
  224. });
  225. </script>