Commit 543b011a authored by lixy's avatar lixy

后台用户管理:所属公司、所属联动回显bug修复

parent 1406a8fd
......@@ -38,3 +38,14 @@ export function putObj(id, obj) {
data: obj
})
}
/**
* 根据所属公司id查询--所属门店数据
*/
export function companyListById(query) {
return fetch({
url: 'vehicle/branchCompany/app/unauth/listByIds',
method: 'post',
data: query
})
}
......@@ -23,7 +23,7 @@
filterable
placeholder="请选择公司"
>
<el-option label="全部" value="0"></el-option>
<el-option :key="0" label="全部" :value="0"></el-option>
<el-option
v-for="val in companys_list"
:key="val.id"
......@@ -41,9 +41,9 @@
clearable
placeholder="请选择"
>
<el-option label="全部" value="0"></el-option>
<el-option :key="0" label="全部" :value="0"></el-option>
<el-option
v-for="val in branchCompany_list"
v-for="val in branchCompany_list_select"
:key="val.id"
:label="val.name"
:value="val.id"
......@@ -210,17 +210,18 @@
<el-select
class="filter-item"
v-model="form.corporationId"
@change="changeCorporation"
clearable
filterable
placeholder="请选择公司"
>
<el-option label="全部" value="0"></el-option>
<el-option label="全部" :value="0"></el-option>
<el-option v-for="val in companys_list" :key="val.id" :label="val.name" :value="val.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="所属门店" prop="companyId">
<el-select class="filter-item" v-model="form.companyId" clearable placeholder="请选择">
<el-option label="全部" value="0"></el-option>
<el-option label="全部" :value="0"></el-option>
<el-option
v-for="val in branchCompany_list"
:key="val.id"
......@@ -257,13 +258,11 @@
</div>
</template>
<script>
import { page, addObj, getObj, delObj, putObj } from "api/admin/user/index";
<script type="javascript">
import { page, addObj, getObj, delObj, putObj, companyListById } from "api/admin/user/index";
import { mapGetters } from "vuex";
import { getAllCompany, getAll } from "api/base_info/branch_company/";
import { getAllZone } from "api/base_info/constant/";
import {
......@@ -401,8 +400,9 @@ export default {
allBranchCompany: [], //所有分公司列表
list_All: [],
companys_list: [],
branchCompany_list: [],
edit_item: {},
branchCompany_list: [], // 所属门店列表
branchCompany_list_select: [],// 全部所属门店
edit_item: {}
};
},
created() {
......@@ -429,8 +429,8 @@ export default {
this.userManager_btn_edit = this.elements["userManager:btn_edit"];
this.userManager_btn_del = this.elements["userManager:btn_del"];
this.userManager_btn_add = this.elements["userManager:btn_add"];
this.get_all_companys();
this.get_all_branchCompany();
this.get_all_companys(); // 获得所属公司列表
this.get_all_branchCompany(); // 获取所有所属门店列表
},
computed: {
...mapGetters(["elements"]),
......@@ -442,11 +442,36 @@ export default {
},
},
methods: {
/**
* 选择所属公司后--查询所属门店列表
*/
changeCorporation(){
this.form.companyId = undefined // 切换所属公司----所属门店置空
companyListById({companyId: this.form.corporationId}).then((res) => {
if (res.status == 200) {
this.branchCompany_list = res.data;
} else {
this.$notify({
title: '失败',
message: res.message,
type: 'error',
duration: 2000
})
}
});
},
//所有公司
get_all_companys() {
company_all_list().then((res) => {
if (res.status == 200) {
this.companys_list = res.data;
} else {
this.$notify({
title: '失败',
message: res.message,
type: 'error',
duration: 2000
})
}
});
},
......@@ -454,7 +479,7 @@ export default {
get_all_branchCompany() {
branchCompany_all_list({ state: 1 }).then((res) => {
if (res.status == 200) {
this.branchCompany_list = res.data;
this.branchCompany_list_select = res.data;
}
});
},
......@@ -568,6 +593,21 @@ export default {
dataLimit: undefined, //数据权限
members: [],
};
if(this.form.corporationId) {
// 所属公司 -所属门店
companyListById({companyId: this.form.corporationId}).then((res) => {
if (res.status == 200) {
this.branchCompany_list = res.data;
} else {
this.$notify({
title: '失败',
message: res.message,
type: 'error',
duration: 2000
})
}
});
}
this.membersName = row.groupStr;
this.list_All.forEach((item) => {
if (item.name == row.groupStr) {
......@@ -608,22 +648,29 @@ export default {
const set = this.$refs;
set[formName].validate((valid) => {
if (valid) {
if (this.form.corporationId == "0") {
this.form.corporationId = undefined;
} else {
// if (this.form.corporationId == "0") {
// this.form.corporationId = undefined;
// } else {
// this.form.dataCorporation = this.form.corporationId;
// }
// if (this.form.companyId == "0") {
// this.form.companyId = undefined;
// } else {
// this.form.dataCompany = this.form.companyId;
// }
// if ( this.form.corporationId == undefined && this.form.companyId == undefined ) {
// this.form.dataAll = 1;
// }
if(this.form.corporationId == 0 && this.form.companyId == 0){ // 所属公司、所属门店 均为全部
this.form.dataAll = 1;
} else if(this.form.corporationId > 0 && this.form.companyId == 0){
// 选择所属公司 全部门店
this.form.dataCorporation = this.form.corporationId;
}
if (this.form.companyId == "0") {
this.form.companyId = undefined;
} else {
} else if(this.form.corporationId > 0 && this.form.companyId > 0) {
this.form.dataAll = undefined;
this.form.dataCorporation = undefined
this.form.dataCompany = this.form.companyId;
}
if (
this.form.corporationId == undefined &&
this.form.companyId == undefined
) {
this.form.dataAll = 1;
}
addObj(this.form).then((response) => {
if (response.status == 200) {
......@@ -682,6 +729,16 @@ export default {
} else {
this.form.password = undefined;
}
if(this.form.corporationId == 0 && this.form.companyId == 0){ // 所属公司、所属门店 均为全部
this.form.dataAll = 1;
} else if(this.form.corporationId > 0 && this.form.companyId == 0){
// 选择所属公司 全部门店
this.form.dataCorporation = this.form.corporationId;
} else if(this.form.corporationId > 0 && this.form.companyId > 0) {
this.form.dataAll = undefined;
this.form.dataCorporation = undefined
this.form.dataCompany = this.form.companyId;
}
putObj(this.form.id, this.form).then((response) => {
if (response.status == 200) {
this.$notify({
......
......@@ -364,8 +364,8 @@ export default {
city: "",
county: "",
detail_address: "",
latitude: null, //纬度
longitude: null, //经度
latitude: undefined, //纬度
longitude: undefined, //经度
},
provinceArr: [],
cityArrs: [],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment