审查视图

src/views/deploy/Tracker.vue 14.6 KB
xudada authored
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 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
<template>
    <div>
        <div>
            <el-descriptions class="margin-top" title="车辆信息" :column="3" :size="size" border>
                <el-descriptions-item>
                    <template slot="label">
                        <i class="el-icon-user"></i>
                        司机
                    </template>
                    {{carinfo.veOwnerName}}
                </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label">
                        <i class="el-icon-mobile-phone"></i>
                        手机号
                    </template>
                    {{carinfo.ownerInsideTel}}
                </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label">
                        <i class="el-icon-truck"></i>
                        车号
                    </template>
                    {{carinfo.domesticLisenceNo}}
                </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label">
                        <i class="el-icon-tickets"></i>
                        驾驶证有效期
                    </template>
                    <el-tag size="small">{{carinfo.veFactoryDate}}</el-tag>
                </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label">
                        <i class="el-icon-shopping-cart-full"></i>
                        车自重
                    </template>
                    {{carinfo.selfWt}}
                </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label">
                        <i class="el-icon-office-building"></i>
                        地址
                    </template>
                    {{carinfo.proposer}}
                </el-descriptions-item>
            </el-descriptions>
        </div>
        <div style="margin-top: 10px">
            <el-descriptions class="margin-top" title="派单列表" :column="3" :size="size" border></el-descriptions>
            <el-table
                    ref="multipleTable"
                    :data="tableData"
                    tooltip-effect="dark"
                    style="width: 100%"
                    >
                <el-table-column
                        prop="dispatch"
                        label="派单号"
                        width="150">
                </el-table-column>
                <el-table-column
                        prop="awba"
                        label="主单号"
                        width="105">
                </el-table-column>
                <el-table-column
                        prop="awbh"
                        label="分单号"
                        width="140">
                </el-table-column>
                <el-table-column
                        prop="deststation"
                        label="目的港"
                        show-overflow-tooltip>
                </el-table-column>
                <el-table-column
                        prop="pcs"
                        label="件数"
                        show-overflow-tooltip>
                </el-table-column>
                <el-table-column
                        prop="weight"
                        label="毛重"
                        show-overflow-tooltip>
                </el-table-column>
                <el-table-column
                        prop="vol"
                        label="体积"
                        show-overflow-tooltip>
                </el-table-column>
                <el-table-column
                        prop="charge"
                        label="应收"
                        show-overflow-tooltip>
                </el-table-column>
            </el-table>
        </div>
        <div style="margin-top: 10px">
            <el-descriptions class="margin-top" title="车辆跟踪" :column="3" :size="size" border>
                <template slot="extra">
                    <el-button type="primary" size="small" @click="addRecords">添加记录</el-button>
                </template>
            </el-descriptions>
            <div>
                <el-timeline :reverse="reverse">
                    <el-timeline-item
                            v-for="(activity, index) in activities"
                            :key="index"
                            :timestamp="activity.opertime">
                        <span style="color: #5BB75B;font-weight: bold">状态:</span>{{activity.status}}--<span style="color: #5BB75B;font-weight: bold">跟踪信息:</span>{{activity.info}}
                    </el-timeline-item>
                </el-timeline>
            </div>
        </div>
        <div>
            <el-dialog
                    title="添加车辆跟进信息"
                    :visible.sync="dialogVisible"
                    width="30%"
                    :before-close="handleClose">
                <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                    <el-form-item label="派单号" prop="dispatch">
                        <el-input v-model="ruleForm.dispatch" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="跟进状态" prop="status">
                        <el-select v-model="ruleForm.status" placeholder="请选择状态" style="width: 100%">
                            <el-option label="待装" value="待装"></el-option>
                            <el-option label="在途" value="在途"></el-option>
                            <el-option label="已到未卸" value="已到未卸"></el-option>
                            <el-option label="已完成" value="已完成"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="跟进信息" prop="info">
                        <el-input v-model="ruleForm.info"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
                        <el-button @click="resetForm('ruleForm')">取消</el-button>
                    </el-form-item>
                </el-form>
            </el-dialog>
        </div>
        <div>
            <el-descriptions class="margin-top" title="货物照片" :column="3" :size="size" border>
                <template slot="extra">
                    <el-upload
                            class="upload-demo"
                            action=""
                            :http-request="uploadRequest"
                            :on-change="handleChange"
                            :on-success="handleSuccess"
                            :on-error="handleError"
                            :before-upload="beforeUpload"
                            multiple
                            accept="image/*"
                    >
                        <el-button size="small" type="success">上传照片</el-button>
                    </el-upload>
                </template>
            </el-descriptions>
            <div>
                <el-image
                        v-for="(url, index) in validUrls"
                        :key="index"
                        :src="url"
                        style="width: 200px; height: 200px; margin: 10px;"
                        :preview-src-list="validUrls"
                />
            </div>
        </div>
    </div>
