Blame view

src/components/community/addCommunity.vue 6.56 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
84ba0155   wuxw   家庭成员测试
2
    <el-dialog :title="$t('addCommunity.title')" :visible.sync="visible" width="40%" @close="clearAddCommunityInfo">
b783cddd   wuxw   v1.9 优化添加小区因为提示bug
3
4
      <el-form ref="form" :model="addCommunityInfo" :rules="rules" label-width="120px" class="text-left">
        <el-form-item :label="$t('addCommunity.name')" prop="name" >
6831c157   wuxw   v1.9 优化不能连续添加小区bug
5
          <el-input v-model="addCommunityInfo.name" :placeholder="$t('addCommunity.name')" />
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
6
7
        </el-form-item>
        <el-form-item :label="$t('addCommunity.area')" prop="area">
6831c157   wuxw   v1.9 优化不能连续添加小区bug
8
          <area-select ref="areaSelectRef" @selectArea="selectArea" />
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
9
        </el-form-item>
b783cddd   wuxw   v1.9 优化添加小区因为提示bug
10
        <el-form-item :label="$t('addCommunity.address')" prop="tmpAddress" >
6831c157   wuxw   v1.9 优化不能连续添加小区bug
11
          <el-input v-model="addCommunityInfo.tmpAddress" :placeholder="$t('addCommunity.address')" />
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
12
        </el-form-item>
b783cddd   wuxw   v1.9 优化添加小区因为提示bug
13
        <el-form-item :label="$t('addCommunity.nearbyLandmarks')" prop="nearbyLandmarks" >
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
14
          <el-input v-model="addCommunityInfo.nearbyLandmarks"
6831c157   wuxw   v1.9 优化不能连续添加小区bug
15
            :placeholder="$t('addCommunity.nearbyLandmarks')" />
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
16
        </el-form-item>
b783cddd   wuxw   v1.9 优化添加小区因为提示bug
17
        <el-form-item :label="$t('addCommunity.tel')" prop="tel" >
6831c157   wuxw   v1.9 优化不能连续添加小区bug
18
          <el-input v-model="addCommunityInfo.tel" :placeholder="$t('addCommunity.tel')" />
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
19
        </el-form-item>
b783cddd   wuxw   v1.9 优化添加小区因为提示bug
20
        <el-form-item :label="$t('addCommunity.payFeeMonth')" prop="payFeeMonth" >
6831c157   wuxw   v1.9 优化不能连续添加小区bug
21
          <el-input v-model="addCommunityInfo.payFeeMonth" :placeholder="$t('addCommunity.payFeeMonth')" />
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
22
        </el-form-item>
b783cddd   wuxw   v1.9 优化添加小区因为提示bug
23
        <el-form-item :label="$t('addCommunity.feePrice')" prop="feePrice" >
