声脉桥梁云监控平台

index.vue 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container" style="margin-bottom:20px">
  4. <el-input style="width: 200px;" class="filter-item" placeholder="桥梁编号" v-model="listQuery.code">
  5. </el-input>
  6. <el-input style="width: 200px;" class="filter-item" placeholder="桥梁简称" v-model="listQuery.name">
  7. </el-input>
  8. <el-button v-waves class="filter-item" style="margin-left: 10px;" @click="handleFilter" type="primary" icon="el-icon-search">查找</el-button>
  9. <el-button v-waves class="filter-item" style="margin-left: 10px;" @click="handleCreate" type="primary" icon="el-icon-edit">添加桥梁</el-button>
  10. </div>
  11. <el-table :key='tableKey' :data="list" v-loading="listLoading" border fit highlight-current-row
  12. style="width: 100%;min-height:550px;">
  13. <el-table-column width="150px" align="center" label="桥梁编号">
  14. <template slot-scope="scope">
  15. <span>{{scope.row.code}}</span>
  16. </template>
  17. </el-table-column>
  18. <el-table-column width="150px" align="center" label="桥梁简称">
  19. <template slot-scope="scope">
  20. <span>{{scope.row.shortName}}</span>
  21. </template>
  22. </el-table-column>
  23. <el-table-column min-width="150px" align="center" label="桥梁位置">
  24. <template slot-scope="scope">
  25. <span>{{citys[scope.row.addrCode]}}</span>
  26. </template>
  27. </el-table-column>
  28. <el-table-column min-width="150px" align="center" label="维护机构">
  29. <template slot-scope="scope">
  30. <span>{{scope.row.org}}</span>
  31. </template>
  32. </el-table-column>
  33. <el-table-column min-width="200px" align="center" label="备注信息">
  34. <template slot-scope="scope">
  35. <span>{{scope.row.remark}}</span>
  36. </template>
  37. </el-table-column>
  38. <el-table-column align="center" label="操作" width="230" class-name="small-padding fixed-width">
  39. <template slot-scope="scope">
  40. <el-button v-waves type="primary" size="mini" @click="handleUpdate(scope.row)">编辑</el-button>
  41. <el-button v-waves size="mini" type="danger" @click="handleModifyStatus(scope.row,'deleted')">删除
  42. </el-button>
  43. </template>
  44. </el-table-column>
  45. </el-table>
  46. <el-dialog title="桥梁信息" ref="ruleForm" :visible.sync="dialogTableVisible" width="860px" @close='closed'>
  47. <el-form :model="ruleForm2" :rules="rules2" ref="ruleForm2" class="form-main" label-position='top' status-icon>
  48. <el-row :gutter="10">
  49. <el-col :xs="16" :sm="16" :lg="16">
  50. <el-row>
  51. <el-col :span="12">
  52. <el-form-item label="桥梁编号" prop="code">
  53. <el-input placeholder="请输入桥梁编号" v-model="ruleForm2.code" maxlength=20></el-input>
  54. </el-form-item>
  55. </el-col>
  56. <el-col :span="12">
  57. <el-form-item label="桥梁简称" prop="shortName">
  58. <el-input placeholder="请输入桥梁简称" v-model="ruleForm2.shortName" maxlength=20></el-input>
  59. </el-form-item>
  60. </el-col>
  61. <el-col :span="24">
  62. <el-form-item label="桥梁全称" prop="name">
  63. <el-input placeholder="请输入桥梁全称" v-model="ruleForm2.name" maxlength=200></el-input>
  64. </el-form-item>
  65. </el-col>
  66. <el-col :span="24">
  67. <el-form-item label="桥梁位置信息" prop="addrCode">
  68. <!-- <city @paren="toshow" :addrCode='ruleForm2.addrCode'></city> -->
  69. <CityPicker @paren="toshow" :addrCode='ruleForm2.addrCode'></CityPicker>
  70. </el-form-item>
  71. </el-col>
  72. <el-col :span="12">
  73. <el-form-item label="地理位置信息" prop="location">
  74. <el-input placeholder="请输入地理位置信息" v-model="ruleForm2.location" maxlength=200></el-input>
  75. </el-form-item>
  76. </el-col>
  77. <el-col :span="12">
  78. <el-form-item label="桥梁开通日期" prop="serviceDay">
  79. <el-date-picker
  80. value-format='yyyyMMdd'
  81. v-model="ruleForm2.serviceDay"
  82. type="date"
  83. placeholder="选择日期">
  84. </el-date-picker>
  85. </el-form-item>
  86. </el-col>
  87. <el-col :span="24">
  88. <el-form-item label="维护机构" prop="org">
  89. <el-input placeholder="请输入维护机构" v-model="ruleForm2.org" maxlength=200></el-input>
  90. </el-form-item>
  91. </el-col>
  92. <el-col :span="12">
  93. <el-form-item label="联系电话" prop="phone">
  94. <el-input placeholder="请输入联系电话" v-model="ruleForm2.phone" maxlength=20></el-input>
  95. </el-form-item>
  96. </el-col>
  97. <el-col :span="12">
  98. <el-form-item label="联系电邮" prop="email">
  99. <el-input placeholder="请输入联系电邮" v-model="ruleForm2.email" maxlength=100></el-input>
  100. </el-form-item>
  101. </el-col>
  102. </el-row>
  103. </el-col>
  104. <el-col :xs="8" :sm="8" :lg="8">
  105. <el-upload
  106. class="avatar-uploader"
  107. action="/ajax/bridge/upload"
  108. accept='image'
  109. :show-file-list="false"
  110. :on-success="handleAvatarSuccess"
  111. :before-upload="beforeAvatarUpload">
  112. <img v-if="imageUrl" :src="imageUrl" class="avatar">
  113. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  114. </el-upload>
  115. <p style="width:100%;text-align:center;font-size:14px;color:#999;">上传桥梁图片<br>
  116. JPEG/JPG/PNG格式大小5M以内</p>
  117. </el-col>
  118. </el-row>
  119. <el-row>
  120. <el-col :span="24">
  121. <el-form-item label="详细描述" class="el-to-block" prop="descp">
  122. <el-input type="textarea" maxlength=500 rows=6 v-model="ruleForm2.descp"></el-input>
  123. </el-form-item>
  124. </el-col>
  125. <el-col :span="24">
  126. <el-form-item label="备注" class="el-to-block" prop="remark">
  127. <el-input type="textarea" maxlength=500 rows=3 v-model="ruleForm2.remark"></el-input>
  128. </el-form-item>
  129. </el-col>
  130. <el-col :span="24" class="el-btn-col">
  131. <div class="el-btn-col-box">
  132. <el-button v-waves type="primary" @click="submitForm('ruleForm2')">确认</el-button>
  133. <el-button v-waves type="primary" @click="resetForm('ruleForm2')">返回</el-button>
  134. </div>
  135. </el-col>
  136. </el-row>
  137. </el-form>
  138. </el-dialog>
  139. <div class="pagination-container" style="text-align:center;">
  140. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="listQuery.pageNo" :page-size="listQuery.pageSize" layout="prev, pager, next, jumper" :total="total">
  141. </el-pagination>
  142. </div>
  143. </div>
  144. </template>
  145. <script>
  146. import { addDevice, updateDevice, deleteDevice, pageQueryDevice, checkDeviceCode, checkBridgeShortName, checkBridgeName } from '@/api/bridge'
  147. import waves from '@/directive/waves'
  148. import CityPicker from '@/components/CityPicker'
  149. import queryDict from '@/utils/queryDict'
  150. export default {
  151. name: 'complexTable',
  152. directives: {
  153. waves
  154. },
  155. data() {
  156. var code = (rule, value, callback) => {
  157. if (value === '') {
  158. callback(new Error('请输入桥梁编号'))
  159. } else {
  160. if (this.edit) {
  161. checkDeviceCode({ code: value, id: this.edit, active: 1 }).then(response => {
  162. if (response.data) {
  163. callback(new Error('桥梁编号已存在,请重新输入'))
  164. } else {
  165. callback()
  166. }
  167. })
  168. } else {
  169. checkDeviceCode({ code: value, active: 1 }).then(response => {
  170. if (response.data) {
  171. callback(new Error('桥梁编号已存在,请重新输入'))
  172. } else {
  173. callback()
  174. }
  175. })
  176. }
  177. }
  178. }
  179. var shortName = (rule, value, callback) => {
  180. if (value === '') {
  181. callback(new Error('请输入桥梁简称'))
  182. } else {
  183. if (this.edit) {
  184. checkBridgeShortName({ shortName: value, id: this.edit, active: 1 }).then(response => {
  185. if (response.data) {
  186. callback(new Error('桥梁简称已存在,请重新输入'))
  187. } else {
  188. callback()
  189. }
  190. })
  191. } else {
  192. checkBridgeShortName({ shortName: value, active: 1 }).then(response => {
  193. if (response.data) {
  194. callback(new Error('桥梁简称已存在,请重新输入'))
  195. } else {
  196. callback()
  197. }
  198. })
  199. }
  200. }
  201. }
  202. var name = (rule, value, callback) => {
  203. if (value === '') {
  204. callback(new Error('请输入桥梁全称'))
  205. } else {
  206. if (this.edit) {
  207. checkBridgeName({ name: value, id: this.edit, active: 1 }).then(response => {
  208. if (response.data) {
  209. callback(new Error('桥梁全称已存在,请重新输入'))
  210. } else {
  211. callback()
  212. }
  213. })
  214. } else {
  215. checkBridgeName({ name: value, active: 1 }).then(response => {
  216. if (response.data) {
  217. callback(new Error('桥梁全称已存在,请重新输入'))
  218. } else {
  219. callback()
  220. }
  221. })
  222. }
  223. }
  224. }
  225. return {
  226. citys: {},
  227. edit: '',
  228. imageUrl: '',
  229. ruleForm2: {
  230. code: '',
  231. shortName: '',
  232. name: '',
  233. addrCode: '',
  234. serviceDay: '',
  235. location: '',
  236. descp: '',
  237. remark: '',
  238. img: '',
  239. org: '',
  240. phone: '',
  241. email: ''
  242. },
  243. rules2: {
  244. code: [
  245. { required: true, validator: code, trigger: 'blur' }
  246. ],
  247. shortName: [
  248. { required: true, validator: shortName, trigger: 'blur' }
  249. ],
  250. name: [
  251. { required: true, validator: name, trigger: 'blur' }
  252. ],
  253. location: [
  254. { required: true, message: '请输入地理位置信息', trigger: 'blur' }
  255. ],
  256. org: [
  257. { required: true, message: '请输入维护机构名称', trigger: 'blur' }
  258. ],
  259. phone: [
  260. { required: true, message: '请输入联系电话', trigger: 'blur' }
  261. ],
  262. addrCode: [
  263. { required: true, message: '请选择桥梁位置信息', trigger: 'blur' }
  264. ]
  265. },
  266. timeout: null,
  267. dialogTableVisible: false,
  268. tableKey: 0,
  269. list: null,
  270. total: null,
  271. listLoading: true,
  272. listQuery: {
  273. name: '',
  274. code: '',
  275. active: 1,
  276. pageSize: 10,
  277. pageNo: 1
  278. }
  279. }
  280. },
  281. filters: {
  282. typeFilter(type) {
  283. }
  284. },
  285. created() {
  286. this.getDictoryData()
  287. },
  288. components: {
  289. CityPicker
  290. },
  291. methods: {
  292. getDictoryData() {
  293. const that = this
  294. queryDict.applyDict('XZQH', function(dictData) {
  295. dictData.map(item => {
  296. that.citys[item.code] = item.fullCaption
  297. })
  298. that.getList()
  299. }) // 城市级联
  300. },
  301. submitForm(formName) {
  302. const that = this
  303. this.$refs[formName].validate((valid) => {
  304. if (valid) {
  305. if (this.ruleForm2.img === '') {
  306. this.ruleForm2.img = '/default-bridge.jpg'
  307. }
  308. if (!this.edit) {
  309. addDevice(this.ruleForm2).then(response => {
  310. if (response.success) {
  311. this.getList()
  312. setTimeout(function() {
  313. that.pop('已成功添加桥梁')
  314. }, 1000)
  315. this.resetForm('ruleForm2')
  316. this.ruleForm2.img = ''
  317. this.dialogTableVisible = false
  318. }
  319. }).catch(error => {
  320. console.log(error)
  321. })
  322. } else {
  323. const par = this.ruleForm2
  324. par.id = this.edit
  325. updateDevice(par).then(response => {
  326. if (response.success) {
  327. setTimeout(function() {
  328. that.pop('已成功更新桥梁')
  329. }, 1000)
  330. this.resetForm('ruleForm2')
  331. this.getList()
  332. this.dialogTableVisible = false
  333. this.edit = ''
  334. this.ruleForm2 = {
  335. code: '',
  336. shortName: '',
  337. name: '',
  338. addrCode: '',
  339. serviceDay: '',
  340. location: '',
  341. descp: '',
  342. remark: '',
  343. img: '',
  344. org: '',
  345. phone: '',
  346. email: ''
  347. }
  348. }
  349. })
  350. }
  351. }
  352. })
  353. },
  354. resetForm(formName) {
  355. this.dialogTableVisible = false
  356. this.$refs[formName].resetFields()
  357. this.imageUrl = ''
  358. this.edit = ''
  359. },
  360. closed() {
  361. this.$refs['ruleForm2'].resetFields()
  362. this.edit = ''
  363. this.imageUrl = ''
  364. },
  365. getList() {
  366. this.listLoading = true
  367. pageQueryDevice(this.listQuery).then(response => {
  368. if (response.success) {
  369. this.list = response.data.data
  370. this.total = response.data.total
  371. setTimeout(() => {
  372. this.listLoading = false
  373. }, 1.5 * 1000)
  374. }
  375. })
  376. },
  377. handleFilter() {
  378. this.listQuery.pageNo = 1
  379. this.getList()
  380. },
  381. handleSizeChange(val) {
  382. this.listQuery.pageSize = val
  383. this.getList()
  384. },
  385. handleCurrentChange(val) {
  386. this.listQuery.pageNo = val
  387. this.getList()
  388. },
  389. handleModifyStatus(row, status) {
  390. this.$confirm('确定要删除:桥梁' + row.code + '吗?', '提示', {
  391. confirmButtonText: '确定',
  392. cancelButtonText: '取消',
  393. type: 'warning',
  394. center: true
  395. }).then(() => {
  396. deleteDevice({ id: row.id }).then(response => {
  397. if (response.success) {
  398. this.getList()
  399. this.pop('已成功删除该桥梁')
  400. }
  401. })
  402. }).catch(() => {
  403. })
  404. },
  405. pop($par) {
  406. this.$confirm($par, '提示', {
  407. confirmButtonText: '确定',
  408. cancelButtonText: '取消',
  409. type: 'success',
  410. showCancelButton: false,
  411. center: true
  412. }).then(() => {
  413. }).catch(() => {
  414. })
  415. },
  416. resetTemp(row) {
  417. this.ruleForm2 = {
  418. code: row.code,
  419. shortName: row.shortName,
  420. name: row.name,
  421. addrCode: row.addrCode,
  422. serviceDay: row.serviceDay,
  423. location: row.location,
  424. descp: row.descp,
  425. remark: row.remark,
  426. img: row.img,
  427. org: row.org,
  428. phone: row.phone,
  429. email: row.email
  430. }
  431. this.edit = row.id
  432. },
  433. handleCreate() {
  434. this.dialogTableVisible = true
  435. this.ruleForm2.img = ''
  436. },
  437. handleUpdate(row) {
  438. const that = this
  439. setTimeout(function() {
  440. that.resetTemp(row)
  441. that.imageUrl = '/data/bridge' + row.img
  442. }, 500)
  443. this.dialogTableVisible = true
  444. },
  445. handleSelect(item) {
  446. this.ruleForm2.deviceId = item.id
  447. },
  448. handleAvatarSuccess(res, file) {
  449. this.imageUrl = URL.createObjectURL(file.raw)
  450. this.ruleForm2.img = res.data[0].uri
  451. },
  452. beforeAvatarUpload(file) {
  453. const isJPG = file.type === 'image/jpeg'
  454. const isPNG = file.type === 'image/png'
  455. const isLt2M = file.size / 1024 / 1024 < 5
  456. if (!isJPG && !isPNG) {
  457. this.$message.error('图片过大或格式不对请重新上传')
  458. }
  459. if (!isLt2M) {
  460. this.$message.error('图片过大或格式不对请重新上传')
  461. }
  462. return (!isJPG || !isPNG) && isLt2M
  463. },
  464. toshow(value) {
  465. this.ruleForm2.addrCode = value
  466. }
  467. }
  468. }
  469. </script>
  470. <style rel="stylesheet/scss" lang="scss" scoped>
  471. .el-autocomplete{
  472. display: block
  473. }
  474. .el-btn-col{
  475. margin-top: 45px
  476. }
  477. .avatar-uploader{
  478. border: 1px dashed #409EFF;
  479. border-radius: 6px;
  480. cursor: pointer;
  481. position: relative;
  482. overflow: hidden;
  483. }
  484. .avatar-uploader {
  485. font-size: 28px;
  486. color: #8c939d;
  487. width: 260px;
  488. height: 260px;
  489. line-height: 260px;
  490. text-align: center;
  491. }
  492. .avatar {
  493. width: 260px;
  494. height: 260px;
  495. display: block;
  496. }
  497. .el-autocomplete{
  498. display: block
  499. }
  500. .el-btn-col{
  501. margin-top: 45px
  502. }
  503. .el-form-item{
  504. margin: 0px 10px
  505. }
  506. .el-select,.el-date-editor--date{
  507. width: 100%
  508. }
  509. .el-col{
  510. margin-bottom: 15px
  511. }
  512. .el-form--label-top .el-form-item__label{
  513. line-height: 20px
  514. }
  515. </style>