Commit 543b011a authored by lixy's avatar lixy

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

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