|
@@ -0,0 +1,106 @@
|
|
|
+<template >
|
|
|
+ <div class="addAccess">
|
|
|
+ <el-form ref="form" :model="formData" :rules="formRules" label-width="110px">
|
|
|
+ <el-form-item label="所属社区" prop="communityId">
|
|
|
+ <el-select v-model="formData.communityId" placeholder="选择社区" clearable @change="buildingNameList(formData.communityId)">
|
|
|
+ <el-option v-for="(item, index) in communityArr" :key="index" :label="item.communityName" :value="item.id"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="设备类型" prop="deviceType">
|
|
|
+ <el-cascader
|
|
|
+ v-model="formData.deviceType"
|
|
|
+ :options="productOptions"
|
|
|
+ :props="defaultProps"
|
|
|
+ clearable
|
|
|
+ placeholder="设备类型"
|
|
|
+ ></el-cascader>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="设备编号" prop="deviceNo">
|
|
|
+ <el-input type="text" maxlength="100" placeholder="请输入设备编号" v-model="formData.deviceNo"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="设备名称" prop="deviceName">
|
|
|
+ <el-input type="text" maxlength="100" placeholder="请输入设备名称" v-model="formData.deviceName"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="设备地址" prop="address">
|
|
|
+ <el-input type="text" maxlength="100" placeholder="请输入设备地址" v-model="formData.address"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script >
|
|
|
+export default {
|
|
|
+ props: ['params'],
|
|
|
+
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ formData: {
|
|
|
+ communityId: '',
|
|
|
+ deviceType: '',
|
|
|
+ deviceNo: '',
|
|
|
+ deviceName: '',
|
|
|
+ address: ''
|
|
|
+ },
|
|
|
+ formRules: {
|
|
|
+ communityId: [this.$valid.selectRequired('所属社区')],
|
|
|
+ deviceType: [this.$valid.selectRequired('设备类型')],
|
|
|
+ deviceNo: [this.$valid.inputRequired('设备编号')],
|
|
|
+ deviceName: [this.$valid.inputRequired('设备名称')],
|
|
|
+ address: [this.$valid.inputRequired('设备地址')]
|
|
|
+ },
|
|
|
+ communityArr: [],
|
|
|
+ productOptions: [],
|
|
|
+ defaultProps: {
|
|
|
+ value: 'id', // 唯一标识
|
|
|
+ label: 'label', // 标签显示
|
|
|
+ children: 'children' // 子级
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getorgTree() {
|
|
|
+ this.$http
|
|
|
+ .get('/sc-community/assets/community/list')
|
|
|
+ .then((data) => {
|
|
|
+ this.communityArr = data.data;
|
|
|
+ })
|
|
|
+ .catch(function () {});
|
|
|
+ },
|
|
|
+ getProductOptions() {
|
|
|
+ this.$http.postForm('/sc-community/devicetype/selectList', { name: '' }).then((data) => {
|
|
|
+ this.productOptions = data;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ submit() {
|
|
|
+ this.$refs.form.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ var loading = this.$loading();
|
|
|
+ let installData = JSON.parse(JSON.stringify(this.formData));
|
|
|
+ installData.deviceType = _.last(installData.deviceType);
|
|
|
+ this.$http
|
|
|
+ .post('/sc-gate-web/gate/add', installData)
|
|
|
+ .then(({ status, msg }) => {
|
|
|
+ if (status == 0) {
|
|
|
+ this.$message.success(msg);
|
|
|
+ this.params.callback();
|
|
|
+ this.$emit('close');
|
|
|
+ } else {
|
|
|
+ this.$message.error(msg);
|
|
|
+ }
|
|
|
+ loading.close();
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ loading.close();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getorgTree();
|
|
|
+ this.getProductOptions();
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+@import '@assets/css/public-style.scss';
|
|
|
+</style>
|