index.vue 8.2 KB

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