oaNotifyForm.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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="type">
  5. <jp-picker v-model="inputForm.type" rangeKey="label" rangeValue="value" :range="$dictUtils.getDictList('oa_notify_type')">
  6. </jp-picker>
  7. </u-form-item>
  8. <u-form-item label="标题" borderBottom prop="title">
  9. <u--input
  10. placeholder="请输入标题"
  11. maxlength="200"
  12. border="none"
  13. v-model="inputForm.title"
  14. ></u--input>
  15. </u-form-item>
  16. <u-form-item label="内容" borderBottom prop="content">
  17. <u--textarea v-model="inputForm.content" placeholder="请输入内容" border="none"></u--textarea>
  18. </u-form-item>
  19. <u-form-item label="状态" borderBottom prop="status">
  20. <u-radio-group v-model="inputForm.status" placement="row">
  21. <u-radio
  22. v-for="item in $dictUtils.getDictList('oa_notify_status')"
  23. :key="item.id"
  24. :label="item.label"
  25. :customStyle="{marginRight: '16px'}"
  26. :name="item.value">
  27. </u-radio>
  28. </u-radio-group>
  29. </u-form-item>
  30. <u-form-item label="选择人员" borderBottom prop="notifyRecordIds">
  31. <user-select v-model="inputForm.notifyRecordIds"></user-select>
  32. </u-form-item>
  33. </u--form>
  34. <view class="padding-xl">
  35. <u-button type="primary" @click="formSubmit" >提交</u-button>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import userSelect from '@/components/user-select/user-select.vue'
  41. import jpPicker from '@/components/jp-picker/jp-picker.vue'
  42. import notifyService from "@/api/notify/notifyService";
  43. import userService from "@/api/sys/userService";
  44. export default {
  45. onShow() {
  46. userService.treeData().then((data)=>{
  47. this.data = data
  48. }).catch((e)=>{
  49. throw e
  50. })
  51. },
  52. async onLoad(notify) {
  53. if(notify&&notify.id){
  54. this.titile = "编辑通知";
  55. let data = await notifyService.query({isSelf:false, id:notify.id});
  56. this.inputForm = this.recover(this.inputForm, data)
  57. }
  58. },
  59. components:{
  60. userSelect,
  61. jpPicker
  62. },
  63. data () {
  64. return {
  65. titile: '新建通知',
  66. inputForm: {
  67. id: '',
  68. type: '',
  69. title: '',
  70. content: '',
  71. files: '',
  72. status: '',
  73. notifyRecordIds: ''
  74. },
  75. rules: {
  76. 'type': [
  77. {
  78. required: true,
  79. message: '类型不能为空',
  80. trigger: ['blur', 'change']
  81. }
  82. ],
  83. 'title': [
  84. {
  85. required: true,
  86. message: '标题不能为空',
  87. trigger: ['blur', 'change']
  88. }
  89. ],
  90. 'content': [
  91. {
  92. required: true,
  93. message: '内容不能为空',
  94. trigger: ['blur', 'change']
  95. }
  96. ],
  97. 'status': [
  98. {
  99. required: true,
  100. message: '状态不能为空',
  101. trigger: ['blur', 'change']
  102. }
  103. ],
  104. 'notifyRecordIds': [
  105. {
  106. required: true,
  107. message: '人员不能为空',
  108. trigger: ['blur', 'change']
  109. }
  110. ]
  111. }
  112. }
  113. },
  114. methods: {
  115. formSubmit: function(e) {
  116. //定义表单规则
  117. this.$refs.inputForm.validate().then(res => {
  118. uni.showLoading()
  119. notifyService.save(this.inputForm).then((data) => {
  120. uni.showToast({title:data, icon:"success"});
  121. uni.navigateTo({
  122. url: '/pages/apps/notification/notification?tabIndex=1'
  123. })
  124. }).catch((e)=>{
  125. console.log(e)
  126. })
  127. })
  128. }
  129. }
  130. }
  131. </script>
  132. <style>
  133. .cu-form-group .title {
  134. min-width: calc(4em + 30px);
  135. }
  136. </style>