Преглед изворни кода

创建测试添加默认jsonString

曹冬冬 пре 5 година
родитељ
комит
fbbc6ef0ce
1 измењених фајлова са 141 додато и 129 уклоњено
  1. 141 129
      src/views/cnctestlists/cncTestLists.vue

+ 141 - 129
src/views/cnctestlists/cncTestLists.vue

@@ -2,136 +2,148 @@
 </template>
 
 <script>
-    import HeaderMain from "../../components/HeaderMain";
-    import api from '../../api/editor'
-    export default {
-        components: {
-            HeaderMain
-        },
-        data() {
-            return {
-                cncTestDetailSingle: null,
-                houseList: [],
-                value: '',
-                isShowDialog: false,
-                pageModel: null,
-                loading: true,
-                currentProject: "所属项目",
-                currentProjectHouseId: "",
-                fullscreenLoading: false,
-            }
-        },
-        created() {
-            this.houseList = [];
-            this.fullscreenLoading = true;
-            api.houseList().then((res) => {
-                if (res.success) {
-                    this.houseList = res.list;
-                }
-            });
-            this.getCncTestcaseList();
-        },
-        filters: {
-            transtion(val) {
-                return String.fromCharCode(64 + parseInt(val));
-            },
-            currentOptionNum(section) {
-                var chnNumChar = ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九"];
-                var chnUnitChar = ["", "十", "百", "千", "万", "亿", "万亿", "亿亿"];
-                var strIns = '', chnStr = '';
-                var unitPos = 0;
-                var zero = true;
-                while (section > 0) {
-                    var v = section % 10;
-                    if (v === 0) {
-                        if (!zero) {
-                            zero = true;
-                            chnStr = chnNumChar[v] + chnStr;
-                        }
-                    } else {
-                        zero = false;
-                        strIns = chnNumChar[v];
-                        strIns += chnUnitChar[unitPos];
-                        chnStr = strIns + chnStr;
-                    }
-                    unitPos++;
-                    section = Math.floor(section / 10);
-                }
-                if (chnStr.indexOf("一十") == 0) {
-                    chnStr = chnStr.substr(1);
-                }
-                return "题目" + chnStr;
-            }
-        },
-        methods: {
-            getCncTestcaseList() {
-                let data = {
-                    "houseId": this.currentProjectHouseId,
-                    "pageNo": 1,
-                    "pageSize": 20,
-                    "uid": ""
-                }
-                api.cncTestcaseList(data).then((res) => {
-                    if (res.success) {
-                        this.pageModel = res.pageModel;
-                    }
-                    this.fullscreenLoading = false;
-                })
-            },
-            cncTestDetail(testcaseId) {
-                let that = this;
-                let data = {
-                    testcaseId
-                }
-                api.cncTestDetail(data).then((res) => {
-                    if (res.success) {
-                        that.cncTestDetailSingle = res.single;
-                    }
-                    that.loading = false;
-                })
-            },
-            showQRDialog(testcaseId) {
-                this.isShowDialog = true;
-                this.loading = true;
-                this.cncTestDetail(testcaseId);
-            },
-            close() {
-                this.isShowDialog = false;
-                this.cncTestDetailSingle = null;
-            },
-            handleCommand(command) {
-                this.houseList.forEach(element => {
-                    if (element.houseId === command) {
-                        this.currentProject = element.houseName;
-                        this.currentProjectHouseId = element.houseId;
-                        this.fullscreenLoading = true;
-                        this.getCncTestcaseList();
-                        return true
-                    } else {
-                        this.currentProjectHouseId = "";
-                        return false
-                    }
-                });
-
-            },
-            useCurrentTest(item) {
-                let data = {
-                    "creator": "admin",
-                    "ownHouseName": item.houseName,
-                    "questionCount": item.questionCount,
-                    "title": item.title,
-                };
-                let that = this;
-                api.createTest(data).then((res) => {
-                    if (res.success) {
-                        that.$router.push({ path: '/h5editor', query: { itemId: res.id } })
-                    }
-                })
-
-            },
-        },
+import HeaderMain from "../../components/HeaderMain";
+import api from "../../api/editor";
+export default {
+  components: {
+    HeaderMain
+  },
+  data() {
+    return {
+      cncTestDetailSingle: null,
+      houseList: [],
+      value: "",
+      isShowDialog: false,
+      pageModel: null,
+      loading: true,
+      currentProject: "所属项目",
+      currentProjectHouseId: "",
+      fullscreenLoading: false
+    };
+  },
+  created() {
+    this.houseList = [];
+    this.fullscreenLoading = true;
+    api.houseList().then(res => {
+      if (res.success) {
+        this.houseList = res.list;
+      }
+    });
+    this.getCncTestcaseList();
+  },
+  filters: {
+    transtion(val) {
+      return String.fromCharCode(64 + parseInt(val));
+    },
+    currentOptionNum(section) {
+      var chnNumChar = [
+        "零",
+        "一",
+        "二",
+        "三",
+        "四",
+        "五",
+        "六",
+        "七",
+        "八",
+        "九"
+      ];
+      var chnUnitChar = ["", "十", "百", "千", "万", "亿", "万亿", "亿亿"];
+      var strIns = "",
+        chnStr = "";
+      var unitPos = 0;
+      var zero = true;
+      while (section > 0) {
+        var v = section % 10;
+        if (v === 0) {
+          if (!zero) {
+            zero = true;
+            chnStr = chnNumChar[v] + chnStr;
+          }
+        } else {
+          zero = false;
+          strIns = chnNumChar[v];
+          strIns += chnUnitChar[unitPos];
+          chnStr = strIns + chnStr;
+        }
+        unitPos++;
+        section = Math.floor(section / 10);
+      }
+      if (chnStr.indexOf("一十") == 0) {
+        chnStr = chnStr.substr(1);
+      }
+      return "题目" + chnStr;
+    }
+  },
+  methods: {
+    getCncTestcaseList() {
+      let data = {
+        houseId: this.currentProjectHouseId,
+        pageNo: 1,
+        pageSize: 20,
+        uid: ""
+      };
+      api.cncTestcaseList(data).then(res => {
+        if (res.success) {
+          this.pageModel = res.pageModel;
+        }
+        this.fullscreenLoading = false;
+      });
+    },
+    cncTestDetail(testcaseId) {
+      let that = this;
+      let data = {
+        testcaseId
+      };
+      api.cncTestDetail(data).then(res => {
+        if (res.success) {
+          that.cncTestDetailSingle = res.single;
+        }
+        that.loading = false;
+      });
+    },
+    showQRDialog(testcaseId) {
+      this.isShowDialog = true;
+      this.loading = true;
+      this.cncTestDetail(testcaseId);
+    },
+    close() {
+      this.isShowDialog = false;
+      this.cncTestDetailSingle = null;
+    },
+    handleCommand(command) {
+      this.houseList.forEach(element => {
+        if (element.houseId === command) {
+          this.currentProject = element.houseName;
+          this.currentProjectHouseId = element.houseId;
+          this.fullscreenLoading = true;
+          this.getCncTestcaseList();
+          return true;
+        } else {
+          this.currentProjectHouseId = "";
+          return false;
+        }
+      });
+    },
+    useCurrentTest(item) {
+      let data = {
+        creator: "admin",
+        ownHouseName: item.houseName,
+        questionCount: item.questionCount,
+        title: item.title,
+        jsonString:
+          '{"pages":[{"elements":[]}],"createDate":1566357290066,"type":"h5","_id":"5d5cb72addd4fa1c047df1d5","title":"标题","description":"描述","canvasHeight":1334,"canvasWidth":750,"bgc":"#B1C096","btnColor":"#5f8a61","cover":"","animatedNameGlobal":"","bodyBackgroundColor":"rgba(255,255,255,0)","animatedNameBackgroundGlobal":"","backgroundAudio":"","loginId":"caodd@elab-plus.com","__v":0}'
+      };
+      let that = this;
+      api.createTest(data).then(res => {
+        if (res.success) {
+          that.$router.push({ path: "/h5editor", query: { itemId: res.id } });
+        }
+      });
     }
+  }
+};
 </script>
 <style lang="scss" scoped>
-    @import './cncTestLists.scss';
+@import "./cncTestLists.scss";
 </style>