addDialog.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845
  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 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 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. obj.tutorId = this.addDialogData.tutorId.split(',');
  391. let userIdList = this.addDialogData.tutorId.split(',');
  392. let nickNameList = this.addDialogData.tutorName.split(',');
  393. let secondaryTeacherList = [];
  394. for(let i=0;i<userIdList.length;i++){
  395. secondaryTeacherList.push({userId:userIdList[i],nickName:nickNameList[i]})
  396. }
  397. this.$set(this,'secondaryTeacherOptions',secondaryTeacherList);
  398. }
  399. //处理实验室数据&手动输入场地
  400. if(this.addDialogData.subId){
  401. obj.subId = this.addDialogData.subId;
  402. obj.position = "";
  403. obj.selectType = 1;
  404. //处理实验室列表
  405. let subList = [{name:this.addDialogData.subName,id:this.addDialogData.subId}]
  406. this.$set(this,'subOptions',subList);
  407. }else{
  408. if(this.addDialogData.position){
  409. obj.subId = "";
  410. obj.position = this.addDialogData.position;
  411. obj.selectType = 2;
  412. }else{
  413. obj.subId = "";
  414. obj.position = "";
  415. obj.selectType = 1;
  416. }
  417. }
  418. //处理学生数据
  419. for(let i=0;i<self.addDialogData.userIds.length;i++){
  420. obj.userIds.push({userId:self.addDialogData.userIds[i]})
  421. }
  422. //根据当前选择院系获取实验室列表
  423. this.getSubList('',this.addDialogData.placeId)
  424. this.$set(this,'dialogForm',obj);
  425. }
  426. this.getDeptList();
  427. },
  428. //提交按钮
  429. dialogSubmit(){
  430. let self = this;
  431. if(this.dialogUserType){
  432. //选择人员页面
  433. if(!this.dialogTableDataList[0]){
  434. this.msgError('请选择人员')
  435. return
  436. }
  437. let userList = JSON.parse(JSON.stringify(this.dialogTableDataList))
  438. this.$set(this.dialogForm,'userIds',userList)
  439. this.$set(this,'dialogUserType',false)
  440. }else{
  441. //提交页面
  442. this.$refs["dialogForm"].validate(valid => {
  443. if (valid) {
  444. if(this.dialogForm.id){
  445. //编辑
  446. let obj = {
  447. id:this.dialogForm.id,
  448. courseName:this.dialogForm.courseName,
  449. lecturerId:this.dialogForm.lecturerId,
  450. lecturerName:this.dialogForm.lecturerName,
  451. tutorId:this.dialogForm.tutorId+'',
  452. userIds:[],
  453. placeId:this.dialogForm.placeId,
  454. place:this.dialogForm.place,
  455. coStartTime:this.dialogForm.courseTime[0],
  456. coEndTime:this.dialogForm.courseTime[1],
  457. courseDate:[this.dialogForm.courseDate,this.dialogForm.courseDate],
  458. content:this.dialogForm.content,
  459. peopleCount:this.dialogForm.userIds.length,
  460. }
  461. if(this.dialogForm.selectType == 1){
  462. obj.subId = this.dialogForm.subId;
  463. }else{
  464. obj.position = this.dialogForm.position;
  465. }
  466. for(let i=0;i<self.dialogForm.userIds.length;i++){
  467. obj.userIds.push(self.dialogForm.userIds[i].userId)
  468. }
  469. securitycourseEdit(obj).then(response => {
  470. this.msgSuccess(response.msg)
  471. this.$parent.controlsButton(6)
  472. });
  473. }else{
  474. //提交
  475. let obj = {
  476. courseName:this.dialogForm.courseName,
  477. lecturerId:this.dialogForm.lecturerId,
  478. lecturerName:this.dialogForm.lecturerName,
  479. tutorId:this.dialogForm.tutorId+'',
  480. userIds:[],
  481. placeId:this.dialogForm.placeId,
  482. place:this.dialogForm.place,
  483. coStartTime:this.dialogForm.courseTime[0],
  484. coEndTime:this.dialogForm.courseTime[1],
  485. courseDate:this.dialogForm.courseDate,
  486. content:this.dialogForm.content,
  487. peopleCount:this.dialogForm.userIds.length,
  488. }
  489. if(this.dialogForm.selectType == 1){
  490. obj.subId = this.dialogForm.subId;
  491. }else{
  492. obj.position = this.dialogForm.position;
  493. }
  494. for(let i=0;i<self.dialogForm.userIds.length;i++){
  495. obj.userIds.push(self.dialogForm.userIds[i].userId)
  496. }
  497. securitycourseAdd(obj).then(response => {
  498. this.msgSuccess(response.msg)
  499. this.$parent.controlsButton(6)
  500. });
  501. }
  502. console.log('dialogForm',this.dialogForm)
  503. }
  504. })
  505. }
  506. },
  507. //取消按钮
  508. dialogClose(){
  509. if(this.dialogUserType){
  510. //选择人员页面
  511. this.$set(this,'dialogTitle',this.addDialogData.id?'编辑':'添加');
  512. this.$set(this,'dialogUserType',false);
  513. }else{
  514. //提交页面
  515. this.$parent.controlsButton(5)
  516. }
  517. },
  518. //主要老师选中
  519. lecturerIdChange(val){
  520. let self = this;
  521. for(let i=0;i<self.mainTeacherOptions.length;i++){
  522. if(self.mainTeacherOptions[i].userId == val){
  523. this.$set(this.dialogForm,'lecturerName',self.mainTeacherOptions[i].nickName);
  524. }
  525. }
  526. },
  527. //主要老师搜索
  528. getMainTeacher(query){
  529. if(query.length > 1){
  530. this.loading = true;
  531. selectUser({userType:11,nickName:query}).then(response => {
  532. this.$set(this,'mainTeacherOptions',response.data)
  533. this.loading = false;
  534. });
  535. }
  536. },
  537. //辅助老师搜错
  538. getSecondaryTeacher(query){
  539. if(query.length > 1){
  540. this.loading = true;
  541. selectUser({userType:11,nickName:query}).then(response => {
  542. this.$set(this,'secondaryTeacherOptions',response.data)
  543. this.loading = false;
  544. });
  545. }
  546. },
  547. //选择院系
  548. deptChange(val){
  549. let self = this;
  550. for(let i=0;i<self.deptOptions.length;i++){
  551. if(self.deptOptions[i].deptId == val){
  552. this.$set(this.dialogForm,'place',self.deptOptions[i].deptName);
  553. }
  554. }
  555. this.$set(this.dialogForm,'subId','');
  556. this.getSubList('')
  557. },
  558. //获取院系列表
  559. getDeptList(){
  560. departmentsList().then(response => {
  561. this.$set(this,'deptOptions',response.data);
  562. });
  563. },
  564. //获取实验室列表
  565. getSubList(val,deptId){
  566. console.log(val,deptId)
  567. if(val == '' && deptId){
  568. subListAdmin({deptId:deptId,name:val}).then(response => {
  569. this.$set(this,'subOptions',response.data);
  570. });
  571. }else if(this.dialogForm.placeId && (val == '' || val.length > 1)){
  572. subListAdmin({deptId:this.dialogForm.placeId,name:val}).then(response => {
  573. this.$set(this,'subOptions',response.data);
  574. });
  575. }
  576. },
  577. //实验室切换
  578. subTypeClick(){
  579. this.$set(this.dialogForm,'subId','');
  580. this.$set(this.dialogForm,'selectType',this.dialogForm.selectType==1?2:1);
  581. },
  582. //开启人员选择
  583. addUserButton(){
  584. let userList = JSON.parse(JSON.stringify(this.dialogForm.userIds))
  585. this.$set(this,'dialogTableDataList',userList)
  586. this.$set(this,'dialogTitle','选择人员');
  587. this.$set(this,'dialogUserType',true);
  588. this.userHandleQueryLeft();
  589. this.userHandleQueryRight();
  590. },
  591. /*===================================人员选择相关===================================*/
  592. //查询
  593. userHandleQueryLeft(){
  594. this.$set(this.userQueryParamsLeft,'pageNum',1);
  595. this.$set(this,'userNumLeft',0);
  596. this.$set(this,'userIdsLeft',[]);
  597. this.$refs.leftUserTable.clearSelection();
  598. this.userGetListLeft();
  599. },
  600. //重置
  601. userResetQueryLeft(){
  602. this.$set(this,'userQueryParamsLeft',{
  603. pageNum: 1,
  604. pageSize: 20,
  605. deptId:"",
  606. searchValue:"",
  607. filtType:1
  608. });
  609. this.userHandleQueryLeft();
  610. },
  611. //查询接口
  612. userGetListLeft(){
  613. let self = this;
  614. let leftObj = JSON.parse(JSON.stringify(this.userQueryParamsLeft));
  615. leftObj.selectedUserIds = [];
  616. for(let i=0;i<self.dialogTableDataList.length;i++){
  617. leftObj.selectedUserIds.push(self.dialogTableDataList[i].userId);
  618. }
  619. findUserList(leftObj).then(response => {
  620. this.userTotalLeft = response.total;
  621. this.userTableListLeft = response.rows;
  622. });
  623. },
  624. //查询
  625. userHandleQueryRight(){
  626. this.$set(this.userQueryParamsRight,'pageNum',1);
  627. this.$set(this,'userNumRight',0);
  628. this.$set(this,'userIdsRight',[]);
  629. this.$refs.rightUserTable.clearSelection();
  630. this.userGetListRight();
  631. },
  632. //重置
  633. userResetQueryRight(){
  634. this.$set(this,'userQueryParamsRight',{
  635. pageNum: 1,
  636. pageSize: 20,
  637. deptId:"",
  638. searchValue:"",
  639. filtType:2
  640. });
  641. this.userHandleQueryRight();
  642. },
  643. //查询接口
  644. userGetListRight(){
  645. let self = this;
  646. let rightObj = JSON.parse(JSON.stringify(this.userQueryParamsRight));
  647. rightObj.userIds = [];
  648. for(let i=0;i<self.dialogTableDataList.length;i++){
  649. rightObj.userIds.push(self.dialogTableDataList[i].userId);
  650. }
  651. findUserList(rightObj).then(response => {
  652. this.userTotalRight = response.total;
  653. this.userTableListRight = response.rows;
  654. });
  655. },
  656. userChangeLeft(selection){
  657. this.userNumLeft = selection.length;
  658. this.userIdsLeft = selection.map(item => item.userId);
  659. },
  660. userChangeRight(selection){
  661. this.userNumRight = selection.length;
  662. this.userIdsRight = selection.map(item => item.userId);
  663. },
  664. //人员穿梭按钮
  665. userArrowButton(type){
  666. let self = this;
  667. if(type == 1){
  668. //右至左
  669. if(this.$refs.rightUserTable.selection[0]){
  670. let list = JSON.parse(JSON.stringify(this.dialogTableDataList));
  671. let userIdsRight = JSON.parse(JSON.stringify(this.$refs.rightUserTable.selection))
  672. for(let i=0;i<userIdsRight.length;i++){
  673. for(let s=0;s<list.length;s++){
  674. if(userIdsRight[i].userId == list[s].userId){
  675. list.splice(s,1);
  676. s--
  677. }
  678. }
  679. }
  680. this.$set(this,'dialogTableDataList',list);
  681. this.$refs.rightUserTable.clearSelection();
  682. this.userHandleQueryLeft();
  683. this.userHandleQueryRight();
  684. }else{
  685. this.msgError('请先勾选右侧列表')
  686. }
  687. }else if(type == 2){
  688. //左至右
  689. if(this.userIdsLeft[0]){
  690. let list = JSON.parse(JSON.stringify(this.dialogTableDataList));
  691. let userIdsLeft = JSON.parse(JSON.stringify(this.$refs.leftUserTable.selection))
  692. for(let i=0;i<userIdsLeft.length;i++){
  693. let obj = {
  694. userId:userIdsLeft[i].userId,
  695. name:userIdsLeft[i].nickName,
  696. jobNum:userIdsLeft[i].userName,
  697. deptName:userIdsLeft[i].deptName,
  698. deptId:userIdsLeft[i].deptId,
  699. userType:userIdsLeft[i].userType,
  700. }
  701. list.push(obj);
  702. }
  703. if(list.length>50){
  704. this.msgError('巡查成员最多50人')
  705. return
  706. }
  707. this.$set(this,'dialogTableDataList',list);
  708. this.$refs.leftUserTable.clearSelection();
  709. this.userHandleQueryLeft();
  710. this.userHandleQueryRight();
  711. }else{
  712. this.msgError('请先勾选左侧列表')
  713. }
  714. }
  715. },
  716. /*===记录勾选数据===
  717. 需要再el-table 添加 :row-key="getRowKeys"
  718. 需要在selection 添加 :reserve-selection="true"
  719. */
  720. getRowKeys(row) {
  721. return row.userId
  722. },
  723. },
  724. }
  725. </script>
  726. <style scoped lang="scss">
  727. .trainingCourseAddDialog{
  728. .add-dialog-form-box{
  729. height: 610px;
  730. }
  731. .dialogFormFlex{
  732. display:flex;
  733. }
  734. .inspectionPlan-dialog-user-box{
  735. display: flex;
  736. overflow: hidden;
  737. height:610px;
  738. .el-table__empty-text{
  739. background-size: 30%!important;
  740. }
  741. .dept-table-title-box{
  742. display: flex;
  743. padding:0 20px;
  744. background: rgba(1,131,250,0.1);
  745. p{
  746. flex:1;
  747. color:#0183FA;
  748. font-size:16px;
  749. line-height:40px;
  750. }
  751. p:nth-child(1){
  752. text-align: left;
  753. }
  754. p:nth-child(2){
  755. text-align: right;
  756. }
  757. }
  758. .dept-table-max-box{
  759. border: 1px solid #e0e0e0;
  760. flex:1;
  761. display: flex;
  762. flex-direction: column;
  763. overflow: hidden;
  764. padding:20px;
  765. .form-index{
  766. .el-input__inner{
  767. border-right:none;
  768. padding-right:0;
  769. }
  770. .el-input-group__append{
  771. background: #fff;
  772. cursor: pointer;
  773. padding:0 10px;
  774. }
  775. }
  776. input{
  777. border: 1px solid #DCDFE6;
  778. }
  779. }
  780. .left-max-box{
  781. height:610px;
  782. display: flex;
  783. flex-direction: column;
  784. overflow: hidden;
  785. width:632px;
  786. }
  787. .right-max-box{
  788. height:610px;
  789. display: flex;
  790. flex-direction: column;
  791. overflow: hidden;
  792. width:632px;
  793. }
  794. .center-box{
  795. width:68px;
  796. p{
  797. display: block;
  798. border-radius:50%;
  799. width:30px;
  800. height:30px;
  801. line-height:30px;
  802. text-align: center;
  803. background: rgba(245,245,245,1);
  804. color:rgba(62,62,62,1);
  805. cursor: pointer;
  806. font-size:16px;
  807. }
  808. p:nth-child(1){
  809. margin:270px 19px 0;
  810. }
  811. p:nth-child(2){
  812. margin:14px 19px 0;
  813. }
  814. p:hover{
  815. color:#fff;
  816. background: #0183fa;
  817. }
  818. }
  819. .el-icon-search{
  820. cursor: pointer;
  821. }
  822. ::v-deep .el-input-group__append{
  823. padding:0;
  824. p{
  825. text-align: center;
  826. line-height: 34px;
  827. width:50px;
  828. height:34px;
  829. font-size:16px;
  830. }
  831. }
  832. }
  833. .dialog-footer{
  834. display: flex;
  835. .dialog-footer-null-p{
  836. flex:1;
  837. }
  838. }
  839. }
  840. </style>