index.vue 10.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><input type="checkbox" @click="allcheck" v-model="isCheckAll"/></td>
                    <td>界址点号</td>
                    <td>顺序号</td>
                    <td>X坐标值</td>
                    <td>Y坐标值</td>
                    <td>界标类型</td>
                    <td>界址点类型</td>
                </tr>
                <tr v-for="(item,index) in jzdlist" :key="index">
                    <td><input type="checkbox" v-model="item.isCheck" @change="changeAll"/></td>
                    <td><input type="text" class="formInput" v-model="item.jzdh" readonly="readonly"/></td>
                    <td><input type="text" class="formInput" v-model="item.sxh" readonly="readonly"/></td>
                    <td><input type="text" class="formInput" v-model="item.xzbz" :readonly="item.iszb"
                               @keydown="oninput"/></td>
                    <td><input tepe="text" class="formInput" v-model="item.yzbz" :readonly="item.iszb"
                               @keydown="oninput"/></td>
                    <td>
                        <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>
                        <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
                    title="批量修改"
                    :visible.sync="centerDialogVisible"
                    width="30%"
                    center>
                <div class="plxg">
                    <div>
                        <span class="batchlx"> 界标类型:</span>
                        <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>
                    </div>
                    <div>
                        <span class="batchlx">界址点类型:</span>
                        <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>
                    </div>

                </div>
                <span slot="footer" class="dialog-footer">
                <el-button @click="centerDialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="jzdbatchsave">确 定</el-button>
              </span>
            </el-dialog>
        </div>
    </div>
</template>

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

    export default {
        name: "界址点",
        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: '1',
                    jzdlx: '1'
                }
            }
        },
        created() {

        },
        mounted() {
            // 该标识码继承过来
            let bsm = '401044005bad0557d5e3787239d8e18e';
            this.bsm=bsm;
            this.getData(this.bsm)
        },
        methods: {
            getData(bsm) {
                queryjzd(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() {
                console.log("保存....");
                jzdsingleModify(this.jzdlist).then(res => {
                    console.log(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() {
                console.log("批量修改")
                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: {},
    }
</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: 80%;
    }

    table {
        margin-top: 10px;
        background-color: #fff;
        font-size: 14px;
        width: 100%;
    }

    td {
        text-align: center;
        height: 36px;
    }

    table .formInput {
        margin: 0;
        height: 36px;
        outline: none;
        border: none;
        color: #606764;
        overflow: visible;
        text-align: center;
        cursor: text;
    }

    table:hover {
        cursor: pointer;
    }

    .batchlx {
        text-align: center;
    }
</style>