web-zk-admin/src/views/equipmentManage/equipmentBanner/index.vue

320 lines
7.7 KiB
Vue

<template>
<div class="page">
<topBar
v-if="topList.length > 0"
:topList="topList"
:moren="moren"
></topBar>
<div class="thetopbox">
<el-form label-width="100px">
<el-row>
<el-col :span="8">
<el-form-item :label="'创建日期'">
<el-date-picker
@change="checkTime1"
v-model="queryParams.times1"
type="daterange"
range-separator="——"
:start-placeholder="'开始日期'"
:end-placeholder="'结束日期'"
value-format="yyyy-MM-dd"
>
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="4">
<div class="searchbox">
<el-button class="my_search" @click="getSearch">
{{ '搜索' }}</el-button
>
<el-button class="my_reset" @click="reChongzhi">
{{ '重置' }}</el-button
>
</div>
</el-col>
</el-row>
</el-form>
</div>
<div class="main">
<div class="maintop">
<div class="mainbtn">
<el-button
size="mini"
@click="addBanner"
style="background: #48b2fd"
class="addBtn"
> {{'添加'}}</el-button
>
<!-- <el-button
size="mini"
style="background: #ffad41; color: #fff; border: none"
class="addBtn"
>{{'导出'}}</el-button
> -->
</div>
</div>
<div class="maintable">
<el-table
ref="multipleTable"
:data="tableData"
v-loading="loading"
height="720px"
style="width: 100%"
:header-cell-style="{ background: '#EEEEEE' }"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55"> </el-table-column>
<el-table-column align="center" prop="cover" label="图片">
<template slot-scope="scope">
<img
style="width: 44px; height: 44px; border-radius: 8px"
:src="scope.row.cover"
alt=""
/>
</template>
</el-table-column>
<el-table-column align="center" prop="creationTime" :label="'创建日期'">
</el-table-column>
<el-table-column
align="center"
prop="time"
:label="'操作'"
fixed="right"
>
<template slot-scope="scope">
<el-button
class="button-s"
type="text"
style="color: #48b2fd"
size="small"
@click="updateBanner(scope.row)"
>
{{'修改'}}
</el-button>
<el-button
class="button-s"
type="text"
style="color: #c73030"
size="small"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
</div>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getSearch"
/>
<el-dialog
:title="dialogTitle"
:visible.sync="visibleShow"
:close-on-click-modal="false"
width="40%"
center
:before-close="handleClose"
>
<el-form :model="form" ref="form" :rules="rules" label-width="100px">
<el-row>
<el-col :span="12">
<el-form-item prop="cover" label="上传banner">
<imageUpload v-model="form.cover" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="handleClose">{{ '取消' }}</el-button>
<el-button type="primary" @click="onSubmit('form')">{{
'确认'
}}</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import topBar from "@/components/topBar";
import * as equ from "@/api/equipment.js";
import ImageUpload from "@/components/ImageUpload";
export default {
name: "EquipmentBanner",
components: {
topBar,
ImageUpload,
},
data() {
return {
moren: "equipmentBanner",
topList: [
{
name: "Banner",
path: "equipmentBanner",
},
],
tableData: [],
loading:false,
queryParams: {
pageNum: 1,
pageSize: 50,
type:1,
},
total: 0,
multipleSelection: [],
form: {
cover: "",
type:1
},
dialogTitle: "",
visibleShow: false,
rules: {
cover: [
{ required: true, message: '请输入规格类型', trigger: "blur" },
],
},
addEdit: "",
};
},
created() {
this.getSearch();
},
methods: {
onSubmit(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
let url = "";
if (this.addEdit == 1) {
url = equ.saveBanner;
} else if (this.addEdit == 2) {
url = equ.updateBanner;
}
url(this.form).then((res) => {
if (res.code == 200) {
this.$message({
message: res.msg,
type: "success",
});
this.visibleShow = false;
this.$refs[formName].resetFields();
this.getSearch();
}
});
}else{
}
});
},
addBanner() {
this.addEdit = 1;
this.dialogTitle = '添加';
this.visibleShow = true;
},
updateBanner(row) {
this.addEdit = 2;
this.dialogTitle = '修改';
this.visibleShow = true;
equ.getBannerRowDetail({ pkId: row.pkId }).then((res) => {
this.form = res.data;
});
},
handleClose() {
this.visibleShow = false;
this.$refs["form"].clearValidate();
this.$refs["form"].resetFields();
},
checkTime1(val) {
this.queryParams.startCreateTime = val[0]
this.queryParams.endCreateTime = val[1]
},
handleSelectionChange(val) {
this.multipleSelection = val;
},
reChongzhi() {
this.queryParams = {
pageNum: 1,
pageSize: 50,
type:1
};
this.getSearch();
},
getSearch() {
this.loading = true
equ.getAppletConfigList(this.queryParams).then((res) => {
this.tableData = res.rows;
this.total = res.total;
this.loading = false
});
},
},
};
</script>
<style lang="scss" scoped>
::v-deep .el-range-editor.el-input__inner {
width: 100%;
}
::v-deep .el-table thead {
color: #000000;
}
::v-deep .el-table .warning-row {
background: #f9f9f9;
}
.page {
padding: 10px 20px;
background: #f9f9f9;
font-size: 14px;
.thetopbox {
padding: 15px 20px 15px 0;
background: #ffffff;
border-radius: 8px;
.searchbox {
display: flex;
align-items: center;
margin-left: 40px;
}
.searchtitle {
margin-right: 10px;
}
.searchbtn {
background: #08143f;
color: #ffffff;
}
}
.main {
//margin-top: 20px;
background: #f9f9f9;
//border-radius: 8px;
//box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);
.maintop {
display: flex;
// padding: 10px 0;
justify-content: space-between;
align-items: center;
.mainbtn {
.thebtn1 {
color: #ffffff;
background: #48b2fd;
}
.thebtn2 {
color: #ffffff;
background: #ffad41;
}
}
}
}
}
</style>