edit.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :visible.sync="dialogVisible"
  5. :close-on-click-modal="false"
  6. :close-on-press-escape="false"
  7. append-to-body
  8. width="60%"
  9. class="dialog paper-dialog"
  10. top="6vh"
  11. @close="closeDialog"
  12. @open="getQuestionData"
  13. >
  14. <el-form
  15. ref="form"
  16. :label-width="formLabelWidth"
  17. :model="form"
  18. :rules="rules"
  19. class="paper-form"
  20. :class="readonly ? 'readonly-form' : ''"
  21. @submit.native.prevent
  22. >
  23. <el-form-item label="题库名称:" prop="ti_ku_ming_cheng_">
  24. <el-input
  25. v-model="form.ti_ku_ming_cheng_"
  26. type="text"
  27. :maxlength="128"
  28. :disabled="readonly"
  29. />
  30. </el-form-item>
  31. <el-form-item label="题库分类:" prop="ti_ku_fen_lei_">
  32. <el-select
  33. v-model="form.ti_ku_fen_lei_"
  34. filterable
  35. allow-create
  36. width="100%"
  37. :disabled="readonly"
  38. placeholder="请选择题库分类"
  39. >
  40. <el-option
  41. v-for="item in paperTypeOptions"
  42. :key="item.value"
  43. :label="item.label"
  44. :value="item.value"
  45. />
  46. </el-select>
  47. </el-form-item>
  48. <el-form-item prop="ti_ku_zhuang_tai_">
  49. <template slot="label">
  50. 题库状态
  51. <el-tooltip effect="dark" content="限制该题库是否可用于创建考试及自主考核。" placement="top">
  52. <i class="el-icon-question question-icon">:</i>
  53. </el-tooltip>
  54. </template>
  55. <el-radio-group v-model="form.ti_ku_zhuang_tai_" :disabled="readonly">
  56. <el-radio label="可用">可用</el-radio>
  57. <el-radio label="禁用">禁用</el-radio>
  58. </el-radio-group>
  59. </el-form-item>
  60. <el-form-item prop="shi_fou_gong_kai_">
  61. <template slot="label">
  62. 是否公开
  63. <el-tooltip effect="dark" content="限制该题库是否可自主考核。若您希望该题库仅用于考试中,则需要设置为“否”。" placement="top">
  64. <i class="el-icon-question question-icon">:</i>
  65. </el-tooltip>
  66. </template>
  67. <el-radio-group v-model="form.shi_fou_gong_kai_" :disabled="readonly">
  68. <el-radio label="是">是&nbsp;&nbsp;&nbsp;&nbsp;</el-radio>
  69. <el-radio label="否">否</el-radio>
  70. </el-radio-group>
  71. </el-form-item>
  72. <el-form-item prop="suo_shu_fan_wei_" class="inline-item">
  73. <template slot="label">
  74. 所属范围
  75. <el-tooltip effect="dark" content="设置题库的所属范围,组级则需要选择具体的专业组。" placement="top">
  76. <i class="el-icon-question question-icon">:</i>
  77. </el-tooltip>
  78. </template>
  79. <el-radio-group v-model="form.suo_shu_fan_wei_" :disabled="readonly">
  80. <el-radio label="科级">科级</el-radio>
  81. <el-radio label="组级">组级</el-radio>
  82. </el-radio-group>
  83. <el-select
  84. v-if="form.suo_shu_fan_wei_ === '组级'"
  85. v-model="form.bian_zhi_bu_men_"
  86. width="100%"
  87. :disabled="readonly"
  88. placeholder="请选择专业组"
  89. >
  90. <el-option
  91. v-for="item in deptList"
  92. :key="item.positionId"
  93. :label="item.positionName"
  94. :value="item.positionId"
  95. />
  96. </el-select>
  97. </el-form-item>
  98. <el-form-item prop="isLimit" class="inline-item">
  99. <template slot="label">
  100. 限考次数
  101. <el-tooltip effect="dark" content="限制是否可重复考核,以及可自主考核的最大次数。" placement="top">
  102. <i class="el-icon-question question-icon">:</i>
  103. </el-tooltip>
  104. </template>
  105. <el-radio-group v-model="form.isLimit" :disabled="readonly" @change="changeLimit">
  106. <el-radio label="0">不限</el-radio>
  107. <el-radio label="1">限制</el-radio>
  108. </el-radio-group>
  109. <div v-if="form.isLimit === '1'" class="time">
  110. <el-input-number
  111. v-model="form.xian_kao_ci_shu_"
  112. :min="1"
  113. :precision="0"
  114. :disabled="readonly"
  115. placeholder="请输入单个用户最大限考次数"
  116. />
  117. <div class="unit">次</div>
  118. </div>
  119. </el-form-item>
  120. <el-form-item prop="limitTime" class="inline-item">
  121. <template slot="label">
  122. 考试时长
  123. <el-tooltip effect="dark" content="设置该题库对于单次用户自主考核的最大考试时长。" placement="top">
  124. <i class="el-icon-question question-icon">:</i>
  125. </el-tooltip>
  126. </template>
  127. <el-radio-group v-model="form.limitTime" :disabled="readonly">
  128. <el-radio label="0">不限</el-radio>
  129. <el-radio label="1">限制</el-radio>
  130. </el-radio-group>
  131. <template v-if="form.limitTime === '1'">
  132. <div class="time">
  133. <el-input-number
  134. v-model="form.hours"
  135. :min="0"
  136. :max="72"
  137. :precision="0"
  138. :disabled="readonly"
  139. />
  140. <div class="unit">小时</div>
  141. </div>
  142. <div class="time">
  143. <el-input-number
  144. v-model="form.minutes"
  145. :min="0"
  146. :max="59"
  147. :precision="0"
  148. :disabled="readonly"
  149. />
  150. <div class="unit">分钟</div>
  151. </div>
  152. </template>
  153. </el-form-item>
  154. <el-form-item prop="da_biao_zhan_bi_">
  155. <template slot="label">
  156. 达标分值占比
  157. <el-tooltip effect="dark" content="设置该题库的达标分数线占题库总分的百分比。" placement="top">
  158. <i class="el-icon-question question-icon">:</i>
  159. </el-tooltip>
  160. </template>
  161. <el-input-number
  162. v-model="form.da_biao_zhan_bi_"
  163. :min="50"
  164. :max="100"
  165. :precision="0"
  166. :disabled="readonly"
  167. placeholder="请输入达标分值占比"
  168. />
  169. <div class="unit">%</div>
  170. </el-form-item>
  171. <el-form-item v-if="!readonly || form.ping_fen_ren_" prop="ping_fen_ren_">
  172. <template slot="label">
  173. 默认评分人
  174. <el-tooltip effect="dark" content="设置该题库试题的默认评分人,该题库下所有未设置评分人的题目都以该评分人为准。" placement="top">
  175. <i class="el-icon-question question-icon">:</i>
  176. </el-tooltip>
  177. </template>
  178. <!-- <el-cascader
  179. v-model="form.ping_fen_ren_"
  180. :options="getRaterOptions()"
  181. :show-all-levels="false"
  182. collapse-tags
  183. :props="{
  184. value: 'value',
  185. label: 'label',
  186. multiple: true,
  187. checkStrictly: false
  188. }"
  189. /> -->
  190. <el-select
  191. v-model="form.ping_fen_ren_"
  192. filterable
  193. width="100%"
  194. clearable
  195. multiple
  196. collapse-tags
  197. :multiple-limit="16"
  198. :disabled="readonly"
  199. placeholder="请选择默认评分人"
  200. >
  201. <el-option
  202. v-for="item in userList"
  203. :key="item.userId"
  204. :label="item.userName"
  205. :value="item.userId"
  206. />
  207. </el-select>
  208. </el-form-item>
  209. <el-form-item v-if="!readonly || form.miao_shu_" label="题库描述:" prop="miao_shu_">
  210. <el-input
  211. v-model="form.miao_shu_"
  212. type="textarea"
  213. :autosize="readonly"
  214. :rows="4"
  215. :disabled="readonly"
  216. placeholder="请输入描述内容"
  217. />
  218. </el-form-item>
  219. </el-form>
  220. <div class="question-table">
  221. <div v-if="!readonly" class="question-select">
  222. <div class="label">选择试题:</div>
  223. <ibps-custom-dialog
  224. v-model="quesIdList"
  225. size="small"
  226. template-key="tmlb"
  227. multiple
  228. type="dialog"
  229. class="custom-dialog"
  230. placeholder="请选择需要关联的题目信息"
  231. />
  232. </div>
  233. <div class="table-title">
  234. 题库试题信息
  235. </div>
  236. <el-table
  237. ref="elTable"
  238. :data="questionData"
  239. border
  240. stripe
  241. highlight-current-row
  242. style="width: 100%"
  243. max-height="400px"
  244. class="exam-table"
  245. @row-dblclick="handleRowDblclick"
  246. >
  247. <el-table-column label="序号" type="index" width="50" />
  248. <el-table-column
  249. prop="content"
  250. label="题干"
  251. min-width="150"
  252. >
  253. <template slot-scope="scope">
  254. <el-popover trigger="hover" placement="top">
  255. <div class="question-info">
  256. <div class="question-info-item">
  257. <div class="label">出题人</div>
  258. <div class="value">{{ transformUser(scope.row.creator) }}</div>
  259. </div>
  260. <div class="question-info-item">
  261. <div class="label">选项类型</div>
  262. <div class="value">{{ scope.row.optionType || '—' }}</div>
  263. </div>
  264. <div class="question-info-item">
  265. <div class="label">评分方式</div>
  266. <div class="value">{{ scope.row.rateType }}</div>
  267. </div>
  268. <div class="question-info-item">
  269. <div class="label">评分人</div>
  270. <div class="value">{{ transformUser(scope.row.rater) }}</div>
  271. </div>
  272. <div class="question-info-item">
  273. <div class="label">标签</div>
  274. <div class="value">{{ scope.row.quesTag }}</div>
  275. </div>
  276. <div class="question-info-item">
  277. <div class="label">状态</div>
  278. <div class="value">{{ scope.row.quesState }}</div>
  279. </div>
  280. </div>
  281. <div slot="reference" class="name-wrapper">{{ scope.row.content }}</div>
  282. </el-popover>
  283. </template>
  284. </el-table-column>
  285. <el-table-column
  286. prop="quesType"
  287. label="题型"
  288. width="70"
  289. />
  290. <el-table-column
  291. prop="score"
  292. label="分值"
  293. width="75"
  294. sortable
  295. />
  296. <el-table-column
  297. prop="createTime"
  298. label="出题时间"
  299. width="160"
  300. sortable
  301. />
  302. <el-table-column
  303. fixed="right"
  304. label="操作"
  305. width="100"
  306. >
  307. <template slot-scope="scope">
  308. <el-button
  309. v-if="!readonly"
  310. type="text"
  311. size="medium"
  312. @click="handleColumnAction(scope.row, false)"
  313. >修改</el-button>
  314. <el-button
  315. v-if="!readonly"
  316. type="text"
  317. style="color: #f56c6c;"
  318. size="medium"
  319. @click="handleRemove(scope.row)"
  320. >删除</el-button>
  321. <el-button
  322. v-if="readonly"
  323. type="text"
  324. style="color: #909399;"
  325. size="medium"
  326. @click="handleColumnAction(scope.row, true)"
  327. >详情</el-button>
  328. </template>
  329. </el-table-column>
  330. </el-table>
  331. </div>
  332. <div slot="footer" class="el-dialog--center">
  333. <ibps-toolbar
  334. :actions="toolbars"
  335. @action-event="handleActionEvent"
  336. />
  337. </div>
  338. <ques-edit
  339. v-if="questionDialogVisible"
  340. :id="quesId"
  341. :bank-id="id"
  342. :visible.sync="questionDialogVisible"
  343. :is-copy="isCopy"
  344. :ques-data="questionData"
  345. :readonly="quesReadonly"
  346. @update="updateData"
  347. @close="questionDialogVisible = false"
  348. />
  349. </el-dialog>
  350. </template>
  351. <script>
  352. import ActionUtils from '@/utils/action'
  353. import { paperTypeOptions } from '../constants'
  354. export default {
  355. components: {
  356. QuesEdit: () => import('../question/edit'),
  357. IbpsCustomDialog: () => import('@/business/platform/data/templaterender/custom-dialog')
  358. },
  359. props: {
  360. visible: {
  361. type: Boolean,
  362. default: false
  363. },
  364. id: {
  365. type: String,
  366. default: ''
  367. },
  368. readonly: {
  369. type: Boolean,
  370. default: false
  371. }
  372. },
  373. data () {
  374. const { userList = [], deptList = [], userId, level = {}} = this.$store.getters || {}
  375. return {
  376. userList,
  377. paperTypeOptions,
  378. level: level.second || level.first,
  379. deptList: deptList.filter(i => i.depth === 4),
  380. title: this.readonly ? '题库明细' : this.id ? '编辑题库' : '创建题库',
  381. formLabelWidth: '150px',
  382. dialogVisible: this.visible,
  383. dialogLoading: false,
  384. questionData: [],
  385. initialData: [],
  386. questionDialogVisible: false,
  387. quesId: '',
  388. quesIdList: '',
  389. isCopy: false,
  390. quesReadonly: false,
  391. form: {
  392. bian_zhi_bu_men_: '',
  393. bian_zhi_ren_: userId,
  394. bian_zhi_shi_jian: this.$common.getDateNow(19),
  395. ti_ku_ming_cheng_: '',
  396. suo_shu_fan_wei_: '科级',
  397. ti_ku_fen_lei_: paperTypeOptions.length ? paperTypeOptions[0].value : '',
  398. ti_ku_zhuang_tai_: '可用',
  399. xian_kao_ci_shu_: '不限',
  400. shi_fou_gong_kai_: '是',
  401. ping_fen_ren_: '',
  402. da_biao_zhan_bi_: 60,
  403. miao_shu_: '',
  404. ti_shu_: 0,
  405. isLimit: '0',
  406. limitTime: '0',
  407. hours: 2,
  408. minutes: 30
  409. },
  410. toolbars: [
  411. {
  412. key: 'submit',
  413. icon: 'ibps-icon-save',
  414. label: '保存',
  415. hidden: () => {
  416. return this.readonly
  417. }
  418. },
  419. { key: 'cancel', label: '关闭' }
  420. ],
  421. rules: {
  422. ti_ku_ming_cheng_: [{ required: true, message: this.$t('validate.required') }],
  423. suo_shu_fan_wei_: [{ required: true, message: this.$t('validate.required') }],
  424. bian_zhi_bu_men_: [{ required: true, message: this.$t('validate.required') }],
  425. ti_ku_fen_lei_: [{ required: true, message: this.$t('validate.required') }],
  426. shi_fou_gong_kai_: [{ required: true, message: this.$t('validate.required') }],
  427. ti_ku_zhuang_tai_: [{ required: true, message: this.$t('validate.required') }],
  428. xian_kao_ci_shu_: [{ required: true, message: this.$t('validate.required') }],
  429. kao_shi_shi_chang: [{ required: true, message: this.$t('validate.required') }],
  430. da_biao_zhan_bi_: [{ required: true, message: this.$t('validate.required') }]
  431. }
  432. }
  433. },
  434. computed: {
  435. formId () {
  436. return this.id
  437. }
  438. },
  439. watch: {
  440. visible: {
  441. handler (val, oldVal) {
  442. this.dialogVisible = this.visible
  443. }
  444. // immediate: true
  445. },
  446. quesIdList: {
  447. handler (val, oldVal) {
  448. this.addSelectQuestion(val)
  449. }
  450. }
  451. },
  452. mounted () {
  453. this.getQuestionData()
  454. },
  455. methods: {
  456. changeLimit (e) {
  457. this.form.xian_kao_ci_shu_ = e === '1' ? 1 : '不限'
  458. },
  459. getRaterOptions () {
  460. const { userList = [], deptList = [] } = this.$store.getters || {}
  461. const depts = deptList.filter(i => i.depth > 2)
  462. const temp = depts.map(item => {
  463. item.value = item.positionId
  464. item.label = item.positionName
  465. item.children = userList.map(i => {
  466. if (i.positionId.includes(item.positionId)) {
  467. i.value = i.userId
  468. i.label = i.userName
  469. return i
  470. }
  471. }).filter(i => i)
  472. return item
  473. })
  474. const res = []
  475. temp.forEach(item => {
  476. const index = res.findIndex(i => item.path === `${i.path}${item.value}.`)
  477. if (index !== -1) {
  478. res[index].children.unshift(item)
  479. } else {
  480. res.push(item)
  481. }
  482. })
  483. return res
  484. },
  485. transformUser (user) {
  486. const idList = user.split(',')
  487. const { userList = [] } = this.$store.getters
  488. const nameList = idList.map(id => {
  489. const user = userList.find(u => u.userId === id) || {}
  490. return user.userName || '-'
  491. })
  492. return nameList.join(',')
  493. },
  494. formatNum (num) {
  495. return num === null || num === undefined || num === '' ? 0 : num
  496. },
  497. handleRowDblclick (row) {
  498. this.handleColumnAction(row, true)
  499. },
  500. handleColumnAction (row, readonly) {
  501. this.quesId = row.quesId
  502. this.quesReadonly = readonly
  503. this.isCopy = this.quesIdList.includes(this.quesId)
  504. this.questionDialogVisible = true
  505. },
  506. handleRemove (row) {
  507. this.$confirm('确定要删除该题目吗?删除操作将在题库信息保存后生效', '提示', {
  508. confirmButtonText: '确定',
  509. cancelButtonText: '取消',
  510. type: 'warning'
  511. }).then(() => {
  512. this.questionData = this.questionData.filter(item => item.quesId !== row.quesId)
  513. })
  514. },
  515. handleActionEvent ({ key }) {
  516. switch (key) {
  517. case 'submit':
  518. this.handleSubmit()
  519. break
  520. case 'cancel':
  521. this.closeDialog()
  522. break
  523. default:
  524. break
  525. }
  526. },
  527. // 获取题库数据
  528. getQuestionData () {
  529. if (this.$utils.isEmpty(this.formId)) {
  530. return
  531. }
  532. const sql1 = `select id_, bian_zhi_ren_, bian_zhi_bu_men_, bian_zhi_shi_jian, ti_ku_ming_cheng_, ti_ku_fen_lei_, ti_ku_zhuang_tai_, shi_fou_gong_kai_, xian_kao_ci_shu_, ping_fen_ren_, miao_shu_, suo_shu_fan_wei_, kao_shi_shi_chang, da_biao_zhan_bi_ from t_question_bank where id_ = '${this.formId}'`
  533. const sql2 = `select id_ as quesId, chu_ti_ren_ as creator, bu_men_ as createDept, chu_ti_shi_jian_ as createTime, xu_hao_ as sn, ti_gan_ as content, ti_xing_ as quesType, fu_tu_ as img, xuan_xiang_lei_xi as optionType, da_an_ as answer, zheng_que_da_an_ as rightKey, ping_fen_fang_shi as rateType, ping_fen_ren_ as rater, fen_zhi_ as score, bei_zhu_ as note, xuan_xiang_shu_ as optionCount, biao_qian_ as quesTag, zhuang_tai_ as quesState from t_questions where parent_id_ = '${this.formId}' order by chu_ti_shi_jian_ desc`
  534. Promise.all([this.$common.request('sql', sql1), this.$common.request('sql', sql2)]).then(([res1, res2]) => {
  535. const { data: bankData = [] } = res1.variables || {}
  536. const { data: questionData = [] } = res2.variables || {}
  537. if (!bankData.length) {
  538. this.$message.error('数据不存在')
  539. return
  540. }
  541. const bank = bankData[0]
  542. bank.isLimit = bank.xian_kao_ci_shu_ === '不限' ? '0' : '1'
  543. bank.ping_fen_ren_ = bank.ping_fen_ren_ ? bank.ping_fen_ren_.split(',') : []
  544. bank.suo_shu_fan_wei_ = bank.suo_shu_fan_wei_ === '不限' ? '不限' : '科级'
  545. if (bank.kao_shi_shi_chang === '不限') {
  546. bank.limitTime = '0'
  547. bank.hours = null
  548. bank.minutes = null
  549. } else {
  550. bank.limitTime = '1'
  551. bank.hours = Math.floor(bank.kao_shi_shi_chang / (1000 * 60 * 60))
  552. bank.minutes = (bank.kao_shi_shi_chang % (1000 * 60 * 60)) / (60 * 1000)
  553. }
  554. // console.log(questionData)
  555. this.questionData = questionData
  556. this.initialData = JSON.parse(JSON.stringify(questionData))
  557. this.form = bank
  558. })
  559. },
  560. addSelectQuestion () {
  561. const sql = `select id_ as quesId, chu_ti_ren_ as creator, bu_men_ as createDept, chu_ti_shi_jian_ as createTime, xu_hao_ as sn, ti_gan_ as content, ti_xing_ as quesType, fu_tu_ as img, xuan_xiang_lei_xi as optionType, da_an_ as answer, zheng_que_da_an_ as rightKey, ping_fen_fang_shi as rateType, ping_fen_ren_ as rater, fen_zhi_ as score, bei_zhu_ as note, xuan_xiang_shu_ as optionCount, biao_qian_ as quesTag, zhuang_tai_ as quesState from t_questions where find_in_set(id_, '${this.quesIdList}')`
  562. this.$common.request('sql', sql).then(res => {
  563. const { data = [] } = res.variables || {}
  564. this.questionData = data.concat(this.questionData)
  565. })
  566. },
  567. handleSubmit () {
  568. this.$refs.form.validate((valid) => {
  569. if (valid) {
  570. // 表单验证通过,提交表单
  571. this.submitForm()
  572. } else {
  573. ActionUtils.saveErrorMessage()
  574. }
  575. })
  576. },
  577. async updatePaper (bankId) {
  578. const sql = `select fen_zhi_ from t_questions where parent_id_ = '${bankId}'`
  579. this.$common.request('sql', sql).then(res => {
  580. const { data = [] } = res.variables || {}
  581. const params = {
  582. tableName: 't_question_bank',
  583. updList: [
  584. {
  585. where: {
  586. id_: bankId
  587. },
  588. param: {
  589. ti_shu_: data.length,
  590. zong_fen_: data.reduce((sum, item) => sum + parseInt(item.fen_zhi_), 0)
  591. }
  592. }
  593. ]
  594. }
  595. this.$common.request('update', params).then(() => {
  596. console.log('更新题库信息成功')
  597. this.closeDialog()
  598. })
  599. })
  600. },
  601. async createQuestion (list, bankId) {
  602. const paramWhere = list.map(item => ({
  603. di_dian_: this.level,
  604. parent_id_: bankId,
  605. bu_men_: item.createDept || '',
  606. chu_ti_ren_: item.creator,
  607. chu_ti_shi_jian_: item.createTime,
  608. xu_hao_: item.sn || '',
  609. ti_gan_: item.content,
  610. ti_xing_: item.quesType,
  611. fu_tu_: item.img,
  612. xuan_xiang_lei_xi: item.optionType || '',
  613. da_an_: item.answer || '',
  614. fen_zhi_: item.score,
  615. xuan_xiang_shu_: item.optionCount || '',
  616. zheng_que_da_an_: item.rightKey,
  617. ping_fen_fang_shi: item.rateType || '',
  618. ping_fen_ren_: item.rater || '',
  619. bei_zhu_: item.note || '',
  620. zhuang_tai_: item.quesState,
  621. biao_qian_: item.quesTag || ''
  622. }))
  623. await this.$common.request('add', {
  624. tableName: 't_questions',
  625. paramWhere
  626. })
  627. },
  628. // 软删除,删除关联关系
  629. async deleteQuestion (list) {
  630. const updList = list.map(item => ({
  631. where: {
  632. id_: item.quesId
  633. },
  634. param: {
  635. parent_id_: ''
  636. }
  637. }))
  638. await this.$common.request('update', {
  639. tableName: 't_questions',
  640. updList
  641. })
  642. },
  643. submitForm () {
  644. if (this.form.limitTime === '0') {
  645. this.form.kao_shi_shi_chang = '不限'
  646. } else {
  647. this.form.kao_shi_shi_chang = (this.formatNum(this.form.hours) * 60 + this.formatNum(this.form.minutes)) * 60 * 1000
  648. }
  649. this.form.bian_zhi_bu_men_ = this.form.suo_shu_fan_wei_ === '科级' ? '' : this.form.bian_zhi_bu_men_
  650. this.form.di_dian_ = this.level
  651. this.form.ping_fen_ren_ = this.form.ping_fen_ren_ ? this.form.ping_fen_ren_.join(',') : ''
  652. delete this.form.isLimit
  653. delete this.form.limitTime
  654. delete this.form.hours
  655. delete this.form.minutes
  656. const addParams = {
  657. tableName: 't_question_bank',
  658. paramWhere: [{
  659. ...this.form,
  660. ti_shu_: 0,
  661. zong_fen_: 0
  662. }]
  663. }
  664. const updateParams = {
  665. tableName: 't_question_bank',
  666. updList: [
  667. {
  668. where: {
  669. id_: this.formId
  670. },
  671. param: this.form
  672. }
  673. ]
  674. }
  675. const type = this.formId ? 'update' : 'add'
  676. const params = type === 'add' ? addParams : updateParams
  677. const temp = this.questionData.filter(i => !this.quesIdList.includes(i.quesId)).map(i => i.quesId)
  678. const deleteList = this.initialData.filter(item => !temp.includes(item.quesId))
  679. const createList = this.questionData.filter(i => this.quesIdList.includes(i.quesId))
  680. this.$common.request(type, params).then(async res => {
  681. const { cont = [] } = res.variables || {}
  682. let dataId = this.id
  683. if (cont.length) {
  684. dataId = cont[0].id_
  685. }
  686. const PromiseList = []
  687. if (createList.length) {
  688. PromiseList.push(this.createQuestion(createList, dataId))
  689. }
  690. if (deleteList.length) {
  691. PromiseList.push(this.deleteQuestion(deleteList))
  692. }
  693. Promise.all(PromiseList).then(() => {
  694. this.updatePaper(dataId)
  695. })
  696. this.$message.success(this.formId ? '保存题库信息成功' : '新增题库成功')
  697. })
  698. },
  699. // 关闭当前窗口
  700. closeDialog () {
  701. this.$emit('close', false)
  702. },
  703. updateData (data) {
  704. this.questionData = data
  705. }
  706. }
  707. }
  708. </script>
  709. <style lang="scss" scoped>
  710. .paper-dialog {
  711. ::v-deep {
  712. .el-dialog {
  713. min-width: 1080px;
  714. }
  715. .el-dialog__body {
  716. height: calc(88vh - 200px);
  717. }
  718. .el-form-item {
  719. margin-bottom: 14px !important;
  720. &:last-child {
  721. margin-bottom: 0 !important;
  722. }
  723. .el-form-item__label {
  724. font-size: 14px !important;
  725. }
  726. }
  727. .el-form-item--small .el-form-item__error {
  728. padding-top: 6px;
  729. }
  730. }
  731. .readonly-form {
  732. ::v-deep {
  733. .el-radio, .el-checkbox, .el-radio-button, .el-input, .el-select, .el-textarea, .el-input-number {
  734. pointer-events: none;
  735. }
  736. }
  737. }
  738. .paper-form {
  739. padding: 20px 20px 14px 20px;
  740. }
  741. .inline-item {
  742. ::v-deep {
  743. .el-radio-group {
  744. margin-right: 20px;
  745. }
  746. }
  747. .time {
  748. display: inline-block;
  749. }
  750. }
  751. .unit {
  752. display: inline-block;
  753. margin: 0 20px 0 5px;
  754. }
  755. .question-table {
  756. margin-bottom: 20px;
  757. padding: 0 20px;
  758. ::v-deep {
  759. .el-table {
  760. th {
  761. font-size: 14px !important;
  762. text-align: center;
  763. }
  764. td {
  765. font-size: 14px !important;
  766. }
  767. .el-table__row {
  768. cursor: pointer;
  769. }
  770. }
  771. }
  772. .question-select {
  773. display: flex;
  774. align-items: center;
  775. .label {
  776. width: 138px;
  777. padding-right: 12px;
  778. text-align: right;
  779. }
  780. .custom-dialog {
  781. flex: 1;
  782. }
  783. margin-bottom: 10px;
  784. }
  785. .table-title {
  786. font-size: 16px;
  787. font-weight: 600;
  788. margin: 20px 0 10px;
  789. }
  790. }
  791. }
  792. .question-info {
  793. .question-info-item {
  794. display: flex;
  795. margin-bottom: 10px;
  796. max-width: 200px;
  797. font-size: 14px;
  798. .label {
  799. width: 100px;
  800. font-size: 14px;
  801. color: #606266;
  802. text-align: left;
  803. }
  804. .value {
  805. font-weight: 600;
  806. overflow: hidden;
  807. text-overflow: ellipsis;
  808. white-space: nowrap;
  809. }
  810. }
  811. }
  812. </style>