Browse Source

feat:修改分班

DESKTOP-USV654P\pc 6 months ago
parent
commit
701a345017
2 changed files with 126 additions and 145 deletions
  1. 14 11
      src/views/educational/division/components/DsionStep2_1.vue
  2. 112 134
      src/views/system/user/index.vue

+ 14 - 11
src/views/educational/division/components/DsionStep2_1.vue

@@ -5,7 +5,7 @@
         <a-button type="primary" @click="handelImport" :disabled="state.status === 1">
           导入
         </a-button>
-        <a-button type="primary" @click="handelAdd" :disabled="state.status === 1">添加</a-button>
+        <a-button type="primary" @click="handelAdd">添加</a-button>
         <a-button type="primary" @click="handelSave" :disabled="state.status === 1">保存</a-button>
       </template>
 
@@ -13,7 +13,7 @@
         <Select
           v-model:value="record[column.dataIndex]"
           :options="majorSetOptions"
-          :disabled="state.status === 1"
+          :disabled="state.status === 1 ? (record._newRow ? false : true) : false"
           :showSearch="true"
           :filterOption="filterOption"
           style="margin: -5px 0; width: 100%"
@@ -23,7 +23,7 @@
         <Select
           v-model:value="record[column.dataIndex]"
           :options="classTypeOptions"
-          :disabled="state.status === 1"
+          :disabled="state.status === 1 ? (record._newRow ? false : true) : false"
           :showSearch="true"
           :filterOption="filterOption"
           style="margin: -5px 0; width: 100%"
@@ -33,7 +33,7 @@
         <a-input
           v-model:value="record[column.dataIndex]"
           placeholder="班级名称"
-          :disabled="state.status === 1"
+          :disabled="state.status === 1 ? (record._newRow ? false : true) : false"
           style="margin: -5px 0; width: 100%"
         />
       </template>
@@ -41,7 +41,7 @@
         <a-input-number
           v-model:value="record[column.dataIndex]"
           placeholder="班级人数"
-          :disabled="state.status === 1"
+          :disabled="state.status === 1 ? (record._newRow ? false : true) : false"
           style="margin: -5px 0; width: 100%"
         />
       </template>
@@ -49,7 +49,7 @@
         <Select
           v-model:value="record[column.dataIndex]"
           :options="teacherOptions"
-          :disabled="state.status === 1"
+          :disabled="state.status === 1 ? (record._newRow ? false : true) : false"
           :showSearch="true"
           :filterOption="filterOption"
           style="margin: -5px 0; width: 100%"
@@ -59,20 +59,23 @@
         <Select
           v-model:value="record[column.dataIndex]"
           :options="classroomOptions"
-          :disabled="state.status === 1"
+          :disabled="state.status === 1 ? (record._newRow ? false : true) : false"
           :showSearch="true"
           :filterOption="filterOption"
           style="margin: -5px 0; width: 100%"
         />
       </template>
       <template #isOrderClass="{ record, column }">
-        <Checkbox :disabled="state.status === 1" v-model:checked="record[column.dataIndex]" />
+        <Checkbox
+          :disabled="state.status === 1 ? (record._newRow ? false : true) : false"
+          v-model:checked="record[column.dataIndex]"
+        />
       </template>
       <template #sortCode="{ record, column }">
         <a-input-number
           v-model:value="record[column.dataIndex]"
           placeholder="排序"
-          :disabled="state.status === 1"
+          :disabled="state.status === 1 ? (record._newRow ? false : true) : false"
           style="margin: -5px 0; width: 100%"
         />
       </template>
@@ -81,13 +84,13 @@
           :actions="[
             {
               label: '保存',
-              disabled: state.status === 1,
+              disabled: state.status === 1 ? (record._newRow ? false : true) : false,
               onClick: handleSave.bind(null, record),
             },
             {
               label: '删除',
               color: 'error',
-              disabled: state.status === 1,
+              disabled: state.status === 1 ? (record._newRow ? false : true) : false,
               onClick: handleDelete.bind(null, record),
             },
           ]"

+ 112 - 134
src/views/system/user/index.vue

@@ -37,8 +37,8 @@
     <AccountModal @register="registerModal" @success="handleSuccess" />
   </PageWrapper>
 </template>
-<script lang="ts">
-  import { defineComponent, ref, reactive, h } from 'vue';
+<script lang="ts" setup>
+  import { ref, reactive, h } from 'vue';
   import { BasicTable, useTable, TableAction, FormSchema, BasicColumn } from '/@/components/Table';
   import { getUserPageList, deleteUser, resetUserPassword } from '/@/api/system/user';
   import { PageWrapper } from '/@/components/Page';
@@ -52,7 +52,7 @@
   import { postUserChangeStatus } from '/@/services/apis/UserController';
   const { t } = useI18n();
   const searchInfo = reactive<Recordable>({});
