feat(标签): 标签页面联调

dev
zjb 11 months ago
parent 03849bbb11
commit df2aa32b78

@ -18,7 +18,8 @@ module.exports = {
assetsPublicPath: '/', assetsPublicPath: '/',
proxyTable: { proxyTable: {
'/': { '/': {
target: 'http://39.103.180.196:9011', // 接口域名 // target: 'http://39.103.180.196:9011', // 接口域名
target: 'http://localhost:9011', // 接口域名
changeOrigin: true, //是否跨域 changeOrigin: true, //是否跨域
pathRewrite: { pathRewrite: {
'^/': '/' //需要rewrite重写的, '^/': '/' //需要rewrite重写的,

@ -0,0 +1,85 @@
/*
* @Description:
* @version: v1
* @Author: zhangjiabao
* @Date: 2024-01-08 00:20:50
*/
import request from "@/utils/request";
export default {
/**
* 查询标签列表
* @param {*} params
* @returns
*/
getList(data, pageNum, pageSize) {
return request({
// url: `/luoo-tag/tag/list?pageNum=${pageNum}&pageSize=${pageSize}`,
url: `/luoo-tag/tag/list`,
method: "get",
params:{
... data,
pageNum,
pageSize
}
});
},
/**
* 查询标签详情
* @param {*} params
* @returns
*/
getById(id) {
return request({
url: `/tag/${id}`,
method: "get"
});
},
/**
* 新增标签信息
* @param {*} data
* @returns
*/
create(data) {
return request({
url: `/luoo-tag/tag`,
method: "post",
data
});
},
/**
* 更新标签信息
* @param {*} id
* @param {*} data
* @returns
*/
update(data) {
return request({
url: `/luoo-tag/tag/${data.id}`,
method: "put",
data
});
},
/**
* 更新标签状态
* @param {*} id
* @param {*} state
* @returns
*/
updateStatus(id, state) {
return request({
url: `/luoo-tag/tag/status/${id}?state=${state}`,
method: "put"
});
},
/**
* 删除标签
* @param {*} params
* @returns
*/
delete(id) {
return request({
url: `/luoo-tag/tag/${id}`,
method: "delete"
});
}
};

@ -1,3 +1,9 @@
/*
* @Description:
* @version: v1
* @Author: zhangjiabao
* @Date: 2024-01-02 21:12:35
*/
import axios from 'axios' import axios from 'axios'
import { Message, MessageBox } from 'element-ui' import { Message, MessageBox } from 'element-ui'
import store from '../store' import store from '../store'
@ -28,7 +34,9 @@ service.interceptors.response.use(
* code为非20000是抛错 可结合自己业务进行修改 * code为非20000是抛错 可结合自己业务进行修改
*/ */
const res = response.data const res = response.data
if (res.code !== 20000) { // TODO: 关于code的逻辑需要重写
return response.data
if (!(res.code == 2000 || res.code == 200)) {
Message({ Message({
message: res.message, message: res.message,
type: 'error', type: 'error',

@ -9,7 +9,8 @@
<!-- card --> <!-- card -->
<el-card class="box-card"> <el-card class="box-card">
<div slot="header" class="card-header clearfix"> <div slot="header" class="card-header clearfix">
<span class="card-header-text">标签列表</span> <span v-if="tagType === 1" class="card-header-text"></span>
<span v-if="tagType === 2" class="card-header-text"></span>
<el-button <el-button
style="float: right; margin-top: -5px;" style="float: right; margin-top: -5px;"
type="primary" type="primary"
@ -25,14 +26,25 @@
<el-input <el-input
placeholder="标签名称" placeholder="标签名称"
size="medium" size="medium"
v-model="queryForm.data.tagName" v-model="queryForm.data.name"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item v-if="tagType === 2">
<el-select
placeholder="选择父级"
size="medium"
v-model="queryForm.data.parentId"
>
<el-option label="民谣" value="1744043047018172416"></el-option>
<el-option label="摇滚" value="1744044157997027328"></el-option>
<el-option label="流行" value="1746150704759836672"></el-option>
</el-select>
</el-form-item>
<el-form-item> <el-form-item>
<el-select <el-select
placeholder="选择发布人" placeholder="选择发布人"
size="medium" size="medium"
v-model="queryForm.data.publisher" v-model="queryForm.data.creatorId"
> >
<el-option label="发布人1" value="1"></el-option> <el-option label="发布人1" value="1"></el-option>
<el-option label="发布人2" value="2"></el-option> <el-option label="发布人2" value="2"></el-option>
@ -75,7 +87,8 @@
plain plain
icon="el-icon-full-screen" icon="el-icon-full-screen"
type="primary" type="primary"
@click="log('查看二级')" v-if="tagType === 1"
@click="handleChangeChildrenTag"
>查看二级</el-button >查看二级</el-button
> >
</el-form-item> </el-form-item>
@ -83,9 +96,10 @@
<!-- 表格 --> <!-- 表格 -->
<el-table <el-table
stripe stripe
class="in-card-table"
:data="table.data" :data="table.data"
v-loading.body="table.loadig" height="calc(100vh - 290px)"
v-loading="table.loading"
v-if="table.show"
element-loading-text="加载中" element-loading-text="加载中"
:header-cell-style="{ background: '#f5f7fa', color: '#606266' }" :header-cell-style="{ background: '#f5f7fa', color: '#606266' }"
border border
@ -96,17 +110,26 @@
{{ scope.$index + 1 }} {{ scope.$index + 1 }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="中文名称" prop="zhName"></el-table-column> <el-table-column label="中文名称" prop="nameCh"></el-table-column>
<el-table-column label="英文名称" prop="enName"></el-table-column> <el-table-column label="英文名称" prop="nameEn"></el-table-column>
<el-table-column label="歌曲数" prop="songCount"></el-table-column> <el-table-column
v-if="tagType === 2"
label="父标签"
prop="parentNameCh"
></el-table-column>
<el-table-column label="歌曲数" prop="songRefCount"></el-table-column>
<el-table-column <el-table-column
label="关联期刊数" label="关联期刊数"
prop="articleCount" prop="articleRefCount"
></el-table-column> ></el-table-column>
<el-table-column label="子标签数" prop="subTagCount"></el-table-column> <el-table-column
<el-table-column label="发布人" prop="publisher"></el-table-column> label="子标签数"
prop="childTagCount"
></el-table-column>
<el-table-column label="发布人" prop="creatorName"></el-table-column>
<el-table-column <el-table-column
label="创建时间" label="创建时间"
width="200"
sortable sortable
prop="createTime" prop="createTime"
></el-table-column> ></el-table-column>
@ -114,13 +137,20 @@
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch
style="margin-bottom: 4px;" style="margin-bottom: 4px;"
v-model="scope.row.inUse" v-model="scope.row.state"
active-color="#13ce66" active-color="#13ce66"
@change="handleTableRowStatusChange($event, scope.row)"
:active-value="1"
:inactive-value="0"
size="mini" size="mini"
></el-switch> ></el-switch>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column fixed="right" label="操作" width="300"> <el-table-column
fixed="right"
label="操作"
:width="[0, 300, 200][tagType]"
>
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
plain plain
@ -133,19 +163,29 @@
<el-button <el-button
plain plain
icon="el-icon-success" icon="el-icon-success"
v-if="tagType === 1"
@click="handleAddSubClick(scope.row)" @click="handleAddSubClick(scope.row)"
type="success" type="success"
size="mini" size="mini"
>新增二级</el-button >新增二级</el-button
> >
<el-button <el-popconfirm
plain confirm-button-text="确定"
icon="el-icon-delete" cancel-button-text="取消"
@click="log('删除' + scope.$index)" icon="el-icon-info"
type="danger" icon-color="red"
size="mini" title="是否确认删除标签?"
>删除</el-button @confirm="handleDeleteClick(scope.row)"
> >
<el-button
slot="reference"
plain
icon="el-icon-delete"
type="danger"
size="mini"
>删除</el-button
>
</el-popconfirm>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -153,6 +193,7 @@
<el-pagination <el-pagination
class="pagination-right" class="pagination-right"
background background
v-if="table.show"
layout="total, prev, pager, next, sizes" layout="total, prev, pager, next, sizes"
:current-page.sync="table.page.current" :current-page.sync="table.page.current"
:page-size="table.page.size" :page-size="table.page.size"
@ -165,9 +206,10 @@
<el-dialog <el-dialog
:title="['新增标签', '修改标签', '新增二级'][modifyDialog.type]" :title="['新增标签', '修改标签', '新增二级'][modifyDialog.type]"
class="popup-dialog" class="popup-dialog"
:visible="true" :visible="modifyDialog.visible"
v-if="modifyDialog.visible" v-if="modifyDialog.visible"
width="30%" width="30%"
:before-close="handleDialogBeforeClose"
> >
<el-form <el-form
:model="modifyDialog.form.data" :model="modifyDialog.form.data"
@ -176,23 +218,37 @@
label-width="100px" label-width="100px"
class="demo-ruleForm" class="demo-ruleForm"
> >
<el-form-item v-if="modifyDialog.type == 2" label="选择父级"> <el-form-item
v-if="tagType === 1 && modifyDialog.type == 2"
label="选择父级"
>
<el-input <el-input
disabled disabled
size="small" size="small"
v-model="modifyDialog.form.data.parent" v-model="modifyDialog.form.data.parentName"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="中文名称" prop="zhName"> <el-form-item v-if="tagType === 2" label="选择父级" prop="parentId">
<el-select
placeholder="选择父级"
size="medium"
v-model="modifyDialog.form.data.parentId"
>
<el-option label="民谣" value="1744043047018172416"></el-option>
<el-option label="摇滚" value="1744044157997027328"></el-option>
<el-option label="流行" value="1746150704759836672"></el-option>
</el-select>
</el-form-item>
<el-form-item label="中文名称" prop="nameCh">
<el-input <el-input
size="small" size="small"
v-model="modifyDialog.form.data.zhName" v-model="modifyDialog.form.data.nameCh"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="英文名称" prop="enName"> <el-form-item label="英文名称" prop="nameEn">
<el-input <el-input
size="small" size="small"
v-model="modifyDialog.form.data.enName" v-model="modifyDialog.form.data.nameEn"
></el-input> ></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -207,10 +263,14 @@
</template> </template>
<script> <script>
import tagApi from "@/api/tag";
export default { export default {
name: "Tag", name: "Tag",
data() { data() {
return { return {
// 1- 2-
tagType: 1,
// //
queryForm: { queryForm: {
remoteData: { remoteData: {
@ -218,14 +278,17 @@ export default {
}, },
lastQuery: {}, lastQuery: {},
data: { data: {
tagName: null, level: 1,
publisher: null, parentId: null,
name: null,
creatorId: null,
timeRange: [] timeRange: []
} }
}, },
// //
table: { table: {
loadinng: true, show: true,
loading: true,
data: [], data: [],
page: { page: {
current: 1, current: 1,
@ -239,26 +302,27 @@ export default {
type: 0, // 0for 1for 2for2 type: 0, // 0for 1for 2for2
form: { form: {
rules: { rules: {
zhName: [ nameCh: [
{ required: true, message: "请输入中文名称", trigger: "blur" } { required: true, message: "请输入中文名称", trigger: "blur" }
], ],
enName: [ nameEn: [
{ required: true, message: "请输入英文名称", trigger: "blur" } { required: true, message: "请输入英文名称", trigger: "blur" }
] ]
}, },
data: { data: {
parent: null, id: null,
zhName: null, parentName: null,
enName: null parentId: null,
nameCh: null,
nameEn: null
} }
} }
}, }
dialogVisible: false
}; };
}, },
filters: {}, filters: {},
created() { created() {
this.fetchData(); this.fetchData(this.queryForm.data);
}, },
methods: { methods: {
log(e) { log(e) {
@ -268,23 +332,35 @@ export default {
/** /**
* 查询表格数据 * 查询表格数据
*/ */
fetchData() { fetchData(param) {
// //
this.queryForm.lastQuery = this.queryForm.data; this.queryForm.lastQuery = param;
console.log("formData", this.queryForm.data);
console.log("pageData", this.table.page); let queryParam = {
// ...param
};
// if (this.queryForm.data.timeRange) {
// if (this.queryForm.data.timeRange[0]) {
// queryParam.createTimeStart =
// this.queryForm.data.timeRange[0] + " 00:00:00";
// }
// if (this.queryForm.data.timeRange[1]) {
// queryParam.createTimeEnd =
// this.queryForm.data.timeRange[1] + " 23:59:59";
// }
// }
this.table.loading = true; this.table.loading = true;
for (let i = 0; i < 10; i++) { this.table.page.total = 0;
this.table.data.push({ this.table.data = [];
zhName: "title1", tagApi
enName: "enname", .getList(queryParam, this.table.page.current, this.table.page.size)
inUse: true .then(res => {
this.table.data = res.data.content;
this.table.page.total = res.data.totalElements;
this.table.page.current = res.data.number + 1;
this.table.loading = false;
}); });
}
// page
this.table.page.total = 20;
this.table.loading = false;
}, },
// ************************* ************************* // ************************* *************************
/** /**
@ -293,15 +369,17 @@ export default {
handleQueryClick() { handleQueryClick() {
this.table.page.current = 1; this.table.page.current = 1;
this.table.page.total = 0; this.table.page.total = 0;
this.fetchData(); this.fetchData(this.queryForm.data);
}, },
/** /**
* 重置点击事件 * 重置点击事件
*/ */
handleResetClick() { handleResetClick() {
this.queryForm.data = { this.queryForm.data = {
tagName: null, level: this.tagType,
publisher: null, parentId: null,
name: null,
creatorId: null,
timeRange: [] timeRange: []
}; };
}, },
@ -309,6 +387,12 @@ export default {
* 新建标签点击事件 * 新建标签点击事件
*/ */
handleAddClick() { handleAddClick() {
this.modifyDialog.form.data.id = null;
this.modifyDialog.form.data.parentName = null;
this.modifyDialog.form.data.parentId = null;
this.modifyDialog.form.data.nameCh = null;
this.modifyDialog.form.data.nameEn = null;
this.modifyDialog.type = 0; this.modifyDialog.type = 0;
this.modifyDialog.visible = true; this.modifyDialog.visible = true;
}, },
@ -316,7 +400,19 @@ export default {
* 编辑标签点击事件 * 编辑标签点击事件
*/ */
handleModifyClick(row) { handleModifyClick(row) {
console.log(row); this.modifyDialog.form.data.id = row.id;
if (this.tagType === 1) {
this.modifyDialog.form.data.parentName = null;
this.modifyDialog.form.data.parentId = null;
}
if (this.tagType === 2) {
this.modifyDialog.form.data.parentName = row.parentName;
this.modifyDialog.form.data.parentId = row.parentId;
}
this.modifyDialog.form.data.nameCh = row.nameCh;
this.modifyDialog.form.data.nameEn = row.nameEn;
this.modifyDialog.type = 1; this.modifyDialog.type = 1;
this.modifyDialog.visible = true; this.modifyDialog.visible = true;
}, },
@ -324,11 +420,43 @@ export default {
* 新增二级点击事件 * 新增二级点击事件
*/ */
handleAddSubClick(row) { handleAddSubClick(row) {
console.log(row); this.modifyDialog.form.data.id = null;
this.modifyDialog.form.data.parent = row["zhName"]; this.modifyDialog.form.data.parentName = row.nameCh;
this.modifyDialog.form.data.parentId = row.id;
this.modifyDialog.form.data.nameCh = null;
this.modifyDialog.form.data.nameEn = null;
this.modifyDialog.type = 2; this.modifyDialog.type = 2;
this.modifyDialog.visible = true; this.modifyDialog.visible = true;
}, },
/**
* 删除按钮点击事件
*/
handleDeleteClick(row) {
tagApi.delete(row.id).then(res => {
if (res.code === 200) {
this.$message.success(res.message);
this.fetchData(this.queryForm.lastQuery);
return;
} else {
this.$message.error(res.message);
}
});
},
/**
* 表格内状态滑块切换事件
*/
handleTableRowStatusChange($event, row) {
tagApi.updateStatus(row.id, $event).then(res => {
if (res.code === 200) {
this.$message.success(res.message);
} else {
this.$message.error(res.message);
}
this.fetchData(this.queryForm.lastQuery);
});
},
/** /**
* 弹窗取消按扭点击事件 * 弹窗取消按扭点击事件
*/ */
@ -339,21 +467,100 @@ export default {
* 弹窗确定按扭点击事件 * 弹窗确定按扭点击事件
*/ */
handleDialogSubmit() { handleDialogSubmit() {
console.log(this.modifyDialog.form.data); this.$refs.modifyDialogForm.validate(valid => {
if (valid) {
//
if (this.modifyDialog.type === 0) {
tagApi.create(this.modifyDialog.form.data).then(res => {
if (res.code === 200) {
this.$message.success(res.message);
this.modifyDialog.visible = false;
this.table.page.current = 1;
//
this.handleResetClick();
this.fetchData(this.queryForm.data);
} else {
this.$message.error(res.message);
}
});
return;
}
//
if (this.modifyDialog.type === 1) {
tagApi.update(this.modifyDialog.form.data).then(res => {
if (res.code === 200) {
this.$message.success(res.message);
this.modifyDialog.visible = false;
this.fetchData(this.queryForm.lastQuery);
} else {
this.$message.error(res.message);
}
});
return;
}
//
if (this.modifyDialog.type === 2) {
tagApi.create(this.modifyDialog.form.data).then(res => {
if (res.code === 200) {
this.$message.success(res.message);
this.modifyDialog.visible = false;
this.fetchData(this.queryForm.lastQuery);
} else {
this.$message.error(res.message);
}
});
return;
}
} else {
this.$message.error("请完善表单相关信息!");
return false;
}
});
},
/**
* 弹窗观察按扭点击事件
*/
handleDialogBeforeClose(done) {
this.modifyDialog.visible = false; this.modifyDialog.visible = false;
done();
}, },
/** /**
* 分页组件页数变化事件 * 分页组件页数变化事件
*/ */
handlePageCurrentChange() { handlePageCurrentChange(val) {
console.log(this.table.page.size + " " + this.table.page.current); this.table.page.current = val;
this.fetchData(this.queryForm.lastQuery);
}, },
/** /**
* 分页组件大小变化事件 * 分页组件大小变化事件
*/ */
handlePageSizeChange(val) { handlePageSizeChange(val) {
this.table.page.size = val; this.table.page.size = val;
console.log(this.table.page.size + " " + this.table.page.current); this.fetchData(this.queryForm.lastQuery);
},
/**
* 查看二级按钮点击事件
*/
handleChangeChildrenTag() {
this.tagType = 2;
//
this.queryForm.data.level = 2;
this.handleResetClick();
//
this.modifyDialog.form.rules["parentId"] = [
{ required: true, message: "请选择父级", trigger: "change" }
];
//
this.table.data = [];
this.table.page.current = 1;
this.table.page.size = 10;
this.table.show = false;
this.$nextTick(() => {
this.table.show = true;
});
this.fetchData(this.queryForm.data);
} }
} }
}; };
@ -396,9 +603,6 @@ export default {
height: 60px; height: 60px;
display: flex; display: flex;
} }
.in-card-table {
height: calc(100vh - 290px);
}
.clearfix:before, .clearfix:before,
.clearfix:after { .clearfix:after {
display: table; display: table;

Loading…
Cancel
Save