add_fireEvent.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="uni-container uni-container-bg">
  3. <view class="event">
  4. <view class="event-title">事件时间</view>
  5. <uni-datetime-picker class="time-item-check" type="date" :clear-icon="false" v-model="eventTime"
  6. @maskClick="startMaskClick" placeholder="请选择事件时间" />
  7. <view class="content">
  8. <view class="event-title">事件内容</view>
  9. <u--textarea v-model="eventContent" placeholder="请输入内容" :maxlength="1000" count height="150">
  10. </u--textarea>
  11. </view>
  12. </view>
  13. <view class="bottons">
  14. <view class="buttons-item">
  15. <u-button shape="circle" type="primary" text="取消" :custom-style="{color:'#4CB2B6',backgroundColor: '#fff',border:'1px solid #fff',marginRight:'10px'}" @click="cancel">
  16. </u-button>
  17. <u-button shape="circle" type="primary" color="#4CB2B6" text="保存" @click="submit">
  18. </u-button>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import riliicon from '@/static/images/riliicon.png'
  25. import {
  26. createStationEvent,
  27. getOneMicrostation,//编辑获取
  28. updateOrgReport
  29. } from '@/api/fire_station/index';
  30. export default {
  31. data() {
  32. return {
  33. eventContent: '',
  34. eventTime: '',
  35. riliicon: riliicon,
  36. isEditId:false
  37. }
  38. },
  39. onLoad: function(option) {
  40. if(option.id){
  41. this.isEditId=option.id
  42. getOneMicrostation({
  43. id:option.id
  44. }).then(reponse => {
  45. this.eventTime=reponse.data.eventTime
  46. this.eventContent=reponse.data.eventContent
  47. console.log(reponse,'opt');
  48. })
  49. }
  50. },
  51. methods: {
  52. submit() {
  53. const that=this
  54. if(!this.eventContent){return this.$modal.msgError('请填写事件内容')}
  55. if(!this.eventTime){return this.$modal.msgError('请选择事件时间')}
  56. if(!this.isEditId){
  57. createStationEvent({
  58. eventContent: this.eventContent,
  59. eventTime:this.eventTime+''
  60. }).then(reponse => {
  61. that.$modal.msg('保存成功')
  62. setTimeout(() => {
  63. uni.navigateBack()
  64. }, 400)
  65. }).catch(err=>{
  66. })
  67. }else{
  68. updateOrgReport({
  69. eventContent: this.eventContent,
  70. eventTime:this.eventTime+'',
  71. id:this.isEditId
  72. }).then(reponse => {
  73. that.$modal.msg('编辑成功')
  74. setTimeout(() => {
  75. uni.navigateBack()
  76. }, 400)
  77. }).catch(err=>{
  78. })
  79. }
  80. },
  81. cancel() {
  82. uni.navigateBack()
  83. }
  84. }
  85. }
  86. </script>
  87. <style lang="scss" scoped>
  88. body {
  89. background-color: #f5f7f9;
  90. }
  91. page {
  92. background-color: #f5f7f9 !important;
  93. }
  94. .uni-container {
  95. height: 100%
  96. }
  97. .event {
  98. margin-top: 40rpx;
  99. background-color: #F5F7F9;
  100. .content {
  101. margin-top: 40rpx
  102. }
  103. .event-title {
  104. color: #274647;
  105. font-size: 28rpx;
  106. margin-bottom: 28rpx
  107. }
  108. }
  109. /deep/ .uniui-calendar:before {
  110. display: inline-block;
  111. content: url('~@/static/images/riliicon.png');
  112. width: 40rpx;
  113. height: 40rpx;
  114. position: absolute;
  115. left: 14rpx;
  116. top: 16rpx
  117. }
  118. /deep/ .uni-input-placeholder{
  119. left: 44rpx !important;
  120. }
  121. /deep/.uni-input-input{
  122. margin-left: 40rpx;
  123. }
  124. /deep/ .uni-date-x[data-v-6e13d7e2],/deep/ .uni-date-x {
  125. height: 72rpx
  126. }
  127. .bottons {
  128. .buttons-item {
  129. display: flex;
  130. justify-content: space-between;
  131. width: 90%;
  132. margin-left: 5%
  133. }
  134. .u-button {
  135. width: 45%
  136. }
  137. position: fixed;
  138. left: 0;
  139. bottom: 100rpx;
  140. right: 0;
  141. }
  142. </style>