<template>
|
<div class="image_data_list_main">
|
<SearchCondition
|
:info="info"
|
ref="condRef"
|
:conForm="conForm"
|
:buttonsList="[1, 2, 3]"
|
:isShowDetail="isShowDetail"
|
:screenWidth="screenWidth"
|
@handleOnSeach="handleOnSeach"
|
@handleOnRest="handleOnRest"
|
@handleClick="isShowDetail = !isShowDetail"
|
/>
|
<div />
|
<el-row class="add-button">
|
<el-col :span="24">
|
<el-button
|
type="primary"
|
size="small"
|
icon="el-icon-circle-plus-outline"
|
@click="handleAddPage"
|
class="add-btn"
|
>新增</el-button
|
>
|
</el-col>
|
</el-row>
|
<ProTable
|
:pageInfo="pageInfo"
|
@doAction="doAction"
|
@handleCurrentChange="handleCurrentChange"
|
@handleSizeChange="handleSizeChange"
|
:isAutoIndex="true"
|
:list="records"
|
:header="tableHeader"
|
:loading="loading"
|
/>
|
<el-dialog
|
:title="dialogTitle"
|
:visible.sync="dialogVisible"
|
:close-on-click-modal="false"
|
:close-on-press-escape="false"
|
:destroy-on-close="true"
|
:show-close="false"
|
width="1000"
|
center
|
custom-class="massage_tpl_dialog"
|
>
|
<CreateForms
|
ref="massageForm"
|
v-if="dialogVisible"
|
:isReset="true"
|
:isView="isView"
|
:isShowBorder="isShowBorder"
|
:screenWidth="1000"
|
:formItems="formItems"
|
:defValues="defValues"
|
:formRules="formRules"
|
/>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="handleDialogCancel">{{
|
isView ? "关 闭" : "取 消"
|
}}</el-button>
|
<el-button type="primary" v-if="!isView" @click="submitForm">{{
|
subTitle
|
}}</el-button>
|
</span>
|
</el-dialog>
|
<el-dialog
|
title="删除确认"
|
:visible.sync="delDialogVisible"
|
:close-on-click-modal="false"
|
:close-on-press-escape="false"
|
:destroy-on-close="true"
|
:show-close="false"
|
width="450"
|
center
|
custom-class="massage_tpl_dialog del_dialog"
|
>
|
<div style="text-align: center">
|
请确认是否删除短信编号为:{{ smsNo }}的模板
|
</div>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="delDialogVisible = false">取 消</el-button>
|
<el-button type="primary" @click="deleteSmsTpl">确 定</el-button>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import { mapState, mapGetters, mapActions } from "vuex";
|
import {
|
MASSAGETPLMANAGECOND,
|
MASSAGETPLMANAGEDEF
|
} from "../config/condtion.config";
|
import { MASSAGETPLMANAGECOLUMN } from "../config/column.config";
|
import { MASSAGETPLFORMS } from "../config/formItem.config";
|
import { MASSAGETPLDEFVALUES } from "../config/defValues.config";
|
import { MASSAGETPLRULES } from "../config/rules.config";
|
import ProTable from "../../components/ProTable";
|
import SearchCondition from "../../components/SearchCondition";
|
import CreateForms from "../../components/CreateForms";
|
import {
|
addOrUpdateSmsModelInfo,
|
deleteSmsModel,
|
qrySmsManagerList,
|
qrySmsModelInfo
|
} from "@/http/api";
|
export default {
|
inject: ["reload"],
|
data() {
|
return {
|
info: [...MASSAGETPLMANAGECOND],
|
restFormItems: [...MASSAGETPLMANAGECOND],
|
tableHeader: [...MASSAGETPLMANAGECOLUMN],
|
formItems: [...MASSAGETPLFORMS(false)],
|
defValues: { ...MASSAGETPLDEFVALUES },
|
formRules: { ...MASSAGETPLRULES(true) },
|
conForm: { ...MASSAGETPLMANAGEDEF },
|
pageInfo: {
|
currentPage: 1,
|
pageSize: 10,
|
total: 0
|
},
|
records: [],
|
isReload: true,
|
addorupdate: "ADD", // 新增更新标识,新增时传’ADD’
|
smsNo: "",
|
subTitle: "新增",
|
dialogTitle: "新增短信模板",
|
screenWidth: document.body.offsetWidth,
|
condtionValue: {}, // 表单value集合
|
isShowBorder: false,
|
isShowDetail: false, // 是否显示所有表单项
|
isView: false,
|
loading: false,
|
btnLoading: false,
|
optionsData: {},
|
passValidate: false,
|
delDialogVisible: false,
|
dialogVisible: false
|
};
|
},
|
components: {
|
SearchCondition,
|
ProTable,
|
CreateForms
|
},
|
watch: {
|
optionsMap: {
|
handler(options) {
|
this.optionsData = options;
|
this.getconfigInfo(options);
|
},
|
deep: true
|
}
|
},
|
computed: {
|
// 获取state值
|
...mapState("rlc", {
|
optionsMap: state => state.OPTIONSMAP
|
}),
|
// 通过getters获取值
|
...mapGetters("rlc", ["getOptionsMap"])
|
},
|
async created() {
|
const optionsArr = ["YesNo", "SmsSourceSystem", "SmsSendObject"];
|
this.getOptionsData(optionsArr);
|
this.getUserInfo();
|
},
|
async mounted() {
|
window.addEventListener("resize", this.getScreenWidth);
|
await this.getSmsManagerList();
|
},
|
destroyed() {
|
window.removeEventListener("resize", this.getScreenWidth);
|
},
|
methods: {
|
...mapActions("rlc", [
|
// 将 `this.setOptionsMap()` 映射为 `this.$store.dispatch('setOptionsMap')`
|
"getOptionsData",
|
"getUserInfo"
|
]),
|
getScreenWidth() {
|
this.$set(this, "screenWidth", document.body.offsetWidth);
|
},
|
getconfigInfo(options, type) {
|
const items = {
|
isinuse: "YesNo",
|
source: "SmsSourceSystem",
|
sendobject: "SmsSendObject"
|
};
|
this.info = [...MASSAGETPLMANAGECOND].map(form => {
|
const newForm = { ...form };
|
if (newForm.type === "select") {
|
newForm.options = options[items[newForm.name]];
|
}
|
return newForm;
|
});
|
this.formItems = [...MASSAGETPLFORMS(type === "DETAIL")].map(form => {
|
const newForm = { ...form };
|
if (newForm.type === "select") {
|
newForm.options = options[items[newForm.name]];
|
}
|
return newForm;
|
});
|
},
|
// 获取列表
|
async getSmsManagerList() {
|
const { currentPage, pageSize } = this.pageInfo;
|
const {
|
isinuse,
|
itemattribute,
|
itemdescribe,
|
itemname,
|
itemno,
|
sendobject,
|
source
|
} = this.condtionValue;
|
const loading = this.$loading({
|
lock: true,
|
text: "",
|
background: "hsla(0,0%,100%,.9)"
|
});
|
setTimeout(() => {
|
loading.close();
|
}, 1500);
|
const params = {
|
currentPage,
|
pageSize,
|
isinuse,
|
itemattribute,
|
itemdescribe,
|
itemname,
|
itemno,
|
sendobject,
|
source
|
};
|
const listRes = await qrySmsManagerList(params);
|
loading.close();
|
if (listRes.code && listRes.code === "00") {
|
const newList =
|
listRes.result &&
|
listRes.result.records.map(item => {
|
const newItem = { ...item };
|
newItem.operationOption = [
|
{ label: "修改", type: "EDIT", value: true },
|
{ label: "详情", type: "DETAIL", value: true },
|
{ label: "删除", type: "DELETE", value: true }
|
];
|
return newItem;
|
});
|
this.$set(this, "records", newList);
|
this.$set(
|
this.pageInfo,
|
"total",
|
listRes.result && listRes.result.total
|
);
|
}
|
},
|
// 获取信息
|
async getSmsModelInfo(itemno) {
|
const smsInfoRes = await qrySmsModelInfo({ itemno });
|
if (!smsInfoRes || smsInfoRes.code !== "00") {
|
return false;
|
}
|
return smsInfoRes.result;
|
},
|
// 搜索列表
|
handleOnSeach() {
|
const conRef = this.$refs.condRef;
|
this.$set(this, "condtionValue", conRef.$refs["conform"].model);
|
this.$set(this, "pageInfo", { currentPage: 1, pageSize: 10, total: 0 });
|
this.getSmsManagerList();
|
},
|
// 删除模板
|
async deleteSmsTpl() {
|
const selRes = await deleteSmsModel({ itemno: this.smsNo });
|
if (!selRes || selRes.code !== "00") {
|
return false;
|
}
|
this.delDialogVisible = false;
|
this.getSmsManagerList();
|
this.$message.success("删除成功");
|
},
|
// 获取筛选条件value
|
setValueInfo(condtions) {
|
this.$set(this, "condtionValue", condtions);
|
},
|
|
// 重置
|
handleOnRest() {
|
this.$set(this, "condtionValue", {});
|
// this.$set(this, 'pageInfo', { currentPage: 1, pageSize: 10, total: 0 })
|
},
|
// 表单事件回调
|
async doAction(name, item, { type }) {
|
if (type === "EDIT") {
|
this.isView = false;
|
this.subTitle = "确定";
|
this.dialogTitle = "短信模板修改";
|
this.addorupdate = "UPDATE";
|
const smsInfo = await this.getSmsModelInfo(item.itemno);
|
this.defValues = { ...this.defValues, ...smsInfo };
|
this.dialogVisible = true;
|
}
|
if (type === "DELETE") {
|
this.smsNo = item.itemno;
|
this.delDialogVisible = true;
|
}
|
if (type === "DETAIL") {
|
this.isView = true;
|
this.dialogTitle = "短信模板详情";
|
const smsInfo = await this.getSmsModelInfo(item.itemno);
|
this.getconfigInfo(this.optionsData, "DETAIL");
|
this.formRules = { ...MASSAGETPLRULES(false) };
|
this.defValues = { ...this.defValues, ...smsInfo };
|
this.dialogVisible = true;
|
}
|
},
|
handleDialogCancel() {
|
this.getconfigInfo(this.optionsData, "EDIT");
|
this.defValues = { ...MASSAGETPLDEFVALUES };
|
this.formRules = { ...MASSAGETPLRULES(true) };
|
this.dialogVisible = false;
|
},
|
vailateForm() {
|
const formRef = this.$refs.massageForm;
|
formRef.$refs["createForm"].validate(async valid => {
|
if (valid) {
|
this.passValidate = true;
|
return true;
|
} else {
|
this.passValidate = false;
|
this.$message.error("请完善必填项!");
|
return false;
|
}
|
});
|
},
|
async submitForm() {
|
await this.vailateForm();
|
const { addorupdate, passValidate } = this;
|
if (!passValidate) {
|
return false;
|
}
|
const formRef = this.$refs.massageForm;
|
const {
|
isinuse,
|
itemattribute,
|
itemdescribe,
|
itemname,
|
itemno,
|
remark,
|
sendobject,
|
source
|
} = formRef.$refs["createForm"].model;
|
const params = {
|
addorupdate,
|
isinuse,
|
itemattribute,
|
itemdescribe,
|
itemname,
|
itemno,
|
remark,
|
sendobject,
|
source
|
};
|
const saveRes = await addOrUpdateSmsModelInfo(params);
|
if (saveRes && saveRes.code === "00") {
|
this.$message.success("保存成功");
|
this.getSmsManagerList();
|
}
|
this.handleDialogCancel();
|
},
|
// 删除文件
|
async handleDelete() {
|
this.fileInfo.images = [];
|
},
|
// 新增
|
handleAddPage() {
|
this.isView = false;
|
this.formRules = { ...MASSAGETPLRULES(true) };
|
this.subTitle = "新增";
|
this.addorupdate = "ADD";
|
this.dialogTitle = "短信模板新增";
|
this.dialogVisible = true;
|
},
|
// 修改翻页条数
|
handleSizeChange(val) {
|
this.pageInfo.pageSize = val;
|
this.getSmsManagerList();
|
},
|
|
// 修改翻页数
|
handleCurrentChange(val) {
|
this.pageInfo.currentPage = val;
|
this.getSmsManagerList();
|
}
|
}
|
};
|
</script>
|
|
<style lang="less">
|
.image_data_list_main {
|
padding: 16px 0px 0 20px;
|
& .massage_tpl_dialog {
|
width: 1000px;
|
& .el-dialog__footer {
|
& .dialog-footer {
|
& .el-button--default {
|
width: 120px;
|
height: 30px;
|
line-height: 7px;
|
border-radius: 4px;
|
border: 1px solid rgba(204, 204, 204, 1);
|
}
|
& .el-button--primary {
|
width: 120px;
|
height: 30px;
|
line-height: 7px;
|
background: #0081f0;
|
border-color: #0081f0;
|
border-radius: 4px;
|
margin-left: 40px;
|
}
|
}
|
}
|
}
|
& .del_dialog {
|
width: 450px;
|
}
|
& .add-button {
|
padding: 2px 0 30px 0;
|
}
|
}
|
</style>
|