index.vue 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <el-container class="is-vertical">
  3. <sc-page-header @add="table_add"></sc-page-header>
  4. <scTable ref="xGridTable" :apiObj="$API.system.dept" v-bind="options">
  5. <template #action="{ row }">
  6. <template v-if="row.pid != 0">
  7. <el-button type="primary" link @click="table_edit(row)">
  8. <template #icon><sc-iconify icon="ant-design:edit-outlined"></sc-iconify></template>修改
  9. </el-button>
  10. <el-button type="primary" link @click="table_del(row)">
  11. <template #icon><sc-iconify icon="ant-design:delete-outlined"></sc-iconify></template>删除
  12. </el-button>
  13. </template>
  14. </template>
  15. </scTable>
  16. </el-container>
  17. <dept-detail v-if="dialog" ref="deptRef" @success="refreshTable" @closed="dialog = false"></dept-detail>
  18. </template>
  19. <script setup>
  20. import XEUtils from "xe-utils";
  21. import API from "@/api";
  22. import { mapFormItemInput } from "@/components/scTable/helper";
  23. import deptDetail from "./detail";
  24. const options = reactive({
  25. formConfig: {
  26. data: {},
  27. items: [mapFormItemInput("nameLike", "部门名称")]
  28. },
  29. paramsColums: [
  30. { column: "orderBy", defaultValue: "deptSort_asc" },
  31. { column: "nameLike" }
  32. ],
  33. toolbarConfig: { enabled: true, export: true },
  34. treeConfig: { transform: true, parentField: "pid" },
  35. columns: [
  36. { type: "seq", width: 60 },
  37. { type: "html", field: "name", title: "部门名称", minWidth: 200, treeNode: true, sortable: true },
  38. { type: "html", field: "firmFunctionary", title: "负责人", minWidth: 160, sortable: true },
  39. { type: "html", field: "firmFunctionaryPhone", title: "负责人电话", minWidth: 160, sortable: true },
  40. { type: "html", field: "remark", title: "备注", minWidth: 300, sortable: true },
  41. { title: "操作", fixed: "right", width: 140, align: "center", slots: { default: "action" } }
  42. ],
  43. pagerConfig: { enabled: false }
  44. });
  45. // 显示隐藏 筛选表单
  46. const xGridTable = ref();
  47. const refreshTable = (mode = "add") => xGridTable.value.searchData(mode);
  48. const deptRef = ref();
  49. const dialog = ref(false);
  50. const table_add = () => {
  51. dialog.value = true;
  52. nextTick(() => deptRef.value?.open());
  53. }
  54. const table_edit = row => {
  55. dialog.value = true;
  56. nextTick(() => deptRef.value?.setData(row));
  57. }
  58. const table_del = ({ id }) => {
  59. ElMessageBox.confirm("是否确认删除该部门?", "删除警告", {
  60. type: "warning",
  61. confirmButtonText: "确定",
  62. cancelButtonText: "取消"
  63. }).then(() => {
  64. API.system.dept.del(({ id })).then(() => {
  65. ElMessage.success("操作成功");
  66. refreshTable();
  67. });
  68. }).catch(() => {});
  69. }
  70. </script>