78 lines
2.5 KiB
Vue
78 lines
2.5 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="submit">
|
|
<wd-button type="primary" block size="large" @click="ok">创建</wd-button>
|
|
</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: 16rpx 24rpx 48rpx; }
|
|
.field { margin-bottom: 24rpx; }
|
|
.lab { font-size: 26rpx; color: #6B7280; display: block; margin-bottom: 10rpx; }
|
|
.box { min-height: 92rpx; background: #fff; border-radius: 16rpx; padding: 22rpx 24rpx; border: 1rpx solid rgba(17,24,39,0.06); }
|
|
.box.tall { min-height: 180rpx; }
|
|
.box input, .box textarea { width: 100%; font-size: 30rpx; color: #111827; }
|
|
.submit { margin-top: 8rpx; }
|
|
</style>
|