兰宝车间质量管理系统-前端
疯狂的狮子Li
2023-07-11 c13c622eac5551c6f099f148feb5256711ca34de
src/views/system/dept/index.vue
@@ -1,7 +1,8 @@
<template>
  <div class="p-2">
    <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
      <div class="search" v-show="showSearch">
      <div class="mb-[10px]" v-show="showSearch">
        <el-card shadow="hover">
        <el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="68px">
          <el-form-item label="菜单名称" prop="menuName">
            <el-input v-model="queryParams.deptName" placeholder="请输入部门名称" clearable @keyup.enter="handleQuery" />
@@ -16,10 +17,11 @@
            <el-button icon="Refresh" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
        </el-card>
      </div>
    </transition>
    <el-card shadow="never">
    <el-card shadow="hover">
      <template #header>
        <el-row :gutter="10">
          <el-col :span="1.5">
@@ -130,7 +132,6 @@
<script setup name="Dept" lang="ts">
import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept"
import { ComponentInternalInstance } from 'vue';
import { DeptForm, DeptQuery, DeptVO } from "@/api/system/dept/types";
interface DeptOptionsType {
@@ -155,9 +156,9 @@
    title: ''
});
const deptTableRef = ref(ElTable);
const queryFormRef = ref(ElForm);
const deptFormRef = ref(ElForm);
const deptTableRef = ref<ElTableInstance>();
const queryFormRef = ref<ElFormInstance>();
const deptFormRef = ref<ElFormInstance>();
const initFormData: DeptForm = {
    deptId: undefined,
@@ -206,7 +207,7 @@
/** 表单重置 */
const reset = () => {
    form.value = {...initFormData};
    deptFormRef.value.resetFields();
  deptFormRef.value?.resetFields();
}
/** 搜索按钮操作 */
@@ -215,7 +216,7 @@
}
/** 重置按钮操作 */
const resetQuery = () => {
    queryFormRef.value.resetFields();
  queryFormRef.value?.resetFields();
    handleQuery()
}
/** 新增按钮操作 */
@@ -243,7 +244,7 @@
/** 展开/折叠所有 */
const toggleExpandAll = (data: DeptVO[], status: boolean) => {
    data.forEach((item) => {
        deptTableRef.value.toggleRowExpansion(item, status)
    deptTableRef.value?.toggleRowExpansion(item, status)
        if(item.children && item.children.length > 0) toggleExpandAll(item.children, status)
    })
}
@@ -253,7 +254,7 @@
    const res = await getDept(row.deptId);
    dialog.visible = true;
    dialog.title = "修改部门";
    nextTick(async () => {
  await nextTick(async () => {
        reset();
        form.value = res.data
        const response = await listDeptExcludeChild(row.deptId);
@@ -261,7 +262,11 @@
        if (data) {
            deptOptions.value = data;
            if (data.length === 0) {
                const noResultsOptions: DeptOptionsType = { deptId: res.data.parentId, deptName: res.data.parentName, children: [] };
        const noResultsOptions: DeptOptionsType = {
          deptId: res.data.parentId,
          deptName: res.data.parentName,
          children: []
        };
                deptOptions.value.push(noResultsOptions);
            }
        }
@@ -269,12 +274,12 @@
}
/** 提交按钮 */
const submitForm = () => {
    deptFormRef.value.validate(async (valid: boolean) => {
  deptFormRef.value?.validate(async (valid: boolean) => {
        if (valid) {
            form.value.deptId ? await updateDept(form.value) : await addDept(form.value);
            proxy?.$modal.msgSuccess("操作成功");
            dialog.visible = false;
            getList();
      await getList();
        }
    })
}
@@ -282,7 +287,7 @@
const handleDelete = async (row: DeptVO) => {
    await proxy?.$modal.confirm('是否确认删除名称为"' + row.deptName + '"的数据项?');
    await delDept(row.deptId);
    getList();
  await getList();
    proxy?.$modal.msgSuccess("删除成功");
}