张延森 4 years ago
parent
commit
d737cc5c69

+ 15
- 0
src/store/models/room.js View File

114
     return request({
114
     return request({
115
       url: '/room/protection/update-status',
115
       url: '/room/protection/update-status',
116
       data,
116
       data,
117
+      toast: '请稍候...',
117
     }).then(() => {
118
     }).then(() => {
118
       detail.roomInfo.protectionFlag = data.protectionFlag
119
       detail.roomInfo.protectionFlag = data.protectionFlag
119
       return
120
       return
120
     })
121
     })
121
   }
122
   }
122
 
123
 
124
+  // 业主电话
125
+  const addOwnerTel = params => {
126
+    return request({
127
+      url: '/room/own-tel/add',
128
+      params,
129
+      toast: '请稍候...',
130
+    }).then(() => {
131
+      const ownerTel = detail.roomInfo.ownerTel || ''
132
+      detail.roomInfo.ownerTel = ownerTel.split(',').filter(Boolean).concat(params.newOwnerTel).join(',')
133
+      return
134
+    })
135
+  }
136
+
123
   return {
137
   return {
124
     list,
138
     list,
125
     page,
139
     page,
134
     getKey,
148
     getKey,
135
     roomKeyBox,
149
     roomKeyBox,
136
     updateProtection,
150
     updateProtection,
151
+    addOwnerTel,
137
   }
152
   }
138
 }
153
 }

+ 1
- 1
src/utils/plugins/shiro.js View File

