add ticket

master
张 元山 11 months ago
parent 3cf407e0d9
commit 181a62b159

@ -16,4 +16,10 @@
<style lang="scss"> <style lang="scss">
/*每个页面公共css */ /*每个页面公共css */
@import "uview-ui/index.scss"; @import "uview-ui/index.scss";
@import "@/common/default.scss";
page {
background: url("./static/bg-common.png") no-repeat;
background-size: 100% 100%;
background-attachment: fixed;
}
</style> </style>

@ -0,0 +1,681 @@
.flex,
.row {
display: flex;
flex-wrap: wrap;
}
.flex > .col,
.flex > .col-0,
.flex > .col-1,
.flex > .col-2,
.flex > .col-3,
.flex > .col-4,
.flex > .col-5,
.flex > .col-6,
.flex > .col-7,
.flex > .col-8,
.flex > .col-9,
.flex > .col-10,
.flex > .col-11,
.flex > .col-12,
.flex > .col-auto,
.flex > .col-grow,
.flex > .col-shrink,
.flex > .col-xs,
.flex > .col-xs-0,
.flex > .col-xs-1,
.flex > .col-xs-2,
.flex > .col-xs-3,
.flex > .col-xs-4,
.flex > .col-xs-5,
.flex > .col-xs-6,
.flex > .col-xs-7,
.flex > .col-xs-8,
.flex > .col-xs-9,
.flex > .col-xs-10,
.flex > .col-xs-11,
.flex > .col-xs-12,
.flex > .col-xs-auto,
.flex > .col-xs-grow,
.flex > .col-xs-shrink,
.row > .col,
.row > .col-0,
.row > .col-1,
.row > .col-2,
.row > .col-3,
.row > .col-4,
.row > .col-5,
.row > .col-6,
.row > .col-7,
.row > .col-8,
.row > .col-9,
.row > .col-10,
.row > .col-11,
.row > .col-12,
.row > .col-auto,
.row > .col-grow,
.row > .col-shrink,
.row > .col-xs,
.row > .col-xs-0,
.row > .col-xs-1,
.row > .col-xs-2,
.row > .col-xs-3,
.row > .col-xs-4,
.row > .col-xs-5,
.row > .col-xs-6,
.row > .col-xs-7,
.row > .col-xs-8,
.row > .col-xs-9,
.row > .col-xs-10,
.row > .col-xs-11,
.row > .col-xs-12,
.row > .col-xs-auto,
.row > .col-xs-grow,
.row > .col-xs-shrink {
width: auto;
min-width: 0;
max-width: 100%;
}
.flex > .col,
.flex > .col-0,
.flex > .col-1,
.flex > .col-2,
.flex > .col-3,
.flex > .col-4,
.flex > .col-5,
.flex > .col-6,
.flex > .col-7,
.flex > .col-8,
.flex > .col-9,
.flex > .col-10,
.flex > .col-11,
.flex > .col-12,
.flex > .col-auto,
.flex > .col-grow,
.flex > .col-shrink,
.flex > .col-xs,
.flex > .col-xs-0,
.flex > .col-xs-1,
.flex > .col-xs-2,
.flex > .col-xs-3,
.flex > .col-xs-4,
.flex > .col-xs-5,
.flex > .col-xs-6,
.flex > .col-xs-7,
.flex > .col-xs-8,
.flex > .col-xs-9,
.flex > .col-xs-10,
.flex > .col-xs-11,
.flex > .col-xs-12,
.flex > .col-xs-auto,
.flex > .col-xs-grow,
.flex > .col-xs-shrink {
height: auto;
min-height: 0;
max-height: 100%;
}
.col,
.col-xs {
flex: 10000 1 0%;
}
.col-0,
.col-1,
.col-2,
.col-3,
.col-4,
.col-5,
.col-6,
.col-7,
.col-8,
.col-9,
.col-10,
.col-11,
.col-12,
.col-auto,
.col-xs-0,
.col-xs-1,
.col-xs-2,
.col-xs-3,
.col-xs-4,
.col-xs-5,
.col-xs-6,
.col-xs-7,
.col-xs-8,
.col-xs-9,
.col-xs-10,
.col-xs-11,
.col-xs-12,
.col-xs-auto {
flex: 0 0 auto;
}
.col-grow,
.col-xs-grow {
flex: 1 0 auto;
}
.col-shrink,
.col-xs-shrink {
flex: 0 1 auto;
}
.row > .col-0,
.row > .col-xs-0 {
height: auto;
width: 0%;
}
.row > .offset-0,
.row > .offset-xs-0 {
margin-left: 0%;
}
.row > .col-1,
.row > .col-xs-1 {
height: auto;
width: 8.3333%;
}
.row > .offset-1,
.row > .offset-xs-1 {
margin-left: 8.3333%;
}
.row > .col-2,
.row > .col-xs-2 {
height: auto;
width: 16.6667%;
}
.row > .offset-2,
.row > .offset-xs-2 {
margin-left: 16.6667%;
}
.row > .col-3,
.row > .col-xs-3 {
height: auto;
width: 25%;
}
.row > .offset-3,
.row > .offset-xs-3 {
margin-left: 25%;
}
.row > .col-4,
.row > .col-xs-4 {
height: auto;
width: 33.3333%;
}
.row > .offset-4,
.row > .offset-xs-4 {
margin-left: 33.3333%;
}
.row > .col-5,
.row > .col-xs-5 {
height: auto;
width: 41.6667%;
}
.row > .offset-5,
.row > .offset-xs-5 {
margin-left: 41.6667%;
}
.row > .col-6,
.row > .col-xs-6 {
height: auto;
width: 50%;
}
.row > .offset-6,
.row > .offset-xs-6 {
margin-left: 50%;
}
.row > .col-7,
.row > .col-xs-7 {
height: auto;
width: 58.3333%;
}
.row > .offset-7,
.row > .offset-xs-7 {
margin-left: 58.3333%;
}
.row > .col-8,
.row > .col-xs-8 {
height: auto;
width: 66.6667%;
}
.row > .offset-8,
.row > .offset-xs-8 {
margin-left: 66.6667%;
}
.row > .col-9,
.row > .col-xs-9 {
height: auto;
width: 75%;
}
.row > .offset-9,
.row > .offset-xs-9 {
margin-left: 75%;
}
.row > .col-10,
.row > .col-xs-10 {
height: auto;
width: 83.3333%;
}
.row > .offset-10,
.row > .offset-xs-10 {
margin-left: 83.3333%;
}
.row > .col-11,
.row > .col-xs-11 {
height: auto;
width: 91.6667%;
}
.row > .offset-11,
.row > .offset-xs-11 {
margin-left: 91.6667%;
}
.row > .col-12,
.row > .col-xs-12 {
height: auto;
width: 100%;
}
.row > .offset-12,
.row > .offset-xs-12 {
margin-left: 100%;
}
.row > .col-all {
height: auto;
flex: 0 0 100%;
}
.cursor {
cursor: pointer;
}
.link-cursor {
cursor: pointer;
text-decoration: underline;
color: #027be3;
}
.bg-grey {
background: #c7bfbf !important;
}
.bg-primary {
background-color: #3aace8 !important;
}
.bg-danger {
background-color: #ef136e;
}
.bg-231 {
background-color: #e7e7e7;
}
.bg-blue {
background: #2196f3 !important;
}
.h-100 {
height: 100vh;
}
.w-100 {
width: 100vw;
}
.height-100 {
height: 100%;
}
.width-100 {
width: 100%;
}
.fl-page-width {
max-width: 1200px;
margin: auto;
}
.relative {
position: relative;
}
.absolute {
position: absolute;
}
.text-ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.overflow-auto {
overflow: auto;
}
/*下三角*/
.tip-bottom {
position: relative;
/*设置圆角*/
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.tip-bottom:after {
content: "";
display: block;
border-width: 25px;
position: absolute;
bottom: -30px;
left: 50px;
border-style: solid dashed dashed solid;
border-color: rgb(255, 255, 255) transparent transparent transparent;
font-size: 0;
line-height: 0;
transform: rotate(224deg);
}
.tip-bottom:after {
bottom: -20px;
}
.text-center {
text-align: center !important;
}
.text-right {
text-align: right !important;
}
.text-left {
text-align: left !important;
}
.align-center {
align-items: center;
}
.flex-wrap {
flex-wrap: wrap;
}
.column {
flex-direction: column;
}
.items-start {
align-items: flex-start !important;
}
.justify-between {
justify-content: space-between;
}
.justify-around {
justify-content: space-around;
}
.justify-end {
justify-content: flex-end;
}
.justify-center {
justify-content: center;
}
.fl-pa-sm {
padding: 8px !important;
}
.fl-pb-xs {
padding-bottom: 4px !important;
}
.fl-mx-xs {
margin-left: 4px !important;
margin-right: 4px !important;
}
.fl-my-xs {
margin-top: 4px !important;
margin-bottom: 4px !important;
}
.fl-ml-xs {
margin-left: 4px !important;
}
.fl-mt-xs {
margin-top: 4px !important;
}
.fl-pt-xs {
padding-top: 4px !important;
}
.fl-pl-xs {
padding-left: 4px !important;
}
.fl-pl-sm {
padding-left: 8px !important;
}
.fl-pr-sm {
padding-right: 8px !important;
}
.fl-pt-sm {
padding-top: 8px !important;
}
.fl-pb-sm {
padding-bottom: 8px !important;
}
.fl-px-sm {
padding-left: 8px !important;
padding-right: 8px !important;
}
.fl-px-xs {
padding-left: 4px !important;
padding-right: 4px !important;
}
.fl-py-sm {
padding-top: 8px !important;
padding-bottom: 8px !important;
}
.fl-pa-md {
padding: 16px !important;
}
.fl-pl-md {
padding-left: 16px !important;
}
.fl-pr-md {
padding-right: 16px !important;
}
.fl-pt-md {
padding-top: 16px !important;
}
.fl-pb-md {
padding-bottom: 16px !important;
}
.fl-px-md {
padding-left: 16px !important;
padding-right: 16px !important;
}
.fl-py-md {
padding-top: 16px !important;
padding-bottom: 16px !important;
}
.fl-pa-lg {
padding: 24px !important;
}
.fl-pl-lg {
padding-left: 24px !important;
}
.fl-pr-lg {
padding-right: 24px !important;
}
.fl-pt-lg {
padding-top: 24px !important;
}
.fl-pb-lg {
padding-bottom: 24px !important;
}
.fl-px-lg {
padding-left: 24px !important;
padding-right: 24px !important;
}
.fl-py-lg {
padding-top: 24px !important;
padding-bottom: 24px !important;
}
.fl-ma-sm {
margin: 8px !important;
}
.fl-ma-xs {
margin: 4px !important;
}
.fl-ml-sm {
margin-left: 8px !important;
}
.fl-mr-sm {
margin-right: 8px !important;
}
.fl-mt-sm {
margin-top: 8px !important;
}
.fl-mb-sm {
margin-bottom: 8px !important;
}
.fl-mx-sm {
margin-left: 8px !important;
margin-right: 8px !important;
}
.fl-my-sm {
margin-top: 8px !important;
margin-bottom: 8px !important;
}
.fl-ma-md {
margin: 16px !important;
}
.fl-ml-md {
margin-left: 16px !important;
}
.fl-mr-md {
margin-right: 16px !important;
}
.fl-mt-md {
margin-top: 16px !important;
}
.fl-mb-md {
margin-bottom: 16px !important;
}
.fl-mx-md {
margin-left: 16px !important;
margin-right: 16px !important;
}
.fl-my-md {
margin-top: 16px !important;
margin-bottom: 16px !important;
}
.fl-ma-lg {
margin: 24px !important;
}
.fl-ml-lg {
margin-left: 24px !important;
}
.fl-mr-lg {
margin-right: 24px !important;
}
.fl-mt-lg {
margin-top: 24px !important;
}
.fl-mb-lg {
margin-bottom: 24px !important;
}
.fl-mx-lg {
margin-left: 24px !important;
margin-right: 24px !important;
}
.fl-my-lg {
margin-top: 24px !important;
margin-bottom: 24px !important;
}
.justify-start {
justify-content: flex-start;
}
.justify-end {
justify-content: flex-end;
}
.justify-center,
.flex-center {
justify-content: center;
}
.justify-between {
justify-content: space-between;
}
.justify-around {
justify-content: space-around;
}
.justify-evenly {
justify-content: space-evenly;
}
.items-start {
align-items: flex-start;
}
.items-end {
align-items: flex-end;
}
.items-center,
.flex-center {
align-items: center;
}
.items-baseline {
align-items: baseline;
}
.items-stretch {
align-items: stretch;
}
.box-border {
box-sizing: border-box;
}
.box-content {
box-sizing: content-box;
}
.width-140 {
width: 280rpx;
}
.width-300 {
width: 600rpx;
}
.no-shadow {
box-shadow: none !important;
}
.border-20 {
border-radius: 20rpx;
}
.fl-link {
cursor: pointer;
text-decoration: underline;
color: #027be3;
}
.border-radius-4 {
border-radius: 4px !important;
}
.border-radius-8 {
border-radius: 8px !important;
}
.border-radius-16 {
border-radius: 16px !important;
}
.margin-auto {
margin: auto;
}
.status_bar {
height: var(--status-bar-height);
width: 100%;
}

@ -0,0 +1,73 @@
<template>
<view>
<view class="status_bar">
<!-- 这里是状态栏 -->
</view>
<view style="height: 110upx">
<u-navbar :bgColor="bgColor"
@rightClick="rightClick"
:autoBack="autoback">
<view v-if="left"
slot="left">
<slot name="left"></slot>
</view>
<view v-if="center"
slot="center">
<slot name="center"></slot>
</view>
<view v-if="right"
slot="right">
<slot name="right"></slot>
</view>
</u-navbar>
</view>
</view>
</template>
<script>
export default {
props: {
left: {
type: Boolean,
default () {
return true;
},
},
center: {
type: Boolean,
default () {
return true;
},
},
right: {
type: Boolean,
default () {
return true;
},
},
autoback: {
type: Boolean,
default () {
return true;
},
},
},
data () {
return {
bgColor: "null",
};
},
methods: {
leftClick () { },
rightClick () { },
},
};
</script>
<style lang="scss" scoped>
::v-deep .u-navbar__content {
background: none !important;
}
</style>

@ -1,41 +1,31 @@
<template> <template>
<view class="content"> <view class="content">
<u-tabbar <u-tabbar :value="value4"
:value="value4"
@change="change" @change="change"
:fixed="true" :fixed="true"
:border="false" :border="false"
:placeholder="false" :placeholder="false"
activeColor="#40BE94" activeColor="#40BE94"
:safeAreaInsetBottom="true" :safeAreaInsetBottom="true">
>
<u-tabbar-item text="场馆"> <u-tabbar-item text="场馆">
<image <image style="width: 52rpx;height: 52rpx"
style="width: 52rpx;height: 52rpx"
class="u-page__item__slot-icon" class="u-page__item__slot-icon"
slot="active-icon" slot="active-icon"
src="../../static/zu618@3x (1).png" src="../../static/zu618@3x (1).png"></image>
></image> <image style="width: 52rpx;height: 52rpx"
<image
style="width: 52rpx;height: 52rpx"
class="u-page__item__slot-icon" class="u-page__item__slot-icon"
slot="inactive-icon" slot="inactive-icon"
src="../../static/zu759@3x.png" src="../../static/zu759@3x.png"></image>
></image>
</u-tabbar-item> </u-tabbar-item>
<u-tabbar-item text="我的"> <u-tabbar-item text="我的">
<image <image style="width: 52rpx;height: 52rpx"
style="width: 52rpx;height: 52rpx"
class="u-page__item__slot-icon" class="u-page__item__slot-icon"
slot="active-icon" slot="active-icon"
src="../../static/zu760@3x.png" src="../../static/zu760@3x.png"></image>
></image> <image style="width: 52rpx;height: 52rpx"
<image
style="width: 52rpx;height: 52rpx"
class="u-page__item__slot-icon" class="u-page__item__slot-icon"
slot="inactive-icon" slot="inactive-icon"
src="../../static/zu628@3x (1).png" src="../../static/zu628@3x (1).png"></image>
></image>
</u-tabbar-item> </u-tabbar-item>
</u-tabbar> </u-tabbar>
</view> </view>
@ -56,7 +46,7 @@ export default {
change (name) { change (name) {
if (name === 0) { if (name === 0) {
uni.switchTab({ uni.switchTab({
url: '/pages/index/index' url: '/pages/ticket/index'
}); });
} else if (name === 1) { } else if (name === 1) {
uni.switchTab({ uni.switchTab({

@ -3,9 +3,12 @@
"^u-(.*)": "@/uview-ui/components/u-$1/u-$1.vue" "^u-(.*)": "@/uview-ui/components/u-$1/u-$1.vue"
}, },
"pages": [ "pages": [
{
"path": "pages/start"
},
//pageshttps://uniapp.dcloud.io/collocation/pages //pageshttps://uniapp.dcloud.io/collocation/pages
{ {
"path": "pages/index/index", "path": "pages/my/my",
"style": { "style": {
"navigationStyle": "custom", "navigationStyle": "custom",
"navigationBarTitleText": "", "navigationBarTitleText": "",
@ -13,9 +16,22 @@
} }
}, },
{ {
"path": "pages/my/my", "path": "pages/ticket/index",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/ticket/elector",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/ticket/reserve",
"style": { "style": {
"navigationStyle": "custom",
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
@ -25,14 +41,17 @@
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app", "navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8", "navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8" "backgroundColor": "#F8F8F8",
"app-plus": {
"titleNView": false
}
}, },
"uniIdRouter": {}, "uniIdRouter": {},
"tabBar": { "tabBar": {
"custom": true, "custom": true,
"list": [ "list": [
{ {
"pagePath": "pages/index/index" "pagePath": "pages/ticket/index"
}, },
{ {

@ -0,0 +1,35 @@
<template>
<view>
</view>
</template>
<script>
export default {
components: {},
data () {
return {
};
},
onLoad () {
setTimeout(() => {
uni.reLaunch({
url: '/pages/ticket/index'
});
}, 1000);
},
onShow () {
},
methods: {
},
};
</script>
<style lang="scss" scope>
page {
background: url("../static/bg-start.png") no-repeat;
background-size: 100% 100%;
background-attachment: fixed;
height: 100vh;
box-sizing: border-box;
}
</style>

@ -0,0 +1,160 @@
<template>
<view>
<fl-page-header :autoback="false">
<template v-slot:center>
<view class="row items-center">
<text class="font-16">智慧门票</text>
</view>
</template>
</fl-page-header>
<view :style="{
minHeight: 'calc(100vh - ' + filterBoxTop + ' - 226rpx'+')',
}">
<view class="row justify-center fl-pt-sm fl-mb-sm">
<view class="row items-center fl-px-sm"
style="font-size:28rpx;border-radius:20rpx;background:#40BE94;color:#fff;height:70rpx;width:calc(100% - 62rpx)">
<text class="col-6 text-center">场馆名称</text>
<text class="col-3 text-center">门票种类</text>
<text class="col-3 text-center">门票预约</text>
</view>
</view>
<u-list v-if="listData.length > 0"
class="col-12"
height="calc(100vh - 310rpx)"
@scrolltolower="scrollRequest">
<u-list-item v-for="(item, index) in listData"
:key="index"
class="fl-mb-sm fl-px-sm">
<view class="fl-card row">
<view class="col-6 font-16 row justify-center items-center">{{item.name}}</view>
<view class="col-3 row justify-center items-center"
:style="{color:item.typeNum!=0?'#40BE94':'#AFAFAF'}">
{{ item.typeNum }}
</view>
<view class="col-3 row justify-center items-center cursur">
<u-button v-if="item.typeNum!=0"
shape="circle"
text="查看"
style="width: 108rpx; height: 56rpx;background:#40BE94;color:#fff"
:loading="item.btnLoading"
@click="handleContractClick(item)" />
<text v-else
class="font-14 row justify-center items-center"
style="width: 108rpx; height: 56rpx;background:#AFAFAF;color:#fff;border-radius:20rpx">暂无</text>
</view>
</view>
</u-list-item>
<view style="width: 100%"
class="row items-center justify-center">
<u-line dashed
:length="110"
style="display: inline-block"></u-line>
<view style="color:#9ebfb3;font-size: 26rpx; margin: 30rpx">~人家是有底线的啦~</view>
<u-line dashed
:length="110"
style="display: inline-block"></u-line>
</view>
</u-list>
</view>
<u-toast ref="uToast" />
<my-tabbar></my-tabbar>
</view>
</template>
<script>
import pageData from "../../static/pageData.json";
import { getLabelByOptions, calcRouteParams } from "@/util/form";
export default {
data () {
return {
pageType: "unfinish",
listData: [],
contractTypeOptions: [
{
label: "艺术品推广及代销服务合同",
value: 1,
class: "border-primary",
},
{
label: "著作权代理转让服务合同",
value: 2,
class: "border-cyan",
},
{
label: "登记授权委托书",
value: 3,
class: "border-draft",
},
{
label: "作品登记承诺书",
value: 5,
class: "border-yell",
},
{
label: "著作权代理转让服务合同-附表",
value: 6,
class: "border-cyan",
},
],
filterBoxTop: null,
pageLoading: false,
tableParams: {
page: 1,
pageSize: 12,
},
btnLoading: false,
};
},
onLoad (pageParams) {
this.filterBoxTop = uni.getSystemInfoSync()["statusBarHeight"] + 44 + "px";
this.listData = pageData.ticketData
},
onShow () {
this.getPageData();
},
beforeDestroy () { },
methods: {
getPageData (scroll) {
},
handleLink (path, params = {}) {
uni.navigateTo({
url: path + calcRouteParams(params),
});
},
scrollRequest () {
console.log('scrollRequest');
this.tableParams.page++;
this.getPageData(true);
},
handleFinishAll () {
},
handlePageType () {
this.listData = [];
this.pageType === "finished"
? (this.pageType = "unfinish")
: (this.pageType = "finished");
this.getPageData();
},
handleContractClick (rowData) {
},
handleLabelByOptions (val, options) {
return getLabelByOptions(val, options);
},
handleTabBack (path) {
uni.switchTab({
url: path
});
},
},
};
</script>
<style lang="scss" scoped>
.fl-card {
border-radius: 20rpx;
background-color: #fff;
padding: 34rpx 0;
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -0,0 +1,98 @@
{
"ticketData":[
{
"name":"门票系统的某个场馆",
"typeNum":"3"
},
{
"name":"门票系统的某个场馆",
"typeNum":"3"
},
{
"name":"门票系统的某个场馆",
"typeNum":"0"
},
{
"name":"门票系统的某个场馆",
"typeNum":"0"
},
{
"name":"门票系统的某个场馆",
"typeNum":"0"
},
{
"name":"门票系统的某个场馆",
"typeNum":"0"
},
{
"name":"门票系统的某个场馆",
"typeNum":"0"
},
{
"name":"门票系统的某个场馆",
"typeNum":"0"
},
{
"name":"门票系统的某个场馆",
"typeNum":"0"
},
{
"name":"门票系统的某个场馆",
"typeNum":"0"
},
{
"name":"门票系统的某个场馆",
"typeNum":"0"
},
{
"name":"门票系统的某个场馆",
"typeNum":"0"
},
{
"name":"门票系统的某个场馆",
"typeNum":"0"
},
{
"name":"门票系统的某个场馆",
"typeNum":"0"
},
{
"name":"门票系统的某个场馆",
"typeNum":"0"
},
{
"name":"门票系统的某个场馆",
"typeNum":"0"
},
{
"name":"门票系统的某个场馆",
"typeNum":"0"
},
{
"name":"门票系统的某个场馆",
"typeNum":"0"
},
{
"name":"门票系统的某个场馆",
"typeNum":"0"
}
]
}

@ -0,0 +1,290 @@
export const getParamsByObj = (params, paramsConfig, obj) => {
if (paramsConfig !== undefined && paramsConfig.length > 0 && obj !== null) {
for (let i in paramsConfig) {
let paramsItem = paramsConfig[i];
if (paramsItem.value !== undefined) {
params[paramsItem.label] = paramsItem.value;
}
if (obj && paramsItem.field !== undefined) {
params[paramsItem.label] =
obj[paramsItem.field] === undefined ? "" : obj[paramsItem.field];
params[paramsItem.label] =
paramsItem.type === "Array"
? [params[paramsItem.label]]
: params[paramsItem.label];
}
}
}
return params;
};
export const getLabelByOptions = (val, options) => {
let label = "";
let valOpt = {};
for (let i in options) {
if (options[i].value === val) {
valOpt = options[i];
break;
}
}
if (valOpt.class || valOpt.style) {
return `<div class="sf-status-label ${valOpt.class}" style="${valOpt.style}">${valOpt.label}</div>`;
}
return valOpt.label;
};
export const getFormObj = (formConfig) => {
let data = {};
formConfig.forEach((item) => {
if (item.field) {
data[item.field] = item.value;
}
});
return data;
};
export const setFormObj = (formConfig, data) => {
formConfig.forEach((item) => {
if (item.field && data[item.field] !== undefined) {
item.value = data[item.field];
}
});
};
export const clearFormObj = (formConfig) => {
formConfig.forEach((item) => {
if (item.field) {
item.value = Array.isArray(item.value)
? []
: !isNaN(item.value)
? null
: "";
}
});
};
export const visibleFormItem = (itemshow, formObj = {}) => {
let flag = true;
if (Object.prototype.toString.call(itemshow) === "[object Boolean]") {
return itemshow;
}
let mathArr = [
"+",
"-",
"/",
"*",
">",
">=",
"<",
"<=",
"==",
"===",
"!==",
"||",
"&&",
];
if (itemshow && Object.keys(formObj).length > 0) {
let expression = itemshow
.replace(/\[%=/g, "")
.replace(/%\]/g, "")
.replace(/'/g, "");
let cs = expression.split(/(\/|%|\*|\+|-|&&|\|\||>|<|>=|<=|\(|\)|===|!==)/);
for (let idx in cs) {
let csItem = cs[idx];
// 右边为''
if (formObj[csItem] === "") {
cs[idx] = "'" + formObj[csItem] + "'";
// 左边可转为数值计算
} else if (
formObj[csItem] !== undefined &&
Object.prototype.toString.call(formObj[csItem]) === "object String"
) {
cs[idx] = formObj[csItem];
} else if (
formObj[csItem] !== undefined &&
Object.prototype.toString.call(formObj[csItem]) === "object Number"
) {
cs[idx] = "'" + formObj[csItem] + "'";
// 左边字段不存在 右边字段值字符串化
} else if (!mathArr.includes(csItem) && formObj[csItem] === undefined) {
cs[idx] = "'" + csItem + "'";
// 计算公式
} else if (mathArr.includes(csItem)) {
cs[idx] = csItem;
} else {
// 左边 在obj中存在 字符串化
cs[idx] = "'" + formObj[csItem] + "'";
}
}
cs = cs.join("");
flag = flag && window.eval(cs);
}
return flag;
};
export const validateItem = (item, itemValue) => {
let validate = item.validate;
let noErr = true;
let message = "";
switch (validate) {
case "required": {
// ADD input type is number is empty is null And dropdowntable,userDropdowntable,dropdownbox is empty is []
if (itemValue === null || itemValue.length === 0) {
noErr = false;
message = "请输入内容";
}
break;
}
case "": {
// ADD input type is number is empty is null And dropdowntable,userDropdowntable,dropdownbox is empty is []
if (itemValue === null || itemValue.length === 0) {
noErr = false;
message = "请输入内容";
}
break;
}
case "email": {
const regEmail =
/^[a-zA-Z0-9_-]+([._\\-]*[a-zA-Z0-9_-])*@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
if (regEmail.test(itemValue) === false) {
noErr = false;
message = "请输入正确邮箱";
}
break;
}
case "chinese": {
const regChinese = /^[^\u4e00-\u9fa5]{0,}$/;
if (regChinese.test(itemValue) === false) {
noErr = false;
message = "请输入中文字符";
}
break;
}
case "maxDecimals4": {
// let regDecimals2 = /^\d+(\.\d{2})?$/
const regDecimals4 = /^\d+(?:\.\d{1,4})?$/;
if (
itemValue !== null &&
itemValue !== "" &&
regDecimals4.test(itemValue) === false
) {
noErr = false;
message = "最多四位小数";
}
break;
}
case "english": {
// 添加英文支持-
const regEnglish = /^[a-zA-Z0-9_@-]{1,}$/;
if (regEnglish.test(itemValue) === false) {
noErr = false;
message = "请输入英文字符";
}
break;
}
case "datetime": {
const regDatetime =
/^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\s+(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d$/;
if (regDatetime.test(itemValue) === false) {
noErr = false;
message = "请输入正确时间";
}
break;
}
case "date": {
const regDate = /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/;
if (regDate.test(itemValue) === false) {
noErr = false;
message = "请输入正确日期";
}
break;
}
case "time": {
const regTime = /^(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d$/;
if (regTime.test(itemValue) === false) {
noErr = false;
message = "请输入正确时间";
}
break;
}
case "interger": {
const regInterger = /^[1-9]\d*$/;
if (regInterger.test(itemValue) === false) {
noErr = false;
message = "请输入整数";
}
break;
}
case "positiveNumber": {
// 包括0的正数
if (itemValue < 0) {
noErr = false;
message = "请输入非负数";
}
break;
}
case "gt0Number": {
// 不包括0的正数
if (itemValue <= 0) {
noErr = false;
message = "请输入非零正数";
}
break;
}
case "telephone": {
const telephoneNumber = /^1(3|4|5|6|7|8|9)\d{9}$/;
if (telephoneNumber.test(itemValue) === false) {
noErr = false;
message = "请输入正确手机号码";
}
break;
}
case "pwdstrong": {
const forceRegex = new RegExp("(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z]).{6,20}");
if (forceRegex.test(itemValue) === false) {
noErr = false;
message = "请输入符合格式的密码";
}
break;
}
default:
noErr = true;
}
if (!noErr) {
item.errorMessage = message;
} else {
item.errorMessage = "";
}
};
export const validataForm = (formConfig) => {
if (formConfig) {
let formHasErr = false;
formConfig.forEach((item) => {
if (item.validate !== undefined) {
validateItem(item, item.value);
}
if (item.errorMessage) {
formHasErr = true;
}
});
return formHasErr;
}
};
export function isEmpty (val) {
if (val === null || val === "" || val === undefined) {
return true;
}
return false;
}
export function calcRouteParams (obj) {
if (obj && JSON.stringify(obj) !== '{}') {
let str = '?'
for (let key in obj) {
str += key + '=' + obj[key] + '&'
}
return str.slice(0, -1)
}
return ''
}
Loading…
Cancel
Save