index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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="mb-[10px]">
  5. <el-card shadow="hover">
  6. <el-form ref="queryFormRef" :model="queryParams" :inline="true">
  7. <el-form-item label="职务名称" prop="name">
  8. <el-input v-model="queryParams.name" placeholder="请输入职务名称" clearable @keyup.enter="handleQuery" />
  9. </el-form-item>
  10. <el-form-item>
  11. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  12. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  13. </el-form-item>
  14. </el-form>
  15. </el-card>
  16. </div>
  17. </transition>
  18. <el-card shadow="never">
  19. <template #header>
  20. <el-row :gutter="10" class="mb8">
  21. <el-col :span="1.5">
  22. <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['physical:judgePosition:add']">新增</el-button>
  23. </el-col>
  24. <el-col :span="1.5">
  25. <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['physical:judgePosition:edit']"
  26. >修改</el-button
  27. >
  28. </el-col>
  29. <el-col :span="1.5">
  30. <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['physical:judgePosition:remove']"
  31. >删除</el-button
  32. >
  33. </el-col>
  34. <el-col :span="1.5">
  35. <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['physical:judgePosition:export']">导出</el-button>
  36. </el-col>
  37. <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
  38. </el-row>
  39. </template>
  40. <el-table v-loading="loading" border :data="judgePositionList" @selection-change="handleSelectionChange">
  41. <el-table-column type="selection" width="55" align="center" />
  42. <el-table-column label="编号" align="center" prop="id" v-if="true" />
  43. <el-table-column label="职务名称" align="center" prop="name" />
  44. <el-table-column label="排序权重" align="center" prop="priority" />
  45. <el-table-column label="状态" align="center" prop="status">
  46. <template #default="scope">
  47. <span v-if="scope.row.status === 1" class="status-enable">启用</span>
  48. <span v-else class="status-disable">禁用</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  52. <template #default="scope">
  53. <el-tooltip content="修改" placement="top">
  54. <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['physical:judgePosition:edit']"></el-button>
  55. </el-tooltip>
  56. <el-tooltip content="删除" placement="top">
  57. <el-button
  58. link
  59. type="primary"
  60. icon="Delete"
  61. @click="handleDelete(scope.row)"
  62. v-hasPermi="['physical:judgePosition:remove']"
  63. ></el-button>
  64. </el-tooltip>
  65. </template>
  66. </el-table-column>
  67. </el-table>
  68. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
  69. </el-card>
  70. <!-- 添加或修改职务管理对话框 -->
  71. <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
  72. <el-form ref="judgePositionFormRef" :model="form" :rules="rules" label-width="80px">
  73. <el-form-item label="职务名称" prop="name">
  74. <el-input v-model="form.name" placeholder="请输入职务名称,如 裁判长" />
  75. </el-form-item>
  76. <el-form-item label="排序权重" prop="priority">
  77. <el-input v-model="form.priority" placeholder="请输入排序权重,越大越优先" />
  78. </el-form-item>
  79. </el-form>
  80. <template #footer>
  81. <div class="dialog-footer">
  82. <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
  83. <el-button @click="cancel">取 消</el-button>
  84. </div>
  85. </template>
  86. </el-dialog>
  87. </div>
  88. </template>
  89. <script setup name="JudgePosition" lang="ts">
  90. import { listJudgePosition, getJudgePosition, delJudgePosition, addJudgePosition, updateJudgePosition } from '@/api/system/physical/judgePosition';
  91. import { JudgePositionVO, JudgePositionQuery, JudgePositionForm } from '@/api/system/physical/judgePosition/types';
  92. import { parseTime } from '@/utils/dateUtils';
  93. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  94. const judgePositionList = ref<JudgePositionVO[]>([]);
  95. const buttonLoading = ref(false);
  96. const loading = ref(true);
  97. const showSearch = ref(true);
  98. const ids = ref<Array<string | number>>([]);
  99. const single = ref(true);
  100. const multiple = ref(true);
  101. const total = ref(0);
  102. const queryFormRef = ref<ElFormInstance>();
  103. const judgePositionFormRef = ref<ElFormInstance>();
  104. const dialog = reactive<DialogOption>({
  105. visible: false,
  106. title: ''
  107. });
  108. const initFormData: JudgePositionForm = {
  109. id: undefined,
  110. name: undefined,
  111. priority: undefined,
  112. status: undefined
  113. };
  114. const data = reactive<PageData<JudgePositionForm, JudgePositionQuery>>({
  115. form: { ...initFormData },
  116. queryParams: {
  117. pageNum: 1,
  118. pageSize: 10,
  119. name: undefined,
  120. priority: undefined,
  121. status: 1,
  122. params: {}
  123. },
  124. rules: {
  125. id: [{ required: true, message: '不能为空', trigger: 'blur' }],
  126. name: [{ required: true, message: '职务名称,如 裁判长不能为空', trigger: 'blur' }],
  127. priority: [{ required: true, message: '优先级,越大越优先不能为空', trigger: 'blur' }]
  128. }
  129. });
  130. const { queryParams, form, rules } = toRefs(data);
  131. /** 查询职务管理列表 */
  132. const getList = async () => {
  133. loading.value = true;
  134. const res = await listJudgePosition(queryParams.value);
  135. judgePositionList.value = res.rows;
  136. total.value = res.total;
  137. loading.value = false;
  138. };
  139. /** 取消按钮 */
  140. const cancel = () => {
  141. reset();
  142. dialog.visible = false;
  143. };
  144. /** 表单重置 */
  145. const reset = () => {
  146. form.value = { ...initFormData };
  147. judgePositionFormRef.value?.resetFields();
  148. };
  149. /** 搜索按钮操作 */
  150. const handleQuery = () => {
  151. queryParams.value.pageNum = 1;
  152. getList();
  153. };
  154. /** 重置按钮操作 */
  155. const resetQuery = () => {
  156. queryFormRef.value?.resetFields();
  157. handleQuery();
  158. };
  159. /** 多选框选中数据 */
  160. const handleSelectionChange = (selection: JudgePositionVO[]) => {
  161. ids.value = selection.map((item) => item.id);
  162. single.value = selection.length != 1;
  163. multiple.value = !selection.length;
  164. };
  165. /** 新增按钮操作 */
  166. const handleAdd = () => {
  167. reset();
  168. dialog.visible = true;
  169. dialog.title = '添加职务管理';
  170. };
  171. /** 修改按钮操作 */
  172. const handleUpdate = async (row?: JudgePositionVO) => {
  173. reset();
  174. const _id = row?.id || ids.value[0];
  175. const res = await getJudgePosition(_id);
  176. Object.assign(form.value, res.data);
  177. dialog.visible = true;
  178. dialog.title = '修改职务管理';
  179. };
  180. /** 提交按钮 */
  181. const submitForm = () => {
  182. judgePositionFormRef.value?.validate(async (valid: boolean) => {
  183. if (valid) {
  184. buttonLoading.value = true;
  185. if (form.value.id) {
  186. await updateJudgePosition(form.value).finally(() => (buttonLoading.value = false));
  187. } else {
  188. await addJudgePosition(form.value).finally(() => (buttonLoading.value = false));
  189. }
  190. proxy?.$modal.msgSuccess('操作成功');
  191. dialog.visible = false;
  192. await getList();
  193. }
  194. });
  195. };
  196. /** 删除按钮操作 */
  197. const handleDelete = async (row?: JudgePositionVO) => {
  198. const _ids = row?.id || ids.value;
  199. await proxy?.$modal.confirm('是否确认删除职务管理编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
  200. await delJudgePosition(_ids);
  201. proxy?.$modal.msgSuccess('删除成功');
  202. await getList();
  203. };
  204. /** 导出按钮操作 */
  205. const handleExport = () => {
  206. proxy?.download(
  207. 'physical/judgePosition/export',
  208. {
  209. ...queryParams.value
  210. },
  211. `职务列表${parseTime(new Date(), '{y}{m}{d}{h}{i}{s}')}.xlsx`
  212. );
  213. };
  214. onMounted(() => {
  215. getList();
  216. });
  217. </script>