审查视图

src/views/consigner/consignee.vue 19.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
                    <el-input  v-model="filters.companyName" placeholder="收货人公司名称英文" clearable>
8 9
                        <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
        <el-table :data="consignerList" highlight-current-row v-loading="listLoading" @selection-change="selsChange"
22
                  @row-dblclick="handleCurrentChange"
23
                  :header-cell-style="{background:'#6F8294',color:'#FFFFFF'}"
24
                  style="border-radius: 10px 10px 0px 0px;line-height: 25px;" >
25 26 27 28
            <el-table-column type="selection" width="55">
            </el-table-column>
            <el-table-column label="序号" type="index">
            </el-table-column>
29
            <el-table-column prop="conName" label="公司中文"  show-overflow-tooltip>
30
            </el-table-column>
31
            <el-table-column prop="companyName" label="公司名称"  >
32
            </el-table-column>
33
            <el-table-column prop="conCity" label="城市"  >
34
            </el-table-column>
35
            <el-table-column prop="country" label="国家代码"  >
36
            </el-table-column>
37
            <el-table-column prop="conPhone" label="电话"  >
38
            </el-table-column>
shenhailong authored
39 40
<!--            <el-table-column prop="enterprise" label="收货人企业代码"  >-->
<!--            </el-table-column>-->
41 42
            <el-table-column label="操作" min-width="150">
                <template slot-scope="scope">
小范 authored
43 44
                    <el-button type="primary" icon="el-icon-edit" size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
                    <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDel(scope.$index, scope.row)">删除</el-button>
45 46 47
                </template>
            </el-table-column>
        </el-table>
48 49 50 51 52 53 54 55 56 57 58
        <el-row style="margin-top: 10px" class="toolbar">
            <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChanges"
                    :current-page="filters.pageSize"
                    :page-size="filters.limitSize"
                    :page-sizes="[10, 50, 100, 500]"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total">
            </el-pagination>
        </el-row>
59
        <!--编辑界面-->
60
        <el-dialog :title="dialogMap[dialogStatus]" :visible.sync="coneeVisible" :append-to-body="true" width="80%" text-align="center" tyle="margin-top: -20px">
shenhailong authored
61
            <el-form :model="coneeForm"  :rules="coneeRules" ref="coneeForm" label-width="145px" style="margin-top: -10px">
62
                <el-row>
shenhailong authored
63
                    <el-col :span="4" style="display: none">
64
                        <el-form-item label="ID">
shenhailong authored
65
                            <span>{{coneeForm.id}}</span>
66 67 68 69 70 71
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="8" style="margin-right: 20px">
                        <el-form-item label="" prop="companyName">
72
                            <el-input v-model="coneeForm.companyName" auto-complete="on" placeholder="公司" style="width:300px" >
73 74 75 76
                                <template  slot="prepend" >公司</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
77
                    <el-col :offset="1" :span="8">
78
                        <el-form-item label="" prop="conAddress">
79
                            <el-input v-model="coneeForm.conAddress" auto-complete="on" placeholder="地址" style="width:300px" >
80 81 82 83 84 85 86 87
                                <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">
88
                            <el-input v-model="coneeForm.conPhone" auto-complete="on" placeholder="电话" style="width:300px" >
89 90 91 92
                                <template  slot="prepend" >电话</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
93
                    <el-col :offset="1"  :span="8">
94
                        <el-form-item label="" prop="conFax">
95
                            <el-input v-model="coneeForm.conFax" auto-complete="on" placeholder="传真" style="width:300px" >
96 97 98 99 100 101 102 103 104
                                <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">
105
                            <el-input v-model="coneeForm.conPostcode" auto-complete="on" placeholder="邮编" style="width:300px" >
106 107 108 109
                                <template  slot="prepend" >邮编</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
110
                    <el-col :offset="1"  :span="8">
111
                        <el-form-item label="" prop="conCity">
112
                            <el-input v-model="coneeForm.conCity" auto-complete="on" placeholder="城市" style="width:300px" >
113 114 115 116 117 118 119 120
                                <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">
121
                            <el-input v-model="coneeForm.country" auto-complete="on" placeholder="国家代码" style="width:300px" >
122 123 124 125
                                <template  slot="prepend" >国家代码</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
