ArtDetail.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <div class="content-container">
  3. <div class="header">
  4. <div class="title"><span v-if="withHeader">{{ artInfo.artTitle }}</span></div>
  5. <div v-if="type==='instruction'" class="handle-container">
  6. <el-button type="text" @click="handleAdd">新增</el-button>
  7. <el-button v-if="isNotNull(artId)" type="text" @click="handleEdit">编辑</el-button>
  8. <el-button v-if="isNotNull(artId)" type="text" @click="handleDel">删除</el-button>
  9. </div>
  10. </div>
  11. <template>
  12. <div class="artDetail-container">
  13. <div v-if="artInfo&&artInfo.artContent" class="art-container" v-html="artInfo.artContent" />
  14. <el-empty v-else description="没有实施指南信息" style="margin-top:100px;" />
  15. <div v-if="artInfo.attachList&&artInfo.attachList.length>0" class="attachList-container">
  16. <h4 class="title">附件:</h4>
  17. <div class="container">
  18. <div class="attach-list">
  19. <p v-for="(item,index) in artInfo.attachList" :key="index"><attach-list :uri="item.fileUrl" :name="item.fileTitle" /></p>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. </template>
  25. <art ref="EditArt" :type="2" title="编辑文章" @formSuccess="EditArtSuccess" />
  26. <art ref="AddArt" :type="2" title="新增文章" @formSuccess="addArtSuccess" />
  27. </div>
  28. </template>
  29. <script>
  30. import Art from '@/views/system/art/components/Art'
  31. import { getArtById, deleteArtById } from '@/api/system/artApi'
  32. import AttachList from '@/components/AttachList'
  33. import { isNotNull } from '@/utils'
  34. export default {
  35. name: 'ArtDetail',
  36. components: { Art, AttachList },
  37. props: {
  38. withHeader: {
  39. type: [Boolean, String],
  40. default: true
  41. },
  42. type: {
  43. type: String,
  44. default: 'news'
  45. },
  46. artCatId: {
  47. type: [Number, String],
  48. default: 'true'
  49. }
  50. },
  51. data() {
  52. return {
  53. dialogVisible: false,
  54. artId: undefined,
  55. artCatTitle: '',
  56. artInfo: {
  57. artTitle: '',
  58. artContent: '',
  59. attachList: []
  60. }
  61. }
  62. },
  63. methods: {
  64. isNotNull,
  65. loadData(artId, artCatTitle) {
  66. this.dialogVisible = true
  67. this.artId = artId
  68. this.artCatTitle = artCatTitle
  69. this.getData()
  70. },
  71. getData() {
  72. getArtById(this.artId).then((res) => {
  73. const { code, msg, data } = res
  74. if (code === 200) {
  75. if (data) {
  76. this.artInfo = data
  77. } else {
  78. this.artInfo = false
  79. }
  80. } else {
  81. this.$message.error(msg)
  82. }
  83. })
  84. },
  85. addArtSuccess() {
  86. this.$emit('success', 'success')
  87. },
  88. EditArtSuccess() {
  89. this.$emit('success', 'edit')
  90. },
  91. handleAdd() {
  92. this.$refs['AddArt'].showAddModel(this.artCatId, this.artCatTitle)
  93. },
  94. handleEdit() {
  95. const artId = this.artId
  96. if (!artId) return
  97. this.$refs['EditArt'].showEditModel(artId)
  98. },
  99. handleDel() {
  100. const artId = this.artId
  101. this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
  102. confirmButtonText: '确定',
  103. cancelButtonText: '取消',
  104. type: 'warning'
  105. }).then(() => {
  106. deleteArtById(artId).then(() => {
  107. this.$emit('success', 'del')
  108. }).catch(() => {
  109. this.$message({
  110. type: 'info',
  111. message: '删除失败!'
  112. })
  113. })
  114. })
  115. }
  116. }
  117. }
  118. </script>
  119. <style lang="scss" scoped>
  120. .content-container{
  121. color: #fff;
  122. margin: 10px 10px 10px 10px;
  123. padding: 15px;
  124. background-color: #193142FF;
  125. height: calc(100vh - 95px);
  126. .header{
  127. display: flex;
  128. justify-content: space-between;
  129. align-items: center;
  130. .title{
  131. font-size: 20px;
  132. font-weight: 600;
  133. line-height: 1.8;
  134. }
  135. }
  136. .artDetail-container{
  137. height:calc(100% - 50px);
  138. overflow-y: auto;
  139. }
  140. .art-container{
  141. font-size: 14px;
  142. line-height: 1.8;
  143. text-indent: 24px;
  144. text-align: justify;
  145. word-break: break-all;
  146. }
  147. }
  148. .attachList-container{
  149. padding: 10px 0;
  150. border-top: 1px solid #464646;
  151. margin-top: 10px;
  152. .title{
  153. margin: 0;
  154. font-size: 16px;
  155. }
  156. .container{
  157. padding:0 24px;
  158. .attach-list{
  159. p{
  160. margin: 0;
  161. }
  162. }
  163. }
  164. .emptyTxt{
  165. color:#ccc;
  166. }
  167. }
  168. </style>