add_archive3.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  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="300" labelAlign="left">
  6. <view class=" flex flex-direction width100">
  7. <u-form-item label="名称 (示例:Xx宾馆)" :required="true" prop="mc">
  8. <u-input v-model="formData.mc" placeholder="必填。请输入名称" />
  9. </u-form-item>
  10. <u-form-item label="所在建筑名称 (示例:Xx商住楼)" :required="true">
  11. <u-input v-model="formData.szjzmc" placeholder="必填。所在建筑名称" />
  12. </u-form-item>
  13. <u-form-item label="消防安全管理人及联系电话" :required="true" prop="xfaqglr">
  14. <u-input v-model="formData.xfaqglr" placeholder="请输入消防安全管理人及联系电话" />
  15. </u-form-item>
  16. <u-form-item label="消防安全责任人及联系电话 " :required="true" prop="xfaqzrr">
  17. <u-input v-model="formData.xfaqzrr" placeholder="请输入消防安全责任人及联系电话" />
  18. </u-form-item>
  19. <u-form-item label="类别 (示例:宾馆)">
  20. <u-input v-model="formData.lb" placeholder="请输入类别" />
  21. </u-form-item>
  22. <u-form-item label="性质 (示例:其他个体工商户)">
  23. <u-input v-model="formData.xz" placeholder="请输入性质" />
  24. </u-form-item>
  25. <!-- <u-form-item label="所属乡镇街道" prop="streetName" :required="true">
  26. <u-input
  27. v-model="formData.streetName"
  28. placeholder="请选择所属乡镇街道"
  29. ></u-input>
  30. </u-form-item> -->
  31. <u-form-item label="地址"><u-input v-model="formData.dz" placeholder="请输入地址" /></u-form-item>
  32. <u-form-item label="使用楼层、面积 (示例:1层,300平方米)">
  33. <u-input v-model="formData.sylcmj" placeholder="请输入使用楼层、面积" />
  34. </u-form-item>
  35. <u-form-item label="消防设施器材情况 (示例:自动火灾报警系统、)">
  36. <u-input v-model="formData.xfssqc" placeholder="请输入消防设施器材情况" />
  37. </u-form-item>
  38. <u-form-item label="备注">
  39. <u-textarea auto-height maxlength="-1" v-model="formData.remark"
  40. placeholder="请输入备注"></u-textarea>
  41. </u-form-item>
  42. </view>
  43. </u--form>
  44. <u-popup :show="show" mode="center" :round="15" :closeOnClickOverlay="true" @close="close">
  45. <view style="height: 390px;width: 350px;">
  46. <swiper :indicator-dots="true" class="swiper">
  47. <swiper-item v-for="(i, index) in actionsMaplist" :key="index">
  48. <u-grid :border="true">
  49. <u-grid-item :customStyle="{ width: 210 + 'rpx', height: 220 + 'rpx' }"
  50. v-for="(item, index1) in i" :index="index1" :key="index1"
  51. @click="info(item), (show = false)">
  52. <text class="grid-text">{{ item.name }}</text>
  53. </u-grid-item>
  54. </u-grid>
  55. </swiper-item>
  56. </swiper>
  57. </view>
  58. </u-popup>
  59. </view>
  60. <uni-row class="heigthButton">
  61. <u-button @click="submit('customForm')" type="primary" shape="circle" size="large" color="#4CB2B6"
  62. text="确认新增"></u-button>
  63. </uni-row>
  64. </view>
  65. </template>
  66. <script>
  67. import {
  68. createArchive, // 更新
  69. getDepartment //获取登陆人的部门信息
  70. } from '@/api/archive/index3.js';
  71. var that = null;
  72. export default {
  73. data() {
  74. return {
  75. screenHeight: this.$screenHeight,
  76. wheight: '',
  77. show: false, //所属乡镇街道
  78. show1: '', // 是否显示弹窗 0不显示
  79. actionsMaplist: [],
  80. actions: [],
  81. // 每页数据量
  82. pageSize: 5,
  83. // 当前页
  84. pageNo: 1,
  85. // 数据总量
  86. total: 0,
  87. unitTime: false,
  88. loading: false,
  89. title: '生成隐患',
  90. content: '确认将此检查项目生成为隐患',
  91. // 自定义表单数据
  92. formData: {
  93. status: '0'
  94. },
  95. // 自定义表单校验规则
  96. customRules: {
  97. streetName: {
  98. type: 'string',
  99. required: true,
  100. message: '所属乡镇街道不能为空',
  101. trigger: ['blur', 'change']
  102. },
  103. mc: {
  104. type: 'string',
  105. required: true,
  106. message: '名称不能为空',
  107. trigger: ['blur', 'change']
  108. },
  109. xfaqglr: {
  110. type: 'string',
  111. required: true,
  112. message: '消防安全管理人及联系电话不能为空',
  113. trigger: ['blur', 'change']
  114. },
  115. xfaqzrr: {
  116. type: 'string',
  117. required: true,
  118. message: '消防安全责任人及联系电话不能为空',
  119. trigger: ['blur', 'change']
  120. },
  121. }
  122. };
  123. },
  124. computed: {},
  125. mounted() {
  126. uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
  127. this.wheight = data.height
  128. }).exec()
  129. },
  130. onLoad: function(option) {
  131. // 以下内容都是为了 选择街道
  132. const deptValue = uni.getStorageSync('getDepartment_key'); //所有街道
  133. const deptId = uni.getStorageSync('getUserInfo_key')?.streetInfo?.id; //登录用户的街道id
  134. var newArrar = {}; //新对象
  135. // 如果存在街道id,就直接取出对应的名称
  136. if (deptId) {
  137. newArrar = deptValue.find((item) => {
  138. if (item.id === deptId) {
  139. this.formData.streetId = item.id;
  140. this.formData.streetName = item.name;
  141. }
  142. })
  143. // show1 ='0' 点击将不再显示弹窗
  144. this.show1 = '0'
  145. // 如果没有街道id,就获取所有街道id,选择一个街道提交
  146. } else {
  147. // 获取所有街道
  148. // storage存储的街道值不为空就执行
  149. if (deptValue.length > 0) {
  150. deptValue.map(v => {
  151. this.actions.push({
  152. id: v.id,
  153. name: v.name
  154. });
  155. });
  156. // 如果本地storage为空就执行网络请求,获取所有部门
  157. } else {
  158. getDepartment({}).then(res => {
  159. if (res.data.length > 0) {
  160. deptValue.map(v => {
  161. this.actions.push({
  162. id: v.id,
  163. name: v.name
  164. });
  165. });
  166. }
  167. })
  168. }
  169. this.actionsMaplist = this.splitArray(this.actions, 9);
  170. }
  171. },
  172. onReady() {
  173. this.$refs.customForm.setRules(this.customRules);
  174. },
  175. methods: {
  176. // size每组数组多少个,如:10
  177. // array需要拆分的数组
  178. splitArray(array, size) {
  179. let data = [];
  180. for (let i = 0; i < array.length; i += size) {
  181. data.push(array.slice(i, i + size));
  182. }
  183. return data;
  184. },
  185. submit(ref) {
  186. this.$refs[ref]
  187. .validate()
  188. .then(res => {
  189. this.formData['status'] = 0;
  190. var jsdata = JSON.stringify(this.formData);
  191. createArchive(jsdata).then(response => {
  192. uni.showLoading({
  193. title: response.data.msg
  194. });
  195. uni.hideLoading();
  196. uni.navigateBack({
  197. delta: 1
  198. });
  199. });
  200. })
  201. .catch(err => {
  202. uni.showToast({
  203. icon: 'none',
  204. title: '错误!' + err[0].message
  205. });
  206. });
  207. },
  208. // 隐藏键盘
  209. hideKeyboard() {
  210. uni.hideKeyboard();
  211. if (this.show1 == '0') {
  212. this.show = false
  213. } else {
  214. this.show = true
  215. }
  216. },
  217. // 单位成立时间
  218. ActiveUnitTime(e) {
  219. this.unitTime = false;
  220. let value = new Date(e.value);
  221. this.formData.jzsj = uni.$u.timeFormat(e.value, 'yyyy-mm-dd');
  222. },
  223. close() {
  224. this.show = false;
  225. },
  226. confirm(e) {
  227. this.show = false;
  228. },
  229. cancel() {
  230. this.show = false;
  231. },
  232. change(e) {
  233. },
  234. info(e) {
  235. this.formData.streetId = e.id;
  236. this.formData.streetName = e.name;
  237. },
  238. // 回调参数为包含columnIndex、value、values
  239. // 触底的事件
  240. scrolltolower() {
  241. // 判断是否还有下一页数据
  242. if (this.pageNo * this.pageSize >= this.total)
  243. return uni.showToast({
  244. title: `数据加载完毕`
  245. });
  246. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  247. if (this.loading) return;
  248. this.pageNo += 1;
  249. this.showCheckboxShow(this.pageNo);
  250. }
  251. }
  252. };
  253. </script>
  254. <style lang="scss" scoped>
  255. page {
  256. height: 100%;
  257. background-color: #f5f7f9;
  258. position: relative;
  259. }
  260. body {
  261. background-color: #f5f7f9;
  262. }
  263. .buttomBorder {
  264. height: 0px;
  265. border: 1px dashed #cbd5e1;
  266. }
  267. /deep/ .uni-section .uni-section-header {
  268. padding: 0px;
  269. }
  270. /deep/ .u-form-item__body {
  271. font-weight: 500;
  272. flex-direction: column !important;
  273. }
  274. /deep/ .u-form-item__body__left__content__label {
  275. margin-bottom: 16rpx;
  276. font-size: 30rpx !important;
  277. color: #274647 !important;
  278. }
  279. /deep/ .u-input[data-v-fdbb9fe6],
  280. /deep/ .u-input.data-v-fdbb9fe6,
  281. /deep/ .u-input {
  282. background-color: #fff;
  283. }
  284. /deep/.u-button[data-v-3bf2dba7],
  285. /deep/.u-button.data-v-3bf2dba7,
  286. /deep/.u-button {
  287. width: 60% !important;
  288. }
  289. //弹框样式
  290. .btnList {
  291. // width: 40%;
  292. display: flex;
  293. // display:flex;
  294. .u-button[data-v-3bf2dba7],
  295. .u-button {
  296. width: 30%;
  297. }
  298. }
  299. /deep/ .u-popup__content {
  300. //弹出的宽高
  301. // height: 100%;
  302. }
  303. /deep/ .u-form-item__body__right__message {
  304. //校验的文字的位置
  305. margin-left: 10rpx !important;
  306. }
  307. /deep/ .uicon-close {
  308. //关闭按钮背景色
  309. background-color: rgba(199, 203, 210, 0.9);
  310. border-radius: 10%;
  311. }
  312. .checkbox {
  313. .checkbox-item {
  314. box-sizing: border-box;
  315. padding-top: 40px;
  316. }
  317. }
  318. //侧边联动
  319. .page-body {
  320. display: flex;
  321. background: #fff;
  322. overflow: hidden;
  323. }
  324. .nav {
  325. display: flex;
  326. width: 100%;
  327. }
  328. .nav-left {
  329. width: 25%;
  330. background: #fafafa;
  331. }
  332. .nav-left-item {
  333. height: 100upx;
  334. border-right: solid 1px #f1f1f1;
  335. border-bottom: solid 1px #f1f1f1;
  336. font-size: 30upx;
  337. display: flex;
  338. align-items: center;
  339. justify-content: center;
  340. }
  341. /deep/.nav-right-item[data-v-73caef23],
  342. /deep/.nav-right-item {
  343. display: flex;
  344. flex-wrap: wrap;
  345. }
  346. .nav-left-item:last-child {
  347. border-bottom: none;
  348. }
  349. .nav-right {
  350. width: 75%;
  351. }
  352. .box {
  353. display: block;
  354. overflow: hidden;
  355. border-bottom: 20upx solid #f3f3f3;
  356. /* min-height: 100vh; */
  357. /*若您的子分类过少想使得每个子分类占满屏请放开上边注视 */
  358. }
  359. .box:last-child {
  360. border: none;
  361. // min-height: 100vh;
  362. }
  363. .nav-right-item {
  364. margin-top: 20px;
  365. // width: 28%;
  366. // min-height: 200upx;
  367. float: left;
  368. text-align: center;
  369. padding: 11upx;
  370. font-size: 28upx;
  371. background: #fff;
  372. /deep/.u-checkbox__icon-wrap[data-v-532d01c7],
  373. /deep/.u-checkbox__icon-wrap {
  374. //复选框的样式
  375. margin: 0 20rpx;
  376. }
  377. /deep/ uni-view[data-v-3d1b15f2] {
  378. //复选框上线的间距
  379. margin: 20rpx 0 !important;
  380. }
  381. // /deep/ .u-checkbox__icon-wrap--square{
  382. // margin: 20rpx;
  383. // }
  384. .u-checkbox-label--right[data-v-532d01c7],
  385. .u-checkbox-label--right {
  386. margin-right: 40rpx;
  387. }
  388. }
  389. .nav-right-item image {
  390. width: 150upx;
  391. height: 150upx;
  392. }
  393. .active {
  394. font-weight: 700;
  395. color: #274647;
  396. background: #fff;
  397. border-right: 0;
  398. }
  399. ::-webkit-scrollbar {
  400. /*取消小程序的默认导航条样式*/
  401. width: 0;
  402. height: 0;
  403. color: transparent;
  404. }
  405. .selectBtn {
  406. width: 200rpx;
  407. margin-left: 0;
  408. font-size: 30rpx;
  409. background-color: #4cb2b6;
  410. }
  411. .swiper {
  412. height: 370px;
  413. }
  414. .grid-text {
  415. padding-left: 15rpx;
  416. font-weight: 600;
  417. font-size: 16px;
  418. color: #636363;
  419. /* #ifndef APP-PLUS */
  420. box-sizing: border-box;
  421. /* #endif */
  422. }
  423. .example {
  424. overflow-y: auto;
  425. }
  426. </style>