审查视图

src/views/consigner/consigner.vue 18.1 KB
1 2 3 4 5 6
<template>
    <section>
        <!--工具条-->
        <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
            <el-form :inline="true" :model="filters">
                <el-form-item>
7 8 9
                    <el-input size="small" v-model="filters.companyName" placeholder="公司名称">
                        <template slot="prepend">公司名称</template>
                    </el-input>
10 11
                </el-form-item>
                <el-form-item>
12
                    <el-button type="warning" style="width:150px"  icon="el-icon-plus" v-on:click="getConsignee()">查&emsp;&emsp;询</el-button>
13 14
                </el-form-item>
                <el-form-item>
15
                    <el-button type="primary" style="width:150px"  icon="el-icon-plus" @click="companyAdd">新&emsp;&emsp;增</el-button>
16 17 18 19 20
                </el-form-item>
            </el-form>
        </el-col>

        <!--列表-->
21 22 23
        <el-table :data="consignerList" highlight-current-row v-loading="listLoading" @selection-change="selsChange"
                  :header-cell-style="{background:'#6F8294',color:'#FFFFFF'}"
                  style="border-radius: 10px 10px 0px 0px;line-height: 25px;" size="small">
24 25 26 27
            <el-table-column type="selection" width="55">
            </el-table-column>
            <el-table-column label="序号" type="index">
            </el-table-column>
shenhailong authored
28
            <el-table-column prop="companyName" label="收货人公司"  >
29
            </el-table-column>
shenhailong authored
30
            <el-table-column prop="conCity" label="收货人城市"  >
31
            </el-table-column>
shenhailong authored
32
            <el-table-column prop="country" label="收货人国家代码"  >
33
            </el-table-column>
shenhailong authored
34
            <el-table-column prop="conPhone" label="收货人电话"  >
35
            </el-table-column>
shenhailong authored
36 37
            <!--            <el-table-column prop="enterprise" label="收货人企业代码"  >-->
            <!--            </el-table-column>-->
38 39
            <el-table-column label="操作" min-width="150">
                <template slot-scope="scope">
40 41
                    <el-button type="primary" icon="el-icon-edit" size="mini" @click="handleEdit(scope.$index, scope.row)">编&emsp;&emsp;辑</el-button>
                    <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDel(scope.$index, scope.row)">删&emsp;&emsp;除</el-button>
42 43 44 45
                </template>
            </el-table-column>
        </el-table>
        <!--编辑界面-->
shenhailong authored
46 47
        <el-dialog :title="dialogMap[dialogStatus]" :visible.sync="conerVisible" :close-on-click-modal="false" width="60%" text-align="center" tyle="margin-top: -20px">
            <el-form :model="conerForm"  :rules="conerRules" ref="conerForm" label-width="145px" style="margin-top: -10px">
48
                <el-row>
shenhailong authored
49
                    <el-col :span="4" style="display: none">
50
                        <el-form-item label="ID">
shenhailong authored
51
                            <span>{{conerForm.id}}</span>
52 53 54 55 56 57
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="8" style="margin-right: 20px">
                        <el-form-item label="" prop="companyName">
shenhailong authored
58
                            <el-input v-model="conerForm.companyName" auto-complete="on" placeholder="公司" style="width:300px" size="small">
59 60 61 62 63 64
                                <template  slot="prepend" >公司</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="" prop="conAddress">
shenhailong authored
65
                            <el-input v-model="conerForm.conAddress" auto-complete="on" placeholder="地址" style="width:300px" size="small">
66 67 68 69 70 71 72 73
                                <template  slot="prepend" >地址</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="8" style="margin-right: 20px">
                        <el-form-item label="" prop="conPhone">
shenhailong authored
74
                            <el-input v-model="conerForm.conPhone" auto-complete="on" placeholder="电话" style="width:300px" size="small">
75 76 77 78 79 80
                                <template  slot="prepend" >电话</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="" prop="conFax">
shenhailong authored
81
                            <el-input v-model="conerForm.conFax" auto-complete="on" placeholder="传真" style="width:300px" size="small">
82 83 84 85 86 87 88 89 90
                                <template  slot="prepend" >传真</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row>
                    <el-col :span="8" style="margin-right: 20px">
                        <el-form-item label="" prop="conPostcode">
shenhailong authored
91
                            <el-input v-model="conerForm.conPostcode" auto-complete="on" placeholder="邮编" style="width:300px" size="small">
92 93 94 95 96 97
                                <template  slot="prepend" >邮编</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="" prop="conCity">
shenhailong authored
98
                            <el-input v-model="conerForm.conCity" auto-complete="on" placeholder="城市" style="width:300px" size="small">
99 100 101 102 103 104 105 106
                                <template  slot="prepend" >城市</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="8" style="margin-right: 20px">
                        <el-form-item label="" prop="country">
