From c85c74e084ac9ede4a4d539262ff865cfcdd7289 Mon Sep 17 00:00:00 2001
From: odc.xiaohui <xiaohui@Q1>
Date: 星期一, 24 七月 2023 11:16:16 +0800
Subject: [PATCH] 修改青羊后台题目个人模拟

---
 src/store/modules/exam.js                  |    4 
 src/views/exam/personalSimulation/list.vue |  116 ++++++++++
 src/router.js                              |   14 +
 src/views/exam/personalSimulation/edit.vue |  460 +++++++++++++++++++++++++++++++++++++++++
 src/api/examPaper.js                       |    9 
 5 files changed, 599 insertions(+), 4 deletions(-)

diff --git a/src/api/examPaper.js b/src/api/examPaper.js
index 58a62ef..88bfd4e 100644
--- a/src/api/examPaper.js
+++ b/src/api/examPaper.js
@@ -1,9 +1,14 @@
-import { post } from '@/utils/request'
+import { get, post } from '@/utils/request'
 
 export default {
   pageList: query => post('/api/admin/exam/paper/page', query),
   taskExamPage: query => post('/api/admin/exam/paper/taskExamPage', query),
   edit: query => post('/api/admin/exam/paper/edit', query),
   select: id => post('/api/admin/exam/paper/select/' + id),
-  deletePaper: id => post('/api/admin/exam/paper/delete/' + id)
+  deletePaper: id => post('/api/admin/exam/paper/delete/' + id),
+  pageselfList: query => get('/api/admin/exam/templates/list', query),
+  selfedit: query => post('/api/admin/exam/templates/edit', query),
+  selfselect: query => post('/api/admin/exam/templates/select/'+ query),
+  selfdeletePaper: id => post('/api/admin/exam/templates/remove/' + id),
+  selflist: query => post('/api/admin/education/subject/list', query),
 }
diff --git a/src/router.js b/src/router.js
index 470f931..6598c82 100644
--- a/src/router.js
+++ b/src/router.js
@@ -108,6 +108,20 @@
         meta: { title: '鍗曢�夐缂栬緫', noCache: true, activeMenu: '/exam/question/list' },
         hidden: true
       },
