siteAdd.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  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">
  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="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">
  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="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. id: 0,
  140. latitude: "",
  141. siteName: "",
  142. userName: "",
  143. phone: "",
  144. address: "",
  145. longitude: "",
  146. siteMessage:{},
  147. region:0,
  148. router_id:0,
  149. routeListData:[],
  150. installed_capacity:'',
  151. rheological_change:''
  152. }
  153. },
  154. onLoad: function(option) {
  155. this.id=option.id
  156. if (option.id) {
  157. uni.setNavigationBarTitle({
  158. title: '站点修改'
  159. });
  160. this.getSiteList({"id":option.id})
  161. } else {
  162. uni.setNavigationBarTitle({
  163. title: '站点新增'
  164. });
  165. }
  166. this.getRoutrBox()
  167. },
  168. methods: {
  169. //线路名称下拉数据请求
  170. async getRoutrBox(params = {}) {
  171. const res = await this.$myRequest({
  172. url: 'Archives/getRoutrBox',
  173. showLoading: true,
  174. data: params
  175. })
  176. this.routeListData = res.data.data;
  177. console.log(this.routeListData)
  178. },
  179. //新增
  180. getLocation(){
  181. // 将this赋值给that
  182. let that = this
  183. // 微信公众号获取位置
  184. jwx.configWeiXin(jweixin => {
  185. wx.getLocation({
  186. type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
  187. success: function (res) {
  188. that.longitude=res.longitude
  189. that.latitude=res.latitude
  190. }
  191. });
  192. });
  193. },
  194. //修改
  195. getLocation2(){
  196. // 将this赋值给that
  197. let that = this
  198. // 微信公众号获取位置
  199. jwx.configWeiXin(jweixin => {
  200. wx.getLocation({
  201. type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
  202. success: function (res) {
  203. that.siteMessage.longitude=res.longitude
  204. that.siteMessage.latitude=res.latitude
  205. }
  206. });
  207. });
  208. },
  209. //新增验证并提交
  210. addSubmit() {
  211. if (!this.siteName) {
  212. uni.showToast({
  213. title: "请输入站点名称...",
  214. icon: "none"
  215. });
  216. return
  217. }
  218. if (!this.address) {
  219. uni.showToast({
  220. title: "请输入地址...",
  221. icon: "none"
  222. });
  223. return
  224. }
  225. if (!this.longitude) {
  226. uni.showToast({
  227. title: "请输入经度...",
  228. icon: "none"
  229. });
  230. return
  231. }
  232. if (!this.latitude) {
  233. uni.showToast({
  234. title: "请输入纬度...",
  235. icon: "none"
  236. });
  237. return
  238. }
  239. if (!this.userName) {
  240. uni.showToast({
  241. title: "请输入联系人...",
  242. icon: "none"
  243. });
  244. return
  245. }
  246. if (!this.phone) {
  247. uni.showToast({
  248. title: "请输入手机号码...",
  249. icon: "none"
  250. });
  251. return
  252. }
  253. if (!/^1[3456789]\d{9}$/.test(this.phone)){
  254. uni.showToast({
  255. title: "请输入正确的手机号码...",
  256. icon:"none"
  257. });
  258. return
  259. }
  260. if (!this.router_id) {
  261. uni.showToast({
  262. title: "请选择所属线路...",
  263. icon: "none"
  264. });
  265. return
  266. }
  267. if (!this.installed_capacity) {
  268. uni.showToast({
  269. title: "请输入装机容量...",
  270. icon: "none"
  271. });
  272. return
  273. }
  274. if (!this.rheological_change) {
  275. uni.showToast({
  276. title: "请输入流变变化...",
  277. icon: "none"
  278. });
  279. return
  280. }
  281. this.getAddSite({
  282. "siteName": this.siteName,
  283. "userName": this.userName,
  284. "phone": this.phone,
  285. "address": this.address,
  286. "longitude": this.longitude,
  287. "latitude": this.latitude,
  288. "route_id":this.router_id,
  289. "region":this.region,
  290. "installed_capacity":this.installed_capacity,
  291. "rheological_change":this.rheological_change
  292. })
  293. },
  294. //编辑验证并提交
  295. editSubmit() {
  296. if (!this.siteMessage.siteName) {
  297. uni.showToast({
  298. title: "请填写站点名称...",
  299. icon: "none"
  300. });
  301. return
  302. }
  303. if (!this.siteMessage.address) {
  304. uni.showToast({
  305. title: "请输入地址...",
  306. icon: "none"
  307. });
  308. return
  309. }
  310. if (!this.siteMessage.longitude) {
  311. uni.showToast({
  312. title: "请输入经度...",
  313. icon: "none"
  314. });
  315. return
  316. }
  317. if (!this.siteMessage.latitude) {
  318. uni.showToast({
  319. title: "请输入纬度...",
  320. icon: "none"
  321. });
  322. return
  323. }
  324. if (!this.siteMessage.userName) {
  325. uni.showToast({
  326. title: "请输入联系人...",
  327. icon: "none"
  328. });
  329. return
  330. }
  331. if (!this.siteMessage.phone) {
  332. uni.showToast({
  333. title: "请输入手机号码...",
  334. icon: "none"
  335. });
  336. return
  337. }
  338. if (!/^1[3456789]\d{9}$/.test(this.siteMessage.phone)){
  339. uni.showToast({
  340. title: "请输入正确的手机号码...",
  341. icon:"none"
  342. });
  343. return
  344. }
  345. if (!this.siteMessage.route_id) {
  346. uni.showToast({
  347. title: "请选择所属线路...",
  348. icon: "none"
  349. });
  350. return
  351. }
  352. if (!this.siteMessage.installed_capacity) {
  353. uni.showToast({
  354. title: "请输入装机容量...",
  355. icon: "none"
  356. });
  357. return
  358. }
  359. if (!this.siteMessage.rheological_change) {
  360. uni.showToast({
  361. title: "请输入流变变化...",
  362. icon: "none"
  363. });
  364. return
  365. }
  366. this.setEditSite({
  367. "id":this.id,
  368. "siteName": this.siteMessage.siteName,
  369. "userName": this.siteMessage.userName,
  370. "phone": this.siteMessage.phone,
  371. "address": this.siteMessage.address,
  372. "longitude": this.siteMessage.longitude,
  373. "latitude": this.siteMessage.latitude,
  374. "route_id":this.siteMessage.route_id,
  375. "region":this.siteMessage.region,
  376. "installed_capacity":this.siteMessage.installed_capacity,
  377. "rheological_change":this.siteMessage.rheological_change
  378. })
  379. },
  380. // 新增请求
  381. async getAddSite(ming = {}) {
  382. const res = await this.$myRequest({
  383. url: 'SiteManagement/setAddSite',
  384. data: ming
  385. })
  386. if (!res.data.flag) {
  387. uni.showToast({
  388. title: "添加失败",
  389. icon: "none"
  390. });
  391. } else {
  392. uni.showToast({
  393. title: "添加成功",
  394. });
  395. }
  396. setTimeout(() => {
  397. uni.navigateTo({
  398. url: '/pages/siteManage/siteManage',
  399. });
  400. }, 1000);
  401. },
  402. // 修改回显请求
  403. async getSiteList(ming = {}) {
  404. const res = await this.$myRequest({
  405. url: 'SiteManagement/getSiteList',
  406. showLoading: true,
  407. data: ming
  408. })
  409. this.siteMessage=res.data.data[0];
  410. },
  411. // 编辑请求
  412. async setEditSite(ming = {}) {
  413. const res = await this.$myRequest({
  414. url: 'SiteManagement/setEditSite',
  415. data: ming
  416. })
  417. if (!res.data.flag) {
  418. uni.showToast({
  419. title: "编辑失败",
  420. icon: "none"
  421. });
  422. } else {
  423. uni.showToast({
  424. title: "编辑成功",
  425. });
  426. }
  427. setTimeout(() => {
  428. uni.navigateTo({
  429. url: '/pages/siteManage/siteManage',
  430. });
  431. }, 1000);
  432. },
  433. }
  434. }
  435. </script>
  436. <style lang="scss">
  437. .cu-form-group {
  438. border-top: 0;
  439. }
  440. input,
  441. select,
  442. option {
  443. line-height: 70rpx;
  444. padding: 0 20rpx;
  445. height: 70rpx;
  446. border: 1px solid #EDEDED;
  447. // width:500rpx!important;
  448. background-color: #fff;
  449. box-sizing: border-box;
  450. appearance: none;
  451. -moz-appearance: none;
  452. -webkit-appearance: none;
  453. color: #999;
  454. }
  455. select:focus,
  456. select:active,
  457. select:hover {
  458. outline: none;
  459. }
  460. select {
  461. background: url(../../static/arrow.png) no-repeat scroll 98% center;
  462. background-size: 6%;
  463. }
  464. .form-item label text {
  465. position: relative;
  466. top: 2rpx
  467. }
  468. .form-item {
  469. padding: 0 40rpx;
  470. display: flex;
  471. align-items: top;
  472. margin-bottom: 20rpx;
  473. .title {
  474. width: 170rpx;
  475. position: relative;
  476. .necessary {
  477. color: red;
  478. display: inline-block;
  479. position: absolute;
  480. top: -2rpx;
  481. left: -20rpx;
  482. font-size: 40rpx;
  483. }
  484. }
  485. input,
  486. select {
  487. width: 500rpx;
  488. font-size: 28rpx;
  489. }
  490. }
  491. /* 站点多选下拉样式 start */
  492. .layui-btn {
  493. background-color: #5fb878;
  494. }
  495. a {
  496. text-decoration: none;
  497. }
  498. .label {
  499. padding: 2px 0px;
  500. background: #aaa;
  501. border-radius: 2px;
  502. color: #fff;
  503. display: block;
  504. line-height: 20px;
  505. height: 20px;
  506. margin: 2px 5px 2px 0;
  507. float: left;
  508. }
  509. .label span {
  510. padding: 0 5px;
  511. color: #fff;
  512. }
  513. .close {
  514. padding: 1px 5px !important;
  515. }
  516. .close:hover {
  517. /* background-color: #009E94;
  518. border-radius: 2px;
  519. color: tomato; */
  520. }
  521. .selectId input {
  522. width: 100% !important;
  523. }
  524. .selectId input {
  525. height: 25px;
  526. padding: 1px 5px;
  527. border-radius: 3px;
  528. width: calc(100% - 12px);
  529. outline-color: #5fb878;
  530. border: 1px solid #5fb878;
  531. }
  532. .selectId {
  533. position: relative;
  534. }
  535. .selectId dl {
  536. border: 1px solid #eee;
  537. border-radius: 3px;
  538. margin: 2px 0px;
  539. max-height: 300px;
  540. overflow-x: hidden;
  541. white-space: nowrap;
  542. position: absolute;
  543. width: 100%;
  544. top: 40px;
  545. background: #fff;
  546. z-index: 1000
  547. }
  548. .selectId dl dd {
  549. margin: 0;
  550. padding: 5px 10px;
  551. }
  552. .selectId dl dd:hover {
  553. background-color: #5FB878;
  554. color: white;
  555. }
  556. .AD {
  557. /* width: 210px;
  558. margin-left: 40px; */
  559. overflow-y: auto;
  560. max-height: 200px;
  561. /* border: 2px solid #5fb878;
  562. border-radius: 6px;
  563. padding: 1px 2px; */
  564. }
  565. form .AD span {
  566. width: auto;
  567. }
  568. .siteSelect {
  569. width: 71%;
  570. display: inline-block;
  571. }
  572. /* 站点多选下拉样式end */
  573. </style>