myHistoryTest.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. import HeaderMain from "../../components/HeaderMain";
  2. import ShareSetting from "../../components/ShareSetting";
  3. import api from '../../api/test'
  4. import editorApi from '../../api/editor'
  5. import timeFormat from '../../util/time'
  6. export default {
  7. components: {
  8. HeaderMain, ShareSetting
  9. },
  10. data() {
  11. return {
  12. isCopy: false,
  13. isShareSetting: false,
  14. cities: [{
  15. value: 'Beijing',
  16. label: '北京'
  17. }, {
  18. value: 'Shanghai',
  19. label: '上海'
  20. }, {
  21. value: 'Nanjing',
  22. label: '南京'
  23. }, {
  24. value: 'Chengdu',
  25. label: '成都'
  26. }, {
  27. value: 'Shenzhen',
  28. label: '深圳'
  29. }, {
  30. value: 'Guangzhou',
  31. label: '广州'
  32. }],
  33. value: '',
  34. loading: false,
  35. houseList: [],
  36. ownHouseName: "所属项目",
  37. orderList: [{ orderName: "按创建时间排序", orderType: "created" }, { orderName: "按更新时间排序", orderType: "updated" }],
  38. currOrderName: "更新时间",
  39. currOrderType: "",
  40. shareModel: "",
  41. pageNo: 1,
  42. dataList: [],
  43. total: 0
  44. }
  45. },
  46. computed: {
  47. noMore() {
  48. return this.pageNo > this.total;
  49. },
  50. disabled() {
  51. return this.loading || this.noMore;
  52. }
  53. },
  54. watch: {
  55. isShareSetting: function (val) {
  56. var mo = function (e) { e.preventDefault(); };
  57. document.body.style.overflow = val ? 'hidden' : '';
  58. if (val) {
  59. document.addEventListener("touchmove", mo, false);
  60. } else {
  61. document.removeEventListener("touchmove", mo, false);
  62. }
  63. }
  64. },
  65. created() {
  66. this.houseList = [];
  67. editorApi.houseList().then((res) => {
  68. if (res.success) {
  69. this.houseList = res.list;
  70. }
  71. });
  72. this.getTestList();
  73. },
  74. methods: {
  75. dataformat(val) {
  76. return timeFormat.dateStr(val);
  77. },
  78. getTestList() {
  79. console.log("加载第" + this.pageNo + "页");
  80. this.loading = true
  81. let data = {
  82. "orderType": this.currOrderType,
  83. "houseNameList": this.ownHouseName == "所属项目" ? '' : this.ownHouseName,
  84. "pageNo": this.pageNo++,
  85. "pageSize": 39
  86. }
  87. api.testList(data).then((res) => {
  88. if (res.success) {
  89. this.total = res.pageModel.total;
  90. this.dataList.push(...res.pageModel.resultSet);
  91. console.log("success", this.dataList, res.pageModel);
  92. } else {
  93. console.log("error");
  94. }
  95. this.loading = false
  96. })
  97. },
  98. projectCommand(command) {
  99. if (this.houseList.indexOf(command) == -1) {
  100. console.log("不存在");
  101. this.ownHouseName = "所属项目";
  102. } else {
  103. console.log("存在", command.houseName);
  104. this.ownHouseName = command.houseName;
  105. }
  106. this.getTestList(true);
  107. },
  108. orderCommand(command) {
  109. console.log(command);
  110. this.currOrderName = command.orderName;
  111. this.currOrderType = command.orderType;
  112. this.getTestList(true);
  113. },
  114. createTest() {
  115. this.$router.push({ path: '/cncTestLists' });
  116. },
  117. deleteTest(item, index) {
  118. const h = this.$createElement;
  119. this.$msgbox({
  120. title: '删除',
  121. message: '删除后不可撤回,确定删除此套测题?',
  122. showCancelButton: true,
  123. confirmButtonText: '确定',
  124. cancelButtonText: '取消',
  125. beforeClose: (action, instance, done) => {
  126. if (action === 'confirm') {
  127. instance.confirmButtonLoading = true;
  128. instance.confirmButtonText = '执行中...';
  129. let data = {
  130. "id": item._id,
  131. "operator": "admin"
  132. }
  133. api.deleteTest(data).then((res) => {
  134. if (res.success) {
  135. instance.confirmButtonLoading = false;
  136. this.$message.success("删除成功");
  137. this.dataList.splice(index, 1);
  138. done();
  139. } else {
  140. this.$message.error("删除失败,请重试");
  141. done();
  142. }
  143. })
  144. } else {
  145. done();
  146. }
  147. }
  148. }).then(() => {
  149. }).catch(() => { });
  150. },
  151. copyTest(item) {
  152. // document.getElementById("historyTools").scrollTo(0, 0);
  153. // document.getElementById("historyTools").scrollIntoView();
  154. // console.log("SSSS", document.getElementById("historyTools").scrollHeight)
  155. let data = {
  156. "id": item._id,
  157. "operator": "admin"
  158. }
  159. api.copyTest(data).then((res) => {
  160. if (res.success) {
  161. this.$message({
  162. message: '复制成功',
  163. type: 'success'
  164. });
  165. this.dataList.unshift(res.single);
  166. this.isCopy = true;
  167. setTimeout(() => {
  168. this.isCopy = false;
  169. }, 2000);
  170. } else {
  171. this.$message.error('复制失败,请重试');
  172. }
  173. })
  174. },
  175. editTest(item) {
  176. this.$router.replace({ path: '/h5editor', query: { itemId: item._id, testcaseId: item.testcaseId } })
  177. },
  178. shareTest(item) {
  179. editorApi.getPageByThemeId(item._id).then((res) => {
  180. if (res.success) {
  181. this.shareModel = {
  182. id: item._id,
  183. shareTitle: res.single.shareTitle,
  184. shareContent: res.single.shareContent,
  185. shareImg: res.single.shareImg,
  186. shareUrl: res.single.shareUrl
  187. };
  188. this.isShareSetting = true;
  189. } else {
  190. this.$message.error('数据加载失败,请重试');
  191. }
  192. })
  193. },
  194. closeShare() {
  195. this.currItem = "";
  196. this.isShareSetting = false;
  197. }
  198. },
  199. }