张延森 4 년 전
부모
커밋
d737cc5c69

+ 15
- 0
src/store/models/room.js 파일 보기

@@ -114,12 +114,26 @@ export default () => {
114 114
     return request({
115 115
       url: '/room/protection/update-status',
116 116
       data,
117
+      toast: '请稍候...',
117 118
     }).then(() => {
118 119
       detail.roomInfo.protectionFlag = data.protectionFlag
119 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 137
   return {
124 138
     list,
125 139
     page,
@@ -134,5 +148,6 @@ export default () => {
134 148
     getKey,
135 149
     roomKeyBox,
136 150
     updateProtection,
151
+    addOwnerTel,
137 152
   }
138 153
 }

+ 1
- 1
src/utils/plugins/shiro.js 파일 보기

@@ -3,7 +3,7 @@ import store from '@/store'
3 3
 const shiro = {
4 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 8
     app.directive('shiro', (el, binding) => {      
9 9
       const { permissions, getPermission } = store.getState('shiro')

+ 17
- 3
src/utils/request/index.js 파일 보기

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

+ 1
- 1
src/view/secondhand/detail/components/Base.vue 파일 보기

@@ -100,7 +100,7 @@ export default {
100 100
 
101 101
     // 获取字典对应名称
102 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 106
     return {

+ 65
- 4
src/view/secondhand/detail/components/MoreActions.vue 파일 보기

@@ -12,6 +12,7 @@
12 12
           v-show="!roomInfo.protectionFlag || roomInfo.protectionFlag === '0'"
13 13
           title="设置房源保护"
14 14
           icon="fire"
15
+          @click="handleRoomProtection(1)"
15 16
         />
16 17
 
17 18
         <van-cell
@@ -19,12 +20,14 @@
19 20
           v-show="roomInfo.protectionFlag === '1'"
20 21
           title="取消房源保护"
21 22
           icon="fire"
23
+          @click="handleRoomProtection(0)"
22 24
         />
23 25
 
24 26
         <van-cell
25 27
           v-shiro="'room:info:addTel'"
26 28
           title="新增业主电话"
27 29
           icon="add"
30
+          @click="phoneShow = true"
28 31
         />
29 32
 
30 33
         <van-cell
@@ -32,6 +35,7 @@
32 35
           v-show="roomInfo.status === '0'"
33 36
           title="下架房源"
34 37
           icon="delete"
38
+          @click="$router.push({name: 'house.close', query: {roomId: roomInfo.id}})"
35 39
         />
36 40
 
37 41
         <van-cell
@@ -48,11 +52,27 @@
48 52
       </van-cell-group>
49 53
     </div>
50 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 70
 </template>
52 71
 
53 72
 <script>
54 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 77
 export default {
58 78
   components: {
@@ -60,6 +80,7 @@ export default {
60 80
     [CellGroup.name]: CellGroup,
61 81
     [Cell.name]: Cell,
62 82
     [Icon.name]: Icon,
83
+    [Field.name]: Field,
63 84
   },
64 85
   props: {
65 86
     roomInfo: {
@@ -67,13 +88,53 @@ export default {
67 88
       default: () => ({})
68 89
     }
69 90
   },
70
-  setup() {
91
+  setup(props) {
71 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 131
     return {
74
-      show
132
+      show,
133
+      phoneShow,
134
+      newOwnerTel,
135
+      handleRoomProtection,
136
+      handleAddOwnerTel,
75 137
     }
76 138
   }
77 139
 }
78 140
 </script>
79
-