UserManage.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. <template>
  2. <div>
  3. <div class="headerRow headerRowLeftRight">
  4. <div class="headerRow">
  5. <el-input placeholder="请输入用户名或账号搜索" v-model="searchKeyLin" @keyup.enter.native="onSubmit" style="width: 260px">
  6. <el-button slot="append" icon="el-icon-search" @click="onSubmit"></el-button>
  7. </el-input>
  8. <el-select v-model="value" @change="onSubmit" placeholder="用户状态" style="width: 120px" class="mrl">
  9. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
  10. </el-option>
  11. </el-select>
  12. <el-select v-model="groupValue" @change="onSubmit" placeholder="年级选择" style="width: 120px" class="mrl">
  13. <el-option v-for="item in groupOptions" :key="item.id" :label="item.groupName" :value="item.id">
  14. </el-option>
  15. </el-select>
  16. <el-button class="ml10" icon="el-icon-refresh" @click="reset"></el-button>
  17. <el-button class="ml10" type="primary" icon="el-icon-plus" @click="exportUser">批量导入</el-button>
  18. <el-button v-if="systemVersion != 'lan'" class="ml10" type="primary" icon="el-icon-s-check"
  19. @click="allUserCheck">一键审核</el-button>
  20. </div>
  21. </div>
  22. <el-table :data="tableData" border style="width: 100%; margin-top: 20px">
  23. <el-table-column prop="petName" label="用户名称" align="center">
  24. </el-table-column>
  25. <el-table-column prop="phone" label="账号" width="auto" align="center">
  26. </el-table-column>
  27. <el-table-column prop="gender" label="性别" align="center" :formatter="sexFormat"></el-table-column>
  28. <el-table-column prop="birthday" label="生日" width="auto" align="center">
  29. </el-table-column>
  30. <!-- <el-table-column prop="institutionName" label="所属学校" width="auto" align="center">
  31. </el-table-column> -->
  32. <el-table-column prop="profession" label="职业" align="center">
  33. </el-table-column>
  34. <el-table-column prop="gid" label="年级名称" align="center">
  35. </el-table-column>
  36. <el-table-column prop="userStatus" label="用户状态" align="center" :formatter="statusFormat">
  37. </el-table-column>
  38. <el-table-column label="操作" width="300px" align="center">
  39. <!-- <template slot-scope="scope">-->
  40. <!-- <el-button type="primary" v-if="scope.row.userStatus=='1'" size="small" @click="editUser(scope.row)">审核通过-->
  41. <!-- </el-button>-->
  42. <!-- </template>-->
  43. <template slot-scope="scope">
  44. <!-- <el-button
  45. type="primary"
  46. size="small"
  47. @click="getUserInfoDetail(scope.row)"
  48. style="margin-top: 10px"
  49. >查看详情
  50. </el-button> -->
  51. <el-button type="primary" size="small" @click="handleResetPwd(scope.$index, scope.row)">重置密码
  52. </el-button>
  53. <!-- <el-dialog title="重置密码" :visible.sync="personalSecurityDialog" width="40%">-->
  54. <!-- <el-form :model="updatePersonalSecurity" status-icon :rules="personalSecurityRules" ref="ruleFormSecurity">-->
  55. <!-- <el-form-item label="输入密码:" prop="userpwd">-->
  56. <!-- <el-input type="password" v-model="updatePersonalSecurity.userpwd" autocomplete="off"-->
  57. <!-- style="width: 50%"></el-input>-->
  58. <!-- </el-form-item>-->
  59. <!-- <el-form-item label="确认密码:" prop="checkPass">-->
  60. <!-- <el-input type="password" v-model="updatePersonalSecurity.checkPass" autocomplete="off"-->
  61. <!-- style="width: 50%"></el-input>-->
  62. <!-- </el-form-item>-->
  63. <!-- <el-form-item>-->
  64. <!-- <el-button type="primary" @click="handleEditSecurity('ruleFormSecurity')">提交</el-button>-->
  65. <!-- <el-button @click="resetFormForPersonalSecurity('ruleFormSecurity')">取消</el-button>-->
  66. <!-- </el-form-item>-->
  67. <!-- </el-form>-->
  68. <!-- </el-dialog>-->
  69. <el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)">删除
  70. </el-button>
  71. <el-button type="primary" v-if="scope.row.userStatus != '2' && scope.row.userStatus != '4'" size="small"
  72. @click="editUser(scope.row)">审核通过
  73. </el-button>
  74. </template>
  75. <!-- &lt;!&ndash;<template slot-scope="scope">-->
  76. <!-- &lt;!&ndash; <el-popconfirm-->
  77. <!-- confirm-button-text='确定'-->
  78. <!-- cancel-button-text='取消'-->
  79. <!-- icon="el-icon-info"-->
  80. <!-- icon-color="red"-->
  81. <!-- title="你确定要删除此签名信息吗?"-->
  82. <!-- >-->
  83. <!-- <el-button slot="reference" type="text" @click="deleteUser(scope.$index,scope.row)" class="button-table-font">删除</el-button>-->
  84. <!-- </el-popconfirm> &ndash;&gt;-->
  85. <!-- <el-button type="text" v-if="scope.row.userStatus=='1'" size="small" @click="editUser(scope.row)">审核通过</el-button>-->
  86. <!-- </template>&ndash;&gt;-->
  87. </el-table-column>
  88. </el-table>
  89. <div class="txt-center" style="margin-top: 20px">
  90. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
  91. :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
  92. :total="total">
  93. </el-pagination>
  94. </div>
  95. <el-dialog :title="addUserEditFlag" :visible.sync="addUser" width="40%" center :close-on-click-modal="false">
  96. <el-row :gutter="24">
  97. <el-col :span="24">
  98. <el-form :inline="true" :model="ruleForm" label-position="left" :rules="rules" ref="ruleForm"
  99. class="demo-form-inline demo-ruleForm">
  100. <el-row :gutter="24">
  101. <el-col :span="12">
  102. <el-form-item label="签字" prop="signature">
  103. <el-input v-model="ruleForm.signature" placeholder="签字"></el-input>
  104. </el-form-item>
  105. </el-col>
  106. <el-col :span="12">
  107. <el-form-item label="签名类型" prop="type">
  108. <el-select v-model="ruleForm.type" placeholder="请选择签名">
  109. <el-option label="报告签名" value="report"></el-option>
  110. <el-option label="审核签名" value="audit"></el-option>
  111. </el-select>
  112. </el-form-item>
  113. </el-col>
  114. </el-row>
  115. <!-- <el-row :gutter="24">
  116. <el-col :span="12"> -->
  117. <el-form-item label="请选择签名照" prop="signature">
  118. <el-upload class="avatar-uploader" action="https://jsonplaceholder.typicode.com/posts/"
  119. :show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
  120. <img v-if="imageUrl" :src="imageUrl" class="avatar" />
  121. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  122. </el-upload>
  123. </el-form-item>
  124. <!-- </el-col>
  125. </el-row> -->
  126. </el-form>
  127. </el-col>
  128. </el-row>
  129. <span slot="footer" class="dialog-footer">
  130. <el-row :gutter="20">
  131. <el-col :span="2">
  132. <div class="grid-content bg-purple"></div>
  133. </el-col>
  134. <el-col :span="6">
  135. <div class="grid-content bg-purple">
  136. <el-button type="primary" @click="addUser = false">确 定</el-button>
  137. </div>
  138. </el-col>
  139. <el-col :span="4">
  140. <div class="grid-content bg-purple"></div>
  141. </el-col>
  142. <el-col :span="4">
  143. <div class="grid-content bg-purple"></div>
  144. </el-col>
  145. <el-col :span="6">
  146. <div class="grid-content bg-purple">
  147. <el-button @click="addUser = false">取 消</el-button>
  148. </div>
  149. </el-col>
  150. </el-row>
  151. </span>
  152. </el-dialog>
  153. <!-- 批量导入 -->
  154. <el-dialog :close-on-click-modal="false" title="批量导入" :visible.sync="dialogTableVisible">
  155. <el-upload class="txt-center" :action="uploadUrl" multiple :before-upload="uploadVa" :limit="3"
  156. :show-file-list="false" :on-success="uploadSuccess" :on-error="uploadFail" :file-list="fileList" :data="{
  157. institutionNo: institutionNo,
  158. userId:createUserId,
  159. }">
  160. <el-button size="small" type="primary">点击上传</el-button>
  161. <div slot="tip" class="el-upload__tip">请上传.xls,.xlsx类型的文件</div>
  162. </el-upload>
  163. <div class="mt20 txt-center" @click="downloadTemplete">
  164. <el-link type="primary">点击下载模板</el-link>
  165. </div>
  166. <el-table v-if="userList.length > 0" :data="userList">
  167. <el-table-column property="date" label="日期" width="150"></el-table-column>
  168. <el-table-column property="name" label="姓名" width="200"></el-table-column>
  169. <el-table-column property="address" label="地址"></el-table-column>
  170. </el-table>
  171. </el-dialog>
  172. </div>
  173. </template>
  174. <script>
  175. export default {
  176. name: "UserInfoDetail",
  177. data() {
  178. let validatePass = (rule, value, callback) => {
  179. if (value === "") {
  180. callback(new Error("请输入密码"));
  181. } else {
  182. if (this.updatePersonalSecurity.checkPass !== "") {
  183. this.$refs.ruleFormSecurity.validateField("checkPass");
  184. }
  185. callback();
  186. }
  187. };
  188. let validatePass2 = (rule, value, callback) => {
  189. if (value === "") {
  190. callback(new Error("请再次输入密码"));
  191. } else if (value !== this.updatePersonalSecurity.userpwd) {
  192. callback(new Error("两次输入密码不一致!"));
  193. } else {
  194. callback();
  195. }
  196. };
  197. return {
  198. systemVersion: process.env.VUE_APP_VERSION,
  199. //年级过滤条件
  200. groupValue: "",
  201. //年级信息
  202. groupOptions: [],
  203. searchKeyLin: "", //查询条件
  204. searchKey: "", //查询条件
  205. institutionNo: "", //学校编码
  206. moreUser: false,
  207. addUser: false,
  208. addUserEditFlag: "",
  209. imageUrl: "",
  210. formInline: {
  211. user: "",
  212. region: "",
  213. },
  214. ruleForm: {
  215. signature: "", //签字
  216. type: "", //签名类型
  217. },
  218. options: [
  219. {
  220. value: "2",
  221. label: "已审核",
  222. },
  223. {
  224. value: "1",
  225. label: "未审核",
  226. },
  227. {
  228. value: "3",
  229. label: "待登录",
  230. },
  231. {
  232. value: "4",
  233. label: "待补充",
  234. },
  235. ],
  236. value: "",
  237. currentPage: 1,
  238. total: 0,
  239. pageSize: 10,
  240. createUserId: '',
  241. updatePersonalSecurity: {},
  242. rules: {
  243. signature: [
  244. { required: true, message: "请输入被监护人", trigger: "blur" },
  245. { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
  246. ],
  247. type: [{ required: true, message: "请输入手机号", trigger: "blur" }],
  248. },
  249. tableData: [],
  250. personalSecurityDialog: false,
  251. personalSecurityRules: {
  252. userpwd: [{ validator: validatePass, trigger: "blur" }],
  253. checkPass: [{ validator: validatePass2, trigger: "blur" }],
  254. },
  255. dialogTableVisible: false,
  256. userList: [],
  257. fileList: [],
  258. uploadUrl: baseUrl + "/userImport",
  259. };
  260. },
  261. created() {
  262. this.institutionNo = sessionStorage.getItem(
  263. "f7a42fe7211f98ac7a60a285ac3a9527"
  264. );
  265. this.createUserId = sessionStorage.getItem(
  266. "b80bb7740288fda1f201890375a60c8f"
  267. );
  268. this.getData();
  269. this.groupFun();
  270. },
  271. methods: {
  272. //查询年级信息
  273. groupFun() {
  274. this.$http.get(
  275. // "/group/find?institutionNo=" + this.institutionNo,
  276. `/group/find?institutionNo=${this.institutionNo}&userId=${this.createUserId}`,
  277. {},
  278. (response) => {
  279. this.groupOptions = response.data;
  280. // this.tableData = response.data;
  281. // console.log(response.data)
  282. }
  283. );
  284. },
  285. uploadVa(file) {
  286. console.log(file);
  287. let q = file.name.split(".");
  288. if (!(q[1] === "xls" || q[1] === "xlsx")) {
  289. this.$message.error("请选择xls或xlsx");
  290. return false;
  291. }
  292. },
  293. sexFormat(row) {
  294. if (row.gender == 0) {
  295. return "男";
  296. } else {
  297. return "女";
  298. }
  299. },
  300. PersonalSecurityJump() {
  301. this.updatePersonalSecurity = {};
  302. this.personalSecurityDialog = true;
  303. },
  304. handleDelete(index, row) {
  305. this.$confirm("您确定要删除吗?", "提示", {
  306. confirmButtonText: "确定",
  307. cancelButtonText: "取消",
  308. type: "warning",
  309. }).then(() => {
  310. //delete方法不用$qs就可以,按照下面的方法传参即可
  311. this.$http.post(`/user/delete/${row.id}`, {}, (res) => {
  312. if (res.code == 200) {
  313. this.$message({
  314. type: "success",
  315. message: "删除成功!",
  316. });
  317. this.getData();
  318. } else {
  319. this.$message({
  320. type: "info",
  321. message: "未成功删除",
  322. });
  323. }
  324. });
  325. });
  326. },
  327. handleResetPwd(index, row) {
  328. // this.$refs[formName].validate((valid) => {
  329. // if (valid) {
  330. // this.$confirm('您确定要提交, 是否继续?', '提示', {
  331. // confirmButtonText: '确定',
  332. // cancelButtonText: '取消',
  333. // type: 'warning'
  334. // }).then(() => {
  335. // //delete方法不用$qs就可以,按照下面的方法传参即可
  336. // this.$refs[formName].validate((valid) => {
  337. // if (valid) {
  338. //
  339. // this.$http.post(`/user/resetPassword`,
  340. // this.updatePersonalSecurity
  341. // ).then(response => {
  342. // if (response.data.code == 200) {
  343. // this.$message({
  344. // type: 'success',
  345. // message: '重置成功!'
  346. //
  347. // });
  348. // this.personalSecurityDialog = false;
  349. // this.getData()
  350. // }
  351. // })
  352. // } else {
  353. // console.log('error submit!!');
  354. // this.arrangeClassDialog = false;
  355. // return false;
  356. // }
  357. // });
  358. //
  359. // }).catch(() => {
  360. // this.$message({
  361. // type: 'info',
  362. // message: '重置失败'
  363. // });
  364. // });
  365. //
  366. //
  367. // } else {
  368. // console.log('error submit!!');
  369. // return false;
  370. // }
  371. // });
  372. this.$confirm("您确定要重置该用户的密码吗?", "提示", {
  373. confirmButtonText: "确定",
  374. cancelButtonText: "取消",
  375. type: "warning",
  376. }).then(() => {
  377. //delete方法不用$qs就可以,按照下面的方法传参即可
  378. this.$http.post(`user/resetPassword/${row.id}`, {}, (res) => {
  379. if (res.code == 200) {
  380. this.$message({
  381. type: "success",
  382. message: "重置成功!重置后密码为:123456",
  383. });
  384. this.getData();
  385. } else {
  386. this.$message({
  387. type: "error",
  388. message: "重置失败",
  389. });
  390. }
  391. });
  392. });
  393. },
  394. resetFormForPersonalSecurity() {
  395. // this.$refs[formName].resetField();
  396. this.updatePersonalSecurity = {};
  397. this.personalSecurityDialog = false;
  398. },
  399. // 刷新列表
  400. reset() {
  401. this.currentPage = 1;
  402. this.searchKey = "";
  403. this.value = "";
  404. this.groupValue = "";
  405. this.getData();
  406. },
  407. // 批量导入用户
  408. exportUser() {
  409. this.dialogTableVisible = true;
  410. },
  411. // 批量导入成功
  412. uploadSuccess(res) {
  413. this.reset();
  414. // this.$message.success(res.msg);
  415. // window.location.href = `${baseUrl}/download/userImportResult?filePath=${res.data}`;
  416. this.getData();
  417. //部分未成功也会在此提示
  418. this.$alert(`${res.msg}`, '提示', {
  419. confirmButtonText: '确定',
  420. type: 'warning',
  421. center: true,
  422. callback: action => {
  423. // this.$message({
  424. // type: 'info',
  425. // message: `action: ${ action }`
  426. // });
  427. }
  428. });
  429. },
  430. // 批量导入失败
  431. uploadFail(res) {
  432. // this.$message.error(res.msg);
  433. this.$alert(`${res.msg}`, '提示', {
  434. confirmButtonText: '确定',
  435. type: 'error',
  436. center: true,
  437. callback: action => {
  438. // this.$message({
  439. // type: 'info',
  440. // message: `action: ${ action }`
  441. // });
  442. }
  443. });
  444. },
  445. // 下载模板
  446. downloadTemplete() {
  447. window.location.href = `${baseUrl}/download/userTemplateDownload`;
  448. },
  449. statusFormat(row) {
  450. if (row.userStatus == 2) {
  451. return "已审核";
  452. } else if (row.userStatus == 1) {
  453. return "未审核";
  454. } else if (row.userStatus == 3) {
  455. return "待登录";
  456. } else if (row.userStatus == 4) {
  457. return "待补充";
  458. } else {
  459. return "--";
  460. }
  461. },
  462. handleCurrentChange(val) {
  463. this.currentPage = val;
  464. this.getData();
  465. },
  466. handleSizeChange(val) {
  467. this.pageSize = val;
  468. this.getData();
  469. },
  470. //lxh 用户信息
  471. getUserInfoDetail(row) {
  472. this.$router.push({
  473. path: "/ContainerSys/UserInfoDetail",
  474. query: {
  475. phone: row.phone,
  476. },
  477. });
  478. },
  479. //编辑用户
  480. editUser(row) {
  481. this.$http.get(
  482. "/user/updateStatus?bid=" + row.id + "&status=2",
  483. {},
  484. () => {
  485. this.getData();
  486. this.$message({
  487. type: "success",
  488. message: "操作成功!",
  489. });
  490. }
  491. );
  492. // this.addUser=true;
  493. // //设置标题
  494. // this.addUserEditFlag="编辑用户";
  495. // //1.点击编辑先置空
  496. // this.ruleForm=[];
  497. // //2.接下来进行赋值
  498. },
  499. //一键审核所有用户
  500. allUserCheck() {
  501. this.$confirm('此操作将所有待审核用户一键通过审核, 是否继续?', '提示', {
  502. confirmButtonText: '确定',
  503. cancelButtonText: '取消',
  504. type: 'warning'
  505. }).then(() => {
  506. this.$http.get("/user/updateStatusAll?institutionNo=" + this.institutionNo, {}, (res) => {
  507. if (res && res.code == '200') {
  508. this.getData();
  509. this.$message({
  510. type: "success",
  511. message: "一键审核成功!",
  512. });
  513. } else {
  514. this.$message({
  515. type: "error",
  516. message: "一键审核失败!",
  517. });
  518. }
  519. });
  520. // this.$message({
  521. // type: 'success',
  522. // message: '审核成功!'
  523. // });
  524. }).catch(() => {
  525. this.$message({
  526. type: 'info',
  527. message: '已取消审核'
  528. });
  529. });
  530. },
  531. //添加单个用户
  532. // addSingleUser(){
  533. // this.addUser=true;
  534. // //设置弹出框表题
  535. // this.addUserEditFlag="添加用户";
  536. // //1.点击添加先把之前填的置空
  537. // this.ruleForm=[];
  538. // },
  539. //删除用户
  540. deleteUser() { },
  541. handleAvatarSuccess(res, file) {
  542. this.imageUrl = URL.createObjectURL(file.raw);
  543. },
  544. beforeAvatarUpload(file) {
  545. const isJPG = file.type === "image/jpeg";
  546. const isLt2M = file.size / 1024 / 1024 < 2;
  547. if (!isJPG) {
  548. this.$message.error("上传头像图片只能是 JPG 格式!");
  549. }
  550. if (!isLt2M) {
  551. this.$message.error("上传头像图片大小不能超过 2MB!");
  552. }
  553. return isJPG && isLt2M;
  554. },
  555. getData() {
  556. this.searchKeyLin = this.searchKey;
  557. this.$http.get(
  558. "/user/getUserListByInstitutionNo?institutionNo=" +
  559. this.institutionNo +
  560. "&searchKey=" +
  561. this.searchKey +
  562. "&pageNum=" +
  563. this.currentPage +
  564. "&pageSize=" +
  565. this.pageSize +
  566. "&status=" +
  567. this.value +
  568. "&groupId=" +
  569. this.groupValue +
  570. "&userId=" +
  571. this.createUserId,
  572. {},
  573. (response) => {
  574. this.total = response.data.allNum;
  575. this.tableData = response.data.data;
  576. console.log(this.tableData);
  577. }
  578. );
  579. },
  580. onSubmit() {
  581. this.currentPage = 1;
  582. this.searchKey = this.searchKeyLin;
  583. //点击搜索时需要将值赋值给搜索的按钮
  584. this.getData();
  585. },
  586. },
  587. };
  588. </script>
  589. <style>
  590. .bg-purple-dark {
  591. background: white;
  592. }
  593. .grid-content {
  594. border-radius: 4px;
  595. min-height: 36px;
  596. }
  597. .mainTable {
  598. /*width: 80%;*/
  599. margin-top: 20px;
  600. }
  601. </style>