pipelineView.vue 10.9 KB
Newer Older
纪泽龙's avatar
纪泽龙 committed
1 2
<template>
  <el-dialog
纪泽龙's avatar
纪泽龙 committed
3
    :title="myTitle"
纪泽龙's avatar
纪泽龙 committed
4
    :visible.sync="dialogVisible"
纪泽龙's avatar
纪泽龙 committed
5
    :before-close="handleClose"
6
    ref="dialog"
纪泽龙's avatar
纪泽龙 committed
7
  >
纪泽龙's avatar
纪泽龙 committed
8
    <el-row>
纪泽龙's avatar
纪泽龙 committed
9 10 11 12
      <el-form
        :rules="rules"
        ref="editForm"
        :model="editForm"
纪泽龙's avatar
纪泽龙 committed
13
        label-width="135px"
纪泽龙's avatar
纪泽龙 committed
14
      >
纪泽龙's avatar
纪泽龙 committed
15 16 17 18 19 20 21 22 23
        <el-col>
          <el-form-item v-show="false" label="管道id" prop="pipeId">
            <el-input
              disabled
              class="el-input"
              v-model="editForm.pipeId"
            ></el-input>
          </el-form-item>
        </el-col>
纪泽龙's avatar
纪泽龙 committed
24

纪泽龙's avatar
纪泽龙 committed
25 26 27 28 29
        <el-col>
          <el-form-item v-show="false" label="企业id" prop="enterpriseId">
            <el-input disabled v-model="editForm.enterpriseId"></el-input>
          </el-form-item>
        </el-col>
纪泽龙's avatar
纪泽龙 committed
30

纪泽龙's avatar
纪泽龙 committed
31 32 33 34
        <el-col
          ><el-form-item label="管道名称" prop="pipeName">
            <el-input v-model="editForm.pipeName"></el-input> </el-form-item
        ></el-col>
纪泽龙's avatar
纪泽龙 committed
35

纪泽龙's avatar
纪泽龙 committed
36
        <el-col :span="11">
纪泽龙's avatar
纪泽龙 committed
37 38 39
          <el-form-item label="管道编号" prop="pipeCode">
            <el-input v-model="editForm.pipeCode"></el-input>
          </el-form-item>
纪泽龙's avatar
纪泽龙 committed
40 41
        </el-col>
        <el-col :span="11">
纪泽龙's avatar
纪泽龙 committed
42
          <el-form-item label="管道长度" prop="pipeLength">
纪泽龙's avatar
纪泽龙 committed
43
            <el-input type="number" min="0" v-model="editForm.pipeLength">
纪泽龙's avatar
纪泽龙 committed
44 45 46 47 48 49 50 51 52
              <i
                slot="suffix"
                style="color: #000; font-style: normal; margin-right: 10px"
                ></i
              >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col>
纪泽龙's avatar
纪泽龙 committed
53 54
          <el-form-item label="管道所在地址" prop="pipeAddr">
            <el-input v-model="editForm.pipeAddr"></el-input>
纪泽龙's avatar
纪泽龙 committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item label="经纬度坐标" prop="coordinates">
            <el-card class="box-card">
              <div v-text="lnglatsArr"></div>
              <!-- [<span
              v-for="(item, index) in lnglatsArr"
              :key="index"
              class="text item"
            >

              {{`[${item[0]},${item[1]}],`}}
            </span>] -->
            </el-card>
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item label="管道类型" prop="pipeType">
            <!-- 下拉 -->

            <el-radio-group v-model="editForm.pipeType">
              <el-radio label="1">地埋管线</el-radio>
              <el-radio label="2">地表管线</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item label="管道压力" prop="pipePressure">
            <!-- select -->
            <el-radio-group v-model="editForm.pipePressure">
              <!-- 1低压,2中压,3次高压,4高压 -->
纪泽龙's avatar
纪泽龙 committed
87
              <el-radio label="1">低压</el-radio>
纪泽龙's avatar
纪泽龙 committed
88 89 90 91 92 93
              <el-radio label="2">中压</el-radio>
              <el-radio label="3">次高压</el-radio>
              <el-radio label="4">高压</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
94
       <!-- <el-col>
纪泽龙's avatar
纪泽龙 committed
95
          <el-form-item label="上传图片" prop="iconUrl">
