add_archive5.vue 12 KB

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