oaNotifyForm.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. 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 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. data () {
  79. return {
  80. loading: false,
  81. expandOnCheckNode: false, // 是否展开选中的节点
  82. data: [],
  83. defaultProps: {
  84. children: 'children',
  85. label: 'label'
  86. },
  87. index: -1,
  88. titile: '新建通知',
  89. modalName: '',
  90. notifyRecordNames: '',
  91. imgList: [],
  92. inputForm: {
  93. id: '',
  94. type: '',
  95. title: '',
  96. content: '',
  97. files: '',
  98. status: '',
  99. notifyRecordIds: ''
  100. }
  101. }
  102. },
  103. methods: {
  104. formSubmit: function(e) {
  105. //定义表单规则
  106. var rule = [
  107. {name:"type", checkType : "notnull", checkRule:"", errorMsg:"类型不能为空"},
  108. {name:"title", checkType : "notnull", checkRule:"", errorMsg:"标题不能为空"},
  109. {name:"content", checkType : "notnull", checkRule:"", errorMsg:"内容不能为空"},
  110. {name:"status", checkType : "notnull", checkRule:"", errorMsg:"状态不能为空"},
  111. {name:"notifyRecordIds", checkType : "notnull", checkRule:"", errorMsg:"候选人不能为空"}
  112. ];
  113. //进行表单检查
  114. var formData = this.inputForm;
  115. var checkRes = graceChecker.check(formData, rule);
  116. if(checkRes){
  117. uni.showLoading()
  118. notifyService.save(this.inputForm).then(({data}) => {
  119. uni.showToast({title:data, icon:"success"});
  120. uni.navigateTo({
  121. url: '/pages/apps/notification/notification?tabIndex=1'
  122. })
  123. }).catch((e)=>{
  124. })
  125. }else{
  126. uni.showToast({ title: graceChecker.error, icon: "none" });
  127. }
  128. }
  129. }
  130. }
  131. </script>
  132. <style>
  133. .cu-form-group .title {
  134. min-width: calc(4em + 30px);
  135. }
  136. </style>