111 lines
2.8 KiB
Vue
111 lines
2.8 KiB
Vue
<template>
|
||
<view class="pad-x120">
|
||
<!-- 头部 -->
|
||
<status-nav navBarTitle="公告管理"></status-nav>
|
||
<view class="content" :style="{'padding-top':statusHeight+50+'px'}">
|
||
<!-- 公告状态 -->
|
||
<view class="notick-status">
|
||
<view class="radio-item" @tap="changeNotickStatus(index)" v-for="(item,index) in radioList" :key="index">
|
||
<view :class="radioIndex==index?'checked':''"></view>
|
||
<view class="font26">{{item}}</view>
|
||
</view>
|
||
</view>
|
||
<!-- 公告内容 -->
|
||
<view class="notick-txt">
|
||
<view class="notick-tips font26">请编辑公告内容</view>
|
||
<textarea class="input font26" name="msg" v-model="noticeMsg" placeholder="请填写公告内容"></textarea>
|
||
</view>
|
||
<!-- 提交按钮 -->
|
||
<view class="enter-detail-btns color-white font30">
|
||
<view class="btn" @tap="savaNoticeEv('btn')">发布</view>
|
||
<view class="btn" @tap="backEv">取消</view>
|
||
</view>
|
||
</view>
|
||
<!-- 尾部 -->
|
||
<tabbar :userType="userType" current="2"></tabbar>
|
||
</view>
|
||
</template>
|
||
<script>
|
||
import tabbar from '@/components/tabbar/tabbar';
|
||
export default {
|
||
components:{
|
||
tabbar
|
||
},
|
||
data() {
|
||
return {
|
||
statusHeight:uni.getSystemInfoSync().statusBarHeight, //状态栏高度
|
||
userType:'director', //账户类型 工人:worker 负责人:director
|
||
radioList:['开启','禁用'],
|
||
radioIndex:0, //当前选择
|
||
noticeMsg:'', //公告内容
|
||
}
|
||
},
|
||
onLoad(op) {
|
||
// 获取工地公告
|
||
this.getWorksiteNotice();
|
||
},
|
||
onShow() {
|
||
|
||
},
|
||
methods: {
|
||
// 改变公告开启状态
|
||
changeNotickStatus(index){
|
||
if(this.radioIndex !== index){
|
||
this.radioIndex = index;
|
||
// 发布公告
|
||
this.savaNoticeEv('change');
|
||
}
|
||
},
|
||
|
||
// 获取工地公告
|
||
getWorksiteNotice(){
|
||
this.$requst.get('/api/v1/index/worksite-notice',{worksite_id:uni.getStorageSync('baseWorksiteId')}).then(res=>{
|
||
if(res.code==0){
|
||
console.log(res,'工地公告');
|
||
this.noticeMsg = res.data.content;
|
||
}
|
||
})
|
||
},
|
||
|
||
// 发布公告
|
||
savaNoticeEv(type){
|
||
let params = {
|
||
status:this.radioIndex==0?1:0,
|
||
content:this.noticeMsg
|
||
}
|
||
this.$requst.post('/api/v1/manager/save-notice',params).then(res=>{
|
||
if(res.code==0){
|
||
if(type=='change'){
|
||
if(this.radioIndex==0){
|
||
this.$toolAll.tools.showToast('已开启');
|
||
}else{
|
||
this.$toolAll.tools.showToast('已禁用');
|
||
}
|
||
}else{
|
||
this.$toolAll.tools.showToast('发布成功');
|
||
}
|
||
}else{
|
||
this.$toolAll.tools.showToast(res.msg);
|
||
if(type=='change'){
|
||
if(this.radioIndex==0){
|
||
this.radioIndex = 1;
|
||
}else{
|
||
this.radioIndex = 0;
|
||
}
|
||
}
|
||
}
|
||
})
|
||
},
|
||
|
||
// 取消发布
|
||
backEv(){
|
||
uni.navigateBack({
|
||
delta:1
|
||
})
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
<style scoped>
|
||
|
||
</style> |