addDialog.vue 31 KB

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