初始提交
This commit is contained in:
133
pages/apply/reportLog/form.vue
Normal file
133
pages/apply/reportLog/form.vue
Normal file
@@ -0,0 +1,133 @@
|
||||
<template>
|
||||
<view class="logForm-v jnpf-wrap">
|
||||
<u-form :model="dataForm" :rules="rules" ref="dataForm" :errorType="['toast']" label-position="left"
|
||||
label-width="150" label-align="left">
|
||||
<view class="u-p-l-20 u-p-r-20 form-item-box">
|
||||
<u-form-item label="日志标题" prop="title" required>
|
||||
<u-input v-model="dataForm.title" placeholder="请输入日志标题" :disabled="disabled" />
|
||||
</u-form-item>
|
||||
<u-form-item label="今日内容" prop="todayContent" required>
|
||||
<u-input v-model="dataForm.todayContent" type="textarea" placeholder="请输入今日内容"
|
||||
:disabled="disabled" />
|
||||
</u-form-item>
|
||||
<u-form-item label="明日内容" prop="tomorrowContent" required>
|
||||
<u-input v-model="dataForm.tomorrowContent" type="textarea" placeholder="请输入明日内容"
|
||||
:disabled="disabled" />
|
||||
</u-form-item>
|
||||
<u-form-item label="遇到问题" prop="question" required>
|
||||
<u-input v-model="dataForm.question" type="textarea" placeholder="请输入遇到问题" :disabled="disabled" />
|
||||
</u-form-item>
|
||||
<u-form-item label="发送给谁" prop="userIds" required>
|
||||
<JnpfUserSelect v-model="dataForm.userIds" multiple :disabled="disabled" />
|
||||
</u-form-item>
|
||||
</view>
|
||||
</u-form>
|
||||
<view class="com-saveBox" v-if="!disabled">
|
||||
<u-button type="primary" @click="save">保存</u-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getLogInfo,
|
||||
createLog,
|
||||
updateLog
|
||||
} from '@/api/apply/reportLog.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
dataForm: {
|
||||
title: '',
|
||||
todayContent: '',
|
||||
tomorrowContent: '',
|
||||
question: '',
|
||||
userIds: ''
|
||||
},
|
||||
rules: {
|
||||
title: [{
|
||||
required: true,
|
||||
message: '日志标题不能为空',
|
||||
trigger: ['change', 'blur']
|
||||
}],
|
||||
todayContent: [{
|
||||
required: true,
|
||||
message: '今日内容不能为空',
|
||||
trigger: ['change', 'blur']
|
||||
}],
|
||||
tomorrowContent: [{
|
||||
required: true,
|
||||
message: '明日内容不能为空',
|
||||
trigger: ['change', 'blur']
|
||||
}],
|
||||
question: [{
|
||||
required: true,
|
||||
message: '问题不能为空',
|
||||
trigger: ['change', 'blur']
|
||||
}],
|
||||
userIds: [{
|
||||
required: true,
|
||||
message: '用户不能为空',
|
||||
trigger: ['change', 'blur'],
|
||||
type: 'array'
|
||||
}],
|
||||
},
|
||||
type: '0',
|
||||
disabled: false
|
||||
}
|
||||
},
|
||||
onReady() {
|
||||
this.$refs.dataForm.setRules(this.rules);
|
||||
},
|
||||
onLoad(option) {
|
||||
this.type = option.type
|
||||
if (!option.id) {
|
||||
uni.setNavigationBarTitle({
|
||||
title: '新增日志'
|
||||
});
|
||||
let userInfo = uni.getStorageSync('userInfo') || {}
|
||||
if (!userInfo.userName) return
|
||||
this.dataForm.title = userInfo.userName + '的日志'
|
||||
} else {
|
||||
if (this.type == '1') this.disabled = true
|
||||
getLogInfo(option.id).then(res => {
|
||||
this.dataForm = res.data;
|
||||
this.dataForm.userIds = this.dataForm.userIds.split(',')
|
||||
uni.setNavigationBarTitle({
|
||||
title: this.dataForm.title
|
||||
});
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
save() {
|
||||
this.$refs.dataForm.validate((valid) => {
|
||||
this.dataForm.toUserId = this.dataForm.userIds.join(',')
|
||||
if (valid) {
|
||||
const method = this.dataForm.id ? updateLog : createLog
|
||||
method(this.dataForm).then(res => {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
complete: () => {
|
||||
setTimeout(() => {
|
||||
uni.$emit('refresh')
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: #f0f2f6;
|
||||
}
|
||||
|
||||
.logForm-v {
|
||||
padding-bottom: 140rpx;
|
||||
}
|
||||
</style>
|
||||
177
pages/apply/reportLog/index.vue
Normal file
177
pages/apply/reportLog/index.vue
Normal file
@@ -0,0 +1,177 @@
|
||||
<template>
|
||||
<view class="reportLog-v">
|
||||
<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :sticky="true"
|
||||
:down="downOption" :up="upOption" :bottombar="false">
|
||||
<view class="search-box_sticky">
|
||||
<u-tabs :list="tabsList" :current="current" @change="change" :is-scroll='false'>
|
||||
</u-tabs>
|
||||
<view class="search-box">
|
||||
<u-search :placeholder="$t('app.apply.pleaseKeyword')" v-model="keyword" height="72"
|
||||
:show-action="false" @change="search" bg-color="#f0f2f6" shape="square">
|
||||
</u-search>
|
||||
</view>
|
||||
</view>
|
||||
<view class="log-list" v-for="(item, index) in list" :key="index">
|
||||
<u-swipe-action :index="index" :show="item.show" @click="handleClick" @open="open" :options="options"
|
||||
@content-click="goDetail(item.id)">
|
||||
<view class="log-list-txt u-flex-col">
|
||||
<view class="u-font-30 u-flex u-m-b-10 log-title">
|
||||
<text class="title u-line-1">{{item.title}}</text>
|
||||
<text>{{jnpf.toDate(item.creatorTime ,'MM-dd')}}</text>
|
||||
</view>
|
||||
<text class="u-m-t-10">{{userInfo.userName}}/{{userInfo.userAccount}}</text>
|
||||
</view>
|
||||
</u-swipe-action>
|
||||
</view>
|
||||
</mescroll-body>
|
||||
<view class="com-addBtn" @click="goDetail()">
|
||||
<u-icon name="plus" size="48" color="#fff" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getSendList,
|
||||
getReceiveList,
|
||||
delLog
|
||||
} from '@/api/apply/reportLog.js'
|
||||
import resources from '@/libs/resources.js'
|
||||
import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
|
||||
export default {
|
||||
mixins: [MescrollMixin],
|
||||
data() {
|
||||
return {
|
||||
downOption: {
|
||||
use: true,
|
||||
auto: true
|
||||
},
|
||||
upOption: {
|
||||
page: {
|
||||
num: 0,
|
||||
size: 20,
|
||||
time: null
|
||||
},
|
||||
empty: {
|
||||
use: true,
|
||||
icon: resources.message.nodata,
|
||||
tip: this.$t('common.noData'),
|
||||
fixed: true,
|
||||
top: "300rpx",
|
||||
},
|
||||
textNoMore: this.$t('app.apply.noMoreData'),
|
||||
},
|
||||
current: 0,
|
||||
tabsList: [{
|
||||
name: '我发出的'
|
||||
},
|
||||
{
|
||||
name: '我收到的'
|
||||
}
|
||||
],
|
||||
keyword: '',
|
||||
list: [],
|
||||
userInfo: {},
|
||||
options: [{
|
||||
text: '删除',
|
||||
style: {
|
||||
backgroundColor: '#dd524d'
|
||||
}
|
||||
}]
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.userInfo = uni.getStorageSync('userInfo') || {}
|
||||
uni.$on('refresh', () => {
|
||||
this.list = [];
|
||||
this.current = 0
|
||||
this.mescroll.resetUpScroll();
|
||||
})
|
||||
},
|
||||
onUnload() {
|
||||
uni.$off('refresh')
|
||||
},
|
||||
methods: {
|
||||
upCallback(page) {
|
||||
let query = {
|
||||
currentPage: page.num,
|
||||
pageSize: page.size,
|
||||
keyword: this.keyword
|
||||
}
|
||||
const method = this.current ? getReceiveList : getSendList
|
||||
method(query, {
|
||||
load: page.num == 1
|
||||
}).then(res => {
|
||||
this.mescroll.endSuccess(res.data.list.length);
|
||||
if (page.num == 1) this.list = [];
|
||||
const list = res.data.list.map(o => ({
|
||||
show: false,
|
||||
...o
|
||||
}));
|
||||
this.list = this.list.concat(list);
|
||||
}).catch(() => {
|
||||
this.mescroll.endErr();
|
||||
})
|
||||
},
|
||||
open(index) {
|
||||
this.list[index].show = true;
|
||||
this.list.map((val, idx) => {
|
||||
if (index != idx) this.list[idx].show = false;
|
||||
})
|
||||
},
|
||||
handleClick(index, index1) {
|
||||
const item = this.list[index]
|
||||
delLog(item.id).then(res => {
|
||||
this.$u.toast(res.msg)
|
||||
this.list.splice(index, 1)
|
||||
if (!this.list.length) this.mescroll.resetUpScroll()
|
||||
})
|
||||
},
|
||||
goDetail(id) {
|
||||
const url = './form?type=' + this.current + (id ? '&id=' + id : '')
|
||||
uni.navigateTo({
|
||||
url: url
|
||||
})
|
||||
},
|
||||
change(index) {
|
||||
this.current = index;
|
||||
this.mescroll.resetUpScroll()
|
||||
},
|
||||
search() {
|
||||
this.searchTimer && clearTimeout(this.searchTimer)
|
||||
this.searchTimer = setTimeout(() => {
|
||||
this.list = [];
|
||||
this.mescroll.resetUpScroll();
|
||||
}, 300)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: #f0f2f6;
|
||||
}
|
||||
|
||||
.reportLog-v {
|
||||
|
||||
.log-list {
|
||||
width: 100%;
|
||||
margin-bottom: 20rpx;
|
||||
color: #9a9a9a;
|
||||
|
||||
.log-list-txt {
|
||||
padding: 16rpx 32rpx;
|
||||
|
||||
.log-title {
|
||||
justify-content: space-between;
|
||||
|
||||
.title {
|
||||
color: #333333;
|
||||
width: 500rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user