交通管理局公文项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

260 lines
9.7 KiB

1 year ago
  1. <template>
  2. <div class="app-container row-container">
  3. <div class="head-container">
  4. <div class="head-search">
  5. <!-- 搜索 -->
  6. <el-input v-model="query.search" clearable size="small" placeholder="输入关键字搜索" prefix-icon="el-icon-search" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
  7. <date-range-picker v-model="blurryTime" class="date-item" />
  8. <rrOperation>
  9. <template v-slot:right>
  10. <el-button class="filter-item filter-refresh" size="mini" type="warning" icon="el-icon-refresh-left" @click="resetQuery()">重置</el-button>
  11. </template>
  12. </rrOperation>
  13. </div>
  14. <crudOperation>
  15. <template v-slot:left>
  16. <el-button size="mini" @click="crud.toAdd">
  17. <i class="iconfont icon-fabu" />
  18. 发布
  19. </el-button>
  20. </template>
  21. </crudOperation>
  22. </div>
  23. <div class="container-wrap">
  24. <span class="right-top-line" />
  25. <span class="left-bottom-line" />
  26. <!--表格渲染-->
  27. <el-table
  28. ref="table"
  29. v-loading="crud.loading"
  30. :data="crud.data"
  31. style="width: 100%;"
  32. @row-dblclick="handleDbClick"
  33. >
  34. <el-table-column type="index" label="序号" width="55" align="center" />
  35. <el-table-column prop="noticeType" label="消息类型" align="center" min-width="100">
  36. <template slot-scope="scope">
  37. <span v-if="scope.row.noticeType === 1">系统消息</span>
  38. </template>
  39. </el-table-column>
  40. <el-table-column prop="noticeTitle" :show-overflow-tooltip="true" label="标题" min-width="150" align="center" />
  41. <el-table-column prop="noticeContext" :show-overflow-tooltip="true" label="内容" align="center" min-width="200" />
  42. <el-table-column :show-overflow-tooltip="true" label="发送对象" align="center" min-width="200">
  43. <!-- <template slot-scope="scope">
  44. <div class="tag-hidden">
  45. <el-tag v-for="(item,i) in scope.row.noticeUsers" :key="i" style="margin-left:3px; ">{{ item.pushUserName }}</el-tag>
  46. </div>
  47. </template> -->
  48. <template slot-scope="scope">
  49. 用户{{ scope.row.noticeUsers && scope.row.noticeUsers !== null ? (scope.row.noticeUsers.includes(',') ? scope.row.noticeUsers.split(',').length : [scope.row.noticeUsers].length) : 0 }}
  50. 设备{{ scope.row.noticeDevices && scope.row.noticeDevices !== null ? scope.row.noticeDevices.split(',').length : 0 }}
  51. <!-- <div class="tag-hidden">
  52. <el-tag v-for="(item,i) in scope.row.noticeDevices" :key="i" style="margin-left:3px; color: #fff">{{ item }}</el-tag>
  53. </div> -->
  54. </template>
  55. </el-table-column>
  56. <el-table-column prop="createBy" label="创建人" align="center" min-width="100" />
  57. <el-table-column prop="createTime" label="创建时间" align="center" min-width="180">
  58. <template slot-scope="scope">
  59. <div>{{ scope.row.createTime | parseTime }}</div>
  60. </template>
  61. </el-table-column>
  62. </el-table>
  63. <!--分页组件-->
  64. <pagination />
  65. </div>
  66. <!-- 发布 -->
  67. <el-dialog append-to-body :close-on-click-modal="false" :modal-append-to-body="false" :before-close="crud.cancelCU" :visible="crud.status.cu > 0" title="发布通知">
  68. <span class="dialog-right-top" />
  69. <span class="dialog-left-bottom" />
  70. <div class="setting-dialog">
  71. <el-form ref="form" :rules="rules" :model="form" size="small" label-width="100px">
  72. <el-form-item label="消息类型" prop="noticeType" class="down-select">
  73. <el-input v-model="form.noticeTypeName" disabled />
  74. <!-- <el-select v-model="noticeType" placeholder="请选择">
  75. <el-option
  76. v-for="item in msgTypeOptions"
  77. :key="item.name"
  78. :label="item.label"
  79. :value="item.value"
  80. :disabled="item.disabled"
  81. />
  82. </el-select> -->
  83. </el-form-item>
  84. <el-form-item label="标题" prop="noticeTitle">
  85. <el-input v-model="form.noticeTitle" placeholder="请输入" style="width: 580px;" />
  86. </el-form-item>
  87. <el-form-item label="内容" prop="noticeContext">
  88. <el-input v-model="form.noticeContext" placeholder="请输入" type="textarea" rows="3" style="width: 580px;" />
  89. </el-form-item>
  90. <el-form-item label="发送对象" prop="userId">
  91. <div class="send-obj">
  92. <span v-if="pushObjItem.length === 0" style="color: rgb(206,209,216)">点击下方按钮选择对象</span>
  93. <el-tag
  94. v-for="tag in pushObjItem"
  95. v-else
  96. :key="tag.userId"
  97. v-model="form.userId"
  98. :disable-transitions="false"
  99. >
  100. {{ tag.username }}
  101. </el-tag>
  102. </div>
  103. </el-form-item>
  104. <span class="select-btn iconfont icon-shezhi" @click="openSelectObj" />
  105. </el-form>
  106. <div slot="footer" class="dialog-footer">
  107. <el-button type="text" @click="crud.cancelCU">取消</el-button>
  108. <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">保存</el-button>
  109. </div>
  110. </div>
  111. </el-dialog>
  112. <SelectObj ref="selectObj" @selectObjItem="handleSelectObjItem" />
  113. <Detail ref="archiveDetailDom" />
  114. </div>
  115. </template>
  116. <script>
  117. import crudNotify from '@/api/system/notify'
  118. import CRUD, { presenter, header, form, crud } from '@crud/crud'
  119. import crudOperation from '@crud/CRUD.operation'
  120. import rrOperation from '@crud/RR.operation'
  121. import DateRangePicker from '@/components/DateRangePicker'
  122. import pagination from '@crud/Pagination'
  123. import SelectObj from './module/selectObj'
  124. import Detail from './module/detail'
  125. const defaultForm = { id: null, noticeTypeName: '系统消息', noticeType: null, noticeTitle: null, noticeContext: null, userId: [], deviceInfoId: [] }
  126. export default {
  127. name: 'NotifyManage',
  128. components: { crudOperation, rrOperation, DateRangePicker, pagination, SelectObj, Detail },
  129. cruds() {
  130. return CRUD({ title: '通知', url: 'api/notice/initNotice', crudMethod: { ...crudNotify }, sort: [], optShow: {
  131. add: false,
  132. edit: false,
  133. del: false,
  134. download: false,
  135. group: false,
  136. reset: false
  137. }})
  138. },
  139. mixins: [presenter(), header(), form(defaultForm), crud()],
  140. data() {
  141. return {
  142. blurryTime: null,
  143. sendVisible: false,
  144. tableData: [],
  145. pushObjItem: [],
  146. msgTypeOptions: [
  147. { value: 1, label: '系统通知' }
  148. // { value: 2, label: '报警消息', disabled: true },
  149. // { value: 3, label: '借还消息', disabled: true },
  150. // { value: 4, label: '下载消息', disabled: true }
  151. ],
  152. rules: {
  153. noticeTitle: [
  154. { required: true, message: '标题不可为空', trigger: 'blur' }
  155. ],
  156. noticeContext: [
  157. { required: true, message: '内容不可为空', trigger: 'blur' }
  158. ],
  159. userId: [
  160. { required: true, message: '发送对象不可为空', trigger: 'blur' }
  161. ]
  162. }
  163. }
  164. },
  165. async created() {
  166. },
  167. methods: {
  168. [CRUD.HOOK.beforeRefresh]() {
  169. this.crud.query.noticeType = 1
  170. if (this.blurryTime) {
  171. this.crud.query.startTime = this.blurryTime[0]
  172. this.crud.query.endTime = this.blurryTime[1]
  173. } else {
  174. this.crud.query.startTime = null
  175. this.crud.query.endTime = null
  176. }
  177. },
  178. resetQuery() {
  179. this.crud.query.search = ''
  180. this.blurryTime = null
  181. this.crud.query.startTime = null
  182. this.crud.query.endTime = null
  183. this.crud.toQuery()
  184. },
  185. openSelectObj() {
  186. this.$refs.selectObj.sendObjVisible = true
  187. this.$refs.selectObj.getFondsDatas()
  188. },
  189. handleSelectObjItem(objType, selectItemAll) {
  190. this.pushObjItem = selectItemAll
  191. if (objType === 0) {
  192. this.form.userId = selectItemAll.map(item => item.userId)
  193. this.form.deviceInfoId = []
  194. } else {
  195. if (this.pushObjItem.length !== 0) {
  196. this.form.userId = selectItemAll.map(item => item.userId)
  197. } else {
  198. this.form.userId = []
  199. }
  200. }
  201. },
  202. // 提交前的验证
  203. [CRUD.HOOK.afterValidateCU](crud) {
  204. console.log(crud.form)
  205. crud.form.noticeType = 1
  206. delete crud.form.noticeTypeName
  207. return true
  208. },
  209. [CRUD.HOOK.afterAddCancel]() {
  210. this.pushObjItem = []
  211. this.$refs.selectObj.checkAll = false
  212. this.$refs.selectObj.selectedItems = []
  213. this.$refs.selectObj.selectObjForm = {
  214. sendObj: 0
  215. }
  216. },
  217. [CRUD.HOOK.afterSubmit]() {
  218. this.pushObjItem = []
  219. this.$refs.selectObj.checkAll = false
  220. this.$refs.selectObj.selectedItems = []
  221. this.$refs.selectObj.selectObjForm = {
  222. sendObj: 0
  223. }
  224. },
  225. handleDbClick(row) {
  226. this.$nextTick(() => {
  227. this.$refs.archiveDetailDom.detailVisible = true
  228. this.$refs.archiveDetailDom.rowData = row
  229. })
  230. }
  231. }
  232. }
  233. </script>
  234. <style lang="scss" scoped>
  235. .select-btn{
  236. display: inline-block;
  237. padding: 4px 11px 4px 14px;
  238. font-size: 18px;
  239. color: #fff;
  240. background: #0348F3;
  241. border-radius: 3px;
  242. margin: 10px 0 0 100px;
  243. text-align: center;
  244. cursor: pointer;
  245. }
  246. .send-obj{
  247. width: 580px;
  248. height: 180px;
  249. padding: 0 10px;
  250. border-radius: 3px 3px 3px 3px;
  251. border: 1px solid #E6E8ED;
  252. .el-tag{
  253. margin-right: 10px;
  254. }
  255. }
  256. </style>