add.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. <template>
  2. <view class="appWrapper">
  3. <form action="" v-if="type==1" @submit="formSubmit">
  4. <view class="form-item margin-top">
  5. <view class="title">
  6. <text class="necessary">*</text>
  7. 用户名称:
  8. </view>
  9. <input name="userName" v-model="formMess.userName"></input>
  10. </view>
  11. <view class="form-item">
  12. <view class="title">地址:</view>
  13. <input name="input" v-model="formMess.place"></input>
  14. </view>
  15. <view class="form-item">
  16. <view class="title">经度:</view>
  17. <input name="input" v-model="formMess.longitude"></input>
  18. </view>
  19. <view class="form-item">
  20. <view class="title">维度:</view>
  21. <input name="input" v-model="formMess.dimension"></input>
  22. </view>
  23. <view class="form-item">
  24. <view class="title">联系人:</view>
  25. <input name="input" v-model="formMess.contactor"></input>
  26. </view>
  27. <view class="form-item">
  28. <view class="title">手机号码:</view>
  29. <input name="input" v-model="formMess.mobile"></input>
  30. </view>
  31. <view class="btn-area submitBottomBtn padding-lr-sm">
  32. <button class="bg-blue round margin-top" form-type="submit">提 交 </button>
  33. </view>
  34. </form>
  35. <form action="" v-else-if="type==2">
  36. <view class="form-item margin-top">
  37. <view class="title">
  38. <text class="necessary">*</text>
  39. 设备编号:
  40. </view>
  41. <input name="input" v-model="formMess.deviceNo"></input>
  42. </view>
  43. <view class="form-item">
  44. <view class="title">设备名称:</view>
  45. <input name="input" v-model="formMess.deviceName"></input>
  46. </view>
  47. <view class="form-item">
  48. <view class="title">安装位置:</view>
  49. <input name="input" v-model="formMess.place"></input>
  50. </view>
  51. <view class="form-item">
  52. <view class="title">所属楼层:</view>
  53. <select name="" id="">
  54. <option value="">楼层一</option>
  55. <option value="">楼层一</option>
  56. <option value="">楼层一</option>
  57. </select>
  58. </view>
  59. <view class="form-item">
  60. <view class="title">站点:</view>
  61. <select name="" id="">
  62. <option value="">站点一</option>
  63. <option value="">站点一</option>
  64. <option value="">站点一</option>
  65. </select>
  66. </view>
  67. <view class="form-item">
  68. <view class="title">设备类型:</view>
  69. <select name="" id="">
  70. <option value="">智慧用电</option>
  71. <option value="">视频监控</option>
  72. </select>
  73. </view>
  74. <view class="btn-area submitBottomBtn padding-lr-sm">
  75. <button class="bg-blue round margin-top">提 交 </button>
  76. </view>
  77. </form>
  78. <form action="" v-else>
  79. <view class="form-item margin-top">
  80. <view class="title">
  81. <text class="necessary">*</text>
  82. 角色名称
  83. </view>
  84. <input name="userName" v-model="formMess.userName"></input>
  85. </view>
  86. <view class="form-item">
  87. <view class="title">
  88. <text class="necessary">*</text>
  89. 站点:
  90. </view>
  91. <!-- <yealuo-select the-style="margin: 20upx auto;font-size: 46upx;"
  92. value="选项2"
  93. item-key="value"
  94. placeholder='请输入内容'
  95. :binData="data2"
  96. checkType="checkbox"
  97. tags="name"
  98. inputStyle=""
  99. selectStyle=""
  100. overflow="hide"
  101. @getBackVal="getBackVal"
  102. :selectIco="true"
  103. >
  104. </yealuo-select> -->
  105. <select name="" id="">
  106. <option value="">站点一</option>
  107. <option value="">站点二</option>
  108. <option value="">站点三</option>
  109. </select>
  110. </view>
  111. <view class="form-item margin-top">
  112. <view class="title">
  113. <text class="necessary">*</text>
  114. 告警类型
  115. </view>
  116. <radio-group name="gender">
  117. <label class="margin-right">
  118. <radio value="全部告警" checked /><text>全部告警</text>
  119. </label>
  120. <label>
  121. <radio value="维保告警" /><text>维保告警</text>
  122. </label>
  123. </radio-group>
  124. </view>
  125. <view class="btn-area submitBottomBtn padding-lr-sm">
  126. <button class="bg-blue round margin-top" form-type="submit">提 交 </button>
  127. </view>
  128. </form>
  129. </view>
  130. </template>
  131. <script>
  132. var graceChecker = require("../../common/graceChecker.js");
  133. // import add from '../../common/select.js';
  134. export default {
  135. data() {
  136. return {
  137. index: -1,
  138. picker: ['楼层一', '楼层二', '楼层三'],
  139. type: '0',
  140. formMess: {
  141. "userName": "sss",
  142. "place": "",
  143. "longitude": "",
  144. "dimension": "",
  145. "contactor": "",
  146. "mobile": "",
  147. },
  148. // 站点多选下拉
  149. data2: [
  150. {id: 1, value: '选项1'},
  151. {id: 2, value: '选项2'},
  152. {id: 3, value: '选项3'},
  153. {id: 4, value: '选项4'},
  154. {id: 5, value: '选项5'},
  155. {id: 6, value: '这是6'},
  156. {id: 7, value: '这是7'},
  157. {id: 8, value: '这是8'},
  158. {id: 9, value: '这是9'},
  159. {id: 10, value: '这是10'},
  160. ],
  161. // 站点多选下拉 end
  162. }
  163. },
  164. onLoad: function(option) {
  165. console.log(option.type); //打印出上个页面传递的参数。
  166. this.type = option.type;
  167. if (option.type == 1) {
  168. uni.setNavigationBarTitle({
  169. title: '站点新增'
  170. });
  171. } else if (option.type == 2) {
  172. uni.setNavigationBarTitle({
  173. title: '设备新增'
  174. });
  175. } else {
  176. uni.setNavigationBarTitle({
  177. title: '权限新增'
  178. });
  179. }
  180. },
  181. methods: {
  182. // 站点多选下拉
  183. getBackVal:function(e){
  184. console.log(e)
  185. },
  186. // 站点多选下拉 end
  187. formSubmit: function(e) {
  188. console.log('form发生了submit事件,携带数据为:' + JSON.stringify(e.detail.value))
  189. //定义表单规则
  190. var rule = [{
  191. name: "userName",
  192. checkType: "string",
  193. checkRule: "1,3",
  194. errorMsg: "姓名应为1-3个字符..."
  195. },
  196. // {name:"gender", checkType : "in", checkRule:"男,女", errorMsg:"请选择性别"},
  197. // {name:"loves", checkType : "notnull", checkRule:"", errorMsg:"请选择爱好"}
  198. ];
  199. //进行表单检查
  200. var formData = e.detail.value;
  201. var checkRes = graceChecker.check(formData, rule);
  202. if (checkRes) {
  203. uni.showToast({
  204. title: "验证通过!",
  205. icon: "none"
  206. });
  207. } else {
  208. uni.showToast({
  209. title: graceChecker.error,
  210. icon: "none"
  211. });
  212. }
  213. },
  214. formReset: function(e) {
  215. console.log('清空数据')
  216. }
  217. }
  218. }
  219. </script>
  220. <style lang="scss">
  221. .cu-form-group {
  222. border-top: 0;
  223. }
  224. input,
  225. select,
  226. option {
  227. line-height: 70rpx;
  228. padding: 0 20rpx;
  229. height: 70rpx;
  230. border: 1px solid #EDEDED;
  231. // width:500rpx!important;
  232. background-color: #fff;
  233. box-sizing: border-box;
  234. appearance: none;
  235. -moz-appearance: none;
  236. -webkit-appearance: none;
  237. color: #999;
  238. }
  239. select:focus,
  240. select:active,
  241. select:hover {
  242. outline: none;
  243. }
  244. select {
  245. background: url(../../static/arrow.png) no-repeat scroll 98% center;
  246. background-size: 6%;
  247. }
  248. .form-item label text {
  249. position: relative;
  250. top: 2rpx
  251. }
  252. .form-item {
  253. padding: 0 40rpx;
  254. display: flex;
  255. align-items: center;
  256. margin-bottom: 20rpx;
  257. .title {
  258. width: 170rpx;
  259. position: relative;
  260. .necessary {
  261. color: red;
  262. display: inline-block;
  263. position: absolute;
  264. top: -2rpx;
  265. left: -20rpx;
  266. font-size: 40rpx;
  267. }
  268. }
  269. input,
  270. select {
  271. width: 500rpx;
  272. font-size: 28rpx;
  273. }
  274. }
  275. /* 站点多选下拉样式 start */
  276. .layui-btn {
  277. background-color: #5fb878;
  278. }
  279. a {
  280. text-decoration: none;
  281. }
  282. .label {
  283. padding: 2px 0px;
  284. background: #aaa;
  285. border-radius: 2px;
  286. color: #fff;
  287. display: block;
  288. line-height: 20px;
  289. height: 20px;
  290. margin: 2px 5px 2px 0;
  291. float: left;
  292. }
  293. .label span {
  294. padding: 0 5px;
  295. color: #fff;
  296. }
  297. .close {
  298. padding: 1px 5px !important;
  299. }
  300. .close:hover {
  301. /* background-color: #009E94;
  302. border-radius: 2px;
  303. color: tomato; */
  304. }
  305. .selectId input {
  306. width: 100% !important;
  307. }
  308. .selectId input {
  309. height: 25px;
  310. padding: 1px 5px;
  311. border-radius: 3px;
  312. width: calc(100% - 12px);
  313. outline-color: #5fb878;
  314. border: 1px solid #5fb878;
  315. }
  316. .selectId {
  317. position: relative;
  318. }
  319. .selectId dl {
  320. border: 1px solid #eee;
  321. border-radius: 3px;
  322. margin: 2px 0px;
  323. max-height: 300px;
  324. overflow-x: hidden;
  325. white-space: nowrap;
  326. position: absolute;
  327. width: 100%;
  328. top: 40px;
  329. background: #fff;
  330. z-index: 1000
  331. }
  332. .selectId dl dd {
  333. margin: 0;
  334. padding: 5px 10px;
  335. }
  336. .selectId dl dd:hover {
  337. background-color: #5FB878;
  338. color: white;
  339. }
  340. .AD {
  341. /* width: 210px;
  342. margin-left: 40px; */
  343. overflow-y: auto;
  344. max-height: 200px;
  345. /* border: 2px solid #5fb878;
  346. border-radius: 6px;
  347. padding: 1px 2px; */
  348. }
  349. form .AD span {
  350. width: auto;
  351. }
  352. .siteSelect {
  353. width: 71%;
  354. display: inline-block;
  355. }
  356. /* 站点多选下拉样式end */
  357. </style>