index.vue 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928
  1. <template>
  2. <div id="questionBankManagement">
  3. <search-box ref="search_box" :formList="formList" @search="search" @init="init" />
  4. <table-list
  5. :tableSets="tableSet"
  6. :tableData="tableData"
  7. :navText="navText"
  8. @addClick="addClick"
  9. :loading="loading"
  10. >
  11. <template slot="btn" slot-scope="props">
  12. <el-button type="text" @click="infoMessage(props.scope.row)"
  13. >详情</el-button
  14. >
  15. <el-button type="text" @click="modify(props.scope.row)">修改</el-button>
  16. <el-button type="text" @click="dels(props.scope.row)">删除</el-button>
  17. </template>
  18. </table-list>
  19. <pagination
  20. :total="total"
  21. :pageSize="pageSize"
  22. :currentPage="currentPage"
  23. @handleSizeChange="handleSizeChange"
  24. @handleCurrentChange="handleCurrentChange"
  25. />
  26. <el-dialog
  27. :visible.sync="dialogBox"
  28. width="920px"
  29. :show-close="false"
  30. :destroy-on-close="true"
  31. :fullscreen="fullscreen"
  32. :close-on-click-modal="false"
  33. >
  34. <div slot="title" class="hearders">
  35. <div class="leftTitle">
  36. {{ statusPop === 1 ? "添加" : statusPop === 0 ? "修改" : "详情" }}
  37. </div>
  38. <div class="rightBoxs">
  39. <img
  40. src="@/assets/images/Max@2x.png"
  41. alt=""
  42. @click="fullscreen = !fullscreen"
  43. />
  44. <img src="@/assets/images/Close@2x.png" alt="" @click="closeBefore" />
  45. </div>
  46. </div>
  47. <el-row class="contentBox" :span="24">
  48. <el-col :span="24" class="juscon">
  49. <el-steps :active="activeTableStatus">
  50. <el-step title="填写题库信息"></el-step>
  51. <el-step title="填写章节信息"></el-step>
  52. </el-steps>
  53. </el-col>
  54. <el-col :span="24" v-show="activeTableStatus === 1">
  55. <el-col :span="12">
  56. <el-col :span="24">
  57. <header>题库分类</header>
  58. <el-cascader
  59. style="width: 100%"
  60. v-model="poppleData.categoryId"
  61. :options="optionsTion"
  62. :size="'medium'"
  63. clearable
  64. :disabled="statusPop === 2"
  65. :props="{
  66. label: 'categoryName',
  67. value: 'categoryId',
  68. checkStrictly: true,
  69. emitPath: false,
  70. }"
  71. ></el-cascader>
  72. </el-col>
  73. <el-col :span="24">
  74. <header>题库名称:</header>
  75. <el-input
  76. :disabled="statusPop === 2"
  77. placeholder="请输入课程名称"
  78. v-model="poppleData.bankName"
  79. />
  80. </el-col>
  81. <el-col :span="24">
  82. <header>练习类型:</header>
  83. <el-radio-group
  84. v-model="poppleData.typeId"
  85. :disabled="statusPop === 2 || statusPop === 0"
  86. @change="changeisZTpaper"
  87. >
  88. <el-radio :label="1">普通练习</el-radio>
  89. <el-radio :label="2">押题试卷</el-radio>
  90. <el-radio :label="3">真题试卷</el-radio>
  91. </el-radio-group>
  92. </el-col>
  93. <el-col :span="24" v-if="isZTpaper">
  94. <header>主讲名师</header>
  95. <el-select
  96. :disabled="statusPop === 2"
  97. style="width: 100%"
  98. multiple
  99. v-model="poppleData.teacherIds"
  100. placeholder="请选择主讲名师"
  101. >
  102. <el-option
  103. v-for="item in optionsTeach"
  104. :key="item.teacherId"
  105. :label="item.teacherName"
  106. :value="item.teacherId"
  107. >
  108. </el-option>
  109. </el-select>
  110. </el-col>
  111. <el-col :span="24">
  112. <header>价格:</header>
  113. <el-input
  114. placeholder="请输入价格"
  115. :disabled="statusPop === 2"
  116. v-model="poppleData.price"
  117. >
  118. <template slot="append">元</template>
  119. </el-input>
  120. </el-col>
  121. <el-col :span="24">
  122. <header>排序:</header>
  123. <el-input-number
  124. :disabled="statusPop === 2"
  125. v-model="poppleData.sort"
  126. controls-position="right"
  127. :min="0"
  128. placeholder="请输入排序"
  129. ></el-input-number>
  130. </el-col>
  131. </el-col>
  132. <el-col :span="12">
  133. <el-col :span="24">
  134. <header>课程封面:</header>
  135. <div class="imgBox">
  136. <label class="imgLabel" for="inputs">
  137. <div class="msPhoto" v-if="poppleData.coverUrl">
  138. <img
  139. :src="$methodsTools.splitImgHost(poppleData.coverUrl)"
  140. alt="图片加载失败"
  141. />
  142. </div>
  143. <div class="imgbbx" v-else>
  144. <p style="margin-top: 49px">
  145. 点击添加或将文件拖拽到这里上传
  146. </p>
  147. <i class="el-icon-plus"></i>
  148. <p style="margin-bottom: 37px">
  149. 图片格式:.jpg/.png/jpeg/bmp
  150. </p>
  151. </div>
  152. <input
  153. :disabled="statusPop === 2"
  154. id="inputs"
  155. type="file"
  156. ref="file"
  157. style="display: none"
  158. @change="getImgFile"
  159. />
  160. </label>
  161. <p style="color: #999999">请上传比例为16:9且小于2m的图片</p>
  162. </div>
  163. </el-col>
  164. <el-col :span="24">
  165. <header>是否启用:</header>
  166. <el-radio-group
  167. v-model="poppleData.status"
  168. :disabled="statusPop === 2"
  169. >
  170. <el-radio :label="1">是</el-radio>
  171. <el-radio :label="0">否</el-radio>
  172. </el-radio-group>
  173. </el-col>
  174. </el-col>
  175. <el-col :span="24">
  176. <el-col :span="24">
  177. <header>课程简介:</header>
  178. <div
  179. style="
  180. max-height: 300px;
  181. overflow-y: auto;
  182. border: 1px solid #e2e2e2;
  183. border-radius: 8px;
  184. padding: 13px;
  185. "
  186. v-if="statusPop === 2"
  187. v-html="poppleData.introduction"
  188. ></div>
  189. <editor
  190. v-else
  191. v-model="poppleData.introduction"
  192. :min-height="100"
  193. :max-height="300"
  194. :uploadStatus="uploadStatus"
  195. /> </el-col
  196. ></el-col>
  197. </el-col>
  198. <el-col :span="24" v-show="activeTableStatus === 2">
  199. <div v-if="showTKtype === 1">
  200. <div>
  201. <el-button type="primary" @click="changeList({ level: 0 }, 0)"
  202. >添加章节</el-button
  203. >
  204. <el-button>导入章节</el-button>
  205. </div>
  206. <div>
  207. <el-table
  208. align="center"
  209. ref="pager"
  210. :data="tableDatas"
  211. style="width: 100%"
  212. row-key="id"
  213. :load="load"
  214. lazy
  215. @expand-change="expandChange"
  216. :tree-props="{
  217. children: 'children',
  218. hasChildren: 'hasChildren',
  219. }"
  220. destroy-on-close
  221. :key="Math.random()"
  222. >
  223. <el-table-column type="index" width="50" label="序号">
  224. </el-table-column>
  225. <el-table-column
  226. v-for="(item, index) in poppleTableHeader"
  227. :key="index"
  228. :label="item.label"
  229. :width="item.width"
  230. align="center"
  231. >
  232. <template slot-scope="scope">
  233. <span v-if="item.scope === 'level'">{{
  234. scope.row[item.prop] === 0 ? "章" : "节"
  235. }}</span>
  236. <span v-else>{{ scope.row[item.prop] }}</span>
  237. </template>
  238. </el-table-column>
  239. <el-table-column
  240. label="操作"
  241. align="center"
  242. fixed="right"
  243. width="180px"
  244. >
  245. <template slot-scope="scope">
  246. <div v-if="scope.row.level === 0">
  247. <el-button type="text" @click="changeList(scope.row, 0)"
  248. >添加下级</el-button
  249. >
  250. <el-button type="text" @click="changeList(scope.row, 1)"
  251. >修改</el-button
  252. >
  253. <el-button type="text" @click="delF(scope.row)"
  254. >删除</el-button
  255. >
  256. </div>
  257. <div v-else>
  258. <el-button type="text" @click="xqpaperTopic(scope.row)"
  259. >详情题目</el-button
  260. >
  261. <el-button type="text" @click="changeList(scope.row, 1)"
  262. >修改</el-button
  263. >
  264. <el-button type="text" @click="delFChild(scope.row)"
  265. >删除</el-button
  266. >
  267. </div>
  268. </template></el-table-column
  269. >
  270. </el-table>
  271. <el-dialog
  272. width="520px"
  273. :visible.sync="innerVisible"
  274. append-to-body
  275. :show-close="false"
  276. :fullscreen="fullscreenChild"
  277. :close-on-click-modal="false"
  278. >
  279. <div slot="title" class="hearders">
  280. <div class="leftTitle">
  281. {{ int === 0 ? "添加" : "修改" }}
  282. </div>
  283. <div class="rightBoxs">
  284. <img
  285. src="@/assets/images/Max@2x.png"
  286. alt=""
  287. @click="fullscreenChild = !fullscreenChild"
  288. />
  289. <img
  290. src="@/assets/images/Close@2x.png"
  291. alt=""
  292. @click="closeBeforeChild"
  293. />
  294. </div>
  295. </div>
  296. <el-col :span="24">
  297. <el-col :span="18" style="margin: 30px 0px 10px">
  298. <el-form label-width="150px">
  299. <el-form-item
  300. v-for="(items, indexs) in formTables"
  301. :key="indexs"
  302. :label="items.label"
  303. >
  304. <el-input
  305. v-if="items.scope === 'dis'"
  306. v-model="formTableChild[items.prop]"
  307. :placeholder="items.placeholder"
  308. :disabled="formTableChild.level === 0 ? true : false"
  309. ></el-input>
  310. <el-radio-group
  311. v-else-if="items.scope === 'radio'"
  312. v-model="formTableChild.status"
  313. >
  314. <el-radio :label="1">是</el-radio>
  315. <el-radio :label="0">否</el-radio>
  316. </el-radio-group>
  317. <el-input
  318. v-else
  319. v-model="formTableChild[items.prop]"
  320. :placeholder="items.placeholder"
  321. ></el-input>
  322. </el-form-item>
  323. </el-form>
  324. </el-col>
  325. </el-col>
  326. <span slot="footer" class="dialog-footer">
  327. <el-button @click="closeBeforeChild">取 消</el-button>
  328. <el-button type="primary" @click="submitChild"
  329. >确 定</el-button
  330. >
  331. </span>
  332. </el-dialog>
  333. </div>
  334. <pagination
  335. :total="totalChild"
  336. :pageSize="pageSizeChild"
  337. :currentPage="currentPageChild"
  338. @handleSizeChange="handleSizeChangeChild"
  339. @handleCurrentChange="handleCurrentChangeChild"
  340. />
  341. </div>
  342. <div v-if="showTKtype === 2">
  343. <div>
  344. <el-button type="primary" @click="paperAddORChange"
  345. >添加试卷</el-button
  346. >
  347. <el-button>导入试卷</el-button>
  348. </div>
  349. <div>
  350. <el-table
  351. ref="pager"
  352. :data="tableDataspaper"
  353. style="width: 100%"
  354. destroy-on-close
  355. :key="Math.random()"
  356. >
  357. <el-table-column
  358. type="index"
  359. width="50"
  360. label="序号"
  361. align="center"
  362. >
  363. </el-table-column>
  364. <el-table-column
  365. v-for="(item, index) in poppleTableHeaderpaper"
  366. :key="index"
  367. :label="item.label"
  368. :width="item.width"
  369. align="center"
  370. >
  371. <template slot-scope="scope">
  372. <span>{{ scope.row[item.prop] }}</span>
  373. </template>
  374. </el-table-column>
  375. <el-table-column label="操作" align="center" fixed="right">
  376. <template slot-scope="scope">
  377. <el-button type="text" @click="xqpaperTopic(scope.row)"
  378. >详情题目</el-button
  379. >
  380. <el-button type="text" @click="paperAddORChange(scope.row)"
  381. >修改</el-button
  382. >
  383. <el-button type="text" @click="delPaper(scope.row)"
  384. >删除</el-button
  385. >
  386. </template></el-table-column
  387. >
  388. </el-table>
  389. <el-dialog
  390. width="520px"
  391. :visible.sync="innerVisiblePaper"
  392. append-to-body
  393. :show-close="false"
  394. :fullscreen="fullscreenChildPaper"
  395. :close-on-click-modal="false"
  396. >
  397. <div slot="title" class="hearders">
  398. <div class="leftTitle">
  399. {{ statusPaperDia === 1 ? "添加" : "修改" }}
  400. </div>
  401. <div class="rightBoxs">
  402. <img
  403. src="@/assets/images/Max@2x.png"
  404. alt=""
  405. @click="fullscreenChildPaper = !fullscreenChildPaper"
  406. />
  407. <img
  408. src="@/assets/images/Close@2x.png"
  409. alt=""
  410. @click="closeBeforeChildPaper"
  411. />
  412. </div>
  413. </div>
  414. <el-col :span="24">
  415. <el-col :span="18" style="margin: 30px 0px 10px">
  416. <el-form label-width="150px">
  417. <el-form-item
  418. v-for="(items, indexs) in formTablesPaper"
  419. :key="indexs"
  420. :label="items.label"
  421. >
  422. <el-input
  423. v-if="items.scope === 'dis'"
  424. v-model="formTableChildPaper[items.prop]"
  425. :placeholder="items.placeholder"
  426. :disabled="
  427. formTableChildPaper.level === 0 ? true : false
  428. "
  429. ></el-input>
  430. <el-radio-group
  431. v-else-if="items.scope === 'radio'"
  432. v-model="formTableChildPaper.status"
  433. >
  434. <el-radio :label="1">是</el-radio>
  435. <el-radio :label="0">否</el-radio>
  436. </el-radio-group>
  437. <el-input
  438. v-else
  439. v-model="formTableChildPaper[items.prop]"
  440. :placeholder="items.placeholder"
  441. ></el-input>
  442. </el-form-item>
  443. </el-form>
  444. </el-col>
  445. </el-col>
  446. <span slot="footer" class="dialog-footer">
  447. <el-button @click="closeBeforeChildPaper">取 消</el-button>
  448. <el-button type="primary" @click="submitnewPaper"
  449. >确 定</el-button
  450. >
  451. </span>
  452. </el-dialog>
  453. </div>
  454. <pagination
  455. :total="totalChildTopic"
  456. :pageSize="pageSizeChildTopic"
  457. :currentPage="currentPageChildTopic"
  458. @handleSizeChange="handleSizeChangeChildTopic"
  459. @handleCurrentChange="handleCurrentChangeChildTopic"
  460. />
  461. </div>
  462. </el-col>
  463. </el-row>
  464. <div slot="footer" class="dialog-footer">
  465. <el-button @click="backTable" v-if="activeTableStatus !== 1"
  466. >上一步</el-button
  467. >
  468. <el-button @click="closeBefore">取 消</el-button>
  469. <el-button
  470. v-if="activeTableStatus === 1"
  471. type="primary"
  472. @click="submitTabel"
  473. >下一步</el-button
  474. ><el-button
  475. v-if="activeTableStatus === 2"
  476. type="primary"
  477. @click="dialogBox = false"
  478. >确定</el-button
  479. >
  480. </div>
  481. </el-dialog>
  482. </div>
  483. </template>
  484. <script>
  485. import searchBox from "@/components/searchBox";
  486. import tableList from "@/components/tableList";
  487. import pagination from "@/components/pagination";
  488. import Editor from "@/components/Editor";
  489. export default {
  490. components: { searchBox, tableList, pagination, Editor },
  491. data() {
  492. return {
  493. uploadStatus: 2, //富文本组件传值
  494. loading: false, //当前表单加载是否加载动画
  495. isZTpaper: true, //主讲老师列表是否显示
  496. navText: {
  497. title: "题库合计",
  498. index: 0,
  499. ch: "个",
  500. num: true,
  501. choice: true,
  502. backFatherBtn: {
  503. status: false,
  504. title: "未定义",
  505. },
  506. },
  507. formTableChild: {},
  508. formTableChildPaper: {},
  509. formTables: [
  510. {
  511. label: "名称",
  512. prop: "name",
  513. placeholder: "输入名称",
  514. },
  515. {
  516. label: "排序",
  517. prop: "sort",
  518. placeholder: "输入排序",
  519. },
  520. {
  521. label: "是否启用",
  522. prop: "status",
  523. scope: "radio",
  524. },
  525. ],
  526. formTablesPaper: [
  527. {
  528. label: "名称",
  529. prop: "name",
  530. placeholder: "输入名称",
  531. },
  532. {
  533. label: "排序",
  534. prop: "sort",
  535. placeholder: "输入排序",
  536. },
  537. {
  538. label: "是否启用",
  539. prop: "status",
  540. scope: "radio",
  541. },
  542. ], //试卷添加或修改表单
  543. tableSet: [
  544. {
  545. label: "题库名称",
  546. prop: "bankName",
  547. hidden: true,
  548. width: "150px",
  549. },
  550. {
  551. label: "题库类型",
  552. prop: "categoryName",
  553. hidden: true,
  554. width: "150px",
  555. },
  556. {
  557. label: "练习类型",
  558. prop: "typeId",
  559. hidden: true,
  560. scope: "typeId",
  561. },
  562. {
  563. label: "排序",
  564. prop: "sort",
  565. hidden: true,
  566. },
  567. {
  568. label: "题目个数",
  569. prop: "questionNum",
  570. hidden: true,
  571. },
  572. {
  573. label: "启用状态",
  574. prop: "status",
  575. hidden: true,
  576. scope: "status",
  577. },
  578. ], //表头信息
  579. showTKtype: 0, //1:章节表格 2:试卷表格
  580. tableData: [], //表单数据
  581. total: 0, //一共多少条
  582. pageSize: 10, //每页多少条数据
  583. currentPage: 1, //当前页码
  584. totalChild: 0, //一共多少条
  585. pageSizeChild: 5, //每页多少条数据
  586. currentPageChild: 1, //当前页码
  587. totalChildTopic: 0, //一共多少条
  588. pageSizeChildTopic: 5, //每页多少条数据
  589. currentPageChildTopic: 1, //当前页码
  590. formList: [
  591. {
  592. label: "题库名称",
  593. prop: "bankName",
  594. placeholder: "输入题库名称",
  595. },
  596. {
  597. label: "启用状态",
  598. prop: "status",
  599. scope: "select",
  600. placeholder: "选择启用状态",
  601. options: [
  602. {
  603. label: "启用",
  604. value: 1,
  605. },
  606. {
  607. label: "关闭",
  608. value: 0,
  609. },
  610. ],
  611. },
  612. {
  613. label: "题库类型",
  614. prop: "categoryId",
  615. scope: "cascader",
  616. placeholder: "选择题库类型",
  617. options: [],
  618. props: {
  619. label: "categoryName",
  620. value: "categoryId",
  621. },
  622. },
  623. {
  624. label: "练习类型",
  625. prop: "typeId",
  626. scope: "select",
  627. placeholder: "选择练习类型",
  628. options: [
  629. {
  630. label: "普通练习",
  631. value: 1,
  632. },
  633. {
  634. label: "押题试卷",
  635. value: 2,
  636. },
  637. {
  638. label: "真题试卷",
  639. value: 3,
  640. },
  641. ],
  642. },
  643. ], //搜索栏
  644. optionsTion: [],
  645. optionsTeach: [],
  646. poppleData: {},
  647. fullscreen: false,
  648. fullscreenChild: false,
  649. fullscreenChildPaperTopic: false,
  650. dialogBox: false,
  651. innerVisible: false,
  652. statusPop: 0,
  653. beif: "", //备份数据
  654. activeTableStatus: 1, //步骤条当前状态
  655. tableDatas: [], //表格数据
  656. poppleTableHeader: [
  657. {
  658. label: "名称",
  659. prop: "name",
  660. width: "150px",
  661. },
  662. {
  663. label: "级别",
  664. prop: "level",
  665. width: "80px",
  666. scope: "level",
  667. },
  668. {
  669. label: "题目数量",
  670. prop: "questionNum",
  671. width: "150px",
  672. },
  673. {
  674. label: "排序",
  675. prop: "sort",
  676. },
  677. ], //表头数据
  678. tableDataspaper: [], //试卷数据
  679. poppleTableHeaderpaper: [
  680. {
  681. label: "名称",
  682. prop: "name",
  683. width: "150px",
  684. },
  685. {
  686. label: "题目数量",
  687. prop: "questionNum",
  688. width: "150px",
  689. },
  690. {
  691. label: "排序",
  692. prop: "sort",
  693. },
  694. ], //试卷表头数据
  695. innerVisiblePaper: false,
  696. fullscreenChildPaper: false,
  697. innerVisiblePaperTopic: false,
  698. formTablesPaperTopic: [
  699. {
  700. label: "类型:",
  701. prop: "type",
  702. scope: "radio",
  703. options: [
  704. {
  705. label: "单选题",
  706. value: 1,
  707. },
  708. {
  709. label: "多选题",
  710. value: 2,
  711. },
  712. {
  713. label: "判断题",
  714. value: 3,
  715. },
  716. {
  717. label: "案例题",
  718. value: 4,
  719. },
  720. ],
  721. optionschild: [
  722. {
  723. label: "单选题",
  724. value: 1,
  725. },
  726. {
  727. label: "多选题",
  728. value: 2,
  729. },
  730. {
  731. label: "判断题",
  732. value: 3,
  733. },
  734. ],
  735. },
  736. {
  737. label: "题目:",
  738. prop: "content",
  739. scope: "textarea",
  740. placeholder: "请输入题目",
  741. },
  742. {
  743. label: "图片:",
  744. prop: "imgUrl",
  745. scope: "photo",
  746. },
  747. {
  748. label: "选项",
  749. prop: "options",
  750. scope: "options",
  751. },
  752. {
  753. label: "正确答案",
  754. prop: "asd",
  755. scope: "optionsResult",
  756. },
  757. {
  758. label: "答案解析",
  759. prop: "analysisContent",
  760. scope: "textarea",
  761. },
  762. ],
  763. formTopic: [],
  764. int: -1,
  765. statusPaperDia: 0, //添加试卷窗口 当前状态为添加1还是修改0
  766. treeObj: {},
  767. priceTest: /(^[1-9]\d*(\.\d{1,2})?$)|(^0(\.\d{1,2})?$)/,
  768. };
  769. },
  770. mounted() {
  771. this.search();
  772. this.initCascader();
  773. this.initTeacherList();
  774. },
  775. methods: {
  776. changeisZTpaper(v) {
  777. if (v === 3) {
  778. this.isZTpaper = false;
  779. } else {
  780. this.isZTpaper = true;
  781. }
  782. },
  783. // 初始化教师列表
  784. initTeacherList() {
  785. var data = {
  786. status: "0,1",
  787. };
  788. this.$api.inquireCourseTeacher(data).then((res) => {
  789. console.log(res);
  790. this.optionsTeach = res.rows;
  791. });
  792. },
  793. //级联选择器数据
  794. initCascader() {
  795. this.$api
  796. .inquireProfessionClassification()
  797. .then((res) => {
  798. this.arrayChangeType(res.rows);
  799. })
  800. .catch((err) => {
  801. console.log(err);
  802. });
  803. },
  804. // 接口数据转换级联类型
  805. arrayChangeType(options) {
  806. let result = [];
  807. if (!Array.isArray(options)) {
  808. return result;
  809. }
  810. options.forEach((item) => {
  811. delete item.children;
  812. });
  813. let map = {};
  814. options.forEach((item) => {
  815. map[item.categoryId] = item;
  816. });
  817. options.forEach((item) => {
  818. let parent = map[item.pid];
  819. if (parent) {
  820. (parent.children || (parent.children = [])).push(item);
  821. } else {
  822. result.push(item);
  823. }
  824. });
  825. result = result.sort(this.sortBy("sort", true));
  826. result.forEach((item, index) => {
  827. if (item.children) {
  828. item.children.sort(this.sortBy("sort", true));
  829. }
  830. });
  831. this.formList.forEach((item, index) => {
  832. if (item.prop === "categoryId") {
  833. item.options = result;
  834. this.optionsTion = result;
  835. }
  836. });
  837. return result;
  838. },
  839. sortBy(attr, rev) {
  840. //第二个参数没有传递 默认升序排列
  841. if (rev == undefined) {
  842. rev = 1;
  843. } else {
  844. rev = rev ? 1 : -1;
  845. }
  846. return function (a, b) {
  847. a = a[attr];
  848. b = b[attr];
  849. if (a < b) {
  850. return rev * -1;
  851. }
  852. if (a > b) {
  853. return rev * 1;
  854. }
  855. return 0;
  856. };
  857. },
  858. backTable() {
  859. if (this.statusPop === 1) {
  860. this.statusPop = 0;
  861. this.activeTableStatus--;
  862. } else {
  863. this.activeTableStatus--;
  864. }
  865. },
  866. nextTable() {
  867. this.activeTableStatus++;
  868. },
  869. getImgFile() {
  870. var self = this;
  871. var file = this.$refs.file.files[0];
  872. if (file === undefined) {
  873. self.$set(self.poppleData, "coverUrl", "");
  874. return;
  875. }
  876. if (file.size > 2 * 1024 * 1024) {
  877. this.$message.error("图片不得大于2MB");
  878. return;
  879. }
  880. var type = this.$refs.file.value.toLowerCase().split(".").splice(-1);
  881. if (
  882. type[0] != "jpg" &&
  883. type[0] != "png" &&
  884. type[0] != "jpeg" &&
  885. type[0] != "bmp"
  886. ) {
  887. this.$message.error("上传格式需为:.jpg/.png/.jpeg/bmp");
  888. this.$refs.file.value = "";
  889. return;
  890. }
  891. var reader = new FileReader();
  892. reader.readAsDataURL(file);
  893. reader.onload = function (ev) {
  894. self.$set(self.poppleData, "coverUrl", ev.target.result);
  895. };
  896. },
  897. // 试卷题目图片
  898. getImgFiletopic(options, childIndex, e) {
  899. if (childIndex !== null) {
  900. var self = this;
  901. var indexNum = -1;
  902. var indexChildNum = -1;
  903. this.formTopic.forEach((item, index) => {
  904. if (item.questionId === options.questionId) {
  905. indexNum = index;
  906. item.jsonStr.forEach((i, l) => {
  907. if (l === childIndex) {
  908. indexChildNum = l;
  909. }
  910. });
  911. }
  912. });
  913. var file = e.target.files[0];
  914. if (file === undefined) {
  915. self.$set(
  916. self.formTopic[indexNum].jsonStr[indexChildNum],
  917. "imgUrl",
  918. ""
  919. );
  920. return;
  921. }
  922. if (file.size > 2 * 1024 * 1024) {
  923. this.$message.error("图片不得大于2MB");
  924. return;
  925. }
  926. var type = e.target.value.toLowerCase().split(".").splice(-1);
  927. if (
  928. type[0] != "jpg" &&
  929. type[0] != "png" &&
  930. type[0] != "jpeg" &&
  931. type[0] != "bmp"
  932. ) {
  933. this.$message.error("上传格式需为:.jpg/.png/.jpeg/bmp");
  934. e.target.value = "";
  935. return;
  936. }
  937. var reader = new FileReader();
  938. reader.readAsDataURL(file);
  939. reader.onload = function (ev) {
  940. self.$set(
  941. self.formTopic[indexNum].jsonStr[indexChildNum],
  942. "imgUrl",
  943. ev.target.result
  944. );
  945. };
  946. } else {
  947. var self = this;
  948. var indexNum = -1;
  949. this.formTopic.forEach((item, index) => {
  950. if (item.questionId === options.questionId) {
  951. indexNum = index;
  952. }
  953. });
  954. var file = e.target.files[0];
  955. if (file === undefined) {
  956. self.$set(self.formTopic[indexNum], "imgUrl", "");
  957. return;
  958. }
  959. if (file.size > 2 * 1024 * 1024) {
  960. this.$message.error("图片不得大于2MB");
  961. return;
  962. }
  963. var type = e.target.value.toLowerCase().split(".").splice(-1);
  964. if (
  965. type[0] != "jpg" &&
  966. type[0] != "png" &&
  967. type[0] != "jpeg" &&
  968. type[0] != "bmp"
  969. ) {
  970. this.$message.error("上传格式需为:.jpg/.png/.jpeg/bmp");
  971. e.target.value = "";
  972. return;
  973. }
  974. var reader = new FileReader();
  975. reader.readAsDataURL(file);
  976. reader.onload = function (ev) {
  977. self.$set(self.formTopic[indexNum], "imgUrl", ev.target.result);
  978. };
  979. }
  980. },
  981. // 详情
  982. infoMessage(options) {
  983. var data = options.bankId;
  984. this.$api.obtainbank(data).then((res) => {
  985. this.poppleData = res.data;
  986. if (res.data.typeId === 3) {
  987. this.isZTpaper = false;
  988. } else {
  989. this.isZTpaper = true;
  990. this.poppleData.teacherIds = res.data.teacherIds
  991. .split(",")
  992. .map(Number);
  993. }
  994. this.beif = res.data.coverUrl;
  995. });
  996. this.statusPop = 2;
  997. this.activeTableStatus = 1;
  998. this.dialogBox = true;
  999. },
  1000. //添加
  1001. addClick() {
  1002. this.poppleData = {};
  1003. this.tableDatas = [];
  1004. this.statusPop = 1;
  1005. this.activeTableStatus = 1;
  1006. this.dialogBox = true;
  1007. },
  1008. // 修改
  1009. modify(options) {
  1010. var data = options.bankId;
  1011. this.$api.obtainbank(data).then((res) => {
  1012. console.log(res);
  1013. this.poppleData = res.data;
  1014. if (res.data.typeId === 3) {
  1015. this.isZTpaper = false;
  1016. } else {
  1017. this.isZTpaper = true;
  1018. if (this.poppleData.teacherIds === null) {
  1019. } else {
  1020. this.poppleData.teacherIds = res.data.teacherIds
  1021. .split(",")
  1022. .map(Number);
  1023. }
  1024. }
  1025. this.beif = res.data.coverUrl;
  1026. });
  1027. this.statusPop = 0;
  1028. this.activeTableStatus = 1;
  1029. this.dialogBox = true;
  1030. },
  1031. //确定提交
  1032. async submitTabel() {
  1033. var self = this;
  1034. if (
  1035. this.poppleData.categoryId === undefined ||
  1036. this.poppleData.categoryId === null
  1037. ) {
  1038. this.$message.error("请选择题库分类");
  1039. return;
  1040. }
  1041. if (!this.poppleData.bankName) {
  1042. this.$message.error("请输入题库名称");
  1043. return;
  1044. }
  1045. if (this.poppleData.typeId === undefined) {
  1046. this.$message.error("请选择练习类型");
  1047. return;
  1048. }
  1049. if (this.poppleData.typeId === 3) {
  1050. this.poppleData.teacherIds = "";
  1051. } else {
  1052. if (
  1053. !this.poppleData.teacherIds ||
  1054. this.poppleData.teacherIds.length === 0
  1055. ) {
  1056. this.$message.error("请选择主讲名师");
  1057. return;
  1058. }
  1059. }
  1060. if (this.poppleData.price === undefined) {
  1061. this.$message.error("请输入价格");
  1062. return;
  1063. }
  1064. if (this.poppleData.sort === undefined) {
  1065. this.$message.error("请输入排序");
  1066. return;
  1067. }
  1068. if (!this.priceTest.test(this.poppleData.price)) {
  1069. this.$message.error("请输入正确价格");
  1070. this.poppleData.price = "";
  1071. return;
  1072. }
  1073. if (!this.poppleData.introduction) {
  1074. this.$message.error("请输入课程简介");
  1075. return;
  1076. }
  1077. if (this.poppleData.status === undefined) {
  1078. this.$message.error("请选择是否启用该课程");
  1079. return;
  1080. }
  1081. if (!this.poppleData.coverUrl || this.poppleData.coverUrl.length === 0) {
  1082. this.$message.error("请上传课程封面");
  1083. return;
  1084. }
  1085. var data = {
  1086. categoryId: this.poppleData.categoryId,
  1087. bankName: this.poppleData.bankName,
  1088. typeId: this.poppleData.typeId,
  1089. introduction: this.poppleData.introduction,
  1090. price: this.poppleData.price,
  1091. status: this.poppleData.status,
  1092. sort: this.poppleData.sort,
  1093. teacherIds:
  1094. this.poppleData.typeId !== 3
  1095. ? this.poppleData.teacherIds.join(",")
  1096. : "",
  1097. };
  1098. if (this.statusPop === 1) {
  1099. const awtimg = await this.imgUpload(2);
  1100. data.coverUrl = this.poppleData.coverUrl;
  1101. this.submitFun(data);
  1102. } else if (this.statusPop === 0) {
  1103. data.bankId = this.poppleData.bankId;
  1104. if (
  1105. this.poppleData.coverUrl === this.beif &&
  1106. this.poppleData.coverUrl.length !== 0
  1107. ) {
  1108. this.submitFun(data);
  1109. } else {
  1110. const awtimg = await this.imgUpload(2);
  1111. data.coverUrl = this.poppleData.coverUrl;
  1112. this.submitFun(data);
  1113. }
  1114. } else if (this.statusPop === 2) {
  1115. if (this.poppleData.typeId === 1) {
  1116. this.showTKtype = 1;
  1117. this.getZJList(this.poppleData.bankId).then(() => {
  1118. this.nextTable();
  1119. });
  1120. } else {
  1121. this.showTKtype = 2;
  1122. this.getPAPERList(this.poppleData.bankId).then(() => {
  1123. this.nextTable();
  1124. });
  1125. }
  1126. }
  1127. },
  1128. submitFun(data) {
  1129. if (data.bankId) {
  1130. this.$api
  1131. .editbank(data)
  1132. .then((res) => {
  1133. console.log(res);
  1134. this.$message.success("修改成功!");
  1135. this.search();
  1136. if (this.poppleData.typeId === 1) {
  1137. this.showTKtype = 1;
  1138. this.getZJList(data.bankId).then(() => {
  1139. this.nextTable();
  1140. });
  1141. } else {
  1142. this.showTKtype = 2;
  1143. this.getPAPERList(this.poppleData.bankId).then(() => {
  1144. this.nextTable();
  1145. });
  1146. }
  1147. })
  1148. .catch((err) => {
  1149. this.$message.error(err);
  1150. });
  1151. } else {
  1152. this.$api
  1153. .addbank(data)
  1154. .then((res) => {
  1155. this.$message.success("添加成功!");
  1156. this.search();
  1157. this.poppleData.bankId = res.log.primary_key_id;
  1158. if (this.poppleData.typeId === 1) {
  1159. this.showTKtype = 1;
  1160. this.getZJList(res.log.primary_key_id).then(() => {
  1161. this.nextTable();
  1162. });
  1163. } else {
  1164. this.showTKtype = 2;
  1165. this.getPAPERList(this.poppleData.bankId).then(() => {
  1166. this.nextTable();
  1167. });
  1168. }
  1169. })
  1170. .catch((err) => {
  1171. this.$message.error(err);
  1172. });
  1173. }
  1174. },
  1175. //获取大章
  1176. getZJList(index) {
  1177. var self = this;
  1178. return new Promise((resolve, reject) => {
  1179. var data = {
  1180. bankId: index,
  1181. status: "0,1",
  1182. pageSize: this.pageSizeChild,
  1183. pageNum: this.currentPageChild,
  1184. };
  1185. var nullBox = [];
  1186. this.$api.inquirebankchapterList(data).then((res) => {
  1187. res.rows.forEach((item) => {
  1188. item.id = item.bankChapterId + "";
  1189. item.level = 0;
  1190. item.hasChildren = true;
  1191. nullBox.push(item);
  1192. });
  1193. nullBox.sort(self.sortBy("sort", true));
  1194. self.tableDatas = nullBox;
  1195. self.totalChild = res.total;
  1196. resolve();
  1197. });
  1198. });
  1199. },
  1200. //获取试卷
  1201. getPAPERList(index) {
  1202. var self = this;
  1203. return new Promise((resolve, reject) => {
  1204. var data = {
  1205. bankId: index,
  1206. status: "0,1",
  1207. pageSize: this.pageSizeChildTopic,
  1208. pageNum: this.currentPageChildTopic,
  1209. };
  1210. var nullBox = [];
  1211. this.$api.inquirebankexamList(data).then((res) => {
  1212. res.rows.forEach((item) => {
  1213. // item.id = item.bankChapterId + "";
  1214. // item.level = 0;
  1215. item.hasChildren = true;
  1216. nullBox.push(item);
  1217. });
  1218. nullBox.sort(self.sortBy("sort", true));
  1219. self.tableDataspaper = nullBox;
  1220. self.totalChildTopic = res.total;
  1221. resolve();
  1222. });
  1223. });
  1224. },
  1225. imgUpload(int) {
  1226. var self = this;
  1227. return new Promise((resolve, reject) => {
  1228. this.$upload
  1229. .upload(this.$refs.file.files[0], int)
  1230. .then((res) => {
  1231. self.poppleData.coverUrl = res;
  1232. resolve();
  1233. })
  1234. .catch((err) => {
  1235. self.$message.error("图片上传错误");
  1236. });
  1237. });
  1238. },
  1239. //删除
  1240. dels(options) {
  1241. console.log(options);
  1242. var self = this;
  1243. this.$confirm("此操作将删除该课程, 是否继续?", "提示", {
  1244. confirmButtonText: "确定",
  1245. cancelButtonText: "取消",
  1246. type: "warning",
  1247. })
  1248. .then(() => {
  1249. var data = {
  1250. bankId: options.bankId,
  1251. categoryId: options.categoryId,
  1252. bankName: options.bankName,
  1253. teacherIds: "",
  1254. price: options.price,
  1255. status: -1,
  1256. typeId: options.typeId,
  1257. };
  1258. this.$api
  1259. .editbank(data)
  1260. .then((res) => {
  1261. this.$message.success("删除成功!");
  1262. this.search();
  1263. })
  1264. .catch((err) => {
  1265. this.$message.error("删除失败:" + err);
  1266. });
  1267. })
  1268. .catch(() => {
  1269. this.$message("取消删除");
  1270. });
  1271. },
  1272. sortBy(attr, rev) {
  1273. //第二个参数没有传递 默认升序排列
  1274. if (rev == undefined) {
  1275. rev = 1;
  1276. } else {
  1277. rev = rev ? 1 : -1;
  1278. }
  1279. return function (a, b) {
  1280. a = a[attr];
  1281. b = b[attr];
  1282. if (a < b) {
  1283. return rev * -1;
  1284. }
  1285. if (a > b) {
  1286. return rev * 1;
  1287. }
  1288. return 0;
  1289. };
  1290. },
  1291. search(v,os) {
  1292. if (os) {
  1293. this.currentPage = 1;
  1294. }
  1295. if (v === undefined) {
  1296. v = {};
  1297. }
  1298. var data = {
  1299. bankName: v.bankName || "",
  1300. categoryId: v.categoryId || "",
  1301. status: v.status === undefined ? "0,1" : v.status,
  1302. typeId: v.typeId,
  1303. pageSize: this.pageSize,
  1304. pageNum: this.currentPage,
  1305. };
  1306. this.loading = true;
  1307. this.$api
  1308. .inquirebankList(data)
  1309. .then((res) => {
  1310. this.tableData = res.rows;
  1311. this.total = res.total;
  1312. this.navText.index = res.total;
  1313. this.loading = false;
  1314. })
  1315. .catch((err) => {
  1316. this.loading = false;
  1317. });
  1318. },
  1319. init() {
  1320. this.search();
  1321. },
  1322. //窗口关闭
  1323. closeBefore() {
  1324. this.dialogBox = false;
  1325. this.fullscreen = false;
  1326. this.poppleData = {};
  1327. },
  1328. closeBeforeChild() {
  1329. this.innerVisible = false;
  1330. this.fullscreenChild = false;
  1331. // this.poppleData = {};
  1332. },
  1333. closeBeforeChildPaper() {
  1334. this.innerVisiblePaper = false;
  1335. this.fullscreenChildPaper = false;
  1336. },
  1337. closeBeforeChildPaperTopic() {
  1338. this.innerVisiblePaperTopic = false;
  1339. this.innerVisiblePaperTopic = false;
  1340. },
  1341. handleSizeChange(v) {
  1342. this.pageSize = v;
  1343. this.currentPage = 1;
  1344. this.search(this.$refs.search_box.formData);
  1345. },
  1346. handleCurrentChange(v) {
  1347. this.currentPage = v;
  1348. this.search(this.$refs.search_box.formData);
  1349. },
  1350. handleSizeChangeChild(v) {
  1351. this.pageSizeChild = v;
  1352. this.currentPageChild = 1;
  1353. this.getZJList(this.poppleData.bankId);
  1354. },
  1355. handleCurrentChangeChild(v) {
  1356. this.currentPageChild = v;
  1357. this.getZJList(this.poppleData.bankId);
  1358. },
  1359. handleSizeChangeChildTopic(v) {
  1360. this.pageSizeChildTopic = v;
  1361. this.currentPageChildTopic = 1;
  1362. this.getPAPERList(this.poppleData.bankId);
  1363. },
  1364. handleCurrentChangeChildTopic(v) {
  1365. this.currentPageChildTopic = v;
  1366. this.getPAPERList(this.poppleData.bankId);
  1367. },
  1368. //点击多级触发异步
  1369. async load(tree, treeNode, resolve) {
  1370. this.treeObj[tree.bankChapterId] = { tree, treeNode, resolve };
  1371. var data = {
  1372. status: "0,1",
  1373. bankChapterId: tree.bankChapterId,
  1374. };
  1375. const loadChildren = await this.$api.inquirebanksectionList(data);
  1376. if (Array.isArray(loadChildren.rows) && loadChildren.rows.length > 0) {
  1377. loadChildren.rows.forEach((item) => {
  1378. item.id = tree.bankChapterId + "." + item.bankSectionId;
  1379. item.level = 1;
  1380. });
  1381. loadChildren.rows.sort(this.sortBy("sort", true));
  1382. if (loadChildren.rows === 0) {
  1383. this.$message.warning("暂无下级");
  1384. }
  1385. resolve(loadChildren.rows); // 返回最终数据对象
  1386. } else {
  1387. tree.children = [];
  1388. resolve([]);
  1389. }
  1390. },
  1391. //添加or修改章节or子节
  1392. changeList(row, int) {
  1393. console.log(row);
  1394. this.int = int;
  1395. var kelone = JSON.stringify(row);
  1396. this.formTableChild = JSON.parse(kelone);
  1397. if (int === 0 && row.bankId !== undefined) {
  1398. this.formTableChild = {
  1399. level: 1,
  1400. bankId: row.bankId,
  1401. bankChapterId: row.bankChapterId,
  1402. };
  1403. }
  1404. this.innerVisible = true;
  1405. },
  1406. expandChange() {
  1407. console.log(111);
  1408. },
  1409. // 修改子节点
  1410. changeTableList() {
  1411. var data = {
  1412. bankChapterId: this.formTableChild.bankChapterId,
  1413. bankSectionId: this.formTableChild.bankSectionId,
  1414. name: this.formTableChild.name,
  1415. sort: this.formTableChild.sort,
  1416. status: this.formTableChild.status,
  1417. };
  1418. this.$api.editbanksection(data).then((res) => {
  1419. this.$message.success("修改成功");
  1420. this.getZJList(this.poppleData.bankId);
  1421. // 处理懒加载节点,先清空再渲染。
  1422. // 利用refs得到表格的数据结构,拿到 lazyTreeNodeMap 这个懒加载对象。
  1423. // 这里面存储的就是你之前加载的所有节点数据对象了。然后清空操作节点的父节点对象。
  1424. this.$refs.pager.store.states.lazyTreeNodeMap[
  1425. this.formTableChild.bankChapterId
  1426. ] = [];
  1427. // 根据我们声明的maps对象,拿到父节点。然后手动进行接口请求,重新进行数据渲染。
  1428. const { tree, treeNode, resolve } =
  1429. this.treeObj[this.formTableChild.bankChapterId];
  1430. this.load(tree, treeNode, resolve);
  1431. this.innerVisible = false;
  1432. });
  1433. },
  1434. //章节操作
  1435. submitChild() {
  1436. if (this.formTableChild.name === undefined) {
  1437. this.$message.error("请输入名字");
  1438. return;
  1439. }
  1440. if (this.formTableChild.sort === undefined) {
  1441. this.$message.error("请输入排序");
  1442. return;
  1443. }
  1444. if (this.formTableChild.status === undefined) {
  1445. this.$message.error("请选择是否启用");
  1446. return;
  1447. }
  1448. // int = 0 添加
  1449. if (this.int === 0) {
  1450. if (this.formTableChild.bankChapterId) {
  1451. //添加下级
  1452. var data = {
  1453. bankChapterId: this.formTableChild.bankChapterId,
  1454. name: this.formTableChild.name,
  1455. sort: this.formTableChild.sort,
  1456. status: this.formTableChild.status,
  1457. };
  1458. this.$api.addbanksection(data).then((res) => {
  1459. this.$message.success("添加下级成功");
  1460. this.getZJList(this.poppleData.bankId);
  1461. if (
  1462. this.$refs.pager.store.states.lazyTreeNodeMap[
  1463. this.formTableChild.bankChapterId
  1464. ] === undefined
  1465. ) {
  1466. } else {
  1467. this.$refs.pager.store.states.lazyTreeNodeMap[
  1468. this.formTableChild.bankChapterId
  1469. ] = [];
  1470. // 根据我们声明的maps对象,拿到父节点。然后手动进行接口请求,重新进行数据渲染。
  1471. const { tree, treeNode, resolve } =
  1472. this.treeObj[this.formTableChild.bankChapterId];
  1473. this.load(tree, treeNode, resolve);
  1474. }
  1475. this.innerVisible = false;
  1476. });
  1477. } else {
  1478. // 添加章节
  1479. var data = {
  1480. bankId: this.poppleData.bankId,
  1481. name: this.formTableChild.name,
  1482. sort: this.formTableChild.sort,
  1483. status: this.formTableChild.status,
  1484. };
  1485. this.$api.addbankchapter(data).then((res) => {
  1486. this.$message.success("添加成功");
  1487. this.getZJList(this.poppleData.bankId);
  1488. this.innerVisible = false;
  1489. });
  1490. }
  1491. }
  1492. //int = 1 修改
  1493. if (this.int === 1) {
  1494. // 章修改
  1495. if (this.formTableChild.bankSectionId === undefined) {
  1496. var data = {
  1497. bankId: this.poppleData.bankId,
  1498. bankChapterId: this.formTableChild.bankChapterId,
  1499. name: this.formTableChild.name,
  1500. sort: this.formTableChild.sort,
  1501. status: this.formTableChild.status,
  1502. };
  1503. this.$api.editbankchapter(data).then((res) => {
  1504. this.$message.success("修改成功");
  1505. this.getZJList(this.poppleData.bankId);
  1506. this.innerVisible = false;
  1507. });
  1508. } else {
  1509. // 节点修改
  1510. this.changeTableList();
  1511. }
  1512. }
  1513. },
  1514. delF(row) {
  1515. this.$confirm("是否确认删除该章?", "提示", {
  1516. confirmButtonText: "确定",
  1517. cancelButtonText: "取消",
  1518. type: "warning",
  1519. })
  1520. .then(() => {
  1521. var data = {
  1522. bankId: this.poppleData.bankId,
  1523. bankChapterId: row.bankChapterId,
  1524. name: row.name,
  1525. sort: row.sort,
  1526. status: -1,
  1527. };
  1528. this.$api.editbankchapter(data).then((res) => {
  1529. this.$message.success("删除成功");
  1530. this.getZJList(this.poppleData.bankId);
  1531. this.innerVisible = false;
  1532. });
  1533. })
  1534. .catch(() => {
  1535. this.$message({
  1536. type: "info",
  1537. message: "已取消删除",
  1538. });
  1539. });
  1540. },
  1541. delFChild(rowsz) {
  1542. this.$confirm("是否确认删除该节?", "提示", {
  1543. confirmButtonText: "确定",
  1544. cancelButtonText: "取消",
  1545. type: "warning",
  1546. })
  1547. .then(() => {
  1548. var data = {
  1549. bankChapterId: rowsz.bankChapterId,
  1550. bankSectionId: rowsz.bankSectionId,
  1551. name: rowsz.name,
  1552. sort: rowsz.sort,
  1553. status: -1,
  1554. };
  1555. this.$api.editbanksection(data).then((res) => {
  1556. this.$message.success("删除成功");
  1557. this.getZJList(this.poppleData.bankId);
  1558. // 处理懒加载节点,先清空再渲染。
  1559. // 利用refs得到表格的数据结构,拿到 lazyTreeNodeMap 这个懒加载对象。
  1560. // 这里面存储的就是你之前加载的所有节点数据对象了。然后清空操作节点的父节点对象。
  1561. this.$refs.pager.store.states.lazyTreeNodeMap[rowsz.bankChapterId] =
  1562. [];
  1563. // 根据我们声明的maps对象,拿到父节点。然后手动进行接口请求,重新进行数据渲染。
  1564. const { tree, treeNode, resolve } =
  1565. this.treeObj[rowsz.bankChapterId];
  1566. this.load(tree, treeNode, resolve);
  1567. this.innerVisible = false;
  1568. });
  1569. })
  1570. .catch(() => {
  1571. this.$message({
  1572. type: "info",
  1573. message: "已取消删除",
  1574. });
  1575. });
  1576. },
  1577. //添加试卷或修改试卷窗口
  1578. paperAddORChange(options) {
  1579. if (options.examId) {
  1580. // 执行修改操作
  1581. this.statusPaperDia = 0;
  1582. this.formTableChildPaper = options;
  1583. } else {
  1584. // 执行添加操作
  1585. this.statusPaperDia = 1;
  1586. this.formTableChildPaper = {
  1587. bankId: this.poppleData.bankId,
  1588. };
  1589. }
  1590. this.innerVisiblePaper = true;
  1591. },
  1592. //提交试卷修改或添加操作
  1593. submitnewPaper() {
  1594. if (!this.formTableChildPaper.name) {
  1595. this.$message.error("请输入试卷名称");
  1596. return;
  1597. }
  1598. if (this.formTableChildPaper.sort === undefined) {
  1599. this.$message.error("请输入试卷排序");
  1600. return;
  1601. }
  1602. if (this.formTableChildPaper.status === undefined) {
  1603. this.$message.error("请选择该试卷是否启用");
  1604. return;
  1605. }
  1606. var data = {
  1607. bankId: this.formTableChildPaper.bankId,
  1608. name: this.formTableChildPaper.name,
  1609. sort: this.formTableChildPaper.sort,
  1610. status: this.formTableChildPaper.status,
  1611. };
  1612. if (this.statusPaperDia === 0) {
  1613. (data.examId = this.formTableChildPaper.examId),
  1614. this.$api.editbankexam(data).then(() => {
  1615. this.$message.success("试卷修改成功!");
  1616. this.getPAPERList(data.bankId).then((res) => {
  1617. this.innerVisiblePaper = false;
  1618. });
  1619. });
  1620. }
  1621. if (this.statusPaperDia === 1) {
  1622. this.$api.addbankexam(data).then(() => {
  1623. this.$message.success("试卷添加成功!");
  1624. this.getPAPERList(data.bankId).then((res) => {
  1625. this.innerVisiblePaper = false;
  1626. });
  1627. });
  1628. }
  1629. },
  1630. delPaper(options) {
  1631. this.$confirm("此操作将删除该试卷, 是否继续?", "提示", {
  1632. confirmButtonText: "确定",
  1633. cancelButtonText: "取消",
  1634. type: "warning",
  1635. })
  1636. .then(() => {
  1637. var data = {
  1638. bankId: options.bankId,
  1639. examId: options.examId,
  1640. name: options.name,
  1641. sort: options.sort,
  1642. status: -1,
  1643. };
  1644. this.$api.editbankexam(data).then(() => {
  1645. this.$message.success("删除成功!");
  1646. this.getPAPERList(data.bankId).then((res) => {
  1647. this.innerVisiblePaper = false;
  1648. });
  1649. });
  1650. })
  1651. .catch(() => {
  1652. this.$message({
  1653. type: "info",
  1654. message: "已取消删除",
  1655. });
  1656. });
  1657. },
  1658. //查看详情题目
  1659. xqpaperTopic(v) {
  1660. console.log(this.poppleData);
  1661. if (v.bankSectionId) {
  1662. var data = {
  1663. bankSectionId: v.bankSectionId,
  1664. };
  1665. } else {
  1666. var data = {
  1667. examId: v.examId,
  1668. };
  1669. }
  1670. data.typeId = this.poppleData.typeId;
  1671. this.$router.push({
  1672. path: "/questionBank",
  1673. query: data,
  1674. });
  1675. },
  1676. //新增题目
  1677. addItem(v) {
  1678. this.formTopic = [{}];
  1679. this.innerVisiblePaperTopic = true;
  1680. },
  1681. resultFormTable(faindex, chilindex) {
  1682. if (chilindex === null) {
  1683. } else {
  1684. }
  1685. },
  1686. //新增案例
  1687. addAnli(options) {
  1688. console.log(options);
  1689. },
  1690. // 删除选项
  1691. closeThislist(options, index) {
  1692. this.formTopic.forEach((items, indexs) => {
  1693. if (items.questionId === options.questionId) {
  1694. if (items.type === "1") {
  1695. items.jsonStr.splice(index, 1);
  1696. } else if (items.type === "2") {
  1697. items.jsonStr.splice(index, 1);
  1698. }
  1699. // this.$set(this.formTopic[indexs],'jsonStr',options.jsonStr)
  1700. }
  1701. });
  1702. console.log(this.formTopic);
  1703. },
  1704. // 新增选项
  1705. addList(options) {
  1706. var sut = {
  1707. questionId: options.questionId,
  1708. imgUrl: null,
  1709. optionAnswer: 0,
  1710. status: 1,
  1711. content: "",
  1712. };
  1713. this.formTopic.forEach((item, index) => {
  1714. if (item.questionId === options.questionId) {
  1715. item.jsonStr.push(sut);
  1716. }
  1717. });
  1718. },
  1719. // 单选框选中
  1720. actionListRadio(fatherNum, childNum) {
  1721. this.formTopic.forEach((item, index) => {
  1722. if (item.questionId === fatherNum) {
  1723. item.jsonStr.forEach((items, indexs) => {
  1724. if (indexs === childNum) {
  1725. items.optionAnswer = 1;
  1726. } else {
  1727. items.optionAnswer = 0;
  1728. }
  1729. });
  1730. }
  1731. });
  1732. },
  1733. // 复选框改变
  1734. actionListCheck(fatherNum, childNum, e) {
  1735. this.formTopic.forEach((item, index) => {
  1736. if (item.questionId === fatherNum) {
  1737. item.jsonStr.forEach((items, indexs) => {
  1738. if (indexs === childNum) {
  1739. if (items.optionAnswer === 1) {
  1740. items.optionAnswer = 0;
  1741. } else {
  1742. items.optionAnswer = 1;
  1743. }
  1744. }
  1745. });
  1746. }
  1747. });
  1748. console.log(this.formTopic);
  1749. },
  1750. },
  1751. };
  1752. </script>
  1753. <style lang="less" scoped>
  1754. /deep/.el-dropdown {
  1755. color: #409eff;
  1756. }
  1757. /deep/.el-button {
  1758. border-radius: 8px;
  1759. }
  1760. /deep/.el-dialog {
  1761. border-radius: 8px;
  1762. .el-dialog__header {
  1763. padding: 0;
  1764. .hearders {
  1765. height: 40px;
  1766. display: flex;
  1767. align-items: center;
  1768. justify-content: space-between;
  1769. padding: 0px 18px 0px 20px;
  1770. border-bottom: 1px solid #e2e2e2;
  1771. .leftTitle {
  1772. font-size: 14px;
  1773. font-weight: bold;
  1774. color: #2f4378;
  1775. }
  1776. .rightBoxs {
  1777. display: flex;
  1778. align-items: center;
  1779. img {
  1780. width: 14px;
  1781. height: 14px;
  1782. margin-left: 13px;
  1783. cursor: pointer;
  1784. }
  1785. }
  1786. }
  1787. }
  1788. .el-dialog__body {
  1789. padding: 0;
  1790. .contentBox {
  1791. padding: 20px 20px 5px;
  1792. .el-col {
  1793. padding: 0px 20px;
  1794. margin-bottom: 30px;
  1795. header {
  1796. margin-bottom: 6px;
  1797. color: #2f4378;
  1798. font-size: 14px;
  1799. }
  1800. }
  1801. .juscon {
  1802. float: none;
  1803. width: 50%;
  1804. margin: 0 auto;
  1805. }
  1806. }
  1807. }
  1808. .el-dialog__footer {
  1809. padding: 0;
  1810. .dialog-footer {
  1811. padding: 0px 40px;
  1812. height: 70px;
  1813. border-top: 1px solid #e2e2e2;
  1814. display: flex;
  1815. align-items: center;
  1816. justify-content: flex-end;
  1817. }
  1818. }
  1819. }
  1820. .imgBox {
  1821. width: 100%;
  1822. // height: 210px;
  1823. border: 1px solid #e2e2e2;
  1824. border-radius: 8px;
  1825. padding: 8px 8px 3px;
  1826. display: flex;
  1827. flex-direction: column;
  1828. align-items: center;
  1829. .imgLabel {
  1830. flex: 1;
  1831. width: 100%;
  1832. border: 1px dotted #e2e2e2;
  1833. color: #999;
  1834. font-size: 14px;
  1835. cursor: pointer;
  1836. border-radius: 8px;
  1837. .msPhoto {
  1838. display: flex;
  1839. justify-content: center;
  1840. align-items: center;
  1841. max-width: 100%;
  1842. max-height: 270px;
  1843. img {
  1844. max-width: 100%;
  1845. max-height: 270px;
  1846. }
  1847. }
  1848. .imgbbx {
  1849. display: flex;
  1850. flex-direction: column;
  1851. align-items: center;
  1852. justify-content: center;
  1853. width: 100%;
  1854. height: 100%;
  1855. i {
  1856. font-weight: bold;
  1857. margin: 14px 0;
  1858. font-size: 24px;
  1859. }
  1860. }
  1861. }
  1862. p {
  1863. margin: 5px 0px;
  1864. }
  1865. }
  1866. .imgBoxTopic {
  1867. width: 150px;
  1868. height: 150px;
  1869. border: 1px solid #e2e2e2;
  1870. border-radius: 8px;
  1871. display: flex;
  1872. flex-direction: column;
  1873. align-items: center;
  1874. .imgLabel {
  1875. flex: 1;
  1876. width: 100%;
  1877. background-color: #f9f9f9;
  1878. color: #999;
  1879. font-size: 14px;
  1880. cursor: pointer;
  1881. border-radius: 8px;
  1882. .msPhoto {
  1883. display: flex;
  1884. justify-content: center;
  1885. align-items: center;
  1886. max-width: 100%;
  1887. max-height: 150px;
  1888. img {
  1889. max-width: 100%;
  1890. max-height: 150px;
  1891. }
  1892. }
  1893. .imgbbx {
  1894. display: flex;
  1895. flex-direction: column;
  1896. align-items: center;
  1897. justify-content: center;
  1898. width: 100%;
  1899. height: 100%;
  1900. i {
  1901. font-weight: bold;
  1902. margin: 8px 0;
  1903. font-size: 20px;
  1904. }
  1905. }
  1906. }
  1907. }
  1908. .listChildoptions {
  1909. margin-bottom: 8px;
  1910. display: flex;
  1911. align-items: center;
  1912. }
  1913. </style>