add_archive6.vue 10 KB

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