siteAdd.vue 17 KB

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