edit_fireStation.vue 11 KB

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