<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
v-show="showSearch"
label-width="68px"
>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['portal:otdhtml:add']"
>新增</el-button
>
</el-col>
</el-row>
<el-table
v-loading="loading"
:data="otdhtmlList"
@selection-change="handleSelectionChange"
>
<el-table-column label="标题" align="center" prop="titlt">
<template slot-scope="scope">
{{ scope.row.title }}
</template>
</el-table-column>
<el-table-column label="期号" align="center" prop="expressNo">
<template slot-scope="scope">
{{ scope.row.expressNo }}
</template>
</el-table-column>
<el-table-column label="上线状态" align="center" prop="flag">
<template slot-scope="scope">
<el-switch
v-hasPermi="['portal:banner:edit']"
v-model="scope.row.flag"
active-value="1"
inactive-value="0"
@change="handleFlagChange(scope.row)"
></el-switch>
</template>
</el-table-column>
<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-view"
@click="handlePreview(scope.row)"
v-hasPermi="['portal:otdhtml:edit']"
>预览</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['portal:otdhtml:edit']"
>修改</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['portal:otdhtml:remove']"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</template>
<script>
import {
listOtdhtml,
getOtdhtml,
delOtdhtml,
addOtdhtml,
updateOtdhtml,
exportOtdhtml,
} from "@/api/portal/otdhtml";
import Editor from "@/components/Editor";
export default {
name: "Otdhtml",
components: { Editor },
data() {
return {
title: "",
expressNo: "",
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// OTDhtml表格数据
otdhtmlList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
content: null,
templateJson: null,
flag: null,
title: null,
expressNo: null,
},
//状态选择
// flagOptions: [
// { value: "0", label: "未发布" },
// { value: "1", label: "已上线" },
// { value: "2", label: "以往发布" },
// { value: "3", label: "审核未通过" },
// ],
// 表单参数
form: {},
// 表单校验
rules: {},
};
},
created() {
this.getList();
},
methods: {
/** 查询OTDhtml列表 */
getList() {
this.loading = true;
listOtdhtml(this.queryParams).then((response) => {
console.log("response.rows", response.rows);
this.otdhtmlList = response.rows;
for (let i = 0; i < this.otdhtmlList.length; i++) {
var rowData = response.rows[i];
this.templateJson = JSON.parse(rowData.templateJson);
rowData.title = this.templateJson.formData.title;
rowData.expressNo = this.templateJson.formData.expressNo;
}
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
//预览跳转
handlePreview(row) {
const id = row.id;
let host = window.location.host;
if (host == "10.58.136.26") {
//uat跳转地址
window.open("http://10.58.136.26/otd/express?id=" + id);
} else {
//生产跳转地址
window.open("https://55555.bba/otd/express?id=" + id);
}
},
// 表单重置
reset() {
this.form = {
id: null,
content: null,
templateJson: null,
createTime: null,
flag: null,
remark: null,
createBy: null,
updateBy: null,
};
this.resetForm("form");
},
//、
handleFlagChange(row) {
let text = row.flag === "1" ? "启用" : "停用";
this.$confirm("确认要" + text + "吗?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(function () {
return updateOtdhtml(row);
})
.then(() => {
this.msgSuccess(text + "成功");
console.log("row", row);
this.getList();
})
.catch(function () {
row.flag = row.flag === "0" ? "1" : "0";
});
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.queryParams.flag = "";
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.id);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
this.$router.push({
path: "/otdPreview/saveEmail",
});
},
/** 修改按钮操作 */
handleUpdate(row) {
if (row.flag == 1) {
this.msgError("不可修改已上线的资讯");
return;
}
const id = row.id;
this.$router.push({
name: "editEmail",
params: { id: row.id },
});
// this.reset();
// const id = row.id || this.ids;
// getOtdhtml(id).then((response) => {
// this.form = response.data;
// this.open = true;
// this.title = "修改OTDhtml";
// });
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.id != null) {
updateOtdhtml(this.form).then((response) => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addOtdhtml(this.form).then((response) => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
if (row.flag == 1) {
this.msgError("不可删除已上线的资讯");
return;
}
const ids = row.id || this.ids;
this.$confirm("是否确认删除?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(function () {
return delOtdhtml(ids);
})
.then(() => {
this.getList();
this.msgSuccess("删除成功");
});
},
formmat(flag) {
if (flag == 0) {
return "未发布";
} else if (flag == 1) {
return "已上线";
} else if (flag == 2) {
return "以往发布";
} else {
return "审核未通过";
}
},
// /** 导出按钮操作 */
// handleExport() {
// const queryParams = this.queryParams;
// this.$confirm("是否确认导出所有OTDhtml数据项?", "警告", {
// confirmButtonText: "确定",
// cancelButtonText: "取消",
// type: "warning",
// })
// .then(function () {
// return exportOtdhtml(queryParams);
// })
// .then((response) => {
// this.download(response.msg);
// });
// },
},
};
</script>
<style lang="scss" scope>
.content2 {
// 3行文本超长换行
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
line-clamp: 1;
box-orient: vertical;
cursor: pointer;
}
</style>
换成vue3