add_archive4.vue 11 KB

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