inform.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <template>
  2. <div class="box boxMinHeight">
  3. <header class="header flex-box-ce">
  4. <div class="header-title" >
  5. <div class="flex-box-ce" style="cursor: pointer;width: 200px;" @click="$router.go(-1)">
  6. <i class="el-icon-arrow-left fontColorC"></i>
  7. <div class="text fontColorB font-flex-word">公告列表</div>
  8. </div>
  9. </div>
  10. <el-button type="primary" style="margin-left: 20px;" size="small" @click="app()" v-if="isAdministrator">发布公告</el-button>
  11. </header>
  12. <div class="main flex-box">
  13. <div class="main-left scroll-bar">
  14. <div v-for="(item, index) in announcement" :key="index" class="font-flex-word"
  15. :class="item.id == articleOne.id ? 'active' : ''"
  16. @click="dept_click(item)"
  17. style="height: 56px;line-height: 56px;padding: 0 10px;border-bottom: 1px solid #f1f1f1;"
  18. >
  19. {{ item.name }}
  20. </div>
  21. <noData v-show="announcement.length == 0" content="暂无数据" imgW="60%" imgH="auto" isSolt>
  22. <el-button v-if="isAdministrator" type="primary" size="small" style="margin-right: 20px;" @click="app()">发布公告</el-button>
  23. </noData>
  24. </div>
  25. <div class="main-right flex-1" v-loading="noticeLoad">
  26. <div class="title" style="position: relative;" v-if="announcement.length>0">
  27. <span class="fontColorC" style="position: absolute;"><span v-if="detaliData.tag[0]" :class="detaliData.tag[0]=='公告'? 'spanBox':'spanBox2'">{{detaliData.tag[0]}}</span> {{ detaliData.create_time ? detaliData.create_time : '' }} {{detaliData.employee_name}}发布</span>
  28. <div style="font-size: 18px;padding-right: 10px;text-align: center;">{{ detaliData.name ? detaliData.name : '' }}</div>
  29. <div style="position: absolute;right:20px;top:0px" v-if="isAdministrator">
  30. <el-button type="danger" plain size="small" @click="deteleItem">删除</el-button>
  31. <el-button type="primary" v-if="detaliData.content.html" plain size="small" @click="compile">编辑</el-button>
  32. </div>
  33. </div>
  34. <div class="RuleRight scroll-bar">
  35. <template v-if="aAtripOfDetails">
  36. <div v-html="aAtripOfDetails"></div>
  37. <template v-for="(item,index) in detaliData.file_list" v-if="detaliData.file_list.length>0">
  38. <el-image :src="item" style="margin-top: 20px;" :preview-src-list="[item]"/>
  39. </template>
  40. </template>
  41. <noData v-else></noData>
  42. </div>
  43. </div>
  44. </div>
  45. <SuggestHtml :visible.sync="isShowJy" :detaliData="detaliData" :isAdd="isAdd"></SuggestHtml>
  46. </div>
  47. </template>
  48. <script>
  49. import { setCache } from '@/utils/auth';
  50. import SuggestHtml from '@/components/SuggestHtml';
  51. export default {
  52. components: { SuggestHtml },
  53. name: 'update_notice',
  54. data() {
  55. return {
  56. articleOne: {tag:[]},
  57. announcement: [],
  58. noticeLoad: false,
  59. defaultProps: {
  60. label: 'name'
  61. },
  62. aAtripOfDetails: '',
  63. isShowJy: false,
  64. detaliData:{content:{},tag:[]},
  65. isAdd:true,
  66. isAdministrator:this.$getIsAdministrator(),
  67. };
  68. },
  69. created() {
  70. setCache('inform', true);
  71. if(this.$route.query.id){
  72. this.articleOne.id=this.$route.query.id;
  73. }
  74. this.noticeList();
  75. },
  76. methods: {
  77. deteleItem() {
  78. this.$confirm('此操作将永久删除该公告, 是否删除?', '提示', {
  79. confirmButtonText: '确定',
  80. cancelButtonText: '取消',
  81. type: 'warning'
  82. }).then(() => {
  83. this.$axiosUser('POST', '/api/pro/information/delete', {id:this.articleOne.id}).then(res => {
  84. if (res.data.code == 1) {
  85. this.$message.success("已删除")
  86. this.articleOne={tag:[]};
  87. this.noticeList();
  88. }
  89. });
  90. }).catch(() => {});
  91. },
  92. compile() {
  93. this.isAdd=false
  94. this.isShowJy = true;
  95. },
  96. app() {
  97. this.isAdd=true
  98. this.isShowJy = true;
  99. },
  100. noticeList() {
  101. let params = {
  102. page: 1,
  103. page_size: 2000
  104. };
  105. this.$axiosUser('get', '/api/pro/information/list/page', params).then(res => {
  106. let list = res.data.data.list;
  107. this.announcement = list;
  108. if(this.articleOne.id){
  109. let is=false
  110. list.forEach(item=>{
  111. if(item.id==this.articleOne.id){
  112. is=true;
  113. }
  114. })
  115. if(is){
  116. this.noticeDetails();
  117. }else if(list[0]){
  118. this.articleOne = list[0];
  119. this.noticeDetails();
  120. }
  121. this.noticeDetails();
  122. }else if(list[0]){
  123. this.articleOne = list[0];
  124. this.noticeDetails();
  125. }
  126. });
  127. },
  128. noticeDetails() {
  129. if (!this.articleOne.id) {
  130. return false;
  131. }
  132. this.noticeLoad = true;
  133. this.aAtripOfDetails='';
  134. this.$axiosUser('get', '/api/pro/information/info', { id: this.articleOne.id }).then(res => {
  135. this.aAtripOfDetails = res.data.data.content.html|| res.data.data.content.content;
  136. let data=res.data.data
  137. if(data.file_list){
  138. data.file_list=data.file_list.split(",");
  139. }
  140. this.detaliData=data;
  141. }).finally(() => {
  142. this.noticeLoad = false;
  143. });
  144. },
  145. dept_click(item) {
  146. this.articleOne = item;
  147. this.noticeDetails();
  148. }
  149. }
  150. };
  151. </script>
  152. <style scoped lang="scss">
  153. .active {
  154. color: #26a2ff;
  155. background-color: #ecf5ff;
  156. }
  157. .spanBox{
  158. color: #26a2ff;
  159. background-color: #fff;
  160. border:1px solid #26a2ff;
  161. border-radius: 4px;
  162. padding: 0 4px;
  163. }
  164. .spanBox2 {
  165. color: #FF9600;
  166. background-color: #fff;
  167. border:1px solid #FF9600;
  168. border-radius: 4px;
  169. padding: 0 4px;
  170. }
  171. /* 表格 */
  172. table {
  173. border-collapse: collapse;
  174. }
  175. table th,
  176. table td {
  177. border: 1px solid #ccc;
  178. min-width: 50px;
  179. height: 20px;
  180. text-align: left;
  181. }
  182. table th {
  183. background-color: #f1f1f1;
  184. text-align: center;
  185. }
  186. /* 代码块 */
  187. pre > code {
  188. display: block;
  189. border: 1px solid hsl(0, 0%, 91%);
  190. border-radius: 4px 4px;
  191. text-indent: 0;
  192. background-color: #fafafa;
  193. padding: 10px;
  194. font-size: 14px;
  195. }
  196. /* 引用 */
  197. blockquote {
  198. display: block;
  199. border-left: 8px solid #d0e5f2;
  200. padding: 10px 10px;
  201. margin: 10px 0;
  202. background-color: #f1f1f1;
  203. }
  204. /* 列表 */
  205. ul,
  206. ol {
  207. margin: 10px 0 10px 20px;
  208. }
  209. ::v-deep p{
  210. margin-block-start: 1em;
  211. margin-block-end: 1em;
  212. }
  213. /* 分割线 */
  214. hr {
  215. display: block;
  216. width: 90%;
  217. margin: 20px auto;
  218. border: 0;
  219. height: 1px;
  220. background-color: #ccc;
  221. }
  222. .header {
  223. border-bottom: 1px solid #f1f1f1;
  224. padding-bottom: 10px;
  225. padding-right: 20px;
  226. }
  227. .header-title {
  228. box-sizing: border-box;
  229. position: relative;
  230. width: 200px;
  231. }
  232. .el-icon-arrow-left {
  233. font-size: 20px;
  234. }
  235. .header-title:hover .el-icon-arrow-left {
  236. background-color: #f5f7fa;
  237. color: #222;
  238. }
  239. .text {
  240. font-size: 16px;
  241. padding-left: 30px;
  242. }
  243. .text::before {
  244. position: absolute;
  245. content: '';
  246. width: 1px;
  247. height: 60px;
  248. background-color: #ebebeb;
  249. left: 34px;
  250. top: 50%;
  251. margin-top: -18px;
  252. }
  253. .title {
  254. background-color: #fff;
  255. height: 56px;
  256. line-height: 56px;
  257. border-bottom: 1px solid #f1f1f1;
  258. }
  259. .RuleRight {
  260. height: 690px;
  261. overflow-y: auto;
  262. position: relative;
  263. }
  264. ::v-deep .el-tree--highlight-current {
  265. .el-tree-node {
  266. border-bottom: 1px #f0f0f0 solid;
  267. }
  268. .el-tree-node__content {
  269. background-color: #fff;
  270. height: 56px;
  271. line-height: 56px;
  272. }
  273. .is-current {
  274. .el-tree-node__content {
  275. .el-icon-caret-right {
  276. // color:#409eff !important;
  277. }
  278. .el-tree-node__label {
  279. color: #409eff !important;
  280. }
  281. }
  282. .el-tree-node__children {
  283. .el-icon-caret-right {
  284. color: #c0c4cc !important;
  285. }
  286. .el-tree-node__label {
  287. color: #606266 !important;
  288. }
  289. }
  290. }
  291. }
  292. .tabs ::v-deep.el-badge__content.is-fixed {
  293. position: absolute;
  294. top: 50%;
  295. right: -2px;
  296. }
  297. .box {
  298. padding: 20px;
  299. font-size: 14px;
  300. position: relative;
  301. background-color: #fff;
  302. }
  303. .main {
  304. margin-top: 30px;
  305. }
  306. /* bug: 我在flex布局的元素中使用了elementui的table组件,饿了么的table上会被加一个动态的宽度, 当第一次改变flex元素宽度的时候。table的动态宽度会变化,第二次和以后就不会变化了。*/
  307. /* 给使用flex的元素加上 overflow-x:hidden */
  308. .main-right {
  309. margin-left: 20px;
  310. overflow-x: hidden;
  311. }
  312. .main-left {
  313. width: 200px;
  314. border-radius: 3px;
  315. box-sizing: border-box;
  316. // padding-right: 20px;
  317. max-height: 700px;
  318. overflow: auto;
  319. }
  320. .main-left::after {
  321. position: absolute;
  322. content: '';
  323. width: 1px;
  324. height: auto;
  325. left: 220px;
  326. top: 0;
  327. bottom: 0;
  328. background-color: #f1f1f1;
  329. }
  330. ::v-deep .has-gutter {
  331. display: none;
  332. }
  333. .li {
  334. height: 53px;
  335. line-height: 53px;
  336. padding: 0 20px;
  337. border-bottom: 1px solid #f1f1f1;
  338. color: #777777;
  339. width: 100%;
  340. }
  341. .li:hover {
  342. background-color: #f5f7fa;
  343. }
  344. .li:hover .el-icon-more {
  345. display: block;
  346. }
  347. .index-name {
  348. width: 170px;
  349. }
  350. .ul {
  351. max-height: calc(100vh - 230px);
  352. overflow: auto;
  353. width: 200px;
  354. }
  355. .isActiveLi {
  356. background-color: #f5f7fa;
  357. color: #409eff !important;
  358. position: relative;
  359. }
  360. .isActiveLi::after {
  361. width: 3px;
  362. content: ' ';
  363. background-color: #409eff;
  364. left: 0;
  365. bottom: 0;
  366. top: 0;
  367. position: absolute;
  368. }
  369. .item {
  370. font-size: 14px;
  371. cursor: pointer;
  372. padding: 8px;
  373. border-bottom: 1px solid #e8e8e8;
  374. }
  375. .item:hover {
  376. background-color: #f5f7fa;
  377. }
  378. .content {
  379. padding: 0 10px;
  380. }
  381. </style>