| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- import HeaderMain from "../../components/HeaderMain";
- import ShareSetting from "../../components/ShareSetting";
- import api from '../../api/test'
- import editorApi from '../../api/editor'
- 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: '',
- pageModel: "",
- loading: false,
- houseList: [],
- ownHouseName: "所属项目",
- orderList: [{ orderName: "按创建时间排序", orderType: "created" }, { orderName: "按更新时间排序", orderType: "updated" }],
- currOrderName: "更新时间",
- currOrderType: ""
- }
- },
- computed: {
- noMore() {
- return this.pageModel.count == this.pageModel.total && this.pageModel.total > 1
- },
- disabled() {
- return this.loading || this.pageModel.count == this.pageModel.total
- }
- },
- 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(true);
- },
- methods: {
- load() {
- this.getTestList(false);
- },
- getTestList(isFirst) {
- this.loading = !isFirst
- let data = {
- "orderType": this.currOrderType,
- "ownHouseName": this.ownHouseName == "所属项目" ? '' : this.ownHouseName,
- "pageNo": isFirst ? 0 : this.pageModel.count + 1,
- }
- api.testList(data).then((res) => {
- if (res.success) {
- this.pageModel = res.pageModel;
- console.log("success", this.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) {
- 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,
- }
- api.deleteTest(data).then((res) => {
- if (res.success) {
- instance.confirmButtonLoading = false;
- } else {
- done();
- }
- })
- } else {
- done();
- }
- }
- }).then(() => {
- this.pageModel.resultSet.splice(index, 1);
- this.$message({
- type: 'success',
- message: '删除成功'
- });
- }).catch(() => { });
- },
- copyTest(item) {
- let data = {
- "id": item._id,
- "operator": "测试"
- }
- api.copyTest(data).then((res) => {
- if (res.success) {
- this.$message({
- message: '复制成功',
- type: 'success'
- });
- this.pageModel.resultSet.unshift(res.single);
- this.isCopy = true;
- setTimeout(() => {
- this.isCopy = false;
- }, 2000);
- } else {
- this.$message.error('复制失败,请重试');
- }
- })
- },
- editTest() {
- this.$router.replace({ path: '/h5editor', query: { itemId: 0 } })
- },
- shareTest() {
- this.isShareSetting = true;
- },
- closeShare() {
- this.isShareSetting = false;
- }
- },
- }
|