eventNotifications.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <!--用户数据-->
  5. <el-col :span="24" :xs="24">
  6. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  7. <el-form-item label="公告标题" prop="noticeTitle">
  8. <el-input
  9. v-model="queryParams.noticeTitle"
  10. placeholder="请输入公告标题"
  11. clearable
  12. style="width: 240px"
  13. @keyup.enter.native="handleQuery"
  14. />
  15. </el-form-item>
  16. <el-form-item label="操作人员" prop="createBy">
  17. <el-input
  18. v-model="queryParams.createBy"
  19. placeholder="请输入操作人员"
  20. clearable
  21. style="width: 240px"
  22. @keyup.enter.native="handleQuery"
  23. />
  24. </el-form-item>
  25. <el-form-item label="公告类型" prop="noticeType">
  26. <el-select v-model="queryParams.noticeType" placeholder="请选择公告类型">
  27. <el-option
  28. v-for="dict in dict.type.tourism_notice_type"
  29. :key="dict.value"
  30. :label="dict.label"
  31. :value="dict.value">
  32. </el-option>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item>
  36. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  37. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  38. </el-form-item>
  39. </el-form>
  40. <el-row :gutter="10" class="mb8">
  41. <el-col :span="1.5">
  42. <el-button
  43. type="primary"
  44. plain
  45. icon="el-icon-plus"
  46. size="mini"
  47. @click="handleAdd"
  48. v-hasPermi="configPermi.add"
  49. >新增</el-button>
  50. </el-col>
  51. <el-col :span="1.5">
  52. <el-button
  53. type="danger"
  54. plain
  55. icon="el-icon-delete"
  56. size="mini"
  57. :disabled="multiple"
  58. @click="handleDelete"
  59. v-hasPermi="configPermi.delect"
  60. >删除</el-button>
  61. </el-col>
  62. <el-col :span="1.5" v-if="false">
  63. <el-button
  64. type="info"
  65. plain
  66. icon="el-icon-upload2"
  67. size="mini"
  68. @click="handleImport"
  69. v-hasPermi="configPermi.upload"
  70. >导入</el-button>
  71. </el-col>
  72. <el-col :span="1.5" v-if="false">
  73. <el-button
  74. type="warning"
  75. plain
  76. icon="el-icon-download"
  77. size="mini"
  78. @click="handleExport"
  79. v-hasPermi="configPermi.export"
  80. >导出</el-button>
  81. </el-col>
  82. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
  83. </el-row>
  84. <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange">
  85. <el-table-column type="selection" width="50" align="center" />
  86. <el-table-column type="index" label="序号" align="center" />
  87. <el-table-column label="公告标题" align="center" key="noticeTitle" prop="noticeTitle" v-if="columns[0].visible">
  88. <template slot-scope="scope">
  89. <el-tooltip class="item" effect="dark" :content="scope.row.noticeTitle" placement="top">
  90. <div style="width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
  91. <span style="width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">{{ scope.row.noticeTitle }}</span>
  92. </div>
  93. </el-tooltip>
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="公告类型" align="center" key="noticeType" prop="noticeType" v-if="columns[1].visible" :show-overflow-tooltip="true">
  97. <template slot-scope="scope">
  98. <dict-tag :options="dict.type.tourism_notice_type" :value="scope.row.noticeType"/>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="状态" align="center" key="status" v-if="columns[2].visible">
  102. <template slot-scope="scope">
  103. <dict-tag :options="dict.type.tourism_notice_status" :value="scope.row.status"/>
  104. </template>
  105. </el-table-column>
  106. <el-table-column label="创建者" align="center" key="createBy" prop="createBy" v-if="columns[3].visible" />
  107. <el-table-column label="创建时间" align="center" key="createTime" prop="createTime" v-if="columns[4].visible" />
  108. <el-table-column
  109. label="操作"
  110. align="center"
  111. width="160"
  112. class-name="small-padding fixed-width"
  113. >
  114. <template slot-scope="scope" v-if="scope.row.id !== 1">
  115. <el-button
  116. v-if="false"
  117. size="mini"
  118. type="text"
  119. icon="el-icon-document"
  120. @click="handleDetails(scope.row)"
  121. v-hasPermi="configPermi.details"
  122. >详情</el-button>
  123. <el-button
  124. size="mini"
  125. type="text"
  126. icon="el-icon-edit"
  127. @click="handleUpdate(scope.row)"
  128. v-hasPermi="configPermi.edit"
  129. >修改</el-button>
  130. <el-button
  131. size="mini"
  132. type="text"
  133. icon="el-icon-delete"
  134. @click="handleDelete(scope.row)"
  135. v-hasPermi="configPermi.delect"
  136. >删除</el-button>
  137. </template>
  138. </el-table-column>
  139. </el-table>
  140. <pagination
  141. v-show="total>0"
  142. :total="total"
  143. :page.sync="queryParams.pageNum"
  144. :limit.sync="queryParams.pageSize"
  145. @pagination="getList"
  146. />
  147. </el-col>
  148. </el-row>
  149. <!-- 新增或修改 -->
  150. <addAndEdit ref="addAndEdit" @refresh="getList" />
  151. </div>
  152. </template>
  153. <script>
  154. import {
  155. listTableApi,
  156. delTableApi,
  157. } from "@/api/CURD";
  158. import addAndEdit from "./formBox/eventNotificationsForm.vue"
  159. export default {
  160. name: "User",
  161. dicts: ['tourism_notice_type','tourism_notice_status'],
  162. components: {addAndEdit},
  163. data() {
  164. return {
  165. title: "活动通知",// 通用标题
  166. configPermi: {
  167. add: ['system:user:edit'], // 新增权限
  168. details: ['system:user:details'], // 详情权限
  169. delect: ['system:user:remove'], // 删除权限
  170. edit: ['system:user:edit'], // 编辑权限
  171. upload: ['system:user:upload'],// 导入权限
  172. export: ['system:user:export'],// 导出权限
  173. },
  174. configUrl: {
  175. list: '/merchant/notice/pageList', // 列表地址
  176. delect: '/merchant/notice/', // 删除地址
  177. upload: '',// 导入地址
  178. download:'', // 下载模板地址
  179. export: '',// 导出地址
  180. },
  181. // 遮罩层
  182. loading: true,
  183. // 选中数组
  184. ids: [],
  185. // 非单个禁用
  186. single: true,
  187. // 非多个禁用
  188. multiple: true,
  189. // 显示搜索条件
  190. showSearch: true,
  191. // 总条数
  192. total: 0,
  193. // 用户表格数据
  194. tableList: null,
  195. // 查询参数
  196. queryParams: {
  197. pageNum: 1,
  198. pageSize: 10,
  199. },
  200. dateRange: [],
  201. // 控制列表是否显示
  202. columns: [
  203. { key: 0, label: `公告标题`, visible: true },
  204. // { key: 1, label: `归属景区`, visible: true },
  205. { key: 2, label: `公告类型`, visible: true },
  206. { key: 3, label: `状态`, visible: true },
  207. { key: 4, label: `创建者`, visible: true },
  208. { key: 5, label: `创建时间`, visible: true },
  209. ],
  210. };
  211. },
  212. created() {
  213. this.getList();
  214. },
  215. methods: {
  216. /** 查询用户列表 */
  217. getList() {
  218. this.loading = true;
  219. listTableApi(
  220. this.configUrl.list,
  221. this.addDateRange(
  222. this.queryParams,
  223. this.dateRange)).then(response => {
  224. this.tableList = response.data.rows;
  225. this.total = response.data.total;
  226. this.loading = false;
  227. }
  228. ).catch (error=>{
  229. console.error('获取列表失败!!!!',error)
  230. this.tableList = [];
  231. this.total = 0;
  232. this.loading = false
  233. })
  234. },
  235. /** 搜索按钮操作 */
  236. handleQuery() {
  237. this.queryParams.pageNum = 1;
  238. this.getList();
  239. },
  240. /** 重置按钮操作 */
  241. resetQuery() {
  242. this.dateRange = [];
  243. this.queryParams = {
  244. pageNum: 1,
  245. pageSize: 10,
  246. }
  247. this.handleQuery();
  248. },
  249. // 多选框选中数据
  250. handleSelectionChange(selection) {
  251. this.ids = selection.map(item => item.id);
  252. this.single = selection.length != 1;
  253. this.multiple = !selection.length;
  254. },
  255. /** 新增按钮操作 */
  256. handleAdd() {
  257. if(this.$refs.addAndEdit) {
  258. this.$refs.addAndEdit.initData(this.title + '新增', "ADD",{})
  259. }
  260. },
  261. /** 修改按钮操作 */
  262. handleUpdate(row) {
  263. if(this.$refs.addAndEdit) {
  264. this.$refs.addAndEdit.initData(this.title + '编辑', "EDITInit",{...row})
  265. }
  266. },
  267. handleDetails(row){
  268. if(this.$refs.detailsBox) {
  269. this.$refs.detailsBox.initData(this.title + '详情',"DEATILSInit", row)
  270. }
  271. },
  272. /** 删除按钮操作 */
  273. handleDelete(row) {
  274. const ids = row.id || this.ids;
  275. this.$modal.confirm('是否确认删除数据项?').then( () => {
  276. return delTableApi(this.configUrl.delect,ids);
  277. }).then(() => {
  278. this.getList();
  279. this.$modal.msgSuccess("删除成功");
  280. }).catch((e) => {
  281. console.error("删除失败====",e)
  282. });
  283. },
  284. /** 导出按钮操作 */
  285. handleExport() {
  286. this.download(this.configUrl.export, {
  287. ...this.queryParams
  288. }, `${this.title }_${new Date().getTime()}.xlsx`)
  289. },
  290. /** 导入按钮操作 */
  291. handleImport() {
  292. if(this.$refs.upload) {
  293. this.$refs.upload.initData({
  294. width: '400px',
  295. // 弹出层标题(用户导入)
  296. title: this.title + "导入",
  297. // 下载模板地址
  298. importTemplate: this.configUrl.download,
  299. // 上传的地址
  300. url: this.configUrl.upload
  301. })
  302. }
  303. },
  304. }
  305. };
  306. </script>