notice.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :getList="getList"
  5. :tableEvents="tableEvents"
  6. :optionsEvensGroup="optionsEvensGroup"
  7. :operation="operation()"
  8. :tableAttributes="tableAttributes"
  9. :columnParsing="columnParsing"
  10. >
  11. <!-- 新增 -->
  12. <el-dialog
  13. title="新增"
  14. :visible.sync="mainFormDialog"
  15. :show-close="false"
  16. width="60%"
  17. :close-on-click-modal="false"
  18. >
  19. <el-form ref="mainForm" :model="mainForm" :rules="mainFormRules" label-position="right" label-width="90px">
  20. <el-row :gutter="20">
  21. <el-col :xs="24" :sm="12" :lg="12">
  22. <el-form-item label="通知类型" prop="type">
  23. <el-input v-model="mainForm.type" placeholder="请输入通知类型"></el-input>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :xs="24" :sm="12" :lg="12">
  27. <el-form-item label="文件编号" prop="code">
  28. <el-input v-model="mainForm.code" placeholder="请输入文件编号"></el-input>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :xs="24" :sm="12" :lg="12">
  32. <el-form-item label="文件标题" prop="title">
  33. <el-input v-model="mainForm.title" placeholder="请输入文件标题"></el-input>
  34. </el-form-item>
  35. </el-col>
  36. <el-col :xs="24" :sm="12" :lg="12">
  37. <el-form-item label="来源" prop="source">
  38. <el-input v-model="mainForm.source" placeholder="请输入来源"></el-input>
  39. </el-form-item>
  40. </el-col>
  41. <el-col :xs="24" :sm="24" :lg="24">
  42. <el-form-item label="发布日期" prop="date">
  43. <el-date-picker
  44. v-model="mainForm.date"
  45. type="datetime"
  46. value-format="yyyy-MM-dd HH:mm:ss"
  47. style="width: 100%"
  48. placeholder="选择发布日期"
  49. >
  50. </el-date-picker>
  51. </el-form-item>
  52. </el-col>
  53. <el-col :xs="24" :sm="24" :lg="24">
  54. <el-form-item label="发布内容" prop="content">
  55. <el-input
  56. type="textarea"
  57. v-model="mainForm.content"
  58. placeholder="请输入发布内容"
  59. :autosize="{ minRows: 4, maxRows: 8 }"
  60. ></el-input>
  61. </el-form-item>
  62. </el-col>
  63. <el-col :xs="24" :sm="24" :lg="24">
  64. <el-form-item label="接收人" prop="department">
  65. <el-tree
  66. :data="departmentList"
  67. show-checkbox
  68. node-key="adminWebsitId"
  69. ref="tree"
  70. highlight-current
  71. :props="props"
  72. >
  73. </el-tree>
  74. </el-form-item>
  75. </el-col>
  76. </el-row>
  77. <el-form-item label="上传附件" prop="fileUrl">
  78. <ImageUpload :fileList="fileList" :multiple="true" />
  79. </el-form-item>
  80. </el-form>
  81. <div slot="footer" class="dialog-footer">
  82. <el-button @click="closeMainForm">取 消</el-button>
  83. <el-button type="primary" @click="submitMainForm">确 定</el-button>
  84. </div>
  85. </el-dialog>
  86. <!-- 已阅记录 -->
  87. <el-dialog
  88. title="已阅记录"
  89. :visible.sync="recordDialog"
  90. :show-close="false"
  91. width="70%"
  92. :close-on-click-modal="false"
  93. >
  94. <div class="table" style="margin: 10px 0 20px">
  95. <el-table
  96. v-loading="detailTable_listLoading"
  97. :data="detailTable_dataList"
  98. element-loading-text="Loading"
  99. tooltip-effect="dark"
  100. style="width: 100%"
  101. max-height="270"
  102. >
  103. <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
  104. <el-table-column
  105. align="center"
  106. prop="title"
  107. label="标题"
  108. min-width="140"
  109. show-overflow-tooltip
  110. ></el-table-column>
  111. <el-table-column align="center" prop="websitNumber" label="网点名称" min-width="140" show-overflow-tooltip>
  112. <template slot-scope="scope"> {{ scope.row.websitName }}({{ scope.row.websitNumber }}) </template>
  113. </el-table-column>
  114. <el-table-column
  115. align="center"
  116. prop="remark"
  117. label="备注"
  118. min-width="140"
  119. show-overflow-tooltip
  120. ></el-table-column>
  121. <el-table-column align="center" prop="createTime" label="下载时间" min-width="160"></el-table-column>
  122. </el-table>
  123. </div>
  124. <div class="pagination clearfix">
  125. <div class="fr">
  126. <el-pagination
  127. @current-change="detailTableCurrentChange"
  128. :current-page="detailTable_currentPage"
  129. :page-size="detailTable_pageSize"
  130. background
  131. layout="prev, pager, next"
  132. :total="detailTable_listTotal"
  133. >
  134. </el-pagination>
  135. </div>
  136. </div>
  137. <div slot="footer" class="dialog-footer">
  138. <el-button @click="recordDialog = false">关 闭</el-button>
  139. </div>
  140. </el-dialog>
  141. <!-- 详情 -->
  142. <el-dialog title="浏览" :visible.sync="detailDialog" width="60%" :close-on-click-modal="false">
  143. <div class="detail-container">
  144. <div class="title">{{ detailData.title }}</div>
  145. <div class="text">
  146. 发布人:{{ detailData.issueNickName }}<el-divider direction="vertical"></el-divider>发布时间:{{
  147. detailData.issueTime
  148. }}
  149. </div>
  150. <el-divider></el-divider>
  151. <div class="content">{{ detailData.content }}</div>
  152. <el-divider v-if="detailData.files && detailData.files.length > 0"></el-divider>
  153. <div class="file" v-if="detailData.files && detailData.files.length > 0">
  154. <div>附件:</div>
  155. <div class="file-list">
  156. <div v-for="(item, index) in detailData.files" :key="index" class="item">
  157. <el-image
  158. v-if="checkFileType(item.url) == 'image'"
  159. class="img"
  160. :src="imageURL + item.url"
  161. :preview-src-list="[imageURL + item.url]"
  162. ></el-image>
  163. <div v-else class="box2" @click="openLink(item.url)">
  164. <img src="@/assets/common/word.png" v-if="checkFileType(item.url) == 'word'" />
  165. <img src="@/assets/common/excel.png" v-if="checkFileType(item.url) == 'excel'" />
  166. <img src="@/assets/common/ppt.png" v-if="checkFileType(item.url) == 'ppt'" />
  167. <img src="@/assets/common/pdf.png" v-if="checkFileType(item.url) == 'pdf'" />
  168. <div class="name ellipsis-3">{{ item.name }}</div>
  169. </div>
  170. </div>
  171. </div>
  172. </div>
  173. </div>
  174. <div slot="footer" class="dialog-footer">
  175. <el-button type="primary" @click="confirmCheck(detailData.id)" v-if="!detailData.readFlag">确认接收</el-button>
  176. <el-button @click="detailDialog = false" v-if="detailData.readFlag">关 闭</el-button>
  177. </div>
  178. </el-dialog>
  179. </template-page>
  180. </template>
  181. <script>
  182. import TemplatePage from '@/components/template/template-page-1.vue'
  183. import import_mixin from '@/components/template/import_mixin.js'
  184. import add_callback_mixin from '@/components/template/add_callback_mixin.js'
  185. import Popu from '@/components/template/popu.vue'
  186. import {
  187. getListV2,
  188. getDownloadList,
  189. deleteData,
  190. addData,
  191. getDepartmentList,
  192. getDetail,
  193. confirmCheck
  194. } from '@/api/notice'
  195. import { getFileUrl } from '@/api/common'
  196. import ImageUpload from '@/components/Common/image-upload.vue'
  197. export default {
  198. components: { TemplatePage, Popu, ImageUpload },
  199. mixins: [import_mixin, add_callback_mixin],
  200. data() {
  201. return {
  202. visible: false,
  203. // 事件组合
  204. optionsEvensGroup: [
  205. [
  206. [
  207. {
  208. name: '新增',
  209. click: this.addOn(() => {
  210. this.openMainForm()
  211. })
  212. // isRole: this.$checkBtnRole('add', this.$route.meta.roles)
  213. }
  214. ]
  215. ],
  216. [
  217. [
  218. {
  219. name: '批量删除',
  220. click: async () => {
  221. if (this.recordSelected.length === 0) {
  222. this.$message.error('请选择需要删除的数据')
  223. return
  224. }
  225. let ids = this.recordSelected.map(v => {
  226. return v.id
  227. })
  228. let params = ids
  229. await deleteData({ id: params.join(',') })
  230. this.$refs.pageRef.refreshList()
  231. this.$message.success('批量删除成功')
  232. }
  233. }
  234. ]
  235. ]
  236. ],
  237. // 表格属性
  238. tableAttributes: {
  239. // 启用勾选列
  240. selectColumn: true
  241. }, // 关闭新增弹窗
  242. // 表格事件
  243. tableEvents: {
  244. 'selection-change': this.selectionChange
  245. },
  246. recordSelected: [],
  247. imageURL: this.$imageUrl,
  248. dataList: null, // 列表数据
  249. listLoading: true, // 列表加载loading
  250. currentPage: 1, // 当前页码
  251. pageSize: 10, // 每页数量
  252. listTotal: 0, // 列表总数
  253. screenForm: {
  254. // 筛选表单数据
  255. type: '',
  256. code: '',
  257. title: '',
  258. date: []
  259. },
  260. mainForm: {
  261. type: '',
  262. code: '',
  263. title: '',
  264. source: '',
  265. department: '',
  266. date: '',
  267. content: ''
  268. },
  269. mainFormRules: {
  270. type: [{ required: true, message: '请输入通知类型', trigger: 'blur' }],
  271. title: [{ required: true, message: '请输入文件标题', trigger: 'blur' }],
  272. date: [{ required: true, message: '请选择发布日期', trigger: 'change' }],
  273. content: [{ required: true, message: '请输入发布内容', trigger: 'blur' }]
  274. },
  275. mainFormDialog: false,
  276. fileList: [],
  277. isCollapse: true,
  278. departmentList: [],
  279. props: {
  280. multiple: true,
  281. value: 'adminWebsitId',
  282. label: 'name',
  283. children: 'children'
  284. },
  285. detailDialog: false, // 详情 - 弹窗
  286. detailData: {},
  287. multipleSelection: [],
  288. recordDialog: false, // 已阅记录 - 弹窗
  289. detailTable_dataList: null, // 已阅记录 - 列表数据
  290. detailTable_listLoading: true, // 已阅记录 - 列表加载loading
  291. detailTable_currentPage: 1, // 已阅记录 - 当前页码
  292. detailTable_pageSize: 10, // 已阅记录 - 每页数量
  293. detailTable_listTotal: 0 // 已阅记录 - 列表总数
  294. }
  295. },
  296. methods: {
  297. // 列表请求函数
  298. getList(...p) {
  299. this.recordSelected = []
  300. return getListV2(...p)
  301. },
  302. // 列表导出函数
  303. exportList: () => {},
  304. // 表格列解析渲染数据更改
  305. columnParsing(item, defaultData) {
  306. return defaultData
  307. },
  308. // 监听勾选变化
  309. selectionChange(data) {
  310. console.log(data);
  311. this.recordSelected = data
  312. },
  313. operation() {
  314. return (h, { row, index, column }) => {
  315. return (
  316. <div class="operation-btns">
  317. {this.checkBtnRole('edit') ? (
  318. <el-button
  319. size="mini"
  320. type="text"
  321. onClick={() => {
  322. this.openDetail(row.id)
  323. }}
  324. >
  325. 浏览
  326. </el-button>
  327. ) : null}
  328. <el-popconfirm
  329. title="确定删除吗?"
  330. onConfirm={() => this.deleteData(row.noticeId)}
  331. >
  332. <el-button slot="reference" type="text" size="mini">
  333. 删除
  334. </el-button>
  335. </el-popconfirm>
  336. </div>
  337. )
  338. }
  339. },
  340. handleClose() {
  341. this.addOff(() => {
  342. this.visible = false
  343. })()
  344. },
  345. // 查询按钮权限
  346. checkBtnRole(value) {
  347. return true
  348. let btnRole = this.$route.meta.roles
  349. if (!btnRole) {
  350. return true
  351. }
  352. let index = btnRole.indexOf(value)
  353. return index >= 0 ? true : false
  354. },
  355. // 获取部门列表
  356. getTree() {
  357. getDepartmentList().then(res => {
  358. this.departmentList = res.data
  359. })
  360. },
  361. // 批量删除
  362. batchDelete() {
  363. if (this.multipleSelection.length < 1) {
  364. return this.$errorMsg('请选择信息')
  365. }
  366. this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
  367. confirmButtonText: '确定',
  368. cancelButtonText: '取消',
  369. type: 'warning'
  370. })
  371. .then(() => {
  372. let ids = []
  373. this.multipleSelection.forEach(item => {
  374. ids.push(item.noticeId)
  375. })
  376. deleteData({ noticeIds: ids.join(',') }).then(res => {
  377. this.$successMsg('删除成功')
  378. this.$refs.pageRef.refreshList()
  379. })
  380. })
  381. .catch(() => {})
  382. },
  383. // 操作 - 删除
  384. deleteData(id) {
  385. deleteData({ noticeIds: id }).then(res => {
  386. this.$successMsg('删除成功')
  387. this.$refs.pageRef.refreshList()
  388. })
  389. },
  390. // 详情 - 打开弹窗
  391. openDetail(id) {
  392. getDetail({ id, isTopRead:true }).then(res => {
  393. this.detailData = res.data
  394. this.detailDialog = true
  395. })
  396. },
  397. // 检查文件类型
  398. checkFileType(url) {
  399. if (!url) return ''
  400. const fileSuffix = url.substring(url.lastIndexOf('.') + 1)
  401. if (['jpg', 'jpeg', 'png'].includes(fileSuffix)) {
  402. return 'image'
  403. } else if (['doc', 'docx', 'dot', 'wps', 'wpt'].includes(fileSuffix)) {
  404. return 'word'
  405. } else if (['xls', 'xlsx', 'xlt', 'et', 'ett'].includes(fileSuffix)) {
  406. return 'excel'
  407. } else if (['ppt', 'pptx', 'dps', 'dpt', 'pot', 'pps'].includes(fileSuffix)) {
  408. return 'ppt'
  409. } else if (['pdf'].includes(fileSuffix)) {
  410. return 'pdf'
  411. } else {
  412. return ''
  413. }
  414. },
  415. // 打开链接
  416. openLink(url) {
  417. getFileUrl({ key: url }).then(res => {
  418. window.open(res.data)
  419. })
  420. },
  421. // 确认查收
  422. confirmCheck(id) {
  423. confirmCheck({ noticeIds: id }).then(res => {
  424. this.$successMsg('查收成功')
  425. this.detailDialog = false
  426. this.$refs.pageRef.refreshList()
  427. })
  428. },
  429. // 已阅记录 - 获取列表
  430. getDownloadList() {
  431. getDownloadList({
  432. pageNo: this.detailTable_currentPage,
  433. pageSize: this.detailTable_pageSize,
  434. id: this.recordId
  435. }).then(res => {
  436. this.detailTable_dataList = res.data.records
  437. this.detailTable_listTotal = res.data.total
  438. this.detailTable_listLoading = false
  439. })
  440. },
  441. // 已阅记录 - 打开弹窗
  442. openRecord(id) {
  443. this.recordId = id
  444. this.recordDialog = true
  445. this.detailTable_currentPage = 1
  446. this.getDownloadList()
  447. },
  448. // 已阅记录 - 更改列表当前页
  449. detailTableCurrentChange(val) {
  450. this.detailTable_currentPage = val
  451. this.getDownloadList()
  452. },
  453. // 打开 表单
  454. openMainForm() {
  455. this.getTree()
  456. this.mainFormDialog = true
  457. },
  458. // 关闭 表单
  459. closeMainForm() {
  460. this.addOff(() => {
  461. this.mainFormDialog = false
  462. })()
  463. this.fileList = []
  464. this.$refs.mainForm.resetFields()
  465. },
  466. // 提交 表单
  467. async submitMainForm() {
  468. this.$refs.mainForm.validate(valid => {
  469. if (valid) {
  470. let params = {
  471. type: this.mainForm.type,
  472. code: this.mainForm.code,
  473. title: this.mainForm.title,
  474. source: this.mainForm.source,
  475. issueTime: this.mainForm.date,
  476. content: this.mainForm.content,
  477. adminWebsitIds: this.$refs.tree.getCheckedKeys(),
  478. files: this.fileList
  479. }
  480. addData(params).then(res => {
  481. this.closeMainForm()
  482. this.$refs.pageRef.refreshList()
  483. this.mainFormDialog = false
  484. })
  485. }
  486. })
  487. }
  488. }
  489. }
  490. </script>
  491. <style lang="scss" scoped>
  492. .detail-container {
  493. .title {
  494. font-size: 16px;
  495. color: #333333;
  496. font-weight: 600;
  497. }
  498. .text {
  499. font-size: 14px;
  500. color: #999999;
  501. margin-top: 10px;
  502. }
  503. .content {
  504. font-size: 14px;
  505. color: #666666;
  506. line-height: 20px;
  507. }
  508. .file {
  509. .file-list {
  510. display: flex;
  511. .item {
  512. margin-top: 10px;
  513. margin-right: 10px;
  514. }
  515. }
  516. .img {
  517. width: 80px;
  518. height: 80px;
  519. display: block;
  520. border: 1px solid #e4e7ed;
  521. }
  522. .box2 {
  523. flex: 1;
  524. display: flex;
  525. padding: 10px;
  526. align-items: center;
  527. border: 1px solid #e4e7ed;
  528. width: 240px;
  529. height: 80px;
  530. cursor: pointer;
  531. img {
  532. width: 40px;
  533. height: 40px;
  534. display: block;
  535. }
  536. .name {
  537. flex: 1;
  538. color: #222;
  539. font-weight: 600;
  540. margin-left: 10px;
  541. }
  542. }
  543. }
  544. }
  545. .el-divider--horizontal {
  546. margin: 16px 0;
  547. }
  548. </style>