hyInfo.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <div class="main-container">
  3. <el-form :model="searchForm" label-width="100px" ref="searchForm">
  4. <el-row>
  5. <el-col :span="8">
  6. <el-form-item label="水文站名称">
  7. <el-input v-model="searchForm.stationName" placeholder="请输入"></el-input>
  8. </el-form-item>
  9. </el-col>
  10. <el-col :span="8">
  11. <el-form-item label="水文站编号">
  12. <el-input v-model="searchForm.stationCode" placeholder="请输入"></el-input>
  13. </el-form-item>
  14. </el-col>
  15. </el-row>
  16. <el-row justify="space-between" class="mb20">
  17. <el-col :span="12" style="text-align: left">
  18. <el-button size="small" icon="el-icon-plus" class="primaryBtn" @click="toAdd">新增水文站</el-button>
  19. </el-col>
  20. <el-col :span="12" style="text-align: right">
  21. <el-button size="small" icon="el-icon-search" @click="handleSearch" class="primaryBtn">查询</el-button>
  22. <el-button size="small" icon="el-icon-refresh-right" @click="resetForm">重置</el-button>
  23. </el-col>
  24. </el-row>
  25. </el-form>
  26. <el-table :data="tableData" border style="width: 100%" height="680">
  27. <el-table-column prop="stationCode" label="水文站编号" align="center"> </el-table-column>
  28. <el-table-column prop="stationName" label="水文站名称" align="center"> </el-table-column>
  29. <el-table-column prop="stationLocation" label="水文站位置" align="center"> </el-table-column>
  30. <el-table-column prop="stationCoordinates" label="水文站经纬度" align="center"></el-table-column>
  31. <el-table-column label="操作" align="center">
  32. <template slot-scope="scope">
  33. <el-button size="small" type="text" @click="jcInfo(scope.row)"><img src="@/assets/image/common/p3.png" class="vIcon" /> 监测信息</el-button>
  34. <el-button size="small" type="text" @click="handleEdit(scope.row)"><i class="el-icon-edit"></i> 编辑</el-button>
  35. <el-button size="small" type="text" @click="handleDelete(scope.row)"><i class="el-icon-delete"></i> 删除</el-button>
  36. </template>
  37. </el-table-column>
  38. </el-table>
  39. <el-pagination
  40. class="page"
  41. popper-class="v-pageination"
  42. @size-change="handleSizeChange"
  43. @current-change="handleCurrentChange"
  44. :current-page="searchForm.pageNum"
  45. :page-sizes="[10, 20, 50, 100]"
  46. :page-size="searchForm.pageSize"
  47. background
  48. small
  49. layout="total, sizes, prev, pager, next, jumper"
  50. :total="total"
  51. >
  52. </el-pagination>
  53. <el-dialog :title="title" :visible.sync="addDialogVisible">
  54. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  55. <el-form-item label="水文站名称:" prop="stationName">
  56. <el-input v-model="form.stationName"></el-input>
  57. </el-form-item>
  58. <el-form-item label="水文站编号:" prop="stationCode">
  59. <el-input v-model="form.stationCode"> </el-input>
  60. </el-form-item>
  61. <el-form-item label="水文站位置:" prop="stationLocation">
  62. <el-input v-model="form.stationLocation"> </el-input>
  63. </el-form-item>
  64. <el-form-item label="经度:" prop="stationLatitude">
  65. <el-input v-model="form.stationLatitude" type="number"> </el-input>
  66. </el-form-item>
  67. <el-form-item label="纬度:" prop="stationLongitude">
  68. <el-input v-model="form.stationLongitude" type="number"> </el-input>
  69. </el-form-item>
  70. <el-form-item label="水文站详情:" prop="stationDetails">
  71. <el-input type="textarea" :rows="6" v-model="form.stationDetails"> </el-input>
  72. </el-form-item>
  73. </el-form>
  74. <div slot="footer" class="dialog-footer">
  75. <el-button type="primary" @click="confirmSubmit" size="small" class="primaryBtn">确 定</el-button>
  76. <el-button @click="addDialogVisible = false" size="small">取 消</el-button>
  77. </div>
  78. </el-dialog>
  79. </div>
  80. </template>
  81. <script>
  82. import { getHydrologicalList, toAddhydrological, toUpdatehydrological, toDelete } from '@/api/hydrologicalStationApi'
  83. export default {
  84. data() {
  85. var checkLongitude = (rule, value, callback) => {
  86. if (value === '') {
  87. return callback(new Error('请输入经度'))
  88. }
  89. if (value < -180 || value > 180) {
  90. return callback(new Error('经度必须在 -180 到 180 之间'))
  91. }
  92. callback()
  93. }
  94. var checkLatitude = (rule, value, callback) => {
  95. if (value === '') {
  96. return callback(new Error('请输入纬度'))
  97. }
  98. if (value < -90 || value > 90) {
  99. return callback(new Error('纬度必须在 -90 到 90 之间'))
  100. }
  101. callback()
  102. }
  103. return {
  104. searchForm: {
  105. stationName: '',
  106. stationCode: '',
  107. pageSize: 10,
  108. pageNum: 1
  109. },
  110. form: {
  111. stationName: '',
  112. stationCode: '',
  113. stationLocation: '',
  114. stationLatitude: '',
  115. stationLongitude: '',
  116. stationDetails: ''
  117. },
  118. tableData: [],
  119. total: 0,
  120. title: '新增文水站',
  121. addDialogVisible: false,
  122. titleType: 'add',
  123. rules: {
  124. stationName: [{ required: true, message: '请输入水文站名称', trigger: 'blur' }],
  125. stationCode: [{ required: true, message: '请输入水文站编码', trigger: 'blur' }],
  126. stationLocation: [{ required: true, message: '请输入水文站位置', trigger: 'blur' }],
  127. stationLatitude: [{ validator: checkLatitude, trigger: 'blur' }],
  128. stationLongitude: [{ validator: checkLongitude, trigger: 'blur' }]
  129. }
  130. }
  131. },
  132. mounted() {
  133. this.fetchData()
  134. },
  135. methods: {
  136. handleSearch() {
  137. this.fetchData()
  138. },
  139. resetForm() {
  140. this.searchForm = {
  141. stationName: '',
  142. stationCode: '',
  143. pageSize: 10,
  144. pageNum: 1
  145. }
  146. this.fetchData()
  147. },
  148. jcInfo(row) {
  149. this.$emit('closeHy', row.id)
  150. },
  151. handleEdit(row) {
  152. this.title = '编辑水文站'
  153. this.titleType = 'edit'
  154. this.form = JSON.parse(JSON.stringify(row))
  155. this.addDialogVisible = true
  156. },
  157. handleDelete(row) {
  158. toDelete({ id: row.id }).then((res) => {
  159. if (res.data) {
  160. this.$message({
  161. message: '删除成功',
  162. type: 'success'
  163. })
  164. this.fetchData()
  165. } else {
  166. this.$message({
  167. message: '删除失败',
  168. type: 'error'
  169. })
  170. }
  171. })
  172. },
  173. handleSizeChange(val) {
  174. this.searchForm.pageSize = val
  175. this.fetchData()
  176. },
  177. handleCurrentChange(val) {
  178. this.searchForm.pageNum = val
  179. this.fetchData()
  180. },
  181. fetchData() {
  182. getHydrologicalList(this.searchForm).then((res) => {
  183. this.tableData = res.data.records
  184. this.total = res.data.total
  185. })
  186. },
  187. toAdd() {
  188. this.title = '新增文水站'
  189. this.titleType = 'add'
  190. this.form = {
  191. stationName: '',
  192. stationCode: '',
  193. stationLatitude: '',
  194. stationLongitude: '',
  195. stationDetails: '',
  196. stationLocation: ''
  197. }
  198. this.addDialogVisible = true
  199. },
  200. confirmSubmit() {
  201. this.$refs.form.validate((valid) => {
  202. if (valid) {
  203. if (this.titleType == 'add') {
  204. toAddhydrological(this.form).then((res) => {
  205. if (res.data) {
  206. this.$message({
  207. message: '新增成功',
  208. type: 'success'
  209. })
  210. this.closeModal()
  211. this.fetchData()
  212. } else {
  213. this.$message({
  214. message: '新增失败',
  215. type: 'error'
  216. })
  217. }
  218. })
  219. } else {
  220. toUpdatehydrological(this.form).then((res) => {
  221. if (res.data) {
  222. this.$message({
  223. message: '修改成功',
  224. type: 'success'
  225. })
  226. this.closeModal()
  227. this.fetchData()
  228. } else {
  229. this.$message({
  230. message: '修改失败',
  231. type: 'error'
  232. })
  233. }
  234. })
  235. }
  236. }
  237. })
  238. },
  239. closeModal() {
  240. this.addDialogVisible = false
  241. this.form = {
  242. stationName: '',
  243. stationCode: '',
  244. stationLatitude: '',
  245. stationLongitude: '',
  246. stationDetails: '',
  247. stationLocation: ''
  248. }
  249. }
  250. }
  251. }
  252. </script>
  253. <style lang="scss" scoped>
  254. :deep(.el-form .el-select),
  255. :deep(.el-input__inner) {
  256. width: 100%;
  257. }
  258. .mb20 {
  259. margin-bottom: px-to-rem(20);
  260. }
  261. .page {
  262. margin-top: px-to-rem(20);
  263. text-align: right;
  264. }
  265. .primaryBtn {
  266. color: #fff !important;
  267. background-color: #ff6a6c !important;
  268. border-color: #ff6a6c !important;
  269. }
  270. .el-upload__tip {
  271. color: #ff6a6c;
  272. }
  273. .vIcon {
  274. width: px-to-rem(12);
  275. height: px-to-rem(12);
  276. }
  277. :deep(.el-pager li.active) {
  278. background-color: rgba(240, 105, 106, 1) !important;
  279. }
  280. </style>