</template>
<script>
    import {list} from "../../api/road_verecord/verecord";
    import {
        selectListByDispatch,
        selectByDispatchList,
        addTracker,
        uploadGoodsImage,
        selectPicsByDispatch
    } from "../../api/consigner/vehicle";
    export default {
        data() {
            return{
                ruleForm:{
                    dispatch: "",
                    id: "",
                    info: "",
                    opertime: "",
                    status: ""
                },
                rules:{
                    status: [
                        { required: true, message: '请选择跟进状态', trigger: 'change' }
                    ],
                },
                reverse: false,
                activities: [],
                validUrls:[],
                routerinfo:{},
                carinfo:{},
                size: 'medium',
                tableData:[],
                dialogVisible: false
            }
        },
        methods:{
            getImgList(){
                selectPicsByDispatch({dispatch:this.routerinfo.dispatch}).then((response) => {
                    const res = response.data
                    if (res.code !== '200') {
                        return this.$message.error('获取消息收发记录,失败!')
                    }
                    if(res.data.urls && res.data.urls.trim() !== ''){
                       this.validUrls= res.data.urls
                            .split(',')
                            .filter(url => url.trim() !== '');
                    }
                }).catch(error => {
                    // 关闭加载
                    this.$message.error(error.toString())
                })
            },

            beforeUpload(file) {
                const isImage = file.type.startsWith('image/');
                if (!isImage) {
                    this.$message.error('只能上传图片文件!');
                }
                return isImage;
            },
            handleChange(file, fileList) {
                console.log(file, fileList);
            },
            handleSuccess(response, file, fileList) {
                console.log('Upload successful:', response);
            },
            handleError(err, file, fileList) {
                console.error('Upload failed:', err);
            },
            uploadRequest({ file, onSuccess, onError }) {
                const formData = new FormData();
                formData.append('file', file);
                formData.append('dispatch',this.routerinfo.dispatch);
                uploadGoodsImage(formData).then((response) => {
                    const res = response.data
                    if (res.code !== '200') {
                        return this.$message.error(res.msg);
                    }
                    this.$message.success(res.msg);
                    this.getImgList();
                    onSuccess(response.data); // 调用 onSuccess 回调通知上传成功
                }).catch(error => {
                    // 关闭加载
                    this.$message.error(error.toString())
                    onError(error); // 调用 onError 回调通知上传失败
                })
                },
            //添加跟踪记录
            addRecords(){
                this.ruleForm.dispatch=this.routerinfo.dispatch;
                this.dialogVisible=true;
            },
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        addTracker(this.ruleForm).then((response) => {
                            const res = response.data
                            if (res.code !== '200') {
                                return this.$message.error('跟进信息添加,失败!')
                            }
                            this.$message.success('跟进信息添加,成功!')
                            this.dialogVisible = false;
                            this.getRecords();
                        }).catch(error => {
                            // 关闭加载
                            this.$message.warning('跟进信息添加,失败!')
                        })
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            resetForm(formName) {
                this.dialogVisible = false;
                this.$refs[formName].resetFields();
            },
            //查询跟踪记录
            getRecords(){
                selectByDispatchList({dispatch:this.routerinfo.dispatch}).then((response) => {
                    const res = response.data
                    if (res.code !== '200') {
                        return this.$message.error('获取消息收发记录,失败!')
                    }
                    // 获取列表数据
                    this.activities=res.data;
                }).catch(error => {
                    // 关闭加载
                    this.$message.error(error.toString())
                })
            },
            //查询派单列表
            getLists() {
                selectListByDispatch({dispatch:this.routerinfo.dispatch}).then((response) => {
                    const res = response.data
                    if (res.code !== '200') {
                        return this.$message.error('获取消息收发记录,失败!')
                    }
                    // 获取列表数据
                    this.tableData=res.data;
                }).catch(error => {
                    // 关闭加载
                    this.$message.error(error.toString())
                })
            },
            getDefault(){
                if(this.$route.query!=null){
                    this.routerinfo=this.$route.query.jilu;
                }
            },
            //查询车辆信息
            getReCord() {
                let para = {
                    pageSize: 1,
                    limitSize: 10,
                    trailerFrameNo: this.$route.query.jilu.licenseno,
                    veState: '',
                    veClassFlag: '',
                    userId: ''
                };
                list(para).then((res) => {
                    if(res.data.data.list.length!==0){
                        this.carinfo = res.data.data.list[0];
                    }else{
                        this.$message.warning('无对应车辆信息!')
                    }
                }).catch((error) => {
                    this.$message.warning('车辆查询,失败!')
                });
            },
            getMess(){
                if(this.routerinfo!=null && this.routerinfo.length!==0){
                    this.getReCord();
                    this.getLists();
                }
            },
            handleClose(done) {
                this.$confirm('确认关闭?')
                    .then(_ => {
                        done();
                    })
                    .catch(_ => {});
            },

        },
        activated() {
            this.getDefault();
            this.getMess();
            this.getRecords();
            this.getImgList();
        }
    }
</script>