3
 const shiro = {
3
 const shiro = {
4
   install: (app) => {
4
   install: (app) => {
5
 
5
 
6
-    const removeNode = el => el.parentNode.removeChild(el)
6
+    const removeNode = el => el.parentNode && el.parentNode.removeChild(el)
7
 
7
 
8
     app.directive('shiro', (el, binding) => {      
8
     app.directive('shiro', (el, binding) => {      
9
       const { permissions, getPermission } = store.getState('shiro')
9
       const { permissions, getPermission } = store.getState('shiro')

+ 17
- 3
src/utils/request/index.js View File

1
 import axios from 'axios'
1
 import axios from 'axios'
2
+import { Toast } from 'vant'
2
 import { router } from '@/router'
3
 import { router } from '@/router'
3
 import store from '@/store'
4
 import store from '@/store'
4
 import { showDanger } from '../'
5
 import { showDanger } from '../'
12
     config.setLoading(true)
13
     config.setLoading(true)
13
   }
14
   }
14
 
15
 
16
+  if (config.toast) {    
17
+    config.toastInst = Toast.loading({
18
+      message: config.toast,
19
+      forbidClick: true,
20
+      duration: 0,
21
+    })
22
+  }
23
+
15
   return config
24
   return config
16
 }
25
 }
17
 
26
 
27
   if (response.config.setLoading) {
36
   if (response.config.setLoading) {
28
     response.config.setLoading(false)
37
     response.config.setLoading(false)
29
   }
38
   }
39
+
40
+  if (response.config.toastInst) {
41
+    response.config.toastInst.clear()
42
+  }
30
  
43
  
31
   if (/json/.test(contentType)) {
44
   if (/json/.test(contentType)) {
32
     if ('0' === data.code) {
45
     if ('0' === data.code) {
33
       return data.data
46
       return data.data
34
-    } else if ('1' === data.code) {
35
-    
36
-      return Promise.reject('账号未登录或没有权限1')
37
     } else if ('-1' === data.code) {
47
     } else if ('-1' === data.code) {
38
       router.push('/login')
48
       router.push('/login')
39
       // return Promise.reject(data.message)
49
       // return Promise.reject(data.message)
58
   if (error.config.setLoading) {
68
   if (error.config.setLoading) {
59
     error.config.setLoading(false)
69
     error.config.setLoading(false)
60
   }
70
   }
71
+  
72
+  if (error.config.toastInst) {
73
+    error.config.toastInst.clear()
74
+  }
61
 
75
 
62
   if (error.response) {
76
   if (error.response) {
63
     console.error(`[${type}]:`)
77
     console.error(`[${type}]:`)

+ 1
- 1
src/view/secondhand/detail/components/Base.vue View File

100
 
100
 
101
     // 获取字典对应名称
101
     // 获取字典对应名称
102
     const getDictLabel = (val, key) => {
102
     const getDictLabel = (val, key) => {
103
-      return dicts[key]?.filter(x => x.code === val)[0]?.name
103
+      return dicts[key]?.filter(x => x.value === val)[0]?.text
104
     }
104
     }
105
 
105
 
106
     return {
106
     return {

+ 65
- 4
src/view/secondhand/detail/components/MoreActions.vue View File

12
           v-show="!roomInfo.protectionFlag || roomInfo.protectionFlag === '0'"
12
           v-show="!roomInfo.protectionFlag || roomInfo.protectionFlag === '0'"
13
           title="设置房源保护"
13
           title="设置房源保护"
14
           icon="fire"
14
           icon="fire"
15
+          @click="handleRoomProtection(1)"
15
         />
16
         />
16
 
17
 
17
         <van-cell
18
         <van-cell
19
           v-show="roomInfo.protectionFlag === '1'"
20
           v-show="roomInfo.protectionFlag === '1'"
20
           title="取消房源保护"
21
           title="取消房源保护"
21
           icon="fire"
22
           icon="fire"
23
+          @click="handleRoomProtection(0)"
22
         />
24
         />
23
 
25
 
24
         <van-cell
26
         <van-cell
25
           v-shiro="'room:info:addTel'"
27
           v-shiro="'room:info:addTel'"
26
           title="新增业主电话"
28
           title="新增业主电话"
27
           icon="add"
29
           icon="add"
30
+          @click="phoneShow = true"
28
         />
31
         />
29
 
32
 
30
         <van-cell
33
         <van-cell
32
           v-show="roomInfo.status === '0'"
35
           v-show="roomInfo.status === '0'"
33
           title="下架房源"
36
           title="下架房源"
34
           icon="delete"
37
           icon="delete"
38
+          @click="$router.push({name: 'house.close', query: {roomId: roomInfo.id}})"
35
         />
39
         />
36
 
40
 
37
         <van-cell
41
         <van-cell
48
       </van-cell-group>
52
       </van-cell-group>
49
     </div>
53
     </div>
50
   </van-popover>
54
   </van-popover>
55
+
56
+  <van-dialog
57
+    v-model:show="phoneShow"
58
+    title="新增电话"
59
+    show-cancel-button
60
+    @confirm="handleAddOwnerTel"
61
+    @cancel="phoneShow = false"
62
+  >
63
+    <van-field
64
+      v-model="newOwnerTel"
65
+      type="tel"
66
+      label="业主电话"
67
+      placeholder="请输入电话"
68
+    />
69
+  </van-dialog>
51
 </template>
70
 </template>
52
 
71
 
53
 <script>
72
 <script>
54
 import { ref } from 'vue'
73
 import { ref } from 'vue'
55
-import { Popover, CellGroup, Cell, Icon } from 'vant'
74
+import { Dialog, Popover, CellGroup, Cell, Field, Icon, Notify } from 'vant'
75
+import { useModel } from '@zjxpcyc/vue-tiny-store'
56
 
76
 
57
 export default {
77
 export default {
58
   components: {
78
   components: {
60
     [CellGroup.name]: CellGroup,
80
     [CellGroup.name]: CellGroup,
61
     [Cell.name]: Cell,
81
     [Cell.name]: Cell,
62
     [Icon.name]: Icon,
82
     [Icon.name]: Icon,
83
+    [Field.name]: Field,
63
   },
84
   },
64
   props: {
85
   props: {
65
     roomInfo: {
86
     roomInfo: {
67
       default: () => ({})
88
       default: () => ({})
68
     }
89
     }
69
   },
90
   },
70
-  setup() {
91
+  setup(props) {
71
     const show = ref(false)
92
     const show = ref(false)
93
+    const phoneShow = ref(false)
94
+    const newOwnerTel = ref()
95
+
96
+    const { updateProtection, addOwnerTel } = useModel('room')
97
+
98
+    // 房源(确定/取消)保护
99
+    const handleRoomProtection = status => {
100
+      show.value = false
101
+      const title = `${status === 1 ? '确定' : '取消'}房源保护`
102
+      const message = status === 1 ? '设为房源保护后,只有录入人、同部门的上级以及上级部门的上级可以看到房源敏感信息。' : '取消房源保护后,其他人可以查看当前房源的敏感信息。'
103
+
104
+      Dialog.confirm({title, message}).then(() => {
105
+        updateProtection({
106
+          id: props.roomInfo.id,
107
+          protectionFlag: status
108
+        }).then(() => {
109
+          Notify({ type: 'success', message: '设置成功' })
110
+        })
111
+      })
112
+    }
113
+
114
+    // 添加户主电话
115
+    const handleAddOwnerTel = () => {
116
+      if (!newOwnerTel.value || newOwnerTel.value.length !== 11) {
117
+        Notify({ type: 'warning', message: '请正确填写手机号' })
118
+        return
119
+      }
120
+
121
+      addOwnerTel({
122
+        newOwnerTel: newOwnerTel.value,
123
+        newOwnerRoomId: props.roomInfo.id,
124
+      }).then(() => {
125
+        Notify({ type: 'success', message: '设置成功' })
126
+      }).catch(e => {
127
+        Notify({ type: 'danger', message: e.message })
128
+      })
129
+    }
72
 
130
 
73
     return {
131
     return {
74
-      show
132
+      show,
133
+      phoneShow,
134
+      newOwnerTel,
135
+      handleRoomProtection,
136
+      handleAddOwnerTel,
75
     }
137
     }
76
   }
138
   }
77
 }
139
 }
78
 </script>
140
 </script>
79
-