add_architecture.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  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="200" labelAlign="left">
  6. <view class=" flex flex-direction width100">
  7. <u-form-item label="楼宇名称" prop="buildingName" :required="true">
  8. <u-input v-model="formData.buildingName" placeholder="必填。请输入楼宇名称" />
  9. </u-form-item>
  10. <u-form-item label="所属单位" prop="orgName" @click="
  11. showSex5 = true;
  12. hideKeyboard();
  13. " :required="true">
  14. <!-- <picker @change="bindPickerChange" :value="index" :range="actions5" range-key="name">
  15. <u--input v-model="actions5[index]" disabled disabledColor="#ffffff" placeholder="必选。请选择单位组织" /></u--input>
  16. </picker> -->
  17. <u--input v-model="formData.orgName" disabled disabledColor="#ffffff"
  18. placeholder="必选。请选择所属单位"></u--input>
  19. </u-form-item>
  20. <u-form-item label="楼宇编号 ">
  21. <u-input v-model="formData.buildingCode" placeholder="请输入楼宇编号" />
  22. </u-form-item>
  23. <u-form-item label="投入使用时间 "><u-input v-model="formData.buildingAge"
  24. placeholder="请输入投入使用时间" /></u-form-item>
  25. <u-form-item label="楼层 "><u-input v-model="formData.buildingFloor"
  26. placeholder="请输入楼层" /></u-form-item>
  27. <u-form-item label="档案负责人">
  28. <u-input v-model="formData.dafzr" placeholder="请输入档案负责人" />
  29. </u-form-item>
  30. <u-form-item label="占地面积"><u-input v-model="formData.zdmj" placeholder="请输入占地面积" /></u-form-item>
  31. <u-form-item label="产权信息 ">
  32. <u-input v-model="formData.ownership" placeholder="请输入产权信息" />
  33. </u-form-item>
  34. <u-form-item prop="dlwz" @tap="agree_poup()">
  35. <view class="address-with-icon">
  36. <view class="address-label">
  37. <view class="main-label">
  38. 地理位置
  39. </view>
  40. <view class="address-sub-label">
  41. <view class="address-icon">
  42. <u-icon name="map-fill" color="#2979ff" size="20"></u-icon>
  43. </view>
  44. <view class="address-title">
  45. 更新地址
  46. </view>
  47. </view>
  48. </view>
  49. <view class="address-input">
  50. <u-input v-model="formData.dlwz" placeholder="请输入地理位置" />
  51. </view>
  52. </view>
  53. </u-form-item>
  54. <u-form-item label="有无避难层" prop="ywbnc" @click="
  55. showSex = true;
  56. hideKeyboard();
  57. ">
  58. <u--input v-model="formData.ywbnc" disabled disabledColor="#ffffff"
  59. placeholder="有无避难层"></u--input>
  60. </u-form-item>
  61. <u-form-item label="避难层层数">
  62. <u-input v-model="formData.bncsl" placeholder="请输入避难层层数 " />
  63. </u-form-item>
  64. <u-form-item label="避难层面积">
  65. <u-input v-model="formData.bncmj" placeholder="请输入避难层面积" />
  66. </u-form-item>
  67. <u-form-item label="避难层位置">
  68. <u-input v-model="formData.bncwz" placeholder="请输入避难层位置" />
  69. </u-form-item>
  70. <u-form-item label="安全出口数">
  71. <u-input v-model="formData.aqcks" placeholder="请输入安全出口数" />
  72. </u-form-item>
  73. <u-form-item label="建筑数量 "><u-input v-model="formData.jzsl" placeholder="请输入建筑数量" /></u-form-item>
  74. <u-form-item label="建筑高度 ">
  75. <u-input v-model="formData.buildingHeight" placeholder="请输入建筑高度" />
  76. </u-form-item>
  77. <u-form-item label="建筑面积 "><u-input v-model="formData.jzmj" placeholder="请输入建筑面积" /></u-form-item>
  78. <u-form-item label="建筑结构 ">
  79. <u-input v-model="formData.buildingStructure" placeholder="请输入建筑结构" />
  80. </u-form-item>
  81. <u-form-item label="消防车道数" prop="xfcds">
  82. <u-input v-model="formData.xfcds" placeholder="请输入消防车道数" />
  83. </u-form-item>
  84. <u-form-item label="消防电梯数" prop="xfdts">
  85. <u-input v-model="formData.xfdts" placeholder="请输入消防电梯数" />
  86. </u-form-item>
  87. <u-form-item prop="xfcdwz" @tap="popHighPosistion()">
  88. <view class="address-with-icon">
  89. <view class="address-label">
  90. <view class="main-label">
  91. 消防车登高操作场地位置
  92. </view>
  93. <view class="address-sub-label">
  94. <view class="address-icon">
  95. <u-icon name="map-fill" color="#2979ff" size="20"></u-icon>
  96. </view>
  97. <view class="address-title">
  98. 更新地址
  99. </view>
  100. </view>
  101. </view>
  102. <view class=".address-input">
  103. <u-input v-model="formData.xfcdwz" placeholder="请输入消防车登高操作场地位置" />
  104. </view>
  105. </view>
  106. <!-- <u-input v-model="formData.xfcdwz" placeholder="请输入消防车登高操作场地位置" /> -->
  107. </u-form-item>
  108. <u-form-item label="消防控制室位置" prop="xfkzswz">
  109. <u-input v-model="formData.xfkzswz" placeholder="请输入消防控制室位置" />
  110. </u-form-item>
  111. <u-form-item label="自动消防设施情况" @click="
  112. showSex4 = true;
  113. hideKeyboard();
  114. ">
  115. <u--input v-model="formData.zdxfss" disabled disabledColor="#ffffff"
  116. placeholder="自动消防设施情况"></u--input>
  117. </u-form-item>
  118. <u-form-item label="耐火等级 ">
  119. <u-input v-model="formData.fireRating" placeholder="请输入耐火等级" />
  120. </u-form-item>
  121. <u-form-item label="燃气类型 "><u-input v-model="formData.rqlx" placeholder="请输入燃气类型" /></u-form-item>
  122. <u-form-item label="重点部位" prop="zdbwpic">
  123. <u-input v-model="formData.zdbwpic" placeholder="请输入重点部位" />
  124. </u-form-item>
  125. <u-form-item label="总平面图纸名称 ">
  126. <!-- 选择文件上传 -->
  127. <uni-file-picker v-model="formData.dwpmtzmc" del-icon limit="1" auto-upload file-mediatype="all"
  128. @select="select" @delete="deleteFile">
  129. <button type="primary" class="selectBtn"
  130. style="background-color: rgba(76, 178, 182, 0.5);">选择文件</button>
  131. <!-- 加载中 -->
  132. <isLodingModel v-if="loading"></isLodingModel>
  133. </uni-file-picker>
  134. </u-form-item>
  135. </view>
  136. </u--form>
  137. <u-action-sheet :show="showSex" :actions="actions2" title="有无避难层" @close="showSex = false"
  138. @select="sexSelect2"></u-action-sheet>
  139. <u-action-sheet :show="showSex4" :actions="actions4" title="自动消防设施情况" @close="showSex4 = false"
  140. @select="sexSelect4"></u-action-sheet>
  141. <u-action-sheet :show="showSex5" :actions="actions5" title="请选择单位" @close="showSex5 = false"
  142. @select="sexSelect5"></u-action-sheet>
  143. </view>
  144. <uni-row class="heigthButton">
  145. <u-button @click="submit('customForm')" type="primary" shape="circle" size="large" color="#4CB2B6"
  146. text="确认新增"></u-button>
  147. </uni-row>
  148. </view>
  149. </template>
  150. <script>
  151. import {
  152. createArc, // 更新
  153. upload, //上传文件
  154. getOrgId
  155. } from '@/api/architecture';
  156. import {
  157. getAccessToken
  158. } from '@/utils/auth';
  159. import config from '@/config';
  160. import store from '@/store';
  161. import {
  162. uploadAvatar
  163. } from '@/api/system/user';
  164. const baseUrl = config.baseUrl;
  165. var that = null;
  166. export default {
  167. data() {
  168. return {
  169. orgaction:[], //单位
  170. screenHeight: this.$screenHeight,
  171. wheight: '',
  172. index: 0,
  173. showSex: false, //有无避难层
  174. showSex3: false, //有无消防车道
  175. showSex4: false, //自动消防设施情况
  176. showSex5: false, //所属单位
  177. actions: [],
  178. columns: [
  179. ['中国', '美国', '日本']
  180. ],
  181. actions2: [{
  182. id: 1,
  183. name: '有'
  184. },
  185. {
  186. id: 2,
  187. name: '无'
  188. }
  189. ],
  190. actions4: [{
  191. id: 1,
  192. name: '情况良好'
  193. },
  194. {
  195. id: 2,
  196. name: '情况一般'
  197. },
  198. {
  199. id: 3,
  200. name: '报废'
  201. }
  202. ],
  203. actions5: [],
  204. // 每页数据量
  205. pageSize: 5,
  206. // 当前页
  207. pageNo: 1,
  208. // 数据总量
  209. total: 0,
  210. // tableData数据加载中
  211. loading: false,
  212. title: '生成隐患',
  213. content: '确认将此检查项目生成为隐患',
  214. // 自定义表单数据
  215. formData: {
  216. status: '0',
  217. File: [],
  218. dlwz: ''
  219. },
  220. // 自定义表单校验规则
  221. customRules: {
  222. buildingName: {
  223. type: 'string',
  224. required: true,
  225. message: '建筑名称不能为空',
  226. trigger: ['blur', 'change']
  227. },
  228. xfdts: {
  229. type: 'number',
  230. message: '消防电梯数为数字',
  231. trigger: ['blur', 'change']
  232. },
  233. xfcds: {
  234. type: 'number',
  235. message: '消防车道数为数字',
  236. trigger: ['blur', 'change']
  237. },
  238. orgName: {
  239. required: true,
  240. message: '所属单位为必填项',
  241. trigger: ['blur', 'change']
  242. }
  243. }
  244. };
  245. },
  246. mounted() {
  247. uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
  248. this.wheight = data.height
  249. }).exec()
  250. },
  251. computed: {},
  252. onLoad: function(option) {
  253. this.formData.orgName = option.orgName ? option.orgName : ''
  254. this.formData.orgId = option.orgId ? option.orgId : ''
  255. getOrgId({
  256. pageNo: this.pageNo,
  257. pageSize: this.pageSize,
  258. userId: this.$store.state.user.id
  259. }).then(response => {
  260. // 取到用户对应的单位名称与id
  261. response.data.map(v => {
  262. // this.actions5.push(
  263. // v.orgName
  264. // );
  265. this.actions5.push({
  266. id: v.dwid,
  267. name: v.orgName
  268. });
  269. });
  270. });
  271. },
  272. onReady() {
  273. this.$refs.customForm.setRules(this.customRules);
  274. },
  275. watch: {
  276. loading: {
  277. handler(newLength, oldLength) {
  278. this.$modal.isLoadingModel(this.loading)
  279. },
  280. immediate: true
  281. }
  282. },
  283. methods: {
  284. //让底部选择框显示出来
  285. agree_poup() {
  286. if (this.formData.orgId == undefined || this.formData.orgId == '' || this.formData.orgId == null) {
  287. uni.showToast({
  288. icon: 'error',
  289. title: '请选择所属单位'
  290. })
  291. } else {
  292. uni.chooseLocation({
  293. success: res => {
  294. this.formData.dlwz = res.address;
  295. }
  296. });
  297. }
  298. },
  299. // 弹出 消防车登高操作场地位置 选择地图
  300. popHighPosistion() {
  301. const that = this
  302. uni.chooseLocation({
  303. success: res => {
  304. that.formData.xfcdwz = res.address;
  305. that.$forceUpdate()
  306. }
  307. });
  308. },
  309. submit(ref) {
  310. this.$refs[ref]
  311. .validate()
  312. .then(res => {
  313. this.formData['status'] = 0;
  314. if (this.formData.File.length > 0) {
  315. this.formData.dwpmtzmc = this.formData.File[0].url.toString();
  316. } else {
  317. this.formData.dwpmtzmc = '';
  318. }
  319. var jsdata = JSON.stringify(this.formData);
  320. // 提交数据
  321. createArc(jsdata).then(response => {
  322. uni.showLoading({
  323. title: response.data.msg
  324. });
  325. setTimeout(() => {
  326. uni.hideLoading();
  327. uni.navigateBack({
  328. delta: 1
  329. });
  330. }, 0);
  331. });
  332. })
  333. .catch(err => {
  334. uni.showToast({
  335. icon: 'none',
  336. title: '错误!' + err[0].message
  337. });
  338. });
  339. },
  340. // 上传图片 获取上传状态
  341. // 选择上传触发函数
  342. select(e) {
  343. // 根据所选图片的个数,多次调用上传函数
  344. let promises = [];
  345. for (let i = 0; i < e.tempFilePaths.length; i++) {
  346. const promise = this.uploadFiles(e.tempFilePaths, i);
  347. promises.push(promise);
  348. }
  349. Promise.all(promises).then(result => {});
  350. },
  351. // 上传函数
  352. async uploadFiles(tempFilePaths, i) {
  353. const that = this;
  354. this.loading = true
  355. await uni.uploadFile({
  356. url: baseUrl + '/admin-api/infra/file/upload', //后端用于处理图片并返回图片地址的接口
  357. filePath: tempFilePaths[i],
  358. name: 'file',
  359. header: {
  360. Authorization: 'Bearer ' + getAccessToken()
  361. }, //请求token
  362. success: res => {
  363. let data = JSON.parse(res.data);
  364. // 返回的url
  365. var fileLink = data.data;
  366. const code = data.code;
  367. // 如果成功,将返回的data数据给 formdata
  368. if (code == 0) {
  369. that.formData.File.push({
  370. url: fileLink,
  371. name: fileLink
  372. });
  373. uni.showToast({
  374. title: '文件上传成功!'
  375. });
  376. that.loading = false
  377. // that.formData.dwpmtzmc = fileLink
  378. }
  379. // this.formData.dwpmtzmc = this.formData.dwpmtzmc.toString();
  380. },
  381. fail: () => {
  382. uni.showToast({
  383. icon: 'error',
  384. title: '文件上传失败!'
  385. });
  386. }
  387. });
  388. },
  389. // 移出图片函数
  390. async deleteFile(e) {
  391. this.formData.dwpmtzmc = [];
  392. },
  393. // 隐藏键盘
  394. hideKeyboard() {
  395. uni.hideKeyboard();
  396. },
  397. // 有无避难层
  398. sexSelect2(e) {
  399. this.formData.ywbnc = e.name;
  400. },
  401. // 消防设施情况
  402. sexSelect4(e) {
  403. this.formData.zdxfss = e.name;
  404. },
  405. // 所属单位
  406. sexSelect5(e) {
  407. this.formData.orgId = e.id;
  408. this.formData.orgName = e.name;
  409. },
  410. // 生成隐患弹出层 //暂存为草稿箱弹出层
  411. cancel() {
  412. this.show = false;
  413. },
  414. confirm() {
  415. setTimeout(() => {
  416. // 0.5秒后自动关闭
  417. this.show = false;
  418. }, 500);
  419. },
  420. bindPickerChange(e) {
  421. this.index = e.detail.value
  422. },
  423. // 触底的事件
  424. scrolltolower() {
  425. // 判断是否还有下一页数据
  426. if (this.pageNo * this.pageSize >= this.total)
  427. return uni.showToast({
  428. title: `数据加载完毕`
  429. });
  430. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  431. if (this.loading) return;
  432. this.pageNo += 1;
  433. this.showCheckboxShow(this.pageNo);
  434. }
  435. }
  436. };
  437. </script>
  438. <style lang="scss" scoped>
  439. page {
  440. height: 100%;
  441. background-color: #f5f7f9;
  442. position: relative;
  443. }
  444. body{
  445. background-color: #f5f7f9;
  446. }
  447. .buttomBorder {
  448. height: 0px;
  449. border: 1px dashed #cbd5e1;
  450. }
  451. /deep/ .uni-section .uni-section-header {
  452. padding: 0px;
  453. }
  454. /deep/ .u-form-item__body {
  455. font-weight: 500;
  456. flex-direction: column !important;
  457. }
  458. /deep/ .u-form-item__body__left__content__label {
  459. margin-bottom: 16rpx;
  460. font-size: 30rpx !important;
  461. color: #274647 !important;
  462. }
  463. .arrow-icon {
  464. //主动检查箭头
  465. position: absolute;
  466. right: 14px;
  467. top: 49px;
  468. transform: rotate(90deg);
  469. }
  470. /deep/ .u-input[data-v-fdbb9fe6],
  471. /deep/ .u-input.data-v-fdbb9fe6,
  472. /deep/ .u-input {
  473. background-color: #fff;
  474. }
  475. /deep/.u-button[data-v-3bf2dba7],
  476. /deep/.u-button.data-v-3bf2dba7,
  477. /deep/.u-button {
  478. width: 60% !important;
  479. }
  480. //弹框样式
  481. .btnList {
  482. // width: 40%;
  483. display: flex;
  484. // display:flex;
  485. .u-button[data-v-3bf2dba7] {
  486. width: 30%;
  487. }
  488. }
  489. /deep/ .u-popup__content {
  490. //弹出的宽高
  491. height: 100%;
  492. }
  493. /deep/ .u-form-item__body__right__message {
  494. //校验的文字的位置
  495. margin-left: 10rpx !important;
  496. }
  497. /deep/ .uicon-close {
  498. //关闭按钮背景色
  499. background-color: rgba(199, 203, 210, 0.9);
  500. border-radius: 10%;
  501. }
  502. .checkbox {
  503. .checkbox-item {
  504. box-sizing: border-box;
  505. padding-top: 40px;
  506. }
  507. }
  508. //侧边联动
  509. .page-body {
  510. display: flex;
  511. background: #fff;
  512. overflow: hidden;
  513. }
  514. .nav {
  515. display: flex;
  516. width: 100%;
  517. }
  518. .nav-left {
  519. width: 25%;
  520. background: #fafafa;
  521. }
  522. .nav-left-item {
  523. height: 100upx;
  524. border-right: solid 1px #f1f1f1;
  525. border-bottom: solid 1px #f1f1f1;
  526. font-size: 30upx;
  527. display: flex;
  528. align-items: center;
  529. justify-content: center;
  530. }
  531. /deep/.nav-right-item[data-v-73caef23] {
  532. display: flex;
  533. flex-wrap: wrap;
  534. }
  535. .nav-left-item:last-child {
  536. border-bottom: none;
  537. }
  538. .nav-right {
  539. width: 75%;
  540. }
  541. .box {
  542. display: block;
  543. overflow: hidden;
  544. border-bottom: 20upx solid #f3f3f3;
  545. /* min-height: 100vh; */
  546. /*若您的子分类过少想使得每个子分类占满屏请放开上边注视 */
  547. }
  548. .box:last-child {
  549. border: none;
  550. // min-height: 100vh;
  551. }
  552. .nav-right-item {
  553. margin-top: 20px;
  554. // width: 28%;
  555. // min-height: 200upx;
  556. float: left;
  557. text-align: center;
  558. padding: 11upx;
  559. font-size: 28upx;
  560. background: #fff;
  561. /deep/.u-checkbox__icon-wrap[data-v-532d01c7],
  562. /deep/.u-checkbox__icon-wrap {
  563. //复选框的样式
  564. margin: 0 20rpx;
  565. }
  566. /deep/ uni-view[data-v-3d1b15f2] {
  567. //复选框上线的间距
  568. margin: 20rpx 0 !important;
  569. }
  570. // /deep/ .u-checkbox__icon-wrap--square{
  571. // margin: 20rpx;
  572. // }
  573. .u-checkbox-label--right[data-v-532d01c7],
  574. .u-checkbox-label--right {
  575. margin-right: 40rpx;
  576. }
  577. }
  578. .nav-right-item image {
  579. width: 150upx;
  580. height: 150upx;
  581. }
  582. .active {
  583. font-weight: 700;
  584. color: #274647;
  585. background: #fff;
  586. border-right: 0;
  587. }
  588. ::-webkit-scrollbar {
  589. /*取消小程序的默认导航条样式*/
  590. width: 0;
  591. height: 0;
  592. color: transparent;
  593. }
  594. .selectBtn {
  595. width: 200rpx;
  596. margin-left: 0;
  597. font-size: 30rpx;
  598. background-color: #4cb2b6;
  599. }
  600. .example{
  601. overflow-y: auto;
  602. }
  603. </style>