liuyg
2022-03-22 e03c1cc18b888731130b92ad518a0dee6de2e479
src/views/vr/vr.vue
@@ -1,6 +1,7 @@
<template>
  <basic-container>
    <avue-crud :option="option"
    <avue-crud
      :option="option"
               :table-loading="loading"
               :data="data"
               :page.sync="page"
@@ -17,15 +18,21 @@
               @current-change="currentChange"
               @size-change="sizeChange"
               @refresh-change="refreshChange"
               @on-load="onLoad">
      @on-load="onLoad"
    >
      <template slot="menuLeft">
        <el-button type="danger"
        <el-button
          type="danger"
                   size="small"
                   icon="el-icon-delete"
                   plain
                   v-if="permission.vr_delete"
                   @click="handleDelete">删 除
          @click="handleDelete"
          >删 除
        </el-button>
      </template>
      <template slot-scope="{ type, disabled }" slot="chouseJdWdForm">
        <chousePoint @setData="getMapDatas" ref="chousePointRef"></chousePoint>
      </template>
    </avue-crud>
  </basic-container>
@@ -44,11 +51,11 @@
        page: {
          pageSize: 10,
          currentPage: 1,
          total: 0
        total: 0,
        },
        selectionList: [],
        option: {
          height:'auto',
        height: "auto",
          calcHeight: 30,
          tip: false,
          searchShow: true,
@@ -57,50 +64,90 @@
          index: true,
          viewBtn: true,
          selection: true,
          align: 'center',
          indexLabel: '序号',
        align: "center",
        indexLabel: "序号",
          dialogClickModal: false,
          column: [
            {
              label: "VR名称",
              search: true,
              prop: "vrname",
              rules: [{
            rules: [
              {
                required: true,
                message: "请输入VR名称",
                trigger: "blur"
              }]
                trigger: "blur",
              },
            ],
            },
            {
              label: "VR地址",
              prop: "vrurl",
              rules: [{
            rules: [
              {
                required: true,
                message: "请输入VR地址",
                trigger: "blur"
              }]
                trigger: "blur",
              },
            ],
          },
          {
            label: "选择地点",
            prop: "chouseJdWd",
            hide: true,
            viewDisplay: false,
            span: 24,
            // rules: [
            //   {
            //     required: true,
            //     message: "请选择地点",
            //     trigger: "blur",
            //   },
            // ],
          },
          {
            label: "详细地点",
            prop: "addressName",
            hide: true,
            // overHidden: true,
            editDisplay: false,
            addDisplay: false,
            span: 24,
            // rules: [
            //   {
            //     required: true,
            //     message: "请选择地点",
            //     trigger: "blur",
            //   },
            // ],
            },
            {
              label: "经度",
            disabled: true,
              prop: "jd",
              rules: [{
            rules: [
              {
                required: true,
                message: "请输入经度",
                trigger: "blur"
              }]
                trigger: "blur",
              },
            ],
            },
            {
              label: "纬度",
            disabled: true,
              prop: "wd",
              rules: [{
            rules: [
              {
                required: true,
                message: "请输入纬度",
                trigger: "blur"
              }]
                trigger: "blur",
            },
          ]
            ],
        },
        data: []
        ],
      },
      data: [],
      };
    },
    computed: {
@@ -110,49 +157,66 @@
          addBtn: this.vaildData(this.permission.vr_add, false),
          viewBtn: this.vaildData(this.permission.vr_view, false),
          delBtn: this.vaildData(this.permission.vr_delete, false),
          editBtn: this.vaildData(this.permission.vr_edit, false)
        editBtn: this.vaildData(this.permission.vr_edit, false),
        };
      },
      ids() {
        let ids = [];
        this.selectionList.forEach(ele => {
      this.selectionList.forEach((ele) => {
          ids.push(ele.id);
        });
        return ids.join(",");
      }
    },
    },
    methods: {
      rowSave(row, done, loading) {
        add(row).then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        }, error => {
          loading();
          window.console.log(error);
    getMapDatas(res) {
      this.form["jd"] = res[0];
      this.form["wd"] = res[1];
      this.form["addressName"] = res[2];
    },
    initData() {
      getDeptTree().then((res) => {
        const column = this.findObject(this.option.column, "type");
        column.dicData = res.data.data;
        });
      },
      rowUpdate(row, index, done, loading) {
        update(row).then(() => {
    rowSave(row, done, loading) {
      add(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
            message: "操作成功!",
          });
          done();
        }, error => {
        },
        (error) => {
          loading();
          window.console.log(error);
        }
      );
    },
    rowUpdate(row, index, done, loading) {
      update(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          done();
        },
        (error) => {
          loading();
          console.log(error);
        });
        }
      );
      },
      rowDel(row) {
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        type: "warning",
        })
          .then(() => {
            return remove(row.id);
@@ -161,7 +225,7 @@
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            message: "操作成功!",
            });
          });
      },
@@ -173,7 +237,7 @@
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        type: "warning",
        })
          .then(() => {
            return remove(this.ids);
@@ -182,15 +246,29 @@
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            message: "操作成功!",
            });
            this.$refs.crud.toggleSelection();
          });
      },
      beforeOpen(done, type) {
        if (["edit", "view"].includes(type)) {
          getDetail(this.form.id).then(res => {
        getDetail(this.form.id).then((res) => {
            this.form = res.data.data;
          if (type == "edit") {
            let that = this;
            this.$store.commit("readDom", {
              this: that,
              refName: "chousePointRef",
              fn: (dom) => {
                dom.openMaps({
                  jd: this.form.jd,
                  wd: this.form.wd,
                  name: this.form.addressName,
                });
              },
            });
          }
          });
        }
        done();
@@ -223,17 +301,20 @@
      },
      onLoad(page, params = {}) {
        this.loading = true;
        getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
      getList(
        page.currentPage,
        page.pageSize,
        Object.assign(params, this.query)
      ).then((res) => {
          const data = res.data.data;
          this.page.total = data.total;
          this.data = data.records;
          this.loading = false;
          this.selectionClear();
        });
      }
    }
    },
  },
  };
</script>
<style>
</style>
<style></style>