articleContent.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <div>
  3. <a-card :bordered="false">
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline">
  6. <a-row :gutter="48">
  7. <a-col :md="8" :sm="32">
  8. <a-form-item label="标题">
  9. <a-input v-model="queryParam.articleContentTitle" allow-clear placeholder="请输入标题搜索" />
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="8" :sm="32">
  13. <a-form-item label="类型">
  14. <a-select v-model="queryParam.systemDictType" placeholder="请选择类型" allow-clear>
  15. <a-select-option
  16. v-for="(item,index) in typeDictTypeDropDown"
  17. :key="index"
  18. :value="item.code"
  19. >{{ item.name }}</a-select-option>
  20. </a-select>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="8" :sm="32">
  24. <a-button type="primary" @click="$refs.table.refresh(true)">搜索</a-button>
  25. <a-button type="primary" style="margin-left: 8px" icon="plus" @click="$refs.detailsOplog.add()">新增</a-button>
  26. </a-col>
  27. </a-row>
  28. </a-form>
  29. <!-- 表格 -->
  30. <s-table
  31. ref="table"
  32. size="default"
  33. :pagination="false"
  34. :loading="loading"
  35. :columns="columns"
  36. :data="loadData"
  37. :rowKey="(record) => record.articleContentId"
  38. >
  39. <span slot="articleContentTitle" slot-scope="text">
  40. <ellipsis :length="30" tooltip>{{ text }}</ellipsis>
  41. </span>
  42. <span slot="articleContentCover" slot-scope="src">
  43. <img :src="src | getImgUrl" width="60" height="45" @click="showPreviewImg(src)" style="cursor: pointer;"/>
  44. </span>
  45. <span slot="articleContentAbstract" slot-scope="text">
  46. <ellipsis :length="80" tooltip>{{ text }}</ellipsis>
  47. </span>
  48. <span slot="articleContentType" slot-scope="text">
  49. {{ typeFilter(text) }}
  50. </span>
  51. <span slot="action" slot-scope="text, record">
  52. <a-popconfirm placement="top" :title="record.articleContentIsLine===1? '是否确认下线该条目?':'是否确认上线该条目?'" @confirm="() => editjobStatusStatus(record.articleContentIsLine,record)">
  53. <a>{{ statusFilter(record.articleContentIsLine) }}</a>
  54. </a-popconfirm>
  55. <a-divider type="vertical"/>
  56. <a v-if="hasPerm('articleContent:edit')" @click="$refs.detailsOplog.edit(record)">编辑</a>
  57. <a-divider type="vertical" v-if="hasPerm('articleContent:edit') && hasPerm('articleContent:delete')"/>
  58. <a-popconfirm v-if="hasPerm('articleContent:delete')" placement="topRight" title="是否确认删除该条目?" @confirm="() => articleContentDelete(record)">
  59. <a>删除</a>
  60. </a-popconfirm>
  61. </span>
  62. </s-table>
  63. </div>
  64. <details-oplog ref="detailsOplog" @ok="handleOk"/>
  65. <a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel" title="预览">
  66. <img alt="example" style="width: 100%" :src="previewImage" />
  67. </a-modal>
  68. </a-card>
  69. </div>
  70. </template>
  71. <script>
  72. import { STable, Ellipsis } from '@/components'
  73. import homeApi from '@/api/homeApi'
  74. import { setImgUrl } from '@/utils/img'
  75. import {
  76. findArticleContentById,
  77. updateArticleContent,
  78. deleteArticleContent
  79. } from '@/api/modular/system/contentControlApi'
  80. import detailsOplog from './details'
  81. export default {
  82. components: {
  83. STable,
  84. detailsOplog,
  85. Ellipsis
  86. },
  87. data () {
  88. return {
  89. // 查询参数
  90. queryParam: { id: '', systemDictType: '', articleContentTitle: '' },
  91. typeDictTypeDropDown: homeApi.systemTypeList,
  92. // 表头
  93. columns: [
  94. {
  95. title: '序号',
  96. dataIndex: 'dataIndex',
  97. customRender: (text, row, index) => {
  98. return index + 1
  99. },
  100. align: 'center',
  101. width: '90px'
  102. },
  103. {
  104. title: '标题',
  105. dataIndex: 'articleContentTitle',
  106. scopedSlots: { customRender: 'articleContentTitle' }
  107. },
  108. {
  109. title: '封面',
  110. dataIndex: 'articleContentCover',
  111. scopedSlots: { customRender: 'articleContentCover' },
  112. align: 'center',
  113. width: '150px'
  114. },
  115. {
  116. title: '摘要',
  117. dataIndex: 'articleContentAbstract',
  118. scopedSlots: { customRender: 'articleContentAbstract' }
  119. },
  120. {
  121. title: '内容类型',
  122. dataIndex: 'articleContentType',
  123. scopedSlots: { customRender: 'articleContentType' },
  124. width: '120px'
  125. },
  126. {
  127. title: '分类',
  128. dataIndex: 'articleContentClassify'
  129. },
  130. {
  131. title: '子分类',
  132. dataIndex: 'articleContentSubclassify'
  133. },
  134. {
  135. title: '排序',
  136. dataIndex: 'articleContentSort',
  137. align: 'center',
  138. width: '60px'
  139. }
  140. ],
  141. loading: true,
  142. loadData: parameter => {
  143. return findArticleContentById(Object.assign(parameter, this.queryParam)).then((res) => {
  144. if (this.hasPerm('ArticleContent:list')) {
  145. return res.data
  146. }
  147. })
  148. },
  149. selectedRows: [],
  150. statusDictTypeDropDown: [{ code: 0, name: '下线' }, { code: 1, name: '上线' }],
  151. previewVisible: false,
  152. previewImage: ''
  153. }
  154. },
  155. created () {
  156. if (this.hasPerm('articleContent:edit') || this.hasPerm('articleContent:delete') || hasPerm('articleContent:start') || hasPerm('articleContent:stop')) {
  157. this.columns.push({
  158. title: '操作',
  159. width: '150px',
  160. dataIndex: 'action',
  161. scopedSlots: { customRender: 'action' }
  162. })
  163. }
  164. },
  165. filters: {
  166. getImgUrl (v) {
  167. return setImgUrl(v)
  168. }
  169. },
  170. methods: {
  171. statusFilter (status) {
  172. const values = this.statusDictTypeDropDown.filter(item => item.code === status)
  173. if (values.length > 0) {
  174. return values[0].name
  175. } else {
  176. return '上线'
  177. }
  178. },
  179. typeFilter (status) {
  180. const values = this.typeDictTypeDropDown.filter(item => item.code === status)
  181. if (values.length > 0) {
  182. return values[0].name
  183. } else {
  184. return ''
  185. }
  186. },
  187. /**
  188. * 启动停止
  189. */
  190. editjobStatusStatus (code, record) {
  191. if (code === 1) {
  192. updateArticleContent({ id: record.articleContentId, isLine: 0 }).then(res => {
  193. if (res.status === 200) {
  194. if (res.data) {
  195. this.$message.success('下线成功')
  196. this.$refs.table.refresh()
  197. } else {
  198. this.$message.error('下线失败')
  199. }
  200. } else {
  201. this.$message.error('下线失败:' + res.msg)
  202. }
  203. })
  204. } else {
  205. updateArticleContent({ id: record.articleContentId, isLine: 1 }).then(res => {
  206. if (res.status === 200) {
  207. if (res.data) {
  208. this.$message.success('上线成功')
  209. this.$refs.table.refresh()
  210. } else {
  211. this.$message.error('上线失败')
  212. }
  213. } else {
  214. this.$message.error('上线失败:' + res.msg)
  215. }
  216. })
  217. }
  218. },
  219. articleContentDelete (record) {
  220. deleteArticleContent({ id: record.articleContentId }).then((res) => {
  221. if (res.status === 200) {
  222. if (res.data) {
  223. this.$message.success('删除成功')
  224. this.$refs.table.refresh()
  225. } else {
  226. this.$message.error('删除失败')
  227. }
  228. } else {
  229. this.$message.error('删除失败:' + res.msg)
  230. }
  231. }).catch((err) => {
  232. this.$message.error('删除错误:' + err.message)
  233. })
  234. },
  235. handleOk () {
  236. this.$refs.table.refresh()
  237. },
  238. showPreviewImg (src) {
  239. this.previewImage = setImgUrl(src)
  240. this.previewVisible = true
  241. },
  242. handleCancel () {
  243. this.previewVisible = false
  244. }
  245. }
  246. }
  247. </script>
  248. <style lang="less">
  249. .mr5 {
  250. margin-right: 5px;
  251. }
  252. </style>