index.vue 11 KB

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