index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="90px">
  4. <el-form-item label="用户id" prop="userId">
  5. <el-input
  6. v-model="queryParams.userId"
  7. placeholder="请输入用户id"
  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 label="订单关联" prop="businessId">
  23. <el-input
  24. v-model="queryParams.businessId"
  25. placeholder="请输入订单关联"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="时间" prop="createTime">
  32. <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="change"></el-date-picker>
  33. </el-form-item>
  34. <el-form-item>
  35. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  36. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  37. </el-form-item>
  38. </el-form>
  39. <el-row :gutter="10" class="mb8">
  40. <el-col :span="1.5">
  41. <el-button
  42. type="warning"
  43. plain
  44. icon="el-icon-download"
  45. size="mini"
  46. :loading="exportLoading"
  47. @click="handleExport"
  48. v-hasPermi="['his:userIntegralLogs:export']"
  49. >导出</el-button>
  50. </el-col>
  51. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  52. </el-row>
  53. <el-table v-loading="loading" border :data="userIntegralLogsList" @selection-change="handleSelectionChange">
  54. <el-table-column label="用户id" align="center" prop="userId" />
  55. <el-table-column label="用户昵称" align="center" prop="nickName" />
  56. <el-table-column label="用户电话" align="center" prop="phone" />
  57. <el-table-column label="类别" align="center" prop="logType" >
  58. <template slot-scope="scope">
  59. <dict-tag :options="intefralLogTypeOptions" :value="scope.row.logType"/>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="积分" align="center" prop="integral" />
  63. <el-table-column label="积分余额" align="center" prop="balance" />
  64. <el-table-column label="订单关联id" align="center" prop="businessId" />
  65. <el-table-column label="时间" align="center" prop="createTime" />
  66. </el-table>
  67. <pagination
  68. v-show="total>0"
  69. :total="total"
  70. :page.sync="queryParams.pageNum"
  71. :limit.sync="queryParams.pageSize"
  72. @pagination="getList"
  73. />
  74. <!-- 添加或修改积分记录对话框 -->
  75. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  76. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  77. <el-form-item label="用户id" prop="userId">
  78. <el-input v-model="form.userId" placeholder="请输入用户id" />
  79. </el-form-item>
  80. <el-form-item label="1 签到获得积分 2购买商品获得积分 3购买积分商品 " prop="logType">
  81. <el-select v-model="form.logType" placeholder="请选择1 签到获得积分 2购买商品获得积分 3购买积分商品 ">
  82. <el-option label="请选择字典生成" value="" />
  83. </el-select>
  84. </el-form-item>
  85. <el-form-item label="积分 正数表示增加积分,负数表示减少积分" prop="integral">
  86. <el-input v-model="form.integral" placeholder="请输入积分 正数表示增加积分,负数表示减少积分" />
  87. </el-form-item>
  88. <el-form-item label="积分余额" prop="balance">
  89. <el-input v-model="form.balance" placeholder="请输入积分余额" />
  90. </el-form-item>
  91. <el-form-item label="订单关联id" prop="businessId">
  92. <el-input v-model="form.businessId" placeholder="请输入订单关联id" />
  93. </el-form-item>
  94. </el-form>
  95. <div slot="footer" class="dialog-footer">
  96. <el-button type="primary" @click="submitForm">确 定</el-button>
  97. <el-button @click="cancel">取 消</el-button>
  98. </div>
  99. </el-dialog>
  100. </div>
  101. </template>
  102. <script>
  103. import { listUserIntegralLogs, getUserIntegralLogs, delUserIntegralLogs, addUserIntegralLogs, updateUserIntegralLogs, exportUserIntegralLogs } from "@/api/his/userIntegralLogs";
  104. export default {
  105. name: "UserIntegralLogs",
  106. data() {
  107. return {
  108. // 遮罩层
  109. loading: true,
  110. // 导出遮罩层
  111. exportLoading: false,
  112. // 选中数组
  113. ids: [],
  114. // 非单个禁用
  115. single: true,
  116. // 非多个禁用
  117. multiple: true,
  118. // 显示搜索条件
  119. showSearch: true,
  120. intefralLogTypeOptions: [],
  121. // 总条数
  122. total: 0,
  123. // 积分记录表格数据
  124. userIntegralLogsList: [],
  125. // 弹出层标题
  126. title: "",
  127. // 是否显示弹出层
  128. open: false,
  129. createTime:null,
  130. // 查询参数
  131. queryParams: {
  132. pageNum: 1,
  133. pageSize: 10,
  134. userId: null,
  135. logtype: null,
  136. integral: null,
  137. balance: null,
  138. businessId: null,
  139. createTime: null,
  140. phone:null,
  141. sTime:null,
  142. eTime:null,
  143. },
  144. // 表单参数
  145. form: {},
  146. // 表单校验
  147. rules: {
  148. }
  149. };
  150. },
  151. created() {
  152. this.getList();
  153. this.getDicts("sys_integral_log_type").then(response => {
  154. this.intefralLogTypeOptions = this.mergeLogTypeOptions(response.data || []);
  155. });
  156. },
  157. methods: {
  158. /** 合并字典与本地兜底类型,确保所有已知 logType 都有对应名称 */
  159. mergeLogTypeOptions(dictOptions) {
  160. // 本地完整映射(与后端 FsUserIntegralLogTypeEnum 对齐),字典缺失时兜底
  161. const localMap = {
  162. 1: '签到获得积分', 2: '消费获得积分', 3: '分享获得积分', 4: '退款扣除积分',
  163. 5: '购买积分商品', 6: '平台取消售后', 7: '积分过期', 8: '螳螂同步积分',
  164. 9: '购买课程小节扣除', 10: '观看课程获取积分', 11: '新用户完善就诊人获得积分',
  165. 12: '新用户填写收货地址获取积分', 13: '浏览商品获得积分', 14: '浏览视频获得积分',
  166. 15: '首次下单疗法获得积分', 16: '点播看课获得积分', 17: '点播答题获得积分',
  167. 18: '邀请新用户获取积分', 19: '填写邀请码获取积分', 20: '首次完成手机号绑定注册',
  168. 21: '首次完成专家咨询', 22: '首次完成积分商城下单', 23: '管理员添加',
  169. 24: '付费课程订阅', 25: '下单使用积分抵扣', 26: '取消订单退回积分', 27: '退款订单退回积分'
  170. };
  171. // 字典已有项优先,收集已有 value
  172. const result = [...dictOptions];
  173. const existValues = new Set(dictOptions.map(o => Number(o.dictValue)));
  174. // 补充字典缺失的类型
  175. Object.keys(localMap).forEach(key => {
  176. const val = Number(key);
  177. if (!existValues.has(val)) {
  178. result.push({ dictValue: String(val), dictLabel: localMap[val] });
  179. }
  180. });
  181. return result;
  182. },
  183. /** 查询积分记录列表 */
  184. getList() {
  185. this.loading = true;
  186. listUserIntegralLogs(this.queryParams).then(response => {
  187. this.userIntegralLogsList = response.rows;
  188. this.total = response.total;
  189. this.loading = false;
  190. });
  191. },
  192. // 取消按钮
  193. cancel() {
  194. this.open = false;
  195. this.reset();
  196. },
  197. // 表单重置
  198. reset() {
  199. this.form = {
  200. id: null,
  201. userId: null,
  202. logType: null,
  203. integral: null,
  204. balance: null,
  205. businessId: null,
  206. createTime: null
  207. };
  208. this.resetForm("form");
  209. },
  210. /** 搜索按钮操作 */
  211. handleQuery() {
  212. this.queryParams.pageNum = 1;
  213. this.getList();
  214. },
  215. /** 重置按钮操作 */
  216. resetQuery() {
  217. this.resetForm("queryForm");
  218. this.createTime=null;
  219. this.queryParams.sTime=null;
  220. this.queryParams.eTime=null;
  221. this.handleQuery();
  222. },
  223. // 多选框选中数据
  224. handleSelectionChange(selection) {
  225. this.ids = selection.map(item => item.id)
  226. this.single = selection.length!==1
  227. this.multiple = !selection.length
  228. },
  229. /** 新增按钮操作 */
  230. handleAdd() {
  231. this.reset();
  232. this.open = true;
  233. this.title = "添加积分记录";
  234. },
  235. /** 修改按钮操作 */
  236. handleUpdate(row) {
  237. this.reset();
  238. const id = row.id || this.ids
  239. getUserIntegralLogs(id).then(response => {
  240. this.form = response.data;
  241. this.open = true;
  242. this.title = "修改积分记录";
  243. });
  244. },
  245. /** 提交按钮 */
  246. submitForm() {
  247. this.$refs["form"].validate(valid => {
  248. if (valid) {
  249. if (this.form.id != null) {
  250. updateUserIntegralLogs(this.form).then(response => {
  251. this.msgSuccess("修改成功");
  252. this.open = false;
  253. this.getList();
  254. });
  255. } else {
  256. addUserIntegralLogs(this.form).then(response => {
  257. this.msgSuccess("新增成功");
  258. this.open = false;
  259. this.getList();
  260. });
  261. }
  262. }
  263. });
  264. },
  265. change(){
  266. if(this.createTime!=null){
  267. this.queryParams.sTime=this.createTime[0];
  268. this.queryParams.eTime=this.createTime[1];
  269. }else{
  270. this.queryParams.sTime=null;
  271. this.queryParams.eTime=null;
  272. }
  273. },
  274. /** 删除按钮操作 */
  275. handleDelete(row) {
  276. const ids = row.id || this.ids;
  277. this.$confirm('是否确认删除积分记录编号为"' + ids + '"的数据项?', "警告", {
  278. confirmButtonText: "确定",
  279. cancelButtonText: "取消",
  280. type: "warning"
  281. }).then(function() {
  282. return delUserIntegralLogs(ids);
  283. }).then(() => {
  284. this.getList();
  285. this.msgSuccess("删除成功");
  286. }).catch(() => {});
  287. },
  288. /** 导出按钮操作 */
  289. handleExport() {
  290. const queryParams = this.queryParams;
  291. this.$confirm('是否确认导出所有积分记录数据项?', "警告", {
  292. confirmButtonText: "确定",
  293. cancelButtonText: "取消",
  294. type: "warning"
  295. }).then(() => {
  296. this.exportLoading = true;
  297. return exportUserIntegralLogs(queryParams);
  298. }).then(response => {
  299. this.download(response.msg);
  300. this.exportLoading = false;
  301. }).catch(() => {});
  302. }
  303. }
  304. };
  305. </script>