You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

202 lines
7.7 KiB

3 years ago
<template>
<div class="main-content">
<div class="area-form">
<el-form :inline="true" size="default">
3 years ago
<el-form-item label="素材名称">
<el-input v-model="form.keyword" placeholder="请输入"></el-input>
</el-form-item>
3 years ago
<el-form-item label="分组">
3 years ago
<el-select clearable v-model="form.groupId" placeholder="请选择">
3 years ago
<el-option v-for="item in apiData.groupData"
:key="item.id" :label="item.name" :value="item.id"></el-option>
3 years ago
</el-select>
</el-form-item>
3 years ago
<el-form-item label="车系">
3 years ago
<el-select multiple clearable v-model="form.brandIdList" style="width: 240px" placeholder="请选择">
3 years ago
<el-option v-for="item in apiData.brandData"
:key="item.id" :label="item.name" :value="item.id"></el-option>
3 years ago
</el-select>
</el-form-item>
<el-form-item label="标签">
3 years ago
<el-select multiple clearable v-model="form.tagIdList" style="width: 240px" placeholder="请选择">
3 years ago
<el-option v-for="item in apiData.tagData"
:key="item.id" :label="item.title" :value="item.id"></el-option>
</el-select>
3 years ago
</el-form-item>
<el-form-item>
<el-button type="primary" @click="confirm"> </el-button>
3 years ago
<el-button @click="reset"> </el-button>
3 years ago
</el-form-item>
</el-form>
</div>
<div class="button-tab">
3 years ago
<el-button size="default" type="primary" @click="goRelease"></el-button>
3 years ago
<el-button size="default" @click="multiDel"></el-button>
3 years ago
</div>
<div class="area-table">
3 years ago
<el-table :data="tableData.data" size="default" border
@selection-change="handleSelect"
:header-cell-style="{background: '#EEE'}">
<el-table-column type="selection" width="55" />
3 years ago
<el-table-column prop="title" label="素材" width="360"></el-table-column>
3 years ago
<el-table-column prop="tag" label="标签" width="240">
<template #default="scope">
3 years ago
<el-tag style="margin-right: 8px" v-for="(item,index) in scope.row.tagList" :key="index">
{{item.title}}
3 years ago
</el-tag>
</template>
</el-table-column>
3 years ago
<el-table-column prop="groupName" label="分组" :formatter="groupFormatter"></el-table-column>
3 years ago
<el-table-column prop="brandList" label="车型">
<template #default="scope">
<el-tag style="margin-right: 8px" v-for="(item,index) in scope.row.brandList" :key="index">
{{item.name}}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="creatAt" label="上传时间"></el-table-column>
3 years ago
<el-table-column prop="action" label="操作" fixed="right" width="240">
<template #default="scope">
3 years ago
<el-link type="primary" @click="goEdit(scope.row.id)"></el-link>
<el-link type="danger" @click="singleDel(scope.row.id)" style="margin-left: 8px">删除</el-link>
3 years ago
</template>
</el-table-column>
</el-table>
<el-pagination
v-model:currentPage="pagination.current"
v-model:page-size="pagination.pageSize"
:page-sizes="[10, 20, 30, 40]"
background
layout="total, sizes, prev, pager, next, jumper"
:total="pagination.total"
/>
</div>
</div>
</template>
<script>
3 years ago
import {defineComponent, reactive, ref, watch, getCurrentInstance} from 'vue'
3 years ago
import {groupFormatter} from './config.js'
3 years ago
export default defineComponent({
name: 'v-questList',
setup() {
const form = reactive({
3 years ago
keyword: undefined,
3 years ago
groupId: undefined,
tagIdList: [],
brandIdList: [],
3 years ago
});
const tableData = reactive({
data: [],
});
3 years ago
const apiData = reactive({
tagData: [],
brandData: [],
groupData: [],
});
3 years ago
const selectedKeys = ref([]);
3 years ago
const { proxy } = getCurrentInstance();
3 years ago
const pagination = reactive({
total: 0,
current: 1,
pageSize: 10
});
return {
3 years ago
form,proxy,
3 years ago
apiData,tableData,
3 years ago
pagination,selectedKeys,
3 years ago
groupFormatter
3 years ago
}
},
mounted() {
3 years ago
this.getApi();
3 years ago
this.getData();
watch(() => (this.pagination.pageSize), () => {
this.getData()
});
watch(() => (this.pagination.current), () => {
this.getData()
})
},
methods: {
3 years ago
getApi() {
this.proxy.$post("/tag/list", {}).then(res => {
this.apiData.tagData = res.data.records;
}).catch(() => {});
this.proxy.$post("/brand/list", {}).then(res => {
this.apiData.brandData = res.data.records;
}).catch(() => {});
this.proxy.$post("/referenceGroup/list", {}).then(res => {
this.apiData.groupData = res.data.records;
}).catch(() => {});
},
3 years ago
getData() {
3 years ago
let obj = Object.assign(this.form, {pageNum: this.pagination.current,pageSize: this.pagination.pageSize})
3 years ago
this.proxy.$post("/reference/list", obj).then(res => {
3 years ago
if(res.code == 200) {
const data = res.data
this.tableData.data = data.records;
this.pagination.total = data.total
} else {
this.$message.error(res.msg)
}
3 years ago
}).catch(() => {});
3 years ago
},
confirm() {
this.getData()
},
3 years ago
reset() {
3 years ago
this.form.keyword = undefined;
3 years ago
this.form.groupId = undefined;
this.form.tagIdList = [];
this.form.brandIdList = [];
this.getData()
},
3 years ago
handleSelect(index) {
let arr = [];
index.forEach(ele => {
arr.push(ele.id)
3 years ago
});
3 years ago
this.selectedKeys = arr;
3 years ago
},
3 years ago
goRelease() {
3 years ago
this.$router.push({ name: "MatUpload" })
3 years ago
},
goEdit(value) {
3 years ago
this.$router.push({ name: "MatEdit",params:{id:value}})
3 years ago
},
3 years ago
//删除
singleDel(id) {
this.$alert(
3 years ago
'是否删除?', //文字
3 years ago
'删除', //标题
{type: 'warning'}
).then(() => {
3 years ago
this.proxy.$post("/reference/del", {idList: [id]}).then(res => {
3 years ago
this.getData();
this.$message.success(res.data);
}).catch(() => {});
3 years ago
}).catch(() => {})
3 years ago
},
multiDel() {
3 years ago
this.$alert(
'是否删除选中的素材?', //文字
'删除', //标题
{type: 'warning'}
).then(() => {
this.proxy.$post("/reference/del", {idList: this.selectedKeys}).then(res => {
this.getData();
this.$message.success(res.data);
this.selectedKeys = [];
}).catch(() => {});
}).catch(() => {})
3 years ago
}
3 years ago
}
})
</script>
<style lang="less" scoped>
.area-table {
margin-top: 16px
}
</style>