add_archive6.vue 10 KB

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