monitorEquip.vue 8.41 KB
Newer Older
neogcg's avatar
neogcg committed
1 2 3 4 5 6 7 8 9
<template>
  <div>
    <el-form
      ref="monitorForm"
      :model="monitorForm"
      :rules="rules"
      label-width="200px"
      class="form"
    >
neogcg's avatar
neogcg committed
10
      <el-form-item label="所在铁路线:" prop="wayId">
neogcg's avatar
neogcg committed
11 12 13 14 15
        <el-select
          v-model="monitorForm.wayId"
          placeholder="请选择铁路线"
          @change="changerailWay()"
        >
neogcg's avatar
neogcg committed
16
          <el-option
neogcg's avatar
neogcg committed
17 18 19 20 21 22 23 24
            v-for="item in railWaySelect"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="所在站点:" prop="siteId">
neogcg's avatar
neogcg committed
25 26 27 28 29
        <el-select
          v-model="monitorForm.siteId"
          placeholder="请选择站点"
          @change="changesite()"
        >
neogcg's avatar
neogcg committed
30 31 32 33 34 35 36 37
          <el-option
            v-for="item in stationSelect2"
            :key="item.id"
            :label="item.siteName"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
neogcg's avatar
neogcg committed
38
      <el-form-item label="所在FSU:" prop="fsuId">
neogcg's avatar
neogcg committed
39 40 41 42 43 44
        <el-select v-model="monitorForm.fsuId" placeholder="请选择FSU">
          <el-option
            v-for="item in fsuSelect2"
            :key="item.id"
            :label="item.equipName"
            :value="item.id"
neogcg's avatar
neogcg committed
45 46 47 48 49 50 51 52
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="设备身份编号:" prop="equipCode">
        <el-input
          v-model="monitorForm.equipCode"
          placeholder="请输入设备身份编号"
        />
neogcg's avatar
neogcg committed
53
      </el-form-item>
neogcg's avatar
neogcg committed
54 55 56 57 58
      <el-form-item label="设备名称:" prop="equipName">
        <el-input
          v-model="monitorForm.equipName"
          placeholder="请输入设备名称"
        />
neogcg's avatar
neogcg committed
59 60 61 62 63 64
      </el-form-item>
      <el-form-item label="设备厂商:" prop="equipFactory">
        <el-input
          v-model="monitorForm.equipFactory"
          placeholder="请输入设备厂商"
        />
neogcg's avatar
neogcg committed
65
      </el-form-item>
neogcg's avatar
neogcg committed
66
      <el-form-item label="IP:" prop="ip">
yanzhongrong's avatar
yanzhongrong committed
67
        <el-input v-model="monitorForm.ip" placeholder="请输入IP" />
neogcg's avatar
neogcg committed
68
      </el-form-item>
dupengyu's avatar
dupengyu committed
69 70 71
      <el-form-item label="端口:" prop="port">
        <el-input v-model="monitorForm.port" placeholder="请输入端口号" />
      </el-form-item>
neogcg's avatar
neogcg committed
72 73
      <el-form-item label="设备类别:" prop="equipType">
        <el-select v-model="monitorForm.equipType" placeholder="请输入设备类别">
neogcg's avatar
neogcg committed
74 75
          <el-option
            v-for="item in equipTypeSelect"
dupengyu's avatar
dupengyu committed
76 77 78
            :key="item.dictValue"
            :label="item.dictLabel"
            :value="item.dictValue"
neogcg's avatar
neogcg committed
79 80
          ></el-option>
        </el-select>
neogcg's avatar
neogcg committed
81 82
      </el-form-item>
      <el-form-item label="设备型号:" prop="equipMode">
neogcg's avatar
neogcg committed
83
        <el-select v-model="monitorForm.equipMode" placeholder="请输入设备型号">
neogcg's avatar
neogcg committed
84 85
          <el-option
            v-for="item in equipModeSelect"
dupengyu's avatar
dupengyu committed
86 87 88
            :key="item.dictValue"
            :label="item.dictLabel"
            :value="item.dictValue"
neogcg's avatar
neogcg committed
89 90
          ></el-option>
        </el-select>
neogcg's avatar
neogcg committed
91 92 93 94 95 96 97
      </el-form-item>
      <el-form-item label="设备生产序列号:" prop="equipSerialNumber">
        <el-input
          v-model="monitorForm.equipSerialNumber"
          placeholder="请输入设备生产序列号"
        />
      </el-form-item>
neogcg's avatar
neogcg committed
98
      <el-form-item label="设备所在铁路公里标:" prop="kmSign">
