edit_fireStation.vue 12 KB

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