+
+      {
+        path: 'personalSimulation/list',
+        component: () => import('@/views/exam/personalSimulation/list'),
+        name: 'personalSimulation',
+        meta: { title: '涓汉妯℃嫙', noCache: true }
+      },
+      {
+        path: 'personalSimulation/edit',
+        component: () => import('@/views/exam/personalSimulation/edit'),
+        name: 'personalSimulationEdit',
+        meta: { title: '璇曞嵎缂栬緫', noCache: true, activeMenu: '/exam/personalSimulation/list' },
+        hidden: true
+      },
       {
         path: 'question/edit/multipleChoice',
         component: () => import('@/views/exam/question/edit/multiple-choice'),
diff --git a/src/store/modules/exam.js b/src/store/modules/exam.js
index b96a649..d1fcbbe 100644
--- a/src/store/modules/exam.js
+++ b/src/store/modules/exam.js
@@ -28,8 +28,8 @@
 
 // actions
 const actions = {
-  initSubject ({ commit }, action) {
-    subjectApi.list().then(re => {
+  async initSubject ({ commit }, action) {
+    await subjectApi.list().then(re => {
       commit('setSubjects', re.response)
       if (action !== undefined) {
         action()
diff --git a/src/views/exam/personalSimulation/edit.vue b/src/views/exam/personalSimulation/edit.vue
new file mode 100644
index 0000000..051c018
--- /dev/null
+++ b/src/views/exam/personalSimulation/edit.vue
@@ -0,0 +1,460 @@
+<template>
+  <div class="app-container">
+    <el-form :model="form" ref="form" label-width="200px" v-loading="formLoading" :rules="rules">
+<!--      <el-form-item label="鑰冪敓锛�" prop="userIds" required>-->
+<!--        <el-cascader v-model="form.userIds" :options="options" :props="props" clearable collapse-tags>-->
+<!--        </el-cascader>-->
+<!--      </el-form-item>-->
+      <el-form-item label="璇剧洰锛�" prop="subjectId" required >
+        <el-select ref="subjectIdRef" v-model="form.subjectId" placeholder="璇剧洰" multiple
+                   collapse-tags   @visible-change="subjectIdEvent">
+          <el-option v-for="item in subjectFilter" :key="item.id" :value="item.id"
+                     :label="item.name+' '"></el-option>
+        </el-select>
+      </el-form-item>
+      <el-form-item label="璇曞嵎绫诲瀷锛�" prop="paperType" required >
+        <el-select v-model="form.paperType" placeholder="璇曞嵎绫诲瀷"  @visible-change="subjectIdEvent" disabled>
+          <el-option v-for="item in paperTypeEnum" :key="item.key" :value="item.key" :label="item.value" ></el-option>
+        </el-select>
+      </el-form-item>
+      <el-form-item label="鏃堕棿闄愬埗锛�" required v-show="form.paperType===4">
+        <el-date-picker v-model="form.limitDateTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange"
+                        range-separator="鑷�" start-placeholder="寮�濮嬫棩鏈�" end-placeholder="缁撴潫鏃ユ湡">
+        </el-date-picker>
+      </el-form-item>
+      <el-form-item label="璇曞嵎鍚嶇О锛�"  prop="name" required >
+        <el-row :gutter="20">
+          <el-col :span="9">
+            <el-input v-model="form.name"/>
+          </el-col>
+          <el-col :span="2" v-if="form.paperType==7">
+            <span>鎬绘暟鍒嗭細</span>
+          </el-col>
+          <el-col :span="9" v-if="form.paperType==7">
+            <el-input disabled v-model="form.aggregateSource"/>
+          </el-col>
+        </el-row>
+      </el-form-item>
+      <el-form-item :key="item.subjectId" :label="item.label"   required  v-for="(item,key) in form.questionTypeVMS"  v-if="form.paperType ==7">
+        <el-row >
+          <el-col :span="3" >
+            <span>澶氶�夐锛� </span>
+
+          </el-col>
+          <el-col :span="3">
+            <el-input v-model="form.questionTypeVMS[key].multipleChoice" style="width: 80%"/>
+          </el-col>
+          <el-col :span="3" >
+            <span>鍗曢�夐锛�</span>
+          </el-col>
+          <el-col :span="3">
+            <el-input v-model="form.questionTypeVMS[key].singleChoice" style="width: 80%"/>
+          </el-col>
+          <el-col :span="3" >
+            <span>鍒ゆ柇棰橈細</span>
+          </el-col>
+          <el-col :span="3">
+            <el-input v-model="form.questionTypeVMS[key].trueFalse" style="width: 80%"/>
+          </el-col>
+        </el-row>
+      </el-form-item>
+      <!--      <el-form-item label="鎬绘暟鍒嗭細" v-if="form.paperType==7"  prop="name" required>-->
+      <!--        <el-input v-model="form.name"/>-->
+      <!--      </el-form-item>-->
+      <el-form-item :key="index" :label="'鏍囬'+(index+1)+'锛�'" required v-for="(titleItem,index) in form.titleItems">
+        <el-input v-model="titleItem.name" style="width: 80%"/>
+        <el-button  v-if="form.paperType!=7" type="text" class="link-left" style="margin-left: 20px" size="mini" @click="addQuestion(titleItem)">
+          娣诲姞棰樼洰
+        </el-button>
+        <el-button type="text" class="link-left" size="mini" @click="form.titleItems.splice(index,1)">鍒犻櫎</el-button>
+        <el-card class="exampaper-item-box" v-if="titleItem.questionItems&&titleItem.questionItems.length!==0&&subjectIdList.length<2">
+          <el-form-item :key="questionIndex" :label="'棰樼洰'+(questionIndex+1)+'锛�'"
+                        v-for="(questionItem,questionIndex) in titleItem.questionItems" style="margin-bottom: 15px">
+            <el-row>
+              <el-col :span="23">
+                <QuestionShow :qType="questionItem.questionType" :question="questionItem"/>
+              </el-col>
+              <el-col :span="1">
+                <el-button type="text" size="mini" @click="titleItem.questionItems.splice(questionIndex,1)">鍒犻櫎
+                </el-button>
+              </el-col>
+            </el-row>
+          </el-form-item>
+        </el-card>
+      </el-form-item>
+      <el-form-item label="寤鸿鏃堕暱锛�" prop="suggestTime" required>
+        <el-input v-model="form.suggestTime" placeholder="鍒嗛挓"/>
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" @click="submitForm">鎻愪氦</el-button>
+        <el-button @click="resetForm">閲嶇疆</el-button>
+        <el-button type="success" @click="addTitle">娣诲姞鏍囬</el-button>
+      </el-form-item>
+    </el-form>
+    <el-dialog :visible.sync="questionPage.showDialog"  width="70%">
+      <el-form :model="questionPage.queryParam" ref="queryForm" :inline="true">
+        <el-form-item label="ID锛�">
+          <el-input v-model="questionPage.queryParam.id"  clearable></el-input>
+        </el-form-item>
+        <el-form-item label="棰樺瀷锛�">
+          <el-select v-model="questionPage.queryParam.questionType" clearable>
+            <el-option v-for="item in questionTypeEnum" :key="item.key" :value="item.key" :label="item.value"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" @click="queryForm">鏌ヨ</el-button>
+        </el-form-item>
+      </el-form>
+      <el-table v-loading="questionPage.listLoading" :data="questionPage.tableData"
+                @selection-change="handleSelectionChange" border fit highlight-current-row style="width: 100%">
+        <el-table-column type="selection" width="35"></el-table-column>
+        <el-table-column prop="questionType" label="棰樺瀷" :formatter="questionTypeFormatter" width="70px"/>
+        <el-table-column prop="shortTitle" label="棰樺共" show-overflow-tooltip/>
+      </el-table>
+      <pagination v-show="questionPage.total>0" :total="questionPage.total"
+                  :page.sync="questionPage.queryParam.pageIndex" :limit.sync="questionPage.queryParam.pageSize"
+                  @pagination="search"/>
+      <span slot="footer" class="dialog-footer">
+          <el-button @click="questionPage.showDialog = false">鍙� 娑�</el-button>
+          <el-button type="primary" @click="confirmQuestionSelect">纭畾</el-button>
+     </span>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+
+import { mapGetters, mapState, mapActions } from 'vuex'
+import Pagination from '@/components/Pagination'
+import QuestionShow from '../question/components/Show'
+import examPaperApi from '@/api/examPaper'
+import questionApi from '@/api/question'
+import departmentApi from '@/api/department'
+
+export default {
+  components: { Pagination, QuestionShow },
+
+  data () {
+    return {
+      props: {
+        multiple: true
+        // lazy: true,
+        // lazyLoad (node, resolve) {
+        //   console.log(node,"node");
+        //   var that = this;
+        //   departmentApi.selectUser(node.value).then(re=>{
+        //     console.log(re,"re");
+        //     const nodes = re.response.map(xxx=>{
+        //       return {value: xxx.id,label: xxx.realName,leaf: node.level >= 1}
+        //     });
+        //     resolve(nodes);
+        //   })
+        // }
+      },
+      options: [],
+      departCascaderProps:{
+        multiple: true
+      },
+      subjectIdList:[],
+      form: {
+        aggregateSource:'',
+        id: null,
+        departmentIds: [],
+
+        subjectId: [],
+        paperType: 7,
+        limitDateTime: [],
+        name: '',
+        suggestTime: null,
+        titleItems: [],
+        subjectSource:{},
+        questionTypeVMS:[]
+      },
+      subjectFilter: null,
+      formLoading: false,
+      rules: {
+
+        subjectId: [
+          { required: true, message: '璇烽�夋嫨璇剧洰', trigger: 'change' }
+        ],
+        paperType: [
+          { required: true, message: '璇烽�夋嫨璇曞嵎绫诲瀷', trigger: 'change' }
+        ],
+        name: [
+          { required: true, message: '璇疯緭鍏ヨ瘯鍗峰悕绉�', trigger: 'blur' }
+        ],
+        suggestTime: [
+          { required: true, message: '璇疯緭鍏ュ缓璁椂闀�', trigger: 'blur' }
+        ]
+      },
+      questionPage: {
+        multipleSelection: [],
+        showDialog: false,
+        queryParam: {
+          id: null,
+          questionType: null,
+          subjectId: 1,
+          pageIndex: 1,
+          pageSize: 5
+        },
+        listLoading: true,
+        tableData: [],
+        total: 0
+      },
+      currentTitleItem: null
+    }
+  },
+  created () {
+    examPaperApi.selflist().then(res => {
+      console.log(res)
+      this.subjectFilter = res.response
+    })
+  },
+   async mounted () {
+
+     let id = this.$route.query.id
+     let _this = this
+
+     this.initSubject(function () {
+       _this.subjectFilter = _this.subjects
+     })
+     if (id && parseInt(id) !== 0) {
+       _this.formLoading = true
+       await examPaperApi.selfselect(id).then(re => {
+         _this.form = re.response
+         // _this.form.userIds = re.response.userId
+         console.log(_this.form)
+         _this.formLoading = false
+       })
+     }
+     departmentApi.selectDepartmentUser().then(res => {
+       console.log("res", res);
+
+       _this.options = res.response.map(x => {
+         return {
+           value: x.department.id, label: x.department.name, children: x.userList.map(xx => {
+             return { value: xx.id, label: xx.realName }
+           })
+         }
+       })
+     })
+
+     // this.subjectIdEvent(false)
+   },
+  methods: {
+    titlejs(val){
+      console.log(val)
+      let str = ''
+      this.subjectFilter.forEach(item=>{
+        if (item.id == val){
+          str = item.name
+        }
+      })
+      return str
+    },
+    subjectIdEvent(e){
+      console.log(e,this.$refs.subjectIdRef.selected)
+      let arr=[]
+      if (e){
+
+      }else {
+        this.$refs.subjectIdRef.selected.forEach(item=>{
+          arr.push({
+            label:item.label,
+            subjectId:item.value,
+            singleChoice:'',
+            multipleChoice:'',
+            trueFalse:''
+          })
+        })
+        console.log(arr)
+        this.form.questionTypeVMS = arr
+      }
+
+      if (this.form.paperType ==7){
+        //瑾槑鏄毃姗�
+        this.subjectIdList = arr
+        let obj1={}
+        let arr1 = []
+        arr.forEach((item,index)=>{
+          // obj1[item.id]=''
+          arr1.push({
+            subjectId:item.id,
+            singleChoice:'',
+            multipleChoice:'',
+            trueFalse:''
+          })
+          // let obj={
+          //   item
+          // }
+
+          // for (let i in obj) {
+          //   i=item.id
+          //   obj[i]= ''
+          //   obj1[i] = ''
+          //   console.log('閿悕锛�', i);
+          //   console.log('閿�硷細', obj[i]);
+          // }
+        })
+        this.form.subjectSource = obj1
+
+        console.log(this.form.subjectSource)
+        console.log(this.form.questionTypeVMS)
+        // this.form.paperType = 7
+        this.form.titleItems = []
+      }else {
+        this.form.subjectSource={}
+        this.subjectIdList = []
+        // this.form.paperType = 1
+      }
+    },
+    submitForm () {
+      let _this = this
+      console.log(this.subjectIdList)
+      console.log(this.form.subjectSource)
+      this.$refs.form.validate((valid) => {
+        if (valid) {
+          this.formLoading = true;
+          if (this.subjectIdList.length == 1){
+            this.form.subjectId= this.form.subjectId
+          };
+          let op = [];
+          // for(var ele of this.form.userIds){
+          //   op.push(ele[1])
+          // };
+          // this.form.userIds = op;
+          console.log("laks",this.form)
+          if(this.form.questionTypeVMS == null){
+            this.form.questionTypeVMS = [];
+          }
+          examPaperApi.selfedit(this.form).then(re => {
+            if (re.code === 1) {
+              _this.$message.success(re.message)
+              _this.delCurrentView(_this).then(() => {
+                _this.$router.push('/exam/personalSimulation/list')
+              })
+            } else {
+              _this.$message.error(re.message)
+              this.formLoading = false
+            }
+          }).catch(e => {
+            this.formLoading = false
+          })
+        } else {
+          return false
+        }
+      })
+    },
+    addTitle () {
+      this.form.titleItems.push({
+        name: '',
+        questionItems: []
+      })
+    },
+    addQuestion (titleItem) {
+      this.currentTitleItem = titleItem
+      this.questionPage.showDialog = true
+      this.search()
+    },
+    removeTitleItem (titleItem) {
+      this.form.titleItems.remove(titleItem)
+    },
+    removeQuestion (titleItem, questionItem) {
+      titleItem.questionItems.remove(questionItem)
+    },
+    queryForm () {
+      this.questionPage.queryParam.pageIndex = 1
+      this.search()
+    },
+    confirmQuestionSelect () {
+      let _this = this
+      this.questionPage.multipleSelection.forEach(q => {
+        questionApi.select(q.id).then(re => {
+          _this.currentTitleItem.questionItems.push(re.response)
+        })
+      })
+      this.questionPage.showDialog = false
+    },
+    levelChange () {
+      // this.form.subjectId = null
+      // this.subjectFilter = this.subjects.filter(data =>{
+      //   return this.form.departmentIds.forEach(item=>{data.level == item})
+      // })
+      //
+      // this.subjectFilter = []
+      // this.form.departmentIds.forEach(item=>{
+      //   this.subjects.forEach(jectitem=>{
+      //     if (item==jectitem.level){
+      //       this.subjectFilter.push(jectitem)
+      //     }
+      //   })
+      // })
+      console.log(this.subjects,this.form.departmentIds)
+      // this.subjectFilter = this.subjects
+    },
+    search () {
+      if (this.subjectIdList.length=1){
+        this.questionPage.queryParam.subjectId = this.form.subjectId
+      }
+
+      this.questionPage.listLoading = true
+      questionApi.pageList(this.questionPage.queryParam).then(data => {
+        const re = data.response
+        this.questionPage.tableData = re.list
+        this.questionPage.total = re.total
+        this.questionPage.queryParam.pageIndex = re.pageNum
+        this.questionPage.listLoading = false
+      })
+    },
+    handleSelectionChange (val) {
+      this.questionPage.multipleSelection = val
+    },
+    questionTypeFormatter (row, column, cellValue, index) {
+      return this.enumFormat(this.questionTypeEnum, cellValue)
+    },
+    subjectFormatter (row, column, cellValue, index) {
+      return this.subjectEnumFormat(cellValue)
+    },
+    resetForm () {
+      let lastId = this.form.id
+      this.$refs['form'].resetFields()
+      this.form= {
+        aggregateSource:100,
+        id: null,
+        departmentIds: [],
+        subjectId: [],
+        paperType: 1,
+        limitDateTime: [],
+        name: '',
+        suggestTime: null,
+        titleItems: [],
+        subjectSource:null,
+        questionTypeVMS:[]
+      }
+      this.form.id = lastId
+    },
+    ...mapActions('exam', { initSubject: 'initSubject' }),
+    ...mapActions('tagsView', { delCurrentView: 'delCurrentView' }),
+  },
+  computed: {
+
+    ...mapGetters('enumItem', ['enumFormat']),
+    ...mapState('enumItem', {
+      questionTypeEnum: state => state.exam.question.typeEnum,
+      paperTypeEnum: state => state.exam.examPaper.paperTypeEnum,
+      levelEnum: state => state.user.levelEnum
+    }),
+    ...mapState('exam', { subjects: state => state.subjects })
+  }
+}
+</script>
+
+<style lang="scss">
+.exampaper-item-box {
+  .q-title {
+    margin: 0px 5px 0px 5px;
+  }
+  .q-item-content {
+  }
+}
+</style>
diff --git a/src/views/exam/personalSimulation/list.vue b/src/views/exam/personalSimulation/list.vue
new file mode 100644
index 0000000..6e5a749
--- /dev/null
+++ b/src/views/exam/personalSimulation/list.vue
@@ -0,0 +1,116 @@
+<template>
+  <div class="app-container">
+<!--    <el-form :model="queryParam" ref="queryForm" :inline="true">-->
+<!--      <el-form-item label="棰樼洰ID锛�">-->
+<!--        <el-input v-model="queryParam.id" clearable></el-input>-->
+<!--      </el-form-item>-->
+<!--      <el-form-item label="閮ㄩ棬锛�">-->
+<!--        <el-select v-model="queryParam.level" placeholder="閮ㄩ棬" @change="levelChange" clearable>-->
+<!--          <el-option v-for="item in levelEnum" :key="item.key" :value="item.key" :label="item.value"></el-option>-->
+<!--        </el-select>-->
+<!--      </el-form-item>-->
+<!--      <el-form-item label="璇剧洰锛�" >-->
+<!--        <el-select v-model="queryParam.subjectId"  clearable>-->
+<!--          <el-option v-for="item in subjectFilter" :key="item.id" :value="item.id" :label="item.name+' '"></el-option>-->
+<!--        </el-select>-->
+<!--      </el-form-item>-->
+<!--      <el-form-item>-->
+<!--        <el-button type="primary" @click="submitForm">鏌ヨ</el-button>-->
+<!--        <router-link :to="{path:'/exam/personalSimulation/edit'}" class="link-left">-->
+<!--          <el-button type="primary">娣诲姞</el-button>-->
+<!--        </router-link>-->
+<!--      </el-form-item>-->
+<!--    </el-form>-->
+    <router-link :to="{path:'/exam/personalSimulation/edit'}" class="link-left">
+      <el-button type="primary">娣诲姞</el-button>
+    </router-link>
+    <el-table v-loading="listLoading" :data="tableData" border fit highlight-current-row style="width: 100%">
+      <el-table-column prop="subjectId" label="璇剧洰" :formatter="subjectFormatter" width="120px" />
+      <el-table-column prop="name" label="鍚嶇О"  />
+      <el-table-column prop="createTime" label="鍒涘缓鏃堕棿" width="160px"/>
+      <el-table-column  label="鎿嶄綔" align="center"  width="160px">
+        <template slot-scope="{row}">
+          <el-button size="mini" @click="$router.push({path:'/exam/personalSimulation/edit',query:{id:row.id}})" >缂栬緫</el-button>
+          <el-button size="mini" type="danger"  @click="deletePaper(row)" class="link-left">鍒犻櫎</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    <pagination v-show="total>0" :total="total" :page.sync="queryParam.pageIndex" :limit.sync="queryParam.pageSize"
+                @pagination="search"/>
+  </div>
+</template>
+
+<script>
+import { mapGetters, mapState, mapActions } from 'vuex'
+import Pagination from '@/components/Pagination'
+import examPaperApi from '@/api/examPaper'
+
+export default {
+  components: { Pagination },
+  data () {
+    return {
+      queryParam: {
+        id: null,
+        level: null,
+        subjectId: null,
+        pageIndex: 1,
+        pageSize: 10
+      },
+      subjectFilter: null,
+      listLoading: true,
+      tableData: [],
+      total: 0
+    }
+  },
+  created () {
+    this.initSubject()
+    this.search()
+    this.queryParam.subjectId = null
+    this.subjectFilter = this.subjects
+  },
+  methods: {
+    submitForm () {
+      this.queryParam.pageIndex = 1
+      this.search()
+    },
+    search () {
+      this.listLoading = true
+      examPaperApi.pageselfList(this.queryParam).then(data => {
+        const re = data.response
+        this.tableData = re.list
+        this.total = re.total
+        this.queryParam.pageIndex = re.pageNum
+        this.listLoading = false
+      })
+    },
+    deletePaper (row) {
+      let _this = this
+      examPaperApi.selfdeletePaper(row.id).then(re => {
+        if (re.code === 1) {
+          _this.search()
+          _this.$message.success(re.message)
+        } else {
+          _this.$message.error(re.message)
+        }
+      })
+    },
+    levelChange () {
+      this.queryParam.subjectId = null
+      this.subjectFilter = this.subjects
+    },
+    subjectFormatter  (row, column, cellValue, index) {
+      console.log(row, column, cellValue, index)
+      return this.subjectEnumFormat(cellValue)
+    },
+    ...mapActions('exam', { initSubject: 'initSubject' })
+  },
+  computed: {
+    ...mapGetters('enumItem', ['enumFormat']),
+    ...mapState('enumItem', {
+      levelEnum: state => state.user.levelEnum
+    }),
+    ...mapGetters('exam', ['subjectEnumFormat']),
+    ...mapState('exam', { subjects: state => state.subjects })
+  }
+}
+</script>

--
Gitblit v1.8.0