-  export const searchFormSchema: FormSchema[] = [
+  const searchFormSchema: FormSchema[] = [
     {
       field: 'userName',
       label: t('用户名'),
@@ -79,7 +79,7 @@
     },
   ];
 
-  export const columns: BasicColumn[] = [
+  const columns: BasicColumn[] = [
     {
       title: t('用户名'),
       dataIndex: 'userName',
@@ -164,141 +164,119 @@
     },
   ];
 
-  export default defineComponent({
-    name: 'UserManagement',
-    components: { BasicTable, PageWrapper, DeptTree, AccountModal, TableAction },
-    setup() {
-      const { notification } = useMessage();
+  const { notification } = useMessage();
 
-      const isVisible = ref<boolean>(false);
-      const deleteIndex = ref();
-      const [registerModal, { openModal }] = useModal();
-      const [registerTable, { reload, getSelectRows }] = useTable({
-        title: t('用户列表'),
-        api: getUserPageList,
-        rowKey: 'id',
-        columns,
-        formConfig: {
-          rowProps: {
-            gutter: 16,
-          },
-          schemas: searchFormSchema,
-        },
-        rowSelection: {
-          type: 'radio',
-        },
-        useSearchForm: true,
-        showTableSetting: true,
-        striped: false,
-        immediate: false,
-        actionColumn: {
-          width: 80,
-          title: t('操作'),
-          dataIndex: 'action',
-          slots: { customRender: 'action' },
-        },
-      });
+  const isVisible = ref<boolean>(false);
+  const deleteIndex = ref();
+  const [registerModal, { openModal }] = useModal();
+  const [registerTable, { reload, getSelectRows }] = useTable({
+    title: t('用户列表'),
+    api: getUserPageList,
+    rowKey: 'id',
+    columns,
+    formConfig: {
+      rowProps: {
+        gutter: 16,
+      },
+      schemas: searchFormSchema,
+    },
+    rowSelection: {
+      type: 'radio',
+    },
+    useSearchForm: true,
+    showTableSetting: true,
+    striped: false,
+    immediate: false,
+    actionColumn: {
+      width: 80,
+      title: t('操作'),
+      dataIndex: 'action',
+      slots: { customRender: 'action' },
+    },
+  });
 
-      function popVisible(index) {
-        return isVisible.value && index === deleteIndex.value;
-      }
+  function popVisible(index) {
+    return isVisible.value && index === deleteIndex.value;
+  }
 
-      function handleCreate() {
-        openModal(true, {
-          isUpdate: false,
-        });
-      }
+  function handleCreate() {
+    openModal(true, {
+      isUpdate: false,
+    });
+  }
 
-      function handleEdit(record: Recordable) {
-        openModal(true, {
-          id: record.id,
-          isUpdate: true,
-        });
-      }
+  function handleEdit(record: Recordable) {
+    openModal(true, {
+      id: record.id,
+      isUpdate: true,
+    });
+  }
 
-      function handleVisibleChange(index, bool) {
-        if (!bool) {
-          isVisible.value = false;
-          return;
-        }
-        // if (process.env.NODE_ENV === 'production') {
-        //   notification.warning({
-        //     message: '在线环境暂不允许该操作,请联系管理员。',
-        //   });
-        //   return;
-        // }
-        isVisible.value = true;
-        deleteIndex.value = index;
-      }
+  function handleVisibleChange(index, bool) {
+    if (!bool) {
+      isVisible.value = false;
+      return;
+    }
+    // if (process.env.NODE_ENV === 'production') {
+    //   notification.warning({
+    //     message: '在线环境暂不允许该操作,请联系管理员。',
+    //   });
+    //   return;
+    // }
+    isVisible.value = true;
+    deleteIndex.value = index;
+  }
 
-      function handleDelete(record: Recordable) {
-        isVisible.value = false;
-        deleteUser([record.id]).then((_) => {
-          reload();
-          notification.success({
-            message: t('删除'),
-            description: t('成功'),
-          }); //提示消息
-        });
-      }
-      function handleCancel() {
-        isVisible.value = false;
-      }
-      function handleReset() {
-        // if (process.env.NODE_ENV === 'production') {
-        //   notification.warning({
-        //     message: '在线环境暂不允许该操作,请联系管理员。',
-        //   });
-        //   return;
-        // }
-        let rows = warning();
-        if (!rows) {
-          return;
-        }
-        resetUserPassword(rows.id).then(() => {
-          notification.success({
-            message: t('重置密码成功'),
-            description: t('成功'),
-          });
-        });
-      }
-      function warning() {
-        const selectRows = getSelectRows();
-        if (selectRows.length === 0) {
-          notification.warning({
-            message: t('警告'),
-            description: t('必须选中一行!'),
-          }); //提示消息
-          return false;
-        } else {
-          return selectRows[0];
-        }
-      }
-      function handleSuccess() {
-        reload();
-      }
-
-      function handleSelect(item) {
-        searchInfo.treeId = item.id;
-        searchInfo.treeType = item.type;
-        reload();
-      }
+  function handleDelete(record: Recordable) {
+    isVisible.value = false;
+    deleteUser([record.id]).then((_) => {
+      reload();
+      notification.success({
+        message: t('删除'),
+        description: t('成功'),
+      }); //提示消息
+    });
+  }
+  function handleCancel() {
+    isVisible.value = false;
+  }
+  function handleReset() {
+    // if (process.env.NODE_ENV === 'production') {
+    //   notification.warning({
+    //     message: '在线环境暂不允许该操作,请联系管理员。',
+    //   });
+    //   return;
+    // }
+    let rows = warning();
+    if (!rows) {
+      return;
+    }
+    resetUserPassword(rows.id).then(() => {
+      notification.success({
+        message: t('重置密码成功'),
+        description: t('成功'),
+      });
+    });
+  }
+  function warning() {
+    const selectRows = getSelectRows();
+    if (selectRows.length === 0) {
+      notification.warning({
+        message: t('警告'),
+        description: t('必须选中一行!'),
+      }); //提示消息
+      return false;
+    } else {
+      return selectRows[0];
+    }
+  }
+  function handleSuccess() {
+    reload();
+  }
 
-      return {
-        registerTable,
-        registerModal,
-        popVisible,
-        handleVisibleChange,
-        handleCreate,
-        handleEdit,
-        handleDelete,
-        handleSuccess,
-        handleSelect,
-        handleReset,
-        handleCancel,
-        t,
-        searchInfo,
-      };
-    },
-  });
+  function handleSelect(item) {
+    searchInfo.treeId = item.id;
+    searchInfo.treeType = item.type;
+    reload();
+  }
 </script>