审查视图

src/views/empt/Location.vue 20.4 KB
朱兆平 authored
1 2 3 4 5 6 7 8 9
<template>
    <section>
        <!--工具条-->
        <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
            <el-form :inline="true" :model="filters">
                <el-form-item>
                    <el-input v-model="filters.processName" placeholder="公寓名称"></el-input>
                </el-form-item>
                <el-form-item>
朱兆平 authored
10
                    <el-button type="primary" v-on:click="getList()">查询</el-button>
朱兆平 authored
11 12 13 14 15 16 17
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="handleAdd()">新增</el-button>
                </el-form-item>
            </el-form>
        </el-col>
朱兆平 authored
18 19 20 21 22 23 24 25 26 27 28 29 30
        <el-table
                :data="locationList"
                style="width: 100%;margin-bottom: 20px;"
                row-key="id"
                border
                :row-class-name="tableRowClassName"
                default-expand-all
                :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
            <el-table-column
                    prop="adrname"
                    label="名称"
                    sortable
                    width="300">
朱兆平 authored
31
            </el-table-column>
朱兆平 authored
32 33 34 35 36 37
            <el-table-column
                    prop="type"
                    label="类型"
                    align="center"
                    :formatter="formatType"
                    width="100">
朱兆平 authored
38 39 40 41
            </el-table-column>
            <el-table-column :label="$t('table.actions')" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                    <el-button type="primary" size="small" @click="handleUpdate(scope.row)">快速编辑</el-button>
朱兆平 authored
42
                    <el-button type="primary" size="small" @click="handleUpdate(scope.row)">新增</el-button>
朱兆平 authored
43
                    <el-button size="mini" type="danger" @click="handleModifyStatus(scope.row,'deleted')">{{ $t('table.delete') }}</el-button>
44
                    <el-button type="primary" size="small" @click="electrixityMeterConfiguration(scope.row)">电表参数配置</el-button>
朱兆平 authored
45 46
                </template>
            </el-table-column>
朱兆平 authored
47
        </el-table>
朱兆平 authored
48 49 50 51 52 53 54

        <!--工具条-->
        <el-col :span="24" class="toolbar">
            <el-button type="danger" @click="batchRemove" :disabled="this.sels.length===0">批量删除</el-button>
            <el-pagination layout="prev, pager, next" @current-change="handleCurrentChange" :page-size="5" :total="total" style="float:right;">
            </el-pagination>
        </el-col>
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

        <!--水表新增-->
        <el-dialog title="电表参数配置新增" :visible.sync="electrixityAddFormVisible" :close-on-click-modal="false">
            <el-form :model="electrixityAddForm" label-width="110px" :rules="addFormRules" ref="electrixityAddForm">
                <el-form-item label="水电预付费" prop="prepaid">
                    <el-switch
                            v-model="electrixityAddForm.prepaid"
                            active-color="#00A854"
                            active-text="是"
                            active-value="0"
                            inactive-color="#F04134"
                            inactive-text="否"
                            inactive-value="1">
                    </el-switch>
                </el-form-item>
                <el-form-item label="电警告跳闸" prop="warningtrip">
                    <el-switch
                            v-model="electrixityAddForm.warningtrip"
                            active-color="#00A854"
                            active-text="是"
                            active-value="0"
                            inactive-color="#F04134"
                            inactive-text="否"
                            inactive-value="1">
                    </el-switch>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>告警阀值</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<el-input v-model="electrixityAddForm.warningthreshold" style="width: 100px;" auto-complete="off"></el-input>&nbsp;&nbsp;&nbsp;<span>元</span>
                </el-form-item>
                <el-form-item label="透支使能" prop="overdraft">
                    <el-switch
                            v-model="electrixityAddForm.overdraft"
                            active-color="#00A854"
                            active-text="是"
                            active-value="0"
                            inactive-color="#F04134"
                            inactive-text="否"
                            inactive-value="1">
                    </el-switch>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>可透支额度</span>&nbsp;&nbsp;<el-input v-model="electrixityAddForm.overdraftthreshold" style="width: 100px;" auto-complete="off"></el-input>&nbsp;&nbsp;&nbsp;<span>元</span>
                </el-form-item>
                <el-form-item label="过负荷跳闸使能" prop="overdraft">
                    <el-switch
                            v-model="electrixityAddForm.load"
                            active-color="#00A854"
                            active-text="是"
                            active-value="0"
                            inactive-color="#F04134"
                            inactive-text="否"
                            inactive-value="1">
                    </el-switch>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>功率</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<el-input v-model="electrixityAddForm.power" style="width: 100px;" auto-complete="off"></el-input>&nbsp;&nbsp;&nbsp;<span>KW</span>
                    <br/>
                    <br/>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>功率因数</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<el-input v-model="electrixityAddForm.powerfactor" style="width: 100px;" auto-complete="off"></el-input>
                </el-form-item>
                <el-form-item label="免费电度使能" prop="overdraft">
                    <el-switch
                            v-model="electrixityAddForm.free"
                            active-color="#00A854"
                            active-text="是"
                            active-value="0"
                            inactive-color="#F04134"
                            inactive-text="否"
                            inactive-value="1">
                    </el-switch>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>免费电度</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<el-input v-model="electrixityAddForm.overdraftthreshold" style="width: 100px;" auto-complete="off"></el-input>&nbsp;&nbsp;&nbsp;<span>度</span>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click.native="electrixityAddFormVisible = false">取消</el-button>
                <el-button type="primary" @click.native="addSubmit" :loading="addLoading">提交</el-button>
            </div>
        </el-dialog>
