carouselAdvertis.vue 11 KB

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