siteAdd.vue 17 KB

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