add_archive1.vue 12 KB

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