first commit
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<template>
|
||||
<div class="card">
|
||||
<div class="card-header" v-if="$slots.header">
|
||||
<slot name="header"></slot>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<slot></slot>
|
||||
</div>
|
||||
<div class="card-footer" v-if="$slots.footer">
|
||||
<slot name="footer"></slot>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
name: "MCard"
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.card {
|
||||
border: none;
|
||||
border-radius: .5rem;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
border-bottom:1px dashed rgba(0,0,0,.125);
|
||||
font-size: 1.15rem;
|
||||
}
|
||||
|
||||
.card-header:first-child {
|
||||
border-radius: calc(.5rem - 1px) calc(.5rem - 1px) 0 0
|
||||
}
|
||||
|
||||
.card-body>.van-cell{
|
||||
padding: 5px 0;
|
||||
}
|
||||
.card-body{
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
|
||||
.card-header, .card-footer {
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,89 @@
|
||||
<template>
|
||||
<div class="loader"></div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
name: "MLoading"
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.loader {
|
||||
z-index: 10000;
|
||||
position: relative;
|
||||
width: 2.5em;
|
||||
height: 2.5em;
|
||||
transform: rotate(165deg);
|
||||
}
|
||||
|
||||
.loader:before, .loader:after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
display: block;
|
||||
width: 0.5em;
|
||||
height: 0.5em;
|
||||
border-radius: 0.25em;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.loader:before {
|
||||
animation: before 2s infinite;
|
||||
}
|
||||
|
||||
.loader:after {
|
||||
animation: after 2s infinite;
|
||||
}
|
||||
|
||||
@keyframes before {
|
||||
0% {
|
||||
width: 0.5em;
|
||||
box-shadow: 1em -0.5em rgba(225, 20, 98, 0.75), -1em 0.5em rgba(111, 202, 220, 0.75);
|
||||
}
|
||||
35% {
|
||||
width: 2.5em;
|
||||
box-shadow: 0 -0.5em rgba(225, 20, 98, 0.75), 0 0.5em rgba(111, 202, 220, 0.75);
|
||||
}
|
||||
70% {
|
||||
width: 0.5em;
|
||||
box-shadow: -1em -0.5em rgba(225, 20, 98, 0.75), 1em 0.5em rgba(111, 202, 220, 0.75);
|
||||
}
|
||||
100% {
|
||||
box-shadow: 1em -0.5em rgba(225, 20, 98, 0.75), -1em 0.5em rgba(111, 202, 220, 0.75);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes after {
|
||||
0% {
|
||||
height: 0.5em;
|
||||
box-shadow: 0.5em 1em rgba(61, 184, 143, 0.75), -0.5em -1em rgba(233, 169, 32, 0.75);
|
||||
}
|
||||
35% {
|
||||
height: 2.5em;
|
||||
box-shadow: 0.5em 0 rgba(61, 184, 143, 0.75), -0.5em 0 rgba(233, 169, 32, 0.75);
|
||||
}
|
||||
70% {
|
||||
height: 0.5em;
|
||||
box-shadow: 0.5em -1em rgba(61, 184, 143, 0.75), -0.5em 1em rgba(233, 169, 32, 0.75);
|
||||
}
|
||||
100% {
|
||||
box-shadow: 0.5em 1em rgba(61, 184, 143, 0.75), -0.5em -1em rgba(233, 169, 32, 0.75);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to center the whole thing!
|
||||
*/
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.loader {
|
||||
position: absolute;
|
||||
top: calc(50% - 1.25em);
|
||||
left: calc(50% - 1.25em);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,140 @@
|
||||
<template>
|
||||
<figure>
|
||||
<div class="dot white"></div>
|
||||
<div class="dot"></div>
|
||||
<div class="dot"></div>
|
||||
<div class="dot"></div>
|
||||
<div class="dot"></div>
|
||||
</figure>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
name: "MTableLoading"
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
body {
|
||||
background: #222;
|
||||
}
|
||||
|
||||
figure {
|
||||
position: absolute;
|
||||
margin: auto;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
width: 6.250em;
|
||||
height: 6.250em;
|
||||
animation: rotate 2.4s linear infinite;
|
||||
}
|
||||
|
||||
.white {
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: white;
|
||||
animation: flash 2.4s linear infinite;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.dot {
|
||||
position: absolute;
|
||||
margin: auto;
|
||||
width: 2.4em;
|
||||
height: 2.4em;
|
||||
border-radius: 100%;
|
||||
transition: all 1s ease;
|
||||
}
|
||||
|
||||
.dot:nth-child(2) {
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
background: #FF4444;
|
||||
animation: dotsY 2.4s linear infinite;
|
||||
}
|
||||
|
||||
.dot:nth-child(3) {
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
background: #FFBB33;
|
||||
animation: dotsX 2.4s linear infinite;
|
||||
}
|
||||
|
||||
.dot:nth-child(4) {
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
background: #99CC00;
|
||||
animation: dotsY 2.4s linear infinite;
|
||||
}
|
||||
|
||||
.dot:nth-child(5) {
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: #33B5E5;
|
||||
animation: dotsX 2.4s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes rotate {
|
||||
0% {
|
||||
transform: rotate(0);
|
||||
}
|
||||
10% {
|
||||
width: 6.250em;
|
||||
height: 6.250em;
|
||||
}
|
||||
66% {
|
||||
width: 2.4em;
|
||||
height: 2.4em;
|
||||
}
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
width: 6.250em;
|
||||
height: 6.250em;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes dotsY {
|
||||
66% {
|
||||
opacity: .1;
|
||||
width: 2.4em;
|
||||
}
|
||||
77% {
|
||||
opacity: 1;
|
||||
width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes dotsX {
|
||||
66% {
|
||||
opacity: .1;
|
||||
height: 2.4em;
|
||||
}
|
||||
77% {
|
||||
opacity: 1;
|
||||
height: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes flash {
|
||||
33% {
|
||||
opacity: 0;
|
||||
border-radius: 0%;
|
||||
}
|
||||
55% {
|
||||
opacity: .6;
|
||||
border-radius: 100%;
|
||||
}
|
||||
66% {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,186 @@
|
||||
<style>
|
||||
.field .van-field__error-message {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<div>
|
||||
<van-form @submit="onSubmit" ref="form">
|
||||
<template v-for="column in dynamicData">
|
||||
<!-- 文本、数值、时间 -->
|
||||
<template v-if="['VARCHAR','TEXT','INT','DATE','DATETIME'].includes(column.columnType)">
|
||||
<van-field
|
||||
class="field"
|
||||
v-model="column.columnValue"
|
||||
:clickable="['SELECT'].includes(column.columnFormType)"
|
||||
:label="column.columnName"
|
||||
:name="column.columnCode"
|
||||
:type="['INT'].includes(column.columnType) ? 'digit' : ''"
|
||||
:placeholder="(['SELECT'].includes(column.columnFormType) ? '请选择' : '请填写') + column.columnName"
|
||||
:readonly="['SELECT'].includes(column.columnFormType)"
|
||||
:rules="[{ required: column.isRequired, message: (['SELECT'].includes(column.columnFormType) ? '请选择' : '请填写') + column.columnName }]"
|
||||
:required="column.isRequired"
|
||||
@click="selectFieldClick(column)"
|
||||
></van-field>
|
||||
|
||||
<van-popup v-if="['SELECT'].includes(column.columnFormType)"
|
||||
v-model="pickerStates[column.columnCode + 'Picker']"
|
||||
position="bottom">
|
||||
<template v-if="['DATETIME','DATE'].includes(column.columnType)">
|
||||
<van-datetime-picker
|
||||
:title="column.columnName"
|
||||
:type="column.columnType.toLocaleLowerCase()"
|
||||
:min-date="new Date(2008, 0, 1)"
|
||||
:max-date="new Date(2017, 5, 30)"
|
||||
show-toolbar
|
||||
@cancel="pickerStates[column.columnCode + 'Picker'] = false; column.columnValue = ''"
|
||||
@confirm="(time)=>{dateTimePickerConfirm(time,column)}"
|
||||
/>
|
||||
</template>
|
||||
<template v-else>
|
||||
<van-picker
|
||||
:columns="column.selectValues"
|
||||
:title="column.columnName"
|
||||
show-toolbar
|
||||
@cancel="pickerStates[column.columnCode + 'Picker'] = false; column.columnValue = ''"
|
||||
@confirm="(value)=>{ordinaryPickerConfirm(value,column)}"
|
||||
/>
|
||||
</template>
|
||||
</van-popup>
|
||||
</template>
|
||||
<!-- 单选框 -->
|
||||
<template v-else-if="['BOOLEAN'].includes(column.columnType)">
|
||||
|
||||
</template>
|
||||
<!-- 文件 -->
|
||||
<template v-else-if="['JSON'].includes(column.columnType)">
|
||||
<van-field :required="column.isRequired" :label="column.columnName"
|
||||
:rules="[{ required: column.isRequired, message: '请上传' + column.columnName }]">
|
||||
<template #input>
|
||||
<!-- <van-uploader v-model="fileList" :after-read="(file)=>{fileAfterRead(file,column)}"
|
||||
:max-count="column.fileNumber"/>-->
|
||||
|
||||
<vant_file_upload :files.sync="column.columnValue" :max="column.fileNumber"
|
||||
:type="column.fileType"></vant_file_upload>
|
||||
</template>
|
||||
</van-field>
|
||||
</template>
|
||||
|
||||
</template>
|
||||
</van-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 请在van-form中引用 -->
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
name: "TrainDynamicForm",
|
||||
components: {
|
||||
'vant_file_upload': httpVueLoader('/components/plugins/VantFileUpload.vue')
|
||||
},
|
||||
props: {
|
||||
dynamicData: []
|
||||
},
|
||||
model: {
|
||||
prop: 'dynamicData',
|
||||
event: 'updateDynamicData'
|
||||
},
|
||||
watch: {
|
||||
dynamicData: {
|
||||
handler: function (newValue, oldValue) {
|
||||
this.$emit('updateDynamicData', newValue)
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
//所有的picker状态
|
||||
pickerStates: {},
|
||||
fileList: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
validForm() {
|
||||
try {
|
||||
this.$refs.form.validate().then(() => {
|
||||
return true
|
||||
}).catch(() => {
|
||||
return false
|
||||
})
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
|
||||
/*return new Promise(resolve => {
|
||||
this.$refs.form.validate().then(() => {
|
||||
resolve(true)
|
||||
}).catch(() => {
|
||||
resolve(false)
|
||||
})
|
||||
})*/
|
||||
|
||||
},
|
||||
onSubmit() {
|
||||
|
||||
},
|
||||
selectFieldClick(column) {
|
||||
console.log(column)
|
||||
this.$set(this.pickerStates, column.columnCode + 'Picker', true)
|
||||
if (!['DATE', 'DATETIME'].includes(column.columnType)) {
|
||||
//说明是普通的下拉框
|
||||
// column.selectValues = ['1', '2', '3']
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 时间picker确认
|
||||
* @param time
|
||||
* @param column
|
||||
*/
|
||||
dateTimePickerConfirm(time, column) {
|
||||
if (column.columnType === 'DATE') {
|
||||
column.columnValue = moment(time).format('YYYY-MM-DD')
|
||||
} else if (column.columnType === 'DATETIME') {
|
||||
column.columnValue = moment(time).format('YYYY-MM-DD HH:mm:ss')
|
||||
} else {
|
||||
//预留别的类型
|
||||
column.columnValue = moment(time).format('YYYY-MM-DD HH:mm:ss')
|
||||
}
|
||||
this.pickerStates[column.columnCode + 'Picker'] = false
|
||||
},
|
||||
/**
|
||||
* 普通picker确认
|
||||
* @param value
|
||||
* @param column
|
||||
*/
|
||||
ordinaryPickerConfirm(value, column) {
|
||||
column.columnValue = value
|
||||
this.pickerStates[column.columnCode + 'Picker'] = false
|
||||
},
|
||||
/**
|
||||
* 文件读取
|
||||
*/
|
||||
fileAfterRead(file, column) {
|
||||
|
||||
|
||||
console.log(file)
|
||||
console.log(column)
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// console.log(this.dynamicData)
|
||||
// this.dynamicData.forEach(v => {
|
||||
// if (v.columnFormType === 'SELECT') {
|
||||
// v.columnPickerName = v.columnCode+'Picker'
|
||||
// }
|
||||
// })
|
||||
// console.log(this.dynamicData)
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user