notificationMangePage.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. <template>
  2. <div class="notification">
  3. <div class="notificationBtn">
  4. <div class="collectSeach">
  5. <div class="exceed">
  6. <span class="exceedSpan">通告标题:</span>
  7. <el-input v-model="noticeTitle" placeholder="请输入通告标题"></el-input>
  8. </div>
  9. <el-button type="primary" style="margin-left: 10px;" @click="getSeachData">搜索</el-button>
  10. <el-button style="margin-left: 10px;" @click="resetSeach">重置</el-button>
  11. </div>
  12. <div class="PeriodBtn">
  13. <btns
  14. :showImport="false"
  15. :showExport="false"
  16. :showSave="true"
  17. :showAdd="true"
  18. :showDelete="true"
  19. :disSave="changeDateSelect.length === 0 || changeDateSelect.length>1"
  20. :disDelete="changeDateSelect.length === 0"
  21. :disImport="false"
  22. :disExport="false"
  23. @handleAdd="handleAdd"
  24. @handleEdit="handleEdit"
  25. @handleDelete="handleDelete"
  26. ></btns>
  27. </div>
  28. <div class="notificationTableData">
  29. <el-table :data="notificationData" style="width: 100%" @select="rowClick" @select-all="rowClick">
  30. <el-table-column type="selection" label="操作" align="center"></el-table-column>
  31. <el-table-column label="序号" prop="serialNumber" align="center" width="80"></el-table-column>
  32. <el-table-column label="通告标题" width="300">
  33. <template #default="scope">
  34. <el-tooltip
  35. class="box-item"
  36. effect="customized"
  37. :content="scope.row.noticeTitle"
  38. placement="right"
  39. >
  40. <span class="tooltipCC">{{scope.row.noticeTitle}}</span>
  41. </el-tooltip>
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="通告内容" width="400">
  45. <template #default="scope">
  46. <el-tooltip
  47. class="box-item"
  48. effect="customized"
  49. :content="scope.row.noticeContent"
  50. placement="right"
  51. >
  52. <span class="tooltipCC">{{scope.row.noticeContent}}</span>
  53. </el-tooltip>
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="通告对象" prop="sendTo" />
  57. <el-table-column label="个别部门" prop="deptNames" />
  58. <el-table-column label="发布状态" prop="releaseState" />
  59. </el-table>
  60. <el-pagination
  61. @size-change="handleSizeChange"
  62. @current-change="handleCurrentChange"
  63. :current-page="page.currentPage"
  64. :page-size="page.pagesize"
  65. layout="total, prev, pager, next, jumper"
  66. :total="page.total">
  67. </el-pagination>
  68. </div>
  69. <el-dialog :title="title" custom-class="startToDia" v-model="dialogVisible" width="600px" :close-on-click-modal="false">
  70. <div class="periodFrom">
  71. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm" :validate-on-rule-change="false">
  72. <el-form-item label="通告标题" prop="noticeTitle">
  73. <el-input v-model="ruleForm.noticeTitle" placeholder="请输入通告标题" />
  74. </el-form-item>
  75. <el-form-item label="通告内容" prop="noticeContent">
  76. <el-input v-model="ruleForm.noticeContent"
  77. type="textarea" :rows="3" placeholder="请输入通告内容"></el-input>
  78. </el-form-item>
  79. <el-form-item label="通告对象" prop="sendTo">
  80. <el-select v-model="ruleForm.sendTo" placeholder="请选择通告对象">
  81. <el-option
  82. v-for="item in sendToData"
  83. :key="item.value"
  84. :label="item.label"
  85. :value="item.value">
  86. </el-option>
  87. </el-select>
  88. </el-form-item>
  89. <el-form-item label="个别部门" prop="sendToContent" v-if="ruleForm.sendTo === '个别部门'">
  90. <el-select v-model="ruleForm.sendToContent" multiple collapse-tags placeholder="请选择部门">
  91. <el-option
  92. v-for="item in departData"
  93. :key="item.id"
  94. :label="item.keyName"
  95. :value="item.id">
  96. </el-option>
  97. </el-select>
  98. </el-form-item>
  99. <el-form-item label="排序">
  100. <el-input-number v-model="ruleForm.serialNumber" :min="1" />
  101. </el-form-item>
  102. <el-form-item label="上传附件">
  103. <div>
  104. <el-upload
  105. :file-list="filesList"
  106. multiple
  107. limit="3"
  108. :auto-upload="false"
  109. :show-file-list="false"
  110. >
  111. <el-button type="primary">选择上传文件</el-button>
  112. <template #tip>
  113. <div class="el-upload__tip">
  114. 最多上传3个文件
  115. </div>
  116. </template>
  117. </el-upload>
  118. <div v-if="!isSave">
  119. <div v-for="it in filesList" :key="it.uid">
  120. <div>
  121. <span>{{it.name}}</span>
  122. <el-icon :size="20" color="#3B7AD1"
  123. @click="removeFile(it)"
  124. style="position: relative;top: 5px;left: 10px;cursor:pointer"><CircleClose /></el-icon>
  125. </div>
  126. </div>
  127. </div>
  128. <div v-else>
  129. <div v-for="it in filesList" :key="it.uid">
  130. <div>
  131. <span>{{it.name}}</span>
  132. <el-icon :size="20" color="#3B7AD1"
  133. @click="removeFile(it)"
  134. style="position: relative;top: 5px;left: 10px;cursor:pointer"><CircleClose /></el-icon>
  135. </div>
  136. </div>
  137. <div v-for="it in filesListEdit" :key="it">
  138. <div>
  139. <span>{{it}}</span>
  140. <el-icon :size="20" color="#3B7AD1"
  141. @click="removeFileFn(it)"
  142. style="position: relative;top: 5px;left: 10px;cursor:pointer"><CircleClose /></el-icon>
  143. </div>
  144. </div>
  145. </div>
  146. </div>
  147. </el-form-item>
  148. </el-form>
  149. </div>
  150. <template #footer>
  151. <span class="dialog-footer">
  152. <el-button type="warning" @click="saveevaluaStart('ruleForm', '草稿')">草 稿</el-button>
  153. <el-button type="primary" @click="saveevaluaStart('ruleForm', '发布')">发 布</el-button>
  154. <el-button @click="saveevaluaStart('ruleForm', '取消')">取 消</el-button>
  155. </span>
  156. </template>
  157. </el-dialog>
  158. </div>
  159. </div>
  160. </template>
  161. <script>
  162. import btns from '../elbuttonS.vue'
  163. import {apiGetevaluationdeptnoticeList, apiGetevaluationdeptnoticeSave,apievaluationdeptnoticeDelete,
  164. apiGetdatadictionaryList, apiPostevaluationdeptnoticeDelete} from '../../api/api'
  165. export default {
  166. components: {
  167. btns
  168. },
  169. data() {
  170. return {
  171. dialogVisible: false,
  172. isSave: false,
  173. title: '',
  174. evalradio: {},
  175. changeDateSelect: [],
  176. notificationData:[],
  177. departData: [],
  178. sendToData: [],
  179. page:{
  180. pagesize: 12,
  181. currentPage: 1,
  182. total: 0
  183. },
  184. ruleForm: {
  185. serialNumber: 1,
  186. noticeTitle: '',
  187. noticeContent: '',
  188. sendTo: '',
  189. sendToContent: [],
  190. releaseDept: '',
  191. releasePeople: '',
  192. },
  193. filesList: [],
  194. filesListEdit: [],
  195. rules: {
  196. noticeTitle: [
  197. { required: true, message: '请输入通告标题', trigger: 'blur' }
  198. ],
  199. noticeContent: [
  200. { required: true, message: '请输入通告内容', trigger: 'blur' }
  201. ],
  202. sendTo: [
  203. { required: true, message: '请选择通告对象', trigger: 'change' }
  204. ],
  205. sendToContent: [
  206. { required: true, message: '请选择个别部门', trigger: 'change' }
  207. ]
  208. },
  209. noticeTitle: '',
  210. headers: { "Content-Type": "multipart/form-data" },
  211. fileType: [ "pdf", "doc", "docx", "xls", "xlsx","txt","png","jpg", "bmp", "jpeg"]
  212. }
  213. },
  214. created() {
  215. this.sendToData = [
  216. {
  217. label: '所有单位',
  218. value: '所有单位'
  219. },
  220. {
  221. label: '本部部门',
  222. value: '本部部门'
  223. },
  224. {
  225. label: '个别部门',
  226. value: '个别部门'
  227. }
  228. ]
  229. this.getevalunotificationList()
  230. this.getDepartmentFromTreeData()
  231. },
  232. methods:{
  233. // 查询列表页面
  234. getevalunotificationList() {
  235. let that = this
  236. let params = {
  237. pageNum: that.page.currentPage,
  238. pageSize: that.page.pagesize,
  239. noticeTitle: that.noticeTitle
  240. }
  241. apiGetevaluationdeptnoticeList(params).then(datas =>{
  242. if (datas && datas.data) {
  243. that.notificationData = datas.data.records
  244. that.page.total = datas.data.total
  245. }
  246. })
  247. },
  248. // 查询部门
  249. getDepartmentFromTreeData() {
  250. let that = this
  251. let params = {
  252. superKey: 'BM0001'
  253. }
  254. apiGetdatadictionaryList(params).then(datas =>{
  255. if (datas && datas.data) {
  256. that.departData = datas.data
  257. }
  258. })
  259. },
  260. notificationFn() {
  261. if (this.notificationData.length>0) {
  262. notificationData.slice((page.currentPage-1)*page.pagesize, page.currentPage*page.pagesize)
  263. }
  264. },
  265. saveevaluaStart(formName, type) {
  266. let that = this
  267. that.$refs[formName].validate((valid) => {
  268. if (valid) {
  269. that.saveAndEditnotificationData(type)
  270. }
  271. });
  272. },
  273. //新增/修改考评启动数据
  274. saveAndEditnotificationData(type) {
  275. let that = this
  276. // let userMes = JSON.parse(window.sessionStorage.getItem('user'))
  277. let params = {
  278. serialNumber: that.ruleForm.serialNumber,
  279. noticeTitle: that.ruleForm.noticeTitle,
  280. noticeContent: that.ruleForm.noticeContent,
  281. sendTo: that.ruleForm.sendTo,
  282. sendToContent: that.ruleForm.sendToContent.join(','),
  283. releaseState: type === '草稿'? '草稿': type === '发布'?'已发布':'未发布',
  284. // releaseDept: userMes.deptId,
  285. // releasePeople: userMes.id
  286. }
  287. debugger
  288. const formData = new FormData()
  289. if (that.filesList.length>0) {
  290. that.filesList.forEach(item =>{
  291. formData.append('files', item.raw)
  292. })
  293. }
  294. if (that.isSave) {
  295. params.id = that.evalradio.id
  296. formData.append('deptNames', 'deptNames')
  297. }
  298. apiGetevaluationdeptnoticeSave(params, formData).then(datas =>{
  299. if (!datas.success) {
  300. that.$message({
  301. message: datas.message,
  302. type: 'error'
  303. });
  304. } else {
  305. if (!that.isSave) {
  306. that.$message({
  307. message: '通告新增成功',
  308. type: 'success'
  309. });
  310. } else {
  311. that.$message({
  312. message: '通告修改成功',
  313. type: 'success'
  314. });
  315. }
  316. that.dialogVisible = false
  317. that.changeDateSelect = []
  318. that.getevalunotificationList()
  319. }
  320. })
  321. },
  322. getSeachData() {
  323. this.page.currentPage = 1
  324. this.getevalunotificationList()
  325. },
  326. resetSeach() {
  327. this.page.currentPage = 1
  328. this.noticeTitle = ''
  329. this.getevalunotificationList()
  330. },
  331. handleSizeChange(val){
  332. this.page.pagesize = val
  333. this.getevalunotificationList()
  334. },
  335. handleCurrentChange(val){
  336. this.page.currentPage =val
  337. this.getevalunotificationList()
  338. },
  339. rowClick(selection, row) {
  340. this.changeDateSelect = selection
  341. },
  342. handleAdd() {
  343. this.dialogVisible = true
  344. this.isSave = false
  345. this.title = '新建通告'
  346. this.$nextTick(() =>{
  347. this.$refs['ruleForm'].resetFields()
  348. this.filesList = []
  349. this.ruleForm = {
  350. serialNumber: 1,
  351. noticeTitle: '',
  352. noticeContent: '',
  353. sendTo: '',
  354. sendToContent: [],
  355. releaseDept: '',
  356. releasePeople: ''
  357. }
  358. })
  359. },
  360. handleEdit() {
  361. this.dialogVisible = true
  362. this.isSave = true
  363. this.title = '修改通告'
  364. this.filesList = []
  365. this.filesListEdit = []
  366. this.evalradio = this.changeDateSelect[0]
  367. this.ruleForm = {
  368. serialNumber: this.evalradio.serialNumber,
  369. noticeTitle: this.evalradio.noticeTitle,
  370. noticeContent: this.evalradio.noticeContent,
  371. sendTo: this.evalradio.sendTo,
  372. sendToContent: this.evalradio.sendToContent.split(','),
  373. releaseDept: this.evalradio.releaseDept,
  374. releasePeople: this.evalradio.releasePeople
  375. }
  376. let filesArr = this.evalradio.noticeAnnex.split(',')
  377. filesArr.forEach(item =>{
  378. let str = item.substring(item.lastIndexOf('/')+1, item.length)
  379. this.filesListEdit.push(str)
  380. })
  381. },
  382. //删除
  383. handleDelete() {
  384. this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
  385. confirmButtonText: '确定',
  386. cancelButtonText: '取消',
  387. type: 'warning'
  388. }).then(() => {
  389. let that = this
  390. let paramsArr = []
  391. that.changeDateSelect.forEach(it =>{
  392. paramsArr.push(it.id)
  393. })
  394. apiPostevaluationdeptnoticeDelete(paramsArr.join(',')).then(datas =>{
  395. that.$message({
  396. type: 'success',
  397. message: '删除成功!'
  398. });
  399. that.getevalunotificationList()
  400. that.changeDateSelect = []
  401. })
  402. })
  403. },
  404. //上传文件之前验证文件类型和大小
  405. beforeUpload(file) {
  406. // this.ruleForm.files = []
  407. if (file.type != "" || file.type != null || file.type != undefined){
  408. //截取文件的后缀,判断文件类型
  409. const FileExt = file.name.replace(/.+\./, "").toLowerCase();
  410. //计算文件的大小
  411. const isLt5M = file.size / 1024 / 1024 < 5; //这里做文件大小限制
  412. //如果大于5M
  413. if (!isLt5M) {
  414. this.$message({
  415. message: '上传文件大小不能超过 5MB!',
  416. type: 'info'
  417. });
  418. return false;
  419. }
  420. //如果文件类型不在允许上传的范围内
  421. if(this.fileType.includes(FileExt)){
  422. return true;
  423. }
  424. else {
  425. this.$message.error("上传文件格式不正确!");
  426. return false;
  427. }
  428. }
  429. },
  430. //移除文件
  431. removeFile(item) {
  432. for (var i in this.filesList) {
  433. if (item.name == this.filesList[i].name) {
  434. this.filesList.splice(i, 1)
  435. }
  436. }
  437. },
  438. removeFileFn(item) {
  439. this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
  440. confirmButtonText: '确定',
  441. cancelButtonText: '取消',
  442. type: 'warning'
  443. }).then(() => {
  444. let that = this
  445. let params = {
  446. id: that.evalradio.id,
  447. noticeAnnex: item
  448. }
  449. apievaluationdeptnoticeDelete(params).then(datas =>{
  450. if (datas.success) {
  451. that.filesListEdit.forEach((it, index) =>{
  452. if (it === item) {
  453. that.filesListEdit.splice(index, 1)
  454. }
  455. })
  456. } else {
  457. this.$message({
  458. message: datas.message,
  459. type: 'error'
  460. });
  461. }
  462. })
  463. })
  464. }
  465. }
  466. }
  467. </script>
  468. <style lang="less">
  469. .notification{
  470. .notificationBtn{
  471. .collectSeach{
  472. display: flex;
  473. padding: 24px 20px;
  474. border-bottom: 1px solid#D6DBEA;
  475. .exceed{
  476. display: flex;
  477. .exceedSpan{
  478. width: 100px;
  479. height: 12px;
  480. font-size: 14px;
  481. font-family: Microsoft YaHei;
  482. font-weight: 400;
  483. color: #8991B0;
  484. line-height: 12px;
  485. margin-top: 14px;
  486. }
  487. .el-input{
  488. margin-right:10px;
  489. height: 40px;
  490. .el-input__inner{
  491. height:40px;
  492. }
  493. .el-input__suffix{
  494. .el-select__caret{
  495. line-height:30px;
  496. }
  497. }
  498. }
  499. }
  500. .el-select{
  501. margin-right:10px;
  502. .el-input__inner{
  503. height:30px;
  504. }
  505. .el-input__suffix{
  506. .el-select__caret{
  507. line-height:30px;
  508. }
  509. }
  510. }
  511. }
  512. span{
  513. font-size:14px;
  514. }
  515. .PeriodBtn{
  516. display: flex;
  517. justify-content: end;
  518. padding: 20px 0;
  519. }
  520. .el-button{
  521. height: 30px;
  522. // width:100px;
  523. padding: 0 20px ;
  524. // padding-top: 8px;
  525. span{
  526. margin:0;
  527. }
  528. }
  529. .notificationTableData{
  530. .el-table{
  531. .el-table__body-wrapper{
  532. height: 60vh !important;
  533. }
  534. .el-input__inner{
  535. height: 30px !important;
  536. }
  537. .el-radio__label{
  538. display: none;
  539. }
  540. .tooltipCC{
  541. width: 300px !important;
  542. display: inline-block;
  543. overflow: hidden;
  544. text-overflow: ellipsis;
  545. white-space: nowrap;
  546. }
  547. .tooltipCCDes{
  548. width: 50px;
  549. display: inline-block;
  550. overflow: hidden;
  551. text-overflow: ellipsis;
  552. white-space: nowrap;
  553. }
  554. .indicitem{
  555. color: #409EFF;
  556. font-size: 12px;
  557. margin-right: 20px;
  558. cursor:pointer;
  559. &:hover{
  560. text-decoration: underline;
  561. }
  562. }
  563. }
  564. .el-pagination{
  565. margin-top: 20px;
  566. text-align: end;
  567. position: relative;
  568. }
  569. }
  570. .el-overlay{
  571. .startToDia{
  572. .el-dialog__body{
  573. padding: 30px 60px 30px 20px !important;
  574. .periodFrom{
  575. .el-select, .el-input{
  576. width: 100%;
  577. }
  578. .el-input{
  579. height: 30px;
  580. }
  581. }
  582. .flowSty{
  583. width: 100%;
  584. height: 70vh;
  585. }
  586. }
  587. }
  588. }
  589. }
  590. }
  591. </style>