index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <d2-container>
  3. <template slot="header"
  4. style="padding: 5px;">
  5. <el-form size="mini"
  6. ref="form"
  7. :inline="true"
  8. class="sbutton_padding"
  9. style="margin-top: -7px;text-align:right;">
  10. <el-form-item label="学年"
  11. class="sbutton_margin">
  12. <el-select v-model="search.Year"
  13. placeholder="请选择学年">
  14. <el-option v-for="item in years"
  15. :key="item.value"
  16. :label="item.label"
  17. :value="item.value">
  18. </el-option>
  19. </el-select>
  20. </el-form-item>
  21. <el-form-item label="学期"
  22. class="sbutton_margin">
  23. <el-select v-model="search.Term"
  24. style="width: 140px;">
  25. <el-option v-for="item in termList"
  26. :key="item.ItemValue"
  27. :label="item.ItemName"
  28. :value="parseInt(item.ItemValue)">
  29. </el-option>
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item label="班级"
  33. class="sbutton_margin">
  34. <el-select v-model="search.ClassId"
  35. filterable
  36. style="width: 140px;">
  37. <el-option v-for="item in classList"
  38. :key="item.Id"
  39. :label="item.Name"
  40. :value="parseInt(item.Id)">
  41. </el-option>
  42. </el-select>
  43. </el-form-item>
  44. <el-button size="mini"
  45. type="primary"
  46. @click="initDatas()"
  47. style="margin-left:10px"
  48. @command="searchCommand"
  49. class="sbutton_margin">查 询</el-button>
  50. <el-button size="mini"
  51. type="primary"
  52. @click="clearSearch"
  53. class="sbutton_margin">重 置</el-button>
  54. <el-button size="mini"
  55. type="primary"
  56. style="margin-right:6px"
  57. @click="openinformationadd()"
  58. class="sbutton_margin">添加</el-button>
  59. </el-form>
  60. </template>
  61. <el-table ref="multipleTable"
  62. :data="activities"
  63. border
  64. fit
  65. tooltip-effect="dark"
  66. style="width: 100%"
  67. @sort-change="orderby"
  68. height="100%">
  69. <el-table-column label="操作"
  70. width="160px"
  71. align="center"
  72. fixed='right'>
  73. <template slot-scope="scope">
  74. <el-button size="mini"
  75. title="编辑"
  76. type="primary"
  77. @click="courseEdit(scope.row.Id)"
  78. icon="el-icon-edit"
  79. circle></el-button>
  80. <el-button size="mini"
  81. type="primary"
  82. title="发布"
  83. @click="publish(scope.row)"
  84. style="margin-left:5px;"
  85. icon="el-icon-s-promotion"
  86. circle></el-button>
  87. <el-button size="mini"
  88. type="primary"
  89. title="详情"
  90. @click="handleDetail(scope.row)"
  91. style="margin-left:5px;"
  92. icon="el-icon-notebook-2"
  93. circle></el-button>
  94. <el-button size="mini"
  95. type="danger"
  96. title="删除"
  97. @click="deleteCourse(scope.row)"
  98. style="margin-left:5px;"
  99. icon="el-icon-delete"
  100. circle></el-button>
  101. </template>
  102. </el-table-column>
  103. <el-table-column prop="Year"
  104. fit
  105. min-width="80px"
  106. label="学年"
  107. align="center"
  108. show-overflow-tooltip></el-table-column>
  109. <el-table-column prop="Term"
  110. label="学期"
  111. align="center"
  112. min-width="160px"
  113. show-overflow-tooltip
  114. :formatter="formatTerm"></el-table-column>
  115. <el-table-column prop="Title"
  116. label="标题"
  117. align="center"
  118. min-width="160px"
  119. show-overflow-tooltip></el-table-column>
  120. <!-- <el-table-column prop="CourseWeek"-->
  121. <!-- label="教学周"-->
  122. <!-- align="center"-->
  123. <!-- min-width="160px"-->
  124. <!-- show-overflow-tooltip></el-table-column>-->
  125. <el-table-column prop="ClassId"
  126. label="班级"
  127. align="center"
  128. min-width="160px"
  129. show-overflow-tooltip
  130. :formatter="formatClass"></el-table-column>
  131. <el-table-column prop="Status"
  132. align="center"
  133. min-width="40px"
  134. label="状态"
  135. show-overflow-tooltip
  136. :formatter="formatStatus"></el-table-column>
  137. <el-table-column prop="CreatedTime"
  138. align="center"
  139. min-width="120px"
  140. label="创建时间"
  141. show-overflow-tooltip></el-table-column>
  142. </el-table>
  143. <!-- </el-card> -->
  144. <courseInfoDialog ref="courseDialog"
  145. @handleClose="handleClose"
  146. :courseId="courseId"
  147. :statusList="statusList"
  148. :termList="termList"
  149. :classList="classList"
  150. width="75"></courseInfoDialog>
  151. <!-- </div> -->
  152. <template slot="footer">
  153. <el-pagination style="margin: -10px;"
  154. @size-change="handleSizeChange"
  155. @current-change="handleCurrentChange"
  156. :current-page="search.page.current"
  157. :page-sizes="[10, 15, 20]"
  158. :page-size="search.page.size"
  159. layout="total, sizes, prev, pager, next, jumper"
  160. :total="search.page.total">
  161. </el-pagination>
  162. </template>
  163. </d2-container>
  164. </template>
  165. <script>
  166. import ClassApi from '@/api/class'
  167. import CourseApi from '@/api/course'
  168. import itemDetailApi from '@/api/sysadmin/itemdetail'
  169. import courseInfoDialog from './components/courseInfoDialog'
  170. export default {
  171. name: 'course',
  172. components: {
  173. courseInfoDialog
  174. },
  175. data () {
  176. return {
  177. dialogvisible: false,
  178. details: false,
  179. activities: [],
  180. courseId: -1,
  181. classList: [], // 班级列表
  182. statusList: [], // 状态列表
  183. termList: [], // 学期
  184. years: [],
  185. search: {
  186. Term: '',
  187. Year: '',
  188. ClassId: '',
  189. page: {
  190. total: 0,
  191. current: 1,
  192. size: 10
  193. }
  194. },
  195. // 列表排序
  196. Column: {
  197. Order: '',
  198. Prop: ''
  199. }
  200. }
  201. },
  202. mounted () {
  203. this.getTerm()
  204. this.getStatus()
  205. this.initDatas()
  206. var myDate = new Date()
  207. var year = myDate.getFullYear() + 1 // 获取下年
  208. this.initSelectYear(year)
  209. },
  210. methods: {
  211. // 匹配状态
  212. formatStatus (row, column) {
  213. for (var i = 0; i < this.statusList.length; i++) {
  214. if (parseInt(this.statusList[i].ItemValue) === parseInt(row.Status)) {
  215. return this.statusList[i].ItemName
  216. }
  217. }
  218. },
  219. // 匹配班级
  220. formatClass (row, column) {
  221. for (var i = 0; i < this.classList.length; i++) {
  222. if (parseInt(this.classList[i].Id) === row.ClassId) {
  223. return this.classList[i].Name
  224. }
  225. }
  226. },
  227. // 获取学期
  228. getTerm () {
  229. itemDetailApi.getItemDetailByItemCode({ ItemCode: 'Term' })
  230. .then(res => {
  231. this.termList = res
  232. })
  233. .catch(err => {
  234. console.error(err)
  235. })
  236. },
  237. // 匹配学期
  238. formatTerm (row, column) {
  239. for (var i = 0; i < this.termList.length; i++) {
  240. if (parseInt(this.termList[i].ItemValue) === parseInt(row.Term)) {
  241. return this.termList[i].ItemName
  242. }
  243. }
  244. },
  245. // 发布状态
  246. getStatus () {
  247. let _this = this
  248. itemDetailApi.getItemDetailByItemCode({ ItemCode: 'PublishStatus' })
  249. .then(res => {
  250. _this.statusList = res
  251. this.initDatas()
  252. })
  253. .catch(err => {
  254. console.error(err)
  255. })
  256. },
  257. initSearchInfo () {
  258. this.search = {
  259. Title: '',
  260. Status: -1,
  261. Content: ''
  262. }
  263. },
  264. // 初始化分页分页对象
  265. initPageInfo () {
  266. this.search.page = {
  267. total: 0,
  268. current: 1,
  269. size: 10
  270. }
  271. },
  272. initSelectYear (year) {
  273. this.years = []
  274. for (let i = 0; i < 5; i++) {
  275. this.years.push({ value: (year - i), label: (year - i) + '年' })
  276. }
  277. },
  278. // 打开 添加弹窗
  279. openinformationadd () {
  280. this.$refs.courseDialog.dialogvisible = true
  281. },
  282. // 打开 编辑弹窗
  283. courseEdit (courseId) {
  284. this.courseId = courseId
  285. this.$refs.courseDialog.dialogvisible = true
  286. },
  287. // 新增修改弹窗关闭 返回页面
  288. handleClose () {
  289. this.courseId = -1
  290. this.$refs.courseDialog.dialogvisible = false
  291. this.initPageInfo()
  292. this.initDatas()
  293. },
  294. publish (course) {
  295. course.Status = 1
  296. CourseApi.addCourse(course)
  297. },
  298. // 初始化列表数据
  299. initDatas () {
  300. let params = {
  301. // 分页信息
  302. size: this.search.page.size,
  303. current: this.search.page.current,
  304. Year: this.search.Year,
  305. Term: this.search.Term,
  306. ClassId: this.search.ClassId
  307. }
  308. this.getClassList()
  309. CourseApi.getPageList(params)
  310. .then(res => {
  311. this.activities = res.records ? res.records : []
  312. this.search.page.total = res.total
  313. })
  314. },
  315. handleSizeChange (val) {
  316. this.search.page.size = val
  317. this.search.page.current = 1
  318. this.initDatas()
  319. },
  320. handleCurrentChange (val) {
  321. this.search.page.current = val
  322. this.initDatas()
  323. },
  324. // 详情
  325. handleDetail (course) {
  326. this.$router.push({ name: 'courseDetailEdit', params: { CourseId: course.Id, Year: course.Year, Term: course.Term, Class: course.ClassId } })
  327. },
  328. // 删除课程
  329. deleteCourse (val) {
  330. let _this = this
  331. let params = {
  332. id: val.Id
  333. }
  334. _this.$confirm('此操作将永久删除该信息, 是否继续?', '提示', {
  335. confirmButtonText: '确定',
  336. cancelButtonText: '关闭',
  337. type: 'warning'
  338. }).then(() => {
  339. CourseApi.deleteCourse(params)
  340. .then(data => {
  341. _this.initDatas()
  342. })
  343. .catch(function (error) {
  344. console.log(error)
  345. })
  346. })
  347. .catch(() => { })
  348. },
  349. // 列表排序功能
  350. orderby (column) {
  351. if (column.order === 'ascending') {
  352. this.Column.Order = 'asc'
  353. } else if (column.order === 'descending') {
  354. this.Column.Order = 'desc'
  355. }
  356. this.Column.Prop = column.prop
  357. this.initDatas()
  358. },
  359. searchCommand (command) {
  360. if (command === 'search') {
  361. this.dialogvisible = true
  362. } else if (command === 'clear') {
  363. this.clearSearch()
  364. }
  365. },
  366. clearSearch () {
  367. this.initSearchInfo()
  368. this.initPageInfo()
  369. this.initDatas()
  370. },
  371. // 获取班级列表
  372. getClassList () {
  373. let params = {
  374. _currentPage: 1,
  375. _size: 9999
  376. }
  377. ClassApi.getAllClass(params)
  378. .then(res => {
  379. this.classList = res.records
  380. })
  381. }
  382. }
  383. }
  384. </script>
  385. <style lang="scss">
  386. .el-pagination {
  387. margin: 1rem 0 2rem;
  388. text-align: right;
  389. }
  390. .plab {
  391. font-size: 13px;
  392. color: #999;
  393. }
  394. </style>