<template>
<div>
<el-dialog custom-class="dialog-content" class="print-content" width="700px" :close-on-click-modal="false" append-to-body :show-close="false" top="0" :visible.sync="isVisible">
<div slot="title" class="compontent-header">
<span class="title">{{$t('member.MemberProfile.lang_memberprofile_114')}}</span>
<i class="iconfont dianadanchuangquxiao close" @click="handleClose"></i>
</div>
<div class="logCont">
<el-form label-width="68px">
<el-row>
<el-col :span="8">
<el-form-item :label="$t('member.MemberProfile.lang_memberprofile_195')" prop="noteGroup">
<el-select v-model="noteGroup" clearable placeholder="请选择">
<el-option v-for="(item,index) in getHotelGroupData" :key="index" :label="item.itemValueName" :value="item.itemValueCode">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item :label="$t('member.MemberProfile.lang_memberprofile_116')" prop="noteType">
<el-select v-model="noteType" clearable placeholder="请选择">
<el-option v-for="(item,index) in getHotelData" :key="index" :label="item.itemValueName" :value="item.itemValueCode">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-checkbox v-model="internal" @change="checkInternal()" style="margin-top:10px;margin-left:30px;">{{$t('member.MemberProfile.lang_memberprofile_117')}}</el-checkbox>
</el-row>
</el-form>
</div>
<div class="addressButton">
<el-button size="mini" type="primary" :disabled="showCopy" @click="copyProfile">{{$t('member.MemberProfile.lang_memberprofile_118')}}</el-button>
<el-button size="mini" type="primary" @click="newProfile">{{$t('member.MemberProfile.lang_memberprofile_91')}}</el-button>
<el-button size="mini" type="danger" :disabled="showDelete" @click="deleteProfile">{{$t('member.MemberProfile.lang_memberprofile_92')}}</el-button>
<el-button size="mini" class="searchButton" type="primary" @click="searchProfile">{{$t('member.MemberProfile.lang_memberprofile_104')}}</el-button>
</div>
<div>
<el-table :data="getNotesListData" height="250" ref="selectTable" @row-dblclick="rowDblclick" @selection-change="selectChecked" @change="changeValue" border style="width: 100%">
<el-table-column type="selection" width="55px"></el-table-column>
<el-table-column :label="$t('member.MemberProfile.lang_memberprofile_117')">
<template slot-scope="scope">
<span v-if="scope.row.internal === true">
<i slot="suffix" class="el-input__icon el-icon-check addCheckColor"></i>
</span>
<span v-else></span>
</template>
</el-table-column>
<el-table-column prop="noteGroupName" :label="$t('member.MemberProfile.lang_memberprofile_195')">
</el-table-column>
<el-table-column prop="noteTypeName" :label="$t('member.MemberProfile.lang_memberprofile_116')">
</el-table-column>
<el-table-column prop="noteTitle" :label="$t('member.MemberProfile.lang_memberprofile_119')">
</el-table-column>
</el-table>
</div>
<el-input type="textarea" :rows="8" :placeholder="$t('member.MemberProfile.lang_memberprofile_123')" v-model="getData.note" style="margin-top:10px;">
</el-input>
<div class="twoButton">
<div style="flex:0 150px;">{{$t('member.MemberProfile.lang_memberprofile_120')}}{{getData.createUser}}</div>
<div style="flex:0 200px;">{{$t('member.MemberProfile.lang_memberprofile_121')}}{{getData.createTime}}</div>
<div style="flex:0 150px;">{{$t('member.MemberProfile.lang_memberprofile_122')}}{{getData.modifyUser}}</div>
<div style="flex:0 200px;">{{$t('member.MemberProfile.lang_memberprofile_121')}}{{getData.modifyTime}}</div>
</div>
</el-dialog>
<!-- 新增 -->
<el-dialog width="700px" style="z-index:9999" custom-class="dialog-content" class="print-content" :close-on-click-modal="false" append-to-body :show-close="false" top="40px" v-if="addDialog" :visible.sync="addDialog">
<div slot="title" class="compontent-header">
<span class="title">{{$t('member.MemberProfile.lang_memberprofile_124')}}</span>
<i class="iconfont dianadanchuangquxiao close" @click="handleClose2"></i>
</div>
<div class="logCont">
<el-form label-width="108px" ref="form" :model="form" :rules="rules">
<el-row>
<el-col :span="10">
<el-form-item :label="$t('member.MemberProfile.lang_memberprofile_195')" prop="noteGroup">
<el-select v-model="form.noteGroup">
<el-option v-for="(item,index) in getHotelGroupData" :key="index" :label="item.itemValueName" :value="item.itemValueCode">
</el-option>
</el-select>
</el-form-item>
</el-col>
<!-- 备注类型 -->
<el-col :span="10" style="margin-left:25px;">
<el-form-item :label="$t('member.MemberProfile.lang_memberprofile_116')" prop="noteType">
<el-select v-model="form.noteType" >
<el-option v-for="(item,index) in getHotelData" :key="index" :label="item.itemValueName" :value="item.itemValueCode">
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="10">
<el-form-item :label="$t('member.MemberProfile.lang_memberprofile_127')" prop="createTime">
<el-date-picker v-model="form.createTime" disabled format="yyyy-MM-dd HH:mm" type="date" placeholder="选择日期">
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="10" style="margin-top:8px;margin-left:70px;">
<el-checkbox v-model="checked" disabled>{{$t('member.MemberProfile.lang_memberprofile_117')}}</el-checkbox>
</el-col>
</el-row>
<el-row>
<el-col :span="20" style="margin-left:50px">
<el-radio v-model="radio" label="HOTEL" @change="getRadioValue" style="margin-top:10px;margin-left:30px;">{{$t('member.MemberProfile.lang_memberprofile_135')}}</el-radio>
<el-radio v-model="radio" label="BRAND" @change="getRadioValue" style="margin-top:10px;margin-left:30px;">{{$t('member.MemberProfile.lang_memberprofile_134')}}</el-radio>
<el-radio v-model="radio" label="GROUP" @change="getRadioValue" style="margin-top:10px;margin-left:30px;">{{$t('member.MemberProfile.lang_memberprofile_133')}}</el-radio>
</el-col>
</el-row>
<el-row>
<el-col :span="21">
<el-form-item :label="$t('member.MemberProfile.lang_memberprofile_129')" prop="noteTitle" style="margin-top:10px;">
<el-input v-model="form.noteTitle"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-input type="textarea" :rows="8" class="textareaCopy" :placeholder="$t('member.MemberProfile.lang_memberprofile_130')" v-model="form.note" style="margin-top:10px;">
</el-input>
</el-form>
<div class="twoButton">
<el-button size="mini" type="primary" @click="okDialog">{{$t('member.MemberProfile.lang_memberprofile_83')}}</el-button>
<el-button size="mini" type="danger" @click="handleClose2">{{$t('member.MemberProfile.lang_memberprofile_84')}}</el-button>
</div>
</div>
</el-dialog>
<!-- 编辑 -->
<el-dialog width="700px" style="z-index:9999" custom-class="dialog-content" class="print-content" :close-on-click-modal="false" append-to-body :show-close="false" top="40px" :visible.sync="editDialog">
<div slot="title" class="compontent-header">
<span class="title">{{$t('member.MemberProfile.lang_memberprofile_126')}}</span>
<i class="iconfont dianadanchuangquxiao close" @click="handleClose3"></i>
</div>
<div class="logCont">
<el-form label-width="108px" ref="form" :model="form" :rules="rules">
<el-row>
<el-col :span="10">
<el-form-item :label="$t('member.MemberProfile.lang_memberprofile_195')" prop="noteGroup">
<el-select v-model="form.noteGroup">
<el-option v-for="(item,index) in getHotelGroupData" :key="index" :label="item.itemValueName" :value="item.itemValueCode">
</el-option>
</el-select>
</el-form-item>
</el-col>
<!-- 备注类型 -->
<el-col :span="10" style="margin-left:25px;">
<el-form-item :label="$t('member.MemberProfile.lang_memberprofile_116')" prop="noteType">
<el-select v-model="form.noteType" placeholder="请选择">
<el-option v-for="(item,index) in getHotelData" :key="index" :label="item.itemValueName" :value="item.itemValueCode">
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="10">
<el-form-item :label="$t('member.MemberProfile.lang_memberprofile_127')" prop="modifyTime">
<el-date-picker v-model="form.modifyTime" disabled format="yyyy-MM-dd HH:mm" type="date" placeholder="选择日期">
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="10" style="margin-top:8px;margin-left:70px;">
<el-checkbox v-model="checked" disabled>{{$t('member.MemberProfile.lang_memberprofile_117')}}</el-checkbox>
</el-col>
</el-row>
<el-row>
<el-col :span="20" style="margin-left:50px">
<el-radio v-model="radio" label="HOTEL" @change="getRadioValue" style="margin-top:10px;margin-left:30px;">{{$t('member.MemberProfile.lang_memberprofile_135')}}</el-radio>
<el-radio v-model="radio" label="BRAND" @change="getRadioValue" style="margin-top:10px;margin-left:30px;">{{$t('member.MemberProfile.lang_memberprofile_134')}}</el-radio>
<el-radio v-model="radio" label="GROUP" @change="getRadioValue" style="margin-top:10px;margin-left:30px;">{{$t('member.MemberProfile.lang_memberprofile_133')}}</el-radio>
</el-col>
</el-row>
<el-row>
<el-col :span="21">
<el-form-item :label="$t('member.MemberProfile.lang_memberprofile_129')" prop="noteTitle" style="margin-top:10px;">
<el-input v-model="form.noteTitle"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-input type="textarea" :rows="8" class="textareaCopy" :placeholder="$t('member.MemberProfile.lang_memberprofile_130')" v-model="form.note" style="margin-top:10px;">
</el-input>
</el-form>
<div class="twoButton">
<el-button size="mini" type="primary" @click="saveDialog">{{$t('member.MemberProfile.lang_memberprofile_83')}}</el-button>
<el-button size="mini" type="danger" @click="handleClose3">{{$t('member.MemberProfile.lang_memberprofile_84')}}</el-button>
</div>
</div>
</el-dialog>
<!-- 复制 -->
<el-dialog width="700px" style="z-index:9999" custom-class="dialog-content" class="print-content" :close-on-click-modal="false" append-to-body :show-close="false" top="40px" v-if="copyDialog" :visible.sync="copyDialog">
<div slot="title" class="compontent-header">
<span class="title">{{$t('member.MemberProfile.lang_memberprofile_125')}}</span>
<i class="iconfont dianadanchuangquxiao close" @click="handleClose4"></i>
</div>
<div class="logCont">
<el-form label-width="108px" ref="form" :model="form" :rules="rules">
<el-row>
<el-col :span="10">
<el-form-item :label="$t('member.MemberProfile.lang_memberprofile_127')" prop="createTime">
<el-date-picker v-model="form.createTime" disabled format="yyyy-MM-dd HH:mm" type="date" placeholder="选择日期">
</el-date-picker>
</el-form-item>
</el-col>
<!-- 备注类型 -->
<el-col :span="10" style="margin-left:25px;">
<el-form-item :label="$t('member.MemberProfile.lang_memberprofile_116')" prop="noteType">
<el-select v-model="form.noteType" placeholder="请选择">
<el-option v-for="item in getHotelData" :key="item.itemCode" :label="item.itemValueName" :value="item.itemValueCode">
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="20" style="margin-left:75px;">
<el-checkbox v-model="checked" disabled>{{$t('member.MemberProfile.lang_memberprofile_117')}}</el-checkbox>
</el-col>
</el-row>
<el-row>
<el-col :span="20" style="margin-left:50px">
<el-radio v-model="radio" label="HOTEL" @change="getRadioValue" style="margin-top:10px;margin-left:30px;">{{$t('member.MemberProfile.lang_memberprofile_135')}}</el-radio>
<el-radio v-model="radio" label="BRAND" @change="getRadioValue" style="margin-top:10px;margin-left:30px;">{{$t('member.MemberProfile.lang_memberprofile_134')}}</el-radio>
<el-radio v-model="radio" label="GROUP" @change="getRadioValue" style="margin-top:10px;margin-left:30px;">{{$t('member.MemberProfile.lang_memberprofile_133')}}</el-radio>
</el-col>
</el-row>
<el-row>
<el-col :span="21">
<el-form-item :label="$t('member.MemberProfile.lang_memberprofile_129')" prop="noteTitle" style="margin-top:10px;">
<el-input v-model="form.noteTitle"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-input type="textarea" :rows="8" class="textareaCopy" :placeholder="$t('member.MemberProfile.lang_memberprofile_130')" v-model="form.note" style="margin-top:10px;">
</el-input>
</el-form>
<div class="twoButton">
<el-button size="mini" type="primary" @click="copySaveButton">{{$t('member.MemberProfile.lang_memberprofile_83')}}</el-button>
<el-button size="mini" type="danger" @click="handleClose4">{{$t('member.MemberProfile.lang_memberprofile_84')}}</el-button>
</div>
</div>
</el-dialog>
</div>
</template>
<script lang="ts">
import { Vue, Component, Prop, Watch, Emit } from "vue-property-decorator";
import { IDefineNotes } from "@/store/types/member/memberProfileRequest";
import { LangHelper } from "@/utils/i18n";
import { Message } from "element-ui";
import {
getBrandId,
getBussList,
getNotesList,
notesDelete,
notesInsert,
notesUpdate,
serarchNotesList,
} from "@/api/member";
import { UserModule } from "@/store/modules/user";
import { ElForm } from "element-ui/types/form";
import { format, addDays } from "date-fns";
@Component({
name: "ProfileNotes",
})
export default class ProfileNotes extends Vue {
@Prop() private isVisible!: boolean;
@Prop() private profileData!: any;
@Prop() private otherGlobalId!: any;
private profileGlobalId: string = "";
private showDelete: boolean = true;
private showCopy: boolean = true;
@Emit("cancel")
private cancel() {
const param = {
name: "operateNotes",
};
return param;
}
// 暴露保存事件
@Emit("saveNotesData")
private saveNotesData() {
return this.checkData;
}
// 带回profileId
@Emit("saveglobalId")
private saveglobalId() {
return this.profileGlobalId;
}
private checkData: [] = []; //勾选数据
private form = new IDefineNotes();
// 新增
private addDialog: boolean = false;
// 编辑
private editDialog: boolean = false;
// copy
private copyDialog: boolean = false;
private number: string = "";
private checked: boolean = true;
private textarea: string = "";
private getHotelData: any = [];
private getHotelGroupData: any = [];
private getHotelIdData: any = {};
private getNotesListData: any = [];
private KeywordType: string = "";
private Keyword: string = "";
private note: string = "";
private radio: string = "";
private noteGroup: string = "";
private noteType: string = "";
private getData: any = {};
private internal: boolean = true;
// 必填
private rules = {
noteType: [
{
required: true,
message: LangHelper.getMessage(
"member.MemberProfile.lang_memberprofile_132"
),
trigger: ["change"],
},
],
noteTitle: [
{
required: true,
message: LangHelper.getMessage(
"member.MemberProfile.lang_memberprofile_132"
),
trigger: ["change", "blur"],
},
],
};
created() {
let profId = "";
if (this.profileData === undefined) {
profId = "";
} else if (this.otherGlobalId) {
profId = this.otherGlobalId;
} else {
profId = this.profileData.id;
}
this.getHotelGroupFunc();
this.getHotelFunc();
this.getNotesListFunc(profId);
this.getBrandIdFunc();
}
// 判断酒店/品牌/集团
getRadioValue(val: any) {
if (val === "HOTEL") {
this.form.scopeCode = this.getHotelIdData.hotelId;
this.form.scopeType = "HOTEL";
}
if (val === "BRAND") {
this.form.scopeCode = this.getHotelIdData.hotelBrand;
this.form.scopeType = "BRAND";
}
if (val === "GROUP") {
this.form.scopeCode = this.getHotelIdData.fromSrc;
this.form.scopeType = "GROUP";
}
}
// 备注组
async getHotelGroupFunc() {
const param = {
hotelId: "1",
itemCode: "NOTE_GROUP",
isValid:true
};
this.getHotelGroupData = await getBussList(param as any);
}
// 备注类型 NOTE_TYPE
async getHotelFunc() {
const param = {
hotelId: "1",
itemCode: "NOTE_TYPE",
isValid:true
};
this.getHotelData = await getBussList(param as any);
}
// 获取品牌id
async getBrandIdFunc() {
const param = {
hotelId: UserModule.GetHotelId,
};
this.getHotelIdData = await getBrandId(param as any);
}
//备注列表
async getNotesListFunc(id: any) {
let profId = "";
if (this.profileData === undefined) {
profId = "";
} else if (this.otherGlobalId) {
profId = this.otherGlobalId;
} else if (id) {
profId = id;
} else {
profId = this.profileData.id;
}
this.getNotesListData = await getNotesList(profId);
}
// 取消
handleClose() {
this.saveNotesData();
this.cancel();
}
handleClose2() {
this.addDialog = false;
}
handleClose3() {
this.editDialog = false;
}
handleClose4() {
this.copyDialog = false;
}
// 新增
newProfile() {
this.form = new IDefineNotes();
this.addDialog = true;
this.form.createTime = format(new Date(), "YYYY-MM-DD HH:mm:ss");
}
checkInternal() {}
// 搜索
async searchProfile() {
if (this.otherGlobalId) {
this.profileData.id = this.otherGlobalId;
}
this.getNotesListData = await serarchNotesList(
this.profileData.id,
this.noteGroup,
this.noteType,
this.internal
);
}
// 双击修改
rowDblclick(row: any) {
this.form = new IDefineNotes();
this.form = row;
this.radio = row.scopeType;
this.editDialog = true;
}
copyProfile() {
this.form = new IDefineNotes();
this.form = this.getData;
this.radio = this.getData.scopeType;
this.copyDialog = true;
}
// 新增
okDialog() {
(this.$refs["form"] as ElForm).validate(async (valid) => {
if (valid) {
this.form.createTime = format(
this.form.createTime,
"YYYY-MM-DD HH:mm:ss"
);
let profId = "";
if (this.profileData != undefined) {
profId = this.profileData.id;
}
if (this.otherGlobalId) {
profId = this.otherGlobalId;
}
this.form.profId = this.profileData.id;
(this.form.profType = this.profileData.type),
(this.form.createUser = UserModule.GetName);
this.form.overwrideInternal = true;
this.form.internal = true;
const getAddress = Object.assign(this.form, {
profId: profId,
});
const result = await notesInsert(this.form)
.then((result) => {
Message.success(
LangHelper.getMessage(
"member.MemberProfile.lang_memberprofile_205"
) as string
);
this.addDialog = false;
this.profileGlobalId = result;
this.saveglobalId();
this.getNotesListFunc(result); //刷新列表
})
.catch((err) => (this.addDialog = false));
}
});
}
okProfile() {
this.cancel();
}
cancelProfile() {
this.cancel();
}
// 勾选
selectChecked(val: any) {
if (val.length === 0) {
this.showDelete = true;
this.showCopy = true;
this.getData = "";
} else {
if(val.length > 1 ){
(this as any).$refs.selectTable.clearSelection();
(this as any).$refs.selectTable.toggleRowSelection(val[val.length-1],true)
}
this.checkData = val;
this.showDelete = false;
this.showCopy = false;
this.checkData.forEach((element) => {
this.getData = element;
});
}
}
changeValue(){
this.$forceUpdate();
}
// 编辑保存
saveDialog() {
(this.$refs["form"] as ElForm).validate(async (valid) => {
if (valid) {
this.form.modifyTime = format(
this.form.modifyTime,
"YYYY-MM-DD HH:mm:ss"
);
this.form.profId = this.profileData.id;
(this.form.profType = this.profileData.type),
(this.form.modifyUser = UserModule.GetName);
this.form.overwrideInternal = true;
this.form.internal = true;
const result = await notesUpdate(this.form)
.then((result) => {
Message.success(
LangHelper.getMessage(
"member.MemberProfile.lang_memberprofile_207"
) as string
);
this.editDialog = false;
this.getNotesListFunc(result); //刷新列表
})
.catch((err) => (this.editDialog = false));
}
});
}
// 复制保存
copySaveButton() {
(this.$refs["form"] as ElForm).validate(async (valid) => {
if (valid) {
this.form.createTime = format(
this.form.createTime,
"YYYY-MM-DD HH:mm:ss"
);
this.form.profId = this.profileData.id;
this.form.id = "";
(this.form.profType = this.profileData.type),
(this.form.createUser = UserModule.GetName);
this.form.overwrideInternal = true;
this.form.internal = true;
const result = await notesInsert(this.form)
.then((result) => {
Message.success(
LangHelper.getMessage(
"member.MemberProfile.lang_memberprofile_208"
) as string
);
this.copyDialog = false;
this.getNotesListFunc(result); //刷新列表
})
.catch((err) => (this.copyDialog = false));
}
});
}
deleteProfile() {
const rows = this.checkData;
(this as any)
.$confirm(
`${(this as any).$t("member.MemberProfile.lang_memberprofile_97")}`,
`${(this as any).$t("member.MemberProfile.lang_memberprofile_96")}`,
{
distinguishCancelAndClose: true,
cancelButtonText: `${(this as any).$t(
"order.SingleRmInfo.lang_singlerminfo_73"
)}`,
confirmButtonText: `${(this as any).$t(
"order.SingleRmInfo.lang_singlerminfo_72"
)}`,
}
)
.then(async () => {
const ids = [];
for (let i = 0; i < rows.length; i++) {
ids.push((rows[i] as any).id);
}
const deleteContent = await notesDelete(ids);
(this as any).$message({
type: "success",
message: LangHelper.getMessage("order.SingleRmInfo.lang_131"),
});
let profId = "";
if (this.profileData === undefined) {
profId = "";
} else if (this.otherGlobalId) {
profId = this.otherGlobalId;
} else {
profId = this.profileData.id;
}
this.getNotesListFunc(profId); //刷新列表
})
.catch((action: any) => {});
}
}
</script>
<style lang="less" scoped>
.print-content {
display: flex;
justify-content: center;
align-items: center;
}
fieldset {
padding: 10px;
margin: 10px 20px;
color: #0fbdd6;
border: #000 dashed 1px;
}
.border-input {
width: 113%;
}
.addressButton {
display: flex;
margin: 0 0 10px 0;
}
.twoButton {
display: flex;
justify-content: center;
align-content: center;
margin-top: 10px;
}
/deep/ .el-input-group__append {
border-right: 1px solid #dcdcdc;
}
.cl {
clear: both;
}
.searchButton {
float: right;
right: 10px;
position: absolute;
}
/deep/ .textareaCopy {
width: 76%;
margin-left: 80px;
}
/deep/ .addCheckColor {
color: green;
font-weight: bold;
margin-left: 40%;
}
/deep/ thead {
.el-table-column--selection {
.cell {
display: none;
}
}
}
</style>