add_archive4.vue 11 KB

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