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

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

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

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

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