index.vue 12.3 KB
<template>
    <div class="main">
        <div class="button">
            <el-button type="primary" @click="oneExit">编辑</el-button>
            <el-button type="primary" @click="save">保存</el-button>
            <el-button type="primary" @click="batchExit">批量修改</el-button>
        </div>
        <div class="table">
            <table border="1">
                <tr>
                    <td class="cz"><input type="checkbox" @click="allcheck" v-model="isCheckAll"/></td>
                    <td class="jzdh">界址点号</td>
                    <td class="sxh">顺序号</td>
                    <td class="xzbz">X坐标值</td>
                    <td class="yzbz">Y坐标值</td>
                    <td class="jblx">界标类型</td>
                    <td class="jzdlx">界址点类型</td>
                </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"><input type="checkbox" v-model="item.isCheck" @change="changeAll"/></td>
                    <td class="jzdh"><input type="text" class="formInput" v-model="item.jzdh" readonly="readonly"/></td>
                    <td class="sxh"><input type="text" class="formInput" v-model="item.sxh" readonly="readonly"/></td>
                    <td class="xzbz"><input type="text" class="formInput" v-model="item.xzbz" :readonly="item.iszb"
                                            @keydown="oninput"/></td>
                    <td class="yzbz"><input tepe="text" class="formInput" v-model="item.yzbz" :readonly="item.iszb"
                                            @keydown="oninput"/></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 @click="centerDialogVisible = false">取 消</el-button>
                    <el-button type="primary" @click="jzdbatchsave">确 定</el-button>
                </div>
            </el-dialog>
        </div>
    </div>
</template>

<script>
    import {queryjzd, jzdsingleModify, jzdbatchModify} from '../../../api/zd'
    import {Message} from 'element-ui'

    export default {
        name: "jzd",
        components: {},
        props: {},
        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() {
                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.target.checked) {
                    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.target.checked;
                }
            },
            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 {
            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%;
            .formInput {
                margin: 0;
                height: 36px;
                outline: none;
                border: none;
                color: #606764;
                overflow: visible;
                text-align: center;
                cursor: text;
            }
        }

        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>