Commit a884876e authored by leidahong's avatar leidahong

附件

parent 7f0cdc6a
...@@ -92,17 +92,17 @@ ...@@ -92,17 +92,17 @@
</div> </div>
</div> </div>
</div> </div>
<!-- <div class="detail-item"> <div class="detail-item">
<div class="label">附件</div> <div class="label">附件</div>
<div class="val"> <div class="val">
<div class="file-list"> <div class="file-list">
<div class="file-item" v-for="item in 1"> <div class="file-item" v-for="item in info.fileUrlList">
<div class="file-name">附件名称.doc</div> <div class="file-name">{{ item }}</div>
<div class="check-btn">查看附件</div> <div class="check-btn">查看附件</div>
</div> </div>
</div> </div>
</div> </div>
</div> --> </div>
</div> </div>
<div <div
class="handle-btn-box" class="handle-btn-box"
......
...@@ -38,14 +38,16 @@ ...@@ -38,14 +38,16 @@
:border="false" :border="false"
show-word-limit show-word-limit
class="textarea" class="textarea"
/><van-uploader />
<van-cell @click="changeUploadType('img')" :border="false">
<van-uploader
class="uploader" class="uploader"
v-model="fileList" v-model="imgList"
multiple multiple
:after-read="afterRead" :after-read="afterRead"
:before-delete="beforeDelete" :before-delete="beforeDelete"
@click-preview="clickPreview" @click-preview="clickPreview"
/> /></van-cell>
</div> </div>
<van-field <van-field
v-model="form.involvedNumber" v-model="form.involvedNumber"
...@@ -71,6 +73,21 @@ ...@@ -71,6 +73,21 @@
@click="popupChange('rankNo')" @click="popupChange('rankNo')"
/> />
<van-field v-model="form.expectedDays" v-bind="field('expectedDays')" /> <van-field v-model="form.expectedDays" v-bind="field('expectedDays')" />
<van-cell
readonly
title="上传附件"
@click="changeUploadType('file')"
:border="false"
>
<van-uploader
v-model="fileList"
:after-read="afterRead"
:before-delete="beforeDelete"
upload-icon="description"
>
</van-uploader
></van-cell>
<van-field readonly /> <van-field readonly />
</van-cell-group> </van-cell-group>
<div class="btn"> <div class="btn">
...@@ -125,6 +142,7 @@ export default { ...@@ -125,6 +142,7 @@ export default {
reportDate: "", reportDate: "",
expectedDays: "1", expectedDays: "1",
imgUrlList: [], imgUrlList: [],
fileUrlList: [],
status: "待处理", status: "待处理",
}, },
fieldMap: { fieldMap: {
...@@ -142,6 +160,7 @@ export default { ...@@ -142,6 +160,7 @@ export default {
rankNo: "事件等级", rankNo: "事件等级",
expectedDays: "处理天数", expectedDays: "处理天数",
}, },
imgList: [],
fileList: [], fileList: [],
popupShow: false, popupShow: false,
popupType: "", popupType: "",
...@@ -161,6 +180,7 @@ export default { ...@@ -161,6 +180,7 @@ export default {
community: [], community: [],
}, },
isPreview: false, isPreview: false,
uploadType: "img",
}; };
}, },
created() { created() {
...@@ -174,9 +194,14 @@ export default { ...@@ -174,9 +194,14 @@ export default {
}, },
methods: { methods: {
async onSubmit() { async onSubmit() {
console.log(this.form); this.form.imgUrlList =
this.form.imgUrlList instanceof Array
this.form.imgUrlList = this.form.imgUrlList.join(","); ? this.form.imgUrlList.join(",")
: "";
this.form.fileUrlList =
this.form.fileUrlList instanceof Array
? this.form.fileUrlList.join(",")
: "";
if (this.isDisabled) return; if (this.isDisabled) return;
this.isDisabled = true; this.isDisabled = true;
const res = await addEvent(this.form); const res = await addEvent(this.form);
...@@ -247,7 +272,10 @@ export default { ...@@ -247,7 +272,10 @@ export default {
let formData = new FormData(); let formData = new FormData();
formData.append("file", file.file); formData.append("file", file.file);
const res = await uploadImg(formData); const res = await uploadImg(formData);
this.form.imgUrlList.push(res.data.url);
if (this.uploadType == "img") this.form.imgUrlList.push(res.data.url);
if (this.uploadType == "file") this.form.fileUrlList.push(res.data.url);
if (res.code == 200) { if (res.code == 200) {
file.status = "done"; file.status = "done";
file.message = "上传成功"; file.message = "上传成功";
...@@ -258,14 +286,22 @@ export default { ...@@ -258,14 +286,22 @@ export default {
}); });
}, },
beforeDelete(file, detail) { beforeDelete(file, detail) {
this.form.photo.splice(detail.index, 1); const handle = {
file: () => this.form.fileUrlList.splice(detail.index, 1),
img: () => this.form.imgUrlList.splice(detail.index, 1),
};
handle[this.uploadType]();
return true; return true;
}, },
changeUploadType(e) {
this.uploadType = e;
},
field(key, required) { field(key, required) {
const data = { const data = {
label: this.fieldMap[key], label: this.fieldMap[key],
placeholder: `请填写${this.fieldMap[key]}`, placeholder: `请填写${this.fieldMap[key]}`,
required: required, required: required ? true : false,
}; };
if (required) data.rules = [{ required: true }]; if (required) data.rules = [{ required: true }];
...@@ -311,13 +347,18 @@ export default { ...@@ -311,13 +347,18 @@ export default {
border-radius: 8px; border-radius: 8px;
border: 1px solid #ebedf0; border: 1px solid #ebedf0;
overflow: hidden; overflow: hidden;
.uploader {
margin: 0 16px;
}
} }
} }
.btn { .btn {
margin: 0px 30px; margin: 0px 30px;
} }
::v-deep .van-cell__title {
flex: none;
width: 110px;
color: #646566;
}
::v-deep .van-cell__value {
text-align: left;
}
</style> </style>
...@@ -29,8 +29,8 @@ module.exports = { ...@@ -29,8 +29,8 @@ module.exports = {
proxy: { proxy: {
"/proxyApi": { "/proxyApi": {
// target: 'http://192.168.10.12:18001/hmit-api', // target: 'http://192.168.10.12:18001/hmit-api',
target: "http://192.168.10.4:10024/", // target: "http://192.168.10.4:10024/",
// target: "https://xcsq.zjhmit.com/api", target: "https://xcsq.zjhmit.com/api",
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
"^/proxyApi": "", "^/proxyApi": "",
......
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