Commit 133574aa authored by rencs's avatar rencs

8.26 公司门店接口调试完成

parent 9a5710d3
......@@ -39,24 +39,23 @@ export function company_all_list() {
return fetch({
url: "vehicle/company/info/alls",
method: "get",
});
}
// 添加公司
export function add_company(query) {
return fetch({
url: 'vehicle/company/info/save',
method: 'post',
data: query
url: "vehicle/company/info/save",
method: "post",
data: query,
});
}
// 删除公司
export function del_company(query) {
return fetch({
url: 'vehicle/company/info/del',
method: 'post',
data: query
url: "vehicle/company/info/del",
method: "post",
data: query,
});
}
......@@ -64,9 +63,9 @@ export function del_company(query) {
export function upd_company(query) {
return fetch({
url: 'vehicle/company/info/upd',
method: 'post',
data: query
url: "vehicle/company/info/upd",
method: "post",
data: query,
});
}
......@@ -75,16 +74,26 @@ export function upd_company(query) {
export function del_store(query) {
return fetch({
url: 'vehicle/admin/branchCompany/del?id=' + query.id,
method: 'delete',
url: "vehicle/admin/branchCompany/del?id=" + query.id,
method: "delete",
});
}
//添加门店
export function add_store(query) {
return fetch({
url: 'vehicle/admin/branchCompany',
method: 'post',
data: query
url: "vehicle/admin/branchCompany",
method: "post",
data: query,
});
}
//修改上下架
//修改门店
export function update_store(id, query) {
return fetch({
url: "vehicle/admin/branchCompany/" + id,
method: "put",
data: query,
});
}
......@@ -3,7 +3,7 @@
<div>
<div class="filter-container" ref="filter-container">
<div class="top_btn">
<el-button type="primary" @click="add_item" icon="plus">添加公司</el-button>
<el-button type="primary" @click="add_item" icon="el-icon-plus">添加公司</el-button>
</div>
<el-form ref="queryForm" :inline="inline" :model="listQuery" label-width="80px">
<el-row>
......@@ -14,7 +14,7 @@
class="filter-item"
type="primary"
v-waves
icon="search"
icon="el-icon-search"
@click="handleFilter"
>搜索</el-button>
<el-button class="filter-item" @click="clear_handleFilter">清除搜索</el-button>
......
......@@ -3,7 +3,7 @@
<div>
<div class="filter-container" ref="filter-container">
<div class="top_btn">
<el-button type="primary" @click="add_item" icon="plus">添加门店</el-button>
<el-button type="primary" @click="add_item" icon="el-icon-plus">添加门店</el-button>
</div>
<el-form ref="queryForm" :inline="inline" :model="listQuery" label-width="80px">
<el-row>
......@@ -48,7 +48,7 @@
class="filter-item"
type="primary"
v-waves
icon="search"
icon="el-icon-search"
@click="handleFilter"
>搜索</el-button>
<el-button class="filter-item" @click="clear_handleFilter">清除搜索</el-button>
......@@ -69,9 +69,9 @@
<el-table-column align="center" label="负责人" prop="leader"></el-table-column>
<el-table-column align="center" label="操作">
<template slot-scope="{row}">
<el-button type="text">编辑</el-button>
<el-button type="text" v-if="row.state==1">下架</el-button>
<el-button type="text" v-if="row.state==2">上架</el-button>
<el-button type="text" @click="edit_item(row)">编辑</el-button>
<el-button type="text" @click="updateState(row,2)" v-if="row.state==1">下架</el-button>
<el-button type="text" @click="updateState(row,1)" v-if="row.state==2">上架</el-button>
<el-button type="text" @click="del_item(row)">删除</el-button>
</template>
</el-table-column>
......@@ -89,9 +89,8 @@
</div>
</div>
<el-dialog
customClass="customWidth"
:title="title_text"
width="30%"
width="50%"
:visible.sync="add_edit_dialog"
@close="add_edit_dialog=false"
>
......@@ -237,7 +236,12 @@
<span slot="footer" class="dialog-footer">
<el-button @click="add_edit_dialog = false">取 消</el-button>
<el-button type="primary" @click="add_store_ok('store_form')">确 定</el-button>
<el-button type="primary" v-if="title_text=='添加门店'" @click="add_store_ok('store_form')">确 定</el-button>
<el-button
type="primary"
v-if="title_text=='修改门店'"
@click="update_store_ok('store_form')"
>确 定</el-button>
</span>
</el-dialog>
</div>
......@@ -260,6 +264,7 @@ import {
store_list,
company_all_list,
add_store,
update_store,
del_store,
} from "api/company";
import { getAllZone } from "api/base_info/constant/";
......@@ -371,20 +376,101 @@ export default {
handleAvatarSuccess(res, file) {
this.store_form.sortPic = res.data;
},
//修改
update_store_ok(formname) {
this.$refs[formname].validate((valid) => {
if (valid) {
let addr_province = undefined;
let addr_city = undefined;
let addr_county = undefined;
if (
this.provinceArr.length > 0 &&
this.store_form.province &&
this.store_form.province != ""
) {
addr_province = this.provinceArr.filter(
(item) => item.name == this.store_form.province
)[0].id;
}
if (
this.cityArrs.length > 0 &&
this.store_form.city &&
this.store_form.city != ""
) {
addr_city = this.cityArrs.filter(
(item) => item.name == this.store_form.city
)[0].id;
}
if (
this.regionArr.length > 0 &&
this.store_form.county &&
this.store_form.county != ""
) {
addr_county = this.regionArr.filter(
(item) => item.name == this.store_form.county
)[0].id;
}
let data = {
id: this.store_form.id,
name: this.store_form.name,
state: this.store_form.state,
shortName: this.store_form.sortName,
companyPic: this.store_form.sortPic,
companyId: this.store_form.companyid,
leader: this.store_form.dutyName,
phone: this.store_form.phone,
provinceName: this.store_form.province,
addrProvince: addr_province,
addrCity: addr_city,
addrTown: addr_county,
cityName: this.store_form.city,
townName: this.store_form.county,
addrDetail: this.store_form.detail_address,
latitude: this.store_form.latitude, //纬度
longitude: this.store_form.longitude, //经度
};
update_store(this.store_form.id, data).then((res) => {
if (res.status == 200) {
this.$message({
type: "success",
message: "修改成功!",
});
this.add_edit_dialog = false;
this.handleFilter();
} else {
this.$message({
type: "info",
message: res.message,
});
}
});
} else {
return false;
}
});
},
//添加
add_store_ok(formname) {
this.$refs[formname].validate((valid) => {
if (valid) {
console.log(this.store_form.county);
let addr_province = this.provinceArr.filter(
(item) => item.name == this.store_form.province
)[0].id;
let addr_city = this.cityArrs.filter(
(item) => item.name == this.store_form.city
)[0].id;
let addr_county = this.regionArr.filter(
(item) => item.name == this.store_form.county
)[0].id;
let addr_province = undefined;
let addr_city = undefined;
let addr_county = undefined;
if (this.store_form.province && this.store_form.province != "") {
addr_province = this.provinceArr.filter(
(item) => item.name == this.store_form.province
)[0].id;
}
if (this.store_form.city && this.store_form.city != "") {
addr_city = this.cityArrs.filter(
(item) => item.name == this.store_form.city
)[0].id;
}
if (this.store_form.county && this.store_form.county != "") {
addr_county = this.regionArr.filter(
(item) => item.name == this.store_form.county
)[0].id;
}
let data = {
name: this.store_form.name,
state: this.store_form.state,
......@@ -423,6 +509,49 @@ export default {
}
});
},
edit_item(row) {
this.store_form = {
id: row.id,
name: row.name,
state: row.state,
sortName: row.shortName,
sortPic: row.companyPic,
companyid: String(row.companyId),
dutyName: row.leader,
phone: row.phone,
// addr_province,
// addr_city,
// addr_county,
province: row.provinceName,
city: row.cityName,
county: row.townName,
detail_address: row.addrDetail,
latitude: row.latitude, //纬度
longitude: row.longitude, //经度
};
this.add_edit_dialog = true;
this.title_text = "修改门店";
},
updateState(row, type) {
let data = {
id: row.id,
state: type,
};
update_store(row.id, data).then((res) => {
if (res.status == 200) {
this.$message({
type: "success",
message: "操作成功!",
});
this.handleFilter();
} else {
this.$message({
type: "info",
message: res.message,
});
}
});
},
//删除
del_item(row) {
this.$confirm("是否确认删除?", "提示", {
......@@ -662,8 +791,6 @@ export default {
this.title_text = "添加门店";
this.form_clear();
},
edit_item(row) {},
edit_del(row) {},
},
};
</script>
......@@ -678,9 +805,7 @@ export default {
display: flex;
flex-direction: column;
}
.customWidth {
width: 50%;
}
.map_box {
width: 100%;
display: flex;
......
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