pipelineView.vue 10.2 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 6
    :before-close="handleClose"
  >
纪泽龙's avatar
纪泽龙 committed
7
    <el-row>
纪泽龙's avatar
纪泽龙 committed
8 9 10 11
      <el-form
        :rules="rules"
        ref="editForm"
        :model="editForm"
纪泽龙's avatar
纪泽龙 committed
12
        label-width="135px"
纪泽龙's avatar
纪泽龙 committed
13
      >
纪泽龙's avatar
纪泽龙 committed
14 15 16 17 18 19 20 21 22
        <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
23

纪泽龙's avatar
纪泽龙 committed
24 25 26 27 28
        <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
29

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

纪泽龙's avatar
纪泽龙 committed
35
        <el-col :span="11">
纪泽龙's avatar
纪泽龙 committed
36 37 38
          <el-form-item label="管道编号" prop="pipeCode">
            <el-input v-model="editForm.pipeCode"></el-input>
          </el-form-item>
纪泽龙's avatar
纪泽龙 committed
39 40
        </el-col>
        <el-col :span="11">
纪泽龙's avatar
纪泽龙 committed
41
          <el-form-item label="管道长度" prop="pipeLength">
纪泽龙's avatar
纪泽龙 committed
42
            <el-input type="number" min="0" v-model="editForm.pipeLength">
纪泽龙's avatar
纪泽龙 committed
43 44 45 46 47 48 49 50 51
              <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
52 53
          <el-form-item label="管道所在地址" prop="pipeAddr">
            <el-input v-model="editForm.pipeAddr"></el-input>
纪泽龙's avatar
纪泽龙 committed
54 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
          </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
86
              <el-radio label="1">低压</el-radio>
纪泽龙's avatar
纪泽龙 committed
87 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>
        <el-col>
纪泽龙's avatar
纪泽龙 committed
94
          <el-form-item label="上传图片" prop="iconUrl">
纪泽龙's avatar
纪泽龙 committed
95 96 97 98 99 100
            <MyFileUpload
              listType="picture-card"
              @resFun="fileFinshed"
              @remove="listRemove"
              :fileArr="fileArr"
            />
纪泽龙's avatar
纪泽龙 committed
101 102 103 104 105
            <el-input
              v-show="false"
              disabled
              v-model="editForm.iconUrl"
            ></el-input>
纪泽龙's avatar
纪泽龙 committed
106
          </el-form-item>
纪泽龙's avatar
纪泽龙 committed
107 108
          <!-- <el-form-item v-show="false" label="设备图片路径" prop="iconUrl"> -->
          <!-- </el-form-item> -->
纪泽龙's avatar
纪泽龙 committed
109
        </el-col>
纪泽龙's avatar
纪泽龙 committed
110 111 112
        <!-- <el-col>
         
        </el-col> -->
纪泽龙's avatar
纪泽龙 committed
113 114 115 116
        <el-col>
          <el-form-item label="安装日期" prop="installationTime">
            <el-col :span="11">
              <el-date-picker
纪泽龙's avatar
纪泽龙 committed
117
                type="date"
纪泽龙's avatar
纪泽龙 committed
118 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
                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
145
    <span slot="footer" class="dialog-footer">
纪泽龙's avatar
纪泽龙 committed
146 147 148
      <el-button :loading="okLoading" type="primary" @click="ok"
        > </el-button
      >
纪泽龙's avatar
纪泽龙 committed
149
      <el-button @click="dialogVisible = false"> </el-button>
纪泽龙's avatar
纪泽龙 committed
150 151 152 153
    </span>
  </el-dialog>
