noticeManagement.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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="type">
  8. <el-select style="width: 350px;" v-model="queryParams.type" placeholder="请选择协议类型">
  9. <el-option
  10. v-for="dict in dict.type.tourism_noticemanagement_type"
  11. :key="dict.value"
  12. :label="dict.label"
  13. :value="dict.value">
  14. </el-option>
  15. </el-select>
  16. </el-form-item>
  17. <el-form-item label="添加时间" prop="time">
  18. <el-date-picker
  19. v-model="queryParams.time"
  20. type="datetimerange"
  21. range-separator="至"
  22. start-placeholder="开始日期"
  23. value-format="yyyy-MM-dd HH:mm:ss"
  24. end-placeholder="结束日期">
  25. </el-date-picker>
  26. </el-form-item>
  27. <el-form-item>
  28. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  29. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  30. </el-form-item>
  31. </el-form>
  32. <el-row :gutter="10" class="mb8">
  33. <el-col :span="1.5">
  34. <el-button
  35. type="primary"
  36. plain
  37. icon="el-icon-plus"
  38. size="mini"
  39. @click="handleAdd"
  40. v-hasPermi="configPermi.add"
  41. >新增</el-button>
  42. </el-col>
  43. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
  44. </el-row>
  45. <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange">
  46. <el-table-column type="index" label="序号" align="center" />
  47. <el-table-column label="协议类型" align="center" key="type" prop="type" v-if="columns[0].visible" :show-overflow-tooltip="true">
  48. <template slot-scope="scope">
  49. <dict-tag :options="dict.type.tourism_noticemanagement_type" :value="scope.row.type"/>
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="协议内容" align="center" key="content" prop="content" v-if="columns[1].visible" :show-overflow-tooltip="true">
  53. <template slot-scope="scope">
  54. <span @click="handleDetails(scope.row)" style="color: rgb(22, 132, 252);cursor: pointer;">查看</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="添加日期" align="center" key="createTime" prop="createTime" v-if="columns[2].visible" />
  58. <el-table-column
  59. label="操作"
  60. align="center"
  61. width="160"
  62. class-name="small-padding fixed-width"
  63. >
  64. <template slot-scope="scope" v-if="scope.row.id !== 1">
  65. <el-button
  66. size="mini"
  67. type="text"
  68. icon="el-icon-edit"
  69. @click="handleUpdate(scope.row)"
  70. v-hasPermi="configPermi.edit"
  71. >修改</el-button>
  72. <el-button
  73. size="mini"
  74. type="text"
  75. icon="el-icon-delete"
  76. @click="handleDelete(scope.row)"
  77. v-hasPermi="configPermi.delect"
  78. >删除</el-button>
  79. </template>
  80. </el-table-column>
  81. </el-table>
  82. <pagination
  83. v-show="total>0"
  84. :total="total"
  85. :page.sync="queryParams.pageNum"
  86. :limit.sync="queryParams.pageSize"
  87. @pagination="getList"
  88. />
  89. </el-col>
  90. </el-row>
  91. <!-- 详情 -->
  92. <detailsBox ref="detailsBox" />
  93. <!-- 新增或修改 -->
  94. <addAndEdit ref="addAndEdit" @refresh="getList" />
  95. </div>
  96. </template>
  97. <script>
  98. import {
  99. listTableApi,
  100. delTableParamsApi,
  101. } from "@/api/CURD";
  102. import addAndEdit from "./formBox/noticeManagementForm.vue"
  103. import detailsBox from "./detailsBox/noticeManagementDetails.vue"
  104. export default {
  105. name: "User",
  106. dicts: ['tourism_noticemanagement_type'],
  107. components: {addAndEdit,detailsBox},
  108. data() {
  109. return {
  110. title: "须知管理",// 通用标题
  111. configPermi: {
  112. add: ['system:user:edit'], // 新增权限
  113. details: ['system:user:details'], // 详情权限
  114. delect: ['system:user:remove'], // 删除权限
  115. edit: ['system:user:edit'], // 编辑权限
  116. upload: ['system:user:upload'],// 导入权限
  117. export: ['system:user:export'],// 导出权限
  118. },
  119. configUrl: {
  120. list: '/merchant/agreementInfo/pageList', // 列表地址
  121. delect: '/merchant/agreementInfo/deleteById', // 删除地址
  122. upload: '',// 导入地址
  123. download:'', // 下载模板地址
  124. export: '',// 导出地址
  125. },
  126. // 遮罩层
  127. loading: true,
  128. // 选中数组
  129. ids: [],
  130. // 非单个禁用
  131. single: true,
  132. // 非多个禁用
  133. multiple: true,
  134. // 显示搜索条件
  135. showSearch: true,
  136. // 总条数
  137. total: 0,
  138. // 用户表格数据
  139. tableList: null,
  140. // 查询参数
  141. queryParams: {
  142. pageNum: 1,
  143. pageSize: 10,
  144. },
  145. dateRange: [],
  146. // 控制列表是否显示
  147. columns: [
  148. { key: 0, label: `协议类型`, visible: true },
  149. { key: 2, label: `协议内容`, visible: true },
  150. { key: 3, label: `添加时间`, visible: true },
  151. ],
  152. };
  153. },
  154. created() {
  155. this.getList();
  156. },
  157. methods: {
  158. /** 查询用户列表 */
  159. getList() {
  160. this.loading = true;
  161. let params = JSON.parse(JSON.stringify({
  162. ...this.queryParams,
  163. startTime: this.queryParams.time&&this.queryParams.time[0]?this.queryParams.time[0]:null,
  164. endTime: this.queryParams.time&&this.queryParams.time[1]?this.queryParams.time[1]:null,
  165. }))
  166. delete params.time;
  167. listTableApi(
  168. this.configUrl.list,
  169. this.addDateRange(
  170. params,
  171. this.dateRange)).then(response => {
  172. this.tableList = response.data.rows;
  173. this.total = response.data.total;
  174. this.loading = false;
  175. }
  176. ).catch (error=>{
  177. console.error('获取列表失败!!!!',error)
  178. this.tableList = [];
  179. this.total = 0;
  180. this.loading = false
  181. })
  182. },
  183. /** 搜索按钮操作 */
  184. handleQuery() {
  185. this.queryParams.pageNum = 1;
  186. this.getList();
  187. },
  188. /** 重置按钮操作 */
  189. resetQuery() {
  190. this.dateRange = [];
  191. this.queryParams = {
  192. pageNum: 1,
  193. pageSize: 10,
  194. }
  195. this.handleQuery();
  196. },
  197. // 多选框选中数据
  198. handleSelectionChange(selection) {
  199. this.ids = selection.map(item => item.id);
  200. this.single = selection.length != 1;
  201. this.multiple = !selection.length;
  202. },
  203. /** 新增按钮操作 */
  204. handleAdd() {
  205. if(this.$refs.addAndEdit) {
  206. this.$refs.addAndEdit.initData(this.title + '新增', "ADD",{})
  207. }
  208. },
  209. /** 修改按钮操作 */
  210. handleUpdate(row) {
  211. if(this.$refs.addAndEdit) {
  212. this.$refs.addAndEdit.initData(this.title + '编辑', "EDITInit",{...row})
  213. }
  214. },
  215. handleDetails(row){
  216. if(this.$refs.detailsBox) {
  217. this.$refs.detailsBox.initData(this.title + '详情',"EDITInit", {...row})
  218. }
  219. },
  220. /** 删除按钮操作 */
  221. handleDelete(row) {
  222. const ids = row.id || this.ids;
  223. this.$modal.confirm('是否确认删除数据项?').then( () => {
  224. return delTableParamsApi(this.configUrl.delect,{
  225. id: ids
  226. });
  227. }).then(() => {
  228. this.getList();
  229. this.$modal.msgSuccess("删除成功");
  230. }).catch((e) => {
  231. console.error("删除失败====",e)
  232. });
  233. },
  234. /** 导出按钮操作 */
  235. handleExport() {
  236. this.download(this.configUrl.export, {
  237. ...this.queryParams
  238. }, `${this.title }_${new Date().getTime()}.xlsx`)
  239. },
  240. /** 导入按钮操作 */
  241. handleImport() {
  242. if(this.$refs.upload) {
  243. this.$refs.upload.initData({
  244. width: '400px',
  245. // 弹出层标题(用户导入)
  246. title: this.title + "导入",
  247. // 下载模板地址
  248. importTemplate: this.configUrl.download,
  249. // 上传的地址
  250. url: this.configUrl.upload
  251. })
  252. }
  253. },
  254. }
  255. };
  256. </script>