PlanRegister.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158
  1. <template>
  2. <div>
  3. <!---lxh-修改密码-->
  4. <div class="dig_update">
  5. <el-dialog
  6. :visible.sync="dialogVisible"
  7. :close-on-click-modal="false"
  8. width="40%"
  9. top="5vh"
  10. style="overflow: hidden"
  11. >
  12. <div slot="title">
  13. <el-form
  14. :model="ruleForm"
  15. :rules="rules"
  16. :inline="true"
  17. ref="ruleForm"
  18. label-width="150px"
  19. class="demo-ruleForm"
  20. >
  21. <p v-if="isView" class="dig_title">新增计划</p>
  22. <p v-if="!isView" class="dig_title">编辑计划</p>
  23. <div slot=""></div>
  24. <div slot="footer"></div>
  25. <div
  26. style="
  27. height: 60vh;
  28. overflow-y: auto;
  29. padding-left: 20px;
  30. padding-right: 20px;
  31. "
  32. class="form_main"
  33. >
  34. <el-form-item label="计划名称" prop="planName">
  35. <el-input v-model="ruleForm.planName"></el-input>
  36. </el-form-item>
  37. <!-- <el-button v-show="true">asasas</el-button> -->
  38. <div v-if="userInfo.roleType != '3'">
  39. <el-form-item label="测评对象" prop="planType">
  40. <el-radio-group v-model="ruleForm.planType" @change="teacherChange">
  41. <el-radio label="1">教师</el-radio>
  42. <el-radio label="0">学生</el-radio>
  43. </el-radio-group>
  44. </el-form-item>
  45. </div>
  46. <el-form-item label="结束时间" prop="endTime">
  47. <el-date-picker
  48. v-model="ruleForm.endTime"
  49. type="date"
  50. placeholder="选择日期"
  51. @change="timeChange"
  52. :picker-options="expireTimeOption"
  53. >
  54. </el-date-picker>
  55. </el-form-item>
  56. <div v-show="ruleForm.planType == '0'">
  57. <el-form-item label="快捷选项">
  58. <el-row>
  59. <el-col :span="12">
  60. <!-- @change="gradeChange"
  61. @remove-tag="gradeRemoveChange"
  62. -->
  63. <el-select
  64. :collapse-tags="true"
  65. multiple
  66. placeholder="请选择年级"
  67. v-model="grade"
  68. clearable
  69. filterable
  70. >
  71. <el-option
  72. v-for="item in gradeOption"
  73. :key="item.value"
  74. :label="item.label"
  75. :value="item.value"
  76. >
  77. </el-option>
  78. </el-select>
  79. </el-col>
  80. <el-col :span="12" style="text-align: right">
  81. <el-select
  82. v-show="userInfo.roleType != '3'"
  83. :collapse-tags="true"
  84. multiple
  85. placeholder="请选择辅导员"
  86. v-model="instructor"
  87. clearable
  88. filterable
  89. >
  90. <el-option
  91. v-for="item in instructorOption"
  92. :key="item.value"
  93. :label="item.label"
  94. :value="item.value"
  95. >
  96. </el-option>
  97. </el-select>
  98. </el-col>
  99. </el-row>
  100. </el-form-item>
  101. </div>
  102. <el-button
  103. type="info"
  104. style="line-height: 10px; margin-top: 10px; font-size: 12px"
  105. round
  106. size="mini"
  107. @click="selectAllDataOrg()"
  108. >全选组织架构</el-button
  109. >
  110. <el-button
  111. type="info"
  112. style="line-height: 10px; margin-top: 10px; font-size: 12px"
  113. round
  114. size="mini"
  115. @click="clearDataOrg()"
  116. >清空组织架构</el-button
  117. >
  118. <div style="display: flex">
  119. <el-form-item label="组织架构" prop="checkedList">
  120. <el-tree
  121. :data="treeData"
  122. show-checkbox
  123. node-key="id"
  124. default-expand-all
  125. :default-checked-keys="ruleForm.checkedList"
  126. :props="defaultProps"
  127. ref="tree"
  128. >
  129. </el-tree>
  130. </el-form-item>
  131. </div>
  132. <!-- <el-button @click="getCheckedNodes"> 获取已选 </el-button> -->
  133. <el-form-item label="量表选择" class="taskSelect">
  134. <el-checkbox-group v-model="ruleForm.checkboxGroup2" size="mini">
  135. <el-checkbox
  136. v-for="item in scaleList"
  137. :key="item.id"
  138. :label="item.flag"
  139. border
  140. :disabled="item.isRequired == '1'"
  141. >{{ item.name }}</el-checkbox
  142. >
  143. <!-- <el-checkbox
  144. v-for="item in taskList"
  145. :key="item.id"
  146. :label="item.flag"
  147. border
  148. :disabled="item.isRequired == '1'"
  149. >{{ item.name }}</el-checkbox
  150. > -->
  151. </el-checkbox-group>
  152. </el-form-item>
  153. <el-form-item label="任务选择" class="taskSelect" prop="taskRadio">
  154. <el-select v-model="ruleForm.taskRadio" placeholder="请选择">
  155. <el-option
  156. v-for="item in taskList"
  157. :key="item.flag"
  158. :label="item.name"
  159. :value="item.flag"
  160. >
  161. </el-option>
  162. </el-select>
  163. <!-- <el-radio-group v-model="ruleForm.taskRadio">
  164. <el-radio v-for="item in taskList" :key="item" :label="item.flag">
  165. {{item.name}}
  166. </el-radio>
  167. </el-radio-group> -->
  168. <!-- <el-checkbox-group v-model="ruleForm.checkboxGroup2" size="mini">
  169. <el-checkbox
  170. v-for="item in taskList"
  171. :key="item.id"
  172. :label="item.flag"
  173. border
  174. :disabled="item.isRequired == '1'"
  175. >{{ item.name }}</el-checkbox
  176. >
  177. </el-checkbox-group> -->
  178. </el-form-item>
  179. </div>
  180. </el-form>
  181. <div class="dig_button">
  182. <el-button type="info" round @click="resetData()">取消</el-button>
  183. <el-button :disabled="disableFlag" type="success" round @click="submitCom()"
  184. >提交</el-button
  185. >
  186. </div>
  187. </div>
  188. <!-- <div slot="footer">
  189. <div class="dig_button">
  190. <el-button type="info" round @click="resetData()">重置</el-button>
  191. <el-button type="success" round @click="submitCom()">下一步</el-button>
  192. </div>
  193. </div> -->
  194. </el-dialog>
  195. </div>
  196. </div>
  197. </template>
  198. <script>
  199. // import { oSessionStorage } from "../../utils/utils";
  200. import { oSessionStorage } from "../utils/utils";
  201. import md5 from "md5";
  202. export default {
  203. data() {
  204. return {
  205. expireTimeOption: {
  206. disabledDate(date) {
  207. // 当天可选:date.getTime() < Date.now() - 24 * 60 * 60 * 1000
  208. return date.getTime() < Date.now();
  209. },
  210. },
  211. //编辑返回的值
  212. userDetailData: {},
  213. //组织架构名字
  214. groupName: "",
  215. disableFlag: false,
  216. phoneFlag: false,
  217. flag: 3,
  218. dialogVisible: false,
  219. //渠道列表
  220. ruleForm: {
  221. //所属组织架构
  222. planName: "",
  223. planType: "0",
  224. endTime: "",
  225. checkboxGroup2: [],
  226. checkedList: [],
  227. taskRadio: "",
  228. },
  229. isView: true,
  230. rules: {
  231. planName: [{ required: true, message: "请输入计划名称", trigger: "blur" }],
  232. endTime: [{ required: true, message: "请输入结束时间", trigger: "blur" }],
  233. checkedList: [{ required: true, message: "请选择组织架构", trigger: "blur" }],
  234. taskRadio: [{ required: true, message: "请选择任务", trigger: "blur" }],
  235. },
  236. userInfo: {},
  237. scaleAndCon: [],
  238. //查看是不是两次都调用完了
  239. countList: [],
  240. //显示用的认知任务名称
  241. cognitionName: "",
  242. id: "",
  243. //学生届数
  244. gradeOption: [],
  245. //辅导员列表
  246. instructorOption: [],
  247. //辅导员的原始列表
  248. teacherList: [],
  249. //树形选择班级的框
  250. treeData: [
  251. {
  252. id: 1,
  253. label: "一级 1",
  254. },
  255. ],
  256. defaultProps: {
  257. children: "children",
  258. label: "label",
  259. },
  260. //所选届数
  261. grade: [],
  262. instructor: [],
  263. ppData: [],
  264. //任务可选量表数据
  265. scaleAndTaskList: [],
  266. scaleList: [],
  267. taskList: [],
  268. //辅导员的组织架构
  269. teacherOrgList: [],
  270. };
  271. },
  272. //需要监听变量
  273. //如果这样变量增加的是谁,减少的是谁都知道
  274. watch: {
  275. grade(newCount, oldCount) {
  276. //首先是判断是新增还是减少
  277. //如果是新增
  278. if (newCount.length > oldCount.length) {
  279. let poor = newCount.filter((a) => !oldCount.includes(a));
  280. //此时新增的话需要调用方法
  281. //此时要判断增加的是谁
  282. if (poor.length == 1) {
  283. this.gradeAdd(poor[0], "isGrade");
  284. }
  285. } else if (newCount.length < oldCount.length) {
  286. let poor = oldCount.filter((a) => !newCount.includes(a));
  287. if (poor.length == 1) {
  288. this.gradeDecrease(poor[0], "isGrade");
  289. }
  290. }
  291. //如果是减少
  292. },
  293. //判断是减少还是增多
  294. instructor(newCount, oldCount) {
  295. if (newCount.length > oldCount.length) {
  296. let poor = newCount.filter((a) => !oldCount.includes(a));
  297. //此时新增的话需要调用方法
  298. //此时要判断增加的是谁
  299. if (poor.length == 1) {
  300. this.gradeAdd(poor[0], "noGrade");
  301. }
  302. } else if (newCount.length < oldCount.length) {
  303. let poor = oldCount.filter((a) => !newCount.includes(a));
  304. if (poor.length == 1) {
  305. this.gradeDecrease(poor[0], "noGrade");
  306. }
  307. }
  308. },
  309. },
  310. mounted() {
  311. this.userInfo = JSON.parse(oSessionStorage.getItem("userInfo"));
  312. // this.ruleForm.type = "3";
  313. },
  314. methods: {
  315. teacherChange(val) {
  316. this.getChannel();
  317. //当val == 1 时 调用查询组织架构的方法
  318. //重新绘制
  319. },
  320. // pickerOptions1() {},
  321. //查询学生模版
  322. queryStudentTemp() {
  323. this.$http.get(`/content/findAllByTemplate?template=studentContent`, {}, (res) => {
  324. // this.$toast.success({message:'成功'});
  325. if (res && res.code == 200) {
  326. //将值赋值给list
  327. if (res.data.length > 0) {
  328. this.scaleAndTaskList = res.data;
  329. this.scaleList = res.data.filter((item) => {
  330. //并且 是必须展示的
  331. return item.type == "0" && item.isDisplayed == "1";
  332. });
  333. this.taskList = res.data.filter((item) => {
  334. return item.type == "1" && item.isDisplayed == "1";
  335. });
  336. let listRequest = res.data.filter((item) => {
  337. return item.isRequired == "1";
  338. });
  339. this.ruleForm.checkboxGroup2 = [];
  340. for (let i = 0; i < listRequest.length; i++) {
  341. this.ruleForm.checkboxGroup2.push(listRequest[i].flag);
  342. }
  343. } else {
  344. // this.groupData = [];
  345. }
  346. // this.channelList = res.data;
  347. } else {
  348. this.$message.error(res.msg);
  349. }
  350. });
  351. },
  352. //获取辅导员
  353. getTeacher() {
  354. this.instructorOption = [];
  355. this.$http.get(`/user/findAllCounsellor`, {}, (res) => {
  356. // this.$toast.success({message:'成功'});
  357. if (res && res.code == 200) {
  358. //将值赋值给list
  359. if (res.data.length > 0) {
  360. //
  361. this.teacherList = res.data;
  362. for (let i = 0; i < res.data.length; i++) {
  363. //
  364. let obj = {
  365. value: res.data[i].userNo,
  366. label: res.data[i].userName,
  367. };
  368. this.instructorOption.push(obj);
  369. }
  370. } else {
  371. // this.groupData = [];
  372. }
  373. // this.channelList = res.data;
  374. } else {
  375. this.$message.error(res.msg);
  376. }
  377. });
  378. },
  379. //当选择的届减少时
  380. gradeDecrease(val, flag) {
  381. //减少的时候去查询
  382. let original = JSON.parse(JSON.stringify(this.ruleForm.checkedList));
  383. let gradeIds = [];
  384. if (flag == "isGrade") {
  385. for (let i = 0; i < this.ppData.length; i++) {
  386. if (this.ppData[i].extend == val) {
  387. //将此选项的ID保存下来
  388. gradeIds.push(this.ppData[i].id);
  389. }
  390. }
  391. } else {
  392. //
  393. for (let i = 0; i < this.teacherList.length; i++) {
  394. if (this.teacherList[i].userNo == val) {
  395. if (this.teacherList[i].gradeEntities.length > 0) {
  396. for (let j = 0; j < this.teacherList[i].gradeEntities.length; j++) {
  397. gradeIds.push(this.teacherList[i].gradeEntities[j].orgNo);
  398. }
  399. }
  400. }
  401. }
  402. }
  403. //求差值
  404. this.ruleForm.checkedList = original.filter((item) => !gradeIds.includes(item));
  405. //这些ID都需要从已选中去掉
  406. this.$refs.tree.setCheckedKeys(this.ruleForm.checkedList);
  407. //应该是要判断减少的是什么
  408. },
  409. //当选择的届发生改变时
  410. gradeAdd(val, flag) {
  411. //获取当前已选列表
  412. //届数改变以后
  413. //获取数行已选项,将已选ID组合
  414. //---------------已选 开始----------
  415. this.ruleForm.checkedList = [];
  416. // this.$refs.tree.setCheckedKeys([]);
  417. let list = this.$refs.tree.getCheckedNodes();
  418. let listIds = [];
  419. if (list.length > 0) {
  420. for (let i = 0; i < list.length; i++) {
  421. if (list[i].id.length == 12) {
  422. listIds.push(list[i].id);
  423. }
  424. }
  425. }
  426. //---------------已选 结束----------
  427. //---------------筛选届 开始----------
  428. let gradeIds = [];
  429. if (flag == "isGrade") {
  430. for (let i = 0; i < this.ppData.length; i++) {
  431. if (this.ppData[i].extend == val) {
  432. //将此选项的ID保存下来
  433. gradeIds.push(this.ppData[i].id);
  434. }
  435. }
  436. } else {
  437. //去遍历数组
  438. for (let i = 0; i < this.teacherList.length; i++) {
  439. if (this.teacherList[i].userNo == val) {
  440. if (this.teacherList[i].gradeEntities.length > 0) {
  441. for (let j = 0; j < this.teacherList[i].gradeEntities.length; j++) {
  442. gradeIds.push(this.teacherList[i].gradeEntities[j].orgNo);
  443. }
  444. }
  445. }
  446. }
  447. }
  448. //合并两个数组
  449. let listAll = gradeIds.concat(listIds);
  450. //然后去重
  451. let listDeWeight = listAll.filter((item, index, arr) => {
  452. return arr.indexOf(item) == index;
  453. });
  454. this.ruleForm.checkedList = listDeWeight;
  455. //然后将两个数组进行合并去重
  456. //---------------筛选届 结束----------
  457. //再将届数的id合并仅已选组合
  458. },
  459. // gradeAdd(val) {
  460. // //获取当前已选列表
  461. // console.log(this.grade);
  462. // //届数改变以后
  463. // //获取数行已选项,将已选ID组合
  464. // //---------------已选 开始----------
  465. // this.checkedList = [];
  466. // let list = this.$refs.tree.getCheckedNodes();
  467. // let listIds = [];
  468. // if (list.length > 0) {
  469. // for (let i = 0; i < list.length; i++) {
  470. // listIds.push(list[i].id);
  471. // }
  472. // }
  473. // //---------------已选 结束----------
  474. // //---------------筛选届 开始----------
  475. // let gradeIds = [];
  476. // if (this.grade.length > 0) {
  477. // for (let i = 0; i < this.ppData.length; i++) {
  478. // for (let j = 0; j < this.grade.length; j++) {
  479. // if (this.ppData[i].extend == this.grade[j]) {
  480. // //将此选项的ID保存下来
  481. // gradeIds.push(this.ppData[i].id);
  482. // }
  483. // }
  484. // }
  485. // }
  486. // //合并两个数组
  487. // let listAll = gradeIds.concat(listIds);
  488. // //然后去重
  489. // let listDeWeight = listAll.filter((item) => {
  490. // return listAll.indexOf(item);
  491. // });
  492. // console.log("去重listDeWeight");
  493. // console.log(listDeWeight);
  494. // this.checkedList = listDeWeight;
  495. // //然后将两个数组进行合并去重
  496. // //---------------筛选届 结束----------
  497. // //再将届数的id合并仅已选组合
  498. // },
  499. //通过node获取方法已选选项
  500. getCheckedNodes() {
  501. // console.log(this.$refs.tree.getCheckedNodes());
  502. let list = [];
  503. list = this.$refs.tree.getCheckedKeys();
  504. this.ruleForm.checkedList = list.filter((item) => {
  505. return item.length == 12;
  506. });
  507. // this.ruleForm.checkedList=this.$refs.tree.getCheckedNodes()
  508. //循环得到ID 将ID放入数组
  509. },
  510. //获取组织架构方法--------------------开始-----------------------
  511. getChannel() {
  512. this.$http.get(
  513. // `/org/findAllOrgByPOrgNo?orgNo=${this.userInfo.orgNo}`,
  514. `/org/findAllOrgByCurrent`,
  515. {},
  516. (res) => {
  517. // this.$toast.success({message:'成功'});
  518. if (res && res.code == 200) {
  519. //将值赋值给list
  520. if (res.data.length > 0) {
  521. //当用户角色为3时 需要将数据处理为辅导员的数据
  522. //选择出来需要的级
  523. //--------------------------------开始
  524. //
  525. //需要保存数据
  526. let list = [];
  527. for (let i = 0; i < res.data.length; i++) {
  528. if (res.data[i].extend !== null && res.data[i].extend !== "") {
  529. let obj = {
  530. value: res.data[i].extend,
  531. label:
  532. res.data[i].extend == -1 ? "教师组" : `${res.data[i].extend}级`,
  533. };
  534. list.push(obj);
  535. }
  536. }
  537. //存储最新的
  538. let listTT = [];
  539. //储存最后过滤数据
  540. let listTMP = [];
  541. //过滤重复数据
  542. listTMP = list.filter((item, index, arr) => {
  543. if (listTT.indexOf(item.label) == -1) {
  544. listTT.push(item.label);
  545. return true;
  546. }
  547. });
  548. console.log(listTMP);
  549. this.gradeOption = listTMP.reverse();
  550. //--------------------------------结束
  551. let resAdd = this.addPro(res.data);
  552. this.ppData = JSON.parse(JSON.stringify(resAdd));
  553. let forRes = this.arrToTree(resAdd);
  554. let resultRes = this.deleteChildren(forRes);
  555. let levelList = this.markersFun(resultRes, 1);
  556. //修改测试计划
  557. let listOrg = levelList[0].children;
  558. this.treeData = listOrg;
  559. //判断选择时教师还是学生
  560. if (this.ruleForm.planType == "1") {
  561. let listOrg = levelList[0].children;
  562. this.treeData = listOrg.filter((item) => {
  563. return item.extend == -1;
  564. });
  565. } else {
  566. let listOrg = levelList[0].children;
  567. this.treeData = listOrg.filter((item) => {
  568. return item.extend != -1;
  569. });
  570. }
  571. //
  572. } else {
  573. this.groupData = [];
  574. }
  575. // this.channelList = res.data;
  576. } else {
  577. this.$message.error(res.msg);
  578. }
  579. }
  580. );
  581. },
  582. //z增加
  583. addPro(val) {
  584. let data = JSON.parse(JSON.stringify(val));
  585. for (let i = 0; i < val.length; i++) {
  586. data[i].id = val[i].orgNo;
  587. data[i].label = val[i].orgName;
  588. }
  589. return data;
  590. },
  591. //非递归方式:将平铺数据转换为树形结构数据
  592. arrToTree(arr) {
  593. let data = arr.filter((item) => {
  594. item.children = arr.filter((e) => {
  595. return item.orgNo === e.parentOrgNo;
  596. });
  597. return item.orgNo == this.userInfo.orgNo;
  598. });
  599. return data;
  600. },
  601. //去除转换树形结构数据后存在的空children
  602. deleteChildren(arr) {
  603. let childs = arr;
  604. for (let i = childs.length; i--; i > 0) {
  605. if (childs[i].children) {
  606. if (childs[i].children.length) {
  607. this.deleteChildren(childs[i].children);
  608. } else {
  609. delete childs[i].children;
  610. }
  611. }
  612. }
  613. return arr;
  614. },
  615. //标记层级
  616. markersFun(arr, level) {
  617. if (!arr || !arr.length) {
  618. return;
  619. }
  620. arr.forEach((item) => {
  621. item.level = level;
  622. //设置都可以编辑
  623. item.isEdit = true;
  624. //设置都可以增加
  625. item.isAdd = true;
  626. //设置都可以删除
  627. item.isDelete = true;
  628. // item.extend = true;
  629. item.isExtend = true;
  630. //当角色是超级管理员时
  631. if (this.userInfo.roleType == "5") {
  632. //则level 是三级时
  633. if (level == "3") {
  634. item.isAdd = false;
  635. }
  636. }
  637. // //当角色是院管理员时
  638. if (this.userInfo.roleType == "4") {
  639. //则level 是三级时
  640. if (level == "2") {
  641. item.isAdd = false;
  642. }
  643. }
  644. if (item.children && item.children.length) {
  645. //
  646. this.markersFun(item.children, level + 1);
  647. }
  648. });
  649. return arr;
  650. },
  651. //获取当前届数
  652. getGradeFun() {
  653. this.gradeOption = [];
  654. //获取当前届数
  655. //获取当前年份
  656. let date = new Date();
  657. let currentYear = date.getFullYear();
  658. let preYear = currentYear - 12;
  659. let list = [];
  660. for (let i = preYear; i < currentYear + 1; i++) {
  661. //
  662. let obj = {
  663. value: i + "",
  664. label: i + "级",
  665. };
  666. list.push(obj);
  667. }
  668. this.gradeOption = list.reverse();
  669. },
  670. resetForm(val) {
  671. this.cancle();
  672. },
  673. timeChange(val) {
  674. if (val !== null) {
  675. //根据时间得到格式化的数据
  676. this.ruleForm.endTime = this.formatterTime(val);
  677. }
  678. },
  679. formatterTime(val) {
  680. let date = new Date(val);
  681. let year = date.getFullYear();
  682. let month = date.getMonth() + 1;
  683. month = this.formatterMon(month);
  684. let day = date.getDate();
  685. day = this.formatterMon(day);
  686. return year + "-" + month + "-" + day;
  687. },
  688. formatterMon(val) {
  689. if (val < 10) {
  690. return "0" + val;
  691. } else {
  692. return val;
  693. }
  694. },
  695. open(val) {
  696. this.cancle();
  697. //打开后返回的数组
  698. this.dialogVisible = true;
  699. this.isView = val;
  700. //获取渠道信息
  701. // this.getGradeFun();
  702. this.getChannel();
  703. this.getTeacher();
  704. this.queryStudentTemp();
  705. //查询以下的教师
  706. //查询学生模版
  707. //添加计划
  708. //查询需要选择的量表
  709. this.$nextTick(() => {
  710. this.$refs.ruleForm.clearValidate();
  711. });
  712. },
  713. edit(val) {
  714. this.id = val.id;
  715. this.dialogVisible = true;
  716. this.isView = false;
  717. this.ruleForm.planType = val.planType;
  718. this.ruleForm.planName = val.planName;
  719. this.ruleForm.endTime = val.planEndTime;
  720. //将配置计划置空
  721. this.ruleForm.checkedList = [];
  722. this.$refs.tree.setCheckedKeys([]);
  723. //将快捷选项 届数 置空
  724. this.grade = [];
  725. //将快捷选项辅导员置空
  726. this.instructor = [];
  727. //将任务选择置空
  728. this.ruleForm.checkboxGroup2 = [];
  729. this.$refs["ruleForm"].clearValidate();
  730. this.userDetailData = val;
  731. // this.getGradeFun();
  732. this.getChannel();
  733. this.getTeacher();
  734. this.queryStudentTemp();
  735. //根据ID查询详情
  736. this.queryDetail();
  737. //调用查询详情的接口
  738. },
  739. //查询量表
  740. queryDetail() {
  741. //val 是查询的类型
  742. this.$http.get(`/plan/findPlanById?id=${this.id}`, {}, (res) => {
  743. if (res.code == 200) {
  744. //查询到已选任务的列表
  745. let list = [];
  746. list = res.data.contentEntities.filter((item) => {
  747. return item.isDisplayed == "1";
  748. });
  749. //已选任务的列表
  750. let listTask = [];
  751. for (let i = 0; i < list.length; i++) {
  752. //
  753. if(list[i].contentType=='1'){
  754. //
  755. this.ruleForm.taskRadio=list[i].flag;
  756. }else{
  757. listTask.push(list[i].flag);
  758. }
  759. }
  760. this.ruleForm.checkboxGroup2 = listTask;
  761. //查询到已选任务
  762. //查询到已选组织架构的列表
  763. let listOrg = [];
  764. //res.data.orgEntityList
  765. for (let i = 0; i < res.data.orgEntityList.length; i++) {
  766. //
  767. listOrg.push(res.data.orgEntityList[i].orgNo);
  768. }
  769. this.ruleForm.checkedList = listOrg;
  770. this.$refs.tree.setCheckedKeys(this.ruleForm.checkedList);
  771. }
  772. });
  773. },
  774. //全选组织架构
  775. selectAllDataOrg() {
  776. let list = [];
  777. for (let i = 0; i < this.treeData.length; i++) {
  778. list.push(this.treeData[i].orgNo);
  779. }
  780. this.ruleForm.checkedList = list;
  781. this.$refs.tree.setCheckedKeys(this.ruleForm.checkedList);
  782. },
  783. //清空组织架构
  784. clearDataOrg() {
  785. this.grade = [];
  786. this.instructor = [];
  787. this.$refs.tree.setCheckedKeys([]);
  788. },
  789. //调用查询详情的接口
  790. resetData() {
  791. //修改编辑计划--关闭该弹出框
  792. this.dialogVisible = false;
  793. // this.$refs["ruleForm"].clearValidate();
  794. // //清空表单
  795. // this.grade = [];
  796. // this.instructor = [];
  797. // this.ruleForm.planName = "";
  798. // this.ruleForm.endTime = "";
  799. // this.ruleForm.checkboxGroup2 = [];
  800. // this.$refs.tree.setCheckedKeys([]);
  801. // this.ruleForm.checkedList = [];
  802. },
  803. cancle() {
  804. this.$refs["ruleForm"].clearValidate();
  805. //清空表单
  806. this.instructor = [];
  807. this.grade = [];
  808. this.ruleForm.planName = "";
  809. this.ruleForm.endTime = "";
  810. this.ruleForm.taskRadio='';
  811. this.ruleForm.checkedList = [];
  812. this.$refs.tree.setCheckedKeys([]);
  813. this.ruleForm.checkboxGroup2 = [];
  814. this.dialogVisible = false;
  815. },
  816. disableFlagStatus() {
  817. this.disableFlag = false;
  818. // setTimeout(() => {
  819. // this.disableFlag = false;
  820. // }, 1500);
  821. },
  822. submitCom() {
  823. if (this.disableFlag) {
  824. return;
  825. }
  826. this.disableFlag = true;
  827. let validSp = [];
  828. if (this.isView) {
  829. validSp = ["planName", "endTime", "checkedList", "taskRadio"];
  830. } else {
  831. validSp = ["planName", "endTime", "checkedList", "taskRadio"];
  832. }
  833. let aa = [];
  834. //获取已选项
  835. //将值赋值给this.ruleForm.checkedList
  836. this.getCheckedNodes();
  837. this.$refs["ruleForm"].validateField(validSp, (valid) => {
  838. if (!valid) {
  839. aa.push(valid);
  840. //判断是编辑还是新增
  841. if (this.isView) {
  842. if (aa.length == 4) {
  843. this.disableFlag = true;
  844. this.register();
  845. } else {
  846. this.disableFlagStatus();
  847. }
  848. } else {
  849. if (aa.length == 4) {
  850. this.disableFlag = true;
  851. this.editUserFun();
  852. } else {
  853. this.disableFlagStatus();
  854. }
  855. }
  856. //都校验通过后可以触发注册接口了
  857. //调用方法进行入参
  858. } else {
  859. this.disableFlagStatus();
  860. }
  861. });
  862. },
  863. register() {
  864. let that = this;
  865. //获取已选任务的列表
  866. let list = [];
  867. let listTmp = [];
  868. let listTmpNo = [];
  869. listTmp = this.scaleAndTaskList.filter((item) => {
  870. return this.ruleForm.checkboxGroup2.includes(item.flag)||this.ruleForm.taskRadio==item.flag;
  871. });
  872. for (let i = 0; i < listTmp.length; i++) {
  873. let obj = {
  874. contentType: listTmp[i].type,
  875. flag: listTmp[i].flag,
  876. isDisplayed: listTmp[i].isDisplayed,
  877. isAvailable: listTmp[i].isAvailable,
  878. name: listTmp[i].name,
  879. expectTime: listTmp[i].expectTime,
  880. };
  881. list.push(obj);
  882. }
  883. //不展示要传输到后台的字段
  884. listTmpNo = this.scaleAndTaskList.filter((item) => {
  885. return item.isDisplayed == "0";
  886. });
  887. for (let i = 0; i < listTmpNo.length; i++) {
  888. let obj = {
  889. contentType: listTmpNo[i].type,
  890. flag: listTmpNo[i].flag,
  891. isDisplayed: listTmpNo[i].isDisplayed,
  892. isAvailable: listTmpNo[i].isAvailable,
  893. name: listTmpNo[i].name,
  894. expectTime: listTmpNo[i].expectTime,
  895. };
  896. list.push(obj);
  897. }
  898. //得到不展示的数组
  899. //获取已选组织架构的列表
  900. let listOrg = [];
  901. let listOrgTmp = [];
  902. listOrgTmp = this.ppData.filter((item) => {
  903. return this.ruleForm.checkedList.includes(item.orgNo);
  904. });
  905. for (let i = 0; i < listOrgTmp.length; i++) {
  906. let obj = {
  907. orgNo: listOrgTmp[i].orgNo,
  908. orgName: listOrgTmp[i].orgName,
  909. };
  910. listOrg.push(obj);
  911. }
  912. // this.ruleForm.password = md5(this.ruleForm.password);
  913. this.$http.post(
  914. `/plan/addOrUpdate`,
  915. {
  916. // planType:this.ruleForm.planType,
  917. contentEntities: list,
  918. orgEntityList: listOrg,
  919. planName: this.ruleForm.planName,
  920. planEndTime: this.ruleForm.endTime,
  921. createUserId: this.userInfo.id,
  922. createUserName: this.userInfo.userName,
  923. planOrgNo: this.userInfo.orgNo,
  924. planOrgName: this.userInfo.orgName,
  925. planType: this.ruleForm.planType,
  926. },
  927. (res) => {
  928. this.disableFlagStatus();
  929. // this.disableFlag = false;
  930. if (res && res.code == 200) {
  931. this.dialogVisible = false;
  932. // this.$toast.success({ message: "成功" });
  933. //调用父组件的查询方法
  934. that.$emit("search");
  935. // that.$emit("configuration", res.data);
  936. //也调用打开人员配置的方法
  937. } else {
  938. // this.$toast.fail({ message: res.msg });
  939. this.$message.error(res.msg);
  940. }
  941. //清空缓存
  942. this.cancle();
  943. }
  944. );
  945. },
  946. editUserFun() {
  947. let that = this;
  948. //获取已选任务的列表
  949. let list = [];
  950. let listTmp = [];
  951. let listTmpNo = [];
  952. listTmp = this.scaleAndTaskList.filter((item) => {
  953. return this.ruleForm.checkboxGroup2.includes(item.flag)||this.ruleForm.taskRadio==item.flag;
  954. });
  955. for (let i = 0; i < listTmp.length; i++) {
  956. let obj = {
  957. contentType: listTmp[i].type,
  958. flag: listTmp[i].flag,
  959. isDisplayed: listTmp[i].isDisplayed,
  960. isAvailable: listTmp[i].isAvailable,
  961. name: listTmp[i].name,
  962. expectTime: listTmp[i].expectTime,
  963. };
  964. list.push(obj);
  965. }
  966. //不展示要传输到后台的字段
  967. listTmpNo = this.scaleAndTaskList.filter((item) => {
  968. return item.isDisplayed == "0";
  969. });
  970. for (let i = 0; i < listTmpNo.length; i++) {
  971. let obj = {
  972. contentType: listTmpNo[i].type,
  973. flag: listTmpNo[i].flag,
  974. isDisplayed: listTmpNo[i].isDisplayed,
  975. isAvailable: listTmpNo[i].isAvailable,
  976. name: listTmpNo[i].name,
  977. expectTime: listTmpNo[i].expectTime,
  978. };
  979. list.push(obj);
  980. }
  981. //获取已选组织架构的列表
  982. let listOrg = [];
  983. let listOrgTmp = [];
  984. listOrgTmp = this.ppData.filter((item) => {
  985. return this.ruleForm.checkedList.includes(item.orgNo);
  986. });
  987. for (let i = 0; i < listOrgTmp.length; i++) {
  988. let obj = {
  989. orgNo: listOrgTmp[i].orgNo,
  990. orgName: listOrgTmp[i].orgName,
  991. };
  992. listOrg.push(obj);
  993. }
  994. this.userDetailData.planEndTime = this.ruleForm.endTime;
  995. this.userDetailData.planName = this.ruleForm.planName;
  996. this.userDetailData.contentEntities = list;
  997. this.userDetailData.orgEntityList = listOrg;
  998. this.userDetailData.planType = this.ruleForm.planType;
  999. this.$http.post(
  1000. `/plan/addOrUpdate`,
  1001. {
  1002. ...this.userDetailData,
  1003. },
  1004. (res) => {
  1005. this.disableFlagStatus();
  1006. if (res && res.code == 200) {
  1007. this.dialogVisible = false;
  1008. // this.$toast.success({ message: "成功" });
  1009. //调用父组件的查询方法
  1010. that.$emit("search");
  1011. this.$message.success("修改成功");
  1012. } else {
  1013. // this.$toast.fail({ message: res.msg });
  1014. this.$message.error(res.msg);
  1015. }
  1016. }
  1017. );
  1018. },
  1019. },
  1020. };
  1021. </script>
  1022. <style lang="less" scoped>
  1023. input[aria-hidden="true"] {
  1024. display: none !important;
  1025. }
  1026. .el-radio:focus:not(.is-focus):not(:active):not(.is-disabled) .el-radio__inner {
  1027. box-shadow: none;
  1028. }
  1029. .taskSelect /deep/ .el-checkbox.is-bordered + .el-checkbox.is-bordered {
  1030. margin-left: 0px !important;
  1031. }
  1032. .dig_update /deep/ .el-dialog {
  1033. border-radius: 20px !important;
  1034. }
  1035. .form_main::-webkit-scrollbar {
  1036. width: 6px;
  1037. }
  1038. .form_main::-webkit-scrollbar-track {
  1039. background: rgb(239, 239, 239);
  1040. border-radius: 2px;
  1041. }
  1042. .form_main::-webkit-scrollbar-thumb {
  1043. background: #00000049;
  1044. border-radius: 10px;
  1045. }
  1046. .form_main::-webkit-scrollbar-thumb:hover {
  1047. background: #444444;
  1048. }
  1049. .dig_update /deep/.el-cascader {
  1050. position: relative;
  1051. font-size: 14px;
  1052. line-height: 40px;
  1053. width: 100%;
  1054. }
  1055. // .dig_update /deep/.el-dialog {
  1056. // box-shadow: none !important;
  1057. // background: transparent !important;
  1058. // }
  1059. .demo-ruleForm /deep/ .el-form-item {
  1060. margin-right: 10px;
  1061. vertical-align: top;
  1062. display: flex !important;
  1063. flex-direction: column;
  1064. }
  1065. .demo-ruleForm /deep/.el-form-item__label {
  1066. text-align: left;
  1067. vertical-align: middle;
  1068. float: left;
  1069. font-size: 14px;
  1070. color: #606266;
  1071. line-height: 40px;
  1072. padding: 0 12px 0 0;
  1073. -webkit-box-sizing: border-box;
  1074. box-sizing: border-box;
  1075. }
  1076. .demo-ruleForm /deep/.el-input {
  1077. width: 100% !important;
  1078. }
  1079. .demo-ruleForm /deep/.el-input__inner {
  1080. width: 100% !important;
  1081. background-color: #f7f7f7;
  1082. border: 0px;
  1083. }
  1084. .dig_button {
  1085. display: flex;
  1086. width: 100%;
  1087. justify-content: space-around;
  1088. }
  1089. .demo-ruleForm {
  1090. background-color: #ffffff;
  1091. // border-radius: 20px;
  1092. margin-right: -10px;
  1093. margin-top: -10px;
  1094. // padding-right: 100px;
  1095. // padding-left: 100px;
  1096. border-radius: 20px;
  1097. padding-top: 20px;
  1098. padding-bottom: 40px;
  1099. .dig_title {
  1100. margin-bottom: 30px;
  1101. text-align: center;
  1102. font-weight: 700;
  1103. }
  1104. }
  1105. </style>