page.vue 6.7 KB

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