siteAdd.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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">地址:</view>
  14. <input name="input" v-model="formMess.address"></input>
  15. </view>
  16. <view class="form-item">
  17. <view class="title">经度:</view>
  18. <input name="input" v-model="formMess.longitude"></input>
  19. </view>
  20. <view class="form-item">
  21. <view class="title">维度:</view>
  22. <input name="input" v-model="formMess.latitude"></input>
  23. </view>
  24. <view class="form-item">
  25. <view class="title">联系人:</view>
  26. <input name="input" v-model="formMess.userName"></input>
  27. </view>
  28. <view class="form-item">
  29. <view class="title">手机号码:</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. this.getAddSite({
  113. "siteName": this.formMess.siteName,
  114. "userName": this.formMess.userName,
  115. "phone": this.formMess.phone,
  116. "address": this.formMess.address,
  117. "longitude": this.formMess.longitude,
  118. "latitude": this.formMess.latitude
  119. })
  120. },
  121. //编辑验证并提交
  122. editSubmit() {
  123. if (!this.siteMessage.siteName) {
  124. uni.showToast({
  125. title: "请填写站点名称",
  126. icon: "none"
  127. });
  128. return
  129. }
  130. this.setEditSite({
  131. "id":this.id,
  132. "siteName": this.siteMessage.siteName,
  133. "userName": this.siteMessage.userName,
  134. "phone": this.siteMessage.phone,
  135. "address": this.siteMessage.address,
  136. "longitude": this.siteMessage.longitude,
  137. "latitude": this.siteMessage.latitude
  138. })
  139. },
  140. // 新增请求
  141. async getAddSite(ming = {}) {
  142. const res = await this.$myRequest({
  143. url: 'SiteManagement/setAddSite',
  144. data: ming
  145. })
  146. if (!res.data.flag) {
  147. uni.showToast({
  148. title: "添加失败",
  149. icon: "none"
  150. });
  151. } else {
  152. uni.showToast({
  153. title: "添加成功",
  154. });
  155. }
  156. setTimeout(() => {
  157. uni.navigateTo({
  158. url: '/pages/siteManage/siteManage',
  159. });
  160. }, 1000);
  161. },
  162. // 修改回显请求
  163. async getSiteList(ming = {}) {
  164. const res = await this.$myRequest({
  165. url: 'SiteManagement/getSiteList',
  166. showLoading: true,
  167. data: ming
  168. })
  169. this.siteMessage=res.data.data[0];
  170. },
  171. // 编辑请求
  172. async setEditSite(ming = {}) {
  173. const res = await this.$myRequest({
  174. url: 'SiteManagement/setEditSite',
  175. data: ming
  176. })
  177. if (!res.data.flag) {
  178. uni.showToast({
  179. title: "编辑失败",
  180. icon: "none"
  181. });
  182. } else {
  183. uni.showToast({
  184. title: "编辑成功",
  185. });
  186. }
  187. setTimeout(() => {
  188. uni.navigateTo({
  189. url: '/pages/siteManage/siteManage',
  190. });
  191. }, 1000);
  192. },
  193. }
  194. }
  195. </script>
  196. <style lang="scss">
  197. .cu-form-group {
  198. border-top: 0;
  199. }
  200. input,
  201. select,
  202. option {
  203. line-height: 70rpx;
  204. padding: 0 20rpx;
  205. height: 70rpx;
  206. border: 1px solid #EDEDED;
  207. // width:500rpx!important;
  208. background-color: #fff;
  209. box-sizing: border-box;
  210. appearance: none;
  211. -moz-appearance: none;
  212. -webkit-appearance: none;
  213. color: #999;
  214. }
  215. select:focus,
  216. select:active,
  217. select:hover {
  218. outline: none;
  219. }
  220. select {
  221. background: url(../../static/arrow.png) no-repeat scroll 98% center;
  222. background-size: 6%;
  223. }
  224. .form-item label text {
  225. position: relative;
  226. top: 2rpx
  227. }
  228. .form-item {
  229. padding: 0 40rpx;
  230. display: flex;
  231. align-items: top;
  232. margin-bottom: 20rpx;
  233. .title {
  234. width: 170rpx;
  235. position: relative;
  236. .necessary {
  237. color: red;
  238. display: inline-block;
  239. position: absolute;
  240. top: -2rpx;
  241. left: -20rpx;
  242. font-size: 40rpx;
  243. }
  244. }
  245. input,
  246. select {
  247. width: 500rpx;
  248. font-size: 28rpx;
  249. }
  250. }
  251. /* 站点多选下拉样式 start */
  252. .layui-btn {
  253. background-color: #5fb878;
  254. }
  255. a {
  256. text-decoration: none;
  257. }
  258. .label {
  259. padding: 2px 0px;
  260. background: #aaa;
  261. border-radius: 2px;
  262. color: #fff;
  263. display: block;
  264. line-height: 20px;
  265. height: 20px;
  266. margin: 2px 5px 2px 0;
  267. float: left;
  268. }
  269. .label span {
  270. padding: 0 5px;
  271. color: #fff;
  272. }
  273. .close {
  274. padding: 1px 5px !important;
  275. }
  276. .close:hover {
  277. /* background-color: #009E94;
  278. border-radius: 2px;
  279. color: tomato; */
  280. }
  281. .selectId input {
  282. width: 100% !important;
  283. }
  284. .selectId input {
  285. height: 25px;
  286. padding: 1px 5px;
  287. border-radius: 3px;
  288. width: calc(100% - 12px);
  289. outline-color: #5fb878;
  290. border: 1px solid #5fb878;
  291. }
  292. .selectId {
  293. position: relative;
  294. }
  295. .selectId dl {
  296. border: 1px solid #eee;
  297. border-radius: 3px;
  298. margin: 2px 0px;
  299. max-height: 300px;
  300. overflow-x: hidden;
  301. white-space: nowrap;
  302. position: absolute;
  303. width: 100%;
  304. top: 40px;
  305. background: #fff;
  306. z-index: 1000
  307. }
  308. .selectId dl dd {
  309. margin: 0;
  310. padding: 5px 10px;
  311. }
  312. .selectId dl dd:hover {
  313. background-color: #5FB878;
  314. color: white;
  315. }
  316. .AD {
  317. /* width: 210px;
  318. margin-left: 40px; */
  319. overflow-y: auto;
  320. max-height: 200px;
  321. /* border: 2px solid #5fb878;
  322. border-radius: 6px;
  323. padding: 1px 2px; */
  324. }
  325. form .AD span {
  326. width: auto;
  327. }
  328. .siteSelect {
  329. width: 71%;
  330. display: inline-block;
  331. }
  332. /* 站点多选下拉样式end */
  333. </style>