| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402 |
- <template>
- <d2-container>
- <template slot="header"
- style="padding: 5px;">
- <el-form size="mini"
- ref="form"
- :inline="true"
- class="sbutton_padding"
- style="margin-top: -7px;text-align:right;">
- <el-form-item label="学年"
- class="sbutton_margin">
- <el-select v-model="search.Year"
- placeholder="请选择学年">
- <el-option v-for="item in years"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="学期"
- class="sbutton_margin">
- <el-select v-model="search.Term"
- style="width: 140px;">
- <el-option v-for="item in termList"
- :key="item.ItemValue"
- :label="item.ItemName"
- :value="parseInt(item.ItemValue)">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="班级"
- class="sbutton_margin">
- <el-select v-model="search.ClassId"
- filterable
- style="width: 140px;">
- <el-option v-for="item in classList"
- :key="item.Id"
- :label="item.Name"
- :value="parseInt(item.Id)">
- </el-option>
- </el-select>
- </el-form-item>
- <el-button size="mini"
- type="primary"
- @click="initDatas()"
- style="margin-left:10px"
- @command="searchCommand"
- class="sbutton_margin">查 询</el-button>
- <el-button size="mini"
- type="primary"
- @click="clearSearch"
- class="sbutton_margin">重 置</el-button>
- <el-button size="mini"
- type="primary"
- style="margin-right:6px"
- @click="openinformationadd()"
- class="sbutton_margin">添加</el-button>
- </el-form>
- </template>
- <el-table ref="multipleTable"
- :data="activities"
- border
- fit
- tooltip-effect="dark"
- style="width: 100%"
- @sort-change="orderby"
- height="100%">
- <el-table-column label="操作"
- width="160px"
- align="center"
- fixed='right'>
- <template slot-scope="scope">
- <el-button size="mini"
- title="编辑"
- type="primary"
- @click="courseEdit(scope.row.Id)"
- icon="el-icon-edit"
- circle></el-button>
- <el-button size="mini"
- type="primary"
- title="发布"
- @click="publish(scope.row)"
- style="margin-left:5px;"
- icon="el-icon-s-promotion"
- circle></el-button>
- <el-button size="mini"
- type="primary"
- title="详情"
- @click="handleDetail(scope.row)"
- style="margin-left:5px;"
- icon="el-icon-notebook-2"
- circle></el-button>
- <el-button size="mini"
- type="danger"
- title="删除"
- @click="deleteCourse(scope.row)"
- style="margin-left:5px;"
- icon="el-icon-delete"
- circle></el-button>
- </template>
- </el-table-column>
- <el-table-column prop="Year"
- fit
- min-width="80px"
- label="学年"
- align="center"
- show-overflow-tooltip></el-table-column>
- <el-table-column prop="Term"
- label="学期"
- align="center"
- min-width="160px"
- show-overflow-tooltip
- :formatter="formatTerm"></el-table-column>
- <el-table-column prop="Title"
- label="标题"
- align="center"
- min-width="160px"
- show-overflow-tooltip></el-table-column>
- <!-- <el-table-column prop="CourseWeek"-->
- <!-- label="教学周"-->
- <!-- align="center"-->
- <!-- min-width="160px"-->
- <!-- show-overflow-tooltip></el-table-column>-->
- <el-table-column prop="ClassId"
- label="班级"
- align="center"
- min-width="160px"
- show-overflow-tooltip
- :formatter="formatClass"></el-table-column>
- <el-table-column prop="Status"
- align="center"
- min-width="40px"
- label="状态"
- show-overflow-tooltip
- :formatter="formatStatus"></el-table-column>
- <el-table-column prop="CreatedTime"
- align="center"
- min-width="120px"
- label="创建时间"
- show-overflow-tooltip></el-table-column>
- </el-table>
- <!-- </el-card> -->
- <courseInfoDialog ref="courseDialog"
- @handleClose="handleClose"
- :courseId="courseId"
- :statusList="statusList"
- :termList="termList"
- :classList="classList"
- width="75"></courseInfoDialog>
- <!-- </div> -->
- <template slot="footer">
- <el-pagination style="margin: -10px;"
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page="search.page.current"
- :page-sizes="[10, 15, 20]"
- :page-size="search.page.size"
- layout="total, sizes, prev, pager, next, jumper"
- :total="search.page.total">
- </el-pagination>
- </template>
- </d2-container>
- </template>
- <script>
- import ClassApi from '@/api/class'
- import CourseApi from '@/api/course'
- import itemDetailApi from '@/api/sysadmin/itemdetail'
- import courseInfoDialog from './components/courseInfoDialog'
- export default {
- name: 'course',
- components: {
- courseInfoDialog
- },
- data () {
- return {
- dialogvisible: false,
- details: false,
- activities: [],
- courseId: -1,
- classList: [], // 班级列表
- statusList: [], // 状态列表
- termList: [], // 学期
- years: [],
- search: {
- Term: '',
- Year: '',
- ClassId: '',
- page: {
- total: 0,
- current: 1,
- size: 10
- }
- },
- // 列表排序
- Column: {
- Order: '',
- Prop: ''
- }
- }
- },
- mounted () {
- this.getTerm()
- this.getStatus()
- this.initDatas()
- var myDate = new Date()
- var year = myDate.getFullYear() + 1 // 获取下年
- this.initSelectYear(year)
- },
- methods: {
- // 匹配状态
- formatStatus (row, column) {
- for (var i = 0; i < this.statusList.length; i++) {
- if (parseInt(this.statusList[i].ItemValue) === parseInt(row.Status)) {
- return this.statusList[i].ItemName
- }
- }
- },
- // 匹配班级
- formatClass (row, column) {
- for (var i = 0; i < this.classList.length; i++) {
- if (parseInt(this.classList[i].Id) === row.ClassId) {
- return this.classList[i].Name
- }
- }
- },
- // 获取学期
- getTerm () {
- itemDetailApi.getItemDetailByItemCode({ ItemCode: 'Term' })
- .then(res => {
- this.termList = res
- })
- .catch(err => {
- console.error(err)
- })
- },
- // 匹配学期
- formatTerm (row, column) {
- for (var i = 0; i < this.termList.length; i++) {
- if (parseInt(this.termList[i].ItemValue) === parseInt(row.Term)) {
- return this.termList[i].ItemName
- }
- }
- },
- // 发布状态
- getStatus () {
- let _this = this
- itemDetailApi.getItemDetailByItemCode({ ItemCode: 'PublishStatus' })
- .then(res => {
- _this.statusList = res
- this.initDatas()
- })
- .catch(err => {
- console.error(err)
- })
- },
- initSearchInfo () {
- this.search = {
- Title: '',
- Status: -1,
- Content: ''
- }
- },
- // 初始化分页分页对象
- initPageInfo () {
- this.search.page = {
- total: 0,
- current: 1,
- size: 10
- }
- },
- initSelectYear (year) {
- this.years = []
- for (let i = 0; i < 5; i++) {
- this.years.push({ value: (year - i), label: (year - i) + '年' })
- }
- },
- // 打开 添加弹窗
- openinformationadd () {
- this.$refs.courseDialog.dialogvisible = true
- },
- // 打开 编辑弹窗
- courseEdit (courseId) {
- this.courseId = courseId
- this.$refs.courseDialog.dialogvisible = true
- },
- // 新增修改弹窗关闭 返回页面
- handleClose () {
- this.courseId = -1
- this.$refs.courseDialog.dialogvisible = false
- this.initPageInfo()
- this.initDatas()
- },
- publish (course) {
- course.Status = 1
- CourseApi.addCourse(course)
- },
- // 初始化列表数据
- initDatas () {
- let params = {
- // 分页信息
- size: this.search.page.size,
- current: this.search.page.current,
- Year: this.search.Year,
- Term: this.search.Term,
- ClassId: this.search.ClassId
- }
- this.getClassList()
- CourseApi.getPageList(params)
- .then(res => {
- this.activities = res.records ? res.records : []
- this.search.page.total = res.total
- })
- },
- handleSizeChange (val) {
- this.search.page.size = val
- this.search.page.current = 1
- this.initDatas()
- },
- handleCurrentChange (val) {
- this.search.page.current = val
- this.initDatas()
- },
- // 详情
- handleDetail (course) {
- this.$router.push({ name: 'courseDetailEdit', params: { CourseId: course.Id, Year: course.Year, Term: course.Term, Class: course.ClassId } })
- },
- // 删除课程
- deleteCourse (val) {
- let _this = this
- let params = {
- id: val.Id
- }
- _this.$confirm('此操作将永久删除该信息, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '关闭',
- type: 'warning'
- }).then(() => {
- CourseApi.deleteCourse(params)
- .then(data => {
- _this.initDatas()
- })
- .catch(function (error) {
- console.log(error)
- })
- })
- .catch(() => { })
- },
- // 列表排序功能
- orderby (column) {
- if (column.order === 'ascending') {
- this.Column.Order = 'asc'
- } else if (column.order === 'descending') {
- this.Column.Order = 'desc'
- }
- this.Column.Prop = column.prop
- this.initDatas()
- },
- searchCommand (command) {
- if (command === 'search') {
- this.dialogvisible = true
- } else if (command === 'clear') {
- this.clearSearch()
- }
- },
- clearSearch () {
- this.initSearchInfo()
- this.initPageInfo()
- this.initDatas()
- },
- // 获取班级列表
- getClassList () {
- let params = {
- _currentPage: 1,
- _size: 9999
- }
- ClassApi.getAllClass(params)
- .then(res => {
- this.classList = res.records
- })
- }
- }
- }
- </script>
- <style lang="scss">
- .el-pagination {
- margin: 1rem 0 2rem;
- text-align: right;
- }
- .plab {
- font-size: 13px;
- color: #999;
- }
- </style>
|