123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451 |
- <template>
- <view class=" uni-container">
- <view class="example container" :style="'height: ' + (screenHeight - wheight - 75) + 'px'">
- <!-- 自定义表单校验 1-->
- <u--form ref="customForm" :model="formData" labelPosition="left" labelWidth="300" labelAlign="left">
- <view class=" flex flex-direction width100">
- <u-form-item label="参加人员及人数 (示例:60人)">
- <u-input v-model="formData.cjryrs" placeholder="请输入参加人员及人数" />
- </u-form-item>
- <u-form-item label="地点 (示例:Xx县xx镇xx街)" prop="xcdd" :required="true">
- <u-input v-model="formData.xcdd" placeholder="请输入地点" />
- </u-form-item>
- <!-- <u-form-item label="所属乡镇街道" prop="streetName" :required="true">
- <u-input
- v-model="formData.streetName"
- placeholder="请选择所属乡镇街道"
- ></u-input>
- </u-form-item> -->
- <u-form-item label="方式 (示例:集中宣传)"><u-input v-model="formData.xcfs"
- placeholder="请输入方式" /></u-form-item>
- <u-form-item label="组织单位及人员 (示例:xx镇安监办共12人)">
- <u-input v-model="formData.zzdwjry" placeholder="请输入组织单位及人员" />
- </u-form-item>
- <u-form-item label="内容">
- <u-textarea auto-height maxlength="-1" v-model="formData.xcnr" placeholder="请输入内容"></u-textarea>
- </u-form-item>
- <u-form-item label="时间">
- <uni-datetime-picker :show="unitTime" v-model="formData.xcsj" mode="date" closeOnClickOverlay
- @confirm="ActiveUnitTime" @cancel="unitTime = false"
- @close="unitTime = false"></uni-datetime-picker>
- </u-form-item>
- <u-form-item label="备注">
- <u-textarea auto-height maxlength="-1" v-model="formData.remark"
- placeholder="请输入备注"></u-textarea>
- </u-form-item>
- </view>
- </u--form>
- <u-popup :show="show" mode="center" :round="15" :closeOnClickOverlay="true" @close="close">
- <view style="height: 390px;width: 350px;">
- <swiper :indicator-dots="true" class="swiper">
- <swiper-item v-for="(i, index) in actionsMaplist" :key="index">
- <u-grid :border="true">
- <u-grid-item :customStyle="{ width: 210 + 'rpx', height: 220 + 'rpx' }"
- v-for="(item, index1) in i" :index="index1" :key="index1"
- @click="info(item), (show = false)">
- <text class="grid-text">{{ item.name }}</text>
- </u-grid-item>
- </u-grid>
- </swiper-item>
- </swiper>
- </view>
- </u-popup>
- </view>
- <uni-row class="heigthButton">
- <u-button @click="submit('customForm')" type="primary" shape="circle" size="large" color="#4CB2B6"
- text="确认新增"></u-button>
- </uni-row>
- </view>
- </template>
- <script>
- import {
- createArchive, // 更新
- getDepartment //获取登陆人的部门信息
- } from '@/api/archive/index6.js';
- var that = null;
- export default {
- data() {
- return {
- screenHeight: this.$screenHeight,
- wheight: '',
- show: false, //所属乡镇街道
- show1: '', // 是否显示弹窗 0不显示
- actionsMaplist: [],
- actions: [],
- // 每页数据量
- pageSize: 5,
- // 当前页
- pageNo: 1,
- // 数据总量
- total: 0,
- unitTime: false,
- loading: false,
- title: '生成隐患',
- content: '确认将此检查项目生成为隐患',
- // 自定义表单数据
- formData: {
- status: '0'
- },
- // 自定义表单校验规则
- customRules: {
- xcdd: {
- type: 'string',
- required: true,
- message: '地点不能为空',
- trigger: ['blur', 'change']
- }
- }
- };
- },
- computed: {},
- mounted() {
- uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
- this.wheight = data.height
- }).exec()
- },
- onLoad: function(option) {
- // 以下内容都是为了 选择街道
- const deptValue = uni.getStorageSync('getDepartment_key'); //所有街道
- const deptId = uni.getStorageSync('getUserInfo_key')?.streetInfo?.id //登录用户的街道id
- var newArrar = {}; //新对象
- // 如果存在街道id,就直接取出对应的名称
- if (deptId) {
- newArrar = deptValue.find((item) => {
- if (item.id === deptId) {
- this.formData.streetId = item.id;
- this.formData.streetName = item.name;
- }
- })
- // show1 ='0' 点击将不再显示弹窗
- this.show1 = '0'
- // 如果没有街道id,就获取所有街道id,选择一个街道提交
- } else {
- // 获取所有街道
- // storage存储的街道值不为空就执行
- if (deptValue.length > 0) {
- deptValue.map(v => {
- this.actions.push({
- id: v.id,
- name: v.name
- });
- });
- // 如果本地storage为空就执行网络请求,获取所有部门
- } else {
- getDepartment({}).then(res => {
- if (res.data.length > 0) {
- deptValue.map(v => {
- this.actions.push({
- id: v.id,
- name: v.name
- });
- });
- }
- })
- }
- this.actionsMaplist = this.splitArray(this.actions, 9);
- }
- },
- onReady() {
- this.$refs.customForm.setRules(this.customRules);
- },
- methods: {
- // size每组数组多少个,如:10
- // array需要拆分的数组
- splitArray(array, size) {
- let data = [];
- for (let i = 0; i < array.length; i += size) {
- data.push(array.slice(i, i + size));
- }
- return data;
- },
- submit(ref) {
- this.$refs[ref]
- .validate()
- .then(res => {
- this.formData['status'] = 0;
- var jsdata = JSON.stringify(this.formData);
- console.log(jsdata, 'jsdatajsdatajsdata');
- createArchive(jsdata).then(response => {
- console.log('response.data.msg,', response.data);
- uni.showLoading({
- title: response.data.msg
- });
- uni.hideLoading();
- uni.navigateBack({
- delta: 1
- });
- });
- })
- .catch(err => {
- uni.showToast({
- icon: 'none',
- title: '错误!' + err[0].message
- });
- console.log('err错误信息为:', err);
- });
- },
- // 隐藏键盘
- hideKeyboard() {
- uni.hideKeyboard();
- if (this.show1 == '0') {
- this.show = false
- } else {
- this.show = true
- }
- },
- // 单位成立时间
- ActiveUnitTime(e) {
- this.unitTime = false;
- let value = new Date(e.value);
- console.log(e.value, e.mode);
- this.formData.xcsj = uni.$u.timeFormat(e.value, 'yyyy-mm-dd');
- },
- close() {
- this.show = false;
- // console.log('close');
- },
- confirm(e) {
- this.show = false;
- },
- cancel() {
- this.show = false;
- },
- change(e) {
- console.log('change', e);
- },
- info(e) {
- this.formData.streetId = e.id;
- this.formData.streetName = e.name;
- console.log(e.id, e.name);
- },
- // 回调参数为包含columnIndex、value、values
- // 触底的事件
- scrolltolower() {
- // 判断是否还有下一页数据
- if (this.pageNo * this.pageSize >= this.total)
- return uni.showToast({
- title: `数据加载完毕`
- });
- // 判断是否正在请求其它数据,如果是,则不发起额外的请求
- if (this.loading) return;
- this.pageNo += 1;
- this.showCheckboxShow(this.pageNo);
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- page {
- height: 100%;
- background-color: #f5f7f9;
- position: relative;
- }
- body {
- background-color: #f5f7f9;
- }
- .buttomBorder {
- height: 0px;
- border: 1px dashed #cbd5e1;
- }
- /deep/ .uni-section .uni-section-header {
- padding: 0px;
- }
- /deep/ .u-form-item__body {
- font-weight: 500;
- flex-direction: column !important;
- }
- /deep/ .u-form-item__body__left__content__label {
- margin-bottom: 16rpx;
- font-size: 30rpx !important;
- color: #274647 !important;
- }
- /deep/ .u-input[data-v-fdbb9fe6],
- /deep/ .u-input.data-v-fdbb9fe6,
- /deep/ .u-input {
- background-color: #fff;
- }
- /deep/.u-button[data-v-3bf2dba7],
- /deep/.u-button.data-v-3bf2dba7,
- /deep/.u-button {
- width: 60% !important;
- }
- //弹框样式
- .btnList {
- // width: 40%;
- display: flex;
- // display:flex;
- .u-button[data-v-3bf2dba7],
- .u-button {
- width: 30%;
- }
- }
- /deep/ .u-popup__content {
- //弹出的宽高
- // height: 100%;
- }
- /deep/ .u-form-item__body__right__message {
- //校验的文字的位置
- margin-left: 10rpx !important;
- }
- /deep/ .uicon-close {
- //关闭按钮背景色
- background-color: rgba(199, 203, 210, 0.9);
- border-radius: 10%;
- }
- .checkbox {
- .checkbox-item {
- box-sizing: border-box;
- padding-top: 40px;
- }
- }
- //侧边联动
- .page-body {
- display: flex;
- background: #fff;
- overflow: hidden;
- }
- .nav {
- display: flex;
- width: 100%;
- }
- .nav-left {
- width: 25%;
- background: #fafafa;
- }
- .nav-left-item {
- height: 100upx;
- border-right: solid 1px #f1f1f1;
- border-bottom: solid 1px #f1f1f1;
- font-size: 30upx;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- /deep/.nav-right-item[data-v-73caef23],
- /deep/.nav-right-item {
- display: flex;
- flex-wrap: wrap;
- }
- .nav-left-item:last-child {
- border-bottom: none;
- }
- .nav-right {
- width: 75%;
- }
- .box {
- display: block;
- overflow: hidden;
- border-bottom: 20upx solid #f3f3f3;
- /* min-height: 100vh; */
- /*若您的子分类过少想使得每个子分类占满屏请放开上边注视 */
- }
- .box:last-child {
- border: none;
- // min-height: 100vh;
- }
- .nav-right-item {
- margin-top: 20px;
- // width: 28%;
- // min-height: 200upx;
- float: left;
- text-align: center;
- padding: 11upx;
- font-size: 28upx;
- background: #fff;
- /deep/.u-checkbox__icon-wrap[data-v-532d01c7],
- /deep/.u-checkbox__icon-wrap {
- //复选框的样式
- margin: 0 20rpx;
- }
- /deep/ uni-view[data-v-3d1b15f2] {
- //复选框上线的间距
- margin: 20rpx 0 !important;
- }
- // /deep/ .u-checkbox__icon-wrap--square{
- // margin: 20rpx;
- // }
- .u-checkbox-label--right[data-v-532d01c7] {
- margin-right: 40rpx;
- }
- }
- .nav-right-item image {
- width: 150upx;
- height: 150upx;
- }
- .active {
- font-weight: 700;
- color: #274647;
- background: #fff;
- border-right: 0;
- }
- ::-webkit-scrollbar {
- /*取消小程序的默认导航条样式*/
- width: 0;
- height: 0;
- color: transparent;
- }
- .selectBtn {
- width: 200rpx;
- margin-left: 0;
- font-size: 30rpx;
- background-color: #4cb2b6;
- }
- .swiper {
- height: 370px;
- }
- .grid-text {
- padding-left: 15rpx;
- font-weight: 600;
- font-size: 16px;
- color: #636363;
- /* #ifndef APP-PLUS */
- box-sizing: border-box;
- /* #endif */
- }
- .example {
- overflow-y: auto;
- }
- </style>
|