6831c157   wuxw   v1.9 优化不能连续添加小区bug
24
          <el-input v-model="addCommunityInfo.feePrice" :placeholder="$t('addCommunity.feePrice')" />
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
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
        </el-form-item>
        <el-form-item v-for="(item, index) in addCommunityInfo.attrs" :key="index" :label="item.specName"
          :prop="'attrs.' + index + '.value'">
          <el-input v-if="item.specType === '2233'" v-model="item.value" :placeholder="item.specHoldplace" />
          <el-select v-else-if="item.specType === '3344'" v-model="item.value" :placeholder="item.specHoldplace"
            style="width: 100%">
            <el-option v-for="value in item.values" :key="value.value" :label="value.valueName" :value="value.value" />
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="visible = false">{{ $t('common.cancel') }}</el-button>
        <el-button type="primary" @click="saveCommunityInfo">{{ $t('common.save') }}</el-button>
      </div>
    </el-dialog>
  </template>
  
  <script>
  import { saveCommunity } from '@/api/community/communityManageApi'
  import { getAttrSpecList } from '@/api/dev/attrSpecApi'
  import { getAttrValueList } from '@/api/dev/attrValueApi'
  import AreaSelect from '@/components/community/areaSelect'
  
  export default {
    name: 'AddCommunity',
    data() {
      return {
        visible: false,
b783cddd   wuxw   v1.9 优化添加小区因为提示bug
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
        rules: {
          name: [
            { required: true, message: this.$t('addCommunity.validate.name'), trigger: 'blur' }
          ],
          cityCode: [
            { required: true, message: this.$t('addCommunity.validate.cityCode'), trigger: 'blur' }
          ],
          address: [
            { required: true, message: this.$t('addCommunity.validate.address'), trigger: 'blur' }
          ],
          nearbyLandmarks: [
            { required: true, message: this.$t('addCommunity.validate.nearbyLandmarks'), trigger: 'blur' }
          ],
          tel: [
            { required: true, message: this.$t('addCommunity.validate.tel'), trigger: 'blur' }
          ],
          payFeeMonth: [
            { required: true, message: this.$t('addCommunity.validate.payFeeMonth'), trigger: 'blur' }
          ],
          feePrice: [
            { required: true, message: this.$t('addCommunity.validate.feePrice'), trigger: 'blur' }
          ],
          attrs: [
            { required: true, message: this.$t('addCommunity.validate.attrs'), trigger: 'blur' }
          ]
        },
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
        addCommunityInfo: {
          name: '',
          address: '',
          tmpAddress: '',
          areaAddress: '',
          nearbyLandmarks: '',
          tel: '',
          cityCode: '',
          mapX: '101.33',
          mapY: '101.33',
          attrs: [],
          payFeeMonth: 12,
          feePrice: 0
        }
      }
    },
    components: { AreaSelect },
    methods: {
      openModal() {
        this._loadCommunityAttrSpec()
6831c157   wuxw   v1.9 优化不能连续添加小区bug
99
100
101
        setTimeout(() => {
          this.$refs.areaSelectRef.clearArea()
        }, 100)
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
102
103
104
105
106
107
108
109
110
111
112
113
        this.visible = true
      },
      selectArea(area) {
        this.addCommunityInfo.cityCode = area.selectArea
      },
      saveCommunityInfo() {
        this.addCommunityInfo.address = this.addCommunityInfo.areaAddress + this.addCommunityInfo.tmpAddress
        if (!this.validateForm()) {
          return
        }
        saveCommunity(this.addCommunityInfo).then(res => {
          console.log(res)
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
114
          this.$message.success(this.$t('common.operationSuccess'))
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
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
          this.visible = false
          this.$emit('listData')
        }).catch(error => {
          this.$message.error(error.message)
        })
      },
      validateForm() {
        if (!this.addCommunityInfo.name) {
          this.$message.error(this.$t('addCommunity.validate.name'))
          return false
        }
        if (!this.addCommunityInfo.cityCode) {
          this.$message.error(this.$t('addCommunity.validate.cityCode'))
          return false
        }
        if (!this.addCommunityInfo.address) {
          this.$message.error(this.$t('addCommunity.validate.address'))
          return false
        }
        if (!this.addCommunityInfo.nearbyLandmarks) {
          this.$message.error(this.$t('addCommunity.validate.nearbyLandmarks'))
          return false
        }
        if (!this.addCommunityInfo.tel) {
          this.$message.error(this.$t('addCommunity.validate.tel'))
          return false
        }
        return true
      },
      clearAddCommunityInfo() {
        this.addCommunityInfo = {
          name: '',
          address: '',
          tmpAddress: '',
          areaAddress: '',
          nearbyLandmarks: '',
          cityCode: '',
          mapX: '101.33',
          mapY: '101.33',
          attrs: [],
          payFeeMonth: 12,
          feePrice: 0
        }
      },
      async _loadCommunityAttrSpec() {
        this.addCommunityInfo.attrs = []
        const { data } = await getAttrSpecList({
          page: 1,
          row: 100,
          tableName: 'building_community_attr'
        })
        data.forEach(item => {
          item.value = ''
          if (item.specShow === 'Y') {
            item.values = []
            this._loadAttrValue(item.specCd, item.values)
            this.addCommunityInfo.attrs.push(item)
          }
        })
      },
      async _loadAttrValue(specCd, values) {
        const { data } = await getAttrValueList({ specCd, page: 1, row: 100 })
        data.forEach(item => {
          if (item.valueShow === 'Y') {
            values.push(item)
          }
        })
  
      }
    }
  }
  </script>