index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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="产品ID" prop="productId">
  5. <el-input
  6. v-model="queryParams.productId"
  7. placeholder="请输入产品ID"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="产品类型" prop="productType">
  14. <el-select v-model="queryParams.productType" placeholder="请选择产品类型" clearable size="small">
  15. <el-option label="请选择字典生成" value="" />
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="产品分类ID" prop="cateId">
  19. <el-input
  20. v-model="queryParams.cateId"
  21. placeholder="请输入产品分类ID"
  22. clearable
  23. size="small"
  24. @keyup.enter.native="handleQuery"
  25. />
  26. </el-form-item>
  27. <el-form-item label="产品类型" prop="type">
  28. <el-select v-model="queryParams.type" placeholder="请选择产品类型" clearable size="small">
  29. <el-option label="请选择字典生成" value="" />
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item label="用户ID" prop="userId">
  33. <el-input
  34. v-model="queryParams.userId"
  35. placeholder="请输入用户ID"
  36. clearable
  37. size="small"
  38. @keyup.enter.native="handleQuery"
  39. />
  40. </el-form-item>
  41. <el-form-item label="访问次数" prop="count">
  42. <el-input
  43. v-model="queryParams.count"
  44. placeholder="请输入访问次数"
  45. clearable
  46. size="small"
  47. @keyup.enter.native="handleQuery"
  48. />
  49. </el-form-item>
  50. <el-form-item label="添加时间" prop="addTime">
  51. <el-input
  52. v-model="queryParams.addTime"
  53. placeholder="请输入添加时间"
  54. clearable
  55. size="small"
  56. @keyup.enter.native="handleQuery"
  57. />
  58. </el-form-item>
  59. <el-form-item>
  60. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  61. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  62. </el-form-item>
  63. </el-form>
  64. <el-row :gutter="10" class="mb8">
  65. <el-col :span="1.5">
  66. <el-button
  67. type="primary"
  68. icon="el-icon-plus"
  69. size="mini"
  70. @click="handleAdd"
  71. v-hasPermi="['store:storeVisit:add']"
  72. >新增</el-button>
  73. </el-col>
  74. <el-col :span="1.5">
  75. <el-button
  76. type="success"
  77. icon="el-icon-edit"
  78. size="mini"
  79. :disabled="single"
  80. @click="handleUpdate"
  81. v-hasPermi="['store:storeVisit:edit']"
  82. >修改</el-button>
  83. </el-col>
  84. <el-col :span="1.5">
  85. <el-button
  86. type="danger"
  87. icon="el-icon-delete"
  88. size="mini"
  89. :disabled="multiple"
  90. @click="handleDelete"
  91. v-hasPermi="['store:storeVisit:remove']"
  92. >删除</el-button>
  93. </el-col>
  94. <el-col :span="1.5">
  95. <el-button
  96. type="warning"
  97. icon="el-icon-download"
  98. size="mini"
  99. @click="handleExport"
  100. v-hasPermi="['store:storeVisit:export']"
  101. >导出</el-button>
  102. </el-col>
  103. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  104. </el-row>
  105. <el-table v-loading="loading" :data="storeVisitList" @selection-change="handleSelectionChange">
  106. <el-table-column type="selection" width="55" align="center" />
  107. <el-table-column label="添加时间" align="center" prop="id" />
  108. <el-table-column label="产品ID" align="center" prop="productId" />
  109. <el-table-column label="产品类型" align="center" prop="productType" />
  110. <el-table-column label="产品分类ID" align="center" prop="cateId" />
  111. <el-table-column label="产品类型" align="center" prop="type" />
  112. <el-table-column label="用户ID" align="center" prop="userId" />
  113. <el-table-column label="访问次数" align="center" prop="count" />
  114. <el-table-column label="备注描述" align="center" prop="content" />
  115. <el-table-column label="添加时间" align="center" prop="addTime" />
  116. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  117. <template slot-scope="scope">
  118. <el-button
  119. size="mini"
  120. type="text"
  121. icon="el-icon-edit"
  122. @click="handleUpdate(scope.row)"
  123. v-hasPermi="['store:storeVisit:edit']"
  124. >修改</el-button>
  125. <el-button
  126. size="mini"
  127. type="text"
  128. icon="el-icon-delete"
  129. @click="handleDelete(scope.row)"
  130. v-hasPermi="['store:storeVisit:remove']"
  131. >删除</el-button>
  132. </template>
  133. </el-table-column>
  134. </el-table>
  135. <pagination
  136. v-show="total>0"
  137. :total="total"
  138. :page.sync="queryParams.pageNum"
  139. :limit.sync="queryParams.pageSize"
  140. @pagination="getList"
  141. />
  142. <!-- 添加或修改产品浏览分析对话框 -->
  143. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  144. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  145. <el-form-item label="产品ID" prop="productId">
  146. <el-input v-model="form.productId" placeholder="请输入产品ID" />
  147. </el-form-item>
  148. <el-form-item label="产品类型" prop="productType">
  149. <el-select v-model="form.productType" placeholder="请选择产品类型">
  150. <el-option label="请选择字典生成" value="" />
  151. </el-select>
  152. </el-form-item>
  153. <el-form-item label="产品分类ID" prop="cateId">
  154. <el-input v-model="form.cateId" placeholder="请输入产品分类ID" />
  155. </el-form-item>
  156. <el-form-item label="产品类型" prop="type">
  157. <el-select v-model="form.type" placeholder="请选择产品类型">
  158. <el-option label="请选择字典生成" value="" />
  159. </el-select>
  160. </el-form-item>
  161. <el-form-item label="用户ID" prop="userId">
  162. <el-input v-model="form.userId" placeholder="请输入用户ID" />
  163. </el-form-item>
  164. <el-form-item label="访问次数" prop="count">
  165. <el-input v-model="form.count" placeholder="请输入访问次数" />
  166. </el-form-item>
  167. <el-form-item label="备注描述">
  168. <editor v-model="form.content" :min-height="192"/>
  169. </el-form-item>
  170. <el-form-item label="添加时间" prop="addTime">
  171. <el-input v-model="form.addTime" placeholder="请输入添加时间" />
  172. </el-form-item>
  173. </el-form>
  174. <div slot="footer" class="dialog-footer">
  175. <el-button type="primary" @click="submitForm">确 定</el-button>
  176. <el-button @click="cancel">取 消</el-button>
  177. </div>
  178. </el-dialog>
  179. </div>
  180. </template>
  181. <script>
  182. import { listStoreVisit, getStoreVisit, delStoreVisit, addStoreVisit, updateStoreVisit, exportStoreVisit } from "@/api/store/storeVisit";
  183. import Editor from '@/components/Editor';
  184. export default {
  185. name: "StoreVisit",
  186. components: { Editor },
  187. data() {
  188. return {
  189. // 遮罩层
  190. loading: true,
  191. // 选中数组
  192. ids: [],
  193. // 非单个禁用
  194. single: true,
  195. // 非多个禁用
  196. multiple: true,
  197. // 显示搜索条件
  198. showSearch: true,
  199. // 总条数
  200. total: 0,
  201. // 产品浏览分析表格数据
  202. storeVisitList: [],
  203. // 弹出层标题
  204. title: "",
  205. // 是否显示弹出层
  206. open: false,
  207. // 查询参数
  208. queryParams: {
  209. pageNum: 1,
  210. pageSize: 10,
  211. productId: null,
  212. productType: null,
  213. cateId: null,
  214. type: null,
  215. userId: null,
  216. count: null,
  217. content: null,
  218. addTime: null
  219. },
  220. // 表单参数
  221. form: {},
  222. // 表单校验
  223. rules: {
  224. }
  225. };
  226. },
  227. created() {
  228. this.getList();
  229. },
  230. methods: {
  231. /** 查询产品浏览分析列表 */
  232. getList() {
  233. this.loading = true;
  234. listStoreVisit(this.queryParams).then(response => {
  235. this.storeVisitList = response.rows;
  236. this.total = response.total;
  237. this.loading = false;
  238. });
  239. },
  240. // 取消按钮
  241. cancel() {
  242. this.open = false;
  243. this.reset();
  244. },
  245. // 表单重置
  246. reset() {
  247. this.form = {
  248. id: null,
  249. productId: null,
  250. productType: null,
  251. cateId: null,
  252. type: null,
  253. userId: null,
  254. count: null,
  255. content: null,
  256. addTime: null
  257. };
  258. this.resetForm("form");
  259. },
  260. /** 搜索按钮操作 */
  261. handleQuery() {
  262. this.queryParams.pageNum = 1;
  263. this.getList();
  264. },
  265. /** 重置按钮操作 */
  266. resetQuery() {
  267. this.resetForm("queryForm");
  268. this.handleQuery();
  269. },
  270. // 多选框选中数据
  271. handleSelectionChange(selection) {
  272. this.ids = selection.map(item => item.id)
  273. this.single = selection.length!==1
  274. this.multiple = !selection.length
  275. },
  276. /** 新增按钮操作 */
  277. handleAdd() {
  278. this.reset();
  279. this.open = true;
  280. this.title = "添加产品浏览分析";
  281. },
  282. /** 修改按钮操作 */
  283. handleUpdate(row) {
  284. this.reset();
  285. const id = row.id || this.ids
  286. getStoreVisit(id).then(response => {
  287. this.form = response.data;
  288. this.open = true;
  289. this.title = "修改产品浏览分析";
  290. });
  291. },
  292. /** 提交按钮 */
  293. submitForm() {
  294. this.$refs["form"].validate(valid => {
  295. if (valid) {
  296. if (this.form.id != null) {
  297. updateStoreVisit(this.form).then(response => {
  298. if (response.code === 200) {
  299. this.msgSuccess("修改成功");
  300. this.open = false;
  301. this.getList();
  302. }
  303. });
  304. } else {
  305. addStoreVisit(this.form).then(response => {
  306. if (response.code === 200) {
  307. this.msgSuccess("新增成功");
  308. this.open = false;
  309. this.getList();
  310. }
  311. });
  312. }
  313. }
  314. });
  315. },
  316. /** 删除按钮操作 */
  317. handleDelete(row) {
  318. const ids = row.id || this.ids;
  319. this.$confirm('是否确认删除产品浏览分析编号为"' + ids + '"的数据项?', "警告", {
  320. confirmButtonText: "确定",
  321. cancelButtonText: "取消",
  322. type: "warning"
  323. }).then(function() {
  324. return delStoreVisit(ids);
  325. }).then(() => {
  326. this.getList();
  327. this.msgSuccess("删除成功");
  328. }).catch(function() {});
  329. },
  330. /** 导出按钮操作 */
  331. handleExport() {
  332. const queryParams = this.queryParams;
  333. this.$confirm('是否确认导出所有产品浏览分析数据项?', "警告", {
  334. confirmButtonText: "确定",
  335. cancelButtonText: "取消",
  336. type: "warning"
  337. }).then(function() {
  338. return exportStoreVisit(queryParams);
  339. }).then(response => {
  340. this.download(response.msg);
  341. }).catch(function() {});
  342. }
  343. }
  344. };
  345. </script>