init
This commit is contained in:
120
pages/testData/form.vue
Normal file
120
pages/testData/form.vue
Normal file
@@ -0,0 +1,120 @@
|
||||
<template>
|
||||
<view class="wrap form_right">
|
||||
<u-form class="form" :model="model" :rules="rules" ref="uForm" label-position="left">
|
||||
<u-form-item label="编号" prop="id" label-width="180">
|
||||
<u-input placeholder="请输入编号" v-model="model.id" type="text" maxlength="64" style="text-align: right;"></u-input>
|
||||
</u-form-item>
|
||||
<u-form-item label="单行文本" prop="testInput" label-width="180">
|
||||
<u-input placeholder="请输入单行文本" v-model="model.testInput" type="text" maxlength="200" style="text-align: right;"></u-input>
|
||||
</u-form-item>
|
||||
<u-form-item label="多行文本" prop="testTextarea" label-width="180" label-position="top">
|
||||
<u-input type="textarea" placeholder="请输入多行文本" v-model="model.testTextarea" style="text-align: left;" height="100" maxlength="500" />
|
||||
</u-form-item>
|
||||
</u-form>
|
||||
<view class="form-footer">
|
||||
<u-button class="btn" type="primary" @click="submit">提交</u-button>
|
||||
<!-- <u-button class="btn" type="default" @click="cancel">关闭</u-button> -->
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://aidex.vip All rights reserved.
|
||||
*/
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
model: {
|
||||
id: '',
|
||||
testInput: '',
|
||||
testTextarea: '',
|
||||
testSelect: '',
|
||||
testSelectMultiple: '',
|
||||
testSelectMultipleLabel: '',
|
||||
testRadio: '',
|
||||
testCheckbox: '',
|
||||
testUser: {
|
||||
userCode: '',
|
||||
userName: ''
|
||||
},
|
||||
testOffice: {
|
||||
officeCode: '',
|
||||
officeName: ''
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
testInput: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入单行文本',
|
||||
trigger: ['change','blur'],
|
||||
}
|
||||
]
|
||||
},
|
||||
officeSelectList: [],
|
||||
userSelectList: [],
|
||||
};
|
||||
},
|
||||
onLoad(params){
|
||||
if (params.id){
|
||||
this.$u.api.testData.form({id: params.id}).then(res => {
|
||||
Object.assign(this.model, res.testData);
|
||||
});
|
||||
}
|
||||
},
|
||||
onReady() {
|
||||
this.$refs.uForm.setRules(this.rules);
|
||||
// 机构数据
|
||||
this.$u.api.office.treeData().then(res => {
|
||||
this.officeSelectList = res;
|
||||
});
|
||||
// 人员和机构数据
|
||||
this.$u.api.office.treeData({isLoadUser: true}).then(res => {
|
||||
this.userSelectList = res;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
console.log(this.model)
|
||||
this.$refs.uForm.validate(valid => {
|
||||
if (valid) {
|
||||
this.$u.api.testData.save(this.model).then(res => {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: res.message,
|
||||
showCancel: false,
|
||||
success: function () {
|
||||
if (res.result == 'true') {
|
||||
uni.navigateBack();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.$u.toast('您填写的信息有误,请根据提示修正。');
|
||||
}
|
||||
});
|
||||
},
|
||||
cancel() {
|
||||
uni.navigateBack();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.input-placeholder{
|
||||
text-align: right;
|
||||
}
|
||||
.u-input{
|
||||
text-align: right!important;
|
||||
}
|
||||
.u-form-item__message{
|
||||
text-align: right!important;
|
||||
}
|
||||
.uni-textarea-placeholder{
|
||||
text-align: left;
|
||||
}
|
||||
.u-form-item{
|
||||
font-size:36rpx;
|
||||
}
|
||||
</style>
|
117
pages/testData/index.vue
Normal file
117
pages/testData/index.vue
Normal file
@@ -0,0 +1,117 @@
|
||||
<template>
|
||||
<view class="wrap">
|
||||
<view class="search">
|
||||
<u-search v-model="keywords" @custom="search" @search="search"></u-search>
|
||||
</view>
|
||||
<scroll-view class="scroll-list" scroll-y="true" @scrolltolower="loadMore">
|
||||
<u-cell-group class="list" :border="false">
|
||||
<u-swipe-action :options="options" v-for="(item, index) in list" :key="item.id" :index="index" @click="optionsClick">
|
||||
<u-cell-item :arrow="true" @click="navTo('form?id='+item.id)">
|
||||
<text slot="title">{{item.testInput || item.id}}</text>
|
||||
<text slot="label">创建者:{{item.createBy}} | 时间:{{item.createDate}}</text>
|
||||
</u-cell-item>
|
||||
</u-swipe-action>
|
||||
</u-cell-group>
|
||||
<view class="loadmore" @click="loadMore">
|
||||
<u-loadmore :status="loadStatus"></u-loadmore>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="btn-plus" @click="navTo('form')">
|
||||
<u-icon name="plus-circle-fill" size="90" color="#3d87ff"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://aidex.vip All rights reserved.
|
||||
*/
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
keywords: '',
|
||||
query: {
|
||||
pageNo: 1,
|
||||
pageSize: 20
|
||||
},
|
||||
list: [],
|
||||
count: 0,
|
||||
loadStatus: 'loadmore',
|
||||
options: [
|
||||
{text: '删除', style: { background: '#dd524d'}}
|
||||
]
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
this.loadList();
|
||||
},
|
||||
methods: {
|
||||
loadMore() {
|
||||
this.loadStatus = "loading";
|
||||
setTimeout(() => {
|
||||
this.query.pageNo += 1;
|
||||
this.loadList();
|
||||
}, 100);
|
||||
},
|
||||
loadList() {
|
||||
this.$u.api.testData.list(this.query).then(res => {
|
||||
if (!res.list || res.list.length == 0){
|
||||
this.loadStatus = "nomore";
|
||||
return;
|
||||
}
|
||||
this.list = this.list.concat(res.list);
|
||||
this.count = res.count;
|
||||
this.query.pageNo = res.pageNo;
|
||||
this.query.pageSize = res.pageSize;
|
||||
this.loadStatus = "loadmore";
|
||||
});
|
||||
},
|
||||
optionsClick(rowIndex, btnIndex) {
|
||||
if(btnIndex == 0) {
|
||||
let self = this;
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确认要删除该数据吗?',
|
||||
showCancel: true,
|
||||
success: function (res2) {
|
||||
if (res2.confirm) {
|
||||
let row = self.list[rowIndex];
|
||||
self.$u.api.testData.delete({id: row.id}).then(res => {
|
||||
self.$u.toast(res.message);
|
||||
if (res.result == 'true'){
|
||||
self.list.splice(rowIndex, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
search(value) {
|
||||
this.list = [];
|
||||
this.query.pageNo = 0;
|
||||
this.query.testInput = value;
|
||||
this.loadList();
|
||||
},
|
||||
navTo(url) {
|
||||
uni.navigateTo({
|
||||
url: url
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.btn-plus {
|
||||
position: absolute;
|
||||
bottom: 50rpx;
|
||||
right: 50rpx;
|
||||
z-index: 1;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.btn-plus:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
</style>
|
Reference in New Issue
Block a user