oaNotifyForm.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-blue" :isBack="true">
  4. <block slot="backText">返回</block>
  5. <block slot="content">{{titile}}</block>
  6. </cu-custom>
  7. <form @submit="formSubmit" class="cu-list menu">
  8. <view class="cu-form-group margin-top">
  9. <view class="title">
  10. <text class="red-color ">* </text> 类型
  11. </view>
  12. <jp-picker v-model="inputForm.type" rangeKey="label" rangeValue="value" :range="$dictUtils.getDictList('oa_notify_type')">
  13. <view class="picker">
  14. {{$dictUtils.getDictLabel('oa_notify_type', inputForm.type ,'请选择')}}
  15. </view>
  16. </jp-picker>
  17. </view>
  18. <view class="cu-form-group">
  19. <view class="title">
  20. <text class="red-color ">* </text> 标题
  21. </view>
  22. <input placeholder="请输入标题" maxlength="200" v-model="inputForm.title" name="title"></input>
  23. </view>
  24. <view class="cu-form-group">
  25. <view class="title">
  26. <text class="red-color ">* </text> 内容
  27. </view>
  28. <textarea maxlength="2000" v-model="inputForm.content" name="content" placeholder="请填写内容"></textarea>
  29. </view>
  30. <view class="cu-form-group">
  31. <view class="title">
  32. <text class="red-color ">* </text> 状态
  33. </view>
  34. <jp-radio-group v-model="inputForm.status">
  35. <radio class='blue radio status' v-for="item in $dictUtils.getDictList('oa_notify_status')" :value="item.value" :key="item.id" :class="inputForm.status==item.value?'checked':''" :checked="inputForm.status==item.value?true:false" >{{item.label}}</radio>
  36. </jp-radio-group>
  37. </view>
  38. <view class="cu-form-group">
  39. <view class="title">
  40. <text class="red-color ">* </text> 选择人员
  41. </view>
  42. <user-select v-model="inputForm.notifyRecordIds"></user-select>
  43. </view>
  44. <view class="padding-xl">
  45. <button form-type="submit" class="cu-btn block bg-blue margin-tb-sm lg" >提交</button>
  46. </view>
  47. </form>
  48. </view>
  49. </template>
  50. <script>
  51. import userSelect from '@/components/user-select/user-select.vue'
  52. import elRadioGroup from '@/components/jp-radio-group/jp-radio-group.vue'
  53. import jpPicker from '@/components/jp-picker/jp-picker.vue'
  54. var graceChecker = require("@/common/graceChecker.js");
  55. import NotifyService from "@/api/notify/NotifyService";
  56. import UserService from "@/api/sys/UserService";
  57. export default {
  58. onShow() {
  59. this.$auth.checkLogin()
  60. this.userService.treeData().then(({data})=>{
  61. this.data = data
  62. }).catch((e)=>{
  63. throw e
  64. })
  65. },
  66. async onLoad(notify) {
  67. if(notify&&notify.id){
  68. this.titile = "编辑通知";
  69. let {data} = await this.notifyService.query({isSelf:false, id:notify.id});
  70. this.inputForm = this.recover(this.inputForm, data)
  71. }
  72. },
  73. components:{
  74. userSelect,
  75. elRadioGroup,
  76. jpPicker
  77. },
  78. notifyService: null,
  79. userService: null,
  80. beforeCreate() {
  81. this.notifyService = new NotifyService()
  82. this.userService = new UserService()
  83. },
  84. data () {
  85. return {
  86. loading: false,
  87. expandOnCheckNode: false, // 是否展开选中的节点
  88. data: [],
  89. defaultProps: {
  90. children: 'children',
  91. label: 'label'
  92. },
  93. index: -1,
  94. titile: '新建通知',
  95. modalName: '',
  96. notifyRecordNames: '',
  97. imgList: [],
  98. inputForm: {
  99. id: '',
  100. type: '',
  101. title: '',
  102. content: '',
  103. files: '',
  104. status: '',
  105. notifyRecordIds: ''
  106. }
  107. }
  108. },
  109. methods: {
  110. formSubmit: function(e) {
  111. //定义表单规则
  112. var rule = [
  113. {name:"type", checkType : "notnull", checkRule:"", errorMsg:"类型不能为空"},
  114. {name:"title", checkType : "notnull", checkRule:"", errorMsg:"标题不能为空"},
  115. {name:"content", checkType : "notnull", checkRule:"", errorMsg:"内容不能为空"},
  116. {name:"status", checkType : "notnull", checkRule:"", errorMsg:"状态不能为空"},
  117. {name:"notifyRecordIds", checkType : "notnull", checkRule:"", errorMsg:"候选人不能为空"}
  118. ];
  119. //进行表单检查
  120. var formData = this.inputForm;
  121. var checkRes = graceChecker.check(formData, rule);
  122. if(checkRes){
  123. uni.showLoading()
  124. this.notifyService.save(this.inputForm).then(({data}) => {
  125. uni.showToast({title:data, icon:"success"});
  126. uni.navigateTo({
  127. url: '/pages/apps/notification/notification?tabIndex=1'
  128. })
  129. }).catch((e)=>{
  130. })
  131. }else{
  132. uni.showToast({ title: graceChecker.error, icon: "none" });
  133. }
  134. }
  135. }
  136. }
  137. </script>
  138. <style>
  139. .cu-form-group .title {
  140. min-width: calc(4em + 30px);
  141. }
  142. </style>