addDialog.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903
  1. <template>
  2. <!--添加/编辑弹窗-->
  3. <el-dialog append-to-body class="trainingCourseAddDialog" :title='dialogTitle' @close="dialogClose"
  4. :show-close="false" :close-on-click-modal="false" :close-on-press-escape="false"
  5. :visible.sync="dialogType" v-if="dialogType" width="1373px">
  6. <!--提交界面-->
  7. <el-form class="add-dialog-form-box" ref="dialogForm" v-show="!dialogUserType" :model="dialogForm" :rules="rules" label-width="120px">
  8. <el-form-item label="课程名称:" prop="courseName">
  9. <el-input v-model="dialogForm.courseName" placeholder="请输入课程名称"
  10. maxLength="30" style="width:800px;"/>
  11. </el-form-item>
  12. <div class="dialogFormFlex">
  13. <el-form-item label="主讲老师:" prop="lecturerId">
  14. <el-select
  15. @change="lecturerIdChange"
  16. style="width:300px;"
  17. v-model="dialogForm.lecturerId"
  18. filterable
  19. remote
  20. reserve-keyword
  21. placeholder="请输入姓名"
  22. :remote-method="getMainTeacher"
  23. :loading="loading">
  24. <el-option
  25. v-for="item in mainTeacherOptions"
  26. :key="item.userId"
  27. :label="item.userName"
  28. :value="item.userId">
  29. </el-option>
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item label="辅导老师:" prop="tutorId" label-width="200px">
  33. <el-select
  34. style="width:300px;"
  35. v-model="dialogForm.tutorId"
  36. multiple
  37. filterable
  38. remote
  39. reserve-keyword
  40. collapse-tags
  41. :multiple-limit="3"
  42. placeholder="请输入姓名"
  43. :remote-method="getSecondaryTeacher"
  44. :loading="loading">
  45. <el-option
  46. v-for="item in secondaryTeacherOptions"
  47. :key="item.userId"
  48. :label="item.userName"
  49. :value="item.userId">
  50. </el-option>
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item label="上课人员:" prop="userIds" label-width="200px">
  54. <p style="line-height:40px;color:#0183FA;cursor: pointer;width:300px;" @click="addUserButton">
  55. 已选择 ({{dialogForm.userIds?dialogForm.userIds.length:0}}人)
  56. </p>
  57. </el-form-item>
  58. </div>
  59. <div class="dialogFormFlex">
  60. <el-form-item label="上课场所:" prop="placeId">
  61. <el-select v-model="dialogForm.placeId"
  62. @change="deptChange"
  63. style="width:300px;" placeholder="请选择学院">
  64. <el-option
  65. v-for="item in deptOptions"
  66. :key="item.deptId"
  67. :label="item.deptName"
  68. :value="item.deptId">
  69. </el-option>
  70. </el-select>
  71. </el-form-item>
  72. <el-form-item :label="dialogForm.selectType==1?'实验室:':'上课场所:'" prop="subId" label-width="200px">
  73. <el-select
  74. style="width:300px;"
  75. @change="subChange"
  76. v-if="dialogForm.selectType == 1"
  77. v-model="dialogForm.subId"
  78. filterable
  79. remote
  80. reserve-keyword
  81. placeholder="请选择实验室"
  82. :remote-method="getSubList"
  83. :loading="loading">
  84. <el-option
  85. v-for="item in subOptions"
  86. :key="item.subId"
  87. :label="item.subName"
  88. :value="item.subId">
  89. </el-option>
  90. </el-select>
  91. <el-input v-model="dialogForm.position" v-if="dialogForm.selectType == 2"
  92. placeholder="请输入上课场所" maxLength="20" style="width:300px;"/>
  93. </el-form-item>
  94. <p class="page-add-common-style-button"
  95. style="margin-left:20px;width:140px;border-radius:4px;" @click="subTypeClick">
  96. {{dialogForm.selectType==1?'手动输入上课场所':(dialogForm.selectType==2?'选择学校':'')}}
  97. </p>
  98. </div>
  99. <div class="dialogFormFlex">
  100. <el-form-item label="上课时间:" prop="courseTime">
  101. <el-time-picker
  102. class="trainingCourse-el-time-picker"
  103. :popper-append-to-body="true"
  104. is-range
  105. style="width:300px;"
  106. format="HH:mm"
  107. value-format="HH:mm"
  108. v-model="dialogForm.courseTime"
  109. range-separator="至"
  110. start-placeholder="开始时间"
  111. end-placeholder="结束时间"
  112. placeholder="选择时间范围">
  113. </el-time-picker>
  114. </el-form-item>
  115. <el-form-item label="上课日期:" prop="courseDate" label-width="200px" v-if="!dialogForm.id">
  116. <el-date-picker
  117. style="width:300px;"
  118. value-format="yyyy-MM-dd"
  119. v-model="dialogForm.courseDate"
  120. type="daterange"
  121. :picker-options="pickerOptions"
  122. range-separator="至"
  123. start-placeholder="开始日期"
  124. end-placeholder="结束日期">
  125. </el-date-picker>
  126. </el-form-item>
  127. <el-form-item label="上课日期:" prop="courseDate" label-width="200px" v-if="dialogForm.id">
  128. <el-date-picker
  129. style="width:300px;"
  130. value-format="yyyy-MM-dd"
  131. v-model="dialogForm.courseDate"
  132. type="date"
  133. :picker-options="pickerOptions"
  134. placeholder="选择日期">
  135. </el-date-picker>
  136. </el-form-item>
  137. </div>
  138. <el-form-item label="课程内容:" prop="content">
  139. <el-input type="textarea" v-model="dialogForm.content" resize="none" show-word-limit
  140. :autosize="{ minRows: 10, maxRows: 10}" maxLength="100" placeholder="请输入处理描述"
  141. style="width:1122px;"/>
  142. </el-form-item>
  143. </el-form>
  144. <!--人员选择界面-->
  145. <div class="inspectionPlan-dialog-user-box" v-show="dialogUserType">
  146. <div class="left-max-box">
  147. <div class="dept-table-title-box">
  148. <p>待选人员</p>
  149. <p>{{userNumLeft}}/{{userTotalLeft}}</p>
  150. </div>
  151. <div class="dept-table-max-box">
  152. <el-form :model="userQueryParamsLeft" class="form-box" ref="queryForm" :inline="true" label-width="50px">
  153. <el-form-item label="" prop="deptId">
  154. <el-select v-model="userQueryParamsLeft.deptId" clearable placeholder="选择部门" style="width: 110px">
  155. <el-option
  156. v-for="item in deptOptions"
  157. :key="item.deptId"
  158. :label="item.deptName"
  159. :value="item.deptId">
  160. </el-option>
  161. </el-select>
  162. </el-form-item>
  163. <el-form-item label="" prop="keyword" class="form-index">
  164. <el-input
  165. maxLength="20"
  166. v-model="userQueryParamsLeft.keyword"
  167. placeholder="搜索姓名/工号"
  168. clearable
  169. @clear="userHandleQueryLeft"
  170. style="width: 240px">
  171. <p class="el-icon-search" slot="append" @click="userHandleQueryLeft"></p>
  172. </el-input>
  173. </el-form-item>
  174. <el-form-item style="margin-right:0;">
  175. <p class="page-reset-common-style-button" @click="userResetQueryLeft" style="width:60px;">重置</p>
  176. </el-form-item>
  177. </el-form>
  178. <el-table ref="leftUserTable" border :data="userTableListLeft" @selection-change="userChangeLeft" :row-key="getRowKeys">
  179. <el-table-column type="selection" width="50" :reserve-selection="true" align="center"/>
  180. <el-table-column label="姓名" align="center" prop="userName" show-overflow-tooltip/>
  181. <el-table-column label="工号" align="center" prop="account" show-overflow-tooltip width="150"/>
  182. <el-table-column label="所在部门" align="center" prop="deptName" show-overflow-tooltip width="168"/>
  183. </el-table>
  184. <pagination layout="total, prev, pager, next, jumper"
  185. v-show="userTotalLeft>0"
  186. :total="userTotalLeft"
  187. :pager-count="5"
  188. :page.sync="userQueryParamsLeft.page"
  189. :limit.sync="userQueryParamsLeft.pageSize"
  190. @pagination="userGetListLeft"/>
  191. </div>
  192. </div>
  193. <div class="center-box">
  194. <p class="el-icon-arrow-left" @click="userArrowButton(1)"></p>
  195. <p class="el-icon-arrow-right" @click="userArrowButton(2)"></p>
  196. </div>
  197. <div class="right-max-box">
  198. <div class="dept-table-title-box">
  199. <p>已选成员</p>
  200. <p>{{userNumRight}}/{{userTotalRight}}</p>
  201. </div>
  202. <div class="dept-table-max-box">
  203. <el-form :model="userQueryParamsRight" class="form-box" ref="queryForm" :inline="true" label-width="50px">
  204. <el-form-item label="" prop="deptId">
  205. <el-select v-model="userQueryParamsRight.deptId" clearable placeholder="选择部门" style="width: 110px">
  206. <el-option
  207. v-for="item in deptOptions"
  208. :key="item.deptId"
  209. :label="item.deptName"
  210. :value="item.deptId">
  211. </el-option>
  212. </el-select>
  213. </el-form-item>
  214. <el-form-item label="" prop="keyword" class="form-index">
  215. <el-input
  216. maxLength="20"
  217. v-model="userQueryParamsRight.keyword"
  218. placeholder="搜索姓名/工号"
  219. clearable
  220. @clear="userHandleQueryRight"
  221. style="width: 240px">
  222. <p class="el-icon-search" slot="append" @click="userHandleQueryRight"></p>
  223. </el-input>
  224. </el-form-item>
  225. <el-form-item style="margin-right:0;">
  226. <p class="page-reset-common-style-button" @click="userResetQueryRight" style="width:60px;">重置</p>
  227. </el-form-item>
  228. </el-form>
  229. <el-table ref="rightUserTable" border :data="userTableListRight" @selection-change="userChangeRight" :row-key="getRowKeys">
  230. <el-table-column type="selection" width="50" :reserve-selection="true" align="center"/>
  231. <el-table-column label="姓名" align="center" prop="userName" show-overflow-tooltip/>
  232. <el-table-column label="工号" align="center" prop="account" show-overflow-tooltip width="150"/>
  233. <el-table-column label="所在部门" align="center" prop="deptName" show-overflow-tooltip width="168"/>
  234. </el-table>
  235. <pagination layout="total, prev, pager, next, jumper"
  236. v-show="userTotalRight>0"
  237. :total="userTotalRight"
  238. :pager-count="5"
  239. :page.sync="userQueryParamsRight.page"
  240. :limit.sync="userQueryParamsRight.pageSize"
  241. @pagination="userGetListRight"/>
  242. </div>
  243. </div>
  244. </div>
  245. <!--公共操作按钮-->
  246. <div slot="footer" class="dialog-footer dialog-footer-box">
  247. <p class="dialog-footer-button-null"></p >
  248. <p class="dialog-footer-button-info" @click="dialogClose">取消</p >
  249. <p class="dialog-footer-button-primary" @click="dialogSubmit">确定</p >
  250. <p class="dialog-footer-button-null"></p >
  251. </div>
  252. </el-dialog>
  253. </template>
  254. <script>
  255. import {
  256. findUserList,
  257. selectUser,
  258. systemSubjectGetlist,
  259. securitycourseEdit,
  260. examSecuritycourseAdd
  261. } from "@/api/safetyEducationExam/index";
  262. import {getDeptDropList,} from "@/api/commonality/permission";
  263. export default {
  264. name: 'trainingCourseAddDialog',
  265. props:{
  266. addDialogData:{},
  267. },
  268. data(){
  269. const timeRules = (rule, value, callback) => {
  270. if(value[0] == value[1]){
  271. callback(new Error("开始与结束时间不能相同"));
  272. }else{
  273. callback();
  274. }
  275. };
  276. return{
  277. // 设置只能选择当前日期及之后的日期
  278. pickerOptions: {
  279. disabledDate(time) {
  280. const times = new Date(new Date().toLocaleDateString()).getTime() + 30 * 8.64e7 - 1
  281. return time.getTime() < Date.now() - 8.64e7 || time.getTime() > times // 如果没有后面的-8.64e7就是不可以选择今天的
  282. }
  283. },
  284. // 遮罩层
  285. loading: false,
  286. //弹窗数据
  287. dialogType:true,
  288. dialogUserType:false,
  289. dialogTitle:"",
  290. dialogForm:{
  291. courseName:"",
  292. lecturerId:"",
  293. lecturerName:"",
  294. tutorId:"",
  295. userIds:[],
  296. placeId:"",
  297. place:"",
  298. subId:"",
  299. position:"",
  300. selectType:1,
  301. content:"",
  302. courseTime:["00:00","00:00"],
  303. courseDate:[],
  304. },
  305. //验证
  306. rules: {
  307. phone: [
  308. { required: true, message: "请输入联系方式", trigger: "blur" },
  309. { required: true, message: "请输入联系方式", validator: this.spaceJudgment, trigger: "blur" },
  310. { pattern:/^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(16[0-9])|(17[0,3,5-8])|(18[0-9])|(147))+\d{8}$/, message: "请输入正确的联系方式", trigger: "blur" }
  311. ],
  312. courseName: [
  313. { required: true, message: "请输入课程名称", trigger: "blur" },
  314. { required: true, message: "请输入课程名称", validator: this.spaceJudgment, trigger: "blur" }
  315. ],
  316. lecturerId: [
  317. { required: true, message: "请选择主讲老师", trigger: "blur" },
  318. ],
  319. tutorId: [
  320. { required: true, message: "请选择辅导老师", trigger: "blur" },
  321. ],
  322. userIds: [
  323. { required: true, message: "请选择上课人员", trigger: "blur" },
  324. ],
  325. placeId: [
  326. { required: true, message: "请选择上课场所", trigger: "blur" },
  327. ],
  328. courseTime: [
  329. { required: true, message: "请选择上课时间", trigger: "blur" },
  330. { required: true, message: "开始与结束时间不能相同", validator: timeRules, trigger: "blur" },
  331. ],
  332. courseDate: [
  333. { required: true, message: "请选择上课日期", trigger: "blur" },
  334. ],
  335. },
  336. //主要老师
  337. mainTeacherOptions:[],
  338. //辅助老师
  339. secondaryTeacherOptions:[],
  340. secondaryTeacherOptionsArr:[],
  341. //院系列表
  342. deptOptions:[],
  343. //实验室列表
  344. subOptions:[],
  345. /**********人员选择数据**********/
  346. userQueryParamsLeft:{
  347. page: 1,
  348. pageSize: 20,
  349. userType:2,
  350. deptId:null,
  351. keyword:null,
  352. filtType:1
  353. },
  354. userTableListLeft:[],
  355. userTotalLeft:0,
  356. userNumLeft:0,
  357. userIdsLeft:[],
  358. userQueryParamsRight:{
  359. page: 1,
  360. pageSize: 20,
  361. userType:2,
  362. deptId:null,
  363. keyword:null,
  364. filtType:2
  365. },
  366. userTableListRight:[],
  367. userTotalRight:0,
  368. userNumRight:0,
  369. userIdsRight:[],
  370. //选择人员交互数据
  371. dialogTableDataList:[],
  372. }
  373. },
  374. created(){
  375. },
  376. mounted(){
  377. this.initialize();
  378. },
  379. methods:{
  380. //初始化
  381. initialize(){
  382. let self = this;
  383. this.$set(this,'dialogTitle',this.addDialogData.id?'编辑':'添加');
  384. if(this.addDialogData.id){
  385. //编辑数据
  386. let obj = {
  387. id:this.addDialogData.id,
  388. courseName:this.addDialogData.courseName,
  389. lecturerId:this.addDialogData.lecturerId,
  390. lecturerName:this.addDialogData.lecturerName,
  391. tutorId:'',
  392. tutorName:'',
  393. placeId:this.addDialogData.placeId,
  394. place:this.addDialogData.place,
  395. content:this.addDialogData.content,
  396. courseTime:[this.addDialogData.coStartTime,this.addDialogData.coEndTime],
  397. courseDate:this.addDialogData.coStartDate,
  398. userIds:[],
  399. };
  400. //处理主要老师列表
  401. let mainTeacherList = [{userId:this.addDialogData.lecturerId,userName:this.addDialogData.lecturerName}];
  402. this.$set(this,'mainTeacherOptions',mainTeacherList);
  403. //处理辅助老师列表
  404. if(this.addDialogData.tutorName){
  405. let list=this.addDialogData.tutorName.split(',');
  406. let tutorIdList=[];
  407. let tutorNameList=[];
  408. let secondaryTeacherList = [];
  409. list.forEach(function(item){
  410. tutorIdList.push(item.split('@')[0])
  411. tutorNameList.push(item.split('@')[1])
  412. secondaryTeacherList.push({userId:item.split('@')[0],userName:item.split('@')[1]})
  413. })
  414. obj.tutorId = JSON.parse(JSON.stringify(tutorIdList));
  415. obj.tutorName = JSON.parse(JSON.stringify(tutorNameList));
  416. this.$set(this,'secondaryTeacherOptions',secondaryTeacherList);
  417. }
  418. //处理实验室数据&手动输入场地
  419. if(this.addDialogData.subId && this.addDialogData.subId!=-1){
  420. obj.subId = this.addDialogData.subId;
  421. obj.position = "";
  422. obj.selectType = 1;
  423. //处理实验室列表
  424. let subList = [{name:this.addDialogData.subName,id:this.addDialogData.subId}]
  425. this.$set(this,'subOptions',subList);
  426. }else{
  427. if(this.addDialogData.position){
  428. obj.subId = "";
  429. obj.position = this.addDialogData.position;
  430. obj.selectType = 2;
  431. }else{
  432. obj.subId = "";
  433. obj.position = "";
  434. obj.selectType = 1;
  435. }
  436. }
  437. //处理学生数据
  438. for(let i=0;i<self.addDialogData.userIds.length;i++){
  439. obj.userIds.push({userId:self.addDialogData.userIds[i]})
  440. }
  441. //根据当前选择院系获取实验室列表
  442. this.getSubList('',this.addDialogData.placeId)
  443. this.$set(this,'dialogForm',obj);
  444. }
  445. this.getDeptList();
  446. },
  447. //提交按钮
  448. dialogSubmit(){
  449. let self = this;
  450. if(this.dialogUserType){
  451. //选择人员页面
  452. if(!this.dialogTableDataList[0]){
  453. this.msgError('请选择人员')
  454. return
  455. }
  456. let userList = JSON.parse(JSON.stringify(this.dialogTableDataList))
  457. this.$set(this.dialogForm,'userIds',userList)
  458. this.$set(this,'dialogUserType',false)
  459. }else{
  460. //提交页面
  461. this.$refs["dialogForm"].validate(valid => {
  462. if (valid) {
  463. if(this.dialogForm.id){
  464. //编辑
  465. let obj = {
  466. id:this.dialogForm.id,
  467. courseName:this.dialogForm.courseName,
  468. lecturerId:this.dialogForm.lecturerId,
  469. lecturerName:this.dialogForm.lecturerName,
  470. tutorIds:this.dialogForm.tutorId+'',
  471. userList:[],
  472. placeId:this.dialogForm.placeId,
  473. place:this.dialogForm.place,
  474. position:"",
  475. coStartTime:this.dialogForm.courseTime[0],
  476. coEndTime:this.dialogForm.courseTime[1],
  477. courseDate:[this.dialogForm.courseDate,this.dialogForm.courseDate],
  478. content:this.dialogForm.content,
  479. peopleCount:this.dialogForm.userIds.length,
  480. }
  481. if(this.dialogForm.selectType == 1){
  482. obj.subId = this.dialogForm.subId;
  483. obj.subName=this.dialogForm.subName;
  484. obj.subRoom=this.dialogForm.subRoom;
  485. }else{
  486. obj.position = this.dialogForm.position;
  487. }
  488. //处理学生数据
  489. for(let i=0;i<self.dialogForm.userIds.length;i++){
  490. if(self.dialogForm.userIds[i].jobNum){
  491. obj.userList.push({'userId':self.dialogForm.userIds[i].userId,'userName':self.dialogForm.userIds[i].jobNum,'userImg':self.dialogForm.userIds[i].avatar,})
  492. }else{
  493. for(let t=0;t<self.addDialogData.userList.length;t++){
  494. if(self.dialogForm.userIds[i].userId==self.addDialogData.userList[t].userId){
  495. obj.userList.push(self.addDialogData.userList[t])
  496. }
  497. }
  498. }
  499. }
  500. securitycourseEdit(obj).then(response => {
  501. this.msgSuccess(response.msg)
  502. this.$parent.controlsButton(6)
  503. });
  504. }else{
  505. //提交
  506. let obj = {
  507. courseName:this.dialogForm.courseName,
  508. lecturerId:this.dialogForm.lecturerId,
  509. lecturerName:this.dialogForm.lecturerName,
  510. tutorIds:this.dialogForm.tutorId+'',
  511. userList:[],
  512. placeId:this.dialogForm.placeId,
  513. place:this.dialogForm.place,
  514. position:"",
  515. coStartTime:this.dialogForm.courseTime[0],
  516. coEndTime:this.dialogForm.courseTime[1],
  517. courseDate:this.dialogForm.courseDate,
  518. content:this.dialogForm.content,
  519. peopleCount:this.dialogForm.userIds.length,
  520. }
  521. if(this.dialogForm.selectType == 1){
  522. obj.subId = this.dialogForm.subId;
  523. obj.subName=this.dialogForm.subName;
  524. obj.subRoom=this.dialogForm.subRoom;
  525. }else{
  526. obj.position = this.dialogForm.position;
  527. }
  528. for(let i=0;i<self.dialogForm.userIds.length;i++){
  529. obj.userList.push({'userId':self.dialogForm.userIds[i].userId,'userName':self.dialogForm.userIds[i].jobNum,'userImg':self.dialogForm.userIds[i].avatar,})
  530. }
  531. //根据id获取辅导老师姓名
  532. // let tutorNamelist=[]
  533. // for(let i=0;i<this.dialogForm.tutorId.length;i++){
  534. // for(let t=0;t<this.secondaryTeacherOptionsArr.length;t++){
  535. // if(this.dialogForm.tutorId[i]==this.secondaryTeacherOptionsArr[t].userId){
  536. // tutorNamelist.push(this.secondaryTeacherOptionsArr[t].userName)
  537. // }
  538. // }
  539. // }
  540. // obj.tutorName=tutorNamelist+'';
  541. examSecuritycourseAdd(obj).then(response => {
  542. this.msgSuccess(response.msg)
  543. this.$parent.controlsButton(6)
  544. });
  545. }
  546. }
  547. })
  548. }
  549. },
  550. //取消按钮
  551. dialogClose(){
  552. if(this.dialogUserType){
  553. //选择人员页面
  554. this.$set(this,'dialogTitle',this.addDialogData.id?'编辑':'添加');
  555. this.$set(this,'dialogUserType',false);
  556. }else{
  557. //提交页面
  558. this.$parent.controlsButton(5)
  559. }
  560. },
  561. //主要老师选中
  562. lecturerIdChange(val){
  563. let self = this;
  564. for(let i=0;i<self.mainTeacherOptions.length;i++){
  565. if(self.mainTeacherOptions[i].userId == val){
  566. this.$set(this.dialogForm,'lecturerName',self.mainTeacherOptions[i].userName);
  567. }
  568. }
  569. },
  570. //主要老师搜索
  571. getMainTeacher(query){
  572. if(query.length > 1){
  573. this.loading = true;
  574. selectUser({userType:1,userName:query}).then(response => {
  575. this.$set(this,'mainTeacherOptions',response.data)
  576. this.loading = false;
  577. });
  578. }
  579. },
  580. //辅助老师搜错
  581. getSecondaryTeacher(query){
  582. if(query.length > 1){
  583. this.loading = true;
  584. selectUser({userType:1,userName:query}).then(response => {
  585. this.$set(this,'secondaryTeacherOptions',response.data)
  586. this.secondaryTeacherOptionsArr=this.secondaryTeacherOptionsArr.concat(response.data)
  587. this.loading = false;
  588. });
  589. }
  590. },
  591. //选择院系
  592. deptChange(val){
  593. let self = this;
  594. for(let i=0;i<self.deptOptions.length;i++){
  595. if(self.deptOptions[i].deptId == val){
  596. this.$set(this.dialogForm,'place',self.deptOptions[i].deptName);
  597. }
  598. }
  599. this.$set(this.dialogForm,'subId','');
  600. this.getSubList('')
  601. },
  602. //选择实验室
  603. subChange(val){
  604. let self = this;
  605. for(let i=0;i<self.subOptions.length;i++){
  606. if(self.subOptions[i].subId == val){
  607. this.$set(this.dialogForm,'subName',self.subOptions[i].subName);
  608. this.$set(this.dialogForm,'subRoom',self.subOptions[i].room);
  609. }
  610. }
  611. },
  612. //获取院系列表
  613. getDeptList(){
  614. getDeptDropList({deptType:1}).then(response => {
  615. this.$set(this,'deptOptions',response.data);
  616. });
  617. },
  618. //获取实验室列表
  619. getSubList(val,deptId){
  620. if(val == '' && deptId){
  621. systemSubjectGetlist({deptId:deptId,name:val}).then(response => {
  622. this.$set(this,'subOptions',response.data);
  623. });
  624. }else if(this.dialogForm.placeId && (val == '' || val.length > 1)){
  625. systemSubjectGetlist({deptId:this.dialogForm.placeId,name:val}).then(response => {
  626. this.$set(this,'subOptions',response.data);
  627. });
  628. }
  629. },
  630. //实验室切换
  631. subTypeClick(){
  632. this.$set(this.dialogForm,'subId','');
  633. this.$set(this.dialogForm,'selectType',this.dialogForm.selectType==1?2:1);
  634. },
  635. //开启人员选择
  636. addUserButton(){
  637. let userList = JSON.parse(JSON.stringify(this.dialogForm.userIds))
  638. this.$set(this,'dialogTableDataList',userList)
  639. this.$set(this,'dialogTitle','选择人员');
  640. this.$set(this,'dialogUserType',true);
  641. this.userHandleQueryLeft();
  642. this.userHandleQueryRight();
  643. },
  644. /*===================================人员选择相关===================================*/
  645. //查询
  646. userHandleQueryLeft(){
  647. this.$set(this.userQueryParamsLeft,'page',1);
  648. this.$set(this,'userNumLeft',0);
  649. this.$set(this,'userIdsLeft',[]);
  650. this.$refs.leftUserTable.clearSelection();
  651. this.userGetListLeft();
  652. },
  653. //重置
  654. userResetQueryLeft(){
  655. this.$set(this,'userQueryParamsLeft',{
  656. page: 1,
  657. pageSize: 20,
  658. deptId:"",
  659. keyword:"",
  660. userType:2,
  661. filtType:1
  662. });
  663. this.userHandleQueryLeft();
  664. },
  665. //查询接口
  666. userGetListLeft(){
  667. let self = this;
  668. let leftObj = JSON.parse(JSON.stringify(this.userQueryParamsLeft));
  669. leftObj.selectedUserIds = [];
  670. for(let i=0;i<self.dialogTableDataList.length;i++){
  671. leftObj.selectedUserIds.push(self.dialogTableDataList[i].userId);
  672. }
  673. findUserList(leftObj).then(response => {
  674. this.userTotalLeft = response.data.total;
  675. this.userTableListLeft = response.data.records;
  676. });
  677. },
  678. //查询
  679. userHandleQueryRight(){
  680. this.$set(this.userQueryParamsRight,'page',1);
  681. this.$set(this,'userNumRight',0);
  682. this.$set(this,'userIdsRight',[]);
  683. this.$refs.rightUserTable.clearSelection();
  684. this.userGetListRight();
  685. },
  686. //重置
  687. userResetQueryRight(){
  688. this.$set(this,'userQueryParamsRight',{
  689. page: 1,
  690. pageSize: 20,
  691. deptId:"",
  692. keyword:"",
  693. userType:2,
  694. filtType:2
  695. });
  696. this.userHandleQueryRight();
  697. },
  698. //查询接口
  699. userGetListRight(){
  700. let self = this;
  701. let rightObj = JSON.parse(JSON.stringify(this.userQueryParamsRight));
  702. rightObj.userIds = [];
  703. for(let i=0;i<self.dialogTableDataList.length;i++){
  704. rightObj.userIds.push(self.dialogTableDataList[i].userId);
  705. }
  706. findUserList(rightObj).then(response => {
  707. this.userTotalRight = response.data.total;
  708. this.userTableListRight = response.data.records;
  709. });
  710. },
  711. userChangeLeft(selection){
  712. this.userNumLeft = selection.length;
  713. this.userIdsLeft = selection.map(item => item.userId);
  714. },
  715. userChangeRight(selection){
  716. this.userNumRight = selection.length;
  717. this.userIdsRight = selection.map(item => item.userId);
  718. },
  719. //人员穿梭按钮
  720. userArrowButton(type){
  721. let self = this;
  722. if(type == 1){
  723. //右至左
  724. if(this.$refs.rightUserTable.selection[0]){
  725. let list = JSON.parse(JSON.stringify(this.dialogTableDataList));
  726. let userIdsRight = JSON.parse(JSON.stringify(this.$refs.rightUserTable.selection))
  727. for(let i=0;i<userIdsRight.length;i++){
  728. for(let s=0;s<list.length;s++){
  729. if(userIdsRight[i].userId == list[s].userId){
  730. list.splice(s,1);
  731. s--
  732. }
  733. }
  734. }
  735. this.$set(this,'dialogTableDataList',list);
  736. this.$refs.rightUserTable.clearSelection();
  737. this.userHandleQueryLeft();
  738. this.userHandleQueryRight();
  739. }else{
  740. this.msgError('请先勾选右侧列表')
  741. }
  742. }else if(type == 2){
  743. //左至右
  744. if(this.userIdsLeft[0]){
  745. let list = JSON.parse(JSON.stringify(this.dialogTableDataList));
  746. let userIdsLeft = JSON.parse(JSON.stringify(this.$refs.leftUserTable.selection))
  747. for(let i=0;i<userIdsLeft.length;i++){
  748. let obj = {
  749. userId:userIdsLeft[i].userId,
  750. name:userIdsLeft[i].nickName,
  751. jobNum:userIdsLeft[i].userName,
  752. deptName:userIdsLeft[i].deptName,
  753. deptId:userIdsLeft[i].deptId,
  754. userType:userIdsLeft[i].userType,
  755. avatar:userIdsLeft[i].avatar,
  756. }
  757. list.push(obj);
  758. }
  759. if(list.length>50){
  760. this.msgError('巡查成员最多50人')
  761. return
  762. }
  763. this.$set(this,'dialogTableDataList',list);
  764. this.$refs.leftUserTable.clearSelection();
  765. this.userHandleQueryLeft();
  766. this.userHandleQueryRight();
  767. }else{
  768. this.msgError('请先勾选左侧列表')
  769. }
  770. }
  771. },
  772. /*===记录勾选数据===
  773. 需要再el-table 添加 :row-key="getRowKeys"
  774. 需要在selection 添加 :reserve-selection="true"
  775. */
  776. getRowKeys(row) {
  777. return row.userId
  778. },
  779. },
  780. }
  781. </script>
  782. <style scoped lang="scss">
  783. .trainingCourseAddDialog{
  784. .add-dialog-form-box{
  785. height: 610px;
  786. }
  787. .dialogFormFlex{
  788. display:flex;
  789. }
  790. .inspectionPlan-dialog-user-box{
  791. display: flex;
  792. overflow: hidden;
  793. height:610px;
  794. .el-table__empty-text{
  795. background-size: 30%!important;
  796. }
  797. .dept-table-title-box{
  798. display: flex;
  799. padding:0 20px;
  800. background: rgba(1,131,250,0.1);
  801. p{
  802. flex:1;
  803. color:#0183FA;
  804. font-size:16px;
  805. line-height:40px;
  806. }
  807. p:nth-child(1){
  808. text-align: left;
  809. }
  810. p:nth-child(2){
  811. text-align: right;
  812. }
  813. }
  814. .dept-table-max-box{
  815. border: 1px solid #e0e0e0;
  816. flex:1;
  817. display: flex;
  818. flex-direction: column;
  819. overflow: hidden;
  820. padding:20px;
  821. .form-index{
  822. .el-input__inner{
  823. border-right:none;
  824. padding-right:0;
  825. }
  826. .el-input-group__append{
  827. background: #fff;
  828. cursor: pointer;
  829. padding:0 10px;
  830. }
  831. }
  832. input{
  833. border: 1px solid #DCDFE6;
  834. }
  835. }
  836. .left-max-box{
  837. height:610px;
  838. display: flex;
  839. flex-direction: column;
  840. overflow: hidden;
  841. width:632px;
  842. }
  843. .right-max-box{
  844. height:610px;
  845. display: flex;
  846. flex-direction: column;
  847. overflow: hidden;
  848. width:632px;
  849. }
  850. .center-box{
  851. width:68px;
  852. p{
  853. display: block;
  854. border-radius:50%;
  855. width:30px;
  856. height:30px;
  857. line-height:30px;
  858. text-align: center;
  859. background: rgba(245,245,245,1);
  860. color:rgba(62,62,62,1);
  861. cursor: pointer;
  862. font-size:16px;
  863. }
  864. p:nth-child(1){
  865. margin:270px 19px 0;
  866. }
  867. p:nth-child(2){
  868. margin:14px 19px 0;
  869. }
  870. p:hover{
  871. color:#fff;
  872. background: #0183fa;
  873. }
  874. }
  875. .el-icon-search{
  876. cursor: pointer;
  877. }
  878. ::v-deep .el-input-group__append{
  879. padding:0;
  880. p{
  881. text-align: center;
  882. line-height: 34px;
  883. width:50px;
  884. height:34px;
  885. font-size:16px;
  886. }
  887. }
  888. }
  889. .dialog-footer{
  890. display: flex;
  891. .dialog-footer-null-p{
  892. flex:1;
  893. }
  894. }
  895. }
  896. </style>