add_archive5.vue 12 KB

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