diff --git a/src/api/article.js b/src/api/article.js index c2e0129..8651134 100644 --- a/src/api/article.js +++ b/src/api/article.js @@ -10,7 +10,9 @@ export function fetchList(query) { } // 文章的编辑、保存 -export function editArticle(data) { +export function editArticle(data) { + + console.log(data , 'datas') return request({ url: '/setCenter/Article/edit', method: 'post', diff --git a/src/api/sort-management.js b/src/api/sort-management.js index e29a763..39e4334 100644 --- a/src/api/sort-management.js +++ b/src/api/sort-management.js @@ -16,3 +16,47 @@ export function getCategoryList(params) { }) } + + +export function getCategoryShow(id, params) { + return request({ + url: `category/show/${id}`, + method: 'get', + params: params + }) +} + + + +export function getCategoryDelete(id) { + return request({ + url: `category/delete/${id}`, + method: 'DELETE' + }) +} + + + +export function getCategoryAdd(data) { + console.log(data ,'data') + return request({ + url: `category/create`, + method: 'POST', + data: { + name: data.name, + source_platform: data.source_platform + } + }) +} + + + +export function getCategoryUpdate( data ,id ) { + console.log(data ,'getCategoryUpdate') + + return request({ + url: `category/update/${id}`, + method: 'PUT', + data: data + }) +} diff --git a/src/utils/request.js b/src/utils/request.js index 5682252..b3cc74b 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,8 +1,9 @@ import axios from 'axios' import { Message } from 'element-ui' -import store from '@/store' + import { getToken } from '@/utils/auth' +import qs from 'qs' // create an axios instance const service = axios.create({ baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url @@ -19,7 +20,9 @@ service.interceptors.request.use( config.headers['Content-Type'] = 'application/x-www-form-urlencoded'; config.headers['api-token'] = getToken() || '' - + + + config.data = qs.stringify(config.data) // 转为formdata数据格式 return config }, error => { diff --git a/src/views/sort-management/components/check-books-dialog.vue b/src/views/sort-management/components/check-books-dialog.vue index 9850181..3e0e9fa 100644 --- a/src/views/sort-management/components/check-books-dialog.vue +++ b/src/views/sort-management/components/check-books-dialog.vue @@ -2,7 +2,7 @@ @@ -16,224 +16,162 @@ inline >
- - + + - - - - - + + + -
-
- - - 提交 - - + + 提交 + 重置
- -
- -
+
- - - - - + + + + + + + + +
- -
- -
diff --git a/src/views/sort-management/components/edit-dialog.vue b/src/views/sort-management/components/edit-dialog.vue index cfe04f9..491df5a 100644 --- a/src/views/sort-management/components/edit-dialog.vue +++ b/src/views/sort-management/components/edit-dialog.vue @@ -7,110 +7,157 @@ > - + - - - - - + - - 确认 - - - 取消 - + 确认 + 取消 diff --git a/src/views/sort-management/index.vue b/src/views/sort-management/index.vue index 1bc4c5b..fe8337a 100644 --- a/src/views/sort-management/index.vue +++ b/src/views/sort-management/index.vue @@ -21,7 +21,7 @@ - + - + @@ -66,11 +66,18 @@ :is-dialog="isEditDialog" :dialog-title="editTitleDialog" @handle-close="isEditDialog = false" - :btn5Data="btn5Data" + :dropdownData="dropdownData" :CategoryList="CategoryList" + :selectItem="selectItem" + @handle-success="onHandleSuccess" /> - + @@ -80,7 +87,12 @@ import CustomButton from "@/components/CustomButton/index"; import EditDialog from "./components/edit-dialog"; import CheckBooksDialog from "./components/check-books-dialog"; -import { getPlatformList, getCategoryList } from "@/api/sort-management"; +import { + getPlatformList, + getCategoryList, + getCategoryShow, + getCategoryDelete, +} from "@/api/sort-management"; export default { components: { @@ -103,17 +115,25 @@ export default { dropdownData: [], CategoryList: [], btn5Data: {}, + booksData: null, + booksItem: null, + selectItem: {}, }; }, created() { this.init(); }, methods: { - init() { - this.onPlatformList(); + init(refresh = false) { + this.onPlatformList(refresh); + }, + + onHandleSuccess() { + this.init(); + this.isEditDialog = false; }, - onPlatformList() { + onPlatformList(refresh) { getPlatformList().then((res) => { let obj = res.data; let arr = []; @@ -128,39 +148,56 @@ export default { this.dropdownData = arr; this.btn5Data = arr[0]; this.onCategoryList(arr[0].value); + refresh && this.$message.success("刷新成功"); }); }, onCategoryList(source_platform) { getCategoryList({ - source_platform, + source_platform: source_platform, + need_num: true, }).then((res) => { this.tableData = res.data; // 分类列表 }); }, handleButton5(data) { - console.log(data) this.btn5Data = data; - this.onCategoryList(data.value); + this.onCategoryList(data.value); this.$forceUpdate(); }, refreshData() { - console.log("刷新"); + this.init(true); }, // 打开编辑弹窗操作 openEditDialog(row) { + this.isEditDialog = true; if (row) { this.editTitleDialog = "编辑分类"; + this.selectItem = { + source_platform: row.id, + name: row.category_name, + }; } else { this.editTitleDialog = "新增分类"; } }, // 打开查看书籍弹窗 - openCheckBooksDialog() { + openCheckBooksDialog(data) { + this.booksData = []; + getCategoryShow(data.id, { + source_platform: this.btn5Data.value, + }).then((res) => { + this.booksData = res.data; + this.booksItem = { + data: data, + btn5Data: this.btn5Data, + }; + }); + this.isCheckDialog = true; }, @@ -175,7 +212,10 @@ export default { } ) .then(() => { - this.selectItem = row; + console.log(row); + getCategoryDelete(row.id).then((res) => { + this.init(); + }); }) .catch(() => {}); },