Syllabus.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. <template>
  2. <div class="syllabus-main center">
  3. <div class="content-wrap">
  4. <div class="header-wrap">
  5. <Input placeholder="关键词搜索课纲" style="width:20.2% !important;" />
  6. <div class="header-right">
  7. <div class="header-right-item" @click="addSubject">
  8. <Icon type="logo-buffer" size="18" />
  9. <span>新增科目</span>
  10. </div>
  11. <div class="header-right-item" @click="addTerm" v-if="currentSubjectList.length > 0">
  12. <Icon type="ios-browsers" size="18" />
  13. <span>新增册别/课纲</span>
  14. </div>
  15. <div class="header-right-item">
  16. <Icon type="ios-cloud-download" size="18" />
  17. <span>导入课纲</span>
  18. </div>
  19. </div>
  20. </div>
  21. <div class="list-wrap">
  22. <!-- 左边科目列表 -->
  23. <div class="list-col list-left">
  24. <Spin fix v-show="subjectLoading"></Spin>
  25. <template v-if="currentSubjectList.length > 0">
  26. <div v-for="item in currentSubjectList" :class='["subject-item", item.rowKey==s_click_id ? "term-item-active" : ""]' @click="subjectClick(item)">
  27. <span class="subject-name">
  28. <Input v-if="item.rowKey==c_edit_id" clearable type="text" v-model="item.name"
  29. @on-blur="editSubject(item)"
  30. @keyup.enter.native="$event.target.blur"
  31. @click.stop.native="inputFocus($event)" />
  32. <span v-else>{{item.name}}</span>
  33. <span class="s-block-tools" v-show="item.rowKey==c_subject_id">
  34. <Icon type="md-create" @click="handleEditSubject(item,$event)" />
  35. <Icon type="md-trash" @click="handleDeleteSubject(item)" />
  36. </span>
  37. </span>
  38. <span class="subject-term-num">册数 | {{item.termNum?item.termNum:0}}</span>
  39. </div>
  40. </template>
  41. <div v-else class="no-data-text">暂无数据</div>
  42. </div>
  43. <!-- 中间册别列表 -->
  44. <div class="list-col list-middle">
  45. <Spin fix v-show="volumesLoading"></Spin>
  46. <template v-if="volumesList.length > 0">
  47. <div v-for="item in volumesList" :class='["subject-item", "term-item", item.rowKey==c_click_id ? "term-item-active" : ""]' @click="volumesClick(item)">
  48. <span class="subject-name term-name">
  49. <Input v-if="item.rowKey==t_edit_id" clearable type="text" v-model="item.name"
  50. @on-blur="editTerm(item)"
  51. @keyup.enter.native="$event.target.blur"
  52. @click.stop.native="inputFocus($event)" />
  53. <span v-else class="term-name-title">{{item.name}} | {{item.termCode}}</span>
  54. <span class="s-block-tools" v-show="item.rowKey==c_term_id">
  55. <Icon type="md-create" @click="handleEditTerm(item,$event)" />
  56. <Icon type="md-trash" @click="handleDeleteVolumes(item)" />
  57. </span>
  58. </span>
  59. <span class="term-period">{{item.periodName}} | {{item.gradeName + item.termName}} <Icon type="md-arrow-dropdown" v-show="item.rowKey==c_click_id" size="18" style="margin-bottom:3px" /></span>
  60. <div class="term-userNum">
  61. <span>共编使用者数 | {{item.termCode}} 名</span>
  62. <Poptip content="content" placement="bottom-end" theme="dark">
  63. <span class="term-add-user" v-show="item.id==c_click_id">添加共编使用者</span>
  64. <div class="pop-content" slot="content" style="padding-bottom:10px;">
  65. <Tabs value="filter" :animated="false">
  66. <TabPane label="选择老师" name="filter">
  67. <template>
  68. <Select v-model="selectGrade" style="width:100%" @on-change="handleGradeChange">
  69. <Option v-for="item in gradeList" :value="item.name" :key="item.name">{{ item.name }}</Option>
  70. </Select>
  71. </template>
  72. <CheckboxGroup v-model="tearchList" @on-change="handleTeacherCheck">
  73. <Checkbox v-for="(item,index) in userList" :key="index" :label="item.index">{{item.name}}{{item.role}}</Checkbox>
  74. </CheckboxGroup>
  75. </TabPane>
  76. <TabPane label="选择群组" name="orderBy">
  77. </TabPane>
  78. </Tabs>
  79. </div>
  80. </Poptip>
  81. </div>
  82. <!-- 使用者列表 -->
  83. <transition enter-active-class="animated slideInDown" leave-active-class="d-none">
  84. <div class="term-users" v-show="item.id==c_click_id">
  85. <div class="term-user-item center" v-for="user in userList">
  86. <img class="term-user-img" :src="user.headImg" />
  87. <span class="term-user-name">{{user.name}} {{user.role}}</span>
  88. </div>
  89. </div>
  90. </transition>
  91. </div>
  92. </template>
  93. <div v-else class="no-data-text">暂无数据</div>
  94. </div>
  95. <!-- 右侧树形列表 -->
  96. <div class="list-col list-right">
  97. <Spin fix v-show="syllabusLoading"></Spin>
  98. <Tree :treeDatas="treeDatas" :volumeCode="volumeCode" v-if="volumesList.length > 0 && treeDatas.length > 0"></Tree>
  99. <div v-else class="no-data-text">暂无数据</div>
  100. </div>
  101. </div>
  102. <!-- 新增科目弹窗 -->
  103. <Modal v-model="addSubjectModal"
  104. title="新增科目"
  105. class-name="subject-modal"
  106. ok-text="确认"
  107. cancel-text="取消"
  108. @on-ok="handleAddSubject"
  109. @on-cancel="">
  110. <p class="modal-title" v-show="currentSubjectList.length > 0">当前已选科目</p>
  111. <CheckboxGroup v-model="currentSubjectList" v-show="currentSubjectList.length > 0">
  112. <Checkbox v-for="(item,index) in currentSubjectList" :label="index" :key="index" disabled>{{item.name}}</Checkbox>
  113. </CheckboxGroup>
  114. <p class="modal-title">请选择需要添加的新科目</p>
  115. <CheckboxGroup v-model="newSubjectList">
  116. <Checkbox v-for="(item,index) in subjectList" :label="index" :key="index">{{item.name}}</Checkbox>
  117. </CheckboxGroup>
  118. </Modal>
  119. <!-- 新增册别弹窗 -->
  120. <Modal v-model="addTermModal"
  121. title="新增册别"
  122. class-name="subject-modal"
  123. ok-text="确认"
  124. cancel-text="取消"
  125. @on-ok="handleAddTerm"
  126. @on-cancel="">
  127. <p class="modal-title">当前科目:{{subjectInfo.name}}</p>
  128. <p class="modal-title">请选择学段:</p>
  129. <Select v-model="periodSelect" style="width:200px" @on-change="periodChange" label-in-value>
  130. <Option v-for="item in findPeriodsList" :value="item.code" :key="item.code">{{ item.name }}</Option>
  131. </Select>
  132. <p class="modal-title">请选择年级:</p>
  133. <Select v-model="gradeSelect" style="width:200px" @on-change="gradeChange" label-in-value>
  134. <Option v-for="item in findGradesList" :value="item.code" :key="item.code">{{ item.name }}</Option>
  135. </Select>
  136. <p class="modal-title">请选择学期:</p>
  137. <Select v-model="termSelect" style="width:200px" @on-change="termChange" label-in-value>
  138. <Option v-for="item in findTermsList" :value="item.code" :key="item.code">{{ item.name }}</Option>
  139. </Select>
  140. <p class="modal-title">请输入册别名称:</p>
  141. <Input v-model="addVolumesData.name" placeholder="输入新册别名称" style="width: 300px" />
  142. </Modal>
  143. </div>
  144. </div>
  145. </template>
  146. <script>
  147. import Tree from '@/components/syllabus/Tree.vue'
  148. import { all } from 'q';
  149. import { setTimeout } from 'core-js';
  150. export default {
  151. name: "Syllabus",
  152. components: {
  153. Tree: Tree
  154. },
  155. data() {
  156. return {
  157. schoolInfos: {}, //身份全部信息
  158. schoolInfo: {},//学校信息
  159. subjectInfo: {},//当前选中科目信息
  160. subjectList: [],//全部科目列表
  161. currentSubjectList: [],//学校科目列表
  162. volumesList: [],//册别列表
  163. treeData: [],//课纲数据
  164. userList: [],//共编使用者列表
  165. treeDatas: [],
  166. volumeCode: "",
  167. subjectLoading: true,
  168. volumesLoading: true,
  169. syllabusLoading:true,
  170. findPeriodsList:[],
  171. findGradesList:[],
  172. findTermsList: [],
  173. newVolumesName:"",
  174. periodSelect:"",
  175. gradeSelect:"",
  176. termSelect: "",
  177. addVolumesData: {},
  178. gradeList: [],
  179. tearchList: [],
  180. c_subject_id:0,
  181. c_term_id: 0,
  182. c_click_id: 0,
  183. s_click_id: 0,
  184. c_edit_id: null,
  185. t_edit_id:null,
  186. addSubjectModal: false,
  187. addTermModal: false,
  188. newSubjectList: [],
  189. termName: "",
  190. selectGrade: "1年级",
  191. }
  192. },
  193. created() {
  194. this.schoolInfo = JSON.parse(localStorage.getItem('c_role_info')).roleClaim[0]; //默认选中第一个学校
  195. let schoolClaims = this.schoolInfo.claim;
  196. for (let i in schoolClaims) {
  197. if (schoolClaims[i].claimType == "SchoolCode") {
  198. this.schoolInfo = schoolClaims[i]
  199. }
  200. }
  201. this.findAllSubjects();
  202. this.findSchoolSubjectsByDict();
  203. },
  204. methods: {
  205. //查找全部科目
  206. findAllSubjects() {
  207. this.$api.FindSubjectsByDict({}).then(res => {
  208. this.subjectList = res.result.data;
  209. })
  210. },
  211. //查找当前学校已有科目
  212. findSchoolSubjectsByDict() {
  213. this.$api.FindSchoolSubjectsByDict({ SchoolCode: this.schoolInfo.claimCode,Status:1 }).then(res => {
  214. this.currentSubjectList = res.result.data;
  215. if (res.result.data.length > 0) {
  216. this.subjectInfo = res.result.data[0];
  217. this.subjectClick(res.result.data[0]);
  218. }
  219. this.subjectLoading = false;
  220. this.volumesLoading = false;
  221. this.syllabusLoading = false;
  222. })
  223. },
  224. //点击科目
  225. subjectClick(data) {
  226. this.volumesLoading = true;
  227. this.subjectInfo = data;
  228. this.s_click_id = data.rowKey;
  229. this.c_subject_id = data.rowKey;
  230. this.c_edit_id = null;
  231. let defaultData = {
  232. SchoolCode: this.schoolInfo.claimCode,
  233. PartitionKey: data.partitionKey,
  234. SubjectCode: data.code,
  235. Status:1
  236. }
  237. this.$api.FindSchoolVolumesByDict(defaultData).then(res => {
  238. this.volumesList = res.result.data;
  239. if (res.result.data.length > 0) {
  240. this.volumesClick(res.result.data[0]);
  241. }
  242. this.volumesLoading = false;
  243. })
  244. },
  245. //点击编辑科目
  246. handleEditSubject(data, e) {
  247. e.stopPropagation();
  248. this.c_edit_id = data.rowKey;
  249. },
  250. //点击册别
  251. volumesClick(data) {
  252. this.syllabusLoading = true;
  253. this.$api.FindSyllabusByVolumeCode({ VolumeCode: data.rowKey, Status:1 }).then(res => {
  254. this.treeDatas = res.result.data;
  255. this.volumeCode = data.rowKey;
  256. this.syllabusLoading = false;
  257. })
  258. this.c_click_id = data.rowKey;
  259. this.c_term_id = data.rowKey;
  260. this.t_edit_id = null;
  261. },
  262. //点击编辑册别
  263. handleEditTerm(data, e) {
  264. e.stopPropagation();
  265. this.t_edit_id = data.rowKey;
  266. },
  267. //编辑科目input失焦
  268. editSubject(data) {
  269. this.$api.SaveOrUpdateSchoolSubject(data).then(res => {
  270. if (res.result.message == "Success") {
  271. this.$Message.success("修改成功");
  272. }
  273. })
  274. this.c_edit_id = null;
  275. },
  276. //编辑册别input失焦
  277. editTerm(data) {
  278. this.$api.SaveOrUpdateSchoolVolume(data).then(res => {
  279. if (res.result.message == "Success") {
  280. this.$Message.success("修改成功");
  281. }
  282. })
  283. this.t_edit_id = null;
  284. },
  285. //input聚焦
  286. inputFocus(e) {
  287. //e.cancelBubble = true;
  288. },
  289. //点击添加科目
  290. addSubject() {
  291. let currentList = this.currentSubjectList;
  292. this.$api.FindSubjectsByDict({}).then(res => {
  293. this.subjectList = res.result.data;
  294. let tempList = this.subjectList.slice(0);
  295. if (currentList.length > 0) {
  296. for (let i in tempList) {
  297. for (let j in currentList) {
  298. if (tempList[i].rowKey == currentList[j].code) {
  299. this.subjectList.splice(this.subjectList.indexOf(tempList[i]), 1);
  300. }
  301. }
  302. }
  303. }
  304. })
  305. this.addSubjectModal = true;
  306. this.newSubjectList = [];
  307. },
  308. //确认添加科目
  309. handleAddSubject() {
  310. let newList = this.newSubjectList;
  311. for (let i of newList) {
  312. let defaultSubject = {
  313. schoolCode: this.schoolInfo.claimCode,
  314. partitionKey: this.subjectList[i].partitionKey,
  315. name: this.subjectList[i].name,
  316. code: this.subjectList[i].rowKey,
  317. status:1,
  318. schoolName:this.schoolInfo.claimName
  319. };
  320. this.$api.SaveOrUpdateSchoolSubject(defaultSubject).then(res => {
  321. this.currentSubjectList.push(res.result.data);
  322. this.subjectClick(this.currentSubjectList[0]); //默认展开第一个
  323. })
  324. }
  325. },
  326. //点击添加册别
  327. addTerm() {
  328. this.addTermModal = true;
  329. this.findSchoolPeriodsByDict();
  330. this.findSchoolTermsByDict();
  331. this.addVolumesData = {
  332. schoolCode: this.schoolInfo.claimCode,
  333. partitionKey: this.schoolInfo.partitionKey,
  334. schoolName: this.schoolInfo.claimName,
  335. subjectName: this.subjectInfo.name,
  336. subjectCode: this.subjectInfo.code,
  337. status: 1,
  338. periodName: 0,
  339. gradeName: 0,
  340. termName: 0,
  341. periodCode: 0,
  342. gradeCode: 0,
  343. termCode: 0,
  344. name:this.newVolumesName
  345. }
  346. },
  347. //发送请求添加册别
  348. handleAddTerm() {
  349. //查询是否已存在此类册别
  350. this.$api.FindSchoolVolumesByDict({
  351. SchoolCode: this.addVolumesData.schoolCode,
  352. PartitionKey: this.addVolumesData.partitionKey,
  353. SubjectCode: this.addVolumesData.subjectCode,
  354. Status: this.addVolumesData.status,
  355. PeriodCode: this.addVolumesData.periodCode,
  356. GradeCode: this.addVolumesData.gradeCode,
  357. TermCode: this.addVolumesData.termCode,
  358. }).then(res => {
  359. if (res.result.data.length > 0) {
  360. this.$Modal.confirm({
  361. title: '温馨提示',
  362. content: '<p>已存在该学期下的册别,是否覆盖?</p>',
  363. okText: "确认",
  364. cancelText:"取消",
  365. onOk: () => {
  366. //存在即更新册别名字
  367. this.$api.SaveOrUpdateSchoolVolume(this.addVolumesData).then(res => {
  368. this.c_term_id = res.result.data.rowKey;
  369. this.c_click_id = res.result.data.rowKey;
  370. for (let i in this.volumesList) {
  371. if (this.volumesList[i].rowKey == res.result.data.rowKey) {
  372. this.volumesList[i].name = res.result.data.name
  373. }
  374. }
  375. })
  376. }
  377. });
  378. } else {
  379. //不存在则直接加入列表
  380. this.$api.SaveOrUpdateSchoolVolume(this.addVolumesData).then(res => {
  381. this.volumesList.push(res.result.data);
  382. this.c_term_id = res.result.data.rowKey;
  383. this.c_click_id = res.result.data.rowKey;
  384. })
  385. }
  386. })
  387. },
  388. //删除科目,修改科目状态
  389. handleDeleteSubject(data) {
  390. data.status = 0;
  391. this.$Modal.confirm({
  392. title: '删除科目',
  393. content: '<p>确认删除该科目?</p>',
  394. okText: "确认",
  395. cancelText:"取消",
  396. onOk: () => {
  397. this.$api.SaveOrUpdateSchoolSubject(data).then(res => {
  398. data.status = 1;
  399. this.$Message.success("删除成功");
  400. this.currentSubjectList.splice(data, 1);
  401. this.subjectList.push(data);
  402. this.findSchoolSubjectsByDict();
  403. if (this.currentSubjectList.length == 0) {
  404. this.volumesList = [];
  405. this.treeData = [];
  406. }
  407. })
  408. },
  409. onCancel: () => {
  410. this.$Message.info('Clicked cancel');
  411. }
  412. });
  413. },
  414. //删除册别,修改册别状态
  415. handleDeleteVolumes(data) {
  416. data.status = 0;
  417. this.$Modal.confirm({
  418. title: '删除科目',
  419. content: '<p>确认删除该册别?</p>',
  420. okText: "确认",
  421. cancelText:"取消",
  422. onOk: () => {
  423. this.$api.SaveOrUpdateSchoolVolume(data).then(res => {
  424. this.$Message.success("删除成功");
  425. this.subjectClick(this.subjectInfo);
  426. })
  427. },
  428. onCancel: () => {
  429. this.$Message.info('Clicked cancel');
  430. }
  431. });
  432. },
  433. //获取当前学校全部学段
  434. findSchoolPeriodsByDict() {
  435. this.$api.FindSchoolPeriodsByDict({SchoolCode: this.schoolInfo.claimCode}).then(res => {
  436. this.findPeriodsList = res.result.data;
  437. this.periodSelect = res.result.data[0].code;
  438. this.addVolumesData.periodCode = res.result.data[0].code;
  439. this.addVolumesData.periodName = res.result.data[0].name;
  440. this.findSchoolGradesByDict(res.result.data[0].code);
  441. })
  442. },
  443. //获取当前学校全部年级
  444. findSchoolGradesByDict(periodCode) {
  445. let data = {
  446. SchoolCode: this.schoolInfo.claimCode,
  447. PeriodCode: periodCode
  448. }
  449. this.$api.FindSchoolGradesByDict(data).then(res => {
  450. this.findGradesList = res.result.data;
  451. this.gradeSelect = res.result.data[0].code;
  452. this.addVolumesData.gradeCode = res.result.data[0].code;
  453. this.addVolumesData.gradeName = res.result.data[0].name;
  454. })
  455. },
  456. //获取当前学校全部学期
  457. findSchoolTermsByDict() {
  458. this.$api.FindSchoolTermsByDict({SchoolCode: this.schoolInfo.claimCode}).then(res => {
  459. this.findTermsList = res.result.data;
  460. this.termSelect = res.result.data[0].code;
  461. this.addVolumesData.termCode = res.result.data[0].code;
  462. this.addVolumesData.termName = res.result.data[0].name;
  463. })
  464. },
  465. periodChange(val) {
  466. console.log(val);
  467. this.addVolumesData.periodName = val.label;
  468. this.addVolumesData.periodCode = val.value;
  469. },
  470. gradeChange(val) {
  471. console.log(val);
  472. this.addVolumesData.gradeName = val.label;
  473. this.addVolumesData.gradeCode = val.value;
  474. },
  475. termChange(val) {
  476. console.log(val);
  477. this.addVolumesData.termName = val.label;
  478. this.addVolumesData.termCode = val.value;
  479. },
  480. //选择年级的自动完成
  481. filterGrade(value, option) {
  482. return option.toUpperCase().indexOf(value.toUpperCase()) !== -1;
  483. },
  484. //选择老师的回调事件
  485. handleTeacherCheck() {
  486. console.log(this.tearchList);
  487. },
  488. //选择老师的回调事件
  489. handleGradeChange(val) {
  490. console.log(val);
  491. }
  492. }
  493. }
  494. </script>