Commit e2776aad authored by leidahong's avatar leidahong

上传

parent e4e08c94
...@@ -116,3 +116,19 @@ export function getVillageList(params) { ...@@ -116,3 +116,19 @@ export function getVillageList(params) {
url: "/wcwy/house/getHouseList/" + params, url: "/wcwy/house/getHouseList/" + params,
}); });
} }
//事件类型
export function getEventTypeList() {
return request({
url: "/wcwy/type/list",
});
}
//获取用户信息
export function getNishiseiInfo(params) {
return request({
url: "/nishisei/user/getNishiseiInfo",
params,
});
}
import Vue from 'vue' import Vue from "vue";
import App from './App.vue' import App from "./App.vue";
import router from './router' import router from "./router";
import store from './store' import store from "./store";
import VConsole from 'vconsole' import VConsole from "vconsole";
import './utils/rem' import "./utils/rem";
import './static/reset.css' import "./static/reset.css";
import Vant from 'vant'; import Vant from "vant";
import 'vant/lib/index.css'; import "vant/lib/index.css";
Vue.use(Vant); Vue.use(Vant);
Vue.config.productionTip = false Vue.config.productionTip = false;
router.afterEach((to, from) => { router.afterEach((to, from) => {
document.title = to.meta.title document.title = to.meta.title;
}) });
const vConsole = new VConsole() // const vConsole = new VConsole()
new Vue({ new Vue({
router, router,
store, store,
render: h => h(App) render: (h) => h(App),
}).$mount('#app') }).$mount("#app");
import Vue from 'vue' import Vue from "vue";
import Vuex from 'vuex' import Vuex from "vuex";
Vue.use(Vuex) Vue.use(Vuex);
export default new Vuex.Store({ export default new Vuex.Store({
state: { state: {
userInfo:{}, userInfo: {},
unReadCount: 0 unReadCount: 0,
NishiseiInfo: {},
}, },
mutations: { mutations: {
SET_USERINFO(state,userInfo){ SET_USERINFO(state, userInfo) {
state.userInfo = userInfo state.userInfo = userInfo;
}, },
SET_READCOUNT(state, value) { SET_READCOUNT(state, value) {
state.unReadCount = value state.unReadCount = value;
} },
}, SET_NishiseiInfo(state, value) {
actions: { state.NishiseiInfo = value;
},
}, },
modules: { actions: {},
} modules: {},
}) });
...@@ -20,14 +20,14 @@ ...@@ -20,14 +20,14 @@
<div class="detail-item"> <div class="detail-item">
<div class="label">事件描述</div> <div class="label">事件描述</div>
<div class="val" style="line-height: 0.42rem"> <div class="val" style="line-height: 0.42rem">
{{ info.description || "--" }} {{ info.eventDetails || "--" }}
</div> </div>
<div class="val"> <div class="val">
<div class="img-box"> <div class="img-box" v-if="info.imgUrlList">
<img <img
:src="item" :src="item"
@click="preview(imgUrlList, index)" @click="preview(info.imgUrlList, index)"
v-for="(item, index) in imgUrlList" v-for="(item, index) in info.imgUrlList.split(',')"
/> />
</div> </div>
</div> </div>
...@@ -64,6 +64,27 @@ ...@@ -64,6 +64,27 @@
<div class="label">处理时间</div> <div class="label">处理时间</div>
<div class="val">{{ info.registerDate || "--" }}</div> <div class="val">{{ info.registerDate || "--" }}</div>
</div> </div>
<div class="detail-item">
<div class="label">附件</div>
<div class="val">
<div class="file-list" v-if="info.fileUrlList">
<div
class="file-item"
v-for="item in info.fileUrlList.split(',')"
:key="item"
>
<div class="file-name">
{{
item.split("/").pop().split("_")[0] +
"." +
item.split(".").pop()
}}
</div>
<div class="check-btn" @click="readFile(item)">查看附件</div>
</div>
</div>
</div>
</div>
<div class="detail-item" v-if="hasProcess"> <div class="detail-item" v-if="hasProcess">
<div class="label">处理内容</div> <div class="label">处理内容</div>
<div class="val">{{ info.processContent || "--" }}</div> <div class="val">{{ info.processContent || "--" }}</div>
...@@ -71,11 +92,11 @@ ...@@ -71,11 +92,11 @@
<div class="detail-item" v-if="hasProcess"> <div class="detail-item" v-if="hasProcess">
<div class="label">处理前</div> <div class="label">处理前</div>
<div class="val"> <div class="val">
<div class="img-box"> <div class="img-box" v-if="info.beforeProcessImgList">
<img <img
:src="item" :src="item"
@click="preview(beforeHandleImgs, index)" @click="preview(info.beforeProcessImgList, index)"
v-for="(item, index) in beforeHandleImgs" v-for="(item, index) in info.beforeProcessImgList.split(',')"
/> />
</div> </div>
</div> </div>
...@@ -83,22 +104,32 @@ ...@@ -83,22 +104,32 @@
<div class="detail-item" v-if="hasProcess"> <div class="detail-item" v-if="hasProcess">
<div class="label">处理后</div> <div class="label">处理后</div>
<div class="val"> <div class="val">
<div class="img-box"> <div class="img-box" v-if="info.afterProcessImgList">
<img <img
:src="item" :src="item"
@click="preview(afterHandleImgs, index)" @click="preview(info.afterProcessImgList, index)"
v-for="(item, index) in afterHandleImgs" v-for="(item, index) in info.afterProcessImgList.split(',')"
/> />
</div> </div>
</div> </div>
</div> </div>
<div class="detail-item"> <div class="detail-item" v-if="hasProcess">
<div class="label">附件</div> <div class="label">处理后附件</div>
<div class="val"> <div class="val">
<div class="file-list"> <div class="file-list" v-if="info.processedFileUrlList">
<div class="file-item" v-for="item in info.fileUrlList"> <div
<div class="file-name">{{ item }}</div> class="file-item"
<div class="check-btn">查看附件</div> v-for="item in info.processedFileUrlList.split(',')"
:key="item"
>
<div class="file-name">
{{
item.split("/").pop().split("_")[0] +
"." +
item.split(".").pop()
}}
</div>
<div class="check-btn" @click="readFile(item)">查看附件</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -141,42 +172,64 @@ export default { ...@@ -141,42 +172,64 @@ export default {
}, },
methods: { methods: {
getInfo() { getInfo() {
getEventDetail(this.id).then((res) => {
this.info = res.data;
if (res.data.status === "已处理") {
this.getPrecessInfo();
}
});
},
getPrecessInfo() {
getEventInfo(this.id).then((res) => { getEventInfo(this.id).then((res) => {
this.info.processContent = res.data.processContent; this.info = res.data;
if (res.data.beforeProcessImgList) { // if (res.data.status === "已处理") {
this.beforeHandleImgs = res.data.beforeProcessImgList.split(","); // this.getPrecessInfo();
} // }
if (res.data.afterProcessImgList) {
this.afterHandleImgs = res.data.afterProcessImgList.split(",");
}
if (res.data.imgUrlList) {
this.info.imgUrlList = res.data.imgUrlList.split(",");
}
if (res.data.fileUrlList) {
this.info.fileList = res.data.fileUrlList.split(",");
}
}); });
}, },
// getPrecessInfo() {
// getEventInfo(this.id).then((res) => {
// this.info.processContent = res.data.processContent;
// if (res.data.beforeProcessImgList) {
// this.beforeHandleImgs = res.data.beforeProcessImgList.split(",");
// }
// if (res.data.afterProcessImgList) {
// this.afterHandleImgs = res.data.afterProcessImgList.split(",");
// }
// if (res.data.imgUrlList) {
// this.info.imgUrlList = res.data.imgUrlList.split(",");
// }
// if (res.data.fileUrlList) {
// this.info.fileList = res.data.fileUrlList.split(",");
// }
// });
// },
toHandle() { toHandle() {
this.$router.push("/handle?id=" + this.id); this.$router.push("/handle?id=" + this.id);
}, },
preview(images, startPosition) { preview(images, startPosition) {
console.log(images);
images = images.split(",").map((item) => window.location.origin + item);
this.scrollTop = this.scrollTop =
document.documentElement.scrollTop || document.body.scrollTop; document.documentElement.scrollTop || document.body.scrollTop;
alert(this.scrollTop);
ImagePreview({ ImagePreview({
images, images,
startPosition, startPosition,
}); });
}, },
readFile(url) {
const link = document.createElement("a");
link.href = window.location.origin + url;
link.download = name;
link.style.display = "none";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
},
formatPath(path) {
console.log(path);
if (path.split(",").length > 1) {
return path.split(",");
} else {
return [path];
}
},
}, },
mounted() { mounted() {
this.id = this.$route.query.id; this.id = this.$route.query.id;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
<div class="handle-item"> <div class="handle-item">
<div class="label">附件上传</div> <div class="label">附件上传</div>
<div class="val"> <div class="val">
<van-uploader v-model="fileList" multiple /> <van-uploader v-model="fileList" :after-read="fileUpload" multiple />
</div> </div>
</div> </div>
<div class="btn-box"> <div class="btn-box">
...@@ -57,6 +57,7 @@ export default { ...@@ -57,6 +57,7 @@ export default {
beforeHandleImgs: [], beforeHandleImgs: [],
afterHandleImgs: [], afterHandleImgs: [],
fileList: [], fileList: [],
fileUrlList: [],
}; };
}, },
methods: { methods: {
...@@ -70,8 +71,9 @@ export default { ...@@ -70,8 +71,9 @@ export default {
.join(","), .join(","),
eventId: this.$route.query.id, eventId: this.$route.query.id,
processContent: this.content, processContent: this.content,
fileUrlList: this.fileList.map((item) => item.url).join(","), fileUrlList: this.fileUrlList.join(","),
}; };
handleEvent(data).then((res) => { handleEvent(data).then((res) => {
if (this.content.trim() === "") { if (this.content.trim() === "") {
Toast.fail("请填写处理内容"); Toast.fail("请填写处理内容");
...@@ -127,6 +129,26 @@ export default { ...@@ -127,6 +129,26 @@ export default {
}); });
} }
}, },
fileUpload(files) {
if (!Array.isArray(files)) files = [files];
files.forEach(async (file) => {
file.status = "uploading";
file.message = "上传中...";
let formData = new FormData();
formData.append("file", file.file);
const res = await uploadImg(formData);
this.fileUrlList.push(res.data.url);
if (res.code == 200) {
file.status = "done";
file.message = "上传成功";
} else {
file.status = "failed";
file.message = "上传失败";
}
});
},
}, },
}; };
</script> </script>
......
...@@ -4,124 +4,144 @@ ...@@ -4,124 +4,144 @@
<router-view></router-view> <router-view></router-view>
</keep-alive> </keep-alive>
<div class="tab-container"> <div class="tab-container">
<div class="tab-item" @click="changeTab(item, index)" :class="{'active': index === tabIndex}" :key="index" v-for="(item, index) in tabs"> <div
<img class="icon" :src="require(`../assets/imgs/bottom_${item.iconName}_${index === tabIndex ? 'hover' : 'def'}_icon.png`)" /> class="tab-item"
@click="changeTab(item, index)"
:class="{ active: index === tabIndex }"
:key="index"
v-for="(item, index) in tabs"
>
<img
class="icon"
:src="
require(`../assets/imgs/bottom_${item.iconName}_${
index === tabIndex ? 'hover' : 'def'
}_icon.png`)
"
/>
<div class="name">{{ item.name }}</div> <div class="name">{{ item.name }}</div>
<div class="message-count" v-if="index === 1 && messageCount > 0">{{ messageCount }}</div> <div class="message-count" v-if="index === 1 && messageCount > 0">
{{ messageCount }}
</div>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { getUserInfo, getMessageCount } from '../api/index' import { getUserInfo, getMessageCount, getNishiseiInfo } from "../api/index";
export default { export default {
name: 'Home', name: "Home",
computed: { computed: {
messageCount() { messageCount() {
return this.$store.state.unReadCount return this.$store.state.unReadCount;
}, },
tabIndex() { tabIndex() {
if (this.$route.name === 'EventList') { if (this.$route.name === "EventList") {
return 0 return 0;
} else if (this.$route.name === 'Message') { } else if (this.$route.name === "Message") {
return 1 return 1;
} else if (this.$route.name === 'Statistics') { } else if (this.$route.name === "Statistics") {
return 2 return 2;
} }
} },
}, },
data() { data() {
return { return {
tabs: [ tabs: [
{ {
name: '事件', name: "事件",
iconName: 'event', iconName: "event",
routerName: 'EventList' routerName: "EventList",
}, },
{ {
name: '消息', name: "消息",
iconName: 'notice', iconName: "notice",
routerName: 'Message' routerName: "Message",
}, },
{ {
name: '统计', name: "统计",
iconName: 'count', iconName: "count",
routerName: 'Statistics' routerName: "Statistics",
} },
] ],
} };
}, },
methods: { methods: {
changeTab(item, index) { changeTab(item, index) {
if (this.tabIndex === index) return; if (this.tabIndex === index) return;
this.$router.push({ this.$router.push({
name: item.routerName name: item.routerName,
}) });
}, },
getInfo() { getInfo() {
getUserInfo().then(res => { getUserInfo().then((res) => {
if (res.code === 200) { if (res.code === 200) {
this.$store.commit('SET_USERINFO', res.user) this.$store.commit("SET_USERINFO", res.user);
} }
}) });
getMessageCount().then(res => { getNishiseiInfo().then((res) => {
if (res.code === 200) { if (res.code === 200) {
this.$store.commit('SET_READCOUNT', res.data) localStorage.setItem("houseId", res.data.houseId);
localStorage.setItem("communityId", res.data.communityId);
} }
}) });
getMessageCount().then((res) => {
if (res.code === 200) {
this.$store.commit("SET_READCOUNT", res.data);
}
});
}, },
}, },
mounted() { mounted() {
this.getInfo() this.getInfo();
} },
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.home{ .home {
min-height: 100vh; min-height: 100vh;
.tab-container{ .tab-container {
height: 1.28rem; height: 1.28rem;
width: 100%; width: 100%;
position: fixed; position: fixed;
z-index: 1000; z-index: 1000;
bottom: 0; bottom: 0;
background: #F3F4F8; background: #f3f4f8;
display: flex; display: flex;
justify-content: space-around; justify-content: space-around;
.tab-item{ .tab-item {
position: relative; position: relative;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
font-size: 0.21rem; font-size: 0.21rem;
align-items: center; align-items: center;
color: #696C76; color: #696c76;
img { img {
width: .5rem; width: 0.5rem;
height: .5rem; height: 0.5rem;
margin-bottom: .15rem; margin-bottom: 0.15rem;
} }
.message-count{ .message-count {
border-radius: 50%; border-radius: 50%;
position: absolute; position: absolute;
width: .4rem; width: 0.4rem;
height: .4rem; height: 0.4rem;
background-color: #FF5000; background-color: #ff5000;
color: #fff; color: #fff;
font-size: .25rem; font-size: 0.25rem;
font-weight: bold; font-weight: bold;
top: -.05rem; top: -0.05rem;
right: -.12rem; right: -0.12rem;
border: 1px solid #fff; border: 1px solid #fff;
text-align: center; text-align: center;
line-height: .4rem; line-height: 0.4rem;
} }
} }
.active{ .active {
color: #3978F8; color: #3978f8;
} }
} }
} }
</style> </style>
\ No newline at end of file
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
/> />
<van-field <van-field
is-link is-link
:disabled="communityDisabled"
readonly readonly
v-model="form.community" v-model="form.community"
v-bind="field('community', 1)" v-bind="field('community', 1)"
...@@ -20,6 +21,7 @@ ...@@ -20,6 +21,7 @@
<van-field <van-field
readonly readonly
is-link is-link
:disabled="houseDisabled"
v-model="form.house" v-model="form.house"
v-bind="field('house', 1)" v-bind="field('house', 1)"
@click="popupChange('house')" @click="popupChange('house')"
...@@ -72,7 +74,10 @@ ...@@ -72,7 +74,10 @@
v-bind="field('rankNo')" v-bind="field('rankNo')"
@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', 1)"
/>
<van-cell <van-cell
readonly readonly
title="上传附件" title="上传附件"
...@@ -133,17 +138,22 @@ import { ...@@ -133,17 +138,22 @@ import {
getCommunityList, getCommunityList,
getVillageList, getVillageList,
uploadImg, uploadImg,
getEventTypeList,
} from "@/api/index"; } from "@/api/index";
export default { export default {
data() { data() {
return { return {
form: { form: {
eventName: "123", eventName: "",
reportDate: "", reportDate: "",
expectedDays: "1", expectedDays: "",
imgUrlList: [], imgUrlList: [],
fileUrlList: [], fileUrlList: [],
status: "待处理", status: "待处理",
communityId: "",
community: "",
houseId: "",
house: "",
}, },
fieldMap: { fieldMap: {
eventName: "事件名称", eventName: "事件名称",
...@@ -167,11 +177,7 @@ export default { ...@@ -167,11 +177,7 @@ export default {
popupData: [], popupData: [],
isDisabled: false, isDisabled: false,
popupList: { popupList: {
category: [ category: [],
{ text: "类型1", value: 1 },
{ text: "类型2", value: 2 },
{ text: "类型3", value: 3 },
],
rankNo: [ rankNo: [
{ text: "一级事件", value: 1 }, { text: "一级事件", value: 1 },
{ text: "二级事件", value: 2 }, { text: "二级事件", value: 2 },
...@@ -189,9 +195,27 @@ export default { ...@@ -189,9 +195,27 @@ export default {
text: item.name, text: item.name,
value: item.id, value: item.id,
})); }));
const communityId = localStorage.getItem("communityId");
if (communityId) {
this.popupList.community.forEach((item) => {
if (item.value == communityId) {
this.popupType = "community";
this.onConfirm(item);
this.communityDisabled = true;
}
});
}
});
getEventTypeList().then((res) => {
this.popupList.category = res.rows.map((item) => ({
text: item.name,
value: item.id,
}));
}); });
this.form.reportDate = this.dateFormate(new Date()); this.form.reportDate = this.dateFormate(new Date());
}, },
methods: { methods: {
async onSubmit() { async onSubmit() {
this.form.imgUrlList = this.form.imgUrlList =
...@@ -249,6 +273,18 @@ export default { ...@@ -249,6 +273,18 @@ export default {
text: item.name, text: item.name,
value: item.id, value: item.id,
})); }));
const houseId = localStorage.getItem("houseId");
if (houseId > 0) {
this.popupList.house.forEach((item) => {
if (item.value == houseId) {
this.form.house = item.text;
this.form.houseId = item.value;
}
});
this.houseDisabled = true;
}
console.log(this.form);
}, },
house: () => { house: () => {
this.form[this.popupType] = e.text; this.form[this.popupType] = e.text;
...@@ -314,7 +350,7 @@ export default { ...@@ -314,7 +350,7 @@ export default {
let hour = date.getHours().toString().padStart(2, "0"); let hour = date.getHours().toString().padStart(2, "0");
let minute = date.getMinutes().toString().padStart(2, "0"); let minute = date.getMinutes().toString().padStart(2, "0");
return `${year}-${month}-${day} ${hour}:${minute} `; return `${year}-${month}-${day} ${hour}:${minute}:00`;
}, },
}, },
computed: { computed: {
......
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