index.vue 12.7 KB
<template>
    <div class="main">
        <div class="button">
            <el-button type="primary" @click="oneExit" :disabled="isDisabled" icon="el-icon-edit">编辑</el-button>
            <el-button type="primary" @click="save" :disabled="isDisabled" icon="iconfont iconbaocun">保存</el-button>
            <el-button type="primary" @click="batchExit" :disabled="isDisabled">批量修改</el-button>
        </div>
        <div class="table">
            <table border="1">
                <tr>
                    <th class="cz">
                        <el-checkbox @change="allcheck" v-model="isCheckAll"></el-checkbox>
                    </th>
                    <th class="">界址点号</th>
                    <th class="">顺序号</th>
                    <th class="">X坐标值</th>
                    <th class="">Y坐标值</th>
                    <th class="">界标类型</th>
                    <th class="">界址点类型</th>
                </tr>
                <tr v-if="jzdlist.length===0">
                    <td colspan="7"><span class="nodata">暂无数据</span></td>
                </tr>
                <tr v-for="(item,index) in jzdlist" :key="index" v-else>
                    <td class="cz">
                        <el-checkbox v-model="item.isCheck" @change="changeAll"></el-checkbox>
                    </td>
                    <td class="jzdh">
                        <el-input v-model="item.jzdh" readonly></el-input>
                    </td>
                    <td class="sxh">
                        <el-input class="" v-model="item.sxh" readonly></el-input>
                    </td>
                    <td class="xzbz">
                        <el-input class="" v-model="item.xzbz" :readonly="item.iszb" oninput="value = (value.match(/^\d*(\.?\d{0,3})/g)[0]) || null"
                                  @keydown="oninput"></el-input>
                    </td>
                    <td class="yzbz">
                        <el-input class="" v-model="item.yzbz" :readonly="item.iszb" oninput="value = (value.match(/^\d*(\.?\d{0,3})/g)[0]) || null"
                                  @keydown="oninput"></el-input>
                    </td>
                    <td class="jblx">
                        <el-select v-model="item.jblx" :disabled="item.jzdisdisabled">
                            <el-option
                                    v-for="i in jblx"
                                    :key="i.key"
                                    :label="i.label"
                                    :value="i.value"
                            ></el-option>
                        </el-select>
                    </td>
                    <td class="jzdlx">
                        <el-select v-model="item.jzdlx" :disabled="item.jzdisdisabled">
                            <el-option
                                    v-for="i in jzdlx"
                                    :key="i.key"
                                    :label="i.label"
                                    :value="i.value"
                            ></el-option>
                        </el-select>
                    </td>
                </tr>
            </table>
        </div>
        <div>
            <el-dialog v-dialogDrag :close-on-click-modal="false"
                       title="批量修改"
                       :visible.sync="centerDialogVisible"
                       width="30%"
            >
                <div class="plxg">
                    <table>
                        <tr>
                            <th> 界标类型:</th>
                            <td>
                                <el-select v-model="batchJzd.jblx">
                                    <el-option
                                            v-for="i in jblx"
                                            :key="i.key"
                                            :label="i.label"
                                            :value="i.value"
                                    ></el-option>
                                </el-select>
                            </td>
                        </tr>
                        <tr>
                            <th>界址点类型:</th>
                            <td>
                                <el-select v-model="batchJzd.jzdlx">
                                    <el-option
                                            v-for="i in jzdlx"
                                            :key="i.key"
                                            :label="i.label"
                                            :value="i.value"
                                    ></el-option>
                                </el-select>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="dialog-footer">
                    <el-button type="primary" @click="jzdbatchsave">确 定</el-button>
                    <el-button @click="centerDialogVisible = false">取 消</el-button>
                </div>
            </el-dialog>
        </div>
    </div>
</template>

