浏览代码

1.3.2开发

刘洋 1 年之前
父节点
当前提交
975ef43967

+ 14 - 0
src/modules/question/api.js

@@ -317,6 +317,20 @@ export function questionImportDownloadTemplate(datas) {
 export function checkGptQuestionEnableApi() {
   return $httpWithMsg.post(`${QUESTION_API}/auth/ai_question_enable`, {});
 }
+export function getAiNums(data) {
+  return $httpWithMsg.post(
+    `${QUESTION_API}/org/ai-balance/info`,
+    {},
+    { params: data }
+  );
+}
+export function updateAiNums(data) {
+  return $httpWithMsg.post(
+    `${QUESTION_API}/org/ai-balance/modify`,
+    {},
+    { params: data }
+  );
+}
 export function buildGptQuestionApi(datas) {
   return $httpWithMsg.post(`${QUESTION_API}/ai/question/build`, datas);
 }

+ 1 - 0
src/modules/question/components/GptQuestionDialog.vue

@@ -58,6 +58,7 @@
               :step="1"
               step-strictly
               :controls="false"
+              disabled
             ></el-input-number>
           </el-form-item>
           <el-form-item

+ 9 - 0
src/modules/question/components/PropertyTreeSelect.vue

@@ -59,6 +59,7 @@
           check-on-click-node
           :expand-on-click-node="false"
           @check-change="checkChange"
+          @check="handleCheck"
         >
           <span slot-scope="{ data }" :class="['custom-tree-node']">
             <span v-if="!data.code">{{ data.name }}</span>
@@ -198,6 +199,14 @@ export default {
       this.selectedPropName = nodes.map((item) => item.name).join(";");
       this.emitChange();
     },
+    handleCheck(nodeObj, tree) {
+      let checkedCount = tree.getCheckedNodes(true, true).length;
+      if (checkedCount >= 3) {
+        // 如果超出限制,则取消最后一次勾选
+        tree.setChecked(nodeObj.id, false);
+        this.$message.warning("最多只能选择3个");
+      }
+    },
     getCheckedPropertyInfos(selectedPropIds = []) {
       let propertyInfos = [];
       const getProperty = (propertyList, parents) => {

+ 22 - 5
src/modules/question/views/QuestionManage.vue

@@ -169,13 +169,13 @@
       </div>
       <div class="question-list">
         <div class="icon-btn-group">
-          <svg-btn
+          <!-- <svg-btn
             name="xinzeng"
             @click="toCreateQuestion"
             v-if="!gptQuestionEnable"
             >创建试题</svg-btn
-          >
-          <el-dropdown v-else>
+          > -->
+          <el-dropdown>
             <svg-btn name="xinzeng">创建试题</svg-btn>
             <el-dropdown-menu slot="dropdown" class="action-dropdown">
               <el-dropdown-item>
@@ -346,7 +346,6 @@
     ></question-import-edit>
     <!-- GptQuestionDialog -->
     <gpt-question-dialog
-      v-if="gptQuestionEnable"
       ref="GptQuestionDialog"
       :course="{
         courseId: curCourse.id,
@@ -368,6 +367,7 @@ import {
   checkGptQuestionEnableApi,
   aiQuestionConfirmApi,
   classifyQuestionPageListApi,
+  getAiNums,
 } from "../api";
 import QuestionStatisticsDialog from "../components/QuestionStatisticsDialog.vue";
 import QuestionSafetySetDialog from "../components/QuestionSafetySetDialog.vue";
@@ -430,6 +430,7 @@ export default {
       questionImportData: {},
       gptQuestionEnable: false,
       curActionQids: [],
+      aiWarningMsg: "",
     };
   },
   computed: {
@@ -462,7 +463,19 @@ export default {
     ...mapActions([USER_SIGNIN]),
     async checkGptEnable() {
       const res = await checkGptQuestionEnableApi();
-      this.gptQuestionEnable = res.data;
+      // this.gptQuestionEnable = res.data;
+      if (res.data) {
+        let result = await getAiNums({
+          rootOrgId: this.$store.state.user.rootOrgId,
+        });
+        if (result?.data?.leftCount == 0) {
+          this.aiWarningMsg =
+            "AI命题出题包已经用完,请联系教务处老师购买试题包后再出题";
+        }
+        console.log("result", result);
+      } else {
+        this.aiWarningMsg = "未开通AI命题功能,请联系教务处老师进行开通";
+      }
     },
     toPage(page) {
       this.currentPage = page;
@@ -666,6 +679,10 @@ export default {
       this.$refs.QuestionImportEdit.open();
     },
     async toGPTQuestion() {
+      // if (this.aiWarningMsg) {
+      //   this.$message.error(this.aiWarningMsg);
+      //   return;
+      // }
       if (!this.filter.courseId) {
         this.$message.error("请先选择课程!");
         return;

+ 33 - 0
src/modules/questions/views/OrgProperty.vue

@@ -263,6 +263,15 @@
             <el-radio label="false">关闭</el-radio>
           </el-radio-group></el-form-item
         >
+        <el-form-item label="剩余题数">
+          {{ form.properties.leftCount }}
+        </el-form-item>
+        <el-form-item label="累计出题数">
+          {{ form.properties.permitCount }}
+        </el-form-item>
+        <el-form-item label="">
+          <el-button type="primary" @click="updateAiNums">更新数量</el-button>
+        </el-form-item>
         <!-- <el-form-item label="购买出题数据包">
           <el-radio-group v-model="trade">
             <el-radio-button
@@ -337,6 +346,7 @@
 import { mapState } from "vuex";
 import { QUESTION_API } from "@/constants/constants.js";
 import { orgAiTransactionSaveApi, orgAiTransactionListApi } from "../api";
+import { getAiNums, updateAiNums } from "../../question/api";
 
 export default {
   name: "OrgProperty",
@@ -408,6 +418,8 @@ export default {
           GEN_PAPER_QUESTION_COUNT: "",
           GEN_PAPER_QUESTION_START: "",
           GEN_PAPER_QUESTION_END: "",
+          leftCount: "",
+          permitCount: "",
         },
       },
       timeRange: [],
@@ -447,6 +459,7 @@ export default {
     }
     this.init();
     this.getTradeList();
+    this.initAiNums();
   },
   mounted() {
     setTimeout(() => {
@@ -458,6 +471,26 @@ export default {
     }, 200);
   },
   methods: {
+    initAiNums(msg) {
+      getAiNums({
+        rootOrgId: this.$store.state.user.rootOrgId,
+      }).then((res) => {
+        if (res.data) {
+          this.form.properties.leftCount = res.data?.leftCount;
+          this.form.properties.permitCount = res.data?.permitCount;
+          if (msg) {
+            this.$message.success(msg);
+          }
+        }
+      });
+    },
+    updateAiNums() {
+      updateAiNums({
+        rootOrgId: this.$store.state.user.rootOrgId,
+      }).then(() => {
+        this.initAiNums("更新成功");
+      });
+    },
     init() {
       var url = QUESTION_API + "/org/allProperties/" + this.form.orgId;
       this.$httpWithMsg.get(url).then((response) => {