You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

580 lines
17 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <template>
  2. <div style="padding:30px;">
  3. <!-- 搜索栏 -->
  4. <div class="search">
  5. <el-form :inline="true">
  6. <el-form-item label="用户昵称:" style="margin-right:50px;">
  7. <el-input
  8. v-model="queryParams.query.nickName"
  9. clearable
  10. placeholder="请输入用户昵称"
  11. />
  12. </el-form-item>
  13. <el-form-item label="用户编号:" style="margin-right:50px;">
  14. <el-input
  15. v-model="queryParams.query.code"
  16. clearable
  17. placeholder="请输入用户编号"
  18. />
  19. </el-form-item>
  20. <el-form-item label="联系电话:" style="margin-right:50px;">
  21. <el-input
  22. v-model="queryParams.query.phonenumber"
  23. clearable
  24. placeholder="请输入联系电话"
  25. />
  26. </el-form-item>
  27. <el-form-item label="注册时间:" style="margin-right:50px;">
  28. <el-date-picker
  29. v-model="time"
  30. type="daterange"
  31. range-separator="至"
  32. start-placeholder="开始日期"
  33. end-placeholder="结束日期"
  34. format="yyyy-MM-dd"
  35. value-format="yyyy-MM-dd"
  36. />
  37. </el-form-item>
  38. </el-form>
  39. <div class="search-button">
  40. <el-button
  41. size="medium"
  42. type="primary"
  43. style="height:36px;width:100px;"
  44. @click="search"
  45. >搜索</el-button
  46. >
  47. <el-button
  48. @click="refresh"
  49. size="medium"
  50. style="margin-left:20px;height:36px;width:100px;"
  51. >重置</el-button
  52. >
  53. </div>
  54. </div>
  55. <!-- 列表 -->
  56. <div class="content">
  57. <el-table
  58. v-loading="loading"
  59. ref="singleTable"
  60. :data="tableData"
  61. border
  62. style="width: 100%"
  63. >
  64. <el-table-column align="center" type="index" label="序号" width="50" />
  65. <el-table-column align="center" property="avatar" label="头像">
  66. <template slot-scope="scope">
  67. <div>
  68. <img style="width: 50px;height: 50px;" :src="scope.row.avatar" alt="" />
  69. </div>
  70. </template>
  71. </el-table-column>
  72. <el-table-column align="center" property="nickName" label="昵称">
  73. <template slot-scope="scope">
  74. <div>
  75. <span>{{ scope.row.nickName }}</span>
  76. <i
  77. style="float: right;font-size:14px;"
  78. @click="handleEditNickName(scope.row)"
  79. class="el-icon-edit-outline"
  80. ></i>
  81. </div>
  82. </template>
  83. </el-table-column>
  84. <el-table-column align="center" property="code" label="编号">
  85. <template slot-scope="scope">
  86. <div>
  87. <span>{{ scope.row.code }}</span>
  88. <i
  89. style="float: right;font-size:14px;"
  90. @click="handleEditCode(scope.row)"
  91. class="el-icon-edit-outline"
  92. ></i>
  93. </div>
  94. </template>
  95. </el-table-column>
  96. <el-table-column
  97. align="center"
  98. property="phonenumber"
  99. label="联系电话"
  100. />
  101. <el-table-column
  102. align="center"
  103. property="createTime"
  104. label="注册时间"
  105. />
  106. <el-table-column align="center" property="level" label="用户等级">
  107. <template slot-scope="scope">
  108. {{ levelormat(scope.row) }}
  109. </template>
  110. </el-table-column>
  111. <el-table-column align="center" property="remark" label="备注">
  112. <template slot-scope="scope">
  113. <div>
  114. <span>{{ scope.row.remark }}</span>
  115. <i
  116. style="float: right;font-size:14px;"
  117. @click="handleEditRemark(scope.row)"
  118. class="el-icon-edit-outline"
  119. ></i>
  120. </div>
  121. </template>
  122. </el-table-column>
  123. <el-table-column align="center" label="操作">
  124. <template slot-scope="scope">
  125. <el-button type="text" size="mini" @click="handleEdit(scope.row)"
  126. >修改等级</el-button
  127. >
  128. <el-button type="text" size="mini" @click="handleInfo(scope.row)"
  129. >完善信息</el-button
  130. >
  131. </template>
  132. </el-table-column>
  133. </el-table>
  134. <pagination
  135. v-show="total > 0"
  136. :total="total"
  137. :page.sync="queryParams.pageNum"
  138. :limit.sync="queryParams.pageSize"
  139. @pagination="queryUserInfo"
  140. />
  141. </div>
  142. <!-- 修改表单 -->
  143. <el-dialog :title="dialog.title" :visible.sync="dialog.Visible" @open=openDialog center :width="type=='userInfo'?'690px':'350px'">
  144. <el-form :model="form" :inline="true">
  145. <div v-if="type == 'level'">
  146. <el-form-item label="客户昵称:" style="width:100%">
  147. <span>{{ data.nickName }}</span>
  148. </el-form-item>
  149. <el-form-item label="客户等级:" style="width:100%">
  150. <span>{{ levelormat(data) }}</span>
  151. </el-form-item>
  152. <el-form-item label="修改为:" style="width:100%">
  153. <el-select v-model="form.level" placeholder="请选择客户等级">
  154. <el-option
  155. v-for="(item,index) in level"
  156. :key="index"
  157. :label="item.dictLabel"
  158. :value="item.dictValue"
  159. />
  160. </el-select>
  161. </el-form-item>
  162. </div>
  163. <div v-if="type == 'userInfo'" style="display:flex;flex-direction: column;width:100%">
  164. <el-form-item label="简介">
  165. <el-input style="width:100%" type="textarea" :rows="5" v-model="form.introduction" placeholder="请输入用户简介" />
  166. </el-form-item>
  167. <el-form-item label="封面信息">
  168. <!-- <el-input v-model="form.coverImgs" clearable placeholder="请输入客户编号" /> -->
  169. <div v-for="(item, l) in dataImg" :key="l" class="imgdata" style="margin-left:10px;">
  170. <el-image style="width: 146px; height: 146px" :src="item" fit="fill">
  171. </el-image>
  172. <div class="imgdialog">
  173. <p>
  174. <i
  175. class="el-icon-delete"
  176. @click="delDataImg(item, l)"
  177. style="font-size: 20px;"
  178. ></i>
  179. </p>
  180. </div>
  181. </div>
  182. <el-upload
  183. class="avatar-uploader"
  184. style="float:left;margin-left: 10px;"
  185. action list-type="picture-card"
  186. :show-file-list="false"
  187. :http-request="changeImgs"
  188. element-loading-text="正在上传..."
  189. v-loading="loadingOtherImg">
  190. <i class="el-icon-plus"></i>
  191. </el-upload>
  192. </el-form-item>
  193. <el-progress :percentage="jinduOtherImgNum" v-if="jinduShowOtherImg" status="success"></el-progress>
  194. </div>
  195. <div v-if="type == 'code'">
  196. <el-form-item label="客户编号">
  197. <el-input v-model="form.code" clearable placeholder="请输入客户编号" />
  198. </el-form-item>
  199. </div>
  200. <div v-if="type == 'nickName'">
  201. <el-form-item label="昵称">
  202. <el-input v-model="form.nickName" clearable placeholder="请输入昵称" />
  203. </el-form-item>
  204. </div>
  205. <div v-if="type == 'remark'">
  206. <el-form-item label="备注">
  207. <el-input
  208. style="width:100%"
  209. type="textarea"
  210. :rows="5"
  211. v-model="form.remark"
  212. placeholder="请输入备注"
  213. />
  214. </el-form-item>
  215. </div>
  216. </el-form>
  217. <div slot="footer" class="dialog-footer">
  218. <el-button @click="dialog.Visible = false"> </el-button>
  219. <el-button type="primary" @click="subMit"> </el-button>
  220. </div>
  221. </el-dialog>
  222. </div>
  223. </template>
  224. <script>
  225. import { queryUserInfo, updateUserInfo } from "@/api/user/user.js";
  226. import { uploadFile, delFile } from "@/api/upload/upload.js";
  227. export default {
  228. data() {
  229. return {
  230. loadingOtherImg:false,//完善信息中封面图片加载圈
  231. jinduOtherImgNum:0,//完善信息中封面图片进度
  232. jinduShowOtherImg:false,//进度条显示
  233. dataImg:[],//多个封面图片
  234. loading: true,
  235. queryParams: {
  236. pageNum: 1,
  237. pageSize: 10,
  238. query: {
  239. nickName: undefined,
  240. code: undefined,
  241. phonenumber: undefined,
  242. userType: '02',
  243. params: {
  244. beginTime: undefined,
  245. endTime: undefined
  246. }
  247. },
  248. },
  249. time: [],
  250. total: 0,
  251. tableData: [],
  252. form: {
  253. userId: "",
  254. nickName:'',//昵称
  255. code:'',//编号
  256. remark:'',//备注
  257. introduction:'',//完善信息中的简介
  258. dataImg:[],//完善信息中的图片
  259. },
  260. dialog: {
  261. Visible: false,
  262. title: ""
  263. },
  264. level: [],
  265. data: {},
  266. type: "level"
  267. };
  268. },
  269. created() {
  270. this.getDicts("jbs_dm_user_level").then(res => {
  271. this.level = res.data;
  272. });
  273. },
  274. mounted() {
  275. this.queryUserInfo();
  276. },
  277. methods: {
  278. //获取用户
  279. async queryUserInfo() {
  280. this.loading = true;
  281. try {
  282. let res = await queryUserInfo(this.queryParams);
  283. if (res.code == 200) {
  284. this.loading = false;
  285. this.tableData = res.rows;
  286. this.total = res.total;
  287. }
  288. } catch (err) {
  289. }
  290. },
  291. //搜索
  292. search() {
  293. if (this.time != null) {
  294. if (this.time.length > 0) {
  295. this.queryParams.query.params.beginTime = this.time[0];
  296. this.queryParams.query.params.endTime = this.time[1];
  297. }
  298. } else {
  299. this.time = [];
  300. this.queryParams.query.params.beginTime = undefined;
  301. this.queryParams.query.params.endTime = undefined;
  302. }
  303. this.queryUserInfo()
  304. },
  305. //重置
  306. refresh() {
  307. this.time = []
  308. this.queryParams = {
  309. pageNum: 1,
  310. pageSize: 10,
  311. query: {
  312. nickName: undefined,
  313. code: undefined,
  314. phonenumber: undefined,
  315. userType: '02',
  316. },
  317. params: {
  318. beginTime: undefined,
  319. endTime: undefined
  320. }
  321. }
  322. this.queryUserInfo()
  323. },
  324. // 任务组名字典翻译
  325. levelormat(row, column) {
  326. return this.selectDictLabel(this.level, row.level);
  327. },
  328. // 编辑用户等级
  329. handleEdit(row) {
  330. // this.form = {}
  331. this.dialog.Visible = true;
  332. this.dialog.title = "修改用户等级";
  333. this.type = "level";
  334. this.form.userId = row.userId;
  335. this.data = row;
  336. },
  337. //弹窗回显
  338. openDialog(){
  339. //昵称回显
  340. if(this.type == 'nickName'){
  341. console.log(this.data.nickName);
  342. console.log('昵称');
  343. this.form.nickName = this.data.nickName;
  344. }
  345. //编号回显
  346. if(this.type == 'code'){
  347. console.log(this.data.code);
  348. console.log('编号');
  349. this.form.code = this.data.code;
  350. }
  351. //备注回显
  352. if(this.type == 'remark'){
  353. console.log(this.data.remark);
  354. console.log('备注');
  355. this.form.remark = this.data.remark;
  356. console.log('21',this.form.remark);
  357. }
  358. //完善信息回显
  359. if(this.type=='userInfo'){
  360. this.form.introduction = this.data.introduction; //简介回显
  361. if(this.data.coverImgs){
  362. this.dataImg = this.data.coverImgs.split(',');//回显图片
  363. }else{
  364. this.dataImg='';
  365. }
  366. }
  367. },
  368. //完善信息
  369. handleInfo(row){
  370. // this.form = {}
  371. this.dialog.Visible = true;
  372. this.dialog.title = "完善用户信息";
  373. this.type = "userInfo";
  374. this.form.userId = row.userId;
  375. // this.form.introduction = row.introduction;
  376. this.data = row;
  377. },
  378. //完善信息中的封面图片上传
  379. changeImgs({ file }) {
  380. this.loadingOtherImg = true; //显示加载
  381. this.jinduOtherImgNum = 0;//进度条从0开始
  382. this.jinduShowOtherImg = true; //是否显示进度条
  383. let formData = new FormData();
  384. formData.append("file", file);
  385. formData.append("type", "product");
  386. uploadFile(formData).then(res => {
  387. this.dataImg.push(res.data.wjUrl);
  388. this.loadingOtherImg = false; //显示加载
  389. clearInterval(this.videoTime); //清除定时器
  390. this.videoTime = null; //清除定时器
  391. this.successVideo('otherImg'); //
  392. });
  393. let videoJindu1 = setTimeout(() => {
  394. this.jinduVideoNum = 30;
  395. }, 500);
  396. let videoJindu2 = setTimeout(() => {
  397. videoJindu1
  398. this.jinduVideoNum = 80;
  399. }, 1000);
  400. this.videoTime = setTimeout(() => {
  401. videoJindu2
  402. this.jinduVideoNum = 90;
  403. }, 1500);
  404. },
  405. successVideo(type){
  406. console.log('上传成功');
  407. switch (type) {
  408. case 'otherImg': //其他图片
  409. this.jinduOtherImgNum = 100;
  410. setTimeout(() => {
  411. this.jinduShowOtherImg = false;
  412. }, 1200);
  413. break;
  414. }
  415. },
  416. //完善信息中的封面图片删除
  417. delDataImg(item, index) {
  418. this.$confirm("此操作将永久删除图片,是否继续?", "提示", {
  419. confirmButtonText: "确定",
  420. cancelButtonText: "取消",
  421. type: "warning"
  422. })
  423. .then(() => {
  424. this.dataImg.splice(index, 1);
  425. delFile({ wjUrl: item }).then(res => {
  426. if (res.code == 200) {
  427. this.$message.success("删除成功");
  428. }
  429. });
  430. // this.$message({
  431. // type: "success",
  432. // message: "删除成功!"
  433. // });
  434. })
  435. .catch(() => {
  436. this.$message({
  437. type: "error",
  438. message: "已取消删除"
  439. });
  440. });
  441. },
  442. //编辑用户编号
  443. handleEditCode(row) {
  444. // this.form = {}
  445. this.dialog.Visible = true;
  446. this.dialog.title = "修改用户编号";
  447. this.form.userId = row.userId;
  448. this.type = "code";
  449. this.data = row;
  450. },
  451. //编写用户昵称
  452. handleEditNickName(row){
  453. // this.form = {}
  454. this.dialog.Visible = true;
  455. this.dialog.title = "修改昵称";
  456. this.form.userId = row.userId;
  457. this.type = "nickName";
  458. this.data = row;
  459. },
  460. //编辑客户备注
  461. handleEditRemark(row) {
  462. // this.form = {}
  463. this.dialog.Visible = true;
  464. this.dialog.title = "修改用户备注";
  465. this.form.userId = row.userId;
  466. this.type = "remark";
  467. this.data = row;
  468. },
  469. //提交表单
  470. async subMit() {
  471. if(this.type == "level"){
  472. if(this.form.level == undefined || this.form.level == ''){
  473. this.$message({
  474. message: '请选择用户等级',
  475. type: "error"
  476. });
  477. return false;
  478. }
  479. }
  480. if(this.type == "userInfo"){
  481. if(this.form.introduction == undefined || this.form.introduction == ''){
  482. this.$message({
  483. message: '请填写完善用户信息',
  484. type: "error"
  485. });
  486. return false;
  487. }
  488. }
  489. if(this.type == "nickName"){
  490. if(this.form.nickName == undefined || this.form.nickName == ''){
  491. this.$message({
  492. message: '请输入用户昵称',
  493. type: "error"
  494. });
  495. return false;
  496. }
  497. }
  498. if(this.type == "code"){
  499. if(this.form.code == undefined || this.form.code == ''){
  500. this.$message({
  501. message: '请输入用户编号',
  502. type: "error"
  503. });
  504. return false;
  505. }
  506. }
  507. if(this.type == "remark"){
  508. if(this.form.remark == undefined || this.form.remark == ''){
  509. this.$message({
  510. message: '请输入用户备注',
  511. type: "error"
  512. });
  513. return false;
  514. }
  515. }
  516. try {
  517. this.form.coverImgs = this.dataImg.join(",");
  518. let res = await updateUserInfo(this.form);
  519. if (res.code == 200) {
  520. this.$message.success("修改成功");
  521. this.dialog.Visible = false;
  522. this.queryUserInfo();
  523. }
  524. } catch (err) {
  525. }
  526. }
  527. }
  528. };
  529. </script>
  530. <style lang='scss' scoped>
  531. .content {
  532. background: #fff;
  533. margin-top: 15px;
  534. }
  535. .add-button {
  536. margin-top: 15px;
  537. }
  538. .search-button {
  539. display: flex;
  540. }
  541. .imgdata {
  542. position: relative;
  543. // display: inline-block;
  544. float: left;
  545. margin-left: 60px;
  546. .imgdialog {
  547. width: 146px;
  548. height: 146px;
  549. display: none;
  550. position: absolute;
  551. background: rgba(127, 127, 127, 0.5);
  552. top: 0;
  553. left: 0;
  554. justify-content: space-between;
  555. align-content: center;
  556. p {
  557. margin: auto;
  558. i {
  559. cursor: pointer;
  560. color: white;
  561. }
  562. }
  563. }
  564. }
  565. .imgdata:hover .imgdialog {
  566. display: flex !important;
  567. }
  568. ::v-deep .el-form-item__content{
  569. width: 100%;
  570. }
  571. </style>