index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  1. <template>
  2. <div class="app-container">
  3. <form-search :searchformShow="searchformShow" :validate-rules="searchRules" :extra-params="extraParams"
  4. :coursewareUpload="coursewareUpload" @handleQuery="handleQuery" @resetQuery="resetQuery"></form-search>
  5. <el-card class="box-card" style="margin-bottom: 30px">
  6. <el-row :gutter="24">
  7. <el-col :span="4" v-if="viewName != 'Custom'">
  8. <h3
  9. style="
  10. padding-left: 11px;
  11. border-left: 2px solid #e6a700;
  12. color: #e6a700;
  13. "
  14. >{{ queryParams.wayType == 1 ? '章节目录' : '知识点目录' }}</h3>
  15. <div class="head-container">
  16. <el-input
  17. v-model="name"
  18. :placeholder="
  19. queryParams.wayType == 1 ? '请输入章节名称' : '请输入知识点名称'
  20. "
  21. clearable
  22. size="small"
  23. prefix-icon="el-icon-search"
  24. style="margin-bottom: 20px"
  25. />
  26. </div>
  27. <div class="head-container" style="overflow: hidden;">
  28. <el-tree
  29. v-loading="treeLoading"
  30. v-show="queryParams.wayType == 1"
  31. :data="deptOptions"
  32. :props="treeProps"
  33. :expand-on-click-node="false"
  34. :filter-node-method="filterNode"
  35. ref="treeDefault"
  36. @node-click="handleNodeClick"
  37. >
  38. <div slot-scope="{node, data}">
  39. <div :title="data.name">{{ data.name }}</div>
  40. </div>
  41. </el-tree>
  42. <el-tree
  43. v-loading="treeLoading"
  44. v-show="queryParams.wayType == 2"
  45. :data="KnowledgeOptions"
  46. :props="treeProps"
  47. :expand-on-click-node="false"
  48. :filter-node-method="filterNode"
  49. ref="treeKnowledge"
  50. @node-click="handleNodeClick"
  51. >
  52. <div slot-scope="{node, data}">
  53. <div :title="data.name">{{ data.name }}</div>
  54. </div>
  55. </el-tree>
  56. </div>
  57. </el-col>
  58. <el-col :span="viewName == 'Custom' ? 24 : 20">
  59. <el-row :gutter="10" class="mb8">
  60. <el-col :span="1.5" v-hasPermi="['front:personResource:uploadToCloudResourse']">
  61. <el-button plain icon="el-icon-upload2" size="small" @click="upToCloudResourse" :disabled="multiple">
  62. 上传至云库
  63. </el-button>
  64. </el-col>
  65. <el-col :span="1.5" v-hasPermi="['front:personResource:uploadToSchoolResourse']">
  66. <el-button plain icon="el-icon-upload2" size="small" @click="upToSchoolResourse" :disabled="multiple">
  67. 上传至校本资源库
  68. </el-button>
  69. </el-col>
  70. <el-col :span="1.5" v-hasPermi="['front:personResource:uploadToBoard']">
  71. <el-button plain icon="el-icon-upload2" size="small" @click="upToSchoolClass" :disabled="multiple">上传至班牌
  72. </el-button>
  73. </el-col>
  74. <el-col :span="1.5" v-hasPermi="['front:personResource:uploadToStudent']">
  75. <el-button plain icon="el-icon-upload2" size="small" @click="upToSchoolStudent" :disabled="multiple">
  76. 上传至学生端
  77. </el-button>
  78. </el-col>
  79. <el-col :span="1.5" v-hasPermi="['front:personResource:uploadToParent']">
  80. <el-button plain icon="el-icon-upload2" size="small" @click="upToSchoolParent" :disabled="multiple">
  81. 上传至家长端
  82. </el-button>
  83. </el-col>
  84. <el-col :span="1.5" v-hasPermi="['front:personResource:uploadToQuestion']">
  85. <el-button plain icon="el-icon-upload2" size="small" @click="upToQuestion()" :disabled="multiple">上传至试题
  86. </el-button>
  87. </el-col>
  88. <el-table v-loading="loading" :data="resourcesList" @selection-change="handleSelectionChange">
  89. <el-table-column type="selection" width="55" align="center"/>
  90. <el-table-column label="文件" align="center" prop="resourcesName" v-if="viewName == 'Index'">
  91. <template slot-scope="scope">
  92. <resource-preview-button :row="scope.row">
  93. <img style="width: 130px; height: 80px; cursor: pointer" :src="img.ship" alt/>
  94. </resource-preview-button>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="文件名" align="center" prop="resourcesName"/>
  98. <el-table-column label="发布人" align="center" prop="createBy"/>
  99. <el-table-column label="时间" align="center" prop="createTime"/>
  100. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  101. <template slot-scope="scope">
  102. <resource-preview-button v-if="viewName != 'Index'" :row="scope.row" class="mr10"/>
  103. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
  104. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除
  105. </el-button>
  106. </template>
  107. </el-table-column>
  108. </el-table>
  109. <pagination v-show="total > 0" :total="total" :page.sync="pageNum" :limit.sync="pageSize"
  110. @pagination="getList"/>
  111. </el-row>
  112. </el-col>
  113. </el-row>
  114. </el-card>
  115. <!-- 添加或修改云库对话框 -->
  116. <el-dialog :title="title" v-loading="quesLoading" :visible.sync="quesDialog" width="800px" append-to-body>
  117. <el-form ref="formQuestion" :model="form" :rules="rules2" label-width="80px" v-if="quesDialog">
  118. <el-form-item label="题目编号" prop="questionId">
  119. <el-input v-model="form.questionId" placeholder="题目编号"/>
  120. </el-form-item>
  121. </el-form>
  122. <div slot="footer" class="dialog-footer">
  123. <el-button type="primary" @click="submitQuestion">确 定</el-button>
  124. <el-button @click="cancelQuestion">取 消</el-button>
  125. </div>
  126. </el-dialog>
  127. <!-- 添加或修改云库对话框 -->
  128. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  129. <el-form ref="form" :model="form" :rules="rules" label-width="80px" v-if="open">
  130. <el-form-item label="资源名称" prop="resourcesName">
  131. <el-input v-model="form.resourcesName" placeholder="请输入资源名称"/>
  132. </el-form-item>
  133. </el-form>
  134. <div slot="footer" class="dialog-footer">
  135. <el-button type="primary" @click="submitForm">确 定</el-button>
  136. <el-button @click="cancel">取 消</el-button>
  137. </div>
  138. </el-dialog>
  139. <upload-dialog
  140. v-if="dialogVisible"
  141. :title="title"
  142. :pageName="pageName"
  143. :isZdy="isZdy"
  144. :selectType="selectType"
  145. :dialogVisible="dialogVisible"
  146. @handleClose="handleClose"
  147. @dialogVisibleClose="dialogVisibleClose"
  148. ></upload-dialog>
  149. </div>
  150. </template>
  151. <script>
  152. import { add, exportList } from '@/api/webApi/school'
  153. import {
  154. getInfo,
  155. list,
  156. modifyPersonResourceInfo,
  157. remove,
  158. updataQuestion,
  159. upToCloudResourse,
  160. upToSchoolClass,
  161. upToSchoolParent,
  162. upToSchoolResourse,
  163. upToSchoolStudent
  164. } from '@/api/webApi/person'
  165. import { knowledgeTree, treeList } from '@/api/webApi/webQue.js'
  166. import { mapGetters } from 'vuex'
  167. import ResourcePreviewButton from '@/views/accurateTeaching/components/resource-preview-button'
  168. import consts from '@/common/mx-const'
  169. export default {
  170. components: { ResourcePreviewButton },
  171. data() {
  172. const blurText = async(rule, value, callback) => {
  173. const boolean = new RegExp('^[1-9][0-9]*$').test(value) // console.log(boolean)
  174. if (!boolean) {
  175. callback(new Error('请输入正整数'))
  176. }
  177. }
  178. return {
  179. quesDialog: false,
  180. quesLoading: false,
  181. questionId: '',
  182. coursewareUpload: false,
  183. treeLoading: false,
  184. searchformShow: {},
  185. searchRules: {},
  186. extraParams: {},
  187. dialogVisible: false,
  188. img: {
  189. ship: require('@/assets/images/ship.png')
  190. },
  191. treeProps: {
  192. children: 'children',
  193. label: 'name',
  194. code: 'id'
  195. },
  196. deptOptions: undefined,
  197. KnowledgeOptions: [],
  198. deptName: '',
  199. // 遮罩层
  200. loading: true,
  201. // 导出遮罩层
  202. exportLoading: false,
  203. // 选中数组
  204. ids: [],
  205. idsSel: [],
  206. resourcesNames: [],
  207. // 非单个禁用
  208. single: true,
  209. // 非多个禁用
  210. multiple: true,
  211. // 显示搜索条件
  212. showSearch: true,
  213. // 总条数
  214. total: 0,
  215. pageNum: 1,
  216. pageSize: 10,
  217. // 云库表格数据
  218. resourcesList: [],
  219. // 弹出层标题
  220. title: '',
  221. pageName: '',
  222. // 是否显示弹出层
  223. open: false,
  224. // 资源类型字典
  225. typeOptions: [],
  226. // 资源分类字典
  227. categoryOptions: [],
  228. // 是否删除字典
  229. delFlagOptions: [],
  230. // 查询参数
  231. queryParams: {
  232. wayType: '1',
  233. pageNum: 1,
  234. pageSize: 10,
  235. resourcesName: '',
  236. type: null,
  237. category: null,
  238. province: null,
  239. city: null,
  240. county: null,
  241. chapterId: null,
  242. resourcesUrl: '',
  243. bookId: null,
  244. subjectId: null
  245. },
  246. // 表单参数
  247. form: {},
  248. // 表单校验
  249. rules: {
  250. resourcesName: [
  251. {
  252. required: true,
  253. message: '资源名称不能为空',
  254. trigger: 'blur'
  255. }
  256. ]
  257. },
  258. rules2: {
  259. questionId: [
  260. {
  261. required: true,
  262. message: '题目编号不能为空',
  263. trigger: 'blur'
  264. },
  265. {
  266. validator: blurText,
  267. trigger: 'blur'
  268. }
  269. ]
  270. },
  271. viewName: '',
  272. name: '',
  273. isZdy: true,
  274. selectType: ''
  275. }
  276. },
  277. computed: {
  278. ...mapGetters(['currentUser']),
  279. userInfo() {
  280. // TODO: hht 22.1.5 兼容历史写法,待清理
  281. return this.currentUser
  282. }
  283. },
  284. created() {
  285. this.viewName = this.$route.name
  286. if (this.viewName == 'Index') {
  287. this.coursewareUpload = false
  288. this.searchformShow = {
  289. wayType: '1',
  290. subjectid: '',
  291. edition: '',
  292. slipid: ''
  293. }
  294. this.searchRules = {}
  295. this.extraParams = {}
  296. } else if (this.viewName == 'Personal') {
  297. this.coursewareUpload = true
  298. this.searchformShow = {
  299. subjectid: '',
  300. edition: '',
  301. slipid: '',
  302. coursewareType: ''
  303. }
  304. this.searchRules = this.createCoursewareRules()
  305. this.extraParams = this.createCoursewareParams()
  306. } else {
  307. this.coursewareUpload = true
  308. this.searchformShow = {
  309. subjectid: '',
  310. resourceType: ''
  311. }
  312. this.searchRules = {}
  313. this.extraParams = {}
  314. }
  315. this.getDicts('resource_type').then((response) => {
  316. this.typeOptions = response.data
  317. })
  318. this.getDicts('category').then((response) => {
  319. this.categoryOptions = response.data
  320. })
  321. this.getDicts('bool_flag').then((response) => {
  322. this.delFlagOptions = response.data
  323. })
  324. },
  325. watch: {
  326. // 根据名称筛选部门树
  327. name(val) {
  328. this.$refs.tree.filter(val)
  329. }
  330. },
  331. methods: {
  332. /** 查询个人资源库列表 */
  333. getList() {
  334. this.loading = true
  335. if (this.viewName == 'Index') {
  336. this.queryParams.category = '微课视频'
  337. this.pageName = '微课视频'
  338. } else if (this.viewName == 'Personal') {
  339. this.queryParams.category = '课件资源'
  340. this.pageName = '课件资源'
  341. } else {
  342. this.queryParams.category = '自定义'
  343. this.pageName = '自定义'
  344. }
  345. let Ajax = {
  346. subjectId: this.queryParams.subjectid, //科目
  347. bookId: this.queryParams.slipid, //学册
  348. chapterId: this.queryParams.chapterId, //章节
  349. coursewareType: this.queryParams.coursewareType,
  350. edition: this.queryParams.edition,
  351. pageNum: this.pageNum,
  352. pageSize: this.pageSize,
  353. category: this.queryParams.category,
  354. type: this.queryParams.resourceType,
  355. linkWay: this.queryParams.wayType
  356. }
  357. list(Ajax)
  358. .then((response) => {
  359. this.resourcesList = response.rows
  360. this.total = response.total
  361. this.loading = false
  362. })
  363. .catch((err) => {
  364. this.loading = false
  365. })
  366. },
  367. // 资源类型字典翻译
  368. typeFormat(row, column) {
  369. return this.selectDictLabel(this.typeOptions, row.type)
  370. },
  371. // 资源分类字典翻译
  372. categoryFormat(row, column) {
  373. return this.selectDictLabel(this.categoryOptions, row.category)
  374. },
  375. // 是否删除字典翻译
  376. delFlagFormat(row, column) {
  377. return this.selectDictLabel(this.delFlagOptions, row.delFlag)
  378. },
  379. handleClose(type, name, selectData) {
  380. console.log('------------')
  381. console.log(type)
  382. console.log(name)
  383. console.log(selectData)
  384. let _this = this
  385. if (this.title == '上传至云库') {
  386. _this.ids.forEach((item, index) => {
  387. let Ajax = {
  388. resourseId: item
  389. }
  390. if (name) {
  391. Ajax.resourcesName = name
  392. }
  393. upToCloudResourse(Ajax).then(() => {
  394. if (index == _this.ids.length - 1) {
  395. _this.msgSuccess('操作成功')
  396. _this.dialogVisible = false
  397. }
  398. })
  399. })
  400. } else if (this.title == '上传至校本资源库') {
  401. _this.ids.forEach((item, index) => {
  402. let Ajax = {
  403. resourseId: item
  404. }
  405. if (name) {
  406. Ajax.resourcesName = name
  407. }
  408. upToSchoolResourse(Ajax).then(() => {
  409. if (index == _this.ids.length - 1) {
  410. _this.msgSuccess('操作成功')
  411. _this.dialogVisible = false
  412. }
  413. })
  414. })
  415. } else if (this.title == '上传至班牌') {
  416. console.log('上传至班牌')
  417. console.log(selectData)
  418. _this.ids.forEach((item, index) => {
  419. let Ajax = {
  420. resourseId: item,
  421. classId: selectData.checkedClass,
  422. studentCodes: selectData.checkedStudent
  423. ? selectData.checkedStudent.join(',')
  424. : ''
  425. }
  426. if (name) {
  427. Ajax.resourcesName = name
  428. }
  429. console.log('上传至班牌', Ajax)
  430. upToSchoolClass(Ajax).then(() => {
  431. if (index == _this.ids.length - 1) {
  432. _this.msgSuccess('操作成功')
  433. _this.dialogVisible = false
  434. }
  435. })
  436. })
  437. } else if (this.title == '上传至学生端') {
  438. console.log('上传至学生端')
  439. console.log(selectData)
  440. _this.ids.forEach((item, index) => {
  441. let Ajax = {
  442. resourseId: item,
  443. classId: selectData.checkedClass,
  444. remark: selectData.remark,
  445. studentCodes: selectData.checkedStudent.join(',')
  446. }
  447. if (name) {
  448. Ajax.resourcesName = name
  449. }
  450. upToSchoolStudent(Ajax).then(() => {
  451. if (index == _this.ids.length - 1) {
  452. _this.msgSuccess('操作成功')
  453. _this.dialogVisible = false
  454. }
  455. })
  456. })
  457. } else if (this.title == '上传至家长端') {
  458. console.log('上传至家长端')
  459. console.log(selectData)
  460. _this.ids.forEach((item, index) => {
  461. let Ajax = {
  462. resourseId: item,
  463. classId: selectData.checkedClass,
  464. remark: selectData.remark,
  465. studentCodes: selectData.checkedStudent.join(',')
  466. }
  467. if (name) {
  468. Ajax.resourcesName = name
  469. }
  470. upToSchoolParent(Ajax).then(() => {
  471. if (index == _this.ids.length - 1) {
  472. _this.msgSuccess('操作成功')
  473. _this.dialogVisible = false
  474. }
  475. })
  476. })
  477. }
  478. },
  479. upToCloudResourse() {
  480. this.isZdy = false
  481. let _this = this
  482. const resourcesIds = this.ids.join(',')
  483. this.title = '上传至云库'
  484. this.selectType = ''
  485. this.dialogVisible = true
  486. },
  487. upToSchoolResourse() {
  488. this.isZdy = true
  489. let _this = this
  490. const resourcesIds = this.ids.join(',')
  491. this.title = '上传至校本资源库'
  492. this.selectType = ''
  493. this.dialogVisible = true
  494. },
  495. upToSchoolClass() {
  496. this.isZdy = false
  497. let _this = this
  498. const resourcesIds = this.ids.join(',')
  499. this.title = '上传至班牌'
  500. this.selectType = 'class'
  501. this.dialogVisible = true
  502. },
  503. upToSchoolStudent() {
  504. this.isZdy = false
  505. let _this = this
  506. const resourcesIds = this.ids.join(',')
  507. this.title = '上传至学生端'
  508. this.selectType = 'student'
  509. this.dialogVisible = true
  510. },
  511. upToSchoolParent() {
  512. this.isZdy = false
  513. let _this = this
  514. const resourcesIds = this.ids.join(',')
  515. this.title = '上传至家长端'
  516. this.selectType = 'parent'
  517. this.dialogVisible = true
  518. },
  519. upToQuestion() {
  520. // 只能上传视频文件
  521. for (var idx = 0; idx < this.idsSel.length; idx++) {
  522. if (this.idsSel[idx].type != 1) {
  523. this.$message.warning('只能上传视频文件!')
  524. return
  525. }
  526. }
  527. this.quesDialog = true
  528. },
  529. submitQuestion() {
  530. this.$refs['formQuestion'].validate((valid) => {
  531. if (valid) {
  532. this.quesLoading = true
  533. this.ids.forEach((item, index) => {
  534. let paramObj = {
  535. questionId: this.form.questionId,
  536. resourseId: item
  537. }
  538. updataQuestion(paramObj)
  539. .then((response) => {
  540. this.msgSuccess('上传成功')
  541. this.quesLoading = false
  542. this.cancelQuestion()
  543. })
  544. .catch((err) => {
  545. console.log(err)
  546. this.quesLoading = false
  547. })
  548. })
  549. }
  550. })
  551. },
  552. cancelQuestion() {
  553. this.questionId = ''
  554. this.quesDialog = false
  555. },
  556. dialogVisibleClose() {
  557. this.dialogVisible = false
  558. },
  559. // 取消按钮
  560. cancel() {
  561. this.open = false
  562. this.reset()
  563. },
  564. // 表单重置
  565. reset() {
  566. this.form = {
  567. resourcesId: null,
  568. resourcesName: null,
  569. sourceId: null,
  570. category: null,
  571. chapterId: null,
  572. knowledgeBasicId: null,
  573. resourcesUrl: null,
  574. type: null,
  575. linkWay: null,
  576. bookId: null,
  577. customerId: null,
  578. subjectId: null,
  579. delFlag: null,
  580. createBy: null,
  581. createTime: null,
  582. remark: null
  583. }
  584. },
  585. /** 搜索按钮操作 */
  586. async handleQuery(data, type) {
  587. this.pageNum = 1
  588. this.queryParams = Object.assign(this.queryParams, data)
  589. this.queryParams.wayType = data.wayType || '1'
  590. await this.getTreeselect(type)
  591. this.getList()
  592. },
  593. /** 重置按钮操作 */
  594. resetQuery(data, type) {
  595. this.queryParams = data
  596. this.queryParams.chapterId = ''
  597. this.pageNum = 1
  598. this.getList()
  599. },
  600. // 多选框选中数据
  601. handleSelectionChange(selection) {
  602. this.idsSel = selection.map((item) => item)
  603. this.ids = selection.map((item) => item.resourcesId)
  604. this.resourcesNames = selection.map((item) => item.resourcesName)
  605. this.single = selection.length !== 1
  606. this.multiple = !selection.length
  607. },
  608. createCoursewareRules() {
  609. return {
  610. subjectid: [{ required: true, message: '科目必选' }],
  611. edition: [{ required: true, message: '版本必选' }],
  612. slipid: [{ required: true, message: '学册必选' }]
  613. }
  614. },
  615. createCoursewareParams() {
  616. const sharedParams = { source: consts.enum.librarySource.courseware }
  617. return {
  618. subjectid: sharedParams,
  619. edition: sharedParams,
  620. slipid: sharedParams
  621. }
  622. },
  623. /** 新增按钮操作 */
  624. handleAdd() {
  625. this.reset()
  626. this.open = true
  627. this.title = '添加个人资源库'
  628. },
  629. /** 修改按钮操作 */
  630. handleUpdate(row) {
  631. this.reset()
  632. const resourcesId = row.resourcesId || this.ids
  633. getInfo(resourcesId).then((response) => {
  634. this.form = response.data
  635. this.open = true
  636. this.title = '修改个人资源库'
  637. })
  638. },
  639. /** 提交按钮 */
  640. submitForm() {
  641. this.$refs['form'].validate((valid) => {
  642. if (valid) {
  643. if (this.form.resourcesId != null) {
  644. modifyPersonResourceInfo(this.form).then((response) => {
  645. this.msgSuccess('修改成功')
  646. this.open = false
  647. this.getList()
  648. })
  649. } else {
  650. add(this.form).then((response) => {
  651. this.msgSuccess('新增成功')
  652. this.open = false
  653. this.getList()
  654. })
  655. }
  656. }
  657. })
  658. },
  659. /** 删除按钮操作 */
  660. handleDelete(row) {
  661. const resourcesIds = row.resourcesId || this.ids
  662. this.$confirm(
  663. '是否确认删除个人资源库名称为"' + row.resourcesName + '"的数据项?',
  664. '警告',
  665. {
  666. confirmButtonText: '确定',
  667. cancelButtonText: '取消',
  668. type: 'warning'
  669. }
  670. )
  671. .then(function() {
  672. return remove(row.resourcesId)
  673. })
  674. .then(() => {
  675. this.getList()
  676. this.msgSuccess('删除成功')
  677. })
  678. },
  679. /** 导出按钮操作 */
  680. handleExport() {
  681. const queryParams = this.queryParams
  682. this.$confirm('是否确认导出所有个人资源库数据项?', '警告', {
  683. confirmButtonText: '确定',
  684. cancelButtonText: '取消',
  685. type: 'warning'
  686. })
  687. .then(() => {
  688. this.exportLoading = true
  689. return exportList(queryParams)
  690. })
  691. .then((response) => {
  692. this.download(response.msg)
  693. this.exportLoading = false
  694. })
  695. },
  696. /** 查询章节下拉树结构 */
  697. async getTreeselect(type) {
  698. if (type == 'coursewareType') return
  699. if (this.queryParams.wayType == 1) {
  700. if (
  701. (type != 'slipid' && type != 'wayType') ||
  702. this.viewName == 'Custom'
  703. ) {
  704. this.deptOptions = []
  705. this.KnowledgeOptions = []
  706. this.queryParams.chapterId = ''
  707. return
  708. }
  709. let Ajax = {
  710. editionId: this.queryParams.edition, //版本
  711. subjectId: this.queryParams.subjectid, //科目
  712. pharseId: this.queryParams.pharseId, //pharseId
  713. gradeId: this.queryParams.slipid //学册
  714. // gradeid:301
  715. }
  716. this.deptOptions = []
  717. if (!Ajax.gradeId) return
  718. this.treeLoading = true
  719. this.queryParams.chapterId = ''
  720. const resTree = await treeList(Ajax)
  721. this.deptOptions = resTree.data
  722. this.treeLoading = false
  723. } else {
  724. if (
  725. (type != 'subjectid' && type != 'wayType') ||
  726. this.viewName == 'Custom'
  727. ) {
  728. this.deptOptions = []
  729. this.KnowledgeOptions = []
  730. this.queryParams.chapterId = ''
  731. return
  732. }
  733. let Ajax = {
  734. subjectId: this.queryParams.subjectid,
  735. pharseId: this.queryParams.pharseId
  736. }
  737. this.KnowledgeOptions = []
  738. if (!Ajax.subjectId) return
  739. this.treeLoading = true
  740. this.queryParams.chapterId = ''
  741. const resTree = await knowledgeTree(Ajax)
  742. let list = this.filterData(resTree.data, 0)
  743. this.KnowledgeOptions = list
  744. this.treeLoading = false
  745. }
  746. },
  747. filterData(data, index) {
  748. let children = []
  749. data.forEach((item) => {
  750. item.tier = index
  751. if (item.children && index < 2) {
  752. item.children = this.filterData(item.children, index + 1)
  753. } else {
  754. item.children = null
  755. }
  756. children.push(item)
  757. })
  758. return children
  759. },
  760. // 筛选节点
  761. filterNode(value, data) {
  762. if (!value) return true
  763. return data.name.indexOf(value) !== -1
  764. },
  765. // 节点单击事件
  766. handleNodeClick(data) {
  767. if (!data.children?.length) {
  768. this.pageNum = 1
  769. this.queryParams.chapterId = data.id
  770. this.getList()
  771. } else {
  772. this.queryParams.chapterId = ''
  773. }
  774. }
  775. }
  776. }
  777. </script>