index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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="courseId">
  5. <el-select
  6. filterable
  7. v-model="queryParams.courseId"
  8. placeholder="请选择营期"
  9. clearable
  10. size="small"
  11. style="width: 200px"
  12. >
  13. <el-option
  14. v-for="dict in campData"
  15. :key="dict.trainingCampId"
  16. :label="dict.trainingCampName"
  17. :value="dict.trainingCampId"
  18. />
  19. </el-select>
  20. </el-form-item>
  21. <el-form-item>
  22. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  23. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  24. </el-form-item>
  25. </el-form>
  26. <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
  27. <el-table-column label="营期名称" align="center" prop="periodName" />
  28. <el-table-column label="总人数" align="center" prop="total" />
  29. <el-table-column label="流失人数" align="center" prop="num" />
  30. <el-table-column label="营期开始时间" align="center" prop="periodStartingTime" />
  31. <el-table-column label="营期结束时间" align="center" prop="periodEndTime" />
  32. </el-table>
  33. <pagination
  34. v-show="total>0"
  35. :total="total"
  36. :page.sync="queryParams.pageNum"
  37. :limit.sync="queryParams.pageSize"
  38. @pagination="getList"
  39. />
  40. <!-- 添加或修改用户对话框 -->
  41. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  42. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  43. <el-form-item label="用户头像" prop="avatar">
  44. <el-popover
  45. placement="right"
  46. title=""
  47. trigger="hover"
  48. >
  49. <img slot="reference" :src="form.avatar" width="80">
  50. <img :src="form.avatar" style="max-width: 80px;">
  51. </el-popover>
  52. </el-form-item>
  53. <el-form-item label="会员昵称" prop="nickname">
  54. <el-input v-model="form.nickname" disabled placeholder="请输入用户昵称" />
  55. </el-form-item>
  56. <el-form-item label="手机号码" prop="phone">
  57. <el-input v-model="form.phone" disabled placeholder="请输入手机号码" />
  58. </el-form-item>
  59. <el-form-item label="最后一次登录ip" prop="lastIp">
  60. <el-input v-model="form.lastIp" disabled placeholder="请输入最后一次登录ip" />
  61. </el-form-item>
  62. <!-- <el-form-item label="用户余额" prop="nowMoney">
  63. <el-input v-model="form.nowMoney" disabled placeholder="请输入用户余额" />
  64. </el-form-item> -->
  65. <el-form-item label="积分" prop="integral">
  66. <el-input v-model="form.integral" disabled placeholder="请输入用户剩余积分" />
  67. </el-form-item>
  68. <el-form-item label="用户备注" prop="remark">
  69. <el-input v-model="form.remark" placeholder="请输入用户备注" />
  70. </el-form-item>
  71. <!-- <el-form-item label="状态">
  72. <el-radio-group v-model="form.status">
  73. <el-radio :label="item.dictValue" v-for="item in statusOptions" >{{item.dictLabel}}</el-radio>
  74. </el-radio-group>
  75. </el-form-item> -->
  76. </el-form>
  77. <div slot="footer" class="dialog-footer">
  78. <el-button type="primary" @click="submitForm">确 定</el-button>
  79. <el-button @click="cancel">取 消</el-button>
  80. </div>
  81. </el-dialog>
  82. </div>
  83. </template>
  84. <script>
  85. import { myList,updateUser,getUser,addUser } from "@/api/users/user";
  86. import { shortListCamp } from '@/api/course/userCourseCamp'
  87. import { courseLost } from '@/api/course/courseRedPacketLog'
  88. export default {
  89. name: "User",
  90. data() {
  91. return {
  92. statusOptions:[],
  93. //课程数据
  94. campData: null,
  95. // 遮罩层
  96. loading: false,
  97. // 选中数组
  98. ids: [],
  99. // 非单个禁用
  100. single: true,
  101. // 非多个禁用
  102. multiple: true,
  103. // 显示搜索条件
  104. showSearch: true,
  105. // 总条数
  106. total: 0,
  107. // 用户表格数据
  108. userList: [],
  109. // 弹出层标题
  110. title: "",
  111. // 是否显示弹出层
  112. open: false,
  113. // 查询参数
  114. queryParams: {
  115. pageNum: 1,
  116. pageSize: 10,
  117. courseId: null
  118. },
  119. // 表单参数
  120. form: {},
  121. // 表单校验
  122. rules: {
  123. nowMoney: [
  124. { required: true, message: "用户余额不能为空", trigger: "blur" }
  125. ],
  126. brokeragePrice: [
  127. { required: true, message: "佣金金额不能为空", trigger: "blur" }
  128. ],
  129. integral: [
  130. { required: true, message: "用户剩余积分不能为空", trigger: "blur" }
  131. ],
  132. signNum: [
  133. { required: true, message: "连续签到天数不能为空", trigger: "blur" }
  134. ],
  135. status: [
  136. { required: true, message: "1为正常,0为禁止不能为空", trigger: "blur" }
  137. ],
  138. level: [
  139. { required: true, message: "等级不能为空", trigger: "blur" }
  140. ],
  141. userType: [
  142. { required: true, message: "用户类型不能为空", trigger: "change" }
  143. ],
  144. isPromoter: [
  145. { required: true, message: "是否为推广员不能为空", trigger: "blur" }
  146. ],
  147. addres: [
  148. { required: true, message: "详细地址不能为空", trigger: "blur" }
  149. ],
  150. }
  151. };
  152. },
  153. created() {
  154. shortListCamp().then(response => {
  155. this.campData = response.data;
  156. })
  157. this.getDicts("user_status").then((response) => {
  158. this.statusOptions = response.data;
  159. });
  160. //this.getList();
  161. },
  162. methods: {
  163. /** 查询用户列表 */
  164. getList() {
  165. this.loading = true;
  166. if(this.queryParams.courseId===null){
  167. this.loading = false
  168. this.userList=null
  169. return;
  170. }
  171. courseLost(this.queryParams).then(response => {
  172. this.userList = response.rows;
  173. this.total = response.total;
  174. this.loading = false;
  175. })
  176. },
  177. // 取消按钮
  178. cancel() {
  179. this.open = false;
  180. this.reset();
  181. },
  182. // 表单重置
  183. reset() {
  184. this.form = {
  185. userId: null,
  186. username: null,
  187. password: null,
  188. realName: null,
  189. birthday: null,
  190. idCard: null,
  191. mark: null,
  192. nickname: null,
  193. avatar: null,
  194. phone: null,
  195. createTime: null,
  196. updateTime: null,
  197. lastIp: null,
  198. nowMoney: null,
  199. brokeragePrice: null,
  200. integral: null,
  201. signNum: null,
  202. status: 0,
  203. level: null,
  204. spreadUserId: null,
  205. spreadTime: null,
  206. userType: null,
  207. isPromoter: null,
  208. payCount: null,
  209. spreadCount: null,
  210. addres: null,
  211. wxProfile: null,
  212. isDel: null
  213. };
  214. this.resetForm("form");
  215. },
  216. /** 搜索按钮操作 */
  217. handleQuery() {
  218. this.queryParams.pageNum = 1;
  219. this.getList();
  220. },
  221. /** 重置按钮操作 */
  222. resetQuery() {
  223. this.resetForm("queryForm");
  224. this.handleQuery();
  225. },
  226. // 多选框选中数据
  227. handleSelectionChange(selection) {
  228. this.ids = selection.map(item => item.userId)
  229. this.single = selection.length!==1
  230. this.multiple = !selection.length
  231. },
  232. /** 新增按钮操作 */
  233. handleAdd() {
  234. this.reset();
  235. this.open = true;
  236. this.title = "添加用户";
  237. },
  238. /** 修改按钮操作 */
  239. handleUpdate(row) {
  240. this.reset();
  241. const userId = row.userId || this.ids
  242. getUser(userId).then(response => {
  243. this.form = response.data;
  244. this.form.status = response.data.status.toString();
  245. this.open = true;
  246. this.title = "修改用户";
  247. });
  248. },
  249. /** 提交按钮 */
  250. submitForm() {
  251. this.$refs["form"].validate(valid => {
  252. if (valid) {
  253. if (this.form.userId != null) {
  254. updateUser(this.form).then(response => {
  255. if (response.code === 200) {
  256. this.msgSuccess("修改成功");
  257. this.open = false;
  258. this.getList();
  259. }
  260. });
  261. } else {
  262. addUser(this.form).then(response => {
  263. if (response.code === 200) {
  264. this.msgSuccess("新增成功");
  265. this.open = false;
  266. this.getList();
  267. }
  268. });
  269. }
  270. }
  271. });
  272. },
  273. /** 删除按钮操作 */
  274. handleDelete(row) {
  275. const userIds = row.userId || this.ids;
  276. this.$confirm('是否确认删除用户编号为"' + userIds + '"的数据项?', "警告", {
  277. confirmButtonText: "确定",
  278. cancelButtonText: "取消",
  279. type: "warning"
  280. }).then(function() {
  281. return delUser(userIds);
  282. }).then(() => {
  283. this.getList();
  284. this.msgSuccess("删除成功");
  285. }).catch(function() {});
  286. },
  287. /** 导出按钮操作 */
  288. handleExport() {
  289. const queryParams = this.queryParams;
  290. this.$confirm('是否确认导出所有用户数据项?', "警告", {
  291. confirmButtonText: "确定",
  292. cancelButtonText: "取消",
  293. type: "warning"
  294. }).then(function() {
  295. return exportUser(queryParams);
  296. }).then(response => {
  297. this.download(response.msg);
  298. }).catch(function() {});
  299. }
  300. }
  301. };
  302. </script>