朱兆平 authored
127 128
    </section>
</template>
朱兆平 authored
129 130 131 132
<style>
    .el-table .building {
        background: oldlace;
    }
朱兆平 authored
133
朱兆平 authored
134 135 136 137 138 139 140 141
    .el-table .floor {
        background: #f0f9eb;
    }

    .el-table .house {
        background: #99CCCC;
    }
</style>
朱兆平 authored
142 143 144 145 146
<script>
    import { getList,add} from '@/api/empt/location_api';
    import moment from 'moment'
    import parseTime from '@/utils'
    import loginUserInfo from '@/api/base'
朱兆平 authored
147
朱兆平 authored
148 149 150 151 152 153 154
    export default {
        data() {
            return {
                filters: {
                    processName: '',
                    parseTime: parseTime
                },
155 156 157
                userId: '',
                realName: '',
                wmId:'',
朱兆平 authored
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
                locationList:[],
                total: 0,
                pageNum: 1,
                pageSize: 5,
                listLoading: false,
                sels: [],//列表选中列
                //编辑界面是否显示
                editFormVisible: false,
                editLoading: false,
                editFormRules: {
                    roleName: [
                        { required: true, message: '请输入岗位/角色名称', trigger: 'blur' }
                    ]
                },
                //编辑界面数据
                editForm: {
                    roleId: 1,
                    description: '',
                    roleName: '',
                    roleSign: 1,
                    departmentId:''
                },
                //用户ID
                //新增界面是否显示
182
                electrixityAddFormVisible: false,
朱兆平 authored
183 184 185 186 187 188 189 190 191 192
                //设置权限界面是否显示
                addLoading: false,
                addFormRules: {
                    roleName: [
                        { required: true, message: '请输入岗位/角色名称', trigger: 'blur' }
                    ],
                    description: [
                        { required: true, message: '请输入岗位/角色描述', trigger: 'blur' }
                    ]
                },
193 194 195 196 197 198 199 200 201 202 203 204
                //水表参数配置、界面数据
                electrixityAddForm: {
                    prepaid: '',
                    warningtrip: '',
                    warningthreshold: '',
                    overdraft:'',
                    overdraftthreshold: '',
                    load: '',
                    power: '',
                    powerfactor: '',
                    freeelectricitylimit: '',
                    eeId: ''
朱兆平 authored
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
                },
                permForm: {
                    roleId: 1,
                    description: '',
                    roleName: '',
                    roleSign: 1,
                    permissions: []
                },
                centerDialogVisible: false,
                dialogData:{
                    process:{
                        processname: ''
                    }
                },
                pickerOptions: {
                    disabledDate(time) {
                        return time.getTime() < Date.now();
                    },
                    shortcuts: [{
                        text: '今天',
                        onClick(picker) {
                            picker.$emit('pick', new Date());
                        }
                    }, {
                        text: '昨天',
                        onClick(picker) {
                            const date = new Date();
                            date.setTime(date.getTime() - 3600 * 1000 * 24);
                            picker.$emit('pick', date);
                        }
                    }, {
                        text: '一周前',
                        onClick(picker) {
                            const date = new Date();
                            date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                            picker.$emit('pick', date);
                        }
                    }]
                },
                options:[{
                    value: '1',
                    label: '测试公司',
                    children: [{
                        value: '2',
                        label: '测试部门一',
                        children: [{
                            value: '1',
                            label: '测试岗位1',
                            children: [{
                                value: '1',
                                label: '测试人员1'
                            }]
                        }]
                    }, {
                        value: '3',
                        label: '测试部门二',
                        children: [{
                            value: '2',
                            label: '测试岗位2',
                            children: [{
                                value: '1',
                                label: '测试人员2'
                            }]
                        }, {
                            value: '3',
                            label: '测试岗位3',
                            children: [{
                                value: '1',
                                label: '测试人员3'
                            }]
                        }]
                    }]
                }],
            }
        },
        methods: {
            //性别显示转换
            formatType: function (row, column) {
                let msg = '未知';
朱兆平 authored
284
                switch (row.type){
朱兆平 authored
285
                    case 0:
朱兆平 authored
286
                        msg='公寓';
朱兆平 authored
287 288
                        break;
                    case 1:
朱兆平 authored
289
                        msg='楼';
朱兆平 authored
290 291
                        break;
                    case 2:
朱兆平 authored
292
                        msg='层';
朱兆平 authored
293 294
                        break;
                    case 3:
朱兆平 authored
295
                        msg='门牌';
朱兆平 authored
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
                        break;
                }
                return msg;
            },
            handleCurrentChange(val) {
                this.pageNum = val;
            },
            //获取列表
            getList() {
                let para = {
                    pageNum: this.pageNum,
                    pageSize: this.pageSize,
                };
                this.listLoading = true;
                //NProgress.start();
                getList(para).then((res) => {
                    let resData = res.data.data;
                    this.total = resData.total;
                    this.locationList = resData.list;
                    this.listLoading = false;
                    //NProgress.done();
                }).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;
                    //NProgress.start();
                    let para = { roleId: row.roleId };
                    remove(para).then((res) => {
                        this.listLoading = false;
                        //NProgress.done();
                        this.$message({
                            message: '删除成功',
                            type: 'success'
                        });
                    }).catch((error) => {
                        this.listLoading = false;
                        alert(error);
                    });
                }).catch();
            },
            /**
             * 显示编辑界面
             * @param index
             * @param row 为这行的数据对象
             */
            handleEdit: function (index, row) {
                this.editFormVisible = true;
                this.editForm = Object.assign({}, row);
                this.getdepartmentNames();
            },
