Commit e2776aad authored by leidahong's avatar leidahong

上传

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