emis-frontend/src/views/emis/emisBrand/index.vue

635 lines
21 KiB
Vue
Raw Normal View History

2023-12-14 13:11:58 +00:00
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="" prop="name">
<el-input
v-model="queryParams.name"
placeholder="名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['emis:emisBrand:add']"
>新增</el-button>
</el-col>
<!--
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['emis:emisBrand:edit']"
>修改</el-button>
</el-col> -->
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['emis:emisBrand:remove']"
>删除</el-button>
</el-col>
<!-- <el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['emis:emisBrand:export']"
>导出</el-button>
</el-col> -->
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="emisBrandList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" align="center" min-width="60">
<template slot-scope="scope">
<span v-text="getIndex(scope.$index)"> </span>
</template>
</el-table-column>
<!--
<el-table-column label="xxx" align="left" prop="xxx" min-width="180">
<template slot-scope="scope">
<div class="link-type" @click="handleView(scope.row)">{{scope.row.orderSn}}</div>
</template>
</el-table-column>
<el-table-column label="结算状态" align="center" prop="settleStatus" min-width="80">
<template slot-scope="scope">
<div v-if="scope.row.settleStatus == 0" style="color:red;">
<span class="el-tag el-tag--info">未结算</span>
</div>
<div v-if="scope.row.settleStatus == 10" style="color:red;">
<span class="el-tag">待确认</span>
</div>
<div v-if="scope.row.settleStatus == 11" style="color:green;">
<span class="el-tag el-tag--success el-tag--light">已确认</span>
</div>
<div v-if="scope.row.settleStatus == 20" >
<span class="el-tag el-tag--warning el-tag--light">待打款</span>
</div>
<div v-if="scope.row.settleStatus == 21" style="color:green;">
<span class="el-tag el-tag--success el-tag--light">已打款</span>
</div>
<div v-if="scope.row.settleStatus == 40" style="color:red;">
<span class="el-tag el-tag--danger">已拒绝</span>
</div>
</template>
</el-table-column>
-->
<el-table-column label="名称" align="center" prop="name" min-width="100" />
<el-table-column label="英文名称" align="center" prop="nameEn" min-width="100" />
2023-12-19 02:00:29 +00:00
<el-table-column label="logo1" align="center" prop="brandImg" min-width="100" />
2023-12-14 13:11:58 +00:00
<el-table-column label="logo" align="center" prop="logo" min-width="100" />
<el-table-column label="备注" align="center" prop="remark" min-width="100" />
2023-12-19 02:00:29 +00:00
<el-table-column label="启用" align="center" prop="status" min-width="100" />
2023-12-14 13:11:58 +00:00
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['emis:emisBrand:edit']"
>修改</el-button>
<!--
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['emis:emisBrand:remove']"
>删除</el-button> -->
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page-sizes="[20,50,100,300,500,1000,2000,5000]"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
:page-size="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改品牌对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" :close-on-click-modal="false" append-to-body>
<el-row :gutter="0">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-col :span="24">
<el-form-item label="名称" prop="name">
<el-input v-model="form.name" placeholder="请输入名称" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="英文名称" prop="nameEn">
<el-input v-model="form.nameEn" placeholder="请输入英文名称" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="logo" prop="logo">
<el-input v-model="form.logo" placeholder="请输入logo" />
</el-form-item>
</el-col>
2023-12-19 02:00:29 +00:00
2023-12-14 13:11:58 +00:00
<el-col :span="24">
2023-12-18 12:23:01 +00:00
<!--
2023-12-14 13:11:58 +00:00
<el-form-item label="品牌图片(多图;号隔开)" prop="brandImg">
<el-input v-model="form.brandImg" placeholder="请输入品牌图片(多图;号隔开)" />
</el-form-item>
2023-12-18 12:23:01 +00:00
-->
<!-- 图片 -->
<el-form-item label="品牌图片" prop="brandImg">
<el-upload
:headers="imgUploadHeaders"
action="none"
accept=".jpg,.jpeg,.png,.gif,.pdf"
name="brandImg"
:limit='1'
:file-list="sendbackitem.fileList"
:on-exceed='uploadOverrun'
:on-change="handleChange"
:before-upload="beforeAvatarUpload"
:http-request='submitUpload'
:before-remove="beforeRemoveCerdImg"
list-type="picture-card"
:on-preview="handlePictureCardPreview" >
<i class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
<el-dialog :visible.sync="dialogVisible1" append-to-body>
<img width="100%" fit="contain" :src="dialogImageUrl" alt="" style=" height: 80%;">
</el-dialog>
</el-form-item>
2023-12-14 13:11:58 +00:00
</el-col>
<el-col :span="24">
2023-12-19 02:00:29 +00:00
<el-form-item label="是否启用" prop="status">
<el-input v-model="form.status" placeholder="请输入0-未开放" />
2023-12-14 13:11:58 +00:00
</el-form-item>
</el-col>
<el-col :span="24">
2023-12-19 02:00:29 +00:00
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
2023-12-14 13:11:58 +00:00
</el-form-item>
</el-col>
</el-form>
</el-row>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
<el-dialog :title="titleForm" :visible.sync="openForm" width="500px" append-to-body>
<emisBrandForm :id="currentId" @on-changed="handleFormChanged" @on-cancel="cancelForm"></EmisBrandForm>
</el-dialog>
<el-dialog :title="titleView" :visible.sync="openView" width="60%" :close-on-click-modal="false" append-to-body>
<emisBrandView :id="id" ></EmisBrandView>
</el-dialog>
</div>
</template>
<script>
import { listEmisBrand, getEmisBrand, delEmisBrand, addEmisBrand, updateEmisBrand } from "@/api/emis/emisBrand";
import elDateSimplePicker from '@/components/DatePickerAdv/elDateSimplePicker';
import emisBrandView from '@/views/emis/emisBrand/emisBrandView';
import emisBrandForm from '@/views/emis/emisBrand/emisBrandForm';
export default {
name: "emisBrand",
components: { elDateSimplePicker,emisBrandView,emisBrandForm },
dicts: [
],
data() {
return {
2023-12-18 12:23:01 +00:00
dialogVisible1:false,
dialogVisible2:false,
dialogImageUrl:"",
dialogImageUrls:"",
currentId:null,
2023-12-14 13:11:58 +00:00
// 遮罩层
2023-12-18 12:23:01 +00:00
sendbackitem:{
package_id:'',
detail:'',
mobile:'',
consignee:'',
img:'',
city:'',
district:'',
detail1:'',
zipcode:'',
yd_sn:'',
img1:[],
fileList:[],
},
2023-12-14 13:11:58 +00:00
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 创建时间搜索
dateTimeRange:[],
// 总条数
total: 0,
// 品牌表格数据
emisBrandList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
openForm: false,
titleForm: "",
titleEmisBrand: "",
openEmisBrand: false,
// 显示编辑框更多
moreInputVisible: false,
// 弹出展示层
id:null,
titleView:"",
openView: false,
// 删除标志(0代表存在时间范围
daterangeCreateTime: [],
// 删除标志(0代表存在时间范围
daterangeUpdateTime: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
name: null,
nameEn: null,
logo: null,
url: null,
sortOrder: null,
status: null,
brandImg: null,
remark: null,
delFlag: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
id: [
{ required: true, message: "id不能为空", trigger: "blur" }
],
name: [
{ required: true, message: "名称不能为空", trigger: "blur" }
],
nameEn: [
{ required: true, message: "英文名称不能为空", trigger: "blur" }
],
logo: [
{ required: true, message: "logo不能为空", trigger: "blur" }
],
status: [
{ required: true, message: "0-未开放不能为空", trigger: "blur" }
],
brandImg: [
2023-12-18 12:23:01 +00:00
{ required: true, message: "品牌图片不能为空", trigger: "blur" }
2023-12-14 13:11:58 +00:00
],
}
};
},
created() {
this.getList();
},
2023-12-18 12:23:01 +00:00
computed: {
uploadDisabled:function() {
return this.sendbackitem.fileList.length >0
},
imgUploadHeaders(){return { }},
},
2023-12-14 13:11:58 +00:00
methods: {
2023-12-18 12:23:01 +00:00
handlePictureCardPreview(file){
//console.log(file)
this.dialogImageUrl = file.url;
this.dialogVisible1 = true;
},
beforeAvatarUpload(file) {
const isLt2M = file.size / 1024 / 1024 < 2;
if (!isLt2M) {
this.$message.error("上传图片大小不能超过 2MB!");
return false
}
},
submitUpload: function(content) {//自定义的上传图片的方法
console.log(content);
/*
let that = this;
//1. 创建formData 利用AXIOS传递
console.log(content)
const formData = new FormData();
// 文件名
const filename = `${content.file.type.split("/")[1]}`;
// 需要上传的文件file
formData.append("file", content.file, filename);
formData.append("name", content.file.name);
let config = {
'Content-Type': 'multipart/form-data'
}
axios.post('http://oms.wuqinclub.com/lca/index.php?m=admin&c=batch&a=batch_upload_goods_images_sd', formData, config)
.then(function(res) {
if (!res.data.success) {
that.$message({
message: res.data.message,
type: 'error'
});
that.sendbackitem.fileList = that.sendbackitem.fileList.splice(-1,1);
that.sendbackitem.img = that.sendbackitem.img1[0];
}else{
if(res.data.pic!=''){
that.$set(that.sendbackitem.img1, 0,res.data.pic)
that.sendbackitem.img = res.data.pic
}
}
})
.catch(function(error) {
that.$message.error(error);
})
*/
},
beforeRemoveCerdImg(file,list){
let that = this
let currentProfileIndex = (that.sendbackitem.fileList || []).findIndex((profile) => profile.uid === file.uid)
console.log(currentProfileIndex)
that.sendbackitem.fileList.splice(currentProfileIndex, 1);
that.sendbackitem.img1.splice(currentProfileIndex, 1);
that.sendbackitem.img = that.sendbackitem.img1[0];
},
handleChange(file, fileList) {
console.log(file);
this.form.brandImg = file;
console.log(11);
const isLt2M = file.size / 1024 / 1024 < 2;
console.log(isLt2M)
if (!isLt2M) {
this.$message.error('上传图片大小不能超过 2MB!');
this.sendbackitem.fileList = this.sendbackitem.fileList.splice(-1,1);
}else{
this.sendbackitem.fileList = fileList;
}
},
uploadOverrun: function() {
this.$message({
type: 'error',
message: '上传文件个数超出限制!最多上传1张图片!'
});
},
2023-12-14 13:11:58 +00:00
/** 查询品牌列表 */
getList() {
this.loading = true;
this.queryParams.params = {};
if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
this.queryParams.params["beginCreateTime"] = this.daterangeCreateTime[0];
this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1];
}
if (null != this.daterangeUpdateTime && '' != this.daterangeUpdateTime) {
this.queryParams.params["beginUpdateTime"] = this.daterangeUpdateTime[0];
this.queryParams.params["endUpdateTime"] = this.daterangeUpdateTime[1];
}
listEmisBrand(this.addDateRange(this.queryParams, this.dateTimeRange)).then(response => {
this.emisBrandList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
2023-12-18 12:23:01 +00:00
this.dialogVisible1 = false;
2023-12-14 13:11:58 +00:00
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
name: null,
nameEn: null,
logo: null,
url: null,
sortOrder: null,
status: null,
brandImg: null,
remark: null,
tenantId: null,
delFlag: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd(row) {
this.reset();
this.open = true;
this.title = "新增";
// 子组件打开模式
// if(row != undefined){
// this.currentParentId = row.id
// }
// this.openEmisBrand = true;
// this.titleEmisBrand = "新增";
},
handleShowMoreInput(){
this.moreInputVisible = !this.moreInputVisible;
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getEmisBrand(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改";
2023-12-18 12:23:01 +00:00
if(this.form.brandImg != null){
this.dialogVisible1 = true;
this.dialogImageUrl = this.form.brandImg;
}else{
this.dialogVisible1 = false;
this.dialogImageUrl = '';
}
2023-12-14 13:11:58 +00:00
});
// 子组件打开模式
// this.currentId= row.id || this.ids;
// this.openEmisBrand = true;
// this.titleEmisBrand = "修改";
},
handleView(row) {
this.id=row.id;
this.titleView="查看";
this.openView=true;
// this.router.push({ path: '/emis/emisBrand/viewDetail', query: { id: row.id }})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
2023-12-18 12:23:01 +00:00
console.log(this.form);
2023-12-14 13:11:58 +00:00
if (this.form.id != null) {
updateEmisBrand(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
2023-12-18 12:23:01 +00:00
this.dialogVisible1 = false;
2023-12-14 13:11:58 +00:00
this.getList();
});
} else {
addEmisBrand(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
2023-12-18 12:23:01 +00:00
this.dialogVisible1 = false;
2023-12-14 13:11:58 +00:00
this.getList();
});
}
}
});
},
handleFormChanged(){
this.openForm = false;
2023-12-18 12:23:01 +00:00
this.dialogVisible1 = false;
2023-12-14 13:11:58 +00:00
this.getList();
},
cancelForm(){
this.openForm = false;
2023-12-18 12:23:01 +00:00
this.dialogVisible1 = false;
2023-12-14 13:11:58 +00:00
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除').then(function() {
return delEmisBrand(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
// this.download('emis/emisBrand/export', {
// ...this.queryParams
// }, `emisBrand_${new Date().getTime()}.xlsx`)
const loadingInstance = this.$loading({
text: '正在导出...'
})
var qParam = {...this.queryParams};
qParam.pageNum=1;
qParam.pageSize=5000;
listEmisBrand(this.addDateRange(qParam, this.dateTimeRange)).then(response => {
this.downloadLoading = false
if (response.code === 200) {
const curList = response.rows
import('@/vendor/Export2Excel').then(excel => {
const tHeader = ['id','名称','英文名称','logo','url','排序','0-未开放','品牌图片(多图;号隔开)','备注','租户ID','删除标志(0代表存在','创建者','创建时间','更新者','更新时间',];
const filterVal = ['id','name','nameEn','logo','url','sortOrder','status','brandImg','remark','tenantId','delFlag','createBy','createTime','updateBy','updateTime',];
const data = this.formatJson(filterVal, curList, response.rows)
excel.export_json_to_excel({
header: tHeader,
data,
filename: '品牌',
autoWidth: true
})
loadingInstance.close()
})
}
});
},
formatJson(filterVal, jsonData, resData) {
let index = 0
return jsonData.map(v => filterVal.map(j => {
if (j === 'index') {
return ++index
}
if (j === 'status') {
var statusStr='xxx'
if(v[j] == 10){
statusStr='xxx'
}
return statusStr;
}
return v[j]
}))
},
/** 列索引函数 */
getIndex($index) {
return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + $index + 1
},
/** 时间搜索响应函数 */
dateTimeChange(value){
this.dateTimeRange=value;
},
}
};
</script>
<style scoped>
.el-divider{
margin-top: 0px;
background: 0 0;
border-top: 1px solid #E6EBF5;
}
.el-divider__text {
color: #0955ee;
cursor: pointer;
}
</style>