index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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="nickname">
  5. <el-input
  6. v-model="queryParams.nickname"
  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 label="创建时间">
  23. <el-date-picker v-model="dateRange" size="small" style="width: 205.4px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  27. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  28. </el-form-item>
  29. </el-form>
  30. <el-row :gutter="10" class="mb8">
  31. <el-col :span="1.5">
  32. <el-button
  33. type="warning"
  34. icon="el-icon-download"
  35. size="mini"
  36. @click="handleExport"
  37. v-hasPermi="['store:userBill:export']"
  38. >导出</el-button>
  39. </el-col>
  40. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  41. </el-row>
  42. <el-table height="500" border v-loading="loading" :data="userBillList" @selection-change="handleSelectionChange">
  43. <el-table-column type="selection" width="55" align="center" />
  44. <el-table-column label="ID" align="center" prop="id" />
  45. <el-table-column label="会员昵称" align="center" prop="nickname" />
  46. <el-table-column label="会员手机号" align="center" prop="phone" />
  47. <el-table-column label="账单标题" align="center" prop="title" />
  48. <el-table-column label="明细分类 " align="center" prop="category" />
  49. <el-table-column label="明细类型" align="center" prop="type" />
  50. <el-table-column label="明细数字" align="center" prop="number" />
  51. <el-table-column label="余额" align="center" prop="balance" />
  52. <el-table-column label="备注" align="center" prop="remark" />
  53. <el-table-column label="创建时间" align="center" prop="createTime" />
  54. </el-table>
  55. <pagination
  56. v-show="total>0"
  57. :total="total"
  58. :page.sync="queryParams.pageNum"
  59. :limit.sync="queryParams.pageSize"
  60. @pagination="getList"
  61. />
  62. </div>
  63. </template>
  64. <script>
  65. import { listUserBill, getUserBill, delUserBill, addUserBill, updateUserBill, exportUserBill } from "@/api/his/userBill";
  66. export default {
  67. name: "UserBill",
  68. data() {
  69. return {
  70. // 遮罩层
  71. loading: true,
  72. // 选中数组
  73. ids: [],
  74. // 非单个禁用
  75. single: true,
  76. // 非多个禁用
  77. multiple: true,
  78. // 显示搜索条件
  79. showSearch: true,
  80. dateRange:[],
  81. // 总条数
  82. total: 0,
  83. // 用户账单表格数据
  84. userBillList: [],
  85. // 弹出层标题
  86. title: "",
  87. // 是否显示弹出层
  88. open: false,
  89. // 查询参数
  90. queryParams: {
  91. pageNum: 1,
  92. pageSize: 10,
  93. userId: null,
  94. businessId: null,
  95. category: null,
  96. billType: null,
  97. type: null,
  98. title: null,
  99. number: null,
  100. balance: null,
  101. status: null
  102. },
  103. // 表单参数
  104. form: {},
  105. // 表单校验
  106. rules: {
  107. userId: [
  108. { required: true, message: "用户uid不能为空", trigger: "blur" }
  109. ],
  110. businessId: [
  111. { required: true, message: "关联id不能为空", trigger: "blur" }
  112. ],
  113. billType: [
  114. { required: true, message: "类型 0 = 支出 1 = 获得不能为空", trigger: "change" }
  115. ],
  116. title: [
  117. { required: true, message: "账单标题不能为空", trigger: "blur" }
  118. ],
  119. number: [
  120. { required: true, message: "明细数字不能为空", trigger: "blur" }
  121. ],
  122. balance: [
  123. { required: true, message: "剩余不能为空", trigger: "blur" }
  124. ],
  125. remark: [
  126. { required: true, message: "备注不能为空", trigger: "blur" }
  127. ],
  128. createTime: [
  129. { required: true, message: "添加时间不能为空", trigger: "blur" }
  130. ],
  131. status: [
  132. { required: true, message: "0 = 带确定 1 = 有效 -1 = 无效不能为空", trigger: "blur" }
  133. ]
  134. }
  135. };
  136. },
  137. created() {
  138. this.getList();
  139. },
  140. methods: {
  141. /** 查询用户账单列表 */
  142. getList() {
  143. this.loading = true;
  144. listUserBill(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  145. this.userBillList = response.rows;
  146. this.total = response.total;
  147. this.loading = false;
  148. });
  149. },
  150. // 取消按钮
  151. cancel() {
  152. this.open = false;
  153. this.reset();
  154. },
  155. // 表单重置
  156. reset() {
  157. this.form = {
  158. id: null,
  159. userId: null,
  160. businessId: null,
  161. category: null,
  162. billType: null,
  163. type: null,
  164. title: null,
  165. number: null,
  166. balance: null,
  167. remark: null,
  168. createTime: null,
  169. updateTime: null,
  170. status: 0
  171. };
  172. this.resetForm("form");
  173. },
  174. /** 搜索按钮操作 */
  175. handleQuery() {
  176. this.queryParams.pageNum = 1;
  177. this.getList();
  178. },
  179. /** 重置按钮操作 */
  180. resetQuery() {
  181. this.resetForm("queryForm");
  182. this.handleQuery();
  183. },
  184. // 多选框选中数据
  185. handleSelectionChange(selection) {
  186. this.ids = selection.map(item => item.id)
  187. this.single = selection.length!==1
  188. this.multiple = !selection.length
  189. },
  190. /** 新增按钮操作 */
  191. handleAdd() {
  192. this.reset();
  193. this.open = true;
  194. this.title = "添加用户账单";
  195. },
  196. /** 修改按钮操作 */
  197. handleUpdate(row) {
  198. this.reset();
  199. const id = row.id || this.ids
  200. getUserBill(id).then(response => {
  201. this.form = response.data;
  202. this.open = true;
  203. this.title = "修改用户账单";
  204. });
  205. },
  206. /** 提交按钮 */
  207. submitForm() {
  208. this.$refs["form"].validate(valid => {
  209. if (valid) {
  210. if (this.form.id != null) {
  211. updateUserBill(this.form).then(response => {
  212. if (response.code === 200) {
  213. this.msgSuccess("修改成功");
  214. this.open = false;
  215. this.getList();
  216. }
  217. });
  218. } else {
  219. addUserBill(this.form).then(response => {
  220. if (response.code === 200) {
  221. this.msgSuccess("新增成功");
  222. this.open = false;
  223. this.getList();
  224. }
  225. });
  226. }
  227. }
  228. });
  229. },
  230. /** 删除按钮操作 */
  231. handleDelete(row) {
  232. const ids = row.id || this.ids;
  233. this.$confirm('是否确认删除用户账单编号为"' + ids + '"的数据项?', "警告", {
  234. confirmButtonText: "确定",
  235. cancelButtonText: "取消",
  236. type: "warning"
  237. }).then(function() {
  238. return delUserBill(ids);
  239. }).then(() => {
  240. this.getList();
  241. this.msgSuccess("删除成功");
  242. }).catch(function() {});
  243. },
  244. /** 导出按钮操作 */
  245. handleExport() {
  246. const queryParams = this.queryParams;
  247. this.$confirm('是否确认导出所有用户账单数据项?', "警告", {
  248. confirmButtonText: "确定",
  249. cancelButtonText: "取消",
  250. type: "warning"
  251. }).then(function() {
  252. return exportUserBill(queryParams);
  253. }).then(response => {
  254. this.download(response.msg);
  255. }).catch(function() {});
  256. }
  257. }
  258. };
  259. </script>