list.vue 11 KB

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