index.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  1. <!--学生管理-->
  2. <template>
  3. <div class="app-container student">
  4. <div v-if="pageType == 1" class="student-one-box">
  5. <el-form :model="queryParams" class="form-box" ref="queryForm" :inline="true" v-show="showSearch">
  6. <!--v-hasPermi="['laboratory:plan:add']"-->
  7. <el-form-item label="关键字" prop="searchValue" label-width="58px">
  8. <el-input
  9. maxLength="20"
  10. v-model="queryParams.searchValue"
  11. placeholder="姓名/学号/导师/电话"
  12. clearable
  13. size="small"
  14. style="width: 240px"
  15. />
  16. </el-form-item>
  17. <el-form-item label="专业" prop="majorId" label-width="60px">
  18. <el-select v-model="queryParams.majorId" clearable placeholder="请选择专业">
  19. <el-option
  20. v-for="item in professionOptions"
  21. :key="item.id"
  22. :label="item.majorName"
  23. :value="item.id">
  24. </el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="学院" prop="deptId" label-width="80px">
  28. <el-select v-model="queryParams.deptId" clearable placeholder="请选择学院">
  29. <el-option
  30. v-for="item in collegeOptions"
  31. :key="item.deptId"
  32. :label="item.deptName"
  33. :value="item.deptId">
  34. </el-option>
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="状态" prop="status" label-width="60px">
  38. <el-select v-model="queryParams.status" clearable placeholder="请选择状态">
  39. <el-option :key="0" label="启用" :value="0"></el-option>
  40. <el-option :key="1" label="停用" :value="1"></el-option>
  41. </el-select>
  42. </el-form-item>
  43. <el-form-item>
  44. <el-dropdown @command="importButton" v-hasPermi="['system:user_student:import']">
  45. <div class="form-dropdown-box">
  46. <img src="@/assets/ZDimages/personnelManagement/icon_jzgxx_dr.png">
  47. <p>导入</p>
  48. <img src="@/assets/ZDimages/personnelManagement/icon_jzggl_xljt.png">
  49. </div>
  50. <el-dropdown-menu slot="dropdown">
  51. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;color:#333;" :command="{command:1}" v-hasPermi="['system:user_student:exceltemplate']">下载模板</el-dropdown-item>
  52. <el-dropdown-item style="margin:0 10px;color:#666;" :command="{command:2}">导入数据</el-dropdown-item>
  53. </el-dropdown-menu>
  54. </el-dropdown>
  55. </el-form-item>
  56. <el-form-item>
  57. <el-dropdown @command="exportButton" v-hasPermi="['system:user_student:export']">
  58. <div class="form-dropdown-box">
  59. <img src="@/assets/ZDimages/personnelManagement/icon_jzgxx_sc.png">
  60. <p>导出</p>
  61. <img src="@/assets/ZDimages/personnelManagement/icon_jzggl_xljt.png">
  62. </div>
  63. <el-dropdown-menu slot="dropdown">
  64. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;color:#333;" :command="{command:1}">导出全部数据</el-dropdown-item>
  65. <el-dropdown-item style="margin:0 10px;color:#666;" :command="{command:2}">导出选中数据</el-dropdown-item>
  66. </el-dropdown-menu>
  67. </el-dropdown>
  68. </el-form-item>
  69. <el-form-item style="float: right;">
  70. <el-col :span="1.5" v-hasPermi="['system:user_student:add']">
  71. <p class="add-button-one-90"
  72. @click="addButton"
  73. ><i class="el-icon-plus"></i>新增</p>
  74. </el-col>
  75. </el-form-item>
  76. <el-form-item>
  77. <p class="inquire-button-one" @click="handleQuery">查询</p>
  78. <p class="reset-button-one" @click="resetQuery">重置</p>
  79. </el-form-item>
  80. </el-form>
  81. <el-table border :data="userList" @selection-change="handleSelectionChange" ref="multipleTable" :row-key="getRowKeys">
  82. <el-table-column type="selection" width="50" align="center"/>
  83. <el-table-column label="序号" width="50" align="center" type="index"/>
  84. <el-table-column label="姓名" align="left" prop="nickName"/>
  85. <el-table-column label="学号" align="left" prop="userName" width="180">
  86. <template slot-scope="scope">
  87. <div style="display: flex">
  88. <span style="flex:1;">{{scope.row.userName}}</span>
  89. <el-switch
  90. @click.native="changeIsNeedCaptcha(scope.row)"
  91. class="switch captcha-img"
  92. active-value="0"
  93. inactive-value="1"
  94. active-color="#0183FA"
  95. inactive-color="#999"
  96. v-model="scope.row.status"
  97. active-text="启用"
  98. inactive-text="停用"
  99. disabled
  100. ></el-switch>
  101. </div>
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="联系电话" align="left" prop="phonenumber" show-overflow-tooltip width="162"/>
  105. <el-table-column label="学院" align="left" prop="deptName" show-overflow-tooltip width="200"/>
  106. <el-table-column label="专业" align="left" prop="major" show-overflow-tooltip width="180"/>
  107. <el-table-column label="学生类别" align="left" prop="education" show-overflow-tooltip width="149"/>
  108. <el-table-column label="班级" align="center" prop="gradeName" show-overflow-tooltip width="100"/>
  109. <el-table-column label="导师" align="center" prop="tutorUserName" show-overflow-tooltip width="150"/>
  110. <el-table-column label="操作" align="left" width="160" class-name="small-padding fixed-width" v-if="tableButtonType">
  111. <template slot-scope="scope">
  112. <div class="button-box">
  113. <p class="table-min-button"
  114. style="margin-left:20px;"
  115. v-hasPermi="['system:user_student:query']"
  116. @click="infoButton(scope.row)"
  117. >详情</p>
  118. <el-dropdown @command="moreClick" v-hasPermi="['system:user_student:query','system:user_student:edit','system:user_student:remove','system:user_student:resetpwd']">
  119. <p class="table-min-button">更多>></p>
  120. <el-dropdown-menu slot="dropdown">
  121. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;" :command="{row:scope.row,command:1}"
  122. v-hasPermiAnd="['system:user_student:query','system:user_student:edit']">编辑</el-dropdown-item>
  123. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;" :command="{row:scope.row,command:2}"
  124. v-hasPermi="['system:user_student:remove']">删除</el-dropdown-item>
  125. <el-dropdown-item style="margin:0 10px;" :command="{row:scope.row,command:3}"
  126. v-hasPermi="['system:user_student:resetpwd']">重置密码</el-dropdown-item>
  127. </el-dropdown-menu>
  128. </el-dropdown>
  129. </div>
  130. </template>
  131. </el-table-column>
  132. </el-table>
  133. <div style="display: flex;height:32px;margin-top:15px;">
  134. <!--<p style="flex:4;"></p>-->
  135. <p style="text-align: left;margin:0;line-height:32px;margin-right:20px;font-size:14px;color:#999;">
  136. <i class="el-icon-warning" style="color:#0183FA;"></i>
  137. 已选择 {{selectedNum}} 项
  138. </p>
  139. <div style="flex:5;">
  140. <pagination
  141. v-show="total>0"
  142. :total="total"
  143. :page.sync="queryParams.pageNum"
  144. :limit.sync="queryParams.pageSize"
  145. @pagination="getList"
  146. />
  147. </div>
  148. </div>
  149. </div>
  150. <add-page v-if="pageType == 2" :editType="editType" :propsData="propsData" :titleName="titleName"></add-page>
  151. <!--重置密码-->
  152. <el-dialog title="重置密码" :visible.sync="reviseOpen" width="600px" append-to-body class="teacher-revise-dialog-box">
  153. <el-form :model="passwordForm" ref="passwordForm" :inline="true" :rules="rules" class="addCheckPage-min">
  154. <el-form-item label="新密码" prop="password" label-width="110px" >
  155. <el-input type="password" v-model="passwordForm.password" clearable maxlength="20" style="width:420px;" placeholder="请输入新密码"/>
  156. </el-form-item>
  157. <el-form-item label="确认新密码" prop="newPassword" label-width="110px">
  158. <el-input type="password" v-model="passwordForm.newPassword" clearable maxlength="20" style="width:420px;" placeholder="请确认新密码"/>
  159. </el-form-item>
  160. </el-form>
  161. <!--<p class="teacher-text-p">确定要重置该账号的密码吗?</p>-->
  162. <!--<p class="teacher-text-p">确定操作后,该账号密码将重置为系统初始密码。</p>-->
  163. <div slot="footer" class="teacher-revise-dialog-button-box">
  164. <p class="reset-button-one" @click="reviseOpenOff">取消</p>
  165. <p class="inquire-button-one" @click="putUserResetPwd">确定</p>
  166. </div>
  167. </el-dialog>
  168. <!--导入窗口-->
  169. <el-dialog title="导入数据" :visible.sync="importOpen" @close="importOpenOff" width="600px" append-to-body class="teacher-import-dialog-box">
  170. <el-upload
  171. class="teacher-import-dialog-upLoad-box"
  172. :drag="true"
  173. :data="upImportData"
  174. :action="uploadImgUrl"
  175. :show-file-list="false"
  176. :on-success="handleAvatarSuccess"
  177. :headers="headers"
  178. :before-upload="beforeAvatarUpload">
  179. <i class="el-icon-upload"></i>
  180. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  181. <div class="el-upload__tip" slot="tip">
  182. <el-checkbox v-model="upImportData.upDate">是否更新已经存在的用户数据</el-checkbox>
  183. </div>
  184. <div class="el-upload__tip" slot="tip">仅允许导入xls、xlsx、格式文件。<span style="color:#0183FA;cursor: pointer" v-hasPermi="['system:user_student:exceltemplate']" @click="importTemplate">下载模板</span></div>
  185. <div class="el-upload-text-box" slot="tip" v-if="getImportData.downFile">
  186. <div class="img-text-box">
  187. <img src="@/assets/ZDimages/personnelManagement/icon_dr_wj.png">
  188. <p>{{getImportData.textName}}</p>
  189. </div>
  190. <p class="text-p">数据导入成功 <span style="color:#0183FA;">{{getImportData.successNum}}</span> 条,失败 <span style="color:#FF6464 ;">{{getImportData.failureNum}}</span> 条</p>
  191. <div class="img-text-box">
  192. <img src="@/assets/ZDimages/personnelManagement/icon_dr_sj.png">
  193. <p style="color:#0183FA;cursor: pointer;" @click="failureExcel">点击下载失败数据报表</p>
  194. </div>
  195. </div>
  196. </el-upload>
  197. <div slot="footer" class="teacher-import-dialog-button-box">
  198. <p class="inquire-button-one" @click="importOpenOff">确定</p>
  199. </div>
  200. <div class="teacher-import-dialog-position-box" v-if="loading"></div>
  201. </el-dialog>
  202. </div>
  203. </template>
  204. <script>
  205. import { Message } from 'element-ui'
  206. import { listDepartments } from "@/api/system/dept";
  207. import { getAuthRole, updateAuthRole, resetUserPwd } from "@/api/system/user";
  208. import { listUser, getUser, delUser, addUser, updateUser, changeUserStatus,getListAll, putUserTeacher,putUserResetPwd,delUserInfo,getStudentInfo } from "@/api/system/user_student";
  209. import { optionUser } from "@/api/system/user_teacher";
  210. import { getToken } from "@/utils/auth";
  211. import { treeselect } from "@/api/system/dept";
  212. import {listMajorAll} from "@/api/system/major";
  213. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  214. import addPage from "./addPage.vue"
  215. export default {
  216. name: "User",
  217. components: {
  218. addPage
  219. },
  220. data() {
  221. const equalToPassword = (rule, value, callback) => {
  222. if (this.passwordForm.password !== value) {
  223. callback(new Error("两次输入的密码不一致"));
  224. } else {
  225. callback();
  226. }
  227. };
  228. return {
  229. tableButtonType:this.hasPermiDom(['system:user_student:query','system:user_student:query','system:user_student:edit','system:user_student:remove','system:user_student:resetpwd']),
  230. uploadImgUrl: window.location.href.split('://')[0]+'://' + process.env.VUE_APP_BASE_API + "/system/user/student/importData", // 上传地址
  231. headers: {
  232. Authorization: "Bearer " + getToken(),
  233. },
  234. //专业列表
  235. majorList:[],
  236. // 遮罩层
  237. loading: false,
  238. // 选中数组
  239. ids: [],
  240. // 非单个禁用
  241. single: true,
  242. // 非多个禁用
  243. multiple: true,
  244. // 显示搜索条件
  245. showSearch: true,
  246. // 总条数
  247. total: 0,
  248. // 用户表格数据
  249. userList: [],
  250. // 弹出层标题
  251. title: "",
  252. // 部门树选项
  253. deptOptions: undefined,
  254. //专业列表
  255. professionOptions:[],
  256. //学院列表
  257. collegeOptions:[],
  258. // 是否显示弹出层
  259. open: false,
  260. // 部门名称
  261. deptName: undefined,
  262. // 日期范围
  263. dateRange: [],
  264. // 岗位选项
  265. postOptions: [],
  266. // 角色选项
  267. roleOptions: [],
  268. // 表单参数
  269. form: {},
  270. defaultProps: {
  271. children: "children",
  272. label: "label"
  273. },
  274. // 用户导入参数
  275. upload: {
  276. // 是否显示弹出层(用户导入)
  277. open: false,
  278. // 弹出层标题(用户导入)
  279. title: "",
  280. // 是否禁用上传
  281. isUploading: false,
  282. // 是否更新已经存在的用户数据
  283. updateSupport: 0,
  284. // 设置上传的请求头部
  285. headers: { Authorization: "Bearer " + getToken() },
  286. // 上传的地址
  287. url: window.location.href.split('://')[0]+'://' + process.env.VUE_APP_BASE_API + "/system/user/importData"
  288. },
  289. // 查询参数
  290. queryParams: {
  291. pageNum: 1,
  292. pageSize: 20,
  293. searchValue: "",
  294. majorId: "",
  295. deptId: "",
  296. status: "",
  297. },
  298. // 列信息
  299. columns: [
  300. { key: 0, label: `用户编号`, visible: true },
  301. { key: 1, label: `用户名称`, visible: true },
  302. { key: 2, label: `用户昵称`, visible: true },
  303. { key: 3, label: `部门`, visible: true },
  304. { key: 4, label: `手机号码`, visible: true },
  305. { key: 5, label: `状态`, visible: true },
  306. { key: 6, label: `创建时间`, visible: true }
  307. ],
  308. // 表单校验
  309. rules: {
  310. password: [
  311. { required: true, message: "新密码不能为空", trigger: "blur" },
  312. { min: 5, max: 20, message: '新密码长度必须介于 5 和 20 之间', trigger: 'blur' }
  313. ],
  314. newPassword: [
  315. { required: true, message: "确认新密码不能为空", trigger: "blur" },
  316. { min: 5, max: 20, message: '确认新密码长度必须介于 5 和 20 之间', trigger: 'blur' },
  317. { required: true, validator: equalToPassword, trigger: "blur" }
  318. ],
  319. },
  320. //表格扩展选择器---需要在@selection-change绑定的方法内监控selection数组长度
  321. selectedNum:0,
  322. //页面选项
  323. pageType:1,
  324. editType:false,
  325. //组件传参数据
  326. propsData:{},
  327. //弹窗状态
  328. shadeType:1,
  329. // 教师列表
  330. teacherList: [],
  331. //学院列表
  332. deptList:[],
  333. // 新增学生开关
  334. addStudentType:false,
  335. addTitle:"",
  336. addForm:{
  337. tutorUserName:"",
  338. tmpTutorUserId:"",
  339. },
  340. subForm:{
  341. tutorUserName:""
  342. },
  343. // 重置密码弹层开关
  344. reviseOpen: false,
  345. //导入弹层开关
  346. importOpen:false,
  347. //导入数据
  348. upImportData:{
  349. sysUserEnable:true,
  350. upDate:false,
  351. },
  352. getImportData:{
  353. downFile:false,
  354. successNum:0,
  355. failureNum:0,
  356. textName:"",
  357. },
  358. //重置密码id
  359. resetPwdId:"",
  360. passwordForm:{
  361. password:"",
  362. newPassword:"",
  363. },
  364. currentDate:'',
  365. };
  366. },
  367. watch: {
  368. // 根据名称筛选部门树
  369. deptName(val) {
  370. this.$refs.tree.filter(val);
  371. }
  372. },
  373. created() {
  374. this.getList();
  375. this.getListAll();
  376. this.listDepartments();
  377. this.getDicts("sys_user_sex").then(response => {
  378. });
  379. this.getConfigKey("sys.user.initPassword").then(response => {
  380. });
  381. },
  382. methods: {
  383. //关闭重置密码页面
  384. reviseOpenOff(){
  385. this.reviseOpen = false;
  386. this.resetPwdId = "";
  387. },
  388. //重置密码
  389. putUserResetPwd(){
  390. this.$refs["passwordForm"].validate(valid => {
  391. if (valid) {
  392. let obj = {
  393. userId : this.resetPwdId,
  394. password:this.passwordForm.password
  395. };
  396. putUserResetPwd(obj).then(response => {
  397. this.reviseOpen = false;
  398. this.msgSuccess(response.msg)
  399. });
  400. }
  401. });
  402. },
  403. //启用/停用
  404. changeIsNeedCaptcha(row){
  405. let obj = {
  406. userId:row.userId,//用户id
  407. userName:row.userName,//用户账户
  408. status:row.status == 1?'0':'1',//账户启用停用,0是启用,1是停用
  409. }
  410. putUserTeacher(obj).then(response => {
  411. row.status = row.status == 1?'0':'1';
  412. this.msgSuccess(response.msg)
  413. });
  414. },
  415. //获取学院列表
  416. listDepartments(){
  417. listDepartments().then(response => {
  418. this.collegeOptions = response.data;
  419. });
  420. },
  421. // 查询专业列表
  422. getListAll(){
  423. getListAll().then(response => {
  424. this.professionOptions = response.data;
  425. });
  426. },
  427. outPage(){
  428. this.pageType = 1;
  429. this.getList();
  430. },
  431. //新增按钮
  432. addButton(){
  433. this.pageType = 2;
  434. this.propsData = {};
  435. this.titleName = '新增学生';
  436. this.editType = false;
  437. },
  438. //详情按钮
  439. infoButton(row){
  440. getStudentInfo(row.userId).then(response => {
  441. this.propsData = response.data;
  442. this.titleName = '学生详情';
  443. this.editType = true;
  444. this.pageType = 2;
  445. });
  446. },
  447. //更多选项
  448. moreClick(item){
  449. let self = this;
  450. if(item.command == 1){
  451. getStudentInfo(item.row.userId).then(response => {
  452. this.titleName = '学生编辑';
  453. this.propsData = response.data;
  454. this.editType = false;
  455. this.pageType = 2;
  456. });
  457. }else if(item.command == 2){
  458. this.$confirm('确认要删除吗?', "警告", {
  459. confirmButtonText: "确定",
  460. cancelButtonText: "取消",
  461. type: "warning"
  462. }).then(() => {
  463. // 确定
  464. delUserInfo(item.row.userId).then(response => {
  465. self.msgSuccess(response.msg);
  466. self.getList();
  467. });
  468. }).catch(function() {});
  469. }else if(item.command == 3){
  470. this.reset();
  471. this.title = "重置密码";
  472. this.resetPwdId = item.row.userId;
  473. this.reviseOpen = true;
  474. }
  475. },
  476. //=========表格扩展选择器方法---开始=========
  477. //选择本页
  478. selectPage(){
  479. console.log(this.$refs.multipleTable)
  480. this.$refs.multipleTable.toggleAllSelection()
  481. // console.log(this.$refs.multipleTable.selection)
  482. },
  483. //清除选择
  484. clearSelection(){
  485. this.$refs.multipleTable.clearSelection()
  486. },
  487. /*===记录勾选数据===
  488. 需要再el-table 添加 :row-key="getRowKeys"
  489. 需要在selection 添加 :reserve-selection="true"
  490. */
  491. getRowKeys(row) {
  492. return row.id
  493. },
  494. //=========表格扩展选择器方法---结束=========
  495. /** 查询用户列表 */
  496. getList() {
  497. // this.loading = true;
  498. listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  499. this.userList = response.rows;
  500. this.total = response.total;
  501. // this.loading = false;
  502. }
  503. );
  504. },
  505. // 取消按钮
  506. cancel() {
  507. this.open = false;
  508. this.reset();
  509. },
  510. // 表单重置
  511. reset() {
  512. this.form = {
  513. userId: undefined,
  514. deptId: undefined,
  515. userName: undefined,
  516. nickName: undefined,
  517. password: undefined,
  518. newPassword: undefined,
  519. phonenumber: undefined,
  520. email: undefined,
  521. sex: undefined,
  522. status: "0",
  523. remark: undefined,
  524. postIds: [],
  525. roleIds: []
  526. };
  527. this.resetForm("form");
  528. },
  529. /** 搜索按钮操作 */
  530. handleQuery() {
  531. this.queryParams.pageNum = 1;
  532. this.getList();
  533. },
  534. /** 重置按钮操作 */
  535. resetQuery() {
  536. this.dateRange = [];
  537. // this.resetForm("queryForm");
  538. this.$set(this,'queryParams',{
  539. pageNum: 1,
  540. pageSize:20,
  541. searchValue: "",
  542. majorId: "",
  543. deptId: "",
  544. status: "",
  545. });
  546. this.handleQuery();
  547. },
  548. // 多选框选中数据
  549. handleSelectionChange(selection) {
  550. this.selectedNum = selection.length;
  551. this.ids = selection.map(item => item.userId);
  552. this.single = selection.length != 1;
  553. this.multiple = !selection.length;
  554. },
  555. /** 修改按钮操作 */
  556. handleUpdate(row) {
  557. this.reset();
  558. const userId = row.userId || this.ids;
  559. getUser(userId).then(response => {
  560. this.form = response.data;
  561. this.postOptions = response.posts;
  562. this.roleOptions = response.roles;
  563. this.form.postIds = response.postIds;
  564. this.form.roleIds = response.roleIds;
  565. this.open = true;
  566. this.title = "修改用户";
  567. this.form.password = "";
  568. });
  569. },
  570. /** 提交按钮 */
  571. submitForm: function() {
  572. debugger
  573. this.$refs["addForm"].validate(valid => {
  574. if (valid) {
  575. if (this.addForm.userId != undefined) {
  576. console.log("this.addForm",this.addForm)
  577. this.subForm=this.addForm;
  578. if(!(!isNaN(this.addForm.tutorUserId) && typeof this.addForm.tutorUserId === 'number')){
  579. this.subForm.tutorUserId=this.addForm.tmpTutorUserId;
  580. }
  581. updateUser(this.subForm).then(response => {
  582. this.msgSuccess("修改成功");
  583. this.addStudentType = false;
  584. this.getList();
  585. });
  586. } else {
  587. this.addForm.password = '123456';
  588. addUser(this.addForm).then(response => {
  589. this.msgSuccess("新增成功");
  590. this.addStudentType = false;
  591. this.getList();
  592. });
  593. }
  594. }
  595. });
  596. },
  597. //导入页面关闭
  598. importOpenOff(){
  599. this.importOpen = false;
  600. this.getImportData.downFile = false;
  601. this.getImportData.successNum = 0;
  602. this.getImportData.failureNum = 0;
  603. this.getImportData.textName = "";
  604. },
  605. /** 导入按钮操作 */
  606. importButton(item){
  607. if(item.command == 1){
  608. // 下载模板
  609. this.download('/system/user/student/importTemplate', {}, `导入模板.xlsx`)
  610. }else if(item.command == 2){
  611. // 导入数据
  612. console.log('导入数据');
  613. this.importOpen = true;
  614. }
  615. },
  616. /** 当前时间 */
  617. getCurrentTime () {
  618. const yy = new Date().getFullYear()
  619. const mm = new Date().getMonth() + 1
  620. const dd = new Date().getDate()
  621. const hh = new Date().getHours()
  622. const mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes()
  623. const ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()
  624. return yy + '-' + mm + '-' + dd
  625. },
  626. /** 导出按钮操作 */
  627. exportButton(item) {
  628. let self = this;
  629. this.currentDate=this.getCurrentTime()
  630. if(item.command == 1){
  631. self.$confirm(`确认导出全部数据?`, "提示", {
  632. confirmButtonText: "确定",
  633. cancelButtonText: "取消",
  634. type: "warning"
  635. }).then(async () => {
  636. self.download('/system/user/student/export/', {...self.queryParams}, '学生信息-'+this.currentDate+'.xlsx')
  637. }).catch(() => {})
  638. }else if(item.command == 2){
  639. if(self.ids.length>0) {
  640. self.$confirm(`确认导出选中数据?`, "提示", {
  641. confirmButtonText: "确定",
  642. cancelButtonText: "取消",
  643. type: "warning"
  644. }).then(async () => {
  645. let ids = self.ids.join(',');
  646. let obj = {
  647. ids :ids
  648. }
  649. self.download(`/system/user/student/export/`,obj, '学生信息-'+this.currentDate+'.xlsx')
  650. }).catch(() => {})
  651. }else {
  652. Message({
  653. message: "请选择要导出的数据",
  654. type: 'error'
  655. });
  656. }
  657. }
  658. },
  659. /** 下载模板操作 */
  660. importTemplate() {
  661. this.download('/system/user/student/importTemplate', {}, `导入模板.xlsx`)
  662. },
  663. /*下载失败列表*/
  664. failureExcel(){
  665. this.download('/system/user/student/importErrorData', {}, `失败报表.xlsx`)
  666. },
  667. //****************************************导入功能**************************************
  668. handleAvatarSuccess(res, file) {
  669. if(res.code == 200){
  670. this.getImportData.downFile = res.data.downFile
  671. this.getImportData.successNum = res.data.successNum
  672. this.getImportData.failureNum = res.data.failureNum
  673. // this.importOpen = false;
  674. // this.getList();
  675. }else{
  676. this.msgError(res.msg);
  677. }
  678. this.loading = false;
  679. },
  680. beforeAvatarUpload(file) {
  681. let type = false;
  682. console.log('file',file);
  683. if (file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.type == 'application/vnd.ms-excel') {
  684. this.getImportData.textName = file.name;
  685. type = true;
  686. this.loading = true;
  687. }else{
  688. this.$message.error('只能上传xls/xlsx格式文件');
  689. type = false;
  690. }
  691. return type;
  692. },
  693. }
  694. };
  695. </script>
  696. <style scoped lang="scss">
  697. .student {
  698. display: flex!important;
  699. flex-direction: column;
  700. overflow: hidden!important;
  701. .sheet-expand-box{
  702. height:40px;
  703. display:flex;
  704. background:rgba(1,131,250,0.1);
  705. border-radius: 5px;
  706. margin-bottom:18px;
  707. font-size:14px;
  708. i{
  709. margin:10px 16px 0 14px;
  710. height:20px;
  711. width:20px;
  712. font-size:20px;
  713. display: block;
  714. }
  715. p{
  716. margin:0;
  717. }
  718. p:nth-child(2){
  719. width:132px;
  720. font-size:14px;
  721. height:40px;
  722. line-height:40px;
  723. }
  724. p:nth-child(3){
  725. width:60px;
  726. font-size:14px;
  727. height:40px;
  728. line-height:40px;
  729. margin-right:20px;
  730. }
  731. p:nth-child(4){
  732. width:60px;
  733. font-size:14px;
  734. height:40px;
  735. line-height:40px;
  736. margin-right:20px;
  737. }
  738. p:nth-child(5){
  739. font-size:14px;
  740. line-height:30px;
  741. width: 100px;
  742. height: 30px;
  743. border-radius: 6px;
  744. text-align: center;
  745. margin-top:5px;
  746. margin-right:20px;
  747. }
  748. p:nth-child(6){
  749. font-size:14px;
  750. line-height:30px;
  751. width: 100px;
  752. height: 30px;
  753. border-radius: 6px;
  754. text-align: center;
  755. margin-top:5px;
  756. }
  757. }
  758. .button-box{
  759. width:300px;
  760. display: flex;
  761. }
  762. .data-max-box{
  763. position:relative;
  764. margin-top:-20px;
  765. p{
  766. margin:0;
  767. }
  768. .info-title-p{
  769. line-height:80px;
  770. font-size:18px;
  771. padding-left:20px;
  772. border-bottom:1px solid #E0E0E0;
  773. }
  774. .info-data-box{
  775. height:100px;
  776. display:flex;
  777. padding-left:20px;
  778. p{
  779. width:270px;
  780. line-height:60px;
  781. font-size:16px;
  782. }
  783. }
  784. .reset-button-p{
  785. position: absolute;
  786. right:0;
  787. top:20px;
  788. cursor: pointer;
  789. text-align: center;
  790. width: 70px;
  791. height: 40px;
  792. line-height: 40px;
  793. border-radius: 6px;
  794. font-size:14px;
  795. border: 1px solid #DCDFE6;
  796. color: #606266;
  797. background: #ffffff;
  798. }
  799. }
  800. .student-one-box{
  801. flex:1;
  802. display: flex;
  803. flex-direction: column;
  804. overflow: hidden!important;
  805. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  806. padding:20px!important;
  807. .top-max-box{
  808. flex:1;
  809. display: flex;
  810. overflow: hidden!important;
  811. .left-max-box{
  812. width:250px;
  813. }
  814. .center-max-box{
  815. border-right:2px dashed #E0E0E0;
  816. margin-right:50px;
  817. margin-top:20px;
  818. }
  819. .right-max-box{
  820. flex:1;
  821. display: flex;
  822. flex-direction: column;
  823. overflow: hidden!important;
  824. .min-list-box{
  825. flex: 1;
  826. overflow: hidden!important;
  827. display: flex;
  828. margin-bottom:15px;
  829. }
  830. }
  831. }
  832. .bottom-max-box{
  833. height:35px;
  834. }
  835. .form-box{
  836. .form-dropdown-box{
  837. display: flex;
  838. margin:0;
  839. padding:0 10px;
  840. cursor: pointer;
  841. height:40px;
  842. img:nth-child(1){
  843. width:16px;
  844. height:16px;
  845. margin-top:12px;
  846. }
  847. p{
  848. width:47px;
  849. text-align: center;
  850. font-size:14px;
  851. margin:0;
  852. line-height:40px;
  853. }
  854. img:nth-child(3){
  855. width:10px;
  856. height:6px;
  857. margin-top:17px;
  858. }
  859. }
  860. }
  861. }
  862. }
  863. </style>
  864. <style lang="scss">
  865. .teacher-revise-dialog-box{
  866. .teacher-text-p{
  867. margin-left:110px;
  868. font-size:16px;
  869. }
  870. .teacher-revise-dialog-button-box{
  871. display: flex;
  872. width:190px;
  873. margin:0 auto;
  874. p{
  875. margin:0;
  876. width:70px;
  877. height:30px;
  878. line-height:30px;
  879. font-size:14px;
  880. }
  881. p:nth-child(1){
  882. margin-right:50px;
  883. }
  884. }
  885. }
  886. .teacher-import-dialog-box{
  887. .teacher-import-dialog-upLoad-box{
  888. .el-upload{
  889. width:450px;
  890. margin:0 55px;
  891. .el-upload-dragger{
  892. width:450px;
  893. .el-icon-upload{
  894. font-size:100px;
  895. color:#CBE6FE;
  896. }
  897. .el-upload__text{
  898. margin-top:20px;
  899. }
  900. }
  901. }
  902. .el-upload__tip{
  903. margin-left:60px;
  904. font-size:14px;
  905. margin-top:10px;
  906. }
  907. .el-upload-text-box{
  908. background: #F5F5F5;
  909. border-radius: 10px;
  910. margin:15px 30px 0;
  911. padding:0 20px 15px;
  912. overflow: hidden;
  913. *{
  914. margin:0;
  915. }
  916. .img-text-box{
  917. display: flex;
  918. margin-top:15px;
  919. img{
  920. width:16px;
  921. height:16px;
  922. margin-right:13px;
  923. }
  924. p{
  925. height:16px;
  926. line-height:16px;
  927. font-size:12px;
  928. }
  929. }
  930. .text-p{
  931. margin-top:15px;
  932. margin-left:29px;
  933. height:16px;
  934. line-height:16px;
  935. font-size:12px;
  936. }
  937. }
  938. }
  939. .teacher-import-dialog-button-box{
  940. display: flex;
  941. width:190px;
  942. margin:0 auto;
  943. p{
  944. width:70px;
  945. height:30px;
  946. line-height:30px;
  947. font-size:14px;
  948. margin:0 auto;
  949. }
  950. }
  951. .teacher-import-dialog-position-box{
  952. width:100%;
  953. height:100%;
  954. position: absolute;
  955. top:0;
  956. left:0;
  957. z-index: 999;
  958. background: rgba(255,255,255,0.4);
  959. border-radius:20px;
  960. }
  961. }
  962. </style>
  963. <style lang="scss">
  964. .student{
  965. .student-one-box{
  966. .switch .el-switch__label {
  967. position: absolute;
  968. display: none;
  969. color: #fff !important;
  970. }
  971. .switch .el-switch__label--right {
  972. z-index: 1;
  973. }
  974. .switch .el-switch__label--right span{
  975. margin-left: 10px;
  976. }
  977. .switch .el-switch__label--left {
  978. z-index: 1;
  979. }
  980. .switch .el-switch__label--left span{
  981. margin-left: 24px;
  982. }
  983. .switch .el-switch__label.is-active {
  984. display: block;
  985. }
  986. .switch.el-switch .el-switch__core,
  987. .el-switch .el-switch__label {
  988. width: 64px !important;
  989. margin: 0;
  990. }
  991. }
  992. }
  993. </style>