shuishen
2022-07-21 03df59a72de4354fcc731675c53dd2805c2ec8b1
src/views/architecture/architecture.vue
@@ -28,11 +28,15 @@
          plain
          v-if="permission.architecture_delete"
          @click="handleDelete"
          >删 除
        </el-button>
                >删 除</el-button>
      </template>
      <template slot-scope="{ type, disabled }" slot="chouseJdWdForm">
        <chousePoint @setData="getMapDatas" ref="chousePointRef"></chousePoint>
            </template>
            <template slot-scope="{ type, disabled }" slot="xForm">
                <setxy @setData="setXyMapDatas"></setxy>
      </template>
    </avue-crud>
  </basic-container>
@@ -45,8 +49,8 @@
  add,
  update,
  remove,
} from "@/api/architecture/architecture";
import { mapGetters } from "vuex";
} from "@/api/architecture/architecture"
import { mapGetters } from "vuex"
export default {
  data() {
@@ -125,6 +129,20 @@
            searchSpan: 5,
            search: true,
          },
                    {
                        label: "2.5维坐标",
                        prop: "x",
                        hide: true,
                        span: 24,
                        rules: [
                            {
                                required: true,
                                message: "请选择2.5维坐标",
                            },
                        ],
                    },
          {
            label: "选择地点",
            prop: "chouseJdWd",
@@ -139,6 +157,7 @@
            //   },
            // ],
          },
          {
            label: "详细地点",
            prop: "addressName",
@@ -266,7 +285,8 @@
        ],
      },
      data: [],
    };
            selectXYShow: false
        }
  },
  computed: {
    ...mapGetters(["permission"]),
@@ -276,69 +296,70 @@
        viewBtn: this.vaildData(this.permission.architecture_view, false),
        delBtn: this.vaildData(this.permission.architecture_delete, false),
        editBtn: this.vaildData(this.permission.architecture_edit, false),
      };
            }
    },
    ids() {
      let ids = [];
            let ids = []
      this.selectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids.join(",");
                ids.push(ele.id)
            })
            return ids.join(",")
    },
  },
  methods: {
        setXyMapDatas (res) {
            this.form["x"] = res
        },
    getMapDatas(res) {
      this.form["jd"] = res[0];
      this.form["wd"] = res[1];
      this.form["addressName"] = res[2];
            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;
      });
    },
    rowSave(row, done, loading) {
      var d = [];
            var d = []
      //var dk = [];
      for (var k in row.tpurl) {
        d.push(row.tpurl[k].value);
                d.push(row.tpurl[k].value)
      }
      // for (var ks in row.codeurl) {
      //   dk.push(row.codeurl[ks].value);
      // }
      row.tpurl = d.join(",");
            row.tpurl = d.join(",")
      //row.codeurl = dk.join(",");
      add(row).then(
        () => {
          this.onLoad(this.page);
                    this.onLoad(this.page)
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          done();
                    })
                    done()
        },
        (error) => {
          loading();
          window.console.log(error);
                    loading()
                    window.console.log(error)
        }
      );
            )
    },
    rowUpdate(row, index, done, loading) {
      update(row).then(
        () => {
          this.onLoad(this.page);
                    this.onLoad(this.page)
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          done();
                    })
                    done()
        },
        (error) => {
          loading();
          console.log(error);
                    loading()
                    console.log(error)
        }
      );
            )
    },
    rowDel(row) {
      this.$confirm("确定将选择数据删除?", {
@@ -347,20 +368,20 @@
        type: "warning",
      })
        .then(() => {
          return remove(row.id);
                    return remove(row.id)
        })
        .then(() => {
          this.onLoad(this.page);
                    this.onLoad(this.page)
          this.$message({
            type: "success",
            message: "操作成功!",
          });
        });
                    })
                })
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
                this.$message.warning("请选择至少一条数据")
                return
      }
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
@@ -368,23 +389,25 @@
        type: "warning",
      })
        .then(() => {
          return remove(this.ids);
                    return remove(this.ids)
        })
        .then(() => {
          this.onLoad(this.page);
                    this.onLoad(this.page)
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          this.$refs.crud.toggleSelection();
        });
                    })
                    this.$refs.crud.toggleSelection()
                })
    },
    beforeOpen(done, type) {
      if (["edit", "view"].includes(type)) {
        getDetail(this.form.id).then((res) => {
          this.form = res.data.data;
                    this.form = res.data.data
                    this.$store.commit('SET_MAP_X_Y', this.form.x)
          if (type == "edit") {
            let that = this;
                        let that = this
            this.$store.commit("readDom", {
              this: that,
              refName: "chousePointRef",
@@ -393,56 +416,57 @@
                  jd: this.form.jd,
                  wd: this.form.wd,
                  name: this.form.addressName,
                });
                                })
              },
            });
                        })
          }
        });
                })
      }
      done();
            done()
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
            this.query = {}
            this.onLoad(this.page)
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
            this.query = params
            this.page.currentPage = 1
            this.onLoad(this.page, params)
            done()
    },
    selectionChange(list) {
      this.selectionList = list;
            this.selectionList = list
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
            this.selectionList = []
            this.$refs.crud.toggleSelection()
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
            this.page.currentPage = currentPage
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
            this.page.pageSize = pageSize
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
            this.onLoad(this.page, this.query)
    },
    onLoad(page, params = {}) {
      this.loading = true;
            this.loading = true
      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();
      });
                const data = res.data.data
                this.page.total = data.total
                this.data = data.records
                this.loading = false
                this.selectionClear()
            })
    },
  },
};
</script>
<style></style>
<style lang="scss" scoped>
</style>