Blame view

src/components/community/editCommunity.vue 6.54 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
2
    <el-dialog :title="$t('editCommunity.title')" :visible.sync="visible" width="60%" @close="refreshEditCommunityInfo">
b783cddd   wuxw   v1.9 优化添加小区因为提示bug
3
4
      <el-form ref="form" :model="editCommunityInfo" :rules="rules" class="text-left" label-width="120px">
        <el-form-item :label="$t('editCommunity.name')" prop="name" >
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
5
6
          <el-input v-model="editCommunityInfo.name" :placeholder="$t('editCommunity.namePlaceholder')" />
        </el-form-item>
b783cddd   wuxw   v1.9 优化添加小区因为提示bug
7
        <el-form-item :label="$t('editCommunity.address')" prop="address" >
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
8
9
          <el-input v-model="editCommunityInfo.address" :placeholder="$t('editCommunity.addressPlaceholder')" />
        </el-form-item>
b783cddd   wuxw   v1.9 优化添加小区因为提示bug
10
        <el-form-item :label="$t('editCommunity.nearbyLandmarks')" prop="nearbyLandmarks" >
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
11
12
13
          <el-input v-model="editCommunityInfo.nearbyLandmarks"
            :placeholder="$t('editCommunity.nearbyLandmarksPlaceholder')" />
        </el-form-item>
b783cddd   wuxw   v1.9 优化添加小区因为提示bug
14
        <el-form-item :label="$t('editCommunity.payFeeMonth')" prop="payFeeMonth" >
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
15
16
          <el-input v-model="editCommunityInfo.payFeeMonth" :placeholder="$t('editCommunity.payFeeMonthPlaceholder')" />
        </el-form-item>
b783cddd   wuxw   v1.9 优化添加小区因为提示bug
17
        <el-form-item :label="$t('editCommunity.feePrice')" prop="feePrice" >
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
18
19
          <el-input v-model="editCommunityInfo.feePrice" :placeholder="$t('editCommunity.feePricePlaceholder')" />
        </el-form-item>
b783cddd   wuxw   v1.9 优化添加小区因为提示bug
20
        <el-form-item :label="$t('editCommunity.tel')" prop="tel" >
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
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
          <el-input v-model="editCommunityInfo.tel" :placeholder="$t('editCommunity.telPlaceholder')" />
        </el-form-item>
        <el-form-item v-for="(item, index) in editCommunityInfo.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="editCommunity">{{ $t('common.save') }}</el-button>
      </div>
    </el-dialog>
  </template>
  
  <script>
  import { updateCommunity } from '@/api/community/communityManageApi'
  import { getAttrSpecList } from '@/api/dev/attrSpecApi'
  import { getAttrValueList } from '@/api/dev/attrValueApi'
  
  export default {
    name: 'EditCommunity',
    data() {
      return {
        visible: false,
b783cddd   wuxw   v1.9 优化添加小区因为提示bug
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
        rules: {
          name: [
            { required: true, message: this.$t('editCommunity.validate.name'), trigger: 'blur' }
          ],
          address: [
            { required: true, message: this.$t('editCommunity.validate.address'), trigger: 'blur' }
          ],
          nearbyLandmarks: [
            { required: true, message: this.$t('editCommunity.validate.nearbyLandmarks'), trigger: 'blur' }
          ],
          payFeeMonth: [
            { required: true, message: this.$t('editCommunity.validate.payFeeMonth'), trigger: 'blur' }
          ],
          feePrice: [
            { required: true, message: this.$t('editCommunity.validate.feePrice'), trigger: 'blur' }
          ],
          tel: [
            { required: true, message: this.$t('editCommunity.validate.tel'), trigger: 'blur' }
          ],
          attrs: [
            { required: true, message: this.$t('editCommunity.validate.attrs'), trigger: 'blur' }
          ]
        },
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
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
        editCommunityInfo: {
          communityId: '',
          name: '',
          address: '',
          nearbyLandmarks: '',
          cityCode: '',
          mapX: '101.33',
          mapY: '101.33',
          payFeeMonth: 12,
          feePrice: 0,
          tel: '',
          attrs: []
        }
      }
    },
  
    methods: {
      async openModal(community) {
        console.log(community)
        this.refreshEditCommunityInfo()
        this.visible = true
        Object.assign(this.editCommunityInfo, community)
        await this._loadEditCommunityAttrSpec()
  
        if (!community.communityAttrDtos) {
          return;
        }
        const attrDtos = community.communityAttrDtos
        let attrs = this.editCommunityInfo.attrs
        console.log(attrs,attrDtos)
  
        attrDtos.forEach(item => {
          attrs.forEach(attrItem => {
            console.log(item.specCd, attrItem.specCd)
            if (item.specCd == attrItem.specCd) {
              attrItem.attrId = item.attrId
              attrItem.value = item.value
            }
          })
  
        })
  
      },
      editCommunity() {
        if (!this.validateForm()) {
          return
        }
        updateCommunity(this.editCommunityInfo).then(res => {
          console.log(res)
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
121
          this.$message.success(this.$t('common.operationSuccess'))
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
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
          this.visible = false
          this.$emit('listData')
  
        }).catch(error => {
          this.$message.error(error.message)
        })
      },
      validateForm() {
        if (!this.editCommunityInfo.name) {
          this.$message.error(this.$t('editCommunity.validate.name'))
          return false
        }
        if (!this.editCommunityInfo.address) {
          this.$message.error(this.$t('editCommunity.validate.address'))
          return false
        }
        if (!this.editCommunityInfo.nearbyLandmarks) {
          this.$message.error(this.$t('editCommunity.validate.nearbyLandmarks'))
          return false
        }
        if (!this.editCommunityInfo.communityId) {
          this.$message.error(this.$t('editCommunity.validate.communityId'))
          return false
        }
        return true
      },
      refreshEditCommunityInfo() {
        const attrs = this.editCommunityInfo.attrs
        this.editCommunityInfo = {
          communityId: '',
          name: '',
          address: '',
          nearbyLandmarks: '',
          cityCode: '',
          mapX: '101.33',
          mapY: '101.33',
          payFeeMonth: 12,
          feePrice: 0,
          tel: '',
          attrs: attrs
        }
      },
      async _loadEditCommunityAttrSpec() {
        this.editCommunityInfo.attrs = []
        const { data } = await getAttrSpecList({
          page: 1,
          row: 100,
          tableName: 'building_community_attr'
        })
        data.forEach(item => {
          item.value = ''
          item.values = []
          this._loadEditAttrValue(item.specCd, item.values)
          if (item.specShow == 'Y') {
            this.editCommunityInfo.attrs.push(item)
          }
        })
  
      },
      async _loadEditAttrValue(specCd, values) {
        const { data } = await getAttrValueList({ specCd, page: 1, row: 100 })
  
        data.forEach(item => {
          if (item.valueShow == 'Y') {
            values.push(item)
          }
        })
  
      }
    }
  }
  </script>