neogcg's avatar
neogcg committed
99
        <el-input
neogcg's avatar
neogcg committed
100 101
          v-model="monitorForm.kmSign"
          placeholder="请输入设备所在铁路公里标"
neogcg's avatar
neogcg committed
102 103 104
        />
      </el-form-item>
    </el-form>
dupengyu's avatar
dupengyu committed
105
    <div class="btn" v-if="isEdit == 1">
yanzhongrong's avatar
yanzhongrong committed
106 107 108 109
      <el-button type="primary" @click="cancel">取 消</el-button>
      <el-button type="primary" @click="confirm">确 定</el-button>
    </div>
    <div class="btn" v-else>
neogcg's avatar
neogcg committed
110 111 112 113 114 115
      <el-button type="primary" @click="reset">重置</el-button>
      <el-button type="primary" @click="submit">确认提交</el-button>
    </div>
  </div>
</template>
<script>
neogcg's avatar
neogcg committed
116 117 118 119 120 121
import {
  railWaylist,
  monitorEquipsave,
  selectMonitorItem,
  selectForSite,
  selectForFsu,
dupengyu's avatar
dupengyu committed
122
  updateMonitorEquipConf,
neogcg's avatar
neogcg committed
123
} from "../../api";
neogcg's avatar
neogcg committed
124
import { successAlert, warningAlert } from "@/utils/alert";
yanzhongrong's avatar
yanzhongrong committed
125

