猫妈狗爸伴宠师小程序后端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

269 lines
7.8 KiB

3 months ago
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px" size="medium" class="ry_form">
  4. <el-form-item label="游客昵称为未登录" prop="name">
  5. <el-input
  6. v-model="queryParams.name"
  7. placeholder="请输入游客昵称为未登录"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item class="flex_one tr">
  14. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  15. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  16. </el-form-item>
  17. </el-form>
  18. <el-row :gutter="10" class="mb8">
  19. <el-col :span="1.5">
  20. <el-button
  21. type="primary"
  22. plain
  23. icon="el-icon-plus"
  24. size="mini"
  25. @click="handleAdd"
  26. v-hasPermi="['model:AppTourist:add']"
  27. >新增</el-button>
  28. </el-col>
  29. <el-col :span="1.5">
  30. <el-button
  31. type="success"
  32. plain
  33. icon="el-icon-edit"
  34. size="mini"
  35. :disabled="single"
  36. @click="handleUpdate"
  37. v-hasPermi="['model:AppTourist:edit']"
  38. >修改</el-button>
  39. </el-col>
  40. <el-col :span="1.5">
  41. <el-button
  42. type="danger"
  43. plain
  44. icon="el-icon-delete"
  45. size="mini"
  46. :disabled="multiple"
  47. @click="handleDelete"
  48. v-hasPermi="['model:AppTourist:remove']"
  49. >删除</el-button>
  50. </el-col>
  51. <el-col :span="1.5">
  52. <el-button
  53. type="warning"
  54. plain
  55. icon="el-icon-download"
  56. size="mini"
  57. :loading="exportLoading"
  58. @click="handleExport"
  59. v-hasPermi="['model:AppTourist:export']"
  60. >导出</el-button>
  61. </el-col>
  62. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
  63. </el-row>
  64. <el-table v-loading="loading" :data="AppTouristList" @selection-change="handleSelectionChange">
  65. <el-table-column type="selection" width="55" align="center" />
  66. <el-table-column label="${comment}" align="center" prop="id" />
  67. <el-table-column label="游客昵称为未登录" align="center" prop="name" v-if="columns[0].visible"/>
  68. <el-table-column label="默认小程序logo" align="center" prop="icon" v-if="columns[1].visible"/>
  69. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  70. <template slot-scope="scope">
  71. <el-button
  72. size="mini"
  73. type="text"
  74. icon="el-icon-edit"
  75. @click="handleUpdate(scope.row)"
  76. v-hasPermi="['model:AppTourist:edit']"
  77. >修改</el-button>
  78. <el-button
  79. size="mini"
  80. type="text"
  81. icon="el-icon-delete"
  82. @click="handleDelete(scope.row)"
  83. v-hasPermi="['model:AppTourist:remove']"
  84. >删除</el-button>
  85. </template>
  86. </el-table-column>
  87. </el-table>
  88. <pagination
  89. v-show="total>0"
  90. :total="total"
  91. :page.sync="queryParams.pageNum"
  92. :limit.sync="queryParams.pageSize"
  93. @pagination="getList"
  94. />
  95. <!-- 添加或修改游客对话框 -->
  96. <el-dialog :title="title" :visible.sync="open" width="50%" append-to-body>
  97. <el-form ref="form" :model="form" :rules="rules" label-width="108px" inline class="dialog-form-two">
  98. <el-form-item label="游客昵称为未登录" prop="name">
  99. <el-input v-model="form.name" placeholder="请输入游客昵称为未登录" />
  100. </el-form-item>
  101. <el-form-item label="默认小程序logo">
  102. <imageUpload v-model="form.icon"/>
  103. </el-form-item>
  104. </el-form>
  105. <div slot="footer" class="dialog-footer">
  106. <el-button type="primary" @click="submitForm"> </el-button>
  107. <el-button @click="cancel"> </el-button>
  108. </div>
  109. </el-dialog>
  110. </div>
  111. </template>
  112. <script>
  113. import { listAppTourist, getAppTourist, delAppTourist, addAppTourist, updateAppTourist, exportAppTourist } from "@/api/model/AppTourist";
  114. export default {
  115. name: "AppTourist",
  116. data() {
  117. return {
  118. // 遮罩层
  119. loading: true,
  120. // 导出遮罩层
  121. exportLoading: false,
  122. // 选中数组
  123. ids: [],
  124. // 非单个禁用
  125. single: true,
  126. // 非多个禁用
  127. multiple: true,
  128. // 显示搜索条件
  129. showSearch: true,
  130. // 总条数
  131. total: 0,
  132. // 游客表格数据
  133. AppTouristList: [],
  134. // 弹出层标题
  135. title: "",
  136. // 是否显示弹出层
  137. open: false,
  138. // 查询参数
  139. queryParams: {
  140. pageNum: 1,
  141. pageSize: 10,
  142. name: null,
  143. icon: null,
  144. },
  145. // 表单参数
  146. form: {},
  147. // 表单校验
  148. rules: {
  149. },
  150. columns: [
  151. { key: 1, label: "游客昵称为未登录", visible: true },
  152. { key: 2, label: "默认小程序logo", visible: false },
  153. ],
  154. };
  155. },
  156. created() {
  157. this.getList();
  158. },
  159. methods: {
  160. /** 查询游客列表 */
  161. getList() {
  162. this.loading = true;
  163. listAppTourist(this.queryParams).then(response => {
  164. this.AppTouristList = response.rows;
  165. this.total = response.total;
  166. this.loading = false;
  167. });
  168. },
  169. // 取消按钮
  170. cancel() {
  171. this.open = false;
  172. this.reset();
  173. },
  174. // 表单重置
  175. reset() {
  176. this.form = {
  177. id: null,
  178. name: null,
  179. icon: null,
  180. };
  181. this.resetForm("form");
  182. },
  183. /** 搜索按钮操作 */
  184. handleQuery() {
  185. this.queryParams.pageNum = 1;
  186. this.getList();
  187. },
  188. /** 重置按钮操作 */
  189. resetQuery() {
  190. this.resetForm("queryForm");
  191. this.handleQuery();
  192. },
  193. // 多选框选中数据
  194. handleSelectionChange(selection) {
  195. this.ids = selection.map(item => item.id)
  196. this.single = selection.length!==1
  197. this.multiple = !selection.length
  198. },
  199. /** 新增按钮操作 */
  200. handleAdd() {
  201. this.reset();
  202. this.open = true;
  203. this.title = "添加游客";
  204. },
  205. /** 修改按钮操作 */
  206. handleUpdate(row) {
  207. this.reset();
  208. const id = row.id || this.ids
  209. getAppTourist(id).then(response => {
  210. this.form = response.data;
  211. this.open = true;
  212. this.title = "修改游客";
  213. });
  214. },
  215. /** 提交按钮 */
  216. submitForm() {
  217. this.$refs["form"].validate(valid => {
  218. if (valid) {
  219. if (this.form.id != null) {
  220. updateAppTourist(this.form).then(response => {
  221. this.$modal.msgSuccess("修改成功");
  222. this.open = false;
  223. this.getList();
  224. });
  225. } else {
  226. addAppTourist(this.form).then(response => {
  227. this.$modal.msgSuccess("新增成功");
  228. this.open = false;
  229. this.getList();
  230. });
  231. }
  232. }
  233. });
  234. },
  235. /** 删除按钮操作 */
  236. handleDelete(row) {
  237. const ids = row.id || this.ids;
  238. this.$modal.confirm('是否确认删除游客编号为"' + ids + '"的数据项?').then(function() {
  239. return delAppTourist(ids);
  240. }).then(() => {
  241. this.getList();
  242. this.$modal.msgSuccess("删除成功");
  243. }).catch(() => {});
  244. },
  245. /** 导出按钮操作 */
  246. handleExport() {
  247. const queryParams = this.queryParams;
  248. this.$modal.confirm('是否确认导出所有游客数据项?').then(() => {
  249. this.exportLoading = true;
  250. return exportAppTourist(queryParams);
  251. }).then(response => {
  252. this.download(response.msg);
  253. this.exportLoading = false;
  254. }).catch(() => {});
  255. }
  256. }
  257. };
  258. </script>