index.vue 9.2 KB

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