智慧社区后台管理页面
liuyg
2022-01-13 0a2d6cae514918e9c1d1422806c366d7e5723923
src/views/hd/hd.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,28 @@
               @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.hd_delete"
                   @click="handleDelete">删 除
          @click="handleDelete"
          >删 除
        </el-button>
      </template>
      <template slot-scope="{ type, disabled }" slot="lineForm">
        <!-- <div class="mapClassMain" style="width: 100%; height: 400px">
          <Map ref="modalForm" />
        </div> -->
        <getMapData
          ref="getMapData"
          id="getMapData"
          @setMapData="setMapData"
        ></getMapData>
      </template>
    </avue-crud>
  </basic-container>
@@ -34,8 +48,14 @@
<script>
  import {getList, getDetail, add, update, remove} from "@/api/hd/hd";
  import {mapGetters} from "vuex";
// import Map from "@/components/map/main.vue";
import getMapData from "./getMapData.vue";
  export default {
  components: {
    // Map,
    getMapData,
  },
    data() {
      return {
        form: {},
@@ -44,11 +64,11 @@
        page: {
          pageSize: 10,
          currentPage: 1,
          total: 0
        total: 0,
        },
        selectionList: [],
        option: {
          height:'auto',
        height: "auto",
          calcHeight: 30,
          tip: false,
          searchShow: true,
@@ -56,19 +76,22 @@
          border: true,
          index: true,
          viewBtn: true,
          align: 'center',
        align: "center",
          selection: true,
          indexLabel: '序号',
        indexLabel: "序号",
          dialogClickModal: false,
          column: [
            {
              label: "活动名称",
              prop: "hdname",
              rules: [{
            editDisabled: true,
            rules: [
              {
                required: true,
                message: "请输入活动名称",
                trigger: "blur"
              }],
                trigger: "blur",
              },
            ],
            },
            {
              label: "活动地点",
@@ -82,11 +105,11 @@
              prop: "time",
              type: "datetime",
              span:8,
              format:'yyyy-MM-dd hh:mm:ss',
              valueFormat:'yyyy-MM-dd hh:mm:ss',
            format: "yyyy-MM-dd hh:mm:ss",
            valueFormat: "yyyy-MM-dd hh:mm:ss",
              mock:{
                type:'datetime',
                format:'yyyy-MM-dd hh:mm:ss',
              type: "datetime",
              format: "yyyy-MM-dd hh:mm:ss",
                now:true,
              },
            },
@@ -96,40 +119,61 @@
              // dataType: 'string',
              type: "upload",
              propsHttp: {
                res: 'data',
                url: 'link',
              res: "data",
              url: "link",
              },
              span: 10,
            span: 24,
              listType: "picture-card",
              tip: "只能上传jpg/png文件,且不超过500kb",
              action: "/api/blade-resource/oss/endpoint/put-file",
            },
            {
            label: "选择路径和标点",
            labelWidth: "0",
            prop: "line",
            className: "mapClass",
            hide: true,
            display: true,
            span: 24,
            formslot: true,
            addDisplay: true,
          },
          {
              label: "介绍",
              prop: "context",
              component: 'AvueUeditor',
            component: "AvueUeditor",
              options: {
                action: '/api/blade-resource/oss/endpoint/put-file',
              action: "/api/blade-resource/oss/endpoint/put-file",
                props: {
                  res: "data",
                  url: "link",
                }
              },
              },
              minRows: 5,
              span: 24,
            },
            {
              label: "路线",
              hide:true,
              prop: "lx",
              editDisply:false,
              addDisplay: false,
          // {
          //   label: "路线",
          //   hide: true,
          //   prop: "lx",
          //   editDisply: false,
          //   addDisplay: false,
          // },
        ],
            },
          ]
        },
        data: []
      data: [],
      LineData: [],
      PointData: [],
      };
    },
  // watch: {
  // rotesData() {
  //   console.log(this.rotesData);
  // },
  // pointData() {
  //   console.log(this.pointData);
  // },
  // },
    computed: {
      ...mapGetters(["permission"]),
      permissionList() {
@@ -137,54 +181,82 @@
          addBtn: this.vaildData(this.permission.hd_add, false),
          viewBtn: this.vaildData(this.permission.hd_view, false),
          delBtn: this.vaildData(this.permission.hd_delete, false),
          editBtn: this.vaildData(this.permission.hd_edit, false)
        editBtn: this.vaildData(this.permission.hd_edit, false),
        };
      },
      ids() {
        let ids = [];
        this.selectionList.forEach(ele => {
      this.selectionList.forEach((ele) => {
          ids.push(ele.id);
        });
        return ids.join(",");
      }
    },
    },
    methods: {
    setMapData(val) {
      this.LineData = val[0];
      this.PointData = val[1];
    },
      rowSave(row, done, loading) {
        var d = [];
        for (var k in row.tpurl) {
          d.push(row.tpurl[k].value);
        }
        row.tpurl = d.join(",");
        add(row).then(() => {
      let outMapData = this.$refs.getMapData.myRulesUse();
      if (!outMapData) {
        loading();
        return;
      }
      row["lxname"] = outMapData[0][0];
      row["lx"] = outMapData[0][1];
      row["addressname"] = outMapData[1][0];
      row["address"] = outMapData[1][1];
      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(() => {
      let outMapData = this.$refs.getMapData.myRulesUse();
      if (!outMapData) {
        loading();
        return;
      }
      row["lxname"] = outMapData[0][0];
      row["lx"] = outMapData[0][1];
      row["addressname"] = outMapData[1][0];
      row["address"] = outMapData[1][1];
      update(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
            message: "操作成功!",
          });
          done();
        }, error => {
        },
        (error) => {
          loading();
          console.log(error);
        });
        }
      );
      },
      rowDel(row) {
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        type: "warning",
        })
          .then(() => {
            return remove(row.id);
@@ -193,7 +265,7 @@
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            message: "操作成功!",
            });
          });
      },
@@ -205,7 +277,7 @@
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        type: "warning",
        })
          .then(() => {
            return remove(this.ids);
@@ -214,17 +286,55 @@
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            message: "操作成功!",
            });
            this.$refs.crud.toggleSelection();
          });
      },
    checkDom(name, fn) {
      //  声明定时器
      let that = this;
      var timer = null;
      //  检查dom是否执行完成
      function checkDom() {
        let dom = that.$refs[name];
        if (dom) {
          //  执行dom加载完成后的操作
          //  清除定时器
          if (!timer) {
            clearTimeout(timer);
          }
          if (fn) {
            //回调函数
            fn(dom);
            return;
          } else {
            return dom;
          }
        } else {
          //  自我调用
          timer = setTimeout(checkDom, 100);
        }
      }
      //  首次执行
      checkDom();
    },
      beforeOpen(done, type) {
      let that = this;
        if (["edit", "view"].includes(type)) {
          getDetail(this.form.id).then(res => {
        getDetail(this.form.id).then((res) => {
            this.form = res.data.data;
          });
        //控制按钮不可编辑
        this.checkDom("getMapData", (dom) => {
          // dom.init(val, num, value);
          dom[type + "Init"]([
            [that.form.lxname, that.form.lx],
            [that.form.addressname, that.form.address],
          ]);
        });
        }
        done();
      },
      searchReset() {
@@ -255,17 +365,38 @@
      },
      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>
.mapClass {
  margin-left: 88px;
}
.mapClass div label {
  display: none;
}
.mapClassMain {
  /* padding-left: 25px !important; */
}
#getMapData {
  width: calc(100% + 90px);
  position: relative;
  left: -90px;
  height: auto;
}
</style>