add_archive3.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  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. console.log(jsdata, 'jsdatajsdatajsdata');
  192. createArchive(jsdata).then(response => {
  193. console.log('response.data.msg,', response.data);
  194. uni.showLoading({
  195. title: response.data.msg
  196. });
  197. uni.hideLoading();
  198. uni.navigateBack({
  199. delta: 1
  200. });
  201. });
  202. })
  203. .catch(err => {
  204. uni.showToast({
  205. icon: 'none',
  206. title: '错误!' + err[0].message
  207. });
  208. console.log('err错误信息为:', err);
  209. });
  210. },
  211. // 隐藏键盘
  212. hideKeyboard() {
  213. uni.hideKeyboard();
  214. if (this.show1 == '0') {
  215. this.show = false
  216. } else {
  217. this.show = true
  218. }
  219. },
  220. // 单位成立时间
  221. ActiveUnitTime(e) {
  222. this.unitTime = false;
  223. let value = new Date(e.value);
  224. console.log(e.value, e.mode);
  225. this.formData.jzsj = uni.$u.timeFormat(e.value, 'yyyy-mm-dd');
  226. },
  227. close() {
  228. this.show = false;
  229. // console.log('close');
  230. },
  231. confirm(e) {
  232. this.show = false;
  233. },
  234. cancel() {
  235. this.show = false;
  236. },
  237. change(e) {
  238. console.log('change', e);
  239. },
  240. info(e) {
  241. this.formData.streetId = e.id;
  242. this.formData.streetName = e.name;
  243. console.log(e.id, e.name);
  244. },
  245. // 回调参数为包含columnIndex、value、values
  246. // 触底的事件
  247. scrolltolower() {
  248. // 判断是否还有下一页数据
  249. if (this.pageNo * this.pageSize >= this.total)
  250. return uni.showToast({
  251. title: `数据加载完毕`
  252. });
  253. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  254. if (this.loading) return;
  255. this.pageNo += 1;
  256. this.showCheckboxShow(this.pageNo);
  257. }
  258. }
  259. };
  260. </script>
  261. <style lang="scss" scoped>
  262. page {
  263. height: 100%;
  264. background-color: #f5f7f9;
  265. position: relative;
  266. }
  267. body {
  268. background-color: #f5f7f9;
  269. }
  270. .buttomBorder {
  271. height: 0px;
  272. border: 1px dashed #cbd5e1;
  273. }
  274. /deep/ .uni-section .uni-section-header {
  275. padding: 0px;
  276. }
  277. /deep/ .u-form-item__body {
  278. font-weight: 500;
  279. flex-direction: column !important;
  280. }
  281. /deep/ .u-form-item__body__left__content__label {
  282. margin-bottom: 16rpx;
  283. font-size: 30rpx !important;
  284. color: #274647 !important;
  285. }
  286. /deep/ .u-input[data-v-fdbb9fe6],
  287. /deep/ .u-input.data-v-fdbb9fe6,
  288. /deep/ .u-input {
  289. background-color: #fff;
  290. }
  291. /deep/.u-button[data-v-3bf2dba7],
  292. /deep/.u-button.data-v-3bf2dba7,
  293. /deep/.u-button {
  294. width: 60% !important;
  295. }
  296. //弹框样式
  297. .btnList {
  298. // width: 40%;
  299. display: flex;
  300. // display:flex;
  301. .u-button[data-v-3bf2dba7],
  302. .u-button {
  303. width: 30%;
  304. }
  305. }
  306. /deep/ .u-popup__content {
  307. //弹出的宽高
  308. // height: 100%;
  309. }
  310. /deep/ .u-form-item__body__right__message {
  311. //校验的文字的位置
  312. margin-left: 10rpx !important;
  313. }
  314. /deep/ .uicon-close {
  315. //关闭按钮背景色
  316. background-color: rgba(199, 203, 210, 0.9);
  317. border-radius: 10%;
  318. }
  319. .checkbox {
  320. .checkbox-item {
  321. box-sizing: border-box;
  322. padding-top: 40px;
  323. }
  324. }
  325. //侧边联动
  326. .page-body {
  327. display: flex;
  328. background: #fff;
  329. overflow: hidden;
  330. }
  331. .nav {
  332. display: flex;
  333. width: 100%;
  334. }
  335. .nav-left {
  336. width: 25%;
  337. background: #fafafa;
  338. }
  339. .nav-left-item {
  340. height: 100upx;
  341. border-right: solid 1px #f1f1f1;
  342. border-bottom: solid 1px #f1f1f1;
  343. font-size: 30upx;
  344. display: flex;
  345. align-items: center;
  346. justify-content: center;
  347. }
  348. /deep/.nav-right-item[data-v-73caef23],
  349. /deep/.nav-right-item {
  350. display: flex;
  351. flex-wrap: wrap;
  352. }
  353. .nav-left-item:last-child {
  354. border-bottom: none;
  355. }
  356. .nav-right {
  357. width: 75%;
  358. }
  359. .box {
  360. display: block;
  361. overflow: hidden;
  362. border-bottom: 20upx solid #f3f3f3;
  363. /* min-height: 100vh; */
  364. /*若您的子分类过少想使得每个子分类占满屏请放开上边注视 */
  365. }
  366. .box:last-child {
  367. border: none;
  368. // min-height: 100vh;
  369. }
  370. .nav-right-item {
  371. margin-top: 20px;
  372. // width: 28%;
  373. // min-height: 200upx;
  374. float: left;
  375. text-align: center;
  376. padding: 11upx;
  377. font-size: 28upx;
  378. background: #fff;
  379. /deep/.u-checkbox__icon-wrap[data-v-532d01c7],
  380. /deep/.u-checkbox__icon-wrap {
  381. //复选框的样式
  382. margin: 0 20rpx;
  383. }
  384. /deep/ uni-view[data-v-3d1b15f2] {
  385. //复选框上线的间距
  386. margin: 20rpx 0 !important;
  387. }
  388. // /deep/ .u-checkbox__icon-wrap--square{
  389. // margin: 20rpx;
  390. // }
  391. .u-checkbox-label--right[data-v-532d01c7],
  392. .u-checkbox-label--right {
  393. margin-right: 40rpx;
  394. }
  395. }
  396. .nav-right-item image {
  397. width: 150upx;
  398. height: 150upx;
  399. }
  400. .active {
  401. font-weight: 700;
  402. color: #274647;
  403. background: #fff;
  404. border-right: 0;
  405. }
  406. ::-webkit-scrollbar {
  407. /*取消小程序的默认导航条样式*/
  408. width: 0;
  409. height: 0;
  410. color: transparent;
  411. }
  412. .selectBtn {
  413. width: 200rpx;
  414. margin-left: 0;
  415. font-size: 30rpx;
  416. background-color: #4cb2b6;
  417. }
  418. .swiper {
  419. height: 370px;
  420. }
  421. .grid-text {
  422. padding-left: 15rpx;
  423. font-weight: 600;
  424. font-size: 16px;
  425. color: #636363;
  426. /* #ifndef APP-PLUS */
  427. box-sizing: border-box;
  428. /* #endif */
  429. }
  430. .example {
  431. overflow-y: auto;
  432. }
  433. </style>