announcement_function.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <div class="body-wrapper">
  3. <div>
  4. <h2 style="color: #3498db;margin-bottom: 20px;display: inline-block;width: 90%">公告信息</h2>
  5. <el-button type="primary" @click="handleAdd">发布公告</el-button>
  6. </div>
  7. <el-table :data="tableData" style="background: #2a2a2a;border-color: #333;">
  8. <el-table-column v-for="(item, index) in columns" :key="index" :label="item.label" :prop="item.key">
  9. </el-table-column>
  10. </el-table>
  11. <div class="table-pagination">
  12. <el-pagination :background="false" layout="total, prev, pager, next" :total="total" @current-change="handlePageChange"
  13. :current-page.sync="pageNum" :page-size.sync="pageSize">
  14. </el-pagination>
  15. </div>
  16. <el-dialog
  17. :title="title"
  18. :visible.sync="dialogVisible"
  19. width="50%"
  20. custom-class="audit-dialog">
  21. <div style="height: 100px" class="form-div">
  22. <el-form label-position="left" label-width="80px" :model="formLabelAlign">
  23. <el-form-item label="发布标题">
  24. <el-input v-model="formLabelAlign.publicTitle"></el-input>
  25. </el-form-item>
  26. <el-form-item label="发布人">
  27. <el-input v-model="formLabelAlign.publicPerson"></el-input>
  28. </el-form-item>
  29. </el-form>
  30. </div>
  31. <span slot="footer" class="dialog-footer">
  32. <el-button @click="dialogVisible = false">取 消</el-button>
  33. <el-button type="primary" @click="handleConfirm">确 定</el-button>
  34. </span>
  35. </el-dialog>
  36. </div>
  37. </template>
  38. <script>
  39. import api from "@/api/audit.js";
  40. export default {
  41. components: {},
  42. data() {
  43. return {
  44. columns: [
  45. {
  46. label: '发布标题',
  47. key: 'publicTitle'
  48. },
  49. {
  50. label: '发布时间',
  51. key: 'publicTime'
  52. },
  53. {
  54. label: '发布人',
  55. key: 'publicPerson'
  56. }
  57. ],
  58. tableData: [{"publicTitle":'预警提示',"publicTime":'2023-12-29 10:00:00',"publicPerson":'李玉'},
  59. {"publicTitle":'停车时限',"publicTime":'2023-12-31 11:00:00',"publicPerson":'张玮'},
  60. {"publicTitle":'设备故障',"publicTime":'2023-12-30 10:00:00',"publicPerson":'李玉'},],
  61. total: 3,
  62. pageSize: 10,
  63. pageNum: 1,
  64. radio: '2',
  65. dialogVisible: false,
  66. selRow: {},
  67. searchWords: undefined,
  68. formLabelAlign: {
  69. publicTitle: '',
  70. // publicTime: '',
  71. publicPerson: ''
  72. },
  73. title: ''
  74. }
  75. },
  76. mounted() {
  77. this.getTableData()
  78. },
  79. watch: {
  80. },
  81. methods: {
  82. handlePageChange() {
  83. this.getTableData()
  84. },
  85. handleAudit(row) {
  86. this.selRow = row
  87. this.dialogVisible = true
  88. },
  89. handleCancelApply(row) {
  90. console.log('enter handle cancel apply')
  91. },
  92. handleAdd () {
  93. this.title = '发布公告'
  94. this.formLabelAlign.publicTitle = ''
  95. // this.formLabelAlign.publicTime = ''
  96. this.formLabelAlign.publicPerson = ''
  97. this.dialogVisible = true
  98. },
  99. handleConfirm() {
  100. const {id} = this.selRow
  101. console.log('radio', this.radio)
  102. api.applyResource({id, applyType: this.formLabelAlign.publicTitle}).then(res => {
  103. if(res.success) {
  104. this.dialogVisible = false
  105. this.$message({
  106. message: '审核成功!',
  107. type: 'success'
  108. })
  109. this.getTableData()
  110. }
  111. })
  112. },
  113. getTableData() {
  114. const {pageNum, pageSize, searchWords} = this
  115. api.applyList({pageNum, pageSize, resourceName: searchWords}).then(res => {
  116. this.tableData = []
  117. res.data.records.map((item, index) => {
  118. const newItem = {...item}
  119. newItem.applyTypeText = this.getApplyTypeText(item.applyType)
  120. this.tableData.push(newItem)
  121. })
  122. this.total = res.data.total
  123. })
  124. },
  125. getApplyTypeText(val) {
  126. if (!val){
  127. return '未申请'
  128. }
  129. const textMap = {
  130. 1: '待审批',
  131. 2: '审批通过',
  132. 3: '审批驳回'
  133. }
  134. return textMap[val]
  135. },
  136. handleSearch() {
  137. this.pageNum = 1
  138. this.getTableData()
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="scss" scoped>
  144. .form-wrapper {
  145. margin-bottom: 20px;
  146. }
  147. /deep/ .el-input__inner {
  148. background: #2d3744;
  149. border: none;
  150. border-radius: 0;
  151. }
  152. /deep/ .el-select {
  153. height: 40px;
  154. .el-input__inner {
  155. height: 40px;
  156. }
  157. .el-input__prefix, .el-input__suffix {
  158. height: 40px;
  159. }
  160. /* 下面设置右侧按钮居中 */
  161. .el-input__suffix {
  162. top: 0px;
  163. display: flex;
  164. justify-content: center;
  165. align-items: center;
  166. flex-wrap: nowrap;
  167. flex-direction: row;
  168. align-content: flex-start;
  169. }
  170. /* 输入框加上上下边是 32px + 2px =34px */
  171. .el-input__icon {
  172. line-height: 0px;
  173. }
  174. }
  175. .body-wrapper {
  176. padding: 20px;
  177. background: #0c0c0c;
  178. .table-pagination{
  179. text-align: right;
  180. }
  181. }
  182. .audit-dialog{
  183. .mg-bt{
  184. margin-bottom: 24px;
  185. }
  186. .label{
  187. text-align: right;
  188. }
  189. .form-div{
  190. /deep/ .el-input__inner{
  191. background: white;
  192. height: 35px;
  193. width: 90%;
  194. border: 1px solid #a6a5a5;
  195. color: black;
  196. }
  197. }
  198. }
  199. </style>