From 710a9bf11a76b7b2fb27ba99f772ecc46aeb99fa Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期一, 23 九月 2024 20:41:21 +0800
Subject: [PATCH] 课目管理

---
 src/views/education/subject/manager.vue |  152 ++++++++++++++++++++++++++++++++++++++
 src/api/subject.js                      |    7 +
 src/views/education/subject/list.vue    |   37 +++++---
 src/router.js                           |    7 +
 4 files changed, 187 insertions(+), 16 deletions(-)

diff --git a/src/api/subject.js b/src/api/subject.js
index a6a847f..4d98f62 100644
--- a/src/api/subject.js
+++ b/src/api/subject.js
@@ -3,9 +3,12 @@
 export default {
   list: query => post('/api/admin/education/subject/list'),
   pageList: query => post('/api/admin/education/subject/page', query),
-  edit: query => post('/api/admin/education/subject/edit', query),
+  page: query => post('/api/admin/education/subject/page1', query),
+  edit: data => post('/api/admin/education/subject/edit', data),
+  update: data => post('/api/admin/education/subject/edit1', data),
   select: id => post('/api/admin/education/subject/select/' + id),
   selectByDeptId: deptId => get('/api/admin/education/subject/select/dept/' + deptId),
   deleteSubject: id => post('/api/admin/education/subject/delete/' + id),
-  add: data => post('/api/admin/education/subject/add', data)
+  add: data => post('/api/admin/education/subject/add', data),
+  save: data => post('/api/admin/education/subject/save', data)
 }