</template>
<script>
纪泽龙's avatar
纪泽龙 committed
154
import MyFileUpload from "@/components/MyFileUpload";
纪泽龙's avatar
纪泽龙 committed
155
import { addPipe, updatePipe } from "@/api/device/pipe.js";
纪泽龙's avatar
纪泽龙 committed
156 157
import { getString } from "@/utils/gassafety.js";
import moment from "moment";
纪泽龙's avatar
纪泽龙 committed
158 159
export default {
  props: {
纪泽龙's avatar
纪泽龙 committed
160 161 162 163 164 165 166 167 168 169
    lineData: {
      type: Object,
      // default:{}
    },
    // 经纬度路径
    lnglatsArr: {
      type: Array,
    },
    // 管道长度
    pipeLength: { type: Number },
纪泽龙's avatar
纪泽龙 committed
170
    title: { type: String },
纪泽龙's avatar
纪泽龙 committed
171
    //回调函数
纪泽龙's avatar
纪泽龙 committed
172 173 174 175 176 177 178 179 180
    lineOkCallBack: { type: Function },
    gaodeMap: { type: Object },
    target: { type: Object },
    //message: { type: String },
    //duration: { type: Number, default: 2000 }
  },
  components: {
    MyFileUpload,
  },
纪泽龙's avatar
纪泽龙 committed
181

纪泽龙's avatar
纪泽龙 committed
182 183 184
  data() {
    return {
      // isShow: false,
纪泽龙's avatar
纪泽龙 committed
185
      okLoading: false,
纪泽龙's avatar
纪泽龙 committed
186
      fileArr: [],
纪泽龙's avatar
纪泽龙 committed
187
      editForm: {
纪泽龙's avatar
纪泽龙 committed
188
        pipeName: "",
纪泽龙's avatar
纪泽龙 committed
189 190
        pipeType: "1",
        pipePressure: "1",
纪泽龙's avatar
纪泽龙 committed
191
        iconUrl: "",
纪泽龙's avatar
纪泽龙 committed
192
      },
纪泽龙's avatar
纪泽龙 committed
193
      dialogVisible: false,
纪泽龙's avatar
纪泽龙 committed
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
      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" },
        ],
纪泽龙's avatar
纪泽龙 committed
214
        iconUrl: [{ required: true, message: "请上传图片", trigger: "change" }],
纪泽龙's avatar
纪泽龙 committed
215 216 217 218 219 220 221 222 223
        installationTime: [
          {
            // type: "date",
            required: true,
            message: "请选择日期",
            trigger: "change",
          },
        ],
      },
纪泽龙's avatar
纪泽龙 committed
224 225
    };
  },
纪泽龙's avatar
纪泽龙 committed
226 227 228 229 230 231
  computed: {
    myTitle() {
      if (this.editForm.pipeId) {
        return `修改管道信息`;
      } else {
        return `新增管道信息`;
纪泽龙's avatar
纪泽龙 committed
232
      }
纪泽龙's avatar
纪泽龙 committed
233
    },
纪泽龙's avatar
纪泽龙 committed
234
  },
