edit_architecture.vue 17 KB

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