wl
2023-01-09 1e07cfd8ac6c3e31e94c0ea98dcff61db51e49d1
src/views/operate/baseSetting/illegalBuild/createUser/index.vue
@@ -18,15 +18,20 @@
                    </el-form-item>
                    <!-- 父级id -->
                    <el-form-item class="optionItem" label="父级:" prop="parentId">
                        <el-select v-model="things.parentId" placeholder="请选择所属父级">
                            <el-option v-for="item in parentList" :key="item.id" :label="item.name" :value="item.id">
                        <el-select v-model="things.parentId" placeholder="请选择所属父级" :disabled="things.level===1">
                            <!-- <el-option v-for="item in parentList" :key="item.id" :label="item.name" :value="item.id">
                            </el-option> -->
                            <el-option :value="mylabel">
                                <el-tree ref="tree" :check-strictly="true"  :data="parentList" :props="defaultProps" show-checkbox
                                    @check-change="handleCheck" default-expand-all node-key="id">
                                </el-tree>
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <!-- 案由 -->
                    <el-form-item class="optionItem" label="案由:" prop="type">
                        <el-input type="textarea" autosize v-model="things.type" placeholder="请输入案由描述内容"></el-input>
                    </el-form-item>
                    <!-- <el-form-item class="optionItem" label="案由:" prop="type">
                        <el-input type="textarea" :rows="2"  v-model="things.type" placeholder="请输入案由描述内容" :disabled="things.level!==2"></el-input>
                    </el-form-item> -->
                    <el-form-item>
                        <div class="optionBtn">
                            <el-button type="primary" class="btn submit" @click.native.prevent="handleSubmit">确认
@@ -62,7 +67,6 @@
                parentId:'',
                level:'',
            },
            parentList: [],
            createIll: {
                name: [
                    { required: true, trigger: 'blur', validator: checkName }
@@ -75,7 +79,7 @@
            },
            levelList: [
                {
                    label: "违建中类型",
                    label: "违建类型",
                    value: 1,
                },
                {
@@ -83,53 +87,63 @@
                    value: 2,
                },
            ],
            parentList: [],
            selectOrg: {
                orgsid: []
            },
            defaultProps: {
                children: 'children',
                label: 'name'
            },
            mylabel:''
        }
    },
    created() {
    },
    methods: {
        // 查询所属类型
        getTypeThird() {
            this.$axios({
        async getTypeThird() {
            let arr = [];
            await this.$axios({
                method: 'get',
                url: "sccg/illegal_building/query/type_first",
            })
                .then(res => {
                    this.parentList = res.data;
                    arr = res.data;
                })
            return arr;
        },
        // 查询所属大类
        getTypeSecond() {
            this.$axios({
        async getTypeSecond() {
            let arr =[];
            await this.$axios({
                method: 'get',
                url: "sccg/illegal_building/query/type_second",
            })
                .then(res => {
                    this.parentList = res.data;
                    arr = res.data;
                })
            return arr;
        },
        // 提交新增违规类型
        handleSubmit() {
            console.log(this.things);
            this.$refs.user.validate((valid) => {
                console.log(valid);
                if (valid) {
                    const { things } = this;
                    const { things,selectOrg } = this;
                    this.$axios({
                        method: 'post',
                        url: 'sccg/illegal_building/addition/type',
                        data: {
                            code: '1111',
                            level: things.parentId === '' ? things.level : things.level + 1,
                            level: things.level,
                            name: things.name,
                            parentId: things.parentId === '' ? 0 : things.parentId,
                            parentId: things.parentId === '' ? 0 : selectOrg.orgsid[0],
                            typeCode: '06',
                            typeName: '违建类型',
                            remark: things.type,
                        }
                    })
                        .then(res => {
                            console.log(res);
                            if (res.code === 200) {
                                this.$message({
                                    type: 'success',
@@ -149,13 +163,40 @@
            })
        },
        // 案件级别变化
        resetParentList(index) {
        async resetParentList(index) {
            if (index === 1) {
                this.getTypeThird();
            }else {
                this.getTypeSecond();
            }else{
                this.parentList = await this.getTypeThird()
            }
        }
        },
        handleCheck(data, checked) {
            this.things.parentId = data.name;
            // 获取当前选择的id在数组中的索引
            const indexs = this.selectOrg.orgsid.indexOf(data.id)
            // 如果不存在数组中,并且数组中已经有一个id并且checked为true的时候,代表不能再次选择。
            if (indexs < 0 && this.selectOrg.orgsid.length === 1 && checked) {
                this.$message({
                    message: '只能选择一个区域!',
                    type: 'warning',
                    showClose: true
                })
                // 设置已选择的节点为false 很重要
                this.$refs.tree.setChecked(data, false)
            } else if (this.selectOrg.orgsid.length === 0 && checked) {
                // 发现数组为空 并且是已选择
                // 防止数组有值,首先清空,再push
                this.selectOrg.orgsid = []
                this.selectOrg.orgsid.push(data.id)
            } else if (
                indexs >= 0 &&
                this.selectOrg.orgsid.length === 1 &&
                !checked
            ) {
                // 再次直接进行赋值为空操作
                this.selectOrg.orgsid = []
            }
        },
    },
    props: ['changeDialog']
}
@@ -163,13 +204,12 @@
<style lang="scss" scoped>
.createUser {
    border-radius: 1px;
    background-color: #09152f;
    background-color: #fff;
    main {
        // border: 1px solid #fff;
        text-align: left;
        padding: 0 55px;
        background-color: #09152f;
        background-color: #fff;
        padding-bottom: 50px;
        .mainContent {
@@ -210,18 +250,18 @@
        }
    }
    &::v-deep .el-textarea__inner {
        background-color: #09152f;
        border: 1px solid #17324c;
    }
    // &::v-deep .el-textarea__inner {
    //     // background-color: #09152f;
    //     border: 1px solid #17324c;
    // }
    ::v-deep .el-form-item__label {
        color: #4b9bb7;
    }
    // ::v-deep .el-form-item__label {
    //     color: #4b9bb7;
    // }
    ::v-deep .el-input__inner {
        background-color: #09152f;
        border: 1px solid #17324c;
    }
    // ::v-deep .el-input__inner {
    //     // background-color: #09152f;
    //     border: 1px solid #17324c;
    // }
}
</style>