<script>
    import {queryjzd, jzdsingleModify, jzdbatchModify} from '@api/zd'
    import {queryStatus} from "@api/search"
    import {Message} from 'element-ui'

    export default {
        name: "jzd",
        components: {},
        props: {
            isDisabled:{
                type:Boolean,
                default:false
            }
        },
        data() {
            return {
                bsm: '',
                isCheckAll: false,
                centerDialogVisible: false,
                jblx: [
                    {
                        key: '1',
                        label: '钢钉',
                        value: '1'
                    }, {
                        key: '2',
                        label: '水泥桩',
                        value: '2'
                    }, {
                        key: '3',
                        label: '石灰桩',
                        value: '3'
                    }, {
                        key: '4',
                        label: '喷绘',
                        value: '4'
                    }, {
                        key: '5',
                        label: '瓷标志',
                        value: '5'
                    }, {
                        key: '6',
                        label: '无标志',
                        value: '6'
                    }, {
                        key: '7',
                        label: '其他',
                        value: '7'
                    },
                ],
                jzdlx: [
                    {
                        key: '1',
                        label: '解析界址点',
                        value: '1'
                    }, {
                        key: '2',
                        label: '图解界址点',
                        value: '2'
                    }, {
                        key: '3',
                        label: '航测界址点',
                        value: '3'
                    }, {
                        key: '4',
                        label: '其他',
                        value: '4'
                    }
                ],
                jzdlist: [],
                batchJzd: {
                    bsms: [],
                    jblx: '',
                    jzdlx: ''
                }
            }
        },
        created() {

        },
        mounted() {
            let bsm = this.$store.state.zdbsm
            this.bsm = bsm;
            this.getData(bsm)
        },
        methods: {
            result() {
                this.batchJzd.jblx = '';
                this.batchJzd.jzdlx = '';
            },
            getData(bsm) {
                queryjzd({glBsm: bsm}).then(res => {
                    for (let i = 0; i < res.result.length; i++) {
                        res.result[i]['isCheck'] = false;
                        res.result[i]['iszb'] = 'readonly';
                        res.result[i]['jzdisdisabled'] = true;
                    }
                    this.isCheckAll = false;
                    this.jzdlist = res.result;
                })
            },
            save() {
                if (this.jzdlist.length === 0) {
                    Message.info("至少填写一条界址点信息")
                    return
                }
                jzdsingleModify(this.jzdlist).then(res => {
                    if (res.success) {
                        Message.success("保存成功")
                        this.getData(this.bsm)
                    } else {
                        Message.error(res.message)
                    }
                })
                for (let item of this.jzdlist) {
                    if (item.isCheck) {
                        item.iszb = 'readonly';
                        item.jbisdisabled = true;
                        item.jzdisdisabled = true;
                    }
                }
            },
            oninput(e) {
                e.target.value = (e.target.value.match(/^\d*(\.?\d{0,4})/g)[0]) || null
            },
            changeAll(e) {
                if (!e) {
                    this.isCheckAll = false;
                    return
                }
                for (let item of this.jzdlist) {
                    if (!item.isCheck) {
                        this.isCheckAll = false;
                        return
                    }
                }
                this.isCheckAll = true;
            },
            allcheck(value) {
                for (let item of this.jzdlist) {
                    item.isCheck = value;
                }
            },
            oneExit() {
                for (let item of this.jzdlist) {
                    if (item.isCheck) {
                        item.iszb = false;
                        item.jzdisdisabled = false;
                    }
                }

            },
            batchExit() {
                let flag = false;
                for (let item of this.jzdlist) {
                    if (item.isCheck) {
                        flag = true;
                    }
                }
                if (flag) {
                    this.centerDialogVisible = true;
                } else {
                    Message.info("请勾选要修改的数据")
                }
            },
            jzdbatchsave() {
                this.batchJzd.bsms.length = 0;
                for (let item of this.jzdlist) {
                    if (item.isCheck) {
                        this.batchJzd.bsms.push(item.bsm);
                    }
                }
                jzdbatchModify(this.batchJzd).then(res => {
                    if (res.success) {
                        this.getData(this.bsm)
                        this.centerDialogVisible = false;
                    } else {
                        Message.error("修改失败")
                    }
                })
            }
        },
        computed: {},
        watch: {
            "$store.state.zdbsm": function (bsm) {
                this.bsm = bsm
                this.getData(bsm)
            },
            centerDialogVisible() {
                this.result();
            }
        },
    }
</script>
<style scoped lang="less">
    /*    /deep/ .el-input.is-disabled .el-input__inner {
            color: #606764;
        }*/

    .main {
        box-sizing: border-box;
        padding: 18px;
        height: auto;
        width: 100%;
        .header-button {
            z-index: 3;
            height: 50px;
            position: fixed;
            bottom: 0;
            text-align: center;
            background-color: #ffffff;
            .saveBtn {
                background-color: #00CACD;
                border-color: #00CACD;
                padding: 10px 30px;
                margin-top: 8px;
            }
            .saveBtn:hover {
                background-color: rgba(0, 202, 205, .8);
                border-color: rgba(0, 202, 205, .8);
            }
        }
        table {
            margin-top: 10px;
            background-color: #fff;
            font-size: 14px;
            width: 100%;
        }
        th{
            height: 36px;
        }
        td {
            text-align: center;
            height: 36px;
        }

        table:hover {
            cursor: pointer;
        }
        .plxg {
            .el-select {
                float: left;
            }
        }
        .batchlx {
            text-align: center;
        }

        .nodata {
            color: #b2b2b2;
        }
    }
    .cz {
        width: 50px;
    }

 /*

    .jzdh {
        width: 120px;
    }

    .sxh {
        width: 120px
    }

    .xzbz {
        width: 120px
    }

    .yzbz {
        width: 120px
    }

    .jblx {
        width: 150px
    }

    .jzdlx {
        width: 180px
    }*/

    .dialog-footer {
        text-align: center;
        margin-top: 20px;
    }
</style>