CreateReservoir.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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==='edit'?'编辑':'新增')+'水库淤堤坝'" type="line"></uni-section>
  5. <view class="form-wrap" >
  6. <uni-forms ref="form" label-position="top" :rules="rules" :model="form" label-width='300px' >
  7. <uni-forms-item label="水库名称" name="rdName" required>
  8. <uni-easyinput v-model="form.rdName" placeholder="请输入水库名称" :clearable="false" />
  9. </uni-forms-item>
  10. <uni-forms-item label="巡查责任人" name="respName" required>
  11. <uni-easyinput v-model="form.respName" placeholder="请输入巡查责任人" :clearable="false"></uni-easyinput>
  12. </uni-forms-item>
  13. <uni-forms-item label="地址" >
  14. <uni-easyinput v-model="form.rdAddress" placeholder="请输入地址" :clearable="false" />
  15. </uni-forms-item>
  16. <uni-forms-item label="联系电话" >
  17. <uni-easyinput v-model="form.respPhone" placeholder="请输入联系电话" :clearable="false"></uni-easyinput>
  18. </uni-forms-item>
  19. <uni-card padding="0" margin="5px 0">
  20. <uni-forms-item label="巡检责任人" >
  21. <uni-easyinput v-model="form.inspectorName" placeholder="请输入巡检责任人"></uni-easyinput>
  22. </uni-forms-item>
  23. <uni-forms-item label="巡检责任人电话" >
  24. <uni-easyinput v-model="form.inspectorPhone" type="number" placeholder="请输入巡检责任人电话"></uni-easyinput>
  25. </uni-forms-item>
  26. </uni-card>
  27. <uni-card padding="0" margin="5px 0">
  28. <uni-forms-item label="行政责任人" >
  29. <uni-easyinput v-model="form.administratorName" placeholder="请输入行政责任人"></uni-easyinput>
  30. </uni-forms-item>
  31. <uni-forms-item label="行政责任人电话" >
  32. <uni-easyinput v-model="form.administratorPhone" type="number" placeholder="请输入行政责任人电话"></uni-easyinput>
  33. </uni-forms-item>
  34. </uni-card>
  35. <uni-card padding="0" margin="5px 0">
  36. <uni-forms-item label="技术责任人" >
  37. <uni-easyinput v-model="form.technicianName" placeholder="请输入技术责任人"></uni-easyinput>
  38. </uni-forms-item>
  39. <uni-forms-item label="技术责任人电话" >
  40. <uni-easyinput v-model="form.technicianPhone" type="number" placeholder="请输入技术责任人电话"></uni-easyinput>
  41. </uni-forms-item>
  42. </uni-card>
  43. <uni-forms-item label="备注说明">
  44. <uni-easyinput type="textarea" :maxlength="500" v-model="form.remark" placeholder="请输入备注说明" autoHeight ></uni-easyinput>
  45. <view class="word-limit">{{form.remark.length||0}}/500</view>
  46. </uni-forms-item>
  47. </uni-forms>
  48. <view class="handle-container">
  49. <button class="save" type="primary" @click="onSubmit">保存</button>
  50. <button class="cancel" type="default" @click="close">取消</button>
  51. </view>
  52. </view>
  53. </scroll-view>
  54. </uni-drawer>
  55. </template>
  56. <script>
  57. import disasterApi from '@/api/disaster.js'
  58. export default{
  59. name:"CreateDisaster",
  60. computed:{
  61. accountInfo(){
  62. let accountInfo=uni.getStorageSync('accountInfo')
  63. if(!accountInfo) return {}
  64. return accountInfo
  65. },
  66. disasterLevels(){
  67. let disasterLevels=this.levels
  68. //uni.getStorageSync('disasterLevels')
  69. if(!disasterLevels)return []
  70. return disasterLevels.map(item=>{
  71. return{
  72. value:item.disasterLevelId,
  73. text:item.disasterLevelTitle
  74. }
  75. })
  76. },
  77. disasterCats(){
  78. let disasterCats=this.cats
  79. if(!disasterCats)return []
  80. return disasterCats.map(item=>{
  81. return{
  82. value:item.disasterCatId,
  83. text:item.disasterCatTitle
  84. }
  85. })
  86. }
  87. },
  88. props:{
  89. cats:{
  90. type:Array,
  91. default:()=>[]
  92. },
  93. levels:{
  94. type:Array,
  95. default:()=>[]
  96. }
  97. },
  98. data(){
  99. return{
  100. type:undefined,
  101. rules:{
  102. rdName:{
  103. rules:[
  104. {
  105. required: true,
  106. errorMessage:"请输入水库名称"
  107. }
  108. ],
  109. validateTrigger:'submit'
  110. },
  111. respName:{
  112. rules:[
  113. {
  114. required: true,
  115. errorMessage:"请输入巡查责任人"
  116. }
  117. ],
  118. validateTrigger:'submit'
  119. }
  120. },
  121. form:{
  122. ocId: 0,
  123. rdId: 0,
  124. groupId: 0,
  125. rdName: '',
  126. rdAddress: '',
  127. respName: '',
  128. respPhone: '',
  129. inspectorName: '',
  130. inspectorPhone: '',
  131. administratorName: '',
  132. administratorPhone: '',
  133. technicianName: '',
  134. technicianPhone: '',
  135. remark: ''
  136. }
  137. }
  138. },
  139. methods:{
  140. resetForm(){
  141. this.form={
  142. ocId: 0,
  143. rdId: 0,
  144. groupId: 0,
  145. rdName: '',
  146. rdAddress: '',
  147. respName: '',
  148. respPhone: '',
  149. inspectorName: '',
  150. inspectorPhone: '',
  151. administratorName: '',
  152. administratorPhone: '',
  153. technicianName: '',
  154. technicianPhone: '',
  155. remark: ''
  156. }
  157. },
  158. onSubmit(){
  159. this.$refs.form.validate().then(res=>{
  160. let submitFx=this.type==='create'?disasterApi.createReservoirDam:disasterApi.updateReservoirDam
  161. this.form.ocId= this.accountInfo.ocId,
  162. this.form.groupId= this.accountInfo.groupId
  163. submitFx(this.form).then(()=>{
  164. uni.showToast({
  165. icon:"none",
  166. title:"成功!!"
  167. })
  168. this.$emit('success')
  169. this.close();
  170. })
  171. }).catch(err =>{
  172. uni.showToast({
  173. icon:"none",
  174. title:"请检查填写信息!"
  175. })
  176. })
  177. },
  178. show(type,item){
  179. this.resetForm()
  180. this.form={...this.form,...item}
  181. this.type=type
  182. this.$refs.drawer.open()
  183. },
  184. close(){
  185. this.$refs.drawer.close()
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. .scroll-view {
  192. height: 100%;
  193. padding: 20rpx;
  194. box-sizing: border-box;
  195. .form-wrap{
  196. padding:40rpx 20rpx;
  197. .handle-container{
  198. display: flex;
  199. justify-content: center;
  200. align-items: center;
  201. button{
  202. width: 160rpx;
  203. padding: 20rpx 16rpx;
  204. line-height: 1;
  205. font-size: 28rpx;
  206. &.save{
  207. background-color: #007aff;
  208. }
  209. }
  210. }
  211. .word-limit{
  212. text-align: right;
  213. padding: 10rpx 0;
  214. color: #999;
  215. font-size: 26rpx;
  216. }
  217. }
  218. }
  219. </style>