siteAdd.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  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="formMess.siteName"></input>
  11. </view>
  12. <view class="form-item">
  13. <view class="title"><text class="necessary">*</text>地址:</view>
  14. <input name="input" v-model="formMess.address"></input>
  15. </view>
  16. <view class="form-item">
  17. <view class="title"><text class="necessary">*</text>经度:</view>
  18. <input name="input" v-model="formMess.longitude"></input>
  19. </view>
  20. <view class="form-item">
  21. <view class="title"><text class="necessary">*</text>维度:</view>
  22. <input name="input" v-model="formMess.latitude"></input>
  23. </view>
  24. <view class="form-item">
  25. <view class="title"><text class="necessary">*</text>联系人:</view>
  26. <input name="input" v-model="formMess.userName"></input>
  27. </view>
  28. <view class="form-item">
  29. <view class="title"><text class="necessary">*</text>手机号码:</view>
  30. <input name="input" v-model="formMess.phone"></input>
  31. </view>
  32. <view class="btn-area submitBottomBtn padding-lr-sm">
  33. <button class="bg-blue round margin-top" @click="addSubmit">提 交 </button>
  34. </view>
  35. </form>
  36. <!-- 站点新增end -->
  37. <!-- 站点修改start -->
  38. <form action="" @submit="formSubmit" v-else>
  39. <view class="form-item margin-top">
  40. <view class="title">
  41. <text class="necessary">*</text>
  42. 站点名称:
  43. </view>
  44. <input name="userName" v-model="siteMessage.siteName"></input>
  45. </view>
  46. <view class="form-item">
  47. <view class="title">地址:</view>
  48. <input name="input" v-model="siteMessage.address"></input>
  49. </view>
  50. <view class="form-item">
  51. <view class="title">经度:</view>
  52. <input name="input" v-model="siteMessage.longitude"></input>
  53. </view>
  54. <view class="form-item">
  55. <view class="title">维度:</view>
  56. <input name="input" v-model="siteMessage.latitude"></input>
  57. </view>
  58. <view class="form-item">
  59. <view class="title">联系人:</view>
  60. <input name="input" v-model="siteMessage.userName"></input>
  61. </view>
  62. <view class="form-item">
  63. <view class="title">手机号码:</view>
  64. <input name="input" v-model="siteMessage.phone"></input>
  65. </view>
  66. <view class="btn-area submitBottomBtn padding-lr-sm">
  67. <button class="bg-blue round margin-top" @click="editSubmit">提 交 </button>
  68. </view>
  69. </form>
  70. <!-- 站点修改end -->
  71. </view>
  72. </template>
  73. <script>
  74. export default {
  75. data() {
  76. return {
  77. id: 0,
  78. formMess: {
  79. "siteName": "",
  80. "userName": "",
  81. "phone": "",
  82. "address": "",
  83. "longitude": "",
  84. "latitude": "",
  85. },
  86. siteMessage:{}
  87. }
  88. },
  89. onLoad: function(option) {
  90. this.id=option.id
  91. if (option.id) {
  92. uni.setNavigationBarTitle({
  93. title: '站点修改'
  94. });
  95. this.getSiteList({"id":option.id})
  96. } else {
  97. uni.setNavigationBarTitle({
  98. title: '站点新增'
  99. });
  100. }
  101. },
  102. methods: {
  103. //新增验证并提交
  104. addSubmit() {
  105. if (!this.formMess.siteName) {
  106. uni.showToast({
  107. title: "请输入站点名称...",
  108. icon: "none"
  109. });
  110. return
  111. }
  112. if (!this.formMess.address) {
  113. uni.showToast({
  114. title: "请输入地址...",
  115. icon: "none"
  116. });
  117. return
  118. }
  119. if (!this.formMess.longitude) {
  120. uni.showToast({
  121. title: "请输入经度...",
  122. icon: "none"
  123. });
  124. return
  125. }
  126. if (!this.formMess.latitude) {
  127. uni.showToast({
  128. title: "请输入纬度...",
  129. icon: "none"
  130. });
  131. return
  132. }
  133. if (!this.formMess.userName) {
  134. uni.showToast({
  135. title: "请输入联系人...",
  136. icon: "none"
  137. });
  138. return
  139. }
  140. if (!this.formMess.phone) {
  141. uni.showToast({
  142. title: "请输入手机号码...",
  143. icon: "none"
  144. });
  145. return
  146. }
  147. if (!/^1[345678]\d{9}$/.test(this.formMess.phone)){
  148. uni.showToast({
  149. title: "请输入正确的手机号码...",
  150. icon:"none"
  151. });
  152. return
  153. }
  154. this.getAddSite({
  155. "siteName": this.formMess.siteName,
  156. "userName": this.formMess.userName,
  157. "phone": this.formMess.phone,
  158. "address": this.formMess.address,
  159. "longitude": this.formMess.longitude,
  160. "latitude": this.formMess.latitude
  161. })
  162. },
  163. //编辑验证并提交
  164. editSubmit() {
  165. if (!this.siteMessage.siteName) {
  166. uni.showToast({
  167. title: "请填写站点名称...",
  168. icon: "none"
  169. });
  170. return
  171. }
  172. if (!this.siteMessage.address) {
  173. uni.showToast({
  174. title: "请输入地址...",
  175. icon: "none"
  176. });
  177. return
  178. }
  179. if (!this.siteMessage.longitude) {
  180. uni.showToast({
  181. title: "请输入经度...",
  182. icon: "none"
  183. });
  184. return
  185. }
  186. if (!this.siteMessage.latitude) {
  187. uni.showToast({
  188. title: "请输入纬度...",
  189. icon: "none"
  190. });
  191. return
  192. }
  193. if (!this.siteMessage.userName) {
  194. uni.showToast({
  195. title: "请输入联系人...",
  196. icon: "none"
  197. });
  198. return
  199. }
  200. if (!this.siteMessage.phone) {
  201. uni.showToast({
  202. title: "请输入手机号码...",
  203. icon: "none"
  204. });
  205. return
  206. }
  207. if (!/^1[345678]\d{9}$/.test(this.siteMessage.phone)){
  208. uni.showToast({
  209. title: "请输入正确的手机号码...",
  210. icon:"none"
  211. });
  212. return
  213. }
  214. this.setEditSite({
  215. "id":this.id,
  216. "siteName": this.siteMessage.siteName,
  217. "userName": this.siteMessage.userName,
  218. "phone": this.siteMessage.phone,
  219. "address": this.siteMessage.address,
  220. "longitude": this.siteMessage.longitude,
  221. "latitude": this.siteMessage.latitude
  222. })
  223. },
  224. // 新增请求
  225. async getAddSite(ming = {}) {
  226. const res = await this.$myRequest({
  227. url: 'SiteManagement/setAddSite',
  228. data: ming
  229. })
  230. if (!res.data.flag) {
  231. uni.showToast({
  232. title: "添加失败",
  233. icon: "none"
  234. });
  235. } else {
  236. uni.showToast({
  237. title: "添加成功",
  238. });
  239. }
  240. setTimeout(() => {
  241. uni.navigateTo({
  242. url: '/pages/siteManage/siteManage',
  243. });
  244. }, 1000);
  245. },
  246. // 修改回显请求
  247. async getSiteList(ming = {}) {
  248. const res = await this.$myRequest({
  249. url: 'SiteManagement/getSiteList',
  250. showLoading: true,
  251. data: ming
  252. })
  253. this.siteMessage=res.data.data[0];
  254. },
  255. // 编辑请求
  256. async setEditSite(ming = {}) {
  257. const res = await this.$myRequest({
  258. url: 'SiteManagement/setEditSite',
  259. data: ming
  260. })
  261. if (!res.data.flag) {
  262. uni.showToast({
  263. title: "编辑失败",
  264. icon: "none"
  265. });
  266. } else {
  267. uni.showToast({
  268. title: "编辑成功",
  269. });
  270. }
  271. setTimeout(() => {
  272. uni.navigateTo({
  273. url: '/pages/siteManage/siteManage',
  274. });
  275. }, 1000);
  276. },
  277. }
  278. }
  279. </script>
  280. <style lang="scss">
  281. .cu-form-group {
  282. border-top: 0;
  283. }
  284. input,
  285. select,
  286. option {
  287. line-height: 70rpx;
  288. padding: 0 20rpx;
  289. height: 70rpx;
  290. border: 1px solid #EDEDED;
  291. // width:500rpx!important;
  292. background-color: #fff;
  293. box-sizing: border-box;
  294. appearance: none;
  295. -moz-appearance: none;
  296. -webkit-appearance: none;
  297. color: #999;
  298. }
  299. select:focus,
  300. select:active,
  301. select:hover {
  302. outline: none;
  303. }
  304. select {
  305. background: url(../../static/arrow.png) no-repeat scroll 98% center;
  306. background-size: 6%;
  307. }
  308. .form-item label text {
  309. position: relative;
  310. top: 2rpx
  311. }
  312. .form-item {
  313. padding: 0 40rpx;
  314. display: flex;
  315. align-items: top;
  316. margin-bottom: 20rpx;
  317. .title {
  318. width: 170rpx;
  319. position: relative;
  320. .necessary {
  321. color: red;
  322. display: inline-block;
  323. position: absolute;
  324. top: -2rpx;
  325. left: -20rpx;
  326. font-size: 40rpx;
  327. }
  328. }
  329. input,
  330. select {
  331. width: 500rpx;
  332. font-size: 28rpx;
  333. }
  334. }
  335. /* 站点多选下拉样式 start */
  336. .layui-btn {
  337. background-color: #5fb878;
  338. }
  339. a {
  340. text-decoration: none;
  341. }
  342. .label {
  343. padding: 2px 0px;
  344. background: #aaa;
  345. border-radius: 2px;
  346. color: #fff;
  347. display: block;
  348. line-height: 20px;
  349. height: 20px;
  350. margin: 2px 5px 2px 0;
  351. float: left;
  352. }
  353. .label span {
  354. padding: 0 5px;
  355. color: #fff;
  356. }
  357. .close {
  358. padding: 1px 5px !important;
  359. }
  360. .close:hover {
  361. /* background-color: #009E94;
  362. border-radius: 2px;
  363. color: tomato; */
  364. }
  365. .selectId input {
  366. width: 100% !important;
  367. }
  368. .selectId input {
  369. height: 25px;
  370. padding: 1px 5px;
  371. border-radius: 3px;
  372. width: calc(100% - 12px);
  373. outline-color: #5fb878;
  374. border: 1px solid #5fb878;
  375. }
  376. .selectId {
  377. position: relative;
  378. }
  379. .selectId dl {
  380. border: 1px solid #eee;
  381. border-radius: 3px;
  382. margin: 2px 0px;
  383. max-height: 300px;
  384. overflow-x: hidden;
  385. white-space: nowrap;
  386. position: absolute;
  387. width: 100%;
  388. top: 40px;
  389. background: #fff;
  390. z-index: 1000
  391. }
  392. .selectId dl dd {
  393. margin: 0;
  394. padding: 5px 10px;
  395. }
  396. .selectId dl dd:hover {
  397. background-color: #5FB878;
  398. color: white;
  399. }
  400. .AD {
  401. /* width: 210px;
  402. margin-left: 40px; */
  403. overflow-y: auto;
  404. max-height: 200px;
  405. /* border: 2px solid #5fb878;
  406. border-radius: 6px;
  407. padding: 1px 2px; */
  408. }
  409. form .AD span {
  410. width: auto;
  411. }
  412. .siteSelect {
  413. width: 71%;
  414. display: inline-block;
  415. }
  416. /* 站点多选下拉样式end */
  417. </style>