|
@@ -2,26 +2,21 @@
|
|
|
<!-- 培训管理-标签管理 -->
|
|
|
<div class="label-manage-wrap traing-manage">
|
|
|
<div class="top-wrap">
|
|
|
- <el-button type="primary" @click="handleModifyLabel({})">新增标签</el-button>
|
|
|
- <el-input v-model="searchText" clearable
|
|
|
- prefix-icon="el-icon-search" placeholder="请输入标签名称" @input="handleCurrentChange(1)"
|
|
|
- style="width:240px;"></el-input>
|
|
|
+ <t-button theme="primary" @click="handleModifyLabel({})">新增标签</t-button>
|
|
|
+ <t-input v-model="searchText" clearable placeholder="请输入标签名称" @input="handleCurrentChange(1)" style="width:240px;">
|
|
|
+ <template #prefixIcon>
|
|
|
+ <SearchIcon/>
|
|
|
+ </template>
|
|
|
+ </t-input>
|
|
|
</div>
|
|
|
<div class="table-wrap">
|
|
|
- <el-table :data="tableData" border v-loading="tableLoading">
|
|
|
- <el-table-column v-for="column in tableColumn" :key="column.key"
|
|
|
- :label="column.label" align="center"
|
|
|
- :prop="column.key"
|
|
|
- :min-width="column.minWidth">
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="操作" align="center">
|
|
|
- <template slot-scope="{row}">
|
|
|
- <el-button type="text" @click="handleModifyLabel(row)">编辑</el-button>
|
|
|
- <el-button type="text" @click="deleteLabel(row)" style="color:red;">删除</el-button>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
- <el-pagination
|
|
|
+ <t-table :data="tableData" :bordered="true" v-loading="tableLoading" :columns="tableColumn" rowKey="TagId">
|
|
|
+ <template #opt="{ row }">
|
|
|
+ <t-button variant="text" theme="primary" @click="handleModifyLabel(row)">编辑</t-button>
|
|
|
+ <t-button variant="text" @click="deleteLabel(row)" style="color:red;">删除</t-button>
|
|
|
+ </template>
|
|
|
+ </t-table>
|
|
|
+ <t-pagination
|
|
|
layout="total,prev,pager,next,jumper"
|
|
|
background
|
|
|
:current-page="currentPage"
|
|
@@ -29,138 +24,139 @@
|
|
|
:page-size="pageSize"
|
|
|
:total="total"
|
|
|
style="text-align:right;margin-top:30px;">
|
|
|
- </el-pagination>
|
|
|
+ </t-pagination>
|
|
|
</div>
|
|
|
<!-- 添加标签弹窗 -->
|
|
|
- <el-dialog
|
|
|
- :title="currentLabel.TagId?'编辑标签':'添加标签'"
|
|
|
+ <t-dialog
|
|
|
+ :header="currentLabel.TagId?'编辑标签':'添加标签'"
|
|
|
:visible.sync="isModifyDialogShow"
|
|
|
- :close-on-click-modal="false"
|
|
|
- :modal-append-to-body="false"
|
|
|
@close="isModifyDialogShow=false"
|
|
|
width="589px"
|
|
|
- v-dialogDrag
|
|
|
- center
|
|
|
+ :footer="false"
|
|
|
>
|
|
|
<div class="dialog-container">
|
|
|
<div class="input-item">
|
|
|
- <el-input placeholder="请输入标签名称" v-model.trim="currentLabel.TagName" required ></el-input>
|
|
|
+ <t-input placeholder="请输入标签名称" v-model.trim="currentLabel.TagName" required ></t-input>
|
|
|
</div>
|
|
|
<p class="form-hint">注:名称不得超过5个字</p>
|
|
|
</div>
|
|
|
<div class="foot-container">
|
|
|
- <el-button @click="isModifyDialogShow=false">取 消</el-button>
|
|
|
- <el-button type="primary" @click="modifyLabel">确认</el-button>
|
|
|
+ <t-button @click="isModifyDialogShow=false">取 消</t-button>
|
|
|
+ <t-button theme="primary" @click="modifyLabel">确认</t-button>
|
|
|
</div>
|
|
|
- </el-dialog>
|
|
|
+ </t-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
-<script>
|
|
|
-import {labelTableColumn} from './config/tableColumn'
|
|
|
-import {TagInterface} from '@/api/modules/trainingApi'
|
|
|
-export default {
|
|
|
- data() {
|
|
|
- return {
|
|
|
- /* table */
|
|
|
- tableLoading:false,
|
|
|
- tableData:[],
|
|
|
- tableColumn:labelTableColumn,
|
|
|
- searchText:'',
|
|
|
- /* table-page */
|
|
|
- currentPage:1,
|
|
|
- pageSize:10,
|
|
|
- total:0,
|
|
|
- /* modify label */
|
|
|
- currentLabel:{},
|
|
|
- isModifyDialogShow:false,
|
|
|
- };
|
|
|
- },
|
|
|
- methods: {
|
|
|
- handleModifyLabel(data){
|
|
|
- this.currentLabel = _.cloneDeep(data)
|
|
|
- this.isModifyDialogShow = true
|
|
|
- },
|
|
|
- async modifyLabel(){
|
|
|
- if(!this.currentLabel.TagName){
|
|
|
- this.$message.warning("请输入标签名称")
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.currentLabel.TagName.length>5){
|
|
|
- this.$message.warning("标签名称过长,请重新编辑")
|
|
|
- return
|
|
|
- }
|
|
|
- let res = null
|
|
|
- if(this.currentLabel.TagId){
|
|
|
- //edit
|
|
|
- res = await TagInterface.editTag({
|
|
|
- TagId:this.currentLabel.TagId,
|
|
|
- TagName:this.currentLabel.TagName
|
|
|
- })
|
|
|
- }else{
|
|
|
- //add
|
|
|
- res = await TagInterface.addTag({
|
|
|
- TagName:this.currentLabel.TagName
|
|
|
- })
|
|
|
- }
|
|
|
- if(res.Ret!==200) return
|
|
|
- //添加/编辑成功
|
|
|
- this.$message.success(`${this.currentLabel.TagId?'编辑':'添加'}成功`)
|
|
|
- this.currentPage = 1
|
|
|
- this.getTableData()
|
|
|
- this.isModifyDialogShow = false
|
|
|
- },
|
|
|
- deleteLabel(label){
|
|
|
- if(label.VideoTotal!==0){
|
|
|
- this.$confirm('该标签已关联视频,删除失败','提示',{confirmButtonText:'知道了',showCancelButton:false,type:'error'})
|
|
|
- return
|
|
|
- }
|
|
|
- this.$confirm(
|
|
|
- '删除后不可恢复,是否确认删除该标签?',
|
|
|
- '提示',
|
|
|
- {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning',
|
|
|
- }
|
|
|
- ).then(()=>{
|
|
|
- TagInterface.deleteTag({
|
|
|
- TagId:label.TagId
|
|
|
- }).then(res=>{
|
|
|
- if(res.Ret!==200) return
|
|
|
- this.$message.success('删除成功')
|
|
|
- this.currentPage=1
|
|
|
- this.getTableData()
|
|
|
- })
|
|
|
- }).catch(()=>{}).finally(()=>{})
|
|
|
- },
|
|
|
- getTableData(){
|
|
|
- this.tableLoading = true
|
|
|
- TagInterface.getTagList({
|
|
|
- PageSize:this.pageSize,
|
|
|
- CurrentIndex:this.currentPage,
|
|
|
- Keyword:this.searchText
|
|
|
- }).then(res=>{
|
|
|
- this.tableLoading = false
|
|
|
- if(res.Ret!==200) return
|
|
|
- if(!res.Data){
|
|
|
- this.tableData = []
|
|
|
- this.total = 0
|
|
|
- return
|
|
|
- }
|
|
|
- this.tableData = res.Data.List||[]
|
|
|
- this.total = res.Data.Paging.Totals
|
|
|
- })
|
|
|
- },
|
|
|
- handleCurrentChange(page){
|
|
|
- this.currentPage = page
|
|
|
- this.getTableData()
|
|
|
- }
|
|
|
- },
|
|
|
- mounted(){
|
|
|
- this.getTableData()
|
|
|
+<script setup>
|
|
|
+import { ref, reactive, onMounted } from 'vue';
|
|
|
+import { labelTableColumn } from './config/tableColumn';
|
|
|
+import { TagInterface } from '@/api/modules/trainingApi';
|
|
|
+import { SearchIcon } from 'tdesign-icons-vue-next';
|
|
|
+import _ from 'lodash';
|
|
|
+
|
|
|
+// 定义响应式数据
|
|
|
+const tableLoading = ref(false);
|
|
|
+const tableData = ref([]);
|
|
|
+const tableColumn = labelTableColumn;
|
|
|
+const searchText = ref('');
|
|
|
+const currentPage = ref(1);
|
|
|
+const pageSize = ref(10);
|
|
|
+const total = ref(0);
|
|
|
+const currentLabel = ref({});
|
|
|
+const isModifyDialogShow = ref(false);
|
|
|
+
|
|
|
+// handleModifyLabel 方法
|
|
|
+const handleModifyLabel = (data) => {
|
|
|
+ // currentLabel.value =
|
|
|
+ currentLabel.value = _.cloneDeep(data);
|
|
|
+ isModifyDialogShow.value = true;
|
|
|
+};
|
|
|
+
|
|
|
+// modifyLabel 方法
|
|
|
+const modifyLabel = async () => {
|
|
|
+ console.log(currentLabel.value);
|
|
|
+
|
|
|
+ if (!currentLabel.value.TagName) {
|
|
|
+ MessagePlugin.warning("请输入标签名称");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (currentLabel.value.TagName.length > 5) {
|
|
|
+ MessagePlugin.warning("标签名称过长,请重新编辑");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let res = null;
|
|
|
+ if (currentLabel.value.TagId) {
|
|
|
+ // edit
|
|
|
+ res = await TagInterface.editTag({
|
|
|
+ TagId: currentLabel.value.TagId,
|
|
|
+ TagName: currentLabel.value.TagName
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // add
|
|
|
+ res = await TagInterface.addTag({
|
|
|
+ TagName: currentLabel.value.TagName
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (res.Ret !== 200) return;
|
|
|
+ // 添加/编辑成功
|
|
|
+ MessagePlugin.success(`${currentLabel.value.TagId ? '编辑' : '添加'}成功`);
|
|
|
+ currentPage.value = 1;
|
|
|
+ getTableData();
|
|
|
+ isModifyDialogShow.value = false;
|
|
|
+};
|
|
|
+
|
|
|
+// deleteLabel 方法
|
|
|
+const deleteLabel = async (label) => {
|
|
|
+ if (label.VideoTotal !== 0) {
|
|
|
+ await $confirmDialog({
|
|
|
+ body: '该标签已关联视频,删除失败',
|
|
|
+ confirmBtn:{default:'知道了',theme:'primary'},
|
|
|
+ cancelBtn: null
|
|
|
+ })
|
|
|
+ return;
|
|
|
}
|
|
|
+ await $confirmDialog({
|
|
|
+ body: '删除后不可恢复,是否确认删除该标签?',
|
|
|
+ confirmBtn:{default:'确认',theme:'primary'},
|
|
|
+ })
|
|
|
+ TagInterface.deleteTag({ TagId: label.TagId }).then(res => {
|
|
|
+ if (res.Ret !== 200) return;
|
|
|
+ MessagePlugin.success('删除成功');
|
|
|
+ currentPage.value = 1;
|
|
|
+ getTableData();
|
|
|
+ });
|
|
|
};
|
|
|
+
|
|
|
+// getTableData 方法
|
|
|
+const getTableData = async () => {
|
|
|
+ tableLoading.value = true;
|
|
|
+ const res = await TagInterface.getTagList({
|
|
|
+ PageSize: pageSize.value,
|
|
|
+ CurrentIndex: currentPage.value,
|
|
|
+ Keyword: searchText.value
|
|
|
+ });
|
|
|
+ tableLoading.value = false;
|
|
|
+ if (res.Ret !== 200) return;
|
|
|
+ if (!res.Data) {
|
|
|
+ tableData.value = [];
|
|
|
+ total.value = 0;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ tableData.value = res.Data.List || [];
|
|
|
+ total.value = res.Data.Paging.Totals;
|
|
|
+};
|
|
|
+
|
|
|
+// handleCurrentChange 方法
|
|
|
+const handleCurrentChange = (page) => {
|
|
|
+ currentPage.value = page;
|
|
|
+ getTableData();
|
|
|
+};
|
|
|
+
|
|
|
+// 生命周期钩子
|
|
|
+onMounted(() => {
|
|
|
+ getTableData();
|
|
|
+});
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|