myHistoryTest.js 4.6 KB

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