workerManView.vue 2.31 KB
Newer Older
纪泽龙's avatar
纪泽龙 committed
1 2 3 4 5 6
<template>
  <el-dialog
    :title="title"
    :visible.sync="dialogVisible"
    :before-close="handleClose"
  >
纪泽龙's avatar
纪泽龙 committed
7 8 9 10 11 12 13 14 15 16 17 18 19
    <el-form>
      <el-form-item label="选择时间段:" prop="">
        <el-date-picker
          v-model="dateValue"
          type="datetimerange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        >
        </el-date-picker>
      </el-form-item>
    </el-form>

纪泽龙's avatar
纪泽龙 committed
20 21 22 23 24 25 26 27 28 29
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button :loading="okLoading" type="primary" @click="ok"
        >确 定
      </el-button>
    </span>
  </el-dialog>
</template>
<script>
import moment from "moment";
纪泽龙's avatar
纪泽龙 committed
30 31
import { getInspectorLocations } from "@/api/inspectorLocation/location";

纪泽龙's avatar
纪泽龙 committed
32 33
export default {
  props: {
纪泽龙's avatar
纪泽龙 committed
34 35 36 37
    userId: {
      type: Number,
    },
    title: {
纪泽龙's avatar
纪泽龙 committed
38 39
      type: String,
    },
纪泽龙's avatar
纪泽龙 committed
40 41 42 43 44 45
    target: {
      type: Object,
    },
    gaodeMap: {
      type: Object,
    },
纪泽龙's avatar
纪泽龙 committed
46 47 48 49 50 51
  },

  components: {},
  data() {
    return {
      dialogVisible: false,
纪泽龙's avatar
纪泽龙 committed
52 53 54
      dateValue: "",
      okLoading: false,
      formData: {},
纪泽龙's avatar
纪泽龙 committed
55 56
    };
  },
纪泽龙's avatar
纪泽龙 committed
57 58 59 60 61

  created() {
    this.formData.userId = this.userId;
  },

纪泽龙's avatar
纪泽龙 committed
62
  methods: {
纪泽龙's avatar
纪泽龙 committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
    ok() {
      this.okLoading = true;

      this.formData.beginTime = moment(this.dateValue[0]).format(
        "YYYY-MM-DD HH:mm:ss"
      );
      this.formData.endTime = moment(this.dateValue[1]).format(
        "YYYY-MM-DD HH:mm:ss"
      );
      getInspectorLocations(this.formData).then((res) => {
        if (res.code == 200) {
          let arr = res.data.map((res) => {
            return [res.longitude, res.latitude];
          });
          arr = arr.sort((a, b) => {
            return -1;
          });
          this.okLoading = false;
          this.$message({
            type: "success",
            // center:true,
            offset: 100,
            message: res.msg,
          });
          this.dialogVisible=false;
          this.gaodeMap.trackBack(this.target, arr);
        }
      });
    },
纪泽龙's avatar
纪泽龙 committed
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
    async requeset(id, data) {
      id ? console.log("修改") : console.log("新增");
      return id ? updatePipe(data) : addPipe(data);
    },
    show() {
      this.dialogVisible = true;
    },
    handleClose(done) {
      done();
    },
  },
};
</script>

<style lang="scss">
</style>