index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <div class="app-container">
  3. <el-table v-loading="loading" :data="recordList" @selection-change="handleSelectionChange">
  4. <el-table-column type="selection" width="55" align="center" />
  5. <el-table-column label="主键自增" align="center" prop="id" />
  6. <el-table-column label="微信用户唯一标识" align="center" prop="unionId" />
  7. <el-table-column label="客户名称" align="center" prop="customerName" />
  8. <el-table-column label="积分记录类型:-,消耗; +,增加;" align="center" prop="recordType" />
  9. <el-table-column label="消耗或增加积分" align="center" prop="integral" />
  10. <el-table-column label="时间" align="center" prop="createTime" />
  11. <el-table-column label="油站ID" align="center" prop="stationId" />
  12. <el-table-column label="油站名称" align="center" prop="stationName" />
  13. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  14. <template slot-scope="scope">
  15. <el-button
  16. size="mini"
  17. type="text"
  18. icon="el-icon-edit"
  19. @click="handleUpdate(scope.row)"
  20. v-hasPermi="['integral:record:edit']"
  21. >修改</el-button>
  22. <el-button
  23. size="mini"
  24. type="text"
  25. icon="el-icon-delete"
  26. @click="handleDelete(scope.row)"
  27. v-hasPermi="['integral:record:remove']"
  28. >删除</el-button>
  29. </template>
  30. </el-table-column>
  31. </el-table>
  32. <pagination
  33. v-show="total>0"
  34. :total="total"
  35. :page.sync="queryParams.pageNum"
  36. :limit.sync="queryParams.pageSize"
  37. @pagination="getList"
  38. />
  39. <!-- 添加或修改客户积分记录对话框 -->
  40. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  41. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  42. <el-form-item label="微信用户唯一标识" prop="unionId">
  43. <el-input v-model="form.unionId" placeholder="请输入微信用户唯一标识" />
  44. </el-form-item>
  45. <el-form-item label="客户名称" prop="customerName">
  46. <el-input v-model="form.customerName" placeholder="请输入客户名称" />
  47. </el-form-item>
  48. <el-form-item label="积分记录类型:-,消耗; +,增加;" prop="recordType">
  49. <el-select v-model="form.recordType" placeholder="请选择积分记录类型:-,消耗; +,增加;">
  50. <el-option label="请选择字典生成" value="" />
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item label="消耗或增加积分" prop="integral">
  54. <el-input v-model="form.integral" placeholder="请输入消耗或增加积分" />
  55. </el-form-item>
  56. <el-form-item label="油站ID" prop="stationId">
  57. <el-input v-model="form.stationId" placeholder="请输入油站ID" />
  58. </el-form-item>
  59. <el-form-item label="油站名称" prop="stationName">
  60. <el-input v-model="form.stationName" placeholder="请输入油站名称" />
  61. </el-form-item>
  62. </el-form>
  63. <div slot="footer" class="dialog-footer">
  64. <el-button type="primary" @click="submitForm">确 定</el-button>
  65. <el-button @click="cancel">取 消</el-button>
  66. </div>
  67. </el-dialog>
  68. </div>
  69. </template>
  70. <script>
  71. import { listRecord, getRecord, delRecord, addRecord, updateRecord, exportRecord } from "@/api/integral/record";
  72. export default {
  73. name: "Record",
  74. data() {
  75. return {
  76. // 遮罩层
  77. loading: true,
  78. // 选中数组
  79. ids: [],
  80. // 非单个禁用
  81. single: true,
  82. // 非多个禁用
  83. multiple: true,
  84. // 显示搜索条件
  85. showSearch: true,
  86. // 总条数
  87. total: 0,
  88. // 客户积分记录表格数据
  89. recordList: [],
  90. // 弹出层标题
  91. title: "",
  92. // 是否显示弹出层
  93. open: false,
  94. // 查询参数
  95. queryParams: {
  96. pageNum: 1,
  97. pageSize: 10,
  98. unionId: null,
  99. customerName: null,
  100. recordType: null,
  101. integral: null,
  102. stationId: null,
  103. stationName: null
  104. },
  105. // 表单参数
  106. form: {},
  107. // 表单校验
  108. rules: {
  109. }
  110. };
  111. },
  112. created() {
  113. this.getList();
  114. },
  115. methods: {
  116. /** 查询客户积分记录列表 */
  117. getList() {
  118. this.loading = true;
  119. this.queryParams.stationId= this.$store.selectDeptId;
  120. if(this.queryParams.stationId==null || this.queryParams.stationId==""){
  121. this.queryParams.stationId =this.$store.state.user.deptId;
  122. }
  123. listRecord(this.queryParams).then(response => {
  124. this.recordList = response.rows;
  125. this.total = response.total;
  126. this.loading = false;
  127. });
  128. },
  129. // 取消按钮
  130. cancel() {
  131. this.open = false;
  132. this.reset();
  133. },
  134. // 表单重置
  135. reset() {
  136. this.form = {
  137. id: null,
  138. unionId: null,
  139. customerName: null,
  140. recordType: null,
  141. integral: null,
  142. createTime: null,
  143. stationId: null,
  144. stationName: null
  145. };
  146. this.resetForm("form");
  147. },
  148. /** 搜索按钮操作 */
  149. handleQuery() {
  150. this.queryParams.pageNum = 1;
  151. this.getList();
  152. },
  153. /** 重置按钮操作 */
  154. resetQuery() {
  155. this.resetForm("queryForm");
  156. this.handleQuery();
  157. },
  158. // 多选框选中数据
  159. handleSelectionChange(selection) {
  160. this.ids = selection.map(item => item.id)
  161. this.single = selection.length!==1
  162. this.multiple = !selection.length
  163. },
  164. /** 新增按钮操作 */
  165. handleAdd() {
  166. this.reset();
  167. this.open = true;
  168. this.title = "添加客户积分记录";
  169. },
  170. /** 修改按钮操作 */
  171. handleUpdate(row) {
  172. this.reset();
  173. const id = row.id || this.ids
  174. getRecord(id).then(response => {
  175. this.form = response.data;
  176. this.open = true;
  177. this.title = "修改客户积分记录";
  178. });
  179. },
  180. /** 提交按钮 */
  181. submitForm() {
  182. this.$refs["form"].validate(valid => {
  183. if (valid) {
  184. if (this.form.id != null) {
  185. updateRecord(this.form).then(response => {
  186. this.msgSuccess("修改成功");
  187. this.open = false;
  188. this.getList();
  189. });
  190. } else {
  191. addRecord(this.form).then(response => {
  192. this.msgSuccess("新增成功");
  193. this.open = false;
  194. this.getList();
  195. });
  196. }
  197. }
  198. });
  199. },
  200. /** 删除按钮操作 */
  201. handleDelete(row) {
  202. const ids = row.id || this.ids;
  203. this.$confirm('是否确认删除客户积分记录', "警告", {
  204. confirmButtonText: "确定",
  205. cancelButtonText: "取消",
  206. type: "warning"
  207. }).then(function() {
  208. return delRecord(ids);
  209. }).then(() => {
  210. this.getList();
  211. this.msgSuccess("删除成功");
  212. })
  213. },
  214. /** 导出按钮操作 */
  215. handleExport() {
  216. const queryParams = this.queryParams;
  217. this.$confirm('是否确认导出所有客户积分记录数据项?', "警告", {
  218. confirmButtonText: "确定",
  219. cancelButtonText: "取消",
  220. type: "warning"
  221. }).then(function() {
  222. return exportRecord(queryParams);
  223. }).then(response => {
  224. this.download(response.msg);
  225. })
  226. }
  227. }
  228. };
  229. </script>