shenhailong authored
107
                            <el-input v-model="conerForm.country" auto-complete="on" placeholder="国家代码" style="width:300px" size="small">
108 109 110 111 112 113
                                <template  slot="prepend" >国家代码</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="" prop="conName">
shenhailong authored
114 115
                            <el-input v-model="conerForm.conName" auto-complete="on" placeholder="收货人名称" style="width:300px" size="small">
                                <template  slot="prepend" >收货人名称</template>
116 117 118 119 120 121 122
                            </el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="8">
                        <el-form-item label="" prop="conAeo">
shenhailong authored
123 124
                            <el-input v-model="conerForm.conAeo" auto-complete="on" placeholder="收货人AEO" style="width:300px" size="small">
                                <template  slot="prepend" >收货人AEO</template>
125 126 127 128
                            </el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
129
            </el-form>
130
            <div slot="footer" class="dialog-footer" style="text-align: center">
shenhailong authored
131 132
                <el-button @click.native="conerVisible = false" style="width: 120px;background-color: #6F8294;color: #ffffff" size="medium" >取消</el-button>
                <el-button type="success" size="medium" style="width: 120px" @click.native="dialogStatus ==='create'? addSubmit():editSubmit()">保存</el-button>
133 134 135 136 137 138 139
            </div>
        </el-dialog>
    </section>
</template>

<script>
    import { getList, remove, add, edit} from '../../api/consigner/consigner';