126
                    <el-col :offset="1"  :span="8">
127
                        <el-form-item label="" prop="conName">
128
                            <el-input v-model="coneeForm.conName" auto-complete="on" placeholder="收货人名称" style="width:300px" >
129
                                <template  slot="prepend" >中文名称</template>
130 131 132 133 134
                            </el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
135
                    <el-col :span="8" style="margin-right: 20px">
136
                        <el-form-item label="" prop="conAeo">
137
                            <el-input v-model="coneeForm.conAeo" auto-complete="on" placeholder="收货人AEO" style="width:300px">
138
                                <template  slot="prepend" >AEO编码</template>
139 140 141
                            </el-input>
                        </el-form-item>
                    </el-col>
142
                    <el-col :offset="1"  :span="8">
143 144 145 146 147 148
                        <el-form-item label="" prop="enterprise">
                            <el-input v-model="coneeForm.enterprise" auto-complete="on" placeholder="企业编码" style="width:300px">
                                <template  slot="prepend" >企业编码</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
149
                </el-row>
150
            </el-form>
151
            <div slot="footer" class="dialog-footer" style="text-align: center">
shenhailong authored
152 153
                <el-button @click.native="coneeVisible = 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>
154 155 156 157 158 159 160
            </div>
        </el-dialog>
    </section>
</template>

<script>
    import { getList, remove, add, edit} from '../../api/consigner/consignee';
161 162

    import {loginedUserInfo} from "../../api/user";
163 164

    export default {
小范 authored
165 166 167 168
        name: "Consignee",
        props: [

        ],
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
        data() {
            return {

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

                filters: {
184 185 186 187 188
                    companyName: '',
                    // 每页大小
                    limitSize: 10,
                    // 当前页数
                    pageSize: 1,
189 190 191 192 193
                },
                consignerList: [],
                total: 0,
                listLoading: false,
                //编辑界面是否显示
shenhailong authored
194 195
                coneeVisible: false,
                dialogStatus: undefined,
196
                editLoading: false,
shenhailong authored
197 198 199 200 201
                dialogMap: {
                    update: '编辑',
                    create: '新增'
                },
                coneeRules: {
202 203 204 205 206 207 208 209 210 211 212
                    companyName: [
                        { required: true, message: '不能为空!!!', trigger: 'blur' }
                    ],
                    conName: [
                        { required: true, message: '不能为空!!!', trigger: 'blur' }
                    ],
                    country: [
                        { required: true, message: '不能为空!!!', trigger: 'blur' }
                    ],
                    conCity: [
                        { required: true, message: '不能为空!!!', trigger: 'blur' }
213 214 215
                    ],
                    conAddress: [
                        { required: true, message: '不能为空!!!', trigger: 'blur' }
shenhailong authored
216 217
                    ],
                    conPhone: [
218
                        { pattern: /^$|^\d{1,20}$/, message: '请输入正确的电话号码格式,只支持20位以内的数字' }
219 220
                    ]
                },
shenhailong authored
221 222
                //实体数据
                coneeForm: {
223 224 225 226 227 228 229 230 231 232 233
                    id:'',
                    companyName: '',
                    conAddress: '',
                    conAeo: '',
                    conCity: '',
                    conFax: '',
                    conName: '',
                    conPhone: '',
                    conPostcode: '',
                    country: '',
                    enterprise: '',
shenhailong authored
234 235 236
                    ent: '',
                    enterpriseId:'',
                    userId:''
237 238 239 240
                },
            }
        },
        mounted() {
shenhailong authored
241
            this.getConsignee();
242 243 244

        },
        methods: {
245 246 247 248 249 250 251 252
            handleSizeChange(val) {
                this.filters.limitSize = val
                this.getConsignee()
            },
            handleCurrentChanges(val) {
                this.filters.pageSize = val
                this.getConsignee()
            },
253
            //获取收货人列表
shenhailong authored
254
            getConsignee() {
255
                let para = {
256 257
                    pageSize: this.filters.pageSize,
                    limitSize: this.filters.limitSize,
shenhailong authored
258
                    companyName: this.filters.companyName,
259
                    enterpriseId: loginedUserInfo().companyId
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
                };
                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);
                    }

                });

            },
