<template>
<div class="wrapper">
<ul>
<li class="from-item">
<div class="from-item-wrapper">
<div class="label-wrapper"><span class="required">*</span><span>诉求标题</span></div>
<div class="content-wrapper">
<el-input
type="input"
:maxlength="22"
v-model="formData.title"
placeholder="请输入标题,不超过22字"
></el-input>
</div>
</div>
</li>
<li class="from-item">
<div class="from-item-wrapper border-style">
<div class="label-wrapper"><span class="required">*</span><span>诉求企业</span></div>
<div class="content-wrapper">
<el-select
v-model="formData.enterprise"
placeholder="请选择诉求企业"
@change="selectEnter"
>
<el-option
v-for="item in options"
:key="item.enterId"
:label="item.enterName"
:value="item.enterId"
>
</el-option>
</el-select>
</div>
</div>
</li>
<li class="from-item">
<div class="from-item-wrapper">
<div class="label-wrapper"><span>企业地址</span></div>
<div class="content-wrapper">
<el-input
type="input"
:maxlength="22"
v-model="formData.address"
placeholder="请输企业地址"
></el-input>
</div>
</div>
</li>
<li class="from-item">
<div class="from-item-wrapper border-style">
<div class="label-wrapper"><span class="required">*</span><span>诉求分类</span></div>
<div class="content-wrapper">
<el-select
v-model="formData.appealType"
placeholder="请选择诉求分类"
>
<el-option
v-for="item in classification"
:key="item.appealType"
:label="item.appealTypeName"
:value="item.appealType"
>
</el-option>
</el-select>
</div>
</div>
</li>
<li class="from-item">
<div class="from-item-wrapper border-style">
<div class="label-wrapper"><span class="required">*</span><span>企业诉求经办人</span></div>
<div class="content-wrapper">
<el-input
type="input"
v-model="formData.submitter"
placeholder="请输入企业诉求经办人"
:maxlength="20"
></el-input>
</div>
</div>
</li>
<li class="from-item">
<div class="from-item-wrapper border-style">
<div class="label-wrapper"><span class="required">*</span><span>经办人联系电话</span></div>
<div class="content-wrapper">
<el-input
type="text"
class="numrule"
v-model="formData.Contact"
placeholder="请输入企业诉求经办人联系电话"
:maxlength="11"
></el-input>
</div>
</div>
</li>
<li class="from-item">
<div class="from-item-wrapper border-style mh">
<div class="label-wrapper"><span class="required">*</span><span>诉求内容</span></div>
<div class="content-wrapper">
<el-input
type="textarea"
v-model="formData.content"
:placeholder="defaultContent"
:maxlength="2000"
></el-input>
</div>
</div>
</li>
<li class="from-item">
<div class="from-item-wrapper border-style mh upload">
<div class="label-wrapper"><span>诉求附件</span></div>
<div class="content-wrapper">
<el-upload
class="upload-demo"
action=""
ref="upload"
list-type="picture-card"
accept="image/*"
multiple
:auto-upload="false"
:limit="5"
:file-list="formData.fileList"
:on-remove="handleRemove"
:on-change="handleChange"
:on-exceed="handleExceed"
>
<div>
<el-button slot="trigger" class="upload-btn"
>上传附件</el-button
>
<span class="file-upload-tip"
>最多上传5张,每张最大5M的图片</span
>
</div>
</el-upload>
</div>
</div>
</li>
</ul>
</div>
</template>
<script>
import serviceApi from "@/api/home/serviceAdmin/index.js";
export default {
data() {
return {
formData: {
title: "",
enterprise: "",
appealType: "",
submitter: "",
Contact: "",
content: "",
fileList: [
],
address:''
},
loading: false,
defaultContent:
"请输入正文:\n1.描述尽量简明扼要;\n2.请勿发布违法违规的言论;\n3.最多2000字。\n4.如有多个不同诉求分类的诉求,请按诉求分类分别提交。",
options: [],
classification: [],
requestFileList: [],
classification: [
],
};
},
mounted(){
this.$emit("save", this.formData);
},
created() {
this.getEnterpriseList();
this.classification.push(...this.$store.state.classType);
},
watch: {
"$store.state.classType": function (nVal) {
this.options.push(...this.$store.state.classType);
},
},
methods: {
remoteMethod(query) {
let params={
key:query
}
this.loading = true;
serviceApi.getEnterpriseList(params).then(res=>{
this.loading = false;
if (res.code == 200) {
this.options = res.result;
}
})
},
messageTip(msg) {
this.$message({
message: msg,
type: "warning",
});
},
selectEnter(val){
console.log(val,this.options,'val')
this.options.forEach(item=>{
if(item.enterId == val){
this.formData.address = item.address
}
})
},
handleRemove(file, fileList) {
let index = fileList.findIndex((item) => item.uid == file.uid);
this.formData.fileList = fileList;
},
handleChange(file, fileList) {
window.$bd("c_event", {
c_event_name: "新增诉求-上传附件",
c_event_id: "addAppeal_uploadFile",
});
let index = fileList.findIndex((item) => item.uid == file.uid);
if (Number(file.size) > 5242880) {
this.messageTip("图片最大支持5M,请重新上传");
fileList.splice(index, 1);
return;
}
if (file.raw.type.indexOf("image") == "-1") {
this.messageTip("请正确上传图片文件");
fileList.splice(index, 1);
return;
}
this.formData.fileList = fileList;
},
handleExceed() {
this.messageTip("最多只能上传5张图片");
},
transformBase64(file) {
var file = file;
var reader = new FileReader();
reader.onload = () => {
this.requestFileList.push(reader.result);
};
if (file) {
reader.readAsDataURL(file);
}
},
verification() {
let { title, enterprise,appealType, submitter, Contact, content } = this.formData;
if (!title) {
this.messageTip("请输入诉求标题,不能超过22字");
return false;
}
if (!enterprise) {
this.messageTip("请选择诉求企业");
return false;
}
if(!appealType){
this.messageTip("请选择诉求分类");
return false;
}
if (!submitter) {
this.messageTip("请输入企业诉求经办人,不能超过20字");
return false;
}
if (!/^[0-9]{11}$/g.test(Contact)) {
this.messageTip("企业诉求经办人联系电话必须是长度为11位的数字");
return false;
}
if (!content) {
this.messageTip("请输入诉求内容,不能超过2000字");
return false;
}
return true;
},
getEnterpriseList() {
serviceApi.getEnterpriseList({}).then((res) => {
if (res.code == 200) {
this.options = res.result;
}
});
},
getFileList() {
this.requestFileList = [];
this.formData.fileList.forEach((item) => this.transformBase64(item.raw));
},
submitBtn() {
this.getFileList();
console.log(this.formData.fileList, this.requestFileList);
},
},
};
</script>
<style scoped lang="less">
.wrapper {
margin-top: 24px;
}
// /deep/.numrule input::-webkit-outer-spin-button,
// /deep/.numrule input::-webkit-inner-spin-button {
// -webkit-appearance: none!important;
// }
// /deep/.numrule input[type="number"]{
// -moz-appearance: textfield;
// }
.required{
color: #EC6E69;
}
.from-item {
.from-item-wrapper {
display: flex;
.label-wrapper {
width: 176px;
min-height: 50px;
background: #f3f7fd;
border: 1px solid #eeeeee;
border-right: none;
opacity: 1;
font-size: 16px;
font-family: PingFang SC;
font-weight: 400;
line-height: 26px;
color: #333333;
display: flex;
align-items: center;
padding-left: 16px;
}
.content-wrapper {
flex: 1;
min-height: 50px;
/deep/ .el-select {
width: 100%;
}
.appeal-type {
/deep/ .el-input__inner {
color: #999999;
opacity: 1;
padding: 0 15px 0 18px;
}
}
/deep/ .el-input__inner {
height: 50px;
background: #ffffff;
border: 1px solid #eeeeee;
font-size: 16px;
padding: 0 15px 0 18px;
&::placeholder {
color: #999999;
font-size: 16px;
}
}
/deep/ .upload-demo {
display: flex;
align-items: center;
.el-upload-list--picture-card {
.el-upload-list__item {
width: 120px;
height: 120px;
margin-bottom: 0;
.el-upload-list__item-status-label {
display: none;
}
}
}
.el-upload--picture-card {
background: none;
border: none;
width: inherit;
height: inherit;
line-height: inherit;
.el-button {
width: 112px;
height: 36px;
border: 1px solid #dddddd;
opacity: 1;
display: flex;
align-items: center;
&::before {
content: "";
display: inline-block;
width: 18px;
height: 18px;
background: url("../assets/images/icon/icon-upload.svg") no-repeat
center center;
background-size: 100% 100%;
margin-right: 6px;
background-size: 18px 18px;
}
}
}
}
}
}
.mh {
.label-wrapper {
min-height: 140px !important;
}
.content-wrapper {
/deep/ .el-textarea__inner {
min-height: 140px !important;
border-top: none;
border: 1px solid #eeeeee;
font-size: 16px;
padding: 5px 15px 0 18px;
&::placeholder {
color: #999999;
font-size: 16px;
}
}
}
}
.upload {
.content-wrapper {
height: 140px;
background: #ffffff;
border: 1px solid #eeeeee;
border-top: none;
padding-left: 18px;
display: flex;
align-items: center;
.file-upload-tip {
font-size: 14px;
padding-top: 5px;
display: inline-block;
color: #999999;
}
}
}
.border-style {
.label-wrapper {
border-top: none;
// border-bottom: none;
}
.content-wrapper {
/deep/ .el-input__inner {
border-top: none;
// border-bottom: none;
}
}
}
}
</style>