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.
 
 
 
 

711 lines
20 KiB

<template>
<basic-container>
<div class="avue-crud">
<div v-h5uShow="!search">
<!-- 查询模块 -->
<el-form :inline="true" :model="query" class="header_search">
<el-form-item label="品牌名称:">
<el-input v-model="query.brandName" placeholder="请输入品牌名称"></el-input>
</el-form-item>
<el-form-item label="品牌编号:">
<el-input v-model="query.brandCode" placeholder="请输入品牌编号"></el-input>
</el-form-item>
<el-form-item label="承接时间:" class="el-times">
<el-date-picker
class="h100"
v-model="dataShi"
type="daterange"
unlink-panels
range-separator="至"
start-placeholder="开始时间"
end-placeholder="结束时间"
:shortcuts="shortcuts"
/>
</el-form-item>
<!-- 查询按钮 -->
<el-form-item class="el-btn">
<el-button type="primary" icon="el-icon-search" @click="searchChange">搜 索</el-button>
<el-button icon="el-icon-delete" @click="searchReset()">清 空</el-button>
</el-form-item>
</el-form>
</div>
<el-row>
<div class="avue-crud__header">
<!-- 头部左侧按钮模块 -->
<div class="avue-crud__left">
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新 增</el-button>
<el-button type="danger" icon="el-icon-delete" @click="handleDelete" plain
>删 除</el-button
>
</div>
<!-- 头部右侧按钮模块 -->
<div class="avue-crud__right">
<el-button icon="el-icon-refresh" @click="searchChange" circle></el-button>
<el-button icon="Operation" @click="showdrawer(true)" circle></el-button>
<el-button icon="el-icon-search" @click="searchHide" circle></el-button>
</div>
</div>
</el-row>
<el-row>
<!-- 列表模块 -->
<tablecmt
class="tableNode"
:columnList="columnList"
:tableData="data"
:loading="loading"
@inputTxt="inputsc"
@timeCheck="timesc"
@btnCheck="btnsc"
@selectCheck="selectsc"
@selection="selectionChange"
>
<template #default="slotProps">
<el-text
type="primary"
text
icon="el-icon-view"
@click="handleView(slotProps.scope.row)"
>查看</el-text
>
<el-text
type="primary"
text
icon="el-icon-edit"
@click="handleEdit(slotProps.scope.row)"
>编辑</el-text
>
<el-text type="primary" text icon="el-icon-delete" @click="rowDel(slotProps.scope.row)"
>删除</el-text
>
</template>
</tablecmt>
</el-row>
<el-row>
<div class="avue-crud__pagination flex-c-sb" style="width: 100%">
<div style="font-size: 14px">勾选数量: {{ selectionList.length }}</div>
<!-- 分页模块 -->
<el-pagination
align="right"
background
@size-change="sizeChange"
@current-change="currentChange"
:current-page="page.currentPage"
:page-sizes="[30, 50, 80, 120]"
:page-size="page.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="page.total"
>
</el-pagination>
</div>
</el-row>
<!-- 表单模块 -->
<el-dialog
:title="title"
v-model="box"
width="50%"
:before-close="beforeClose"
append-to-body
>
<el-form
v-loading="loadingObj.detailLoading"
:disabled="view"
ref="form"
:model="form"
label-width="80px"
:rules="rules"
>
<!-- 表单字段 -->
<el-form-item label="品牌名称" prop="brandName">
<el-input v-model="form.brandName" placeholder="请输入品牌名称" />
</el-form-item>
<el-form-item label="品牌编号" prop="brandCode">
<el-input v-model="form.brandCode" placeholder="请输入品牌编号" />
</el-form-item>
<el-form-item label="品牌图标" prop="brandIcon">
<!-- <el-input v-model="form.brandIcon" placeholder="请输入品牌图标"/>-->
<el-upload
class="avatar-uploader"
:action="action"
:headers="headers"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload"
>
<img v-if="imageUrl" :src="imageUrl" class="avatar" />
<el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload>
</el-form-item>
<el-form-item label="承接时间" prop="acceptanceTime">
<!-- <el-input v-model="form.acceptanceTime" placeholder="请输入承接时间"/>-->
<el-date-picker
v-model="form.acceptanceTime"
type="date"
placeholder="选择时间"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD HH:mm:ss"
/>
</el-form-item>
<!-- 表单按钮 -->
<el-form-item v-if="!view">
<div class="flex-c-c w100">
<el-button type="primary" icon="el-icon-circle-check" @click="handleSubmit('form')">
提 交
</el-button>
<el-button icon="el-icon-circle-close" @click="box = false">取 消</el-button>
</div>
</el-form-item>
</el-form>
</el-dialog>
<el-drawer
title="子表操作"
append-to-body
size="60%"
v-model="drawer"
:direction="direction"
:before-close="handleDrawerClose"
>
<BasicStoreBrandSub :mainId="basicBrandId"></BasicStoreBrandSub>
</el-drawer>
</div>
</basic-container>
<edittablehead
@setcolum="setnewcolum"
@closce="showdrawer"
:drawerShow="drawerShow"
:columnList="columnList"
></edittablehead>
</template>
<script>
import { getList, getDetail, add, update, remove, getFile } from '@/api/basicdata/basicBrand';
import option from '@/option/basicdata/basicBrand';
import { mapGetters } from 'vuex';
import BasicStoreBrandSub from '@/views/basicdata/brand/basicStoreBrandSub.vue';
import { getToken } from '@/utils/auth';
import { setNodeHeight } from '@/utils/util';
export default {
components: {
BasicStoreBrandSub,
},
data() {
return {
columnList: [
{
prop: '',
label: '序号',
type: 0,
values: '',
width: 55,
checkarr: [],
fixed: true,
},
{
prop: 'brandName',
label: '品牌名称',
type: 2,
values: '',
width: '200',
checkarr: [],
fixed: false,
sortable: true,
head: false,
},
{
prop: 'brandCode',
label: '品牌编号',
type: 2,
values: '',
width: '200',
checkarr: [],
fixed: false,
sortable: true,
head: false,
},
{
prop: 'brandIcon',
label: '品牌图标',
type: 7,
values: '',
width: '200',
checkarr: [],
fixed: false,
sortable: true,
head: false,
},
{
prop: 'acceptanceTime',
label: '承接时间',
type: 2,
values: '',
width: '150',
checkarr: [],
fixed: false,
sortable: true,
},
{
prop: '',
label: '操作',
type: 6,
values: '',
width: '150',
checkarr: [],
fixed: 'right',
hide: true,
},
],
drawerShow: false,
height: 0,
srcList: [],
dataShi: '', //时间
// 主键
basicBrandId: '',
// 弹框标题
title: '',
// 是否展示弹框
box: false,
// 是否展示抽屉
drawer: false,
// 抽屉方向
direction: 'rtl',
// 是否显示查询
search: true,
// 加载中
loading: true,
// 是否为查看模式
view: false,
// 查询信息
query: {},
// 分页信息
page: {
currentPage: 1,
pageSize: 30,
total: 40,
},
// 表单数据
form: {},
imageUrl: '',
// 选择行
selectionList: [],
// 表单配置
option: option,
// 表单列表
data: [],
shortcuts: [
{
text: '上周',
value: () => {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
return [start, end];
},
},
{
text: '上个月',
value: () => {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
return [start, end];
},
},
{
text: '最近3个月',
value: () => {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
return [start, end];
},
},
],
dialogImageUrl: '',
dialogVisible: false,
disabled: false,
rules: {
brandName: [
{ required: true, message: '请输入品牌名称', trigger: 'blur' },
// { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
],
brandCode: [{ required: true, message: '请输入品牌编号', trigger: 'change' }],
brandIcon: [{ required: true, message: '请上传图标', trigger: 'blur' }],
acceptanceTime: [{ required: true, message: '请选择承接时间', trigger: 'blur' }],
},
loadingObj: {
/** 查看loading */
detailLoading: false,
},
};
},
mounted() {
this.init();
this.onLoad(this.page);
/**
* 初始化获取本地缓存的编辑隐藏的列表
* 固定搭配,不能更改
*/
let checkListnewarr = this.$functions.getStorage(window.location.pathname + 'checkList');
let flexListnewarr = this.$functions.getStorage(window.location.pathname + 'flexList');
let sortlistnewarr = this.$functions.getStorage(window.location.pathname + 'sortlist');
if (checkListnewarr) {
this.columnList.map(item => {
item.head = false;
});
checkListnewarr.map(ite => {
this.columnList.map(item => {
if (ite == item.label) {
item.head = true;
}
});
});
} else {
let arr = [];
this.columnList.map(item => {
if (item.head) {
arr.push(item.label);
}
});
this.$functions.setStorage(window.location.pathname + 'checkList', arr);
}
if (flexListnewarr) {
this.columnList.map(item => {
item.fixed = false;
});
flexListnewarr.map(ite => {
this.columnList.map(item => {
if (ite == item.label) {
if (item.type == 6) {
item.fixed = 'right';
} else {
item.fixed = true;
}
}
});
});
} else {
let arr = [];
this.columnList.map(item => {
if (item.fixed) {
arr.push(item.label);
}
});
this.$functions.setStorage(window.location.pathname + 'flexList', arr);
}
if (sortlistnewarr) {
this.columnList.map(item => {
item.sortable = false;
});
sortlistnewarr.map(ite => {
this.columnList.map(item => {
if (ite == item.label) {
item.sortable = true;
}
});
});
} else {
let arr = [];
this.columnList.map(item => {
if (item.sortable) {
arr.push(item.label);
}
});
this.$functions.setStorage(window.location.pathname + 'sortlist', arr);
}
},
computed: {
...mapGetters(['permission']),
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
headers() {
return {
'Blade-Auth': 'Bearer ' + getToken(),
};
},
action() {
// return '/api/logpm-basicdata/common/uploadFile'
return '/api/blade-resource/oss/endpoint/put-file';
},
},
methods: {
showdrawer(value) {
this.drawerShow = value;
},
/**
* 弹窗的勾选回调,用于更改头部数组
* 固定搭配,只需要更换 columnList
*/
setnewcolum(newarr, headarr, type) {
// console.log(newarr,'+++++++++++')
if (type == 1) {
this.columnList = newarr;
this.$functions.setStorage(window.location.pathname + 'checkList', headarr);
} else if (type == 2) {
this.columnList = newarr;
this.$functions.setStorage(window.location.pathname + 'flexList', headarr);
} else if (type == 3) {
this.columnList = newarr;
this.$functions.setStorage(window.location.pathname + 'sortlist', headarr);
}
},
handleAvatarSuccess(res, file) {
console.log('>>>>>>>>', res, file);
this.imageUrl = URL.createObjectURL(file.raw);
this.form.brandIcon = res.data.link;
},
beforeAvatarUpload(file) {
const isJPG = file.type === 'image/jpeg';
const isLt2M = file.size / 1024 / 1024 < 2;
if (!isJPG) {
this.$message.error('上传头像图片只能是 JPG 格式!');
}
if (!isLt2M) {
this.$message.error('上传头像图片大小不能超过 2MB!');
}
return isJPG && isLt2M;
},
uploadSuccess(fileList) {
console.log('123123123', fileList);
// this.$set(row, 'imageCos', fileList);
},
handlePictureCardPreview(file) {
console.log('.....', file);
this.dialogImageUrl = file.url;
this.dialogVisible = true;
},
handleDownload(file) {
console.log(file);
},
handleRemove(file) {
console.log(file);
},
init() {
this.height = this.setPx(document.body.clientHeight - 340);
},
searchHide() {
this.search = !this.search;
const _tableNode = document.querySelector('.tableNode');
setNodeHeight(_tableNode, '', true);
},
searchChange() {
this.onLoad(this.page);
},
searchReset() {
this.query = {};
this.dataShi = '';
this.page.currentPage = 1;
this.onLoad(this.page);
},
handleSubmit(from) {
this.$refs[from].validate(valid => {
if (valid) {
this.loadingObj.detailLoading = true;
if (!this.form.id) {
console.log('提交的数据!!', this.form);
add(this.form).then(() => {
this.box = false;
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
}).finally(() => {
this.loadingObj.detailLoading = false;
});
this.imageUrl = null;
});
} else {
update(this.form)
.then(() => {
this.box = false;
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
})
.finally(() => {
this.loadingObj.detailLoading = false;
});
}
}
});
},
handleAdd() {
this.title = '新增';
this.form = {};
this.form.brandIcon = null;
this.imageUrl = null;
this.box = true;
},
handleEdit(row) {
this.title = '编辑';
this.box = true;
this.loadingObj.detailLoading = true;
getDetail(row.id)
.then(res => {
this.form = res.data.data;
this.imageUrl = res.data.data.brandIcon || '';
})
.finally(() => {
this.loadingObj.detailLoading = false;
});
},
handleView(row) {
this.title = '查看';
this.view = true;
this.box = true;
this.loadingObj.detailLoading = true;
getDetail(row.id)
.then(res => {
this.form = res.data.data;
this.imageUrl = res.data.data.brandIcon || '';
})
.finally(() => {
this.loadingObj.detailLoading = false;
});
},
handleDrawer(row) {
this.basicBrandId = row.id;
this.drawer = true;
},
handleDrawerClose() {
this.basicBrandId = '';
this.drawer = false;
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.selectionClear();
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
beforeClose(done) {
done();
this.form = {};
this.view = false;
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
// this.$refs.table.clearSelection();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
this.onLoad(this.page);
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
this.onLoad(this.page);
},
onLoad(page, params = {}) {
this.loading = true;
if (this.dataShi.length > 0) {
this.query.checkInTime = this.dataShi[0];
this.query.postSetTime = this.dataShi[1];
}
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
// console.log("res.data.data",res.data.data.records);
this.srcList = [];
res.data.data.records.forEach(i => {
this.srcList.push(i.brandIcon);
// let a = getFile(i.brandIcon);
// console.log("QQQQQQQQQQQ",i.brandIcon);
});
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>
<style lang="scss" scoped>
.avatar-uploader .avatar {
width: 178px;
height: 178px;
display: block;
}
:deep(.no-print) {
margin-left: auto;
}
.fr-fm {
width: 100%;
display: flex;
justify-content: space-between;
}
.el-btn {
margin-right: 0;
}
.header_search :deep(.el-range-editor.el-input__wrapper) {
height: 100% !important;
}
</style>
<style>
.avatar-uploader .el-upload {
border: 1px dashed var(--el-border-color);
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
transition: var(--el-transition-duration-fast);
}
.avatar-uploader .el-upload:hover {
border-color: var(--el-color-primary);
}
.el-icon.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 178px;
height: 178px;
text-align: center;
}
</style>