75 lines
2.3 KiB
Vue
75 lines
2.3 KiB
Vue
<template>
|
|
<view class="page">
|
|
<fy-header title="新建协同" back />
|
|
<view class="body">
|
|
<view class="field">
|
|
<text class="lab">标题</text>
|
|
<view class="box"><input v-model="title" placeholder="请输入任务标题" /></view>
|
|
</view>
|
|
<view class="field">
|
|
<text class="lab">办理人</text>
|
|
<picker :range="names" @change="pick">
|
|
<view class="box">{{ assigneeName || '请选择' }}</view>
|
|
</picker>
|
|
</view>
|
|
<view class="field">
|
|
<text class="lab">说明</text>
|
|
<view class="box tall"><textarea v-model="content" /></view>
|
|
</view>
|
|
<view class="btn-primary" @click="ok">创建</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import FyHeader from '../../components/fy-header.vue'
|
|
import { store } from '../../utils/store.js'
|
|
import { asList, toast } from '../../utils/format.js'
|
|
import { oaGet, oaPost } from '../../utils/api.js'
|
|
|
|
export default {
|
|
components: { FyHeader },
|
|
data() {
|
|
return { title: '', content: '', assignees: [], assignee: '', assigneeName: '' }
|
|
},
|
|
computed: {
|
|
names() { return this.assignees.map((a) => a.realName || a.name || a.username) }
|
|
},
|
|
onLoad() { this.boot() },
|
|
methods: {
|
|
async boot() {
|
|
try {
|
|
this.assignees = asList(await oaGet('/work-tasks/assignees', store.token))
|
|
} catch (_) {
|
|
this.assignees = Object.values(store.people)
|
|
}
|
|
},
|
|
pick(e) {
|
|
const a = this.assignees[e.detail.value]
|
|
this.assignee = a.username || a.id
|
|
this.assigneeName = a.realName || a.name || a.username
|
|
},
|
|
async ok() {
|
|
if (!this.title.trim()) return toast('请填写标题')
|
|
if (!this.assignee) return toast('请选择办理人')
|
|
try {
|
|
await oaPost('/work-tasks', { title: this.title, content: this.content, assignee: this.assignee }, store.token)
|
|
toast('已创建', 'success')
|
|
setTimeout(() => uni.navigateBack(), 400)
|
|
} catch (e) {
|
|
toast(e.message || '创建失败')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.body { padding: 24rpx; }
|
|
.field { margin-bottom: 20rpx; }
|
|
.lab { font-size: 24rpx; color: #434655; display: block; margin-bottom: 8rpx; }
|
|
.box { min-height: 88rpx; background: #fff; border-radius: 16rpx; padding: 20rpx 24rpx; }
|
|
.box.tall { min-height: 160rpx; }
|
|
.box input, .box textarea { width: 100%; }
|
|
</style>
|