diff --git a/src/router.js b/src/router.js
index 9a3b6a7..bb38a20 100644
--- a/src/router.js
+++ b/src/router.js
@@ -115,6 +115,13 @@
         meta: { title: '閮ㄩ棬璇剧洰', noCache: true }
       },
       {
+        path: 'subject/manager',
+        hidden: true,
+        component: () => import('@/views/education/subject/manager'),
+        name: 'SubjectManager',
+        meta: { title: '璇剧洰绠$悊', noCache: true }
+      },
+      {
         path: 'department/list',
         component: () => import('@/views/education/department/list'),
         name: 'EducationDepartmentPage',
diff --git a/src/views/education/subject/list.vue b/src/views/education/subject/list.vue
index a6691a2..2acefea 100644
--- a/src/views/education/subject/list.vue
+++ b/src/views/education/subject/list.vue
@@ -1,19 +1,25 @@
 <template>
   <div class="app-container">
-    <el-form :model="queryParam" ref="queryForm" :inline="true">
-      <el-form-item label="鏌ヨ鏉′欢锛�">
-        <el-input v-model="queryParam.name" size="small"></el-input>
-<!--        <el-select v-model="queryParam.level" placeholder="閮ㄩ棬" clearable="">-->
-<!--          <el-option v-for="item in levelEnum" :key="item.key" :value="item.key" :label="item.value"></el-option>-->
-<!--        </el-select>-->
-      </el-form-item>
-      <el-form-item>
-        <el-button type="primary" @click="submitForm" size="small">鏌ヨ</el-button>
-        <!-- <router-link :to="{path:'/education/subject/edit'}" class="link-left">
-          <el-button type="primary">娣诲姞</el-button>
-        </router-link> -->
-      </el-form-item>
-    </el-form>
+    <div style="width: 100%;position: relative;display: flex">
+      <el-form :model="queryParam" ref="queryForm" :inline="true">
+        <el-form-item label="鏌ヨ鏉′欢锛�">
+          <el-input v-model="queryParam.name" size="small"></el-input>
+          <!--        <el-select v-model="queryParam.level" placeholder="閮ㄩ棬" clearable="">-->
+          <!--          <el-option v-for="item in levelEnum" :key="item.key" :value="item.key" :label="item.value"></el-option>-->
+          <!--        </el-select>-->
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" @click="submitForm" size="small">鏌ヨ</el-button>
+          <!-- <router-link :to="{path:'/education/subject/edit'}" class="link-left">
+            <el-button type="primary">娣诲姞</el-button>
+          </router-link> -->
+        </el-form-item>
+      </el-form>
+      <div style="position: absolute; right: 0">
+        <el-button @click="jumpToSubject" type="primary">璇剧洰绠$悊</el-button>
+      </div>
+    </div>
+
 
     <el-table
       v-loading="listLoading"
@@ -107,6 +113,9 @@
     this.getAllSubject()
   },
   methods: {
+    jumpToSubject() {
+      this.$router.push({path: '/education/subject/manager'})
+    },
     getAllSubject() {
       subjectApi.list().then(res => {
         this.subjectList = res.response
diff --git a/src/views/education/subject/manager.vue b/src/views/education/subject/manager.vue
new file mode 100644
index 0000000..6d52215
--- /dev/null
+++ b/src/views/education/subject/manager.vue
@@ -0,0 +1,152 @@
+<template>
+  <div class="app-container">
+    <el-form :inline="true" :model="queryForm">
+      <el-form-item label="璇剧洰鍚嶇О">
+        <el-input v-model="queryForm.name" clearable @input="page" @clear="page"/>
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" @click="page">鎼滅储</el-button>
+      </el-form-item>
+      <el-form-item>
+        <el-button type="success" @click="handleAdd">鏂板</el-button>
+      </el-form-item>
+    </el-form>
+    <el-table
+      :data="tableData"
+      border
+      style="width: 100%">
+      <el-table-column
+        prop="name"
+        label="璇剧洰鍚嶇О"
+        >
+      </el-table-column>
+      <el-table-column
+        label="鎿嶄綔"
+        >
+        <template slot-scope="scope">
+          <el-button @click="handleEdit(scope.row)" type="text" size="small" style="margin-right: 5px">淇敼</el-button>
+          <el-popconfirm
+            title="纭畾瑕佸垹闄よ璇剧洰鍚楋紵锛岃璇剧洰绠$悊鐨勬暟鎹兘灏嗚鍒犻櫎锛�"
+            @confirm="del(scope.row.id)"
+          >
+            <el-button slot="reference" type="text" size="small">鍒犻櫎</el-button>
+          </el-popconfirm>
+
+        </template>
+      </el-table-column>
+    </el-table>
+    <pagination v-show="total>0" :total="total" :page.sync="queryForm.pageIndex" :limit.sync="queryForm.pageSize"
+                @pagination="page"/>
+
+    <el-dialog
+      :close-on-click-modal="false"
+      :title="title"
+      :visible.sync="editOpen"
+      width="400px"
+      :before-close="handleClose">
+      <el-form :model="form" :rules="rules" ref="form">
+        <el-form-item label="璇剧洰鍚嶇О" prop="name">
+          <el-input v-model="form.name" placeholder="璇剧洰鍚嶇О"/>
+        </el-form-item>
+      </el-form>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="editOpen = false">鍙� 娑�</el-button>
+        <el-button type="primary" @click="addOrUpdate">纭� 瀹�</el-button>
+      </span>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import subjectApi from '@/api/subject'
+import Pagination from '@/components/Pagination'
+
+export default {
+  name: "manager",
+  components: {Pagination},
+  data() {
+    return {
+      total: 0,
+      queryForm: {
+        name: '',
+        pageIndex: 1,
+        pageSize: 10,
+      },
+      tableData: [],
+      title: '鏂板璇剧洰',
+      editOpen: false,
+      form: {
+        id: null,
+        name: ''
+      },
+      rules: {
+        name: [
+          {required: true, message: '璇疯緭鍏ヨ鐩悕绉�'}
+        ]
+      }
+    }
+  },
+  mounted() {
+    this.page();
+  },
+  methods: {
+    del(id) {
+      subjectApi.deleteSubject(id).then(res => {
+        this.$message.success("鍒犻櫎鎴愬姛")
+        this.page()
+      })
+    },
+    page() {
+      subjectApi.page(this.queryForm).then(res => {
+        this.tableData = res.response.list
+        this.total = res.response.total
+      })
+    },
+    addOrUpdate() {
+      this.$refs['form'].validate((valid) => {
+        if (valid) {
+          if (this.form.id) {
+            subjectApi.update(this.form).then(res => {
+              this.editOpen = false
+              this.$message.success("淇敼鎴愬姛")
+              this.page()
+            })
+          } else {
+            subjectApi.save(this.form).then(res => {
+              this.editOpen = false
+              this.$message.success("娣诲姞鎴愬姛")
+              this.page()
+            })
+          }
+
+        }
+      })
+    },
+    handleAdd() {
+      this.form = {
+        id: null,
+        name: ''
+      }
+      this.title = '鏂板璇剧洰'
+      this.editOpen = true
+    },
+    handleEdit(row) {
+      this.form.id = row.id
+      this.form.name = row.name
+      this.title = '淇敼璇剧洰'
+      this.editOpen = true
+    },
+    handleClose() {
+      this.editOpen = false
+      this.form = {
+        id: null,
+        name: ''
+      }
+    }
+  }
+}
+</script>
+
+<style scoped>
+
+</style>

--
Gitblit v1.8.0