140
    import {loginedUserInfo} from "../../api/user";
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

    export default {
        data() {
            return {

                options: [{
                    value: 'USCI',
                    label: 'USCI'
                }, {
                    value: 'OC',
                    label: 'OC'
                }, {
                    value: '9999',
                    label: '9999'
                }],

                filters: {
                    companyName: ''
                },
                consignerList: [],
                total: 0,
                pageSize: 1,
                limitSize: 5,
                listLoading: false,
                //编辑界面是否显示
shenhailong authored
166 167
                conerVisible: false,
                dialogStatus: undefined,
168
                editLoading: false,
shenhailong authored
169 170 171 172 173
                dialogMap: {
                    update: '编辑',
                    create: '新增'
                },
                conerRules: {
174 175 176 177 178 179 180 181 182 183 184 185 186 187
                    companyName: [
                        { required: true, message: '不能为空!!!', trigger: 'blur' }
                    ],
                    conName: [
                        { required: true, message: '不能为空!!!', trigger: 'blur' }
                    ],
                    country: [
                        { required: true, message: '不能为空!!!', trigger: 'blur' }
                    ],
                    enterprise: [
                        { required: true, message: '不能为空!!!', trigger: 'blur' }
                    ],
                    conCity: [
                        { required: true, message: '不能为空!!!', trigger: 'blur' }
188 189 190
                    ],
                    conAddress: [
                        { required: true, message: '不能为空!!!', trigger: 'blur' }
shenhailong authored
191 192 193 194 195 196 197 198 199 200 201 202
                    ],
                    conPhone: [
                        { required: true, message: '手机号不能为空', trigger: 'blur' },
                        { type: 'number', message: '手机号格式不正确', trigger: 'blur',
                            transform(value){
                                var phone = 11 && /^((13|14|15|16|17|18|19)[0-9]{1}\d{8})$/
                                if (!phone.test(value)){
                                    return false;
                                }else {
                                    return Number(value);
                                }
                            }}
203 204
                    ]
                },
shenhailong authored
205 206
                //实体数据
                conerForm: {
207 208 209 210 211 212 213 214 215 216 217
                    id:'',
                    companyName: '',
                    conAddress: '',
                    conAeo: '',
                    conCity: '',
                    conFax: '',
                    conName: '',
                    conPhone: '',
                    conPostcode: '',
                    country: '',
                    enterprise: '',
shenhailong authored
218 219 220
                    ent: '',
                    enterpriseId:'',
                    userId:''
221 222 223 224
                },
            }
        },
        mounted() {
shenhailong authored
225
            this.getConsignee();
226 227 228 229

        },
        methods: {
shenhailong authored
230 231
            //获取收货人列表
            getConsignee() {
232 233 234
                let para = {
                    pageSize: this.pageSize,
                    limitSize: this.limitSize,
shenhailong authored
235
                    companyName: this.filters.companyName,
236
                    enterpriseId: loginedUserInfo().companyId
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
                };
                this.listLoading = true;
                getList(para).then((res) => {
                    this.total = res.data.data.total;
                    this.consignerList = res.data.data.list;
                    this.listLoading = false;
                }).catch((error) => {
                    this.listLoading = false;
                    if(null!= error.response && error.response!==undefined){
                        let status= error.response.status;
                        let msg = error.response.statusText;
                        alert(status+msg);
                    }else {
                        alert(error);
                    }

                });

            },
            //删除
            handleDel: function (index, row) {
                this.$confirm('确认删除该记录吗?', '提示', {
                    type: 'warning'
                }).then(() => {
                    this.listLoading = true;
                    let para = {id: row.id };
                    remove(para).then((res) => {
                        if (res.data.code == 200){
                            this.listLoading = false;
                            this.$message({
                                message: '删除成功',
                                type: 'success'
                            });
shenhailong authored
270
                            this.getConsignee();
271 272 273 274 275 276
                        }else {
                            this.listLoading = false;
                            this.$message({
                                message: '删除失败',
                                type: 'error'
                            });
shenhailong authored
277
                            this.getConsignee();
278 279 280 281 282 283 284 285 286 287 288 289 290 291
                        }

                    }).catch((error) => {
                        this.listLoading = false;
                        alert(error);
                    });
                }).catch();
            },
            /**
             * 显示编辑界面
             * @param index
             * @param row 为这行的数据对象
             */
            handleEdit: function (index, row) {
shenhailong authored
292 293 294 295 296
                this.dialogStatus = 'update'
                this.conerVisible = true;
                this.conerForm = Object.assign({}, row);
                // this.getConsignee();
                this.userId()
297 298 299
            },
            //编辑
            editSubmit: function () {
shenhailong authored
300
                this.$refs.conerForm.validate((valid) => {
301 302 303
                    if (valid) {
                        this.$confirm('确认提交吗?', '提示', {}).then(() => {
                            this.editLoading = true;
shenhailong authored
304
                            let para = Object.assign({}, this.conerForm);
305 306
                            this.editLoading = true;
                            edit(para).then((res) => {
shenhailong authored
307
                                if (res.data.code == '200'){
308 309 310 311
                                    this.$message({
                                        message: '提交成功',
                                        type: 'success'
                                    });
shenhailong authored
312 313 314
                                    this.$refs['conerForm'].resetFields();
                                    this.conerVisible = false;
                                    this.getConsignee();
315 316 317 318 319 320 321 322 323 324 325 326 327 328
                                }else {
                                    this.$message({
                                        message: '提交失败',
                                        type: 'error'
                                    });
                                }

                            }).catch(error => alert(error));
                        });
                    }
                });
            },
            //显示新增界面,每次点开初始化数据
            companyAdd: function () {
shenhailong authored
329 330 331 332
                this.dialogStatus = 'create'
                this.conerVisible = true;
                this.tableForm();
                this.userId();
333 334 335
            },
            //新增
            addSubmit: function () {
shenhailong authored
336
                this.$refs.conerForm.validate((valid) => {
337 338 339 340
                    if (valid) {
                        this.$confirm('确认提交吗?', '提示', {}).then(() => {
                            //NProgress.start();
                            this.listLoading = true;
shenhailong authored
341
                            let para = Object.assign({}, this.conerForm);
342
                            add(para).then((res) => {
shenhailong authored
343
                                if (res.data.code == '200'){
344 345 346 347 348
                                    //NProgress.done();
                                    this.$message({
                                        message: '提交成功',
                                        type: 'success'
                                    });
shenhailong authored
349 350 351
                                    this.$refs['conerForm'].resetFields();
                                    this.conerVisible = false;
                                    this.getConsignee();
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
                                }else {
                                    this.$message({
                                        message: '提交失败',
                                        type: 'error'
                                    });
                                }
                            }).catch(error => alert(error));
                        });
                    }
                });
            },
            selsChange: function (sels) {
                this.sels = sels;
            },
            //批量删除
            batchRemove: function () {
                var ids = this.sels.map(item => item.id).toString();
                this.$confirm('确认删除选中记录吗?', '提示', {
                    type: 'warning'
                }).then(() => {
                    this.listLoading = true;
                    //NProgress.start();
                    let para = { ids: ids };
                    batchRemove(para).then((res) => {
                        this.listLoading = false;
                        //NProgress.done();
                        this.$message({
                            message: '删除成功',
                            type: 'success'
                        });
shenhailong authored
382
                        this.getConsignee();
383 384 385 386
                    });
                }).catch(() => {

                });
shenhailong authored
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406
            },
            // 实体重置
            tableForm(){
                this.conerForm =  {
                    id:'',
                    companyName: '',
                    conAddress: '',
                    conAeo: '',
                    conCity: '',
                    conFax: '',
                    conName: '',
                    conPhone: '',
                    conPostcode: '',
                    country: '',
                    enterprise: '',
                    ent: ''
                }
            },
            //设置 用户id  企业id
            userId(){
407 408
                this.conerForm.userId = loginedUserInfo().userId;
                this.conerForm.enterpriseId = loginedUserInfo().companyId;
409 410 411 412
            }
        },

    }
413
</script>