|
|
@@ -82,284 +82,284 @@ import itemDetailApi from '@/api/sysadmin/itemdetail'
|
|
|
import command from './components/command'
|
|
|
import detailApi from '@/api/course/detail'
|
|
|
import editForm from './editForm'
|
|
|
-import {searchmanagingroomdata} from '@/api/instrumentroom'
|
|
|
+import { searchmanagingroomdata } from '@/api/instrumentroom'
|
|
|
import { AgGridVue } from 'ag-grid-vue'
|
|
|
import 'ag-grid-community/dist/styles/ag-grid.css'
|
|
|
import 'ag-grid-community/dist/styles/ag-theme-balham.css'
|
|
|
|
|
|
export default {
|
|
|
- name: 'courseDetail',
|
|
|
- components: { AgGridVue, editForm },
|
|
|
- data () {
|
|
|
- return {
|
|
|
- // ag-grid相关变量
|
|
|
- gridOptions: null,
|
|
|
- gridApi: null,
|
|
|
- columnApi: null,
|
|
|
- rowData: null,
|
|
|
- columnDefs: null,
|
|
|
- RoomList:[],
|
|
|
- TeacherList:[],
|
|
|
- page: {
|
|
|
- current: 1,
|
|
|
- size: 10,
|
|
|
- total: 1
|
|
|
- },
|
|
|
- sort: {
|
|
|
- prop: '',
|
|
|
- order: ''
|
|
|
- },
|
|
|
+ name: 'courseDetail',
|
|
|
+ components: { AgGridVue, editForm },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ // ag-grid相关变量
|
|
|
+ gridOptions: null,
|
|
|
+ gridApi: null,
|
|
|
+ columnApi: null,
|
|
|
+ rowData: null,
|
|
|
+ columnDefs: null,
|
|
|
+ RoomList: [],
|
|
|
+ TeacherList: [],
|
|
|
+ page: {
|
|
|
+ current: 1,
|
|
|
+ size: 10,
|
|
|
+ total: 1
|
|
|
+ },
|
|
|
+ sort: {
|
|
|
+ prop: '',
|
|
|
+ order: ''
|
|
|
+ },
|
|
|
|
|
|
- id: -1,
|
|
|
- CourseId:null,
|
|
|
- Term:null,
|
|
|
- Class:null,
|
|
|
- Year:null,
|
|
|
- rowdata: {},
|
|
|
- searchForm: {
|
|
|
- name: ''
|
|
|
- },
|
|
|
- loading: false,
|
|
|
- multipleSelection: [],
|
|
|
- editFormVisible: false,
|
|
|
- deleteBtnVisible: true,
|
|
|
- deleteIds: []
|
|
|
- }
|
|
|
- },
|
|
|
- beforeMount () {
|
|
|
- let _this = this
|
|
|
- this.gridOptions = {
|
|
|
- rowHeight: 32, // 设置行高为32px
|
|
|
- // 缺省列属性
|
|
|
- defaultColDef: {
|
|
|
- width: 200,
|
|
|
- resizable: true
|
|
|
- },
|
|
|
- onRowSelected: this.handleSelectionChange, // 行选中
|
|
|
- onSortChanged: this.handleSortChange // 排序传递后台
|
|
|
+ id: -1,
|
|
|
+ CourseId: null,
|
|
|
+ Term: null,
|
|
|
+ Class: null,
|
|
|
+ Year: null,
|
|
|
+ rowdata: {},
|
|
|
+ searchForm: {
|
|
|
+ name: ''
|
|
|
+ },
|
|
|
+ loading: false,
|
|
|
+ multipleSelection: [],
|
|
|
+ editFormVisible: false,
|
|
|
+ deleteBtnVisible: true,
|
|
|
+ deleteIds: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ beforeMount () {
|
|
|
+ let _this = this
|
|
|
+ this.gridOptions = {
|
|
|
+ rowHeight: 32, // 设置行高为32px
|
|
|
+ // 缺省列属性
|
|
|
+ defaultColDef: {
|
|
|
+ width: 200,
|
|
|
+ resizable: true
|
|
|
+ },
|
|
|
+ onRowSelected: this.handleSelectionChange, // 行选中
|
|
|
+ onSortChanged: this.handleSortChange // 排序传递后台
|
|
|
+ }
|
|
|
+ this.columnDefs = [
|
|
|
+ { headerName: '', checkboxSelection: true, headerCheckboxSelection: true, width: 50, 'pinned': 'left' },
|
|
|
+ {
|
|
|
+ headerName: '序号',
|
|
|
+ width: 50,
|
|
|
+ field: 'OrdNo',
|
|
|
+ cellRenderer: (params) => {
|
|
|
+ return params ? params.node.rowIndex + 1 + '' : ''
|
|
|
}
|
|
|
- this.columnDefs = [
|
|
|
- { headerName: '', checkboxSelection: true, headerCheckboxSelection: true, width: 50, 'pinned': 'left' },
|
|
|
- {
|
|
|
- headerName: '序号',
|
|
|
- width: 50,
|
|
|
- field: 'OrdNo',
|
|
|
- cellRenderer: (params) => {
|
|
|
- return params ? params.node.rowIndex + 1 + '' : ''
|
|
|
- }
|
|
|
- },
|
|
|
- {headerName: '课程名称', field: 'CourseName', sortable: true},
|
|
|
- { headerName: '授课老师', field: 'Teacher',valueFormatter:teacherFormatter},
|
|
|
- { headerName: '实验地点', field: 'Local', valueFormatter:localFormatter},
|
|
|
+ },
|
|
|
+ { headerName: '课程名称', field: 'CourseName', sortable: true },
|
|
|
+ { headerName: '授课老师', field: 'Teacher', valueFormatter: teacherFormatter },
|
|
|
+ { headerName: '实验地点', field: 'Local', valueFormatter: localFormatter },
|
|
|
|
|
|
- { headerName: '人数', field: 'Num', sortable: true },
|
|
|
+ { headerName: '人数', field: 'Num', sortable: true },
|
|
|
|
|
|
- { headerName: '创建时间', field: 'CreatedTime', sortable: true },
|
|
|
- { headerName: '操作', field: 'operation', width: 120, 'pinned': 'right', cellRendererFramework: command }
|
|
|
- ]
|
|
|
+ { headerName: '创建时间', field: 'CreatedTime', sortable: true },
|
|
|
+ { headerName: '操作', field: 'operation', width: 120, 'pinned': 'right', cellRendererFramework: command }
|
|
|
+ ]
|
|
|
|
|
|
- // 授课老师
|
|
|
- function teacherFormatter(item) {
|
|
|
- for (var i = 0; i < _this.TeacherList.length; i++) {
|
|
|
- if (parseInt(_this.TeacherList[i].ItemValue) === item.value) {
|
|
|
- return _this.TeacherList[i].ItemName
|
|
|
- }
|
|
|
- }
|
|
|
+ // 授课老师
|
|
|
+ function teacherFormatter (item) {
|
|
|
+ for (var i = 0; i < _this.TeacherList.length; i++) {
|
|
|
+ if (parseInt(_this.TeacherList[i].ItemValue) === item.value) {
|
|
|
+ return _this.TeacherList[i].ItemName
|
|
|
}
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // 实验地点
|
|
|
- function localFormatter(item ) {
|
|
|
- for (var i = 0; i < _this.RoomList.length; i++) {
|
|
|
- if (parseInt(_this.RoomList[i].Id) === item.value) {
|
|
|
- return _this.RoomList[i].RoomName
|
|
|
- }
|
|
|
- }
|
|
|
+ // 实验地点
|
|
|
+ function localFormatter (item) {
|
|
|
+ for (var i = 0; i < _this.RoomList.length; i++) {
|
|
|
+ if (parseInt(_this.RoomList[i].Id) === item.value) {
|
|
|
+ return _this.RoomList[i].RoomName
|
|
|
}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created () {
|
|
|
+ },
|
|
|
+ mounted () {
|
|
|
+ let _this = this
|
|
|
+ _this.gridOptions.context = { page: _this }
|
|
|
+ _this.gridApi = _this.gridOptions.api
|
|
|
+ _this.CourseId = _this.$route.query.CourseId
|
|
|
+ _this.Year = _this.$route.query.Year
|
|
|
+ _this.Term = _this.$route.query.Term
|
|
|
+ _this.Class = _this.$route.query.Class
|
|
|
+ this.getTeacherList()
|
|
|
+ let params = {
|
|
|
+ _currentPage: 1,
|
|
|
+ _size: 9999
|
|
|
+ }
|
|
|
+ this.getRoomList(params)
|
|
|
+ this.doRefresh()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 表格就绪后后执行
|
|
|
+ onGridReady (params) {
|
|
|
+ // 调整表格列宽大小自适应
|
|
|
+ this.gridApi.sizeColumnsToFit()
|
|
|
},
|
|
|
- created () {
|
|
|
+ // 获取教师列表
|
|
|
+ getTeacherList (query) {
|
|
|
+ let _this = this
|
|
|
+ if (query !== '') {
|
|
|
+ _this.loading = true
|
|
|
+ itemDetailApi.getItemDetailByItemCode({ ItemCode: 'Teacher' })
|
|
|
+ .then(res => {
|
|
|
+ _this.loading = false
|
|
|
+ this.TeacherList = res
|
|
|
+ this.initData()
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.error(err)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ _this.TeacherList = []
|
|
|
+ }
|
|
|
},
|
|
|
- mounted () {
|
|
|
- let _this = this
|
|
|
- _this.gridOptions.context = { page: _this }
|
|
|
- _this.gridApi = _this.gridOptions.api
|
|
|
- _this.CourseId = _this.$route.query.CourseId
|
|
|
- _this.Year = _this.$route.query.Year
|
|
|
- _this.Term = _this.$route.query.Term
|
|
|
- _this.Class = _this.$route.query.Class
|
|
|
- this.getTeacherList()
|
|
|
- let params = {
|
|
|
- _currentPage: 1,
|
|
|
- _size: 9999,
|
|
|
- }
|
|
|
- this.getRoomList(params)
|
|
|
- this.doRefresh()
|
|
|
+ // 获取实验室地点
|
|
|
+ getRoomList (params) {
|
|
|
+ let _this = this
|
|
|
+ if (params !== '') {
|
|
|
+ _this.loading = true
|
|
|
+ searchmanagingroomdata(params)
|
|
|
+ .then(res => {
|
|
|
+ _this.loading = false
|
|
|
+ this.RoomList = res.info.items
|
|
|
+ })
|
|
|
+ .catch(function (error) {
|
|
|
+ console.log(error)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ _this.RoomList = []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 执行刷新(获取数据)
|
|
|
+ doRefresh () {
|
|
|
+ let _this = this
|
|
|
+ let query = {
|
|
|
+ // 分页信息
|
|
|
+ size: this.page.size,
|
|
|
+ current: this.page.current,
|
|
|
+ // 排序信息
|
|
|
+ prop: this.sort.prop,
|
|
|
+ order: this.sort.order,
|
|
|
+ // 搜索名称
|
|
|
+ CourseName: this.searchForm.name,
|
|
|
+ CourseId: this.CourseId // 课程ID
|
|
|
+ }
|
|
|
+ detailApi.getList(query)
|
|
|
+ .then(res => {
|
|
|
+ _this.rowData = res.records ? res.records : []
|
|
|
+ _this.page.current = res.current
|
|
|
+ _this.page.size = res.size
|
|
|
+ _this.page.total = res.total
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.error(err)
|
|
|
+ })
|
|
|
},
|
|
|
- methods: {
|
|
|
- // 表格就绪后后执行
|
|
|
- onGridReady (params) {
|
|
|
- // 调整表格列宽大小自适应
|
|
|
- this.gridApi.sizeColumnsToFit()
|
|
|
- },
|
|
|
- // 获取教师列表
|
|
|
- getTeacherList(query) {
|
|
|
- let _this = this
|
|
|
- if (query !== '') {
|
|
|
- _this.loading = true
|
|
|
- itemDetailApi.getItemDetailByItemCode({ItemCode: 'Teacher'})
|
|
|
- .then(res => {
|
|
|
- _this.loading = false
|
|
|
- this.TeacherList = res
|
|
|
- this.initData()
|
|
|
- })
|
|
|
- .catch(err => {
|
|
|
- console.error(err)
|
|
|
- })
|
|
|
- } else {
|
|
|
- _this.TeacherList = []
|
|
|
- }
|
|
|
- },
|
|
|
- // 获取实验室地点
|
|
|
- getRoomList (params) {
|
|
|
- let _this = this
|
|
|
- if (params !== '') {
|
|
|
- _this.loading = true
|
|
|
- searchmanagingroomdata(params)
|
|
|
- .then(res => {
|
|
|
- _this.loading = false
|
|
|
- this.RoomList = res.info.items
|
|
|
- })
|
|
|
- .catch(function (error) {
|
|
|
- console.log(error)
|
|
|
- })
|
|
|
- }else {
|
|
|
- _this.RoomList = []
|
|
|
- }
|
|
|
- },
|
|
|
- // 执行刷新(获取数据)
|
|
|
- doRefresh () {
|
|
|
- let _this = this
|
|
|
- let query = {
|
|
|
- // 分页信息
|
|
|
- size: this.page.size,
|
|
|
- current: this.page.current,
|
|
|
- // 排序信息
|
|
|
- prop: this.sort.prop,
|
|
|
- order: this.sort.order,
|
|
|
- // 搜索名称
|
|
|
- CourseName: this.searchForm.name,
|
|
|
- CourseId:this.CourseId // 课程ID
|
|
|
- }
|
|
|
- detailApi.getList(query)
|
|
|
- .then(res => {
|
|
|
- _this.rowData = res.records ? res.records : []
|
|
|
- _this.page.current = res.current
|
|
|
- _this.page.size = res.size
|
|
|
- _this.page.total = res.total
|
|
|
- })
|
|
|
- .catch(err => {
|
|
|
- console.error(err)
|
|
|
- })
|
|
|
- },
|
|
|
|
|
|
- // 分页-改变分页大小
|
|
|
- handleSizeChange (value) {
|
|
|
- this.page.size = value
|
|
|
- this.page.current = 1
|
|
|
- this.doRefresh()
|
|
|
- },
|
|
|
- // 分页-改变当前页
|
|
|
- handleCurrentChange (value) {
|
|
|
- this.page.current = value
|
|
|
- this.doRefresh()
|
|
|
- },
|
|
|
- // 处理编辑
|
|
|
- handleEdit (id) {
|
|
|
- this.id = id
|
|
|
- this.editFormVisible = true
|
|
|
- },
|
|
|
- // 处理删除
|
|
|
- handleDelete (id) {
|
|
|
- const params = {
|
|
|
- ids: this.deleteIds
|
|
|
- }
|
|
|
- detailApi.delete(params).then((res) => {
|
|
|
- this.$message({
|
|
|
- type: 'success',
|
|
|
- message: '删除成功!'
|
|
|
- })
|
|
|
- this.doRefresh()
|
|
|
- })
|
|
|
- },
|
|
|
+ // 分页-改变分页大小
|
|
|
+ handleSizeChange (value) {
|
|
|
+ this.page.size = value
|
|
|
+ this.page.current = 1
|
|
|
+ this.doRefresh()
|
|
|
+ },
|
|
|
+ // 分页-改变当前页
|
|
|
+ handleCurrentChange (value) {
|
|
|
+ this.page.current = value
|
|
|
+ this.doRefresh()
|
|
|
+ },
|
|
|
+ // 处理编辑
|
|
|
+ handleEdit (id) {
|
|
|
+ this.id = id
|
|
|
+ this.editFormVisible = true
|
|
|
+ },
|
|
|
+ // 处理删除
|
|
|
+ handleDelete (id) {
|
|
|
+ const params = {
|
|
|
+ ids: this.deleteIds
|
|
|
+ }
|
|
|
+ detailApi.delete(params).then((res) => {
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '删除成功!'
|
|
|
+ })
|
|
|
+ this.doRefresh()
|
|
|
+ })
|
|
|
+ },
|
|
|
|
|
|
- // 查询
|
|
|
- handleSearch () {
|
|
|
- this.currentPage = 1
|
|
|
- this.doRefresh()
|
|
|
- },
|
|
|
- // 重置
|
|
|
- handleSearchFormReset () {
|
|
|
- this.searchForm.name = ''
|
|
|
- this.doRefresh()
|
|
|
- },
|
|
|
- // 新建窗口
|
|
|
- add () {
|
|
|
- this.rowdata = {}
|
|
|
- this.id = 0
|
|
|
- this.editFormVisible = true
|
|
|
- },
|
|
|
- // 批量删除
|
|
|
- delSelectedIds () {
|
|
|
- this.$confirm('此操作将永久删除所选课程, 是否继续?', '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- const params = {
|
|
|
- ids: this.deleteIds
|
|
|
- }
|
|
|
- detailApi.delete(params).then((res) => {
|
|
|
- this.$message({
|
|
|
- type: 'success',
|
|
|
- message: '删除成功!'
|
|
|
- })
|
|
|
- this.doRefresh()
|
|
|
- })
|
|
|
- }).catch(() => {
|
|
|
- this.$message({
|
|
|
- type: 'info',
|
|
|
- message: '已取消删除'
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
- // 处理列表选择
|
|
|
- handleSelectionChange () {
|
|
|
- let _this = this
|
|
|
- _this.multipleSelection = _this.gridOptions.api.getSelectedRows()
|
|
|
- _this.deleteBtnVisible = !_this.multipleSelection || _this.multipleSelection.length === 0
|
|
|
- if (!_this.deleteBtnVisible) {
|
|
|
- _this.deleteIds = []
|
|
|
- // 赋值删除id列表
|
|
|
- _this.multipleSelection.forEach((item, k) => {
|
|
|
- _this.deleteIds.push(item.Id)
|
|
|
- })
|
|
|
- } else {
|
|
|
- _this.deleteIds = []
|
|
|
- }
|
|
|
- },
|
|
|
- handleSortChange (val) {
|
|
|
- var sortState = this.gridApi.getSortModel()
|
|
|
- // 获取排序的字段
|
|
|
- if (sortState && sortState.length > 0) {
|
|
|
- var item = sortState[0]
|
|
|
- this.sort.prop = item.colId
|
|
|
- this.sort.order = item.sort
|
|
|
- }
|
|
|
- this.doRefresh()
|
|
|
- },
|
|
|
- back () { // 返回上一页
|
|
|
- this.$router.go(-1)
|
|
|
+ // 查询
|
|
|
+ handleSearch () {
|
|
|
+ this.currentPage = 1
|
|
|
+ this.doRefresh()
|
|
|
+ },
|
|
|
+ // 重置
|
|
|
+ handleSearchFormReset () {
|
|
|
+ this.searchForm.name = ''
|
|
|
+ this.doRefresh()
|
|
|
+ },
|
|
|
+ // 新建窗口
|
|
|
+ add () {
|
|
|
+ this.rowdata = {}
|
|
|
+ this.id = 0
|
|
|
+ this.editFormVisible = true
|
|
|
+ },
|
|
|
+ // 批量删除
|
|
|
+ delSelectedIds () {
|
|
|
+ this.$confirm('此操作将永久删除所选课程, 是否继续?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ const params = {
|
|
|
+ ids: this.deleteIds
|
|
|
}
|
|
|
+ detailApi.delete(params).then((res) => {
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '删除成功!'
|
|
|
+ })
|
|
|
+ this.doRefresh()
|
|
|
+ })
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message({
|
|
|
+ type: 'info',
|
|
|
+ message: '已取消删除'
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 处理列表选择
|
|
|
+ handleSelectionChange () {
|
|
|
+ let _this = this
|
|
|
+ _this.multipleSelection = _this.gridOptions.api.getSelectedRows()
|
|
|
+ _this.deleteBtnVisible = !_this.multipleSelection || _this.multipleSelection.length === 0
|
|
|
+ if (!_this.deleteBtnVisible) {
|
|
|
+ _this.deleteIds = []
|
|
|
+ // 赋值删除id列表
|
|
|
+ _this.multipleSelection.forEach((item, k) => {
|
|
|
+ _this.deleteIds.push(item.Id)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ _this.deleteIds = []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleSortChange (val) {
|
|
|
+ var sortState = this.gridApi.getSortModel()
|
|
|
+ // 获取排序的字段
|
|
|
+ if (sortState && sortState.length > 0) {
|
|
|
+ var item = sortState[0]
|
|
|
+ this.sort.prop = item.colId
|
|
|
+ this.sort.order = item.sort
|
|
|
+ }
|
|
|
+ this.doRefresh()
|
|
|
+ },
|
|
|
+ back () { // 返回上一页
|
|
|
+ this.$router.go(-1)
|
|
|
}
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|