index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  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="会员ID" prop="userId">
  5. <el-input
  6. v-model="queryParams.userId"
  7. placeholder="请输入会员ID"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="用户昵称" prop="nickName">
  14. <el-input
  15. v-model="queryParams.nickName"
  16. placeholder="请输入用户昵称"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="手机号码" prop="phone">
  23. <el-input
  24. v-model="queryParams.phone"
  25. placeholder="请输入手机号码"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="加密号码" prop="phoneMk">
  32. <el-input
  33. v-model="queryParams.phoneMk"
  34. placeholder="请输入手机号码"
  35. clearable
  36. size="small"
  37. @keyup.enter.native="handleQuery"
  38. />
  39. </el-form-item>
  40. <el-form-item label="app来源" prop="source">
  41. <el-input
  42. v-model="queryParams.source"
  43. placeholder="请输入手机号码"
  44. clearable
  45. size="small"
  46. @keyup.enter.native="handleQuery"
  47. />
  48. </el-form-item>
  49. <el-form-item label="用户状态" prop="status">
  50. <el-select v-model="queryParams.status" placeholder="请选择用户状态" clearable size="small">
  51. <el-option
  52. v-for="dict in userOptions"
  53. :key="dict.dictValue"
  54. :label="dict.dictLabel"
  55. :value="dict.dictValue"
  56. />
  57. </el-select>
  58. </el-form-item>
  59. <el-form-item label="是否购药" prop="isBuy">
  60. <el-select v-model="queryParams.isBuy" placeholder="请选择用户状态" clearable size="small">
  61. <el-option
  62. v-for="dict in orOptions"
  63. :key="dict.dictValue"
  64. :label="dict.dictLabel"
  65. :value="dict.dictValue"
  66. />
  67. </el-select>
  68. </el-form-item>
  69. <el-form-item label="注册时间" prop="createTime">
  70. <el-date-picker v-model="createTime" size="small" style="width: 230px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="change"></el-date-picker>
  71. </el-form-item>
  72. <el-form-item>
  73. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  74. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  75. </el-form-item>
  76. </el-form>
  77. <el-row :gutter="10" class="mb8">
  78. <el-col :span="1.5">
  79. <el-button
  80. type="warning"
  81. plain
  82. icon="el-icon-download"
  83. size="mini"
  84. :loading="exportLoading"
  85. @click="handleExport"
  86. v-hasPermi="['his:user:export']"
  87. >导出</el-button>
  88. </el-col>
  89. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  90. </el-row>
  91. <el-table height="660" v-loading="loading" border :data="userList" @selection-change="handleSelectionChange" >
  92. <el-table-column type="selection" width="55" align="center" />
  93. <el-table-column label="会员id" align="center" prop="userId" width="150px"/>
  94. <el-table-column label="用户昵称" align="center" prop="nickName" width="150px"/>
  95. <el-table-column label="会员头像" align="center" width="80">
  96. <template slot-scope="scope">
  97. <el-popover
  98. placement="right"
  99. title=""
  100. trigger="hover"
  101. >
  102. <img slot="reference" :src="scope.row.avatar" width="50" >
  103. <img :src="scope.row.avatar" style="max-width: 120px;">
  104. </el-popover>
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="手机号码" align="center" prop="phone" width="150px" />
  108. <el-table-column label="用户积分" align="center" prop="integral" />
  109. <el-table-column label="用户状态" align="center" prop="status" >
  110. <template slot-scope="scope">
  111. <dict-tag :options="userOptions" :value="scope.row.status"/>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="用户备注" align="center" prop="remark" />
  115. <el-table-column label="上级昵称" align="center" prop="tuiName" />
  116. <el-table-column label="app来源" align="center" prop="source" />
  117. <el-table-column label="登陆设备" align="center" prop="loginDevice" />
  118. <el-table-column label="上级手机号码" align="center" prop="tuiPhone" width="150px"/>
  119. <el-table-column label="下级人数" align="center" prop="tuiUserCount" />
  120. <el-table-column label="最后一次登录ip" align="center" prop="lastIp" width="130px"/>
  121. <el-table-column label="余额" align="center" prop="balance" />
  122. <el-table-column label="注册时间" align="center" prop="createTime" width="150px" />
  123. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="150px">
  124. <template slot-scope="scope">
  125. <el-button
  126. size="mini"
  127. type="text"
  128. icon="el-icon-edit"
  129. @click="handleUpdate(scope.row)"
  130. v-hasPermi="['his:user:edit']"
  131. >修改</el-button>
  132. <el-button
  133. size="mini"
  134. type="text"
  135. @click="handledetails(scope.row)"
  136. >详情</el-button>
  137. <el-button
  138. size="mini"
  139. type="text"
  140. @click="handleDelete(scope.row)"
  141. v-hasPermi="['his:user:remove']"
  142. >删除</el-button>
  143. <el-button
  144. size="mini"
  145. type="text"
  146. @click="handleAddPoint(scope.row)"
  147. v-hasPermi="['his:user:addPoint']"
  148. >添加积分</el-button>
  149. </template>
  150. </el-table-column>
  151. </el-table>
  152. <pagination
  153. v-show="total>0"
  154. :total="total"
  155. :page.sync="queryParams.pageNum"
  156. :limit.sync="queryParams.pageSize"
  157. @pagination="getList"
  158. />
  159. <!-- 添加或修改用户对话框 -->
  160. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  161. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  162. <el-form-item label="用户昵称" prop="nickName">
  163. <el-input v-model="form.nickName" placeholder="请输入用户昵称" />
  164. </el-form-item>
  165. <el-form-item label="用户状态" prop="status">
  166. <el-select v-model="form.status" placeholder="请选择状态" clearable size="small">
  167. <el-option
  168. v-for="dict in userOptions"
  169. :key="dict.dictValue"
  170. :label="dict.dictLabel"
  171. :value="dict.dictValue"
  172. />
  173. </el-select>
  174. </el-form-item>
  175. <el-form-item label="用户备注" prop="remark" >
  176. <el-input v-model="form.remark" placeholder="请输入用户备注" type="textarea"/>
  177. </el-form-item>
  178. </el-form>
  179. <div slot="footer" class="dialog-footer">
  180. <el-button type="primary" @click="submitForm">确 定</el-button>
  181. <el-button @click="cancel">取 消</el-button>
  182. </div>
  183. </el-dialog>
  184. <el-drawer
  185. :with-header="false"
  186. size="75%"
  187. :title="show.title" :visible.sync="show.open">
  188. <!-- <userDetails ref="userDetails" />-->
  189. <userDetailsByNew ref="userDetailsByNew" />
  190. </el-drawer>
  191. <el-dialog :title="addPointDialog.title" :visible.sync="addPointDialog.open" width="500px" append-to-body>
  192. <el-form ref="addPointForm" :model="addPointDialog.form" :rules="addPointDialog.rules" label-width="100px">
  193. <el-form-item label="积分" prop="point">
  194. <el-input-number :min="0" :step="1" :precision="0" v-model="addPointDialog.form.point" placeholder="请输入积分" />
  195. <div style="color: #a95812">积分不能为小数</div>
  196. </el-form-item>
  197. <el-form-item label="备注" prop="remark">
  198. <el-input type="textarea" v-model="addPointDialog.form.remark" placeholder="请输入备注说明" />
  199. </el-form-item>
  200. </el-form>
  201. <div slot="footer" class="dialog-footer">
  202. <el-button type="primary" @click="submitAddPointForm">确 定</el-button>
  203. <el-button @click="cancelAddPoint">取 消</el-button>
  204. </div>
  205. </el-dialog>
  206. </div>
  207. </template>
  208. <script>
  209. import { listUser, getUser, delUser, addUser, updateUser, exportUser, addPoint } from "@/api/his/user";
  210. import { getCompanyUserList, changeCompanyUser, getCompanyList } from '@/api/company/companyUser';
  211. import userDetails from '../../components/his/userDetails.vue';
  212. import userDetailsByNew from './userDetails.vue';
  213. export default {
  214. name: "User",
  215. components: {userDetails,userDetailsByNew},
  216. data() {
  217. return {
  218. companyName: null,
  219. companyUserNickName: null,
  220. companyOptions: [],
  221. companyUserOptions: [],
  222. show:{
  223. title:"用户详情",
  224. open:false,
  225. },
  226. userOptions: [],
  227. // 遮罩层
  228. loading: true,
  229. // 导出遮罩层
  230. exportLoading: false,
  231. // 选中数组
  232. ids: [],
  233. orOptions:[],
  234. // 非单个禁用
  235. single: true,
  236. // 非多个禁用
  237. multiple: true,
  238. // 显示搜索条件
  239. showSearch: true,
  240. // 总条数
  241. total: 0,
  242. // 用户表格数据
  243. userList: [],
  244. // 弹出层标题
  245. title: "",
  246. // 是否显示弹出层
  247. open: false,
  248. createTime:null,
  249. // 查询参数
  250. queryParams: {
  251. pageNum: 1,
  252. pageSize: 10,
  253. nickName: null,
  254. avatar: null,
  255. phone: null,
  256. phoneMk: null,
  257. integral: null,
  258. status: null,
  259. tuiUserId: null,
  260. tuiTime: null,
  261. tuiUserCount: null,
  262. maOpenId: null,
  263. mpOpenId: null,
  264. unionId: null,
  265. isDel: null,
  266. userCode: null,
  267. lastIp: null,
  268. balance: null,
  269. sTime:null,
  270. eTime:null,
  271. isBuy:null,
  272. source:null,
  273. companyName: null,
  274. userId: null
  275. },
  276. // 表单参数
  277. form: {},
  278. // 表单校验
  279. rules: {
  280. nickName: [
  281. { required: true, message: "昵称不能为空", trigger: "blur" }
  282. ],
  283. status: [
  284. { required: true, message: "用户状态不能为空", trigger: "blur" }
  285. ],
  286. integral: [
  287. { required: true, message: "用户积分不能为空", trigger: "blur" }
  288. ],
  289. },
  290. addPointDialog: {
  291. open: false,
  292. title: "添加积分",
  293. form: {
  294. userId: null,
  295. point: null,
  296. remark: null
  297. },
  298. rules: {
  299. point: [
  300. { required: true, message: "请输入积分", trigger: "blur" },
  301. { validator: (rule, value, callback) => {
  302. if (Number(value) > 0) {
  303. callback(); // 验证通过
  304. } else {
  305. callback(new Error("积分必须大于0"));
  306. }
  307. },
  308. trigger: "blur" }
  309. ]
  310. }
  311. }
  312. };
  313. },
  314. created() {
  315. this.getList();
  316. this.getDicts("sys_user_status").then(response => {
  317. this.userOptions = response.data;
  318. });
  319. this.getDicts("sys_company_or").then(response => {
  320. this.orOptions = response.data;
  321. });
  322. },
  323. methods: {
  324. /** 销售选择变化 */
  325. handleCompanyUserChange(userId) {
  326. if (!this.changeCompanyUserForm.companyId) {
  327. this.$message.warning('请先选择公司');
  328. this.changeCompanyUserForm.companyUserId = null;
  329. return;
  330. }
  331. },
  332. change(){
  333. if(this.createTime!=null){
  334. this.queryParams.sTime=this.createTime[0];
  335. this.queryParams.eTime=this.createTime[1];
  336. }else{
  337. this.queryParams.sTime=null;
  338. this.queryParams.eTime=null;
  339. }
  340. },
  341. handledetails(row){
  342. this.show.open=true;
  343. setTimeout(() => {
  344. this.$refs.userDetailsByNew.getDetails(row.userId);
  345. }, 1);
  346. },
  347. /** 查询用户列表 */
  348. getList() {
  349. this.loading = true;
  350. listUser(this.queryParams).then(response => {
  351. this.userList = response.rows;
  352. this.total = response.total;
  353. this.loading = false;
  354. });
  355. },
  356. // 取消按钮
  357. cancel() {
  358. this.open = false;
  359. this.reset();
  360. },
  361. // 表单重置
  362. reset() {
  363. this.form = {
  364. userId: null,
  365. nickName: null,
  366. avatar: null,
  367. phone: null,
  368. integral: null,
  369. status: null,
  370. tuiUserId: null,
  371. tuiTime: null,
  372. tuiUserCount: null,
  373. maOpenId: null,
  374. mpOpenId: null,
  375. unionId: null,
  376. isDel: null,
  377. userCode: null,
  378. remark: null,
  379. createTime: null,
  380. updateTime: null,
  381. lastIp: null,
  382. balance: null
  383. };
  384. this.resetForm("form");
  385. },
  386. /** 搜索按钮操作 */
  387. handleQuery() {
  388. this.queryParams.pageNum = 1;
  389. this.getList();
  390. },
  391. /** 重置按钮操作 */
  392. resetQuery() {
  393. this.resetForm("queryForm");
  394. this.createTime=null;
  395. this.queryParams.sTime=null;
  396. this.queryParams.eTime=null;
  397. this.handleQuery();
  398. },
  399. // 多选框选中数据
  400. handleSelectionChange(selection) {
  401. this.ids = selection.map(item => item.userId)
  402. this.single = selection.length!==1
  403. this.multiple = !selection.length
  404. },
  405. /** 新增按钮操作 */
  406. handleAdd() {
  407. this.reset();
  408. this.open = true;
  409. this.title = "添加用户";
  410. },
  411. /** 修改按钮操作 */
  412. handleUpdate(row) {
  413. this.reset();
  414. const userId = row.userId || this.ids
  415. getUser(userId).then(response => {
  416. this.form = response.data;
  417. this.open = true;
  418. this.title = "修改用户";
  419. this.form.status = String(this.form.status)
  420. });
  421. },
  422. /** 提交按钮 */
  423. submitForm() {
  424. this.$refs["form"].validate(valid => {
  425. if (valid) {
  426. if (this.form.userId != null) {
  427. updateUser(this.form).then(response => {
  428. this.msgSuccess("修改成功");
  429. this.open = false;
  430. this.getList();
  431. });
  432. } else {
  433. addUser(this.form).then(response => {
  434. this.msgSuccess("新增成功");
  435. this.open = false;
  436. this.getList();
  437. });
  438. }
  439. }
  440. });
  441. },
  442. /** 删除按钮操作 */
  443. handleDelete(row) {
  444. const userIds = row.userId || this.ids;
  445. this.$confirm('是否确认删除用户编号为"' + userIds + '"的数据项?', "警告", {
  446. confirmButtonText: "确定",
  447. cancelButtonText: "取消",
  448. type: "warning"
  449. }).then(function() {
  450. return delUser(userIds);
  451. }).then(() => {
  452. this.getList();
  453. this.msgSuccess("删除成功");
  454. }).catch(() => {});
  455. },
  456. handleAddPoint(row) {
  457. console.log(row)
  458. this.resetForm("addPointForm");
  459. this.addPointDialog.form = {
  460. userId: row.userId,
  461. point: 0,
  462. remark: ''
  463. }
  464. this.addPointDialog.open = true
  465. },
  466. submitAddPointForm() {
  467. this.$refs["addPointForm"].validate(valid => {
  468. if (valid) {
  469. addPoint(this.addPointDialog.form).then(response => {
  470. const {code} = response
  471. if (code !== 200) {
  472. this.msgError(response.msg || '添加失败');
  473. return
  474. }
  475. this.msgSuccess("添加成功");
  476. this.addPointDialog.open = false;
  477. this.getList();
  478. });
  479. }
  480. });
  481. },
  482. cancelAddPoint() {
  483. this.addPointDialog.open = false;
  484. },
  485. /** 导出按钮操作 */
  486. handleExport() {
  487. const queryParams = this.queryParams;
  488. this.$confirm('是否确认导出当前用户数据项?', "警告", {
  489. confirmButtonText: "确定",
  490. cancelButtonText: "取消",
  491. type: "warning"
  492. }).then(() => {
  493. this.exportLoading = true;
  494. return exportUser(queryParams);
  495. }).then(response => {
  496. this.download(response.msg);
  497. this.exportLoading = false;
  498. }).catch(() => {
  499. this.exportLoading = false;
  500. });
  501. },
  502. }
  503. };
  504. </script>