TestActivitiLeaveForm.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view>
  3. <form @submit="formSubmit" ref="inputForm" class="cu-list menu">
  4. <view class="cu-form-group margin-top">
  5. <view class="title">
  6. <text class="red-color">* </text> 类型
  7. </view>
  8. <jp-picker v-model="inputForm.leaveType" :disabled="formReadOnly" :range="$dictUtils.getDictList('oa_leave_type')">
  9. <view class="picker">
  10. {{$dictUtils.getDictLabel('oa_leave_type', inputForm.leaveType ,'请选择')}}
  11. </view>
  12. </jp-picker>
  13. </view>
  14. <view class="cu-form-group">
  15. <view class="title">请假开始时间</view>
  16. <picker mode="date" :value="inputForm.startTime" :disabled="formReadOnly" @change="StartTimeChange" >
  17. <view class="picker">
  18. {{inputForm.startTime}}
  19. </view>
  20. </picker>
  21. </view>
  22. <view class="cu-form-group">
  23. <view class="title">请假结束时间</view>
  24. <picker mode="date" :value="inputForm.endTime" :disabled="formReadOnly" @change="EndTimeChange">
  25. <view class="picker">
  26. {{inputForm.endTime}}
  27. </view>
  28. </picker>
  29. </view>
  30. <view class="cu-form-group">
  31. <view class="title">
  32. <text class="red-color">* </text> 请假事由
  33. </view>
  34. <textarea maxlength="2000" v-model="inputForm.reason" :disabled="formReadOnly" name="reason" placeholder="请填写内容"></textarea>
  35. </view>
  36. </form>
  37. </view>
  38. </template>
  39. <script>
  40. var graceChecker = require("@/common/graceChecker.js");
  41. import jpPicker from '@/components/jp-picker/jp-picker.vue'
  42. import moment from 'moment'
  43. import TestActivitiLeaveService from "@/api/test/activiti/TestActivitiLeaveService"
  44. export default {
  45. data () {
  46. return {
  47. loading: false,
  48. inputForm: {
  49. id: '',
  50. leaveType: '',
  51. startTime: moment(new Date()).format('YYYY-MM-DD'),
  52. endTime: moment(new Date()).format('YYYY-MM-DD'),
  53. reason: ''
  54. }
  55. }
  56. },
  57. props: {
  58. businessId: {
  59. type: String,
  60. default: ''
  61. },
  62. formReadOnly: {
  63. type: Boolean,
  64. default: false
  65. }
  66. },
  67. components: {
  68. jpPicker
  69. },
  70. testActivitiLeaveService: null,
  71. created() {
  72. this.testActivitiLeaveService = new TestActivitiLeaveService()
  73. },
  74. watch: {
  75. 'businessId': {
  76. handler (newVal) {
  77. if (this.businessId) {
  78. this.init(this.businessId)
  79. } else {
  80. this.$nextTick(() => {
  81. // this.$refs.inputForm.reset()
  82. })
  83. }
  84. },
  85. immediate: true,
  86. deep: false
  87. }
  88. },
  89. methods: {
  90. StartTimeChange (e) {
  91. this.inputForm.startTime = e.detail.value
  92. },
  93. EndTimeChange (e) {
  94. this.inputForm.endTime = e.detail.value
  95. },
  96. init (id) {
  97. if (id) {
  98. this.testActivitiLeaveService.queryById(id).then(({data}) => {
  99. this.inputForm = this.recover(this.inputForm, data)
  100. })
  101. }
  102. },
  103. saveForm (callback) {
  104. //定义表单规则
  105. var rule = [
  106. {name:"leaveType", checkType : "notnull", checkRule:"", errorMsg:"类型不能为空"},
  107. {name:"startTime", checkType : "notnull", checkRule:"", errorMsg:"请假开始时间不能为空"},
  108. {name:"endTime", checkType : "notnull", checkRule:"", errorMsg:"请假结束时间不能为空"},
  109. {name:"reason", checkType : "notnull", checkRule:"", errorMsg:"请假事由不能为"}
  110. ];
  111. //进行表单检查
  112. var formData = this.inputForm;
  113. var checkRes = graceChecker.check(formData, rule);
  114. if(checkRes){
  115. uni.showLoading()
  116. this.testActivitiLeaveService.save(this.inputForm).then(({data}) => {
  117. callback(data.businessTable, data.businessId)
  118. }).catch((e)=>{
  119. })
  120. }else{
  121. uni.showToast({ title: graceChecker.error, icon: "none" });
  122. }
  123. }
  124. }
  125. }
  126. </script>
  127. <style>
  128. .cu-form-group .title {
  129. min-width: calc(4em + 40px);
  130. }
  131. </style>