add_fireStation.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. <template>
  2. <view class=" uni-container">
  3. <view class="example container" :style="'height: ' + (screenHeight - wheight - 75) + 'px'">
  4. <!-- 自定义表单校验 1-->
  5. <!-- 自定义表单校验 1-->
  6. <u--form ref="customForm" :model="formData" labelPosition="left" labelWidth="150" labelAlign="left">
  7. <view class=" flex flex-direction width100">
  8. <u-form-item label="社区名称" prop="microName" :required="true">
  9. <u-input v-model="formData.microName" placeholder="请输入社区名称" />
  10. </u-form-item>
  11. <u-form-item prop="org_name" label="所属单位" @click="
  12. showSex5 = true;
  13. hideKeyboard();
  14. " :required="true">
  15. <u-input v-model="formData.org_name" disabled disabledColor="#ffffff" placeholder="请选择所属单位">
  16. </u-input>
  17. </u-form-item>
  18. <u-form-item label="所属区县 " prop="county">
  19. <u-input v-model="formData.county" placeholder="请输入所属区县" />
  20. </u-form-item>
  21. <u-form-item label="建站日期" prop="built_on">
  22. <!-- <u-button customStyle="background-color: rgba(76, 178, 182, 0.5);" plain shape="circle"
  23. size="small" color="#fff" @click="unitTime = true" :text="builtOn"></u-button> -->
  24. <uni-datetime-picker :show="unitTime" v-model="formData.builtOn" mode="date" closeOnClickOverlay
  25. @confirm="ActiveUnitTime" @cancel="unitTime = false" @change="changetime"
  26. @close="unitTime = false"></uni-datetime-picker>
  27. </u-form-item>
  28. <u-form-item label="详细地址">
  29. <u-input v-model="formData.addr" placeholder="请输入详细地址" />
  30. </u-form-item>
  31. <u-form-item label="控制室值班人数" prop="dutyer">
  32. <u-input v-model="formData.dutyer" placeholder="请输入控制室值班人数 " />
  33. <button @click="goWorkNum" class="manyBtn">添加值班人</button>
  34. </u-form-item>
  35. <u-form-item label="报警电话">
  36. <u-input v-model="formData.alarmTel" placeholder="请输入报警电话 " />
  37. </u-form-item>
  38. <u-form-item label="负责人">
  39. <u-input v-model="formData.charger" placeholder="请输入负责人" />
  40. <button @click="goBigNum" class="manyBtn">添加负责人</button>
  41. </u-form-item>
  42. <u-form-item label="人员信息" prop="members">
  43. <u-input v-model="formData.members" placeholder="请输入队员人数" />
  44. <button @click="goPeopleMes" class="manyBtn">添加人员信息</button>
  45. </u-form-item>
  46. <u-form-item label="水罐车数量" prop="waterTanker">
  47. <u-input v-model="formData.waterTanker" placeholder="请输入水罐车" />
  48. </u-form-item>
  49. <u-form-item label="泡沫车数量" prop="foamCar">
  50. <u-input v-model="formData.foamCar" placeholder="请输入泡沫车" />
  51. </u-form-item>
  52. <u-form-item label="消防摩托数量" prop="fireMoto">
  53. <u-input v-model="formData.fireMoto" placeholder="请输入消防摩托数量" />
  54. </u-form-item>
  55. <u-form-item label="其它数量" prop="others">
  56. <u-input v-model="formData.others" placeholder="请输入其它" />
  57. </u-form-item>
  58. </view>
  59. </u--form>
  60. <u-action-sheet :show="showSex5" :actions="actions5" title="请选择单位" @close="showSex5 = false"
  61. @select="sexSelect5"></u-action-sheet>
  62. </view>
  63. <uni-row class="heigthButton">
  64. <u-button @click="submit('customForm')" type="primary" shape="circle" size="large" color="#4CB2B6"
  65. text="确认新增"></u-button>
  66. </uni-row>
  67. </view>
  68. </template>
  69. <script>
  70. import {
  71. getOrgId,
  72. createStation,
  73. }
  74. from '@/api/fire_station/index';
  75. import config from '@/config';
  76. import store from '@/store';
  77. var that = null;
  78. export default {
  79. data() {
  80. return {
  81. screenHeight: this.$screenHeight,
  82. wheight: '',
  83. showSex: false, //有无避难层
  84. showSex5: false, //所属单位
  85. actions5: [],
  86. // 每页数据量
  87. pageSize: 5,
  88. // 当前页
  89. pageNo: 1,
  90. // 数据总量
  91. total: 0,
  92. unitTime: false,
  93. loading: false,
  94. title: '生成隐患',
  95. content: '确认将此检查项目生成为隐患',
  96. // 自定义表单数据
  97. formData: {
  98. status: '0',
  99. empList: []
  100. },
  101. // 自定义表单校验规则
  102. customRules: {
  103. microName: {
  104. type: 'string',
  105. required: true,
  106. message: '社区名称不能为空',
  107. trigger: ['blur', 'change']
  108. },
  109. orgName: {
  110. type: 'string',
  111. required: true,
  112. message: '所属单位不能为空',
  113. trigger: ['blur', 'change']
  114. },
  115. number: {
  116. type: 'number',
  117. message: '所填项必须为数字',
  118. trigger: ['blur', 'change']
  119. },
  120. dutyer: {
  121. type: 'number',
  122. message: '所填项为数字类型',
  123. trigger: ['blur', 'change']
  124. },
  125. members: {
  126. type: 'number',
  127. message: '所填项为数字类型',
  128. trigger: ['blur', 'change']
  129. },
  130. foamCar: {
  131. type: 'number',
  132. message: '所填项为数字类型',
  133. trigger: ['blur', 'change']
  134. },
  135. fireMoto: {
  136. type: 'number',
  137. message: '所填项为数字类型',
  138. trigger: ['blur', 'change']
  139. },
  140. waterTanker: {
  141. type: 'number',
  142. message: '所填项为数字类型',
  143. trigger: ['blur', 'change']
  144. },
  145. others: {
  146. type: 'number',
  147. message: '所填项为数字类型',
  148. trigger: ['blur', 'change']
  149. },
  150. newEmpList: [],
  151. },
  152. };
  153. },
  154. computed: {},
  155. mounted() {
  156. uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
  157. this.wheight = data.height
  158. }).exec()
  159. },
  160. // 在 vue页面,向起始页通过事件传递数据
  161. onLoad: function(option) {
  162. this.formData.org_name = option.orgName ? option.orgName : ''
  163. this.formData.orgId = option.orgId ? option.orgId : ''
  164. // 获取单位id
  165. getOrgId({
  166. pageNo: this.pageNo,
  167. pageSize: this.pageSize,
  168. userId: this.$store.state.user.id
  169. }).then(response => {
  170. console.log(response, 'response');
  171. // 取到用户对应的单位名称与id
  172. response.data.map(v => {
  173. this.actions5.push({
  174. id: v.dwid,
  175. name: v.orgName
  176. });
  177. });
  178. });
  179. },
  180. onReady() {
  181. this.$refs.customForm.setRules(this.customRules);
  182. },
  183. onShow() {
  184. let empList = localStorage.getItem('empList')
  185. empList = JSON.parse(empList)
  186. console.log(empList,'emplddddddd');
  187. if(empList&&empList.length!=0){
  188. let pack = {
  189. duty: empList[0].power,
  190. empName: empList[0].name,
  191. mobile: empList[0].phone,
  192. idcardno: empList[0].userNum
  193. }
  194. this.newEmpList = pack
  195. }
  196. },
  197. methods: {
  198. submit(ref) {
  199. this.$refs[ref]
  200. .validate()
  201. .then(res => {
  202. // 因为需要提交的数据和绑定的数据不一样,所以要转换
  203. this.formData['status'] = 0;
  204. if (this.formData.builtOn) {
  205. this.formData.builtOn = this.formData.builtOn
  206. }
  207. if (this.newEmpList) {
  208. this.formData.empList = [this.newEmpList]
  209. }
  210. var jsdata = JSON.stringify(this.formData);
  211. createStation(jsdata).then(response => {
  212. // console.log('response.data.msg,', response.data);
  213. uni.showLoading({
  214. title: response.data.msg
  215. });
  216. setTimeout(() => {
  217. // console.log('新增成功!');
  218. uni.hideLoading();
  219. uni.navigateBack({
  220. delta: 1
  221. })
  222. }, 0);
  223. });
  224. localStorage.removeItem('empList')
  225. })
  226. .catch(err => {
  227. // console.log('err错误信息为:', err);
  228. uni.showToast({
  229. icon: 'none',
  230. title: '错误!' + err[0].message
  231. })
  232. });
  233. },
  234. // 隐藏键盘
  235. hideKeyboard() {
  236. uni.hideKeyboard();
  237. },
  238. // 记录类型
  239. // 单位成立时间
  240. ActiveUnitTime(e) {
  241. this.unitTime = false;
  242. console.log(e.value, e.mode);
  243. let value = new Date(e.value);
  244. this.formData.built_on = uni.$u.timeFormat(e.value, 'yyyy-mm-dd');
  245. },
  246. changetime(e) {
  247. console.log('change', e);
  248. },
  249. // 所属单位
  250. sexSelect5(e) {
  251. this.formData.orgId = e.id;
  252. this.formData.org_name = e.name;
  253. console.log(this.formData.orgId);
  254. },
  255. // 生成隐患弹出层 //暂存为草稿箱弹出层
  256. cancel() {
  257. this.show = false;
  258. },
  259. confirm() {
  260. setTimeout(() => {
  261. // 0.5秒后自动关闭
  262. this.show = false;
  263. }, 500);
  264. },
  265. // 触底的事件
  266. scrolltolower() {
  267. // 判断是否还有下一页数据
  268. if (this.pageNo * this.pageSize >= this.total)
  269. return uni.showToast({
  270. title: `数据加载完毕`
  271. });
  272. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  273. if (this.loading) return;
  274. this.pageNo += 1;
  275. this.showCheckboxShow(this.pageNo);
  276. },
  277. // 值班
  278. goWorkNum() {
  279. uni.navigateTo({
  280. url: "/pagesA/fire/fire_station/people_fireStation/people_fireStation"
  281. })
  282. },
  283. // 负责人
  284. goBigNum() {
  285. uni.navigateTo({
  286. url: "/pagesA/fire/fire_station/people_fireStation/people_fireStation"
  287. })
  288. },
  289. // 普通人
  290. goPeopleMes() {
  291. uni.navigateTo({
  292. url: "/pagesA/fire/fire_station/people_fireStation/people_fireStation"
  293. })
  294. }
  295. }
  296. };
  297. </script>
  298. <style lang="scss" scoped>
  299. page {
  300. height: 100%;
  301. background-color: #f5f7f9;
  302. position: relative;
  303. }
  304. .buttomBorder {
  305. height: 0px;
  306. border: 1px dashed #cbd5e1;
  307. }
  308. /deep/ .uni-section .uni-section-header {
  309. padding: 0px;
  310. }
  311. /deep/ .u-form-item__body {
  312. font-weight: 500;
  313. flex-direction: column !important;
  314. }
  315. /deep/ .u-form-item__body__left__content__label {
  316. margin-bottom: 16rpx;
  317. font-size: 30rpx !important;
  318. color: #274647 !important;
  319. }
  320. .arrow-icon {
  321. //主动检查箭头
  322. position: absolute;
  323. right: 14px;
  324. top: 49px;
  325. transform: rotate(90deg);
  326. }
  327. /deep/ .u-input[data-v-fdbb9fe6],
  328. /deep/ .u-input.data-v-fdbb9fe6,
  329. /deep/ .u-input {
  330. background-color: #fff;
  331. }
  332. /deep/.u-button[data-v-3bf2dba7],
  333. /deep/.u-button.data-v-3bf2dba7,
  334. /deep/.u-button {
  335. width: 60% !important;
  336. }
  337. //弹框样式
  338. .btnList {
  339. // width: 40%;
  340. display: flex;
  341. // display:flex;
  342. .u-button[data-v-3bf2dba7] {
  343. width: 30%;
  344. }
  345. }
  346. /deep/ .u-popup__content {
  347. //弹出的宽高
  348. height: 100%;
  349. }
  350. /deep/ .u-form-item__body__right__message {
  351. //校验的文字的位置
  352. margin-left: 10rpx !important;
  353. }
  354. /deep/ .uicon-close {
  355. //关闭按钮背景色
  356. background-color: rgba(199, 203, 210, 0.9);
  357. border-radius: 10%;
  358. }
  359. .checkbox {
  360. .checkbox-item {
  361. box-sizing: border-box;
  362. padding-top: 40px;
  363. }
  364. }
  365. //侧边联动
  366. .page-body {
  367. display: flex;
  368. background: #fff;
  369. overflow: hidden;
  370. }
  371. .nav {
  372. display: flex;
  373. width: 100%;
  374. }
  375. .nav-left {
  376. width: 25%;
  377. background: #fafafa;
  378. }
  379. .nav-left-item {
  380. height: 100upx;
  381. border-right: solid 1px #f1f1f1;
  382. border-bottom: solid 1px #f1f1f1;
  383. font-size: 30upx;
  384. display: flex;
  385. align-items: center;
  386. justify-content: center;
  387. }
  388. /deep/.nav-right-item[data-v-73caef23],
  389. /deep/.nav-right-item {
  390. display: flex;
  391. flex-wrap: wrap;
  392. }
  393. .nav-left-item:last-child {
  394. border-bottom: none;
  395. }
  396. .nav-right {
  397. width: 75%;
  398. }
  399. .box {
  400. display: block;
  401. overflow: hidden;
  402. border-bottom: 20upx solid #f3f3f3;
  403. /* min-height: 100vh; */
  404. /*若您的子分类过少想使得每个子分类占满屏请放开上边注视 */
  405. }
  406. .box:last-child {
  407. border: none;
  408. // min-height: 100vh;
  409. }
  410. .nav-right-item {
  411. margin-top: 20px;
  412. // width: 28%;
  413. // min-height: 200upx;
  414. float: left;
  415. text-align: center;
  416. padding: 11upx;
  417. font-size: 28upx;
  418. background: #fff;
  419. /deep/.u-checkbox__icon-wrap[data-v-532d01c7],
  420. /deep/.u-checkbox__icon-wrap {
  421. //复选框的样式
  422. margin: 0 20rpx;
  423. }
  424. /deep/ uni-view[data-v-3d1b15f2] {
  425. //复选框上线的间距
  426. margin: 20rpx 0 !important;
  427. }
  428. // /deep/ .u-checkbox__icon-wrap--square{
  429. // margin: 20rpx;
  430. // }
  431. .u-checkbox-label--right[data-v-532d01c7],
  432. .u-checkbox-label--right {
  433. margin-right: 40rpx;
  434. }
  435. }
  436. .nav-right-item image {
  437. width: 150upx;
  438. height: 150upx;
  439. }
  440. .active {
  441. font-weight: 700;
  442. color: #274647;
  443. background: #fff;
  444. border-right: 0;
  445. }
  446. ::-webkit-scrollbar {
  447. /*取消小程序的默认导航条样式*/
  448. width: 0;
  449. height: 0;
  450. color: transparent;
  451. }
  452. .selectBtn {
  453. width: 200rpx;
  454. margin-left: 0;
  455. font-size: 30rpx;
  456. background-color: #4cb2b6;
  457. }
  458. /deep/.u-action-sheet {
  459. overflow-y: auto;
  460. height: 1000rpx;
  461. background-color: #fff;
  462. }
  463. .example {
  464. overflow-y: auto;
  465. }
  466. /deep/ .antherBtn {
  467. width: 200rpx !important;
  468. height: 80rpx;
  469. font-size: 30rpx;
  470. text-align: center;
  471. line-height: 80rpx;
  472. }
  473. .manyBtn {
  474. width: 150rpx;
  475. height: 60rpx;
  476. font-size: 20rpx;
  477. line-height: 60rpx;
  478. text-align: center;
  479. border-radius: 20rpx;
  480. background-color: #4DB1B6;
  481. color: white;
  482. }
  483. </style>