neogcg's avatar
neogcg committed
126
export default {
yanzhongrong's avatar
yanzhongrong committed
127 128 129
  props: {
    isEdit: {
      type: Number,
dupengyu's avatar
dupengyu committed
130
      default: 0,
yanzhongrong's avatar
yanzhongrong committed
131 132 133
    },
    curInfo: {
      type: Object,
dupengyu's avatar
dupengyu committed
134 135
      default: () => {},
    },
yanzhongrong's avatar
yanzhongrong committed
136 137 138 139 140
  },
  watch: {
    curInfo: {
      immediate: true,
      handler(newV) {
yanzhongrong's avatar
yanzhongrong committed
141
        this.monitorForm = formInit(newV);
dupengyu's avatar
dupengyu committed
142 143
      },
    },
yanzhongrong's avatar
yanzhongrong committed
144
  },
neogcg's avatar
neogcg committed
145 146
  data() {
    return {
neogcg's avatar
neogcg committed
147
      railWaySelect: [],
neogcg's avatar
neogcg committed
148 149
      stationSelect2: [],
      fsuSelect2: [],
neogcg's avatar
neogcg committed
150 151
      equipTypeSelect: [],
      equipModeSelect: [],
neogcg's avatar
neogcg committed
152 153 154 155
      monitorForm: formInit(),
      params: {
        current: 1,
        size: 10,
neogcg's avatar
neogcg committed
156 157
      },
      rules: {
neogcg's avatar
neogcg committed
158
        wayId: [{ required: true, message: "请选择铁路线", trigger: "blur" }],
neogcg's avatar
neogcg committed
159 160
        siteId: [{ required: true, message: "请选择站点", trigger: "blur" }],
        fsuId: [{ required: true, message: "请选择FSU", trigger: "blur" }],
neogcg's avatar
neogcg committed
161 162 163 164 165
        equipCode: [
          { required: true, message: "请输入设备身份编号", trigger: "blur" },
        ],
        equipFactory: [
          { required: true, message: "请输入设备厂商", trigger: "blur" },
neogcg's avatar
neogcg committed
166
        ],
dupengyu's avatar
dupengyu committed
167 168 169 170 171 172 173 174 175 176
        ip: [
          {
            required: true,
            pattern:
              /^(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|[1-9])\.((1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.){2}(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)$/,
            message: "请输入正确的IP地址",
            trigger: "blur",
          },
        ],
        port: [{ required: true, message: "请选择端口号", trigger: "blur" }],
neogcg's avatar
neogcg committed
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
        equipMode: [
          { required: true, message: "请选择设备型号", trigger: "blur" },
        ],
        equipName: [
          { required: true, message: "请输入设备名", trigger: "blur" },
        ],
        equipSerialNumber: [
          { required: true, message: "请输入设备生产序列号", trigger: "blur" },
        ],
        equipType: [
          { required: true, message: "请输入设备类别", trigger: "blur" },
        ],
        installDate: [
          { required: true, message: "请输入安装日期", trigger: "blur" },
        ],
        kmSign: [
          {
            required: true,
            message: "请输入设备所在铁路公里标",
            trigger: "blur",
          },
        ],
        repairDate: [
          { required: true, message: "请输入维护日期", trigger: "blur" },
        ],
      },
    };
  },
yanzhongrong's avatar
yanzhongrong committed
205 206 207
  mounted() {
    this.getAllWay();
  },
neogcg's avatar
neogcg committed
208
  methods: {
yanzhongrong's avatar
yanzhongrong committed
209 210 211
    // 编辑的确认
    confirm() {
      let params = {
dupengyu's avatar
dupengyu committed
212 213 214 215 216 217
        ...this.monitorForm,
      };
      delete params.creationTime;
      updateMonitorEquipConf(params).then((res) => {
        if (res.code == 200) {
          this.$message.success("保存成功!");
yanzhongrong's avatar
yanzhongrong committed
218
        }
yanzhongrong's avatar
yanzhongrong committed
219
        this.cancel(true);
dupengyu's avatar
dupengyu committed
220
      });
yanzhongrong's avatar
yanzhongrong committed
221 222
    },
    cancel(refersh) {
dupengyu's avatar
dupengyu committed
223
      this.$emit("update", refersh);
yanzhongrong's avatar
yanzhongrong committed
224
      this.reset();
yanzhongrong's avatar
yanzhongrong committed
225
    },
neogcg's avatar
neogcg committed
226
    changerailWay() {
neogcg's avatar
neogcg committed
227 228 229
      selectForSite({ wayId: this.monitorForm.wayId }).then((res) => {
        this.stationSelect2 = res;
      });
neogcg's avatar
neogcg committed
230
    },
neogcg's avatar
neogcg committed
231
    changesite() {
neogcg's avatar
neogcg committed
232 233 234
      selectForFsu({ siteId: this.monitorForm.siteId }).then((res) => {
        this.fsuSelect2 = res;
      });
neogcg's avatar
neogcg committed
235
    },
neogcg's avatar
neogcg committed
236 237 238 239 240 241
    reset() {
      this.$refs.monitorForm.resetFields();
    },
    submit() {
      this.$refs.monitorForm.validate((valid) => {
        if (valid) {
neogcg's avatar
neogcg committed
242
          this.monitorForm.parentId = this.monitorForm.fsuId;
neogcg's avatar
neogcg committed
243
          monitorEquipsave(this.monitorForm).then((res) => {
neogcg's avatar
neogcg committed
244 245
            if (res.code == 200) {
              successAlert("添加成功");
dupengyu's avatar
dupengyu committed
246 247
              
        this.monitorForm = formInit();
neogcg's avatar
neogcg committed
248
            } else {
neogcg's avatar
neogcg committed
249
              warningAlert("添加失败");
neogcg's avatar
neogcg committed
250 251
            }
          });
neogcg's avatar
neogcg committed
252
        }
neogcg's avatar
neogcg committed
253 254
      });
    },
neogcg's avatar
neogcg committed
255

neogcg's avatar
neogcg committed
256 257 258 259 260 261 262
    getAllWay() {
      railWaylist(this.params).then((res) => {
        this.railWaySelect = res.records;
        if (res.total > this.params.size) {
          this.params.size = res.total;
          this.getAllWay();
        }
dupengyu's avatar
dupengyu committed
263
      });
neogcg's avatar
neogcg committed
264 265
    },
  },
neogcg's avatar
neogcg committed
266 267
  created() {
    selectMonitorItem().then((res) => {
neogcg's avatar
neogcg committed
268 269
      this.equipTypeSelect = res["03"];
      this.equipModeSelect = res["09"];
neogcg's avatar
neogcg committed
270 271
    });
  },
neogcg's avatar
neogcg committed
272
};
yanzhongrong's avatar
yanzhongrong committed
273

neogcg's avatar
neogcg committed
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
function formInit(data = {}) {
  return {
    wayId: "",
    parentId: "",
    siteId: "",
    fsuId: "",
    equipCode: "",
    ip: "",
    equipFactory: "",
    equipMode: "",
    equipName: "",
    equipSerialNumber: "",
    equipType: "",
    installDate: "",
    kmSign: "",
    repairDate: "",
    ...data,
  };
}
neogcg's avatar
neogcg committed
293 294 295 296 297 298 299 300
</script>
<style lang="scss" scoped>
.form {
  padding: 20px 0;
  width: 600px;
  margin: 0 auto;
}
.btn {
yanzhongrong's avatar
yanzhongrong committed
301
  padding: 20px 0 50px 0;
neogcg's avatar
neogcg committed
302 303 304
  text-align: center;
}
</style>