membershipLevel.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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>
  17. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  18. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  19. </el-form-item>
  20. </el-form>
  21. <el-row :gutter="10" class="mb8">
  22. <el-col :span="1.5">
  23. <el-button
  24. type="primary"
  25. plain
  26. icon="el-icon-plus"
  27. size="mini"
  28. @click="handleAdd"
  29. v-hasPermi="configPermi.add"
  30. >新增</el-button>
  31. </el-col>
  32. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
  33. </el-row>
  34. <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange">
  35. <el-table-column type="index" label="序号" align="center" />
  36. <el-table-column label="等级名称" align="center" key="name" prop="name" v-if="columns[0].visible">
  37. <template slot-scope="scope">
  38. <el-tooltip class="item" effect="dark" :content="scope.row.name" placement="top">
  39. <div style="width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
  40. <span style="width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">{{ scope.row.name }}</span>
  41. </div>
  42. </el-tooltip>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="积分值" align="center" key="upIntegral" prop="upIntegral" v-if="columns[1].visible" :show-overflow-tooltip="true" />
  46. <el-table-column label="等级图片" align="center" key="logo" v-if="columns[2].visible">
  47. <template slot-scope="scope">
  48. <el-image
  49. v-if="scope.row.logo"
  50. style="width: 100px; height: 100px"
  51. :src="scope.row.logo"
  52. :preview-src-list="[scope.row.logo]">
  53. </el-image>
  54. <span v-else>暂无图片</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="享受折扣" align="center" key="discount" prop="discount" v-if="columns[3].visible" />
  58. <el-table-column label="专属优惠卷" align="center" key="couponNames" prop="couponNames" v-if="columns[4].visible" />
  59. <el-table-column
  60. label="操作"
  61. align="center"
  62. width="160"
  63. class-name="small-padding fixed-width"
  64. >
  65. <template slot-scope="scope" v-if="scope.row.id !== 1">
  66. <el-button
  67. v-if="false"
  68. size="mini"
  69. type="text"
  70. icon="el-icon-document"
  71. @click="handleDetails(scope.row)"
  72. v-hasPermi="configPermi.details"
  73. >详情</el-button>
  74. <el-button
  75. size="mini"
  76. type="text"
  77. icon="el-icon-edit"
  78. @click="handleUpdate(scope.row)"
  79. v-hasPermi="configPermi.edit"
  80. >修改</el-button>
  81. <el-button
  82. size="mini"
  83. type="text"
  84. icon="el-icon-delete"
  85. @click="handleDelete(scope.row)"
  86. v-hasPermi="configPermi.delect"
  87. >删除</el-button>
  88. </template>
  89. </el-table-column>
  90. </el-table>
  91. <pagination
  92. v-show="total>0"
  93. :total="total"
  94. :page.sync="queryParams.pageNum"
  95. :limit.sync="queryParams.pageSize"
  96. @pagination="getList"
  97. />
  98. </el-col>
  99. </el-row>
  100. <!-- 新增或修改 -->
  101. <addAndEdit ref="addAndEdit" @refresh="getList" />
  102. </div>
  103. </template>
  104. <script>
  105. import {
  106. listTableApi,
  107. delTableParamsApi,
  108. } from "@/api/CURD";
  109. import addAndEdit from "./formBox/membershipLevelForm.vue"
  110. export default {
  111. name: "User",
  112. dicts: [],
  113. components: {addAndEdit},
  114. data() {
  115. return {
  116. title: "会员等级",// 通用标题
  117. configPermi: {
  118. add: ['system:user:edit'], // 新增权限
  119. details: ['system:user:details'], // 详情权限
  120. delect: ['system:user:remove'], // 删除权限
  121. edit: ['system:user:edit'], // 编辑权限
  122. upload: ['system:user:upload'],// 导入权限
  123. export: ['system:user:export'],// 导出权限
  124. },
  125. configUrl: {
  126. list: '/member/memberLevelInfo/pageList', // 列表地址
  127. delect: '/member/memberLevelInfo/deleteById', // 删除地址
  128. upload: '',// 导入地址
  129. download:'', // 下载模板地址
  130. export: '',// 导出地址
  131. },
  132. // 遮罩层
  133. loading: true,
  134. // 选中数组
  135. ids: [],
  136. // 非单个禁用
  137. single: true,
  138. // 非多个禁用
  139. multiple: true,
  140. // 显示搜索条件
  141. showSearch: true,
  142. // 总条数
  143. total: 0,
  144. // 用户表格数据
  145. tableList: null,
  146. // 查询参数
  147. queryParams: {
  148. pageNum: 1,
  149. pageSize: 10,
  150. },
  151. dateRange: [],
  152. // 控制列表是否显示
  153. columns: [
  154. { key: 0, label: `等级名称`, visible: true },
  155. // { key: 1, label: `归属景区`, visible: true },
  156. { key: 2, label: `开/闭园时间`, visible: true },
  157. { key: 3, label: `开放状态`, visible: true },
  158. { key: 4, label: `景点产品`, visible: true },
  159. ],
  160. };
  161. },
  162. created() {
  163. this.getList();
  164. },
  165. methods: {
  166. /** 查询用户列表 */
  167. getList() {
  168. this.loading = true;
  169. listTableApi(
  170. this.configUrl.list,
  171. this.addDateRange(
  172. this.queryParams,
  173. this.dateRange)).then(response => {
  174. this.tableList = response.data.rows;
  175. this.total = response.data.total;
  176. this.loading = false;
  177. }
  178. ).catch (error=>{
  179. console.error('获取列表失败!!!!',error)
  180. this.tableList = [];
  181. this.total = 0;
  182. this.loading = false
  183. })
  184. },
  185. /** 搜索按钮操作 */
  186. handleQuery() {
  187. this.queryParams.pageNum = 1;
  188. this.getList();
  189. },
  190. /** 重置按钮操作 */
  191. resetQuery() {
  192. this.dateRange = [];
  193. this.queryParams = {
  194. pageNum: 1,
  195. pageSize: 10,
  196. }
  197. this.handleQuery();
  198. },
  199. // 多选框选中数据
  200. handleSelectionChange(selection) {
  201. this.ids = selection.map(item => item.id);
  202. this.single = selection.length != 1;
  203. this.multiple = !selection.length;
  204. },
  205. /** 新增按钮操作 */
  206. handleAdd() {
  207. if(this.$refs.addAndEdit) {
  208. this.$refs.addAndEdit.initData(this.title + '新增', "ADD",{})
  209. }
  210. },
  211. /** 修改按钮操作 */
  212. handleUpdate(row) {
  213. if(this.$refs.addAndEdit) {
  214. this.$refs.addAndEdit.initData(this.title + '编辑', "EDITInit",{...row})
  215. }
  216. },
  217. handleDetails(row){
  218. if(this.$refs.detailsBox) {
  219. this.$refs.detailsBox.initData(this.title + '详情',"DEATILSInit", row)
  220. }
  221. },
  222. /** 删除按钮操作 */
  223. handleDelete(row) {
  224. const ids = row.id || this.ids;
  225. this.$modal.confirm('是否确认删除数据项?').then( () => {
  226. return delTableParamsApi(this.configUrl.delect,{
  227. id: ids
  228. });
  229. }).then(() => {
  230. this.getList();
  231. this.$modal.msgSuccess("删除成功");
  232. }).catch((e) => {
  233. console.error("删除失败====",e)
  234. });
  235. },
  236. /** 导出按钮操作 */
  237. handleExport() {
  238. this.download(this.configUrl.export, {
  239. ...this.queryParams
  240. }, `${this.title }_${new Date().getTime()}.xlsx`)
  241. },
  242. /** 导入按钮操作 */
  243. handleImport() {
  244. if(this.$refs.upload) {
  245. this.$refs.upload.initData({
  246. width: '400px',
  247. // 弹出层标题(用户导入)
  248. title: this.title + "导入",
  249. // 下载模板地址
  250. importTemplate: this.configUrl.download,
  251. // 上传的地址
  252. url: this.configUrl.upload
  253. })
  254. }
  255. },
  256. /** 开/闭 园 */
  257. openAttraction(row) {
  258. console.log("row======",row)
  259. this.$modal.confirm(`是否确认${row.status == 2 ? '关闭' : '打开'} ${row.name}园区吗?`).then( () => {
  260. return addTableApi(this.configUrl.edit,{
  261. ...row,
  262. status: row.status == 1 ? 2 : 1
  263. });
  264. }).then(() => {
  265. this.getList();
  266. this.$modal.msgSuccess(`${row.status == 1 ? '打开' : '关闭'}成功`);
  267. }).catch((e) => {
  268. console.error("失败====",e)
  269. });
  270. },
  271. }
  272. };
  273. </script>