|
|
@@ -39,12 +39,6 @@ import Table from "./CarTypeTable";
|
|
|
import Modal from "./CarTypeModal";
|
|
|
|
|
|
export default {
|
|
|
- props: {
|
|
|
- parentId: {
|
|
|
- type: String,
|
|
|
- default: "",
|
|
|
- },
|
|
|
- },
|
|
|
components: {
|
|
|
Count,
|
|
|
Table,
|
|
|
@@ -58,6 +52,7 @@ export default {
|
|
|
currentPage: 1,
|
|
|
tableData: [],
|
|
|
modalFlag: false, // 控制模态框展示
|
|
|
+ parentId: (this.$route.query && this.$route.query.id) || "",
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -65,11 +60,6 @@ export default {
|
|
|
totalPage() {
|
|
|
return Math.ceil(this.sum / this.pageSize);
|
|
|
},
|
|
|
- // 获取路由参数
|
|
|
- queryTag() {
|
|
|
- console.log(111, this.$route.query);
|
|
|
- return this.$route.query && this.$route.query.tag ? 0 : 1;
|
|
|
- },
|
|
|
},
|
|
|
methods: {
|
|
|
// 获取某一页面的数据,展示在表格
|
|
|
@@ -101,24 +91,37 @@ export default {
|
|
|
},
|
|
|
// 点击编辑
|
|
|
edit(index, newName) {
|
|
|
- console.log(index, newName);
|
|
|
+ let id = this.tableData[index]["id"];
|
|
|
+ let req = {
|
|
|
+ id,
|
|
|
+ typeName: newName,
|
|
|
+ parentId: this.parentId
|
|
|
+ };
|
|
|
+ this.updataCarTypeInfo(req).then(() => {
|
|
|
+ this.getData();
|
|
|
+ });
|
|
|
},
|
|
|
// 点击删除
|
|
|
deleteData(index) {
|
|
|
- console.log("删除", index);
|
|
|
+ let id = this.tableData[index]['id'];
|
|
|
+ this.deleteCarTypeInfo(id).then(() => {
|
|
|
+ this.getData()
|
|
|
+ })
|
|
|
},
|
|
|
// 新增车型模态框 保存
|
|
|
submit: function (car) {
|
|
|
- this.addCarSeries(car);
|
|
|
- this.modalFlag = false;
|
|
|
+ this.addCarSeries(car).then(() => {
|
|
|
+ this.getData();
|
|
|
+ this.modalFlag = false;
|
|
|
+ });
|
|
|
},
|
|
|
- // 获取数据 接口
|
|
|
+ // 获取数据 接口
|
|
|
getData: function () {
|
|
|
this.$http({
|
|
|
method: "post",
|
|
|
url: "/base/carTypeManager/selectCarTypePage",
|
|
|
data: {
|
|
|
- parentId: this.parentId
|
|
|
+ parentId: this.parentId,
|
|
|
},
|
|
|
})
|
|
|
.then((res) => {
|
|
|
@@ -134,16 +137,16 @@ export default {
|
|
|
console.log(err);
|
|
|
});
|
|
|
},
|
|
|
- // 新增车系 接口
|
|
|
+ // 新增车型 接口
|
|
|
addCarSeries: function (typeName) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
this.$http({
|
|
|
url: "/base/carTypeManager/addCarTypeInfo",
|
|
|
method: "post",
|
|
|
- data: {
|
|
|
+ data: {
|
|
|
typeName: typeName,
|
|
|
- parentId: this.parentId
|
|
|
- },
|
|
|
+ parentId: this.parentId,
|
|
|
+ },
|
|
|
})
|
|
|
.then((res) => {
|
|
|
if (res.data && res.data.code === 200) {
|
|
|
@@ -159,6 +162,53 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
+ // 编辑车型 接口
|
|
|
+ updataCarTypeInfo: function (data) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ this.$http({
|
|
|
+ url: "/base/carTypeManager/updateCarTypeInfo",
|
|
|
+ method: "post",
|
|
|
+ data,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if (res.data && res.data.code === 200) {
|
|
|
+ resolve();
|
|
|
+ } else {
|
|
|
+ alert("编辑失败,请重试");
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ alert("编辑失败,请重试");
|
|
|
+ reject(err);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 删除车型 接口
|
|
|
+ deleteCarTypeInfo: function (id) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ this.$http({
|
|
|
+ url: "/base/carTypeManager/deleteCarTypeInfo",
|
|
|
+ method: "post",
|
|
|
+ data: {
|
|
|
+ parentId: this.parentId,
|
|
|
+ id,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if (res.data && res.data.code === 200) {
|
|
|
+ resolve();
|
|
|
+ } else {
|
|
|
+ alert("删除失败,请重试");
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ alert("删除失败,请重试");
|
|
|
+ reject(err);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
},
|
|
|
mounted() {
|
|
|
this.getData();
|