Commit 66ead8b5 authored by rencs's avatar rencs

Merge branch 'dev_ren' into 'dev'

12.25 交易保障

See merge request !14
parents a10f7321 c3f4c8e1
......@@ -71,6 +71,26 @@
</div>
</el-col>
</el-form-item>
<el-form-item label="图片">
<el-upload
class="avatar-uploader"
:action="BASE_API + '/api/universal/file/app/unauth/admin/upload'"
:show-file-list="false"
:on-success="handleIconSuccess"
>
<img
v-if="form.icon"
:src="form.icon"
style="width: 100px; height: 100px"
class="avatar"
/>
<i
v-else
class="el-icon-plus avatar-uploader-icon"
style="width: 100px; height: 100px; line-height: 100px"
></i>
</el-upload>
</el-form-item>
<el-form-item label="内容" prop="content">
<el-col :span="24">
<div
......@@ -126,11 +146,11 @@
align="center"
></el-table-column>
<el-table-column label="保障内容" align="center">
<template slot-scope="scope">
<div v-html="scope.row.content">
{{scope.row.content}}
</div>
</template>
<template slot-scope="scope">
<div v-html="scope.row.content">
{{ scope.row.content }}
</div>
</template>
</el-table-column>
<el-table-column
label="发布时间"
......@@ -151,7 +171,9 @@
<template slot-scope="scope">
<span>
<div class="operators">
<div class="edit" @click.stop="editProtection(scope.row)">编辑</div>
<div class="edit" @click.stop="editProtection(scope.row)">
编辑
</div>
<div
class="offshelf"
v-if="scope.row.status == 1"
......@@ -159,7 +181,13 @@
>
下架
</div>
<div class="upshelf" v-else @click.stop="changeStatus(scope.row)">上架</div>
<div
class="upshelf"
v-else
@click.stop="changeStatus(scope.row)"
>
上架
</div>
<div class="delete" @click.stop="delInfo(scope.row)">删除</div>
</div>
</span>
......@@ -187,12 +215,13 @@ import {
addUpdateProtection,
getListProtections,
} from "api/website/industryApplication/index";
import elementVue from '../../../admin/menu/components/element.vue';
import elementVue from "../../../admin/menu/components/element.vue";
export default {
name: "TransactionProtection",
components: {},
data() {
return {
BASE_API: process.env.BASE_API,
currentTheme: "",
// 功能按钮
operatorControls: [
......@@ -213,6 +242,7 @@ export default {
currentEidtInfo: "",
form: {
rank: "",
icon: undefined,
title: "",
detail: [
{
......@@ -233,104 +263,112 @@ export default {
// },
],
pagination: {
total: 0,
pageSize: 10,
currentPage: 0
total: 0,
pageSize: 10,
currentPage: 0,
},
};
},
watch: {
managerVisible(newVal){
if(!newVal){
this.form.rank = ""
this.form.title = ""
this.form.detail = [{content:""}]
this.form.color = ""
}
},
managerVisible(newVal) {
if (!newVal) {
this.form.rank = "";
this.form.title = "";
this.form.detail = [{ content: "" }];
this.form.color = "";
this.form.icon = undefined;
}
},
},
mounted() {
this.pullListProtections()
this.pullListProtections();
},
methods: {
pullListProtections(){
getListProtections({
page: this.pagination.currentPage,
limit: this.pagination.pageSize
}).then(res => {
if(res.status == 200){
console.log("获取的保障分页数据为=>",res)
this.tableDataCache = []
this.pagination.total = res.data.totalCount
res.data.data.forEach(element => {
this.tableDataCache.push(element)
})
this.screenListProtections()
}
})
handleIconSuccess(res) {
this.form.icon = res.data;
},
screenListProtections(){
this.tableData = []
let index = 0
this.tableDataCache.forEach(element => {
this.tableData.push({
content: this.transDetailToContent(element.detail),
index: ((this.pagination.currentPage-1)*this.pagination.pageSize)+(++index),
id: element.id,
title: element.title,
crtTime: element.crtTime,
updTime: element.updTime,
detail: element.detail,
isDel: element.isDel,
rank: element.rank,
status: element.status,
type: element.type,
color: !!element.color ? element.color : "#000000"
})
})
if(this.currentTheme!=""){
this.tableData = this.tableData.filter(element => {
//正则表达式
let reg = new RegExp(this.currentTheme);
return element.title.match(reg)
})
pullListProtections() {
getListProtections({
page: this.pagination.currentPage,
limit: this.pagination.pageSize,
}).then((res) => {
if (res.status == 200) {
console.log("获取的保障分页数据为=>", res);
this.tableDataCache = [];
this.pagination.total = res.data.totalCount;
res.data.data.forEach((element) => {
this.tableDataCache.push(element);
});
this.screenListProtections();
}
});
},
changeStatus(info){
let message = ""
if(info.status == 1){
info.status = 2
message = "下架成功!!!"
}else{
info.status = 1
message = "上架成功!!!"
}
addUpdateProtection({
type: info.type,
title: info.title,
detail: info.detail,
status: info.status,
isDel: info.isDel,
color: info.color,
rank: info.rank,
id: info.id,
}).then((res) => {
if (res.status == 200) {
this.$message({
message: message,
type: "success",
});
this.pullListProtections()
}else{
this.$message.error('操作失败,请稍后重试!!!');
}
screenListProtections() {
this.tableData = [];
let index = 0;
this.tableDataCache.forEach((element) => {
this.tableData.push({
content: this.transDetailToContent(element.detail),
index:
(this.pagination.currentPage - 1) * this.pagination.pageSize +
++index,
id: element.id,
title: element.title,
crtTime: element.crtTime,
updTime: element.updTime,
detail: element.detail,
isDel: element.isDel,
rank: element.rank,
status: element.status,
type: element.type,
icon: element.icon,
color: !!element.color ? element.color : "#000000",
});
});
if (this.currentTheme != "") {
this.tableData = this.tableData.filter((element) => {
//正则表达式
let reg = new RegExp(this.currentTheme);
return element.title.match(reg);
});
}
},
delInfo(info){
this.$confirm('确定继续执行该操作吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
changeStatus(info) {
let message = "";
if (info.status == 1) {
info.status = 2;
message = "下架成功!!!";
} else {
info.status = 1;
message = "上架成功!!!";
}
addUpdateProtection({
type: info.type,
title: info.title,
detail: info.detail,
status: info.status,
isDel: info.isDel,
color: info.color,
icon: info.icon,
rank: info.rank,
id: info.id,
}).then((res) => {
if (res.status == 200) {
this.$message({
message: message,
type: "success",
});
this.pullListProtections();
} else {
this.$message.error("操作失败,请稍后重试!!!");
}
});
},
delInfo(info) {
this.$confirm("确定继续执行该操作吗?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() => {
addUpdateProtection({
type: info.type,
......@@ -338,6 +376,7 @@ export default {
detail: info.detail,
status: info.status,
isDel: 1,
icon: info.icon,
color: info.color,
rank: info.rank,
id: info.id,
......@@ -347,43 +386,44 @@ export default {
message: "删除成功!!!",
type: "success",
});
this.pullListProtections()
}else{
this.$message.error('操作失败,请稍后重试!!!');
this.pullListProtections();
} else {
this.$message.error("操作失败,请稍后重试!!!");
}
});
})
});
},
changeHandleSize(val) {
// console.log(`每页 ${val} 条`);
this.pagination.pageSize = val
this.pullListApplicationType()
// console.log(`每页 ${val} 条`);
this.pagination.pageSize = val;
this.pullListApplicationType();
},
changeHandleCurrent(val) {
// console.log(`当前页: ${val}`);
this.pagination.currentPage = val
this.pullListProtections()
// console.log(`当前页: ${val}`);
this.pagination.currentPage = val;
this.pullListProtections();
},
clickOperator(index) {
console.log("index=>", index);
if (index == 1) {
this.currentTheme = ""
this.currentTheme = "";
}
this.screenListProtections()
this.screenListProtections();
},
addProtect() {
this.managerTitle = "交易保障"
this.managerTitle = "交易保障";
this.managerVisible = true;
},
editProtection(info){
this.managerTitle = "修改交易保障"
let detail = JSON.parse(info.detail)
editProtection(info) {
this.managerTitle = "修改交易保障";
let detail = JSON.parse(info.detail);
this.managerVisible = true;
this.form.rank = info.rank
this.form.title = info.title
this.form.detail = Array.isArray(detail) ? detail : [{content:""}]
this.form.color = !!info.color ? info.color : ""
this.currentEidtInfo = info
this.form.rank = info.rank;
this.form.icon = info.icon;
this.form.title = info.title;
this.form.detail = Array.isArray(detail) ? detail : [{ content: "" }];
this.form.color = !!info.color ? info.color : "";
this.currentEidtInfo = info;
},
closeManager() {
this.managerVisible = false;
......@@ -396,39 +436,41 @@ export default {
} else if (this.detailHasNull()) {
this.$message.error("保障内容有缺值,请输入!!!");
} else {
let data,message
if(this.managerTitle=="交易保障"){
data = {
rank: this.form.rank,
type: 1, // 类型,1、交易保障,暂时默认值为1
title: this.form.title,
detail: JSON.stringify(this.form.detail),
status: 1, // 默认为启用
color: this.form.color,
}
message = "添加成功!!!"
}else{
data = {
type: this.currentEidtInfo.type,
title: this.form.title,
detail: JSON.stringify(this.form.detail),
status: this.currentEidtInfo.status,
isDel: this.currentEidtInfo.isDel,
color: this.form.color,
rank: this.form.rank,
id: this.currentEidtInfo.id,
}
message = "修改成功!!!"
let data, message;
if (this.managerTitle == "交易保障") {
data = {
rank: this.form.rank,
type: 1, // 类型,1、交易保障,暂时默认值为1
title: this.form.title,
detail: JSON.stringify(this.form.detail),
status: 1, // 默认为启用
color: this.form.color,
icon: this.form.icon,
};
message = "添加成功!!!";
} else {
data = {
type: this.currentEidtInfo.type,
title: this.form.title,
detail: JSON.stringify(this.form.detail),
status: this.currentEidtInfo.status,
isDel: this.currentEidtInfo.isDel,
color: this.form.color,
rank: this.form.rank,
id: this.currentEidtInfo.id,
icon: this.form.icon,
};
message = "修改成功!!!";
}
addUpdateProtection(data).then((res) => {
if (res.status == 200) {
this.$message({
message: message,
type: "success",
});
this.pullListProtections()
this.managerVisible = false;
}
if (res.status == 200) {
this.$message({
message: message,
type: "success",
});
this.pullListProtections();
this.managerVisible = false;
}
});
}
},
......@@ -441,23 +483,23 @@ export default {
});
return bool;
},
transDetailToContent(detail){
let contents = JSON.parse(detail)
let content = ""
if(contents.constructor==Array){
if(contents.length>1){
contents.forEach((element,index) => {
content += (index+1) + "." + element.content + "<br/>"
})
}else{
contents.forEach((element,index) => {
content += element.content
})
}
}else{
content = detail
transDetailToContent(detail) {
let contents = JSON.parse(detail);
let content = "";
if (contents.constructor == Array) {
if (contents.length > 1) {
contents.forEach((element, index) => {
content += index + 1 + "." + element.content + "<br/>";
});
} else {
contents.forEach((element, index) => {
content += element.content;
});
}
return content
} else {
content = detail;
}
return content;
},
handleChangeColor(val) {
console.log("输出颜色值", val); // 颜色 #6c8198
......@@ -651,10 +693,10 @@ export default {
}
}
}
.pagination{
.pagination {
margin: 1% 1% 0 1%;
width: 98%;
height: auto;
}
}
</style>
\ No newline at end of file
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment