Files
dou_fire/pages/work/create.vue
唐明明 1f3f6b230a 工作台
2022-12-26 09:31:55 +08:00

212 lines
4.8 KiB
Vue

<template>
<view class="create-page">
<view class="create-title">创建新的订单</view>
<view class="create-submit">完善创建订单用户与订单类型</view>
<view class="create-from">
<block v-if="createType === 'other'">
<view class="create-user" @click="() => this.$Router.push({name: 'OrderAvailable'})">
<view class="cover">
<image class="cover-src" v-if="user != ''" :src="user.avatar" mode="aspectFill"></image>
<u-icon v-else name="plus" color="#ddd" size="24"></u-icon>
</view>
<view class="nickname nowrap" :class="{'hide': user == ''}">{{user.nickname || '请选择办理用户'}}</view>
<view class="icon">
<u-icon class="icon-u" name="arrow-right" color="#ddd" size="20"></u-icon>
</view>
</view>
</block>
<view class="create-type">
<view class="create-type-title">选择业务类型</view>
<block v-for="(item, index) in businessArr" :key="index">
<view class="create-type-item" :class="{'active': item.business_id == businessId}" @click="onBusiness(item.business_id)">
<image class="create-type-icon" :src="item.cover_url" mode="aspectFill"></image>
<view class="create-type-text">
<view class="title nowrap">{{item.title || '-'}}</view>
<view class="submit nowrap">{{item.subtitle || '-'}}</view>
</view>
</view>
</block>
</view>
<view class="create-btn">
<button size="default" @click="onNext()">下一步</button>
</view>
</view>
</view>
</template>
<script>
import { business } from '@/apis/interfaces/business.js'
export default {
data() {
return {
createType : '',
businessArr: [],
businessId : '',
user : ''
};
},
onShow(){
let user = this.$store.getters.getUser
this.createType = this.$Route.query.type
if(user != ''){
this.user = user
this.$store.commit('setUser', '')
}
},
created() {
business().then(res => {
this.businessArr = res
this.businessId = res[0].business_id
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
})
},
methods: {
// 选择业务类型
onBusiness(id){
this.businessId = id
},
// 创建业务单
onNext(){
if(this.createType == 'other' && !this.user.user_id){
uni.showToast({
title: '请选择办理用户',
icon : 'none'
})
return
}
let busines = this.businessArr.find(val => val.business_id === this.businessId)
this.$Router.replace({
name : 'WorkGenerate',
params : {
businessTitle : busines.title,
businessId : busines.business_id,
serviceUser : this.user.user_id,
createType : this.createType
}
})
}
}
}
</script>
<style lang="scss">
.create-page{
padding: 50rpx;
box-sizing: border-box;
height: 100vh;
.create-title{
text-align: center;
font-weight: bold;
font-size: 44rpx;
}
.create-submit{
text-align: center;
font-size: 30rpx;
color: gray;
padding-top: 10rpx;
}
.create-from{
padding-top: 50rpx;
}
// 目标用户
.create-user{
background: #f8f8f8;
border-radius: $radius;
padding: 30rpx;
display: flex;
justify-content: space-between;
align-items: center;
.cover{
width: 88rpx;
height: 88rpx;
background: white;
border-radius: $radius;
margin-right: 20rpx;
border: dashed 1rpx #ddd;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
.cover-src{
width: 100%;
height: 100%;
}
}
.nickname{
width: calc(100% - 188rpx);
line-height: 70rpx;
font-size: 32rpx;
&.hide{
color: gray;
}
}
.icon{
width: 80rpx;
text-align: right;
.icon-u{
display: inline-block;
}
}
}
// 选择业务类型
.create-type{
padding-top: 50rpx;
.create-type-title{
text-align: center;
line-height: 50rpx;
color: gray;
font-size: 30rpx;
}
.create-type-item{
background: #f8f8f8;
border-radius: $radius;
padding: 30rpx;
margin-top: 30rpx;
border:solid 1rpx #f8f8f8;
box-sizing: border-box;
display: flex;
align-items: center;
.create-type-icon{
width: 88rpx;
height: 88rpx;
margin-right: $margin;
background-color: white;
border-radius: $radius;
}
.create-type-text{
line-height: 40rpx;
.title{
font-size: 30rpx;
}
.submit{
color: gray;
font-size: 26rpx;
}
}
&.active{
border:solid 1rpx $main-color;
}
}
}
// 按钮
.create-btn{
margin-top: 90rpx;
button[size="default"]{
height: 100rpx;
line-height: 100rpx;
background: $main-color;
font-size: 32rpx;
color: white;
font-weight: bold;
&::after{
border: none;
}
}
}
}
</style>