index.vue 8.9 KB

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