纪泽龙's avatar
纪泽龙 committed
96 97 98 99 100 101
            <MyFileUpload
              listType="picture-card"
              @resFun="fileFinshed"
              @remove="listRemove"
              :fileArr="fileArr"
            />
纪泽龙's avatar
纪泽龙 committed
102 103 104 105 106
            <el-input
              v-show="false"
              disabled
              v-model="editForm.iconUrl"
            ></el-input>
纪泽龙's avatar
纪泽龙 committed
107
          </el-form-item>
108 109 110
          &lt;!&ndash; <el-form-item v-show="false" label="设备图片路径" prop="iconUrl"> &ndash;&gt;
          &lt;!&ndash; </el-form-item> &ndash;&gt;
        </el-col>-->
纪泽龙's avatar
纪泽龙 committed
111
        <!-- <el-col>
112

纪泽龙's avatar
纪泽龙 committed
113
        </el-col> -->
纪泽龙's avatar
纪泽龙 committed
114 115 116 117
        <el-col>
          <el-form-item label="安装日期" prop="installationTime">
            <el-col :span="11">
              <el-date-picker
纪泽龙's avatar
纪泽龙 committed
118
                type="date"
纪泽龙's avatar
纪泽龙 committed
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
                placeholder="选择日期"
                style="width: 100%"
                v-model="editForm.installationTime"
              ></el-date-picker>
            </el-col>
          </el-form-item>
        </el-col>
        <!-- <el-col>
        <el-form-item label="最后巡检日期" prop="inspectionTime">
          <el-col :span="11">
            <el-date-picker
              type="date"
              placeholder="选择日期"
              style="width: 100%"
              v-model="editForm.inspectionTime"
            ></el-date-picker>
          </el-col>
        </el-form-item>
      </el-col> -->
        <el-col>
          <el-form-item label="备注信息" prop="remarks">
            <el-input v-model="editForm.remarks" type="textarea"></el-input>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>

纪泽龙's avatar
纪泽龙 committed
146
    <span slot="footer" class="dialog-footer">
纪泽龙's avatar
纪泽龙 committed
147 148 149
      <el-button :loading="okLoading" type="primary" @click="ok"
        > </el-button
      >
150
      <el-button @click="handleCloseBtn"> </el-button>
纪泽龙's avatar
纪泽龙 committed
151 152 153 154
    </span>
  </el-dialog>
