index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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="mobilePhone">
  5. <el-input
  6. v-model="queryParams.mobilePhone"
  7. placeholder="请输入用户手机号码"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item>
  14. <el-button type="cyan" 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-button type="warning" icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
  17. </el-form-item>
  18. </el-form>
  19. <el-table v-loading="loading" :data="pointsList" @selection-change="handleSelectionChange">
  20. <el-table-column type="selection" width="55" align="center" />
  21. <el-table-column label="id" align="center" prop="id" v-if ="false" />
  22. <el-table-column label="微信用户unionID" align="center" prop="unionId" v-if="false"/>
  23. <el-table-column label="公众号的openID" align="center" prop="blogOpenid" v-if="false"/>
  24. <el-table-column label="小程序的openID" align="center" prop="minaOpenid" v-if="false" />
  25. <el-table-column label="手机号码" align="center" prop="mobilePhone" />
  26. <el-table-column label="账户积分余额" align="center" prop="points" />
  27. <el-table-column label="使用积分累计" align="center" prop="consumptionPoints" />
  28. <el-table-column label="获得积分累计" align="center" prop="accumulatePoints" />
  29. <el-table-column label="失效积分累计" align="center" prop="invalidPoints" />
  30. <el-table-column label="最近积分消费日期" align="center" prop="recentConsumptionDate" width="180">
  31. <template slot-scope="scope">
  32. <span>{{ parseTime(scope.row.recentConsumptionDate, '{y}-{m}-{d}') }}</span>
  33. </template>
  34. </el-table-column>
  35. <el-table-column label="油站ID" align="center" prop="stationId" v-if="false"/>
  36. <el-table-column label="油站名称" align="center" prop="stationName" v-if="false" />
  37. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  38. <template slot-scope="scope">
  39. <el-button
  40. size="mini"
  41. type="text"
  42. icon="el-icon-edit"
  43. @click="lookInfo(scope.row)"
  44. >明细</el-button>
  45. </template>
  46. </el-table-column>
  47. </el-table>
  48. <pagination
  49. v-show="total>0"
  50. :total="total"
  51. :page.sync="queryParams.pageNum"
  52. :limit.sync="queryParams.pageSize"
  53. @pagination="getList"
  54. />
  55. <!-- 添加或修改客户积分记录对话框 -->
  56. <el-dialog :title="title" :visible.sync="open" width="750px" append-to-body>
  57. <div class="app-container">
  58. <el-table v-loading="loadingInfo" :data="recordList" @selection-change="handleSelectionChange">
  59. <el-table-column label="主键自增" align="center" prop="id" v-if ="false"/>
  60. <el-table-column label="微信用户唯一标识" align="center" prop="unionId" v-if ="false"/>
  61. <el-table-column label="客户名称" align="center" prop="customerName" />
  62. <el-table-column label="积分记录类型" align="center" prop="recordType" :formatter="recordTypeFotmat" />
  63. <el-table-column label="消耗或增加积分" align="center" prop="integral" />
  64. <el-table-column label="时间" align="center" prop="createTime" />
  65. <el-table-column label="油站ID" align="center" prop="stationId" v-if ="false" />
  66. <el-table-column label="油站名称" align="center" prop="stationName" />
  67. </el-table>
  68. <pagination
  69. v-show="totalInfo>0"
  70. :total="totalInfo"
  71. :page.sync="query.pageNum"
  72. :limit.sync="query.pageSize"
  73. @pagination="getInfoList"
  74. />
  75. </div>
  76. </el-dialog>
  77. </div>
  78. </template>
  79. <script>
  80. import { listPoints, exportPoints } from "@/api/integral/points";
  81. import { listRecord } from "@/api/integral/record";
  82. export default {
  83. name: "Points",
  84. data() {
  85. return {
  86. // 遮罩层
  87. loading: true,
  88. loadingInfo: true,
  89. // 选中数组
  90. ids: [],
  91. // 非单个禁用
  92. single: true,
  93. // 非多个禁用
  94. multiple: true,
  95. // 显示搜索条件
  96. showSearch: true,
  97. // 总条数
  98. total: 0,
  99. totalInfo: 0,
  100. // 用户积分表格数据
  101. pointsList: [],
  102. //用户积分明细
  103. recordList: [],
  104. // 弹出层标题
  105. title: "",
  106. // 是否显示弹出层
  107. open: false,
  108. // 查询参数
  109. queryParams: {
  110. pageNum: 1,
  111. pageSize: 10,
  112. unionId: null,
  113. blogOpenid: null,
  114. minaOpenid: null,
  115. mobilePhone: null,
  116. points: null,
  117. consumptionPoints: null,
  118. accumulatePoints: null,
  119. invalidPoints: null,
  120. recentConsumptionDate: null,
  121. stationId: null,
  122. stationName: null
  123. },
  124. //积分明细 查询参数
  125. query: {
  126. pageNum: 1,
  127. pageSize: 10,
  128. unionId: null,
  129. customerName: null,
  130. recordType: null,
  131. integral: null,
  132. stationId: null,
  133. stationName: null
  134. },
  135. // 表单参数
  136. form: {},
  137. // 表单校验
  138. rules: {
  139. }
  140. };
  141. },
  142. created() {
  143. this.getList();
  144. },
  145. methods: {
  146. recordTypeFotmat(row, column){
  147. if(row.recordType === '-'){
  148. return '兑换积分'
  149. }else if(row.recordType === '+'){
  150. return '增加积分'
  151. }
  152. },
  153. /** 查询用户积分列表 */
  154. getList() {
  155. this.loading = true;
  156. this.queryParams.stationId= this.$store.selectDeptId;
  157. listPoints(this.queryParams).then(response => {
  158. this.pointsList = response.rows;
  159. this.total = response.total;
  160. this.loading = false;
  161. });
  162. },
  163. /** 查询用户积分明细列表 */
  164. getInfoList() {
  165. this.loadingInfo = true;
  166. this.queryParams.stationId= this.$store.selectDeptId;
  167. listRecord(this.query).then(response => {
  168. this.recordList = response.rows;
  169. this.totalInfo = response.total;
  170. this.loadingInfo = false;
  171. });
  172. },
  173. // 取消按钮
  174. cancel() {
  175. this.open = false;
  176. this.reset();
  177. },
  178. // 表单重置
  179. reset() {
  180. this.form = {
  181. id: null,
  182. unionId: null,
  183. blogOpenid: null,
  184. minaOpenid: null,
  185. mobilePhone: null,
  186. points: null,
  187. consumptionPoints: null,
  188. accumulatePoints: null,
  189. invalidPoints: null,
  190. recentConsumptionDate: null,
  191. stationId: null,
  192. stationName: null
  193. };
  194. this.resetForm("form");
  195. },
  196. /** 搜索按钮操作 */
  197. handleQuery() {
  198. this.queryParams.pageNum = 1;
  199. this.getList();
  200. },
  201. /** 重置按钮操作 */
  202. resetQuery() {
  203. this.resetForm("queryForm");
  204. this.handleQuery();
  205. },
  206. //查看明细
  207. lookInfo(rows){
  208. this.query.unionId = rows.unionId;
  209. this.getInfoList();
  210. this.open = true;
  211. this.title = "查看客户积分记录";
  212. },
  213. // 多选框选中数据
  214. handleSelectionChange(selection) {
  215. this.ids = selection.map(item => item.id)
  216. this.single = selection.length!==1
  217. this.multiple = !selection.length
  218. },
  219. /** 导出按钮操作 */
  220. handleExport() {
  221. const queryParams = this.queryParams;
  222. this.$confirm('是否确认导出所有用户积分数据项?', "警告", {
  223. confirmButtonText: "确定",
  224. cancelButtonText: "取消",
  225. type: "warning"
  226. }).then(function() {
  227. return exportPoints(queryParams);
  228. }).then(response => {
  229. this.download(response.msg);
  230. })
  231. }
  232. }
  233. };
  234. </script>