AddForm.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <view class="modal" :class="showModal?'show':''">
  3. <view class="form-wrap" >
  4. <uni-forms ref="form" label-position="top" :rules="rules" :model="form">
  5. <uni-forms-item label="值班岗" name="posName">
  6. <uni-data-select v-model="form.posId" :localdata="posList"></uni-data-select>
  7. </uni-forms-item>
  8. <uni-forms-item label="值班人员" name="user">
  9. <uni-data-select v-model="form.accountId" :localdata="userList"></uni-data-select>
  10. </uni-forms-item>
  11. <uni-forms-item label="职责说明" name="remark">
  12. <uni-easyinput type="textarea" :maxlength="30" v-model="form.remark" placeholder="请输入职责说明"></uni-easyinput>
  13. </uni-forms-item>
  14. </uni-forms>
  15. <view class="handle-container">
  16. <button class="save" type="primary" @click="onSubmit">保存</button>
  17. <button class="cancel" type="default" @click="showModal=false">取消</button>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default{
  24. name:'DutyAddForm',
  25. data(){
  26. return{
  27. showModal:false,
  28. rules:{
  29. posName:{
  30. rules:[
  31. {
  32. required: true,
  33. errorMessage: '请选择值班岗'
  34. }
  35. ],
  36. validateTrigger:'submit'
  37. },
  38. user:{
  39. rules:[
  40. {
  41. required: true,
  42. errorMessage: '请选择值班人员',
  43. }
  44. ],
  45. validateTrigger:'submit'
  46. }
  47. },
  48. form:{
  49. year:"",
  50. week:'',
  51. dutyType: undefined,
  52. groupId: 0,
  53. groupName: '',
  54. posId: undefined,
  55. posName: '',
  56. accountId: undefined,
  57. accountName: '',
  58. positionId: 0,
  59. positionName: '',
  60. remark: '',
  61. },
  62. posList:[],
  63. userList:[]
  64. }
  65. },
  66. methods:{
  67. show(){
  68. this.showModal=true
  69. },
  70. onSubmit(){
  71. this.$refs.form.validate().then(res=>{
  72. uni.showToast({
  73. icon:"none",
  74. title:"成功!!"
  75. })
  76. }).catch(err =>{
  77. uni.showToast({
  78. icon:"none",
  79. title:"请检查填写信息!"
  80. })
  81. })
  82. }
  83. }
  84. }
  85. </script>
  86. <style lang="scss" scoped>
  87. .modal{
  88. position: fixed;
  89. left: 100%;
  90. top: 0;
  91. right: 0;
  92. bottom: 0;
  93. background-color: #fff;
  94. z-index: 999;
  95. box-sizing: border-box;
  96. overflow-y: auto;
  97. transition: 0.36s;
  98. overflow: hidden;
  99. &.show{
  100. left: 0;
  101. }
  102. .form-wrap{
  103. padding: 20rpx;
  104. .handle-container{
  105. display: flex;
  106. justify-content: center;
  107. align-items: center;
  108. button{
  109. width: 160rpx;
  110. padding: 20rpx 16rpx;
  111. line-height: 1;
  112. font-size: 28rpx;
  113. &.save{
  114. background-color: #007aff;
  115. }
  116. }
  117. }
  118. }
  119. }
  120. </style>