Edit.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <uni-drawer ref="drawer" mode="left" :mask-click="false" width="85%" :maskClick='true'>
  3. <scroll-view class="scroll-view" scroll-y="true">
  4. <uni-section :title="type==='add'?'突发事件上报':'编辑突发事件' " type="line"></uni-section>
  5. <view class="form-wrap" >
  6. <uni-forms ref="form" label-position="top" :rules="rules" :model="form" :label-width="300">
  7. <uni-forms-item label ="消息标题">
  8. <uni-easyinput v-model="form.reportingSubject" placeholder="请输入消息标题" type="textarea" :maxlength="150" autoHeight />
  9. <view class="word-limit">{{form.reportingSubject.length||0}}/150</view>
  10. </uni-forms-item>
  11. <uni-forms-item label ="上报单位" >
  12. <uni-easyinput v-model="form.reportingGroupName" placeholder="请输入上报单位" />
  13. </uni-forms-item>
  14. <uni-forms-item label="请输入消息内容">
  15. <uni-easyinput type="textarea" :maxlength="300"
  16. v-model="form.reportingContent" autoHeight
  17. placeholder="请输入消息内容"></uni-easyinput>
  18. <view class="word-limit">{{form.reportingContent.length||0}}/300</view>
  19. </uni-forms-item>
  20. </uni-forms>
  21. <view class="handle-container">
  22. <button class="save" type="primary" @click="onSubmit">保存</button>
  23. <button class="cancel" type="default" @click="close">取消</button>
  24. </view>
  25. </view>
  26. </scroll-view>
  27. </uni-drawer>
  28. </template>
  29. <script>
  30. import reportingApi from '@/api/reporting.js'
  31. export default{
  32. name:"EditReporting",
  33. data(){
  34. return{
  35. type:undefined,
  36. form:{
  37. reportingId: 0,
  38. reportingTypeId: 0,
  39. reportingTypeTitle: '',
  40. reportingSubject: '',
  41. reportingContent: '',
  42. reportingGroupName: '',
  43. remark: ''
  44. }
  45. }
  46. },
  47. methods:{
  48. resetForm(){
  49. this.form={
  50. reportingId: 0,
  51. reportingTypeId: 0,
  52. reportingTypeTitle: '',
  53. reportingSubject: '',
  54. reportingContent: '',
  55. reportingGroupName: '',
  56. remark: ''
  57. }
  58. },
  59. onSubmit(){
  60. this.$refs.form.validate().then(res=>{
  61. reportingApi.update(this.form).then(()=>{
  62. uni.showToast({
  63. icon:"none",
  64. title:"成功!!"
  65. })
  66. this.$emit('success')
  67. this.close();
  68. })
  69. }).catch(err =>{
  70. uni.showToast({
  71. icon:"none",
  72. title:"请检查填写信息!"
  73. })
  74. })
  75. },
  76. show({type,item}){
  77. this.resetForm()
  78. this.type=type
  79. this.$refs.drawer.open()
  80. reportingApi.getById(item.reportingId).then((res)=>{
  81. this.form={...res.data}
  82. })
  83. },
  84. close(){
  85. this.$refs.drawer.close()
  86. }
  87. }
  88. }
  89. </script>
  90. <style lang="scss" scoped>
  91. .scroll-view {
  92. height: 100%;
  93. padding: 20rpx;
  94. box-sizing: border-box;
  95. .form-wrap{
  96. padding:40rpx 20rpx;
  97. .handle-container{
  98. display: flex;
  99. justify-content: center;
  100. align-items: center;
  101. button{
  102. width: 160rpx;
  103. padding: 20rpx 16rpx;
  104. line-height: 1;
  105. font-size: 28rpx;
  106. &.save{
  107. background-color: #007aff;
  108. }
  109. }
  110. }
  111. .word-limit{
  112. text-align: right;
  113. padding: 10rpx 0;
  114. color: #999;
  115. font-size: 26rpx;
  116. }
  117. .attachbox{
  118. display: flex;
  119. flex-wrap: wrap;
  120. .attach{
  121. padding: 16rpx 18rpx;
  122. image,.handle{
  123. display: block;
  124. width: 100rpx;
  125. height: 100rpx;
  126. box-shadow: rgba(0,0,0,0.6);
  127. border: 1rpx solid #ccc;
  128. border-radius: 10px;
  129. overflow: hidden;
  130. box-sizing: border-box;
  131. }
  132. .handle{
  133. display: flex;
  134. justify-content: center;
  135. align-items: center;
  136. }
  137. }
  138. }
  139. }
  140. }
  141. </style>