index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item prop="title">
  5. <el-input v-model="queryParams.title" placeholder="请输入标题" clearable @keyup.enter.native="handleQuery" />
  6. </el-form-item>
  7. <el-form-item prop="clickType">
  8. <el-select v-model="queryParams.clickType" placeholder="请选择跳转类型" clearable>
  9. <el-option v-for="dict in dict.type.app_notify_click_type" :key="dict.value" :label="dict.label" :value="dict.value" />
  10. </el-select>
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  14. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  15. </el-form-item>
  16. </el-form>
  17. <el-row :gutter="10" class="mb8">
  18. <el-col :span="1.5">
  19. <el-button type="primary" plain icon="el-icon-plus" @click="handleAdd" v-hasPermi="['app:notify:add']">新增</el-button>
  20. </el-col>
  21. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  22. </el-row>
  23. <Page uri="/mapi/app/notify/list" :request-params="queryParams" ref="pagination">
  24. <el-table-column label="序号" align="center" prop="id" width="80" />
  25. <el-table-column label="标题" align="center" prop="title" :show-overflow-tooltip="true" />
  26. <el-table-column label="通知描述" align="center" prop="content" :show-overflow-tooltip="true" />
  27. <el-table-column label="跳转类型" align="center" prop="clickType" width="100">
  28. <template slot-scope="scope">
  29. <dict-tag :options="dict.type.app_notify_click_type" :value="scope.row.clickType" />
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="创建人" align="center" prop="createBy" />
  33. <el-table-column label="创建时间" align="center" prop="createTime" />
  34. <el-table-column label="修改人" align="center" prop="updateBy" />
  35. <el-table-column label="修改时间" align="center" prop="createTime" />
  36. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
  37. <template slot-scope="scope">
  38. <el-button type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">明细</el-button>
  39. <!-- <el-button-->
  40. <!-- -->
  41. <!-- type="text"-->
  42. <!-- icon="el-icon-delete"-->
  43. <!-- @click="handleDelete(scope.row)"-->
  44. <!-- v-hasPermi="['app:notify:remove']"-->
  45. <!-- >删除</el-button>-->
  46. </template>
  47. </el-table-column>
  48. </Page>
  49. <!-- 添加或修改消息通知对话框 -->
  50. <el-dialog :title="title" :visible.sync="open" size="30%" append-to-body>
  51. <el-row :gutter="15">
  52. <el-form ref="form" :model="form" :rules="rules" label-width="100px" :disabled="form.id > 0">
  53. <el-col :span="24">
  54. <el-form-item label="标题" prop="title">
  55. <el-input v-model="form.title" placeholder="请输入标题" maxlength="50" />
  56. </el-form-item>
  57. <el-form-item label="通知描述" prop="content">
  58. <el-input v-model="form.content" type="textarea" placeholder="请输入通知描述" maxlength="200" show-word-limit />
  59. </el-form-item>
  60. <el-form-item label="跳转类型" prop="clickType">
  61. <el-select v-model="form.clickType" placeholder="请选择跳转类型">
  62. <el-option v-for="dict in dict.type.app_notify_click_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
  63. </el-select>
  64. </el-form-item>
  65. <el-form-item label="跳转页面" v-if="form.clickType == '1'">
  66. <el-select v-model="form.redirectContent">
  67. <el-option v-for="dict in dict.type.app_notify_redirect_page" :key="dict.value" :label="dict.label" :value="dict.value" />
  68. </el-select>
  69. </el-form-item>
  70. <el-form-item label="跳转内容" v-if="form.clickType == '2'">
  71. <editor v-model="form.redirectContent" :min-height="300" />
  72. </el-form-item>
  73. <el-form-item label="跳转网址" v-if="form.clickType == '3'">
  74. <el-input v-model="form.redirectContent" maxlength="200" placeholder="请输入网址">
  75. <template slot="prepend">https://</template>
  76. </el-input>
  77. </el-form-item>
  78. </el-col>
  79. </el-form>
  80. </el-row>
  81. <div slot="footer" class="dialog-footer" v-if="!form.id">
  82. <el-button type="primary" @click="submitForm" style="margin-left: 5%">提交</el-button>
  83. <el-button @click="cancel">取 消</el-button>
  84. </div>
  85. </el-dialog>
  86. </div>
  87. </template>
  88. <script>
  89. import { listNotify, getNotify, addNotify } from '@/api/app/notify'
  90. export default {
  91. name: 'Notify',
  92. dicts: ['app_notify_type', 'app_notify_click_type', 'app_notify_redirect_page'],
  93. data() {
  94. return {
  95. // 遮罩层
  96. loading: true,
  97. // 选中数组
  98. ids: [],
  99. // 非单个禁用
  100. single: true,
  101. // 非多个禁用
  102. multiple: true,
  103. // 显示搜索条件
  104. showSearch: true,
  105. // 总条数
  106. total: 0,
  107. // 消息通知表格数据
  108. notifyList: [],
  109. // 弹出层标题
  110. title: '',
  111. // 是否显示弹出层
  112. open: false,
  113. // 查询参数
  114. queryParams: {
  115. title: null,
  116. clickType: null
  117. },
  118. // 表单参数
  119. form: {
  120. clickType: '0'
  121. },
  122. // 表单校验
  123. rules: {
  124. title: [{ required: true, message: '标题不能为空', trigger: 'blur' }],
  125. content: [{ required: true, message: '通知描述不能为空', trigger: 'blur' }],
  126. clickType: [{ required: true, message: '跳转类型不能为空', trigger: 'change' }]
  127. }
  128. }
  129. },
  130. created() {
  131. this.getList()
  132. },
  133. methods: {
  134. /** 查询消息通知列表 */
  135. getList() {
  136. this.$nextTick(() => {
  137. this.$refs.pagination.handleSearch(true)
  138. })
  139. },
  140. // 取消按钮
  141. cancel() {
  142. this.open = false
  143. this.reset()
  144. },
  145. // 表单重置
  146. reset() {
  147. this.form = {
  148. id: null,
  149. title: null,
  150. content: null,
  151. clickType: '0',
  152. redirectContent: null,
  153. isAll: 'Y',
  154. notifyType: null
  155. }
  156. this.resetForm('form')
  157. },
  158. /** 搜索按钮操作 */
  159. handleQuery() {
  160. this.getList()
  161. },
  162. /** 重置按钮操作 */
  163. resetQuery() {
  164. this.resetForm('queryForm')
  165. this.handleQuery()
  166. },
  167. // 多选框选中数据
  168. handleSelectionChange(selection) {
  169. this.ids = selection.map((item) => item.id)
  170. this.single = selection.length !== 1
  171. this.multiple = !selection.length
  172. },
  173. /** 新增按钮操作 */
  174. handleAdd() {
  175. this.reset()
  176. this.open = true
  177. this.title = '添加消息通知'
  178. },
  179. /** 修改按钮操作 */
  180. handleUpdate(row) {
  181. this.reset()
  182. const id = row.id || this.ids
  183. getNotify(id).then((response) => {
  184. this.form = response.data
  185. this.open = true
  186. this.title = '消息通知明细'
  187. })
  188. },
  189. /** 提交按钮 */
  190. submitForm() {
  191. this.$refs['form'].validate((valid) => {
  192. if (valid) {
  193. this.$confirm('确定提交吗,提交后消息会以通知形式推送到用户?')
  194. .then(function () {
  195. if (this.form.id != null) {
  196. updateNotify(this.form).then((response) => {
  197. this.$modal.msgSuccess('修改成功')
  198. this.open = false
  199. this.getList()
  200. })
  201. } else {
  202. addNotify(this.form).then((response) => {
  203. this.$modal.msgSuccess('新增成功')
  204. this.open = false
  205. this.getList()
  206. })
  207. }
  208. })
  209. .then(() => {})
  210. .catch(() => {})
  211. }
  212. })
  213. },
  214. // /** 删除按钮操作 */
  215. // handleDelete(row) {
  216. // const ids = row.id || this.ids;
  217. // this.$modal.confirm('是否确认删除消息通知编号为"' + ids + '"的数据项?').then(function() {
  218. // return delNotify(ids);
  219. // }).then(() => {
  220. // this.getList();
  221. // this.$modal.msgSuccess("删除成功");
  222. // }).catch(() => {});
  223. // },
  224. /** 导出按钮操作 */
  225. handleExport() {
  226. this.download(
  227. 'app/notify/export',
  228. {
  229. ...this.queryParams
  230. },
  231. `notify_${new Date().getTime()}.xlsx`
  232. )
  233. },
  234. checkClose(done) {
  235. this.$confirm('是否关闭表单,关闭后数据将丢失?')
  236. .then(function () {
  237. done()
  238. })
  239. .then(() => {})
  240. .catch(() => {})
  241. }
  242. }
  243. }
  244. </script>
  245. <style>
  246. textarea {
  247. min-height: 200px;
  248. }
  249. </style>