index.vue 7.9 KB

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