siteAdd.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. <template>
  2. <view class="appWrapper">
  3. <!-- 站点新增start -->
  4. <form action="" @submit="formSubmit" v-if="!id">
  5. <view class="form-item margin-top">
  6. <view class="title">
  7. <text class="necessary">*</text>
  8. 站点名称:
  9. </view>
  10. <input name="userName" v-model="siteName"></input>
  11. </view>
  12. <view class="form-item">
  13. <view class="title"><text class="necessary">*</text>地址:</view>
  14. <input name="input" v-model="address"></input>
  15. </view>
  16. <view class="form-item">
  17. <view class="title"><text class="necessary">*</text>经度:</view>
  18. <input name="input" v-model="longitude"></input>
  19. </view>
  20. <view class="form-item">
  21. <view class="title"><text class="necessary">*</text>纬度:</view>
  22. <input name="input" v-model="latitude"></input>
  23. </view>
  24. <view class="form-item">
  25. <view class="title"></view>
  26. <button class=" cu-btn " style="padding:10rpx 20rpx" @click="getLocation()">
  27. <image src="../../static/nav-icon.png" style="width:25rpx;height:25rpx;margin-right:26rpx"></image>
  28. 获取当前经纬度
  29. </button>
  30. </view>
  31. <view class="form-item">
  32. <view class="title"><text class="necessary">*</text>联系人:</view>
  33. <input name="input" v-model="userName"></input>
  34. </view>
  35. <view class="form-item">
  36. <view class="title"><text class="necessary">*</text>手机号码:</view>
  37. <input name="input" v-model="phone"></input>
  38. </view>
  39. <view class="form-item">
  40. <view class="title"><text class="necessary">*</text>所属线路:</view>
  41. <select name="" id="" filterable clearable v-model="router_id">
  42. <option value="0">请选择</option>
  43. <option :value=item.id v-for="item in routeListData">{{ item.route_name}}</option>
  44. </select>
  45. </view>
  46. <view class="form-item">
  47. <view class="title"><text class="necessary">*</text>所属线区域:</view>
  48. <select name="" id="" v-model="region">
  49. <option value="0">请选择</option>
  50. <option value="1">宝山</option>
  51. <option value="2">嘉定</option>
  52. </select>
  53. </view>
  54. <view class="form-item">
  55. <view class="title"><text class="necessary">*</text>装机容量:</view>
  56. <input name="input" v-model="installed_capacity"></input>
  57. </view>
  58. <view class="form-item" style="padding-bottom:200rpx">
  59. <view class="title"><text class="necessary">*</text>流变变化:</view>
  60. <input name="input" v-model="rheological_change"></input>
  61. </view>
  62. <view class="btn-area submitBottomBtn padding-lr-sm">
  63. <button class="bg-blue round margin-top" @click="$noMultipleClicks(addSubmit)">提 交 </button>
  64. </view>
  65. </form>
  66. <!-- 站点新增end -->
  67. <!-- 站点修改start -->
  68. <form action="" @submit="formSubmit" v-else>
  69. <view class="form-item margin-top">
  70. <view class="title">
  71. <text class="necessary">*</text>
  72. 站点名称:
  73. </view>
  74. <input name="userName" v-model="siteMessage.siteName"></input>
  75. </view>
  76. <view class="form-item">
  77. <view class="title">地址:</view>
  78. <input name="input" v-model="siteMessage.address"></input>
  79. </view>
  80. <view class="form-item">
  81. <view class="title">经度:</view>
  82. <input name="input" v-model="siteMessage.longitude"></input>
  83. </view>
  84. <view class="form-item">
  85. <view class="title">纬度:</view>
  86. <input name="input" v-model="siteMessage.latitude"></input>
  87. </view>
  88. <view class="form-item">
  89. <view class="title"></view>
  90. <button class=" cu-btn " style="padding:10rpx 20rpx" @click="getLocation2()">
  91. <image src="../../static/nav-icon.png" style="width:25rpx;height:25rpx;margin-right:26rpx"></image>
  92. 获取当前经纬度
  93. </button>
  94. </view>
  95. <view class="form-item">
  96. <view class="title">联系人:</view>
  97. <input name="input" v-model="siteMessage.userName"></input>
  98. </view>
  99. <view class="form-item">
  100. <view class="title">手机号码:</view>
  101. <input name="input" v-model="siteMessage.phone"></input>
  102. </view>
  103. <view class="form-item">
  104. <view class="title"><text class="necessary">*</text>所属线区域:</view>
  105. <select name="" id="" v-model="siteMessage.region">
  106. <option value="0">请选择</option>
  107. <option value="1">宝山</option>
  108. <option value="2">嘉定</option>
  109. </select>
  110. </view>
  111. <view class="form-item">
  112. <view class="title"><text class="necessary">*</text>所属线路:</view>
  113. <select name="" id=" " v-model="siteMessage.route_id">
  114. <option value="0">请选择</option>
  115. <option :value=item.id v-for="item in routeListData">{{ item.route_name}}</option>
  116. </select>
  117. </view>
  118. <view class="form-item">
  119. <view class="title"><text class="necessary">*</text>装机容量:</view>
  120. <input name="input" v-model="siteMessage.installed_capacity"></input>
  121. </view>
  122. <view class="form-item" style="padding-bottom:200rpx">
  123. <view class="title"><text class="necessary">*</text>流变变化:</view>
  124. <input name="input" v-model="siteMessage.rheological_change"></input>
  125. </view>
  126. <view class="btn-area submitBottomBtn padding-lr-sm">
  127. <button class="bg-blue round margin-top" @click="$noMultipleClicks(editSubmit)">提 交 </button>
  128. </view>
  129. </form>
  130. <!-- 站点修改end -->
  131. </view>
  132. </template>
  133. <script>
  134. //引入js sdk的封装
  135. import * as jwx from '../../util/jssdk.js'
  136. export default {
  137. data() {
  138. return {
  139. noClick:true,
  140. id: 0,
  141. latitude: "",
  142. siteName: "",
  143. userName: "",
  144. phone: "",
  145. address: "",
  146. longitude: "",
  147. siteMessage:{},
  148. region:0,
  149. router_id:0,
  150. routeListData:[],
  151. installed_capacity:'',
  152. rheological_change:''
  153. }
  154. },
  155. onLoad: function(option) {
  156. this.id=option.id
  157. if (option.id) {
  158. uni.setNavigationBarTitle({
  159. title: '站点修改'
  160. });
  161. this.getSiteList({"id":option.id})
  162. } else {
  163. uni.setNavigationBarTitle({
  164. title: '站点新增'
  165. });
  166. }
  167. this.getRoutrBox()
  168. },
  169. methods: {
  170. //线路名称下拉数据请求
  171. async getRoutrBox(params = {}) {
  172. const res = await this.$myRequest({
  173. url: 'Archives/getRoutrBox',
  174. showLoading: true,
  175. data: params
  176. })
  177. this.routeListData = res.data.data;
  178. console.log(this.routeListData)
  179. },
  180. //新增
  181. getLocation(){
  182. // 将this赋值给that
  183. let that = this
  184. // 微信公众号获取位置
  185. jwx.configWeiXin(jweixin => {
  186. wx.getLocation({
  187. type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
  188. success: function (res) {
  189. that.longitude=res.longitude
  190. that.latitude=res.latitude
  191. }
  192. });
  193. });
  194. },
  195. //修改
  196. getLocation2(){
  197. // 将this赋值给that
  198. let that = this
  199. // 微信公众号获取位置
  200. jwx.configWeiXin(jweixin => {
  201. wx.getLocation({
  202. type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
  203. success: function (res) {
  204. that.siteMessage.longitude=res.longitude
  205. that.siteMessage.latitude=res.latitude
  206. }
  207. });
  208. });
  209. },
  210. //新增验证并提交
  211. addSubmit() {
  212. if (!this.siteName.replace(/^\s*/g,'')) {
  213. uni.showToast({
  214. title: "请输入站点名称...",
  215. icon: "none"
  216. });
  217. return
  218. }
  219. if (!this.address.replace(/^\s*/g,'')) {
  220. uni.showToast({
  221. title: "请输入地址...",
  222. icon: "none"
  223. });
  224. return
  225. }
  226. if (!this.longitude) {
  227. uni.showToast({
  228. title: "请输入经度...",
  229. icon: "none"
  230. });
  231. return
  232. }
  233. if (!this.latitude) {
  234. uni.showToast({
  235. title: "请输入纬度...",
  236. icon: "none"
  237. });
  238. return
  239. }
  240. if (!this.userName.replace(/^\s*/g,'')) {
  241. uni.showToast({
  242. title: "请输入联系人...",
  243. icon: "none"
  244. });
  245. return
  246. }
  247. if (!this.phone.replace(/^\s*/g,'')) {
  248. uni.showToast({
  249. title: "请输入手机号码...",
  250. icon: "none"
  251. });
  252. return
  253. }
  254. if (!/^1[3456789]\d{9}$/.test(this.phone)){
  255. uni.showToast({
  256. title: "请输入正确的手机号码...",
  257. icon:"none"
  258. });
  259. return
  260. }
  261. if (!this.router_id) {
  262. uni.showToast({
  263. title: "请选择所属线路...",
  264. icon: "none"
  265. });
  266. return
  267. }
  268. if (!this.region) {
  269. uni.showToast({
  270. title: "请选择所属区域...",
  271. icon: "none"
  272. });
  273. return
  274. }
  275. if (!this.installed_capacity.replace(/^\s*/g,'')) {
  276. uni.showToast({
  277. title: "请输入装机容量...",
  278. icon: "none"
  279. });
  280. return
  281. }
  282. if (!this.rheological_change.replace(/^\s*/g,'')) {
  283. uni.showToast({
  284. title: "请输入流变变化...",
  285. icon: "none"
  286. });
  287. return
  288. }
  289. this.getAddSite({
  290. "siteName": this.siteName,
  291. "userName": this.userName,
  292. "phone": this.phone,
  293. "address": this.address,
  294. "longitude": this.longitude,
  295. "latitude": this.latitude,
  296. "route_id":this.router_id,
  297. "region":this.region,
  298. "installed_capacity":this.installed_capacity,
  299. "rheological_change":this.rheological_change
  300. })
  301. },
  302. //编辑验证并提交
  303. editSubmit() {
  304. if (!this.siteMessage.siteName.replace(/^\s*/g,'')) {
  305. uni.showToast({
  306. title: "请填写站点名称...",
  307. icon: "none"
  308. });
  309. return
  310. }
  311. if (!this.siteMessage.address.replace(/^\s*/g,'')) {
  312. uni.showToast({
  313. title: "请输入地址...",
  314. icon: "none"
  315. });
  316. return
  317. }
  318. if (!this.siteMessage.longitude) {
  319. uni.showToast({
  320. title: "请输入经度...",
  321. icon: "none"
  322. });
  323. return
  324. }
  325. if (!this.siteMessage.latitude) {
  326. uni.showToast({
  327. title: "请输入纬度...",
  328. icon: "none"
  329. });
  330. return
  331. }
  332. if (!this.siteMessage.userName.replace(/^\s*/g,'')) {
  333. uni.showToast({
  334. title: "请输入联系人...",
  335. icon: "none"
  336. });
  337. return
  338. }
  339. if (!this.siteMessage.phone.replace(/^\s*/g,'')) {
  340. uni.showToast({
  341. title: "请输入手机号码...",
  342. icon: "none"
  343. });
  344. return
  345. }
  346. if (!/^1[3456789]\d{9}$/.test(this.siteMessage.phone)){
  347. uni.showToast({
  348. title: "请输入正确的手机号码...",
  349. icon:"none"
  350. });
  351. return
  352. }
  353. if (!this.siteMessage.route_id) {
  354. uni.showToast({
  355. title: "请选择所属线路...",
  356. icon: "none"
  357. });
  358. return
  359. }
  360. if (!this.siteMessage.region) {
  361. uni.showToast({
  362. title: "请选择所属区域...",
  363. icon: "none"
  364. });
  365. return
  366. }
  367. if (!this.siteMessage.installed_capacity) {
  368. uni.showToast({
  369. title: "请输入装机容量...",
  370. icon: "none"
  371. });
  372. return
  373. }
  374. if (!this.siteMessage.rheological_change) {
  375. uni.showToast({
  376. title: "请输入流变变化...",
  377. icon: "none"
  378. });
  379. return
  380. }
  381. this.setEditSite({
  382. "id":this.id,
  383. "siteName": this.siteMessage.siteName,
  384. "userName": this.siteMessage.userName,
  385. "phone": this.siteMessage.phone,
  386. "address": this.siteMessage.address,
  387. "longitude": this.siteMessage.longitude,
  388. "latitude": this.siteMessage.latitude,
  389. "route_id":this.siteMessage.route_id,
  390. "region":this.siteMessage.region,
  391. "installed_capacity":this.siteMessage.installed_capacity,
  392. "rheological_change":this.siteMessage.rheological_change
  393. })
  394. },
  395. // 新增请求
  396. async getAddSite(ming = {}) {
  397. const res = await this.$myRequest({
  398. url: 'SiteManagement/setAddSite',
  399. data: ming
  400. })
  401. if (!res.data.flag) {
  402. uni.showToast({
  403. title: "添加失败",
  404. icon: "none"
  405. });
  406. } else {
  407. uni.showToast({
  408. title: "添加成功",
  409. });
  410. }
  411. setTimeout(() => {
  412. uni.navigateTo({
  413. url: '/pages/siteManage/siteManage',
  414. });
  415. }, 1000);
  416. },
  417. // 修改回显请求
  418. async getSiteList(ming = {}) {
  419. const res = await this.$myRequest({
  420. url: 'SiteManagement/getSiteList',
  421. showLoading: true,
  422. data: ming
  423. })
  424. this.siteMessage=res.data.data[0];
  425. },
  426. // 编辑请求
  427. async setEditSite(ming = {}) {
  428. const res = await this.$myRequest({
  429. url: 'SiteManagement/setEditSite',
  430. data: ming
  431. })
  432. if (!res.data.flag) {
  433. uni.showToast({
  434. title: "编辑失败",
  435. icon: "none"
  436. });
  437. } else {
  438. uni.showToast({
  439. title: "编辑成功",
  440. });
  441. }
  442. setTimeout(() => {
  443. uni.navigateTo({
  444. url: '/pages/siteManage/siteManage',
  445. });
  446. }, 1000);
  447. },
  448. }
  449. }
  450. </script>
  451. <style lang="scss">
  452. .cu-form-group {
  453. border-top: 0;
  454. }
  455. input,
  456. select,
  457. option {
  458. line-height: 70rpx;
  459. padding: 0 20rpx;
  460. height: 70rpx;
  461. border: 1px solid #EDEDED;
  462. // width:500rpx!important;
  463. background-color: #fff;
  464. box-sizing: border-box;
  465. appearance: none;
  466. -moz-appearance: none;
  467. -webkit-appearance: none;
  468. color: #999;
  469. }
  470. select:focus,
  471. select:active,
  472. select:hover {
  473. outline: none;
  474. }
  475. select {
  476. background: url(../../static/arrow.png) no-repeat scroll 98% center;
  477. background-size: 6%;
  478. }
  479. .form-item label text {
  480. position: relative;
  481. top: 2rpx
  482. }
  483. .form-item {
  484. padding: 0 40rpx;
  485. display: flex;
  486. align-items: top;
  487. margin-bottom: 20rpx;
  488. .title {
  489. width: 170rpx;
  490. position: relative;
  491. .necessary {
  492. color: red;
  493. display: inline-block;
  494. position: absolute;
  495. top: -2rpx;
  496. left: -20rpx;
  497. font-size: 40rpx;
  498. }
  499. }
  500. input,
  501. select {
  502. width: 500rpx;
  503. font-size: 28rpx;
  504. }
  505. }
  506. /* 站点多选下拉样式 start */
  507. .layui-btn {
  508. background-color: #5fb878;
  509. }
  510. a {
  511. text-decoration: none;
  512. }
  513. .label {
  514. padding: 2px 0px;
  515. background: #aaa;
  516. border-radius: 2px;
  517. color: #fff;
  518. display: block;
  519. line-height: 20px;
  520. height: 20px;
  521. margin: 2px 5px 2px 0;
  522. float: left;
  523. }
  524. .label span {
  525. padding: 0 5px;
  526. color: #fff;
  527. }
  528. .close {
  529. padding: 1px 5px !important;
  530. }
  531. .close:hover {
  532. /* background-color: #009E94;
  533. border-radius: 2px;
  534. color: tomato; */
  535. }
  536. .selectId input {
  537. width: 100% !important;
  538. }
  539. .selectId input {
  540. height: 25px;
  541. padding: 1px 5px;
  542. border-radius: 3px;
  543. width: calc(100% - 12px);
  544. outline-color: #5fb878;
  545. border: 1px solid #5fb878;
  546. }
  547. .selectId {
  548. position: relative;
  549. }
  550. .selectId dl {
  551. border: 1px solid #eee;
  552. border-radius: 3px;
  553. margin: 2px 0px;
  554. max-height: 300px;
  555. overflow-x: hidden;
  556. white-space: nowrap;
  557. position: absolute;
  558. width: 100%;
  559. top: 40px;
  560. background: #fff;
  561. z-index: 1000
  562. }
  563. .selectId dl dd {
  564. margin: 0;
  565. padding: 5px 10px;
  566. }
  567. .selectId dl dd:hover {
  568. background-color: #5FB878;
  569. color: white;
  570. }
  571. .AD {
  572. /* width: 210px;
  573. margin-left: 40px; */
  574. overflow-y: auto;
  575. max-height: 200px;
  576. /* border: 2px solid #5fb878;
  577. border-radius: 6px;
  578. padding: 1px 2px; */
  579. }
  580. form .AD span {
  581. width: auto;
  582. }
  583. .siteSelect {
  584. width: 71%;
  585. display: inline-block;
  586. }
  587. /* 站点多选下拉样式end */
  588. </style>