cncTestLists.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template src='./cncTestLists.html'>
  2. </template>
  3. <script>
  4. import HeaderMain from "../../components/HeaderMain";
  5. import api from "../../api/editor";
  6. export default {
  7. components: {
  8. HeaderMain
  9. },
  10. data() {
  11. return {
  12. cncTestDetailSingle: null,
  13. houseList: [],
  14. value: "",
  15. isShowDialog: false,
  16. pageModel: null,
  17. cncTestCaseList:[],
  18. loading: true,
  19. currentProject: "所属项目",
  20. currentProjectHouseId: null,
  21. fullscreenLoading: false,
  22. loadingMore:false,
  23. count: 0,
  24. pageNo:1,
  25. };
  26. },
  27. created() {
  28. this.houseList = [];
  29. this.fullscreenLoading = true;
  30. api.houseList().then(res => {
  31. if (res.success) {
  32. this.houseList = res.list;
  33. this.houseList.unshift({houseId: null,houseName:"全部"});
  34. console.log("户型列表",this.houseList);
  35. }
  36. });
  37. this.cncTestCaseList = [];
  38. this.getCncTestcaseList();
  39. },
  40. filters: {
  41. transtion(val) {
  42. return String.fromCharCode(64 + parseInt(val));
  43. },
  44. currentOptionNum(section) {
  45. var chnNumChar = [
  46. "零",
  47. "一",
  48. "二",
  49. "三",
  50. "四",
  51. "五",
  52. "六",
  53. "七",
  54. "八",
  55. "九"
  56. ];
  57. var chnUnitChar = ["", "十", "百", "千", "万", "亿", "万亿", "亿亿"];
  58. var strIns = "",
  59. chnStr = "";
  60. var unitPos = 0;
  61. var zero = true;
  62. while (section > 0) {
  63. var v = section % 10;
  64. if (v === 0) {
  65. if (!zero) {
  66. zero = true;
  67. chnStr = chnNumChar[v] + chnStr;
  68. }
  69. } else {
  70. zero = false;
  71. strIns = chnNumChar[v];
  72. strIns += chnUnitChar[unitPos];
  73. chnStr = strIns + chnStr;
  74. }
  75. unitPos++;
  76. section = Math.floor(section / 10);
  77. }
  78. if (chnStr.indexOf("一十") == 0) {
  79. chnStr = chnStr.substr(1);
  80. }
  81. return "题目" + chnStr;
  82. }
  83. },
  84. computed: {
  85. noMore() {
  86. return this.count === this.cncTestCaseList.length
  87. },
  88. disabled() {
  89. return this.loadingMore || this.noMore
  90. }
  91. },
  92. methods: {
  93. getCncTestcaseList() {
  94. let data = {
  95. houseId: this.currentProjectHouseId,
  96. pageNo: this.pageNo++,
  97. pageSize: 20,
  98. };
  99. this.loadingMore = true;
  100. api.cncTestcaseList(data).then(res => {
  101. if (res.success) {
  102. this.pageModel = res.pageModel;
  103. res.pageModel.resultSet.forEach((item, index) => {
  104. this.cncTestCaseList.push(item);
  105. });
  106. this.count = res.pageModel.rowTotal;
  107. this.loadingMore = false;
  108. }
  109. this.fullscreenLoading = false;
  110. });
  111. },
  112. cncTestDetail(testcaseId) {
  113. let that = this;
  114. let data = {
  115. testcaseId
  116. };
  117. api.cncTestDetail(data).then(res => {
  118. if (res.success) {
  119. that.cncTestDetailSingle = res.single;
  120. }
  121. that.loading = false;
  122. });
  123. },
  124. showQRDialog(testcaseId) {
  125. this.isShowDialog = true;
  126. this.loading = true;
  127. this.cncTestDetail(testcaseId);
  128. },
  129. close() {
  130. this.isShowDialog = false;
  131. this.cncTestDetailSingle = null;
  132. },
  133. handleCommand(command) {
  134. this.currentProjectHouseId = null;
  135. for (let i = 0; i < this.houseList.length; i++) {
  136. let element = this.houseList[i];
  137. if (element.houseId === command) {
  138. this.currentProject = element.houseName;
  139. this.currentProjectHouseId = element.houseId;
  140. this.fullscreenLoading = true;
  141. this.cncTestCaseList = [];
  142. this.pageNo = 1;
  143. this.getCncTestcaseList();
  144. break;
  145. }
  146. }
  147. },
  148. useCurrentTest(item) {
  149. let data = {
  150. creator: "admin",
  151. houseNameList: item.houseNameList,
  152. questionCount: item.questionCount,
  153. title: item.title,
  154. testcaseId: item.testcaseId,
  155. jsonString:
  156. '{"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}'
  157. };
  158. let that = this;
  159. api.createTest(data).then(res => {
  160. if (res.success) {
  161. that.$router.push({path: "/h5editor", query: {itemId: res.id, testcaseId: item.testcaseId}});
  162. }
  163. });
  164. }
  165. },
  166. destroyed() {
  167. this.pageNo = 1;
  168. this.cncTestCaseList=[];
  169. }
  170. };
  171. </script>
  172. <style lang="scss" scoped>
  173. @import "./cncTestLists.scss";
  174. </style>