queenwuli
2021-01-19 a3a48da30bdea132d2bfbb47fa2ccf83f1937c45
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
49
50
51
52
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
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
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<template>
    <view class="font-14 container">
        <view class="content-row">
            <view class="input-group-cloume">
                <textarea v-model="formData.content" maxlength="300" placeholder="请填写跟进记录" placeholder-class='placeholder' />
            </view>
            <view class="img-wrap">
                <image v-for="(item, index) in formData.albums" :src="item.img" @click="editImg(index)"></image>
                <view class="add-img" @click="showUploadImage">
                    <text class="iconfont iconxiangji"></text>
                </view>
            </view>
        </view>
        <view class="input-group-row">
            <text class="label">客户</text>
            <navigator url="../../member/selectCustomer" hover-class="none" class="gray right-text">
                <text>{{formData.vipName || '请选择'}}</text>
                <text class="iconfont iconarrow-backimg"></text>
            </navigator>
        </view>
        <view class="input-group-row">
            <text class="label">相关订单</text>
            <navigator url="./orderList" hover-class="none" class="gray right-text flex align-center justify-end">
                <text class="ellipsis" v-if="formData.orderId">{{orderName}}</text>
                <text class="ellipsis" v-else-if="formData.serviceId">{{serviceName}}</text>
                <text v-else>请选择</text>
                <text class="iconfont iconarrow-backimg"></text>
            </navigator>
        </view>
        <view class="input-group-row">
            <text class="label">下次跟进提醒</text>
            <view class="right-text gray">
                <text @click="showTime()">{{formData.nextNotifyTime || '请选择'}}</text>
                <text class="iconfont iconarrow-backimg"></text>
            </view>
        </view>
        <view class="input-group-row">
            <text class="label">设置可见范围</text>
            <view class="right-text">
                <radio-group name="visible" @change="privacyChange">
                    <label><radio value="1" color="#518EFF"  class="radio" :checked="formData.visible==1"/>公开</label>
                    <label><radio value="2" color="#518EFF" class="radio" :checked="formData.visible==2"/>仅自己可见</label>
                </radio-group>
            </view>
        </view>
        <button class="blue-btn sticky-footer" :disabled="isDisabled" @click="submit">提交跟进</button>
        <date-time-picker ref='date-time' :startDate="startDate" type='datetime' @change='dateTimeChange'></date-time-picker>
    </view>
</template>
 
<script>
    import imageUploadUtils from '../../../common/jssdk/uploadImg.js'
    import DateTimePicker from '../../../components/bory-dateTimePicker/bory-dateTimePicker.vue'
    export default{
        components:{
            DateTimePicker
        },
        data(){
            return{
                formData: {
                    content: '',
                    nextNotifyTime: '',
                    visible: 1,
                    vipId: '',
                    vipName: '',
                    orderId: '',
                    serviceId: '',
                    albums: []
                },
                orderName: '',
                serviceName:'',
                isDisabled: false
            }
        },
        computed:{
            startDate(){
                return this.$utils.formmatTime('YY-mm-dd')
            }
        },
        onLoad() {
            uni.$on('orderChange', (data) => {
                // type: 0 订单, 1服务单
                if(data.type==0){
                    this.formData.orderId = data.id;
                    this.formData.serviceId = '';
                    this.loadOrderDetail();
                }else{
                    this.formData.serviceId = data.id;
                    this.formData.orderId = '';
                    this.loadServiceOrderDetail();
                }
                this.formData.vipName = data.vipName;
                this.formData.vipId = data.vipId;
            })
        },
        methods:{
            showTime () {
                this.$refs['date-time'].show();
            },
            dateTimeChange(val) {
                this.formData.nextNotifyTime = val;
            },
            privacyChange(e){
                this.formData.visible = e.detail.value;
            },
            setData(selectItem){
                let data = selectItem[0];
                this.formData.vipId = data.id;
                this.formData.vipName = data.vipName;
            },
            // 图片上传
            showUploadImage(){
                if(this.formData.albums.length >= 9){
                    this.$toast.info('最多只能上传9张图片');
                    return;
                }
                imageUploadUtils.show((res) => {
                    this.formData.albums.push({img: res});
                })
            },
            // 图片编辑
            editImg(index){
                imageUploadUtils.show((res) => {
                    this.formData.albums[index].img = res;
                })
            },
            loadOrderDetail(){
                this.$httpUtils.request('/api/order/findOrderDetail/'+this.formData.orderId).then((res) => {
                    if(res.status == 200){
                        let result = res.mapInfo.orderDetail;
                        this.orderName = result.items.length?result.items[0].goodsName:'';
                    }
                })
            },
            loadServiceOrderDetail(){
                this.$httpUtils.request('/api/serviceOrder/findServiceOrderDetail/'+this.formData.serviceId).then((res) => {
                    if(res.status == 200){
                        let result = res.mapInfo.detail;
                        this.serviceName = result.items.length?result.items[0].name:'';
                    }
                })
            },
            valid(){
                const {content, vipId, orderId, serviceId} = this.formData;
                if(!content){
                    this.$toast.info('请填写跟进记录');
                    return false
                }
                if(!vipId){
                    this.$toast.info('请选择客户');
                    return false
                }
                if(!orderId && !serviceId){
                    this.$toast.info('请选择相关订单');
                    return false
                }
            },
            submit(){
                if(this.valid() === false){
                    return;
                }
                this.isDisabled = true;
                this.$httpUtils.request('/api/followup/addFollowup', this.formData, 'POST').then((res) => {
                    if(res.status == 200){
                        uni.navigateBack()
                    }
                    this.$toast.info(res.info)
                    this.isDisabled = false
                }).catch((err) => {
                    this.isDisabled = false
                })
            }
        }
    }
</script>
 
<style>
    .container{
        padding: 0 10px;
    }
    .content-row{
        border-bottom: 1px solid #EDEAF4;
        padding: 15px 0;
    }
    
    .input-group-cloume uni-textarea{
        border: 0;
        height: 58px;
        padding: 0;
    }
    .ellipsis{
        max-width: 200px;
        overflow: hidden;
        text-overflow:ellipsis;
        white-space: nowrap;
    }
    .img-wrap{
        display: flex;
        flex-wrap: wrap;
        margin-left: -5px;
        margin-right: -5px;
    }
    .img-wrap image{
        width: 50px;
        height: 50px;
        margin: 5px;
    }
    .add-img{
        display: flex;
        align-items: center;
        justify-content: center;
        width: 50px;
        height: 50px;
        color: #a5abaf;
        border: 1px solid #EDEAF4;
        border-radius: 2px;
        box-sizing: border-box;
        margin: 5px;
    }
    .add-img .iconfont{
        font-size: 22px;
    }
</style>