index.vue 11 KB

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