ZZJ
2022-07-27 88078aa63c669cffc2d91e1269d460436427d09d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<template>
  <div class="FormArea">
    <el-form
      :model="gb28181"
      :rules="rules"
      label-position="left"
      label-width="90px"
      class="alarmSetting"
      ref="gb28181"
    >
      <el-radio-group v-model="gb28181.idType">
        <el-radio :label="0">输入已有ID</el-radio>
        <el-radio :label="1">生成新的ID</el-radio>
      </el-radio-group>
 
      <el-form-item class="selectItem" label="所在地">
        <el-select
          class="h32"
          v-model="locationCity.province"
          @change="changeProvince"
          size="small"
          placeholder="请选择省份"
          :disabled="gb28181.idType === 0"
        >
          <el-option
            v-for="item in locationCity.provinceOptions"
            :key="item.id"
            :label="item.name"
            size="small"
            :value="item.id"
          ></el-option>
        </el-select>
        <el-select
          class="ml10 mr10 h32"
          v-model="locationCity.city"
          :disabled="!locationCity.province"
          @change="changeCity"
          size="small"
          placeholder="请选择城市"
        >
          <el-option
            v-for="item in locationCity.cityOptions"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          ></el-option>
        </el-select>
        <el-select
          class="h32"
          v-model="locationCity.county"
          :disabled="!locationCity.city"
          size="small"
          placeholder="请选择区县"
        >
          <el-option
            v-for="item in locationCity.countyOptions"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          ></el-option>
        </el-select>
        <div class="button" v-show="gb28181.idType === 1" @click="newGBID">
          生成ID
        </div>
      </el-form-item>
 
      <el-form-item label="国标ID">
        <el-input
          class="h32"
          v-model="gb28181.PublicId"
          placeholder="请输入"
          size="small"
          :disabled="gb28181.idType === 1"
        ></el-input>
      </el-form-item>
 
      <el-form-item label="国标端口" prop="GbServerPort">
        <el-input
          class="h32"
          v-model.number="gb28181.GbServerPort"
          placeholder="请输入"
          size="small"
          style="width: 200px"
        ></el-input>
      </el-form-item>
 
      <el-form-item label="开启鉴权" style="text-align: left">
        <el-switch v-model="gb28181.IsAuth"></el-switch>
      </el-form-item>
 
      <el-form-item label="鉴权密码">
        <el-input
          class="h32"
          v-model="gb28181.Password"
          placeholder="请输入"
          size="small"
          :disabled="!gb28181.IsAuth"
        ></el-input>
      </el-form-item>
    </el-form>
 
    <div class="btnArea">
      <div class="button cancel" @click="$emit('close')">取消</div>
      <div class="button submit" @click="submitGB28281">保存</div>
    </div>
  </div>
</template>
 
<script>
import {
  getGB28181Config,
  saveGB28181Config,
  getGb28181AreaList,
  newGb28181ID,
} from "@/api/Gb28181";
import { isPort, isIPv4 } from "@/scripts/validate";
 
export default {
  props: {
    id: {},
  },
  created() {
    this.initGB28181Conf();
  },
  data() {
    return {
      gb28181: {},
      rules: {
        ip: [
          {
            required: true,
            message: "请输入IP地址",
            trigger: "change",
          },
          { validator: isIPv4, trigger: "change" },
        ],
        ServerIp: [
          {
            required: true,
            message: "请输入IP地址",
            trigger: "change",
          },
          { validator: isIPv4, trigger: "change" },
        ],
        ServerPort: [
          {
            required: true,
            message: "请输入端口",
            trigger: "change",
          },
          { validator: isPort, trigger: "change" },
        ],
        GbServerPort: [
          {
            required: true,
            message: "请输入端口",
            trigger: "change",
          },
          { validator: isPort, trigger: "change" },
        ],
      },
      locationCity: {
        province: "",
        city: "",
        county: "",
        provinceOptions: [],
        cityOptions: [],
        countyOptions: [],
      },
    };
  },
  methods: {
    initGB28181Conf() {
      getGB28181Config(this.id).then((rsp) => {
        if (rsp && rsp.success) {
          this.gb28181 = rsp.data;
          //this.gb28181.idType = 0;
 
          this.$set(this.gb28181, "idType", 0);
          this.$refs["gb28181"].resetFields();
        }
      });
      getGb28181AreaList().then((rsp) => {
        if (rsp && rsp.success) {
          this.locationCity.provinceOptions = rsp.data.list;
        }
      });
    },
    submitGB28281() {
      this.$refs["gb28181"].validate((valid) => {
        if (valid) {
          saveGB28181Config(this.gb28181).then((rsp) => {
            if (rsp && rsp.success) {
              console.log("1212112");
              this.$notify({
                type: "success",
                message: "GB28181设置保存成功",
              });
            }
          });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    changeProvince() {
      let pid = this.locationCity.province;
      getGb28181AreaList({ parentId: pid }).then((rsp) => {
        if (rsp && rsp.success) {
          this.locationCity.cityOptions = rsp.data.list;
          this.locationCity.city = this.locationCity.cityOptions[0].id;
          this.changeCity();
        }
      });
    },
    changeCity() {
      let pid = this.locationCity.city;
      getGb28181AreaList({ parentId: pid }).then((rsp) => {
        if (rsp && rsp.success) {
          this.locationCity.countyOptions = rsp.data.list;
          this.locationCity.county = this.locationCity.countyOptions[0].id;
        }
      });
    },
    newGBID() {
      let cCode = this.locationCity.county + "";
      newGb28181ID({ code: cCode }).then((rsp) => {
        if (rsp && rsp.success) {
          this.gb28181.PublicId = rsp.data.code;
        }
      });
    },
  },
};
</script>
 
<style lang="scss" scoped >
.FormArea {
  position: relative;
  height: 565px;
  .el-form {
    padding: 20px;
    padding-top: 34px;
 
    .el-form-item {
      margin-bottom: 34px;
    }
 
    .h32 {
      border-radius: 3px;
 
      ::v-deep input {
        border-radius: 3px;
        border-color: #c0c5cc;
      }
    }
 
    .el-input {
      width: 410px;
    }
 
    .el-radio-group {
      margin-bottom: 34px;
 
      ::v-deep .el-radio__label {
        color: #3d3d3d;
      }
    }
 
    .selectItem ::v-deep {
      .el-form-item__content {
        display: flex;
 
        .el-select {
          margin-right: 10px;
          width: 200px;
        }
 
        .button {
          margin-left: 10px;
          line-height: 32px;
          color: #0065ff;
        }
      }
    }
  }
 
  .el-form-item.is-required {
    ::v-deep .el-form-item__label:before {
      display: none;
    }
 
    ::v-deep .el-form-item__label::after {
      content: "*";
      color: #f52323;
      margin-right: 4px;
    }
  }
 
  .btnArea {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 20px 0;
    border-top: 1px solid #e9ebee;
    display: flex;
    justify-content: flex-end;
    text-align: center;
 
    .cancel {
      margin-right: 10px;
      padding: 6px 16px;
      border: 1px solid #0065ff;
      color: #0065ff;
    }
 
    .submit {
      padding: 6px 16px;
      border: 1px solid #0065ff;
      color: #fff;
      background-color: #0065ff;
    }
  }
}
</style>