add_fireStation.vue 13 KB

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