纪泽龙's avatar
纪泽龙 committed
235 236 237 238
  created() {
    console.log("lineData", this.lineData, this.lnglatsArr, this.pipeLength);
    if (this.lineData?.pipeId) {
      this.editForm = { ...this.lineData };
纪泽龙's avatar
纪泽龙 committed
239 240 241 242
    } else {
      // 如果是新建的里面天蝎过东西就存档
      console.log("内部lineDate", this.target.getExtData());
      const { lineData } = this.target.getExtData();
纪泽龙's avatar
纪泽龙 committed
243
      console.log(lineData);
纪泽龙's avatar
纪泽龙 committed
244 245 246
      if (lineData) {
        this.editForm = { ...lineData };
      }
纪泽龙's avatar
纪泽龙 committed
247
    }
纪泽龙's avatar
纪泽龙 committed
248
    this.editForm.coordinates = getString(this.lnglatsArr);
纪泽龙's avatar
纪泽龙 committed
249
    // 如果有图片路径就赋显,如果没有就啥也没有
纪泽龙's avatar
纪泽龙 committed
250 251 252
    this.fileArr = this.editForm?.iconUrl
      ? [{ url: this.editForm.iconUrl }]
      : [];
纪泽龙's avatar
纪泽龙 committed
253 254
  },
  methods: {
纪泽龙's avatar
纪泽龙 committed
255 256
    mouseup() {
      console.log("组件mouseup");
纪泽龙's avatar
纪泽龙 committed
257
    },
纪泽龙's avatar
纪泽龙 committed
258
    ok() {
纪泽龙's avatar
纪泽龙 committed
259 260 261
      this.$refs.editForm.validate((valid) => {
        if (valid) {
          this.okLoading = true;
纪泽龙's avatar
纪泽龙 committed
262
          const data = { ...this.editForm };
纪泽龙's avatar
纪泽龙 committed
263 264 265 266 267 268 269 270 271 272 273 274
          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;
                this.lineOkCallBack.call(this.gaodeMap, this.target, data);
纪泽龙's avatar
纪泽龙 committed
275 276 277 278 279
                if (!this.editForm.pipeId) {
                  this.gaodeMap.newLineObj = null;
                  this.gaodeMap.createNewLine();
                }

纪泽龙's avatar
纪泽龙 committed
280 281 282 283
                this.$message({
                  type: "success",
                  offset: 100,
                  // center:true,
纪泽龙's avatar
纪泽龙 committed
284 285 286
                  message: `${
                    this.editForm.pipeId ? "修改管道成功" : "添加管道成功"
                  }`,
纪泽龙's avatar
纪泽龙 committed
287 288 289 290 291 292
                });
              }
            })
            .catch(() => {
              this.okLoading = false;
            });
纪泽龙's avatar
纪泽龙 committed
293
        }
纪泽龙's avatar
纪泽龙 committed
294
      });
纪泽龙's avatar
纪泽龙 committed
295 296 297 298 299
      // console.log(this.gaodeMap,this.target)
    },
    async requeset(id, data) {
      id ? console.log("修改") : console.log("新增");
      return id ? updatePipe(data) : addPipe(data);
纪泽龙's avatar
纪泽龙 committed
300 301 302 303 304
    },
    show() {
      //this.isShow = true;
      this.dialogVisible = true;
      /*setTimeout(() => {
纪泽龙's avatar
纪泽龙 committed
305 306
          this.hide()
        }, this.duration)*/
纪泽龙's avatar
纪泽龙 committed
307 308 309 310 311 312
    },
    hide() {
      this.isShow = false;
      this.remove();
    },
    handleClose(done) {
纪泽龙's avatar
纪泽龙 committed
313 314 315 316 317 318 319 320 321 322 323
      let options = this.target.getExtData();
      options.lineData = { ...this.editForm };
      this.target.setExtData(options);
      // 把值带出去
      done();

      // this.$confirm("确认关闭?")
      //   .then((_) => {
      //     done();
      //   })
      //   .catch((_) => {});
纪泽龙's avatar
纪泽龙 committed
324 325
    },
    // 图片上传成功
纪泽龙's avatar
纪泽龙 committed
326
    fileFinshed(e) {
纪泽龙's avatar
纪泽龙 committed
327
      this.editForm.iconUrl = e.url;
纪泽龙's avatar
纪泽龙 committed
328
      console.log(this.editForm.iconUrl);
纪泽龙's avatar
纪泽龙 committed
329 330
    },
    // 图片列表移除
纪泽龙's avatar
纪泽龙 committed
331
    listRemove(e) {
纪泽龙's avatar
纪泽龙 committed
332 333
      this.editForm.iconUrl = "";

纪泽龙's avatar
纪泽龙 committed
334 335
      this.fileArr = [];
    },
纪泽龙's avatar
纪泽龙 committed
336 337
  },
};
纪泽龙's avatar
纪泽龙 committed
338 339 340
</script>

<style lang="scss">
纪泽龙's avatar
纪泽龙 committed
341 342 343 344 345 346 347 348 349 350 351 352 353 354
.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
355 356
</style>