123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- import HeaderMain from "../../components/HeaderMain";
- import ShareSetting from "../../components/ShareSetting";
- import api from '../../api/test'
- import editorApi from '../../api/editor'
- import timeFormat from '../../util/time'
- export default {
- components: {
- HeaderMain, ShareSetting
- },
- data() {
- return {
- isCopy: false,
- isShareSetting: false,
- cities: [{
- value: 'Beijing',
- label: '北京'
- }, {
- value: 'Shanghai',
- label: '上海'
- }, {
- value: 'Nanjing',
- label: '南京'
- }, {
- value: 'Chengdu',
- label: '成都'
- }, {
- value: 'Shenzhen',
- label: '深圳'
- }, {
- value: 'Guangzhou',
- label: '广州'
- }],
- value: '',
- loading: false,
- houseList: [],
- ownHouseName: "所属项目",
- orderList: [{ orderName: "按创建时间排序", orderType: "created" }, { orderName: "按更新时间排序", orderType: "updated" }],
- currOrderName: "更新时间",
- currOrderType: "",
- shareModel: "",
- pageNo: 1,
- dataList: [],
- total: 0
- }
- },
- computed: {
- noMore() {
- return this.pageNo > this.total;
- },
- disabled() {
- return this.loading || this.noMore;
- }
- },
- watch: {
- isShareSetting: function (val) {
- var mo = function (e) { e.preventDefault(); };
- document.body.style.overflow = val ? 'hidden' : '';
- if (val) {
- document.addEventListener("touchmove", mo, false);
- } else {
- document.removeEventListener("touchmove", mo, false);
- }
- }
- },
- created() {
- this.houseList = [];
- editorApi.houseList().then((res) => {
- if (res.success) {
- this.houseList = res.list;
- }
- });
- this.getTestList();
- },
- methods: {
- dataformat(val) {
- return timeFormat.dateStr(val);
- },
- getTestList() {
- console.log("加载第" + this.pageNo + "页");
- this.loading = true
- let data = {
- "orderType": this.currOrderType,
- "houseNameList": this.ownHouseName == "所属项目" ? '' : this.ownHouseName,
- "pageNo": this.pageNo++,
- "pageSize": 39
- }
- api.testList(data).then((res) => {
- if (res.success) {
- this.total = res.pageModel.total;
- this.dataList.push(...res.pageModel.resultSet);
- console.log("success", this.dataList, res.pageModel);
- } else {
- console.log("error");
- }
- this.loading = false
- })
- },
- projectCommand(command) {
- if (this.houseList.indexOf(command) == -1) {
- console.log("不存在");
- this.ownHouseName = "所属项目";
- } else {
- console.log("存在", command.houseName);
- this.ownHouseName = command.houseName;
- }
- this.getTestList(true);
- },
- orderCommand(command) {
- console.log(command);
- this.currOrderName = command.orderName;
- this.currOrderType = command.orderType;
- this.getTestList(true);
- },
- createTest() {
- this.$router.push({ path: '/cncTestLists' });
- },
- deleteTest(item, index) {
- const h = this.$createElement;
- this.$msgbox({
- title: '删除',
- message: '删除后不可撤回,确定删除此套测题?',
- showCancelButton: true,
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- beforeClose: (action, instance, done) => {
- if (action === 'confirm') {
- instance.confirmButtonLoading = true;
- instance.confirmButtonText = '执行中...';
- let data = {
- "id": item._id,
- "operator": "admin"
- }
- api.deleteTest(data).then((res) => {
- if (res.success) {
- instance.confirmButtonLoading = false;
- this.$message.success("删除成功");
- this.dataList.splice(index, 1);
- done();
- } else {
- this.$message.error("删除失败,请重试");
- done();
- }
- })
- } else {
- done();
- }
- }
- }).then(() => {
- }).catch(() => { });
- },
- copyTest(item) {
- // document.getElementById("historyTools").scrollTo(0, 0);
- // document.getElementById("historyTools").scrollIntoView();
- // console.log("SSSS", document.getElementById("historyTools").scrollHeight)
- let data = {
- "id": item._id,
- "operator": "admin"
- }
- api.copyTest(data).then((res) => {
- if (res.success) {
- this.$message({
- message: '复制成功',
- type: 'success'
- });
- this.dataList.unshift(res.single);
- this.isCopy = true;
- setTimeout(() => {
- this.isCopy = false;
- }, 2000);
- } else {
- this.$message.error('复制失败,请重试');
- }
- })
- },
- editTest(item) {
- this.$router.replace({ path: '/h5editor', query: { itemId: item._id, testcaseId: item.testcaseId } })
- },
- shareTest(item) {
- editorApi.getPageByThemeId(item._id).then((res) => {
- if (res.success) {
- this.shareModel = {
- id: item._id,
- shareTitle: res.single.shareTitle,
- shareContent: res.single.shareContent,
- shareImg: res.single.shareImg,
- shareUrl: res.single.shareUrl
- };
- this.isShareSetting = true;
- } else {
- this.$message.error('数据加载失败,请重试');
- }
- })
- },
- closeShare() {
- this.currItem = "";
- this.isShareSetting = false;
- }
- },
- }
|