|
|
@@ -11,7 +11,7 @@
|
|
|
@edit="edit"
|
|
|
@delet_data="deleteData"
|
|
|
@jump_router="jumpRouter"
|
|
|
- :pageSize='sum'
|
|
|
+ :pageSize="sum"
|
|
|
></Table>
|
|
|
</div>
|
|
|
<div class="page">
|
|
|
@@ -23,7 +23,11 @@
|
|
|
></Tablepage>
|
|
|
</div>
|
|
|
<div class="modal" v-if="modalFlag">
|
|
|
- <Modal :modalFlag="modalFlag" @hide_modal="showModal" @submit='submit'></Modal>
|
|
|
+ <Modal
|
|
|
+ :modalFlag="modalFlag"
|
|
|
+ @hide_modal="showModal"
|
|
|
+ @submit="submit"
|
|
|
+ ></Modal>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div v-else>
|
|
|
@@ -51,13 +55,7 @@ export default {
|
|
|
sum: 100, // 一共有多少条数据
|
|
|
pageSize: 20, // 每页展示的数据
|
|
|
currentPage: 1,
|
|
|
- // 表格配置
|
|
|
tableData: [],
|
|
|
- getDate: [
|
|
|
- { platform: "汽车之家", str: "123" },
|
|
|
- { platform: "其他", str: "124" },
|
|
|
- ],
|
|
|
- functionData: [],
|
|
|
modalFlag: false, // 控制模态框展示
|
|
|
};
|
|
|
},
|
|
|
@@ -95,49 +93,139 @@ export default {
|
|
|
}
|
|
|
console.log(this.currentPage);
|
|
|
},
|
|
|
- // 获取数据
|
|
|
- getData: function () {
|
|
|
- this.tableData = [];
|
|
|
- this.functionData = [];
|
|
|
- this.getDate.forEach((element) => {
|
|
|
- this.tableData.push({
|
|
|
- platform: element.platform,
|
|
|
- });
|
|
|
- this.functionData.push({
|
|
|
- str: element.str,
|
|
|
- });
|
|
|
- });
|
|
|
- },
|
|
|
// 展示、隐藏模态框
|
|
|
showModal: function () {
|
|
|
this.modalFlag = !this.modalFlag;
|
|
|
},
|
|
|
// 模态框保存
|
|
|
- submit: function(plateName) {
|
|
|
- console.log('plateName保存', plateName);
|
|
|
+ submit: function (plateName) {
|
|
|
+ this.addPublishPlatformInfo(plateName).then(() => {
|
|
|
+ this.selectPublishPlatformPage();
|
|
|
+ });
|
|
|
this.modalFlag = false;
|
|
|
},
|
|
|
// 点击编辑
|
|
|
edit(index, newName) {
|
|
|
- console.log(this.functionData[index].str, newName);
|
|
|
+ let id = this.tableData[index]["id"];
|
|
|
+ console.log(id);
|
|
|
+ this.updatePublishPlatformInfo(id, newName).then(() => {
|
|
|
+ this.updatePublishPlatformInfo();
|
|
|
+ });
|
|
|
},
|
|
|
// 点击删除
|
|
|
- deleteData: function(index) {
|
|
|
- console.log("删除", this.functionData[index].str);
|
|
|
+ deleteData: function (index) {
|
|
|
+ let id = this.tableData[index]['id'];
|
|
|
+ this.deletePublishPlatformInfo(id).then(() => {
|
|
|
+ this.selectPublishPlatformPage();
|
|
|
+ })
|
|
|
},
|
|
|
// 点击系列车型
|
|
|
- jumpRouter: function(index) {
|
|
|
+ jumpRouter: function (index) {
|
|
|
// 页面变化
|
|
|
this.$router.push({ query: { tag: "detail" } });
|
|
|
console.log("点击平台模块", this.functionData[index].str);
|
|
|
},
|
|
|
- // 删除数据
|
|
|
- detletData: function() {
|
|
|
- console.log('删除数据');
|
|
|
- }
|
|
|
+ // 新增平台 接口
|
|
|
+ addPublishPlatformInfo: function (platformName) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ this.$http({
|
|
|
+ method: "post",
|
|
|
+ url: "/base/publishPlatformManager/addPublishPlatformInfo",
|
|
|
+ data: {
|
|
|
+ platformName,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if (res.data && res.data.code === 200) {
|
|
|
+ console.log(res);
|
|
|
+ resolve();
|
|
|
+ } else {
|
|
|
+ alert("新增失败,请重试");
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.log(err);
|
|
|
+ reject(err);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 获取列表 接口
|
|
|
+ selectPublishPlatformPage: function () {
|
|
|
+ this.$http({
|
|
|
+ method: "post",
|
|
|
+ url: "/base/publishPlatformManager/selectPublishPlatformPage",
|
|
|
+ data: {},
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if (res.data && res.data.code === 200) {
|
|
|
+ console.log(res);
|
|
|
+ this.tableData = res.data.data;
|
|
|
+ this.sum = res.data.count;
|
|
|
+ } else {
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.log(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 编辑接口
|
|
|
+ updatePublishPlatformInfo: function (id, platformName) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ this.$http({
|
|
|
+ method: "post",
|
|
|
+ url: "/base/publishPlatformManager/updatePublishPlatformInfo",
|
|
|
+ data: {
|
|
|
+ id,
|
|
|
+ platformName,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ console.log(res, 1111);
|
|
|
+ if (res.data && res.data.code === 200) {
|
|
|
+ console.log(res);
|
|
|
+ resolve();
|
|
|
+ } else {
|
|
|
+ alert("编辑失败,请重试");
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ alert("编辑失败,请重试");
|
|
|
+ console.log(err);
|
|
|
+ reject(err);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ deletePublishPlatformInfo: function (id) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ this.$http({
|
|
|
+ method: "post",
|
|
|
+ url: "/base/publishPlatformManager/deletePublishPlatformInfo",
|
|
|
+ data: {
|
|
|
+ id,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if (res.data && res.data.code === 200) {
|
|
|
+ console.log(res);
|
|
|
+ resolve();
|
|
|
+ } else {
|
|
|
+ alert("编辑失败,请重试");
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ alert("编辑失败,请重试");
|
|
|
+ console.log(err);
|
|
|
+ reject(err);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
},
|
|
|
- mounted() {
|
|
|
- this.getData();
|
|
|
+ created() {
|
|
|
+ this.selectPublishPlatformPage();
|
|
|
},
|
|
|
};
|
|
|
</script>
|