361 362 363 364 365 366 367 368 369 370 371 372 373 374
            //水表参数配置新增界面,每次点开初始化数据
            electrixityMeterConfiguration: function (row) {
                this.electrixityAddFormVisible = true;
                this.electrixityAddForm =  {
                    prepaid: '',
                    warningtrip: '',
                    warningthreshold: '',
                    overdraft:'',
                    overdraftthreshold: '',
                    load: '',
                    water: '',
                    free: '',
                    freeWater: '',
                    eeId: row.eeId
朱兆平 authored
375 376
                }
            },
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402

            //新增
            addSubmit: function () {
                this.$refs.electrixityAddForm.validate((valid) => {
                    if (valid) {
                        this.$confirm('确认提交吗?', '提示', {}).then(() => {
                            this.addLoading = true;
                            //NProgress.start();
                            let para = Object.assign({}, this.electrixityAddForm);
                            add(para).then((res) => {
                                this.addLoading = false;
                                if (res.status ===200) {
                                    this.$message({
                                        message: '提交成功',
                                        type: 'success'
                                    });
                                    this.$refs['permForm'].resetFields();
                                    this.electrixityAddFormVisible = false;
                                    this.getList();
                                }
                            }).catch(error => alert(error));
                        });
                    }
                });
            },
朱兆平 authored
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
            //编辑
            editSubmit: function () {
                this.$refs.editForm.validate((valid) => {
                    if (valid) {
                        this.$confirm('确认提交吗?', '提示', {}).then(() => {
                            this.editLoading = true;
                            //NProgress.start();
                            let para = Object.assign({}, this.editForm);
                            //不需要提交的 去掉,后端不好接收
                            para.authorities = null;
                            para.permissions = null;
                            para.roles = null;
//							para.birth = (!para.birth || para.birth == '') ? '' : util.formatDate.format(new Date(para.birth), 'yyyy-MM-dd');
                            /*
        					查询之后格式this.filters.column.create_start_date中日期发生变化;
        					Wed Aug 09 2017 00:00:00 GMT+0800 (中国标准时间) 变成了 "2017-08-08T16:00:00.000Z";
        					所以使用 moment 日期格式化插件将时间转换成 [ Wed Aug 09 2017 00:00:00 GMT+0800 (中国标准时间) ] 格
        					式;
    						*/
                            /*moment 安装 npm install moment --save*/
                            para.creattime = moment(para.creattime).format('YYYY-MM-DD HH:mm:ss');
                            this.editLoading = false;
                            edit(para).then((res) => {

                                //NProgress.done();
                                this.$message({
                                    message: '提交成功',
                                    type: 'success'
                                });
                                this.$refs['editForm'].resetFields();
                                this.editFormVisible = false;
                            }).catch(error => alert(error));
                        });
                    }
                });
            },
            selsChange: function (sels) {
                this.sels = sels;
            },
            //批量删除
            batchRemove: function () {
                var ids = this.sels.map(item => item.roleId).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'
                        })
                    });
                }).catch(() => {

                });
            },
朱兆平 authored
463 464 465 466 467 468 469 470 471 472
            tableRowClassName({row, rowIndex}) {
                let type = row.type;
                if (type === 1) {
                    return 'building';
                } else if (type === 2) {
                    return 'floor';
                } else if (type === 3){
                    return 'house';
                }
                    return '';
朱兆平 authored
473
            },
朱兆平 authored
474 475
            handleSelectionChange(val) {
                this.multipleSelection = val
476
            },
朱兆平 authored
477 478
        },
        mounted() {
479 480
            this.userId = loginUserInfo.userId;
            this.realName = loginUserInfo.realname;
朱兆平 authored
481 482 483 484 485 486 487 488 489
            this.getList();
        }
    }

</script>

<style scoped>

</style>