</template>
<script>
纪泽龙's avatar
纪泽龙 committed
155
import MyFileUpload from "@/components/MyFileUpload";
纪泽龙's avatar
纪泽龙 committed
156
import { addPipe, updatePipe } from "@/api/device/pipe.js";
纪泽龙's avatar
纪泽龙 committed
157 158
import { getString } from "@/utils/gassafety.js";
import moment from "moment";
纪泽龙's avatar
纪泽龙 committed
159 160
export default {
  props: {
纪泽龙's avatar
纪泽龙 committed
161 162 163 164 165 166 167 168 169 170
    lineData: {
      type: Object,
      // default:{}
    },
    // 经纬度路径
    lnglatsArr: {
      type: Array,
    },
    // 管道长度
    pipeLength: { type: Number },
纪泽龙's avatar
纪泽龙 committed
171
    title: { type: String },
纪泽龙's avatar
纪泽龙 committed
172
    //回调函数
纪泽龙's avatar
纪泽龙 committed
173 174 175 176 177 178 179 180 181
    lineOkCallBack: { type: Function },
    gaodeMap: { type: Object },
    target: { type: Object },
    //message: { type: String },
    //duration: { type: Number, default: 2000 }
  },
  components: {
    MyFileUpload,
  },
纪泽龙's avatar
纪泽龙 committed
182

纪泽龙's avatar
纪泽龙 committed
183 184 185
  data() {
    return {
      // isShow: false,
纪泽龙's avatar
纪泽龙 committed
186
      okLoading: false,
纪泽龙's avatar
纪泽龙 committed
187
      fileArr: [],
纪泽龙's avatar
纪泽龙 committed
188
      editForm: {
纪泽龙's avatar
纪泽龙 committed
189
        pipeName: "",
纪泽龙's avatar
纪泽龙 committed
190 191
        pipeType: "1",
        pipePressure: "1",
192
        pipeLength:"",
纪泽龙's avatar
纪泽龙 committed
193
        iconUrl: "",
纪泽龙's avatar
纪泽龙 committed
194
      },
纪泽龙's avatar
纪泽龙 committed
195
      dialogVisible: false,
纪泽龙's avatar
纪泽龙 committed
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
      rules: {
        pipeName: [
          { required: true, message: "请输入管道名称", trigger: "blur" },
          // { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
        ],
        pipeCode: [
          { required: true, message: "请输入管道编号", trigger: "blur" },
        ],
        pipeLength: [
          { required: true, message: "请输入管道长度", trigger: "blur" },
        ],
        pipeAddr: [
          { required: true, message: "请输入管道所在地址", trigger: "blur" },
        ],
        pipeType: [
          { required: true, message: "请选择管道类型", trigger: "blur" },
        ],
        pipePressure: [
          { required: true, message: "请选择管道压力", trigger: "blur" },
        ],
216
        /*iconUrl: [{ required: true, message: "请上传图片", trigger: "change" }],*/
纪泽龙's avatar
纪泽龙 committed
217 218 219 220 221 222 223 224 225
        installationTime: [
          {
            // type: "date",
            required: true,
            message: "请选择日期",
            trigger: "change",
          },
        ],
      },
纪泽龙's avatar
纪泽龙 committed
226 227
    };
  },
纪泽龙's avatar
纪泽龙 committed
228 229 230 231 232 233
  computed: {
    myTitle() {
      if (this.editForm.pipeId) {
        return `修改管道信息`;
      } else {
        return `新增管道信息`;
纪泽龙's avatar
纪泽龙 committed
234
      }
纪泽龙's avatar
纪泽龙 committed
235
    },
纪泽龙's avatar
纪泽龙 committed
236
  },
纪泽龙's avatar
纪泽龙 committed
237 238
  created() {
    console.log("lineData", this.lineData, this.lnglatsArr, this.pipeLength);
239
    this.editForm.pipeLength=parseInt(this.pipeLength);
纪泽龙's avatar
纪泽龙 committed
240 241
    if (this.lineData?.pipeId) {
      this.editForm = { ...this.lineData };
纪泽龙's avatar
纪泽龙 committed
242 243 244 245
    } else {
      // 如果是新建的里面天蝎过东西就存档
      console.log("内部lineDate", this.target.getExtData());
      const { lineData } = this.target.getExtData();
纪泽龙's avatar
纪泽龙 committed
246
      console.log(lineData);
纪泽龙's avatar
纪泽龙 committed
247 248 249
      if (lineData) {
        this.editForm = { ...lineData };
      }
纪泽龙's avatar
纪泽龙 committed
250
    }
纪泽龙's avatar
纪泽龙 committed
251
    this.editForm.coordinates = getString(this.lnglatsArr);
纪泽龙's avatar
纪泽龙 committed
252
    // 如果有图片路径就赋显,如果没有就啥也没有
纪泽龙's avatar
纪泽龙 committed
253 254 255
    this.fileArr = this.editForm?.iconUrl
      ? [{ url: this.editForm.iconUrl }]
      : [];
纪泽龙's avatar
纪泽龙 committed
256 257
  },
  methods: {
纪泽龙's avatar
纪泽龙 committed
258 259
    mouseup() {
      console.log("组件mouseup");
纪泽龙's avatar
纪泽龙 committed
260
    },
纪泽龙's avatar
纪泽龙 committed
261
    ok() {
纪泽龙's avatar
纪泽龙 committed
262 263 264
      this.$refs.editForm.validate((valid) => {
        if (valid) {
          this.okLoading = true;
纪泽龙's avatar
纪泽龙 committed
265
          const data = { ...this.editForm };
纪泽龙's avatar
纪泽龙 committed
266 267 268 269 270 271 272 273 274 275 276
          data.installationTime = moment(this.editForm.installationTime).format(
            "YYYY-MM-DD HH:mm:ss"
          );
          console.log("data", data);
          console.log(this.editForm.pipeId);
          this.requeset(this.editForm.pipeId, data)
            .then((res) => {
              // 改变this指向,传回去target ,传回去data
              if (res.code == 200) {
                this.dialogVisible = false;
                data.pipeId = data.pipeId ? data.pipeId : res.data;
277 278 279 280 281 282 283 284 285 286 287 288 289
                this.lineOkCallBack.call(
                  this.gaodeMap,
                  this.target,
                  data,
                  () => {
                    const arr = this.gaodeMap.polyLines.map((item) => {
                      return item.getExtData().lineData;
                    });
                    console.log("arr===================", arr);
                    this.gaodeMap.view.pipeClassify(arr);
                    this.gaodeMap.view.pipeList();
                  }
                );
纪泽龙's avatar
纪泽龙 committed
290 291 292 293 294
                if (!this.editForm.pipeId) {
                  this.gaodeMap.newLineObj = null;
                  this.gaodeMap.createNewLine();
                }

纪泽龙's avatar
纪泽龙 committed
295 296 297 298
                this.$message({
                  type: "success",
                  offset: 100,
                  // center:true,
纪泽龙's avatar
纪泽龙 committed
299 300 301
                  message: `${
                    this.editForm.pipeId ? "修改管道成功" : "添加管道成功"
                  }`,
纪泽龙's avatar
纪泽龙 committed
302 303 304 305 306 307
                });
              }
            })
            .catch(() => {
              this.okLoading = false;
            });
纪泽龙's avatar
纪泽龙 committed
308
        }
纪泽龙's avatar
纪泽龙 committed
309
      });
纪泽龙's avatar
纪泽龙 committed
310 311 312 313 314
      // console.log(this.gaodeMap,this.target)
    },
    async requeset(id, data) {
      id ? console.log("修改") : console.log("新增");
      return id ? updatePipe(data) : addPipe(data);
纪泽龙's avatar
纪泽龙 committed
315 316 317 318 319
    },
    show() {
      //this.isShow = true;
      this.dialogVisible = true;
      /*setTimeout(() => {
纪泽龙's avatar
纪泽龙 committed
320 321
          this.hide()
        }, this.duration)*/
纪泽龙's avatar
纪泽龙 committed
322 323 324 325 326 327
    },
    hide() {
      this.isShow = false;
      this.remove();
    },
    handleClose(done) {
纪泽龙's avatar
纪泽龙 committed
328 329 330 331
      let options = this.target.getExtData();
      options.lineData = { ...this.editForm };
      this.target.setExtData(options);
      // 把值带出去
332 333 334
      if (done) {
        done();
      }
纪泽龙's avatar
纪泽龙 committed
335 336 337 338 339 340

      // this.$confirm("确认关闭?")
      //   .then((_) => {
      //     done();
      //   })
      //   .catch((_) => {});
纪泽龙's avatar
纪泽龙 committed
341
    },
342 343 344 345
    handleCloseBtn() {
      this.handleClose();
      this.dialogVisible = false;
    },
纪泽龙's avatar
纪泽龙 committed
346
    // 图片上传成功
纪泽龙's avatar
纪泽龙 committed
347
    fileFinshed(e) {
纪泽龙's avatar
纪泽龙 committed
348
      this.editForm.iconUrl = e.url;
纪泽龙's avatar
纪泽龙 committed
349
      console.log(this.editForm.iconUrl);
纪泽龙's avatar
纪泽龙 committed
350 351
    },
    // 图片列表移除
纪泽龙's avatar
纪泽龙 committed
352
    listRemove(e) {
纪泽龙's avatar
纪泽龙 committed
353
      this.editForm.iconUrl = "";
纪泽龙's avatar
纪泽龙 committed
354 355
      this.fileArr = [];
    },
纪泽龙's avatar
纪泽龙 committed
356 357
  },
};
纪泽龙's avatar
纪泽龙 committed
358 359 360
</script>

<style lang="scss">
纪泽龙's avatar
纪泽龙 committed
361 362 363 364 365 366 367 368 369 370 371 372 373 374
.notice {
  background: white;
  position: fixed;
  top: 102px;
  right: 0;
  left: 0;
  margin: auto;
  width: 80%;
  height: 80%;
  border: solid 1px;
}
.el-input {
  // width: 200px;
}
纪泽龙's avatar
纪泽龙 committed
375 376
</style>