TestActivitiLeaveForm.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <view>
  3. <u--form :model="inputForm" labelWidth="100px" class="u-form" labelPosition="left" :rules="rules" ref="inputForm">
  4. <u-form-item label="类型" borderBottom prop="name">
  5. <jp-picker v-model="inputForm.leaveType" rangeKey="label" rangeValue="value" :range="$dictUtils.getDictList('oa_leave_type')"></jp-picker>
  6. </u-form-item>
  7. <u-form-item label="请假开始时间" borderBottom prop="startTime">
  8. <jp-datetime-picker v-model="inputForm.startTime" mode="datetime"></jp-datetime-picker>
  9. </u-form-item>
  10. <u-form-item label="请假结束时间" borderBottom prop="endTime">
  11. <jp-datetime-picker v-model="inputForm.endTime" mode="datetime"></jp-datetime-picker>
  12. </u-form-item>
  13. <u-form-item label="请假事由" borderBottom prop="reason">
  14. <u--textarea placeholder='请填写请假事由' v-model="inputForm.reason" ></u--textarea>
  15. </u-form-item>
  16. </u--form>
  17. </view>
  18. </template>
  19. <script>
  20. import testActivitiLeaveService from "@/api/test/activiti/testActivitiLeaveService"
  21. export default {
  22. data () {
  23. return {
  24. loading: false,
  25. inputForm: {
  26. id: '',
  27. leaveType: '',
  28. startTime: '',
  29. endTime: '',
  30. reason: ''
  31. },
  32. rules: {
  33. 'leaveType': [
  34. {
  35. required: true,
  36. message: '类型不能为空',
  37. trigger: ['blur', 'change']
  38. }],
  39. 'startTime': [
  40. {
  41. required: true,
  42. message: '请假开始时间不能为空',
  43. trigger: ['blur', 'change']
  44. }],
  45. 'endTime': [
  46. {
  47. required: true,
  48. message: '请假结束时间不能为空',
  49. trigger: ['blur', 'change']
  50. }],
  51. 'reason': [
  52. {
  53. required: true,
  54. message: '请假事由不能为',
  55. trigger: ['blur', 'change']
  56. }]
  57. }
  58. }
  59. },
  60. props: {
  61. businessId: {
  62. type: String,
  63. default: ''
  64. },
  65. formReadOnly: {
  66. type: Boolean,
  67. default: false
  68. }
  69. },
  70. watch: {
  71. 'businessId': {
  72. handler (newVal) {
  73. if (this.businessId) {
  74. this.init(this.businessId)
  75. } else {
  76. this.$nextTick(() => {
  77. // this.$refs.inputForm.reset()
  78. })
  79. }
  80. },
  81. immediate: true,
  82. deep: false
  83. }
  84. },
  85. methods: {
  86. init (id) {
  87. if (id) {
  88. testActivitiLeaveService.queryById(id).then((data) => {
  89. this.inputForm = this.recover(this.inputForm, data)
  90. })
  91. }
  92. },
  93. saveForm (callback) {
  94. //定义表单规则
  95. this.$refs.inputForm.validate().then(res => {
  96. uni.showLoading()
  97. testActivitiLeaveService.save(this.inputForm).then((data) => {
  98. callback(data.businessTable, data.businessId)
  99. }).catch((e)=>{
  100. })
  101. }).catch((e)=>{
  102. })
  103. }
  104. }
  105. }
  106. </script>
  107. <style>
  108. .cu-form-group .title {
  109. min-width: calc(4em + 40px);
  110. }
  111. </style>