279 280 281
            consignee_data(){
                (this.filters.companyName = '')
            },
282 283 284 285 286 287 288 289 290 291 292 293 294 295
            //删除
            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
296
                            this.getConsignee();
297 298 299 300 301 302
                        }else {
                            this.listLoading = false;
                            this.$message({
                                message: '删除失败',
                                type: 'error'
                            });
shenhailong authored
303
                            this.getConsignee();
304 305 306 307 308 309 310 311 312 313 314 315 316 317
                        }

                    }).catch((error) => {
                        this.listLoading = false;
                        alert(error);
                    });
                }).catch();
            },
            /**
             * 显示编辑界面
             * @param index
             * @param row 为这行的数据对象
             */
            handleEdit: function (index, row) {
shenhailong authored
318 319 320 321 322
                this.dialogStatus = 'update'
                this.coneeVisible = true;
                this.coneeForm = Object.assign({}, row);
                // this.getConsignee();
                this.userId()
323 324 325
            },
            //编辑
            editSubmit: function () {
shenhailong authored
326
                this.$refs.coneeForm.validate((valid) => {
327 328 329
                    if (valid) {
                        this.$confirm('确认提交吗?', '提示', {}).then(() => {
                            this.editLoading = true;
shenhailong authored
330
                            let para = Object.assign({}, this.coneeForm);
331 332
                            this.editLoading = true;
                            edit(para).then((res) => {
shenhailong authored
333
                                if (res.data.code == '200'){
334 335 336 337
                                    this.$message({
                                        message: '提交成功',
                                        type: 'success'
                                    });
shenhailong authored
338 339 340
                                    this.$refs['coneeForm'].resetFields();
                                    this.coneeVisible = false;
                                    this.getConsignee();
341 342 343 344 345 346 347 348 349 350 351 352 353 354
                                }else {
                                    this.$message({
                                        message: '提交失败',
                                        type: 'error'
                                    });
                                }

                            }).catch(error => alert(error));
                        });
                    }
                });
            },
            //显示新增界面,每次点开初始化数据
            companyAdd: function () {
shenhailong authored
355 356 357 358
                this.dialogStatus = 'create'
                this.coneeVisible = true;
                this.tableForm();
                this.userId();
359 360 361
            },
            //新增
            addSubmit: function () {
shenhailong authored
362
                this.$refs.coneeForm.validate((valid) => {
363 364 365 366
                    if (valid) {
                        this.$confirm('确认提交吗?', '提示', {}).then(() => {
                            //NProgress.start();
                            this.listLoading = true;
shenhailong authored
367
                            let para = Object.assign({}, this.coneeForm);
368
                            add(para).then((res) => {
shenhailong authored
369
                                if (res.data.code == '200'){
370 371 372 373 374
                                    //NProgress.done();
                                    this.$message({
                                        message: '提交成功',
                                        type: 'success'
                                    });
shenhailong authored
375 376 377
                                    this.$refs['coneeForm'].resetFields();
                                    this.coneeVisible = false;
                                    this.getConsignee();
378 379 380 381 382 383 384 385 386 387 388 389 390 391
                                }else {
                                    this.$message({
                                        message: '提交失败',
                                        type: 'error'
                                    });
                                }
                            }).catch(error => alert(error));
                        });
                    }
                });
            },
            selsChange: function (sels) {
                this.sels = sels;
            },
小范 authored
392 393 394
            handleCurrentChange:function(currentRow,oldCurrentRow){
                this.$emit('consigeerow',currentRow)
            },
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410
            //批量删除
            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
411
                        this.getConsignee();
412 413 414 415
                    });
                }).catch(() => {

                });
shenhailong authored
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435
            },
            // 实体重置
            tableForm(){
               this.coneeForm =  {
                    id:'',
                    companyName: '',
                    conAddress: '',
                    conAeo: '',
                    conCity: '',
                    conFax: '',
                    conName: '',
                    conPhone: '',
                    conPostcode: '',
                    country: '',
                    enterprise: '',
                    ent: ''
                }
            },
            //设置 用户id  企业id
            userId(){
436 437
                this.coneeForm.userId = loginedUserInfo().userId;
                this.coneeForm.enterpriseId = loginedUserInfo().companyId;
438 439 440 441
            }
        },

    }
442
</script>