123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- <template>
- <uni-drawer ref="drawer" mode="left" :mask-click="false" width="85%" :maskClick='true'>
- <scroll-view class="scroll-view" scroll-y="true">
- <view class="form-wrap" >
- <uni-forms ref="form" label-position="top" :rules="rules" :model="form">
- <uni-forms-item label="队伍名称" name="teamName" required>
- <uni-easyinput v-model="form.teamName" placeholder="请输入队伍名称" :clearable="false" />
- </uni-forms-item>
- <uni-forms-item label="队伍类别" name="teamCatId" required>
- <uni-data-select v-model="form.teamCatId" :localdata="teamCats" placeholder="请选择值班人员" :clear="false"></uni-data-select>
- </uni-forms-item>
- <uni-forms-item label="职责说明">
- <uni-easyinput type="textarea" :maxlength="1000" v-model="form.teamDuty" placeholder="请输入职责说明" autoHeight ></uni-easyinput>
- <view class="word-limit">{{form.teamDuty.length||0}}/1000</view>
- </uni-forms-item>
- <uni-forms-item label="说明">
- <uni-easyinput type="textarea" :maxlength="500"
- v-model="form.teamDesc" autoHeight
- placeholder="请输入职责说明"></uni-easyinput>
- <view class="word-limit">{{form.teamDesc.length||0}}/500</view>
- </uni-forms-item>
- <uni-forms-item label="排序" v-model="form.sortNo">
- <uni-number-box :min="1"></uni-number-box>
- </uni-forms-item>
- </uni-forms>
- <view class="handle-container">
- <button class="save" type="primary" @click="onSubmit">保存</button>
- <button class="cancel" type="default" @click="close">取消</button>
- </view>
- </view>
- </scroll-view>
- </uni-drawer>
- </template>
- <script>
- import teamApi from '@/api/team.js'
- export default{
- name:"TeamForm",
- computed:{
- teamCats(){
- let teamCats=uni.getStorageSync('teamCat')
- return teamCats.map(item=>{
- return{
- value:item.teamCatId,
- text:item.teamCatTitle
- }
- })
- }
- },
- data(){
- return{
- type:undefined,
- rules:{
- teamName:{
- rules:[
- {
- required: true,
- errorMessage: '请输入队伍名称'
- }
- ],
- validateTrigger:'submit'
- },
- teamCatId:{
- rules:[
- {
- required: true,
- errorMessage: '请选择队伍类别',
- }
- ],
- validateTrigger:'submit'
- },
- },
- form:{
- teamId: 0,
- teamName: '',
- teamType: 1,
- teamCatId: 1,
- teamDuty: '',
- teamDesc: '',
- sortNo: 1
- }
- }
- },
- methods:{
- resetForm(){
- this.form={
- teamId: 0,
- teamName: '',
- teamType: 1,
- teamCatId: 1,
- teamDuty: '',
- teamDesc: '',
- sortNo: 1
- }
- },
- onSubmit(){
- this.$refs.form.validate().then(res=>{
- let submitFx=this.type==='add'?teamApi.create:teamApi.update
- submitFx(this.form).then(()=>{
- uni.showToast({
- icon:"none",
- title:"成功!!"
- })
- this.$emit('success')
- this.close();
- })
- }).catch(err =>{
- uni.showToast({
- icon:"none",
- title:"请检查填写信息!"
- })
- })
- },
- show(type,item){
- this.resetForm()
- if(type==='edit'){
- this.form={...item}
- }else{
- this.form.teamType=item
- }
- this.type=type
- this.$refs.drawer.open()
- },
- close(){
- this.$refs.drawer.close()
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .scroll-view {
- height: 100%;
- padding: 20rpx;
- box-sizing: border-box;
- .form-wrap{
- padding:40rpx 20rpx;
- .handle-container{
- display: flex;
- justify-content: center;
- align-items: center;
- button{
- width: 160rpx;
- padding: 20rpx 16rpx;
- line-height: 1;
- font-size: 28rpx;
- &.save{
- background-color: #007aff;
- }
- }
- }
- .word-limit{
- text-align: right;
- padding: 10rpx 0;
- color: #999;
- font-size: 26rpx;
- }
- }
- }
- </style>
|