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

558 lines
18 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">
2024-05-11 11:44:01 +00:00
<el-form-item label="品牌名称" prop="name">
2023-12-14 13:11:58 +00:00
<el-input
v-model="queryParams.name"
2024-04-22 05:33:25 +00:00
placeholder="品牌名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
2024-05-11 11:44:01 +00:00
<!-- <el-form-item label="" prop="code">
2024-04-22 05:33:25 +00:00
<el-input
v-model="queryParams.name"
placeholder="品牌编码"
2023-12-14 13:11:58 +00:00
clearable
@keyup.enter.native="handleQuery"
/>
2024-05-11 11:44:01 +00:00
</el-form-item> -->
2023-12-14 13:11:58 +00:00
<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>
2024-04-22 05:33:25 +00:00
<xd-table
size="mini"
v-loading="loading" border stripe
:data="emisBrandList"
:showSearch.sync="showSearch"
:total="total"
@queryTable="getList"
:queryParams="queryParams"
@selection-change="handleSelectionChange"
@sort-change="handleSortChange"
>
<div slot="toolbar">
<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> -->
</el-row>
2023-12-14 13:11:58 +00:00
2024-04-22 05:33:25 +00:00
</div>
<!-- <el-table v-loading="loading" :data="emisBrandList" border @selection-change="handleSelectionChange"> -->
2023-12-14 13:11:58 +00:00
<el-table-column type="selection" width="55" align="center" />
2024-01-10 05:58:24 +00:00
<!-- <el-table-column label="序号" align="center" min-width="60">
2023-12-14 13:11:58 +00:00
<template slot-scope="scope">
<span v-text="getIndex(scope.$index)"> </span>
</template>
</el-table-column>
2024-01-10 05:58:24 +00:00
-->
2024-05-11 11:44:01 +00:00
<!-- <el-table-column label="品牌编码" align="left" prop="code" min-width="100">
2024-04-22 05:33:25 +00:00
<template slot-scope="scope">
<div class="link-type" @click="handleUpdate(scope.row)">{{scope.row.code}}</div>
</template>
2024-05-11 11:44:01 +00:00
</el-table-column> -->
2024-01-10 05:58:24 +00:00
<el-table-column label="品牌名称" align="left" prop="name" min-width="100">
2023-12-14 13:11:58 +00:00
<template slot-scope="scope">
2024-01-11 08:30:56 +00:00
<div class="link-type" @click="handleUpdate(scope.row)">{{scope.row.name}}</div>
2023-12-14 13:11:58 +00:00
</template>
</el-table-column>
<el-table-column label="英文名称" align="center" prop="nameEn" min-width="100" />
2024-01-10 05:58:24 +00:00
<el-table-column label="logo" align="left" prop="logo" min-width="130" >
<template slot-scope="scope">
<div style="height:30px">
2024-05-13 04:51:49 +00:00
<img style="height: 100%;max-width:100%;cursor: pointer;" :src="scope.row.logo" onerror="onerror=null;src='@../../../assets/images/plus.jpg'">
2024-01-10 05:58:24 +00:00
</div>
</template>
</el-table-column>
<el-table-column label="url" align="center" prop="url" min-width="100" />
2023-12-14 13:11:58 +00:00
<el-table-column label="备注" align="center" prop="remark" min-width="100" />
2024-05-11 11:44:01 +00:00
<!-- <el-table-column label="启用" align="center" prop="status" min-width="100" >
2023-12-19 05:49:05 +00:00
<template slot-scope="scope">
<el-switch
v-model="scope.row.status"
2024-04-22 05:33:25 +00:00
:active-value="1"
:inactive-value="0"
2023-12-19 05:49:05 +00:00
@change="handleStatusChange(scope.row)"
></el-switch>
</template>
2024-05-11 11:44:01 +00:00
</el-table-column> -->
<el-table-column label="启用状态" align="center" prop="status" min-width="100" >
<template slot-scope="scope">
<el-tag v-if="scope.row.status==1" type="success">启用</el-tag>
<el-tag v-if="scope.row.status==0" type="danger">停用</el-tag>
<!-- <dict-tag :options="dict.type.sys_biz_enable_status" :value="scope.row.status"/> -->
</template>
</el-table-column>
2024-05-22 23:35:24 +00:00
<el-table-column label="创建人" align="center" prop="createBy" width="80" :show-overflow-tooltip="true"/>
<el-table-column label="创建网点" align="center" prop="createSite" width="80" :show-overflow-tooltip="true"/>
<el-table-column label="创建时间" align="center" prop="createTime" width="170"/>
<el-table-column label="修改人" align="center" prop="updateBy" width="80" :show-overflow-tooltip="true"/>
<el-table-column label="修改网点" align="center" prop="updateSite" width="80" :show-overflow-tooltip="true"/>
<el-table-column label="修改时间" align="center" prop="updateTime" width="170"/>
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>
</template>
</el-table-column>
2024-04-22 05:33:25 +00:00
</xd-table>
2023-12-14 13:11:58 +00:00
<!-- 添加或修改品牌对话框 -->
2024-05-22 17:06:32 +00:00
<el-dialog :title="title" :visible.sync="open" width="500px" :close-on-click-modal="false" v-dialogDrag append-to-body>
2023-12-14 13:11:58 +00:00
<el-row :gutter="0">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
2024-04-22 05:33:25 +00:00
<el-col :span="12">
<el-form-item label="品牌名称" prop="name">
2023-12-14 13:11:58 +00:00
<el-input v-model="form.name" placeholder="请输入名称" />
</el-form-item>
</el-col>
2024-04-22 05:33:25 +00:00
<el-col :span="12">
2023-12-14 13:11:58 +00:00
<el-form-item label="英文名称" prop="nameEn">
<el-input v-model="form.nameEn" placeholder="请输入英文名称" />
</el-form-item>
</el-col>
2024-05-11 11:44:01 +00:00
<!-- <el-col :span="12">
2024-04-22 05:33:25 +00:00
<el-form-item label="品牌编码" prop="code">
<el-input v-model="form.code" placeholder="品牌编码" />
</el-form-item>
2024-05-11 11:44:01 +00:00
</el-col> -->
2023-12-14 13:11:58 +00:00
<el-col :span="24">
2024-01-10 05:58:24 +00:00
<el-form-item label="官方网址" prop="url">
<el-input v-model="form.url" placeholder="url" />
2023-12-14 13:11:58 +00:00
</el-form-item>
</el-col>
<el-col :span="24">
2024-01-10 05:58:24 +00:00
<el-form-item label="logo" prop="logo">
<ImageOneUpload v-model="form.logo" ></ImageOneUpload>
2023-12-18 12:23:01 +00:00
</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">
2023-12-19 05:49:05 +00:00
<el-radio-group v-model="form.status">
2024-04-22 05:33:25 +00:00
<el-radio label="1">是</el-radio>
<el-radio label="0">否</el-radio>
2023-12-19 05:49:05 +00:00
</el-radio-group>
2023-12-14 13:11:58 +00:00
</el-form-item>
</el-col>
<el-col :span="24">
2024-01-10 05:58:24 +00:00
<el-form-item label="备注" prop="note">
<el-input v-model="form.note" type="textarea" 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>
2024-05-22 17:06:32 +00:00
<el-dialog :title="titleForm" :visible.sync="openForm" width="500px" v-dialogDrag append-to-body>
2023-12-14 13:11:58 +00:00
<emisBrandForm :id="currentId" @on-changed="handleFormChanged" @on-cancel="cancelForm"></EmisBrandForm>
</el-dialog>
</div>
</template>
<script>
2023-12-19 05:49:05 +00:00
import { listEmisBrand, getEmisBrand, delEmisBrand, addEmisBrand, updateEmisBrand,changeBrandStatus } from "@/api/emis/emisBrand";
2023-12-14 13:11:58 +00:00
export default {
name: "emisBrand",
2024-05-13 04:51:49 +00:00
components: { },
2023-12-19 05:49:05 +00:00
dicts: ['sys_normal_disable'],
2023-12-14 13:11:58 +00:00
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:{
2024-01-10 05:58:24 +00:00
package_id:'',
2023-12-18 12:23:01 +00:00
detail:'',
2024-01-10 05:58:24 +00:00
mobile:'',
2023-12-18 12:23:01 +00:00
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: {
2024-04-22 05:33:25 +00:00
code: [
{ required: true, message: "编码不能为空", trigger: "blur" }
2023-12-14 13:11:58 +00:00
],
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" }
],
}
};
},
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-19 05:49:05 +00:00
// 角色状态修改
handleStatusChange(row) {
2024-01-10 05:58:24 +00:00
2024-04-22 05:33:25 +00:00
let text = row.status == "1" ? "启用" : "停用";
this.$modal.confirm('确认要"' + text + '"' + row.name + '品牌吗?').then(function() {
2023-12-19 05:49:05 +00:00
return changeBrandStatus(row.id, row.status);
}).then(() => {
this.$modal.msgSuccess(text + "成功");
}).catch(function() {
2024-04-22 05:33:25 +00:00
// row.status = row.status === "0" ? "1" : "0";
2023-12-19 05:49:05 +00:00
});
2024-01-10 05:58:24 +00:00
2024-05-11 11:44:01 +00:00
},
// 排序 查询字段是表格中字段名字 动态取值排序顺序
handleSortChange(column) {
this.queryParams.orderByColumn = column.prop;
this.queryParams.isAsc = column.order;
this.getList();
2023-12-18 12:23:01 +00:00
},
2024-01-10 05:58:24 +00:00
2023-12-14 13:11:58 +00:00
/** 查询品牌列表 */
getList() {
this.loading = true;
this.queryParams.params = {};
listEmisBrand(this.addDateRange(this.queryParams, this.dateTimeRange)).then(response => {
2023-12-19 05:49:05 +00:00
response.rows.forEach(item =>{
response.rows.status = item.status+"";
});
2023-12-14 13:11:58 +00:00
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 => {
2023-12-19 05:49:05 +00:00
response.data.status = response.data.status+"";
2023-12-14 13:11:58 +00:00
this.form = response.data;
2023-12-19 05:49:05 +00:00
console.log(this.form);
2023-12-14 13:11:58 +00:00
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>