提交 44a0082b 编写于 作者: M MicroMilo

管理界面全初步完成

上级 d69b41f4
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const validator = {
"owner_id": {
"rules": [
{
"format": "string"
}
],
"title": "评论人id",
"label": "评论人id"
},
"date": {
"rules": [
{
"format": "string"
}
],
"title": "发布时间",
"label": "发布时间"
},
"likes": {
"rules": [
{
"format": "int"
}
],
"title": "点赞数",
"label": "点赞数"
},
"post_id": {
"rules": [
{
"format": "string"
}
],
"title": "帖子id",
"label": "帖子id"
},
"check_status": {
"rules": [
{
"format": "bool"
}
],
"title": "状态",
"label": "状态"
},
"content": {
"rules": [
{
"format": "string"
}
],
"title": "评论内容",
"label": "评论内容"
}
}
const enumConverter = {}
function filterToWhere(filter, command) {
let where = {}
for (let field in filter) {
let { type, value } = filter[field]
switch (type) {
case "search":
if (typeof value === 'string' && value.length) {
where[field] = new RegExp(value)
}
break;
case "select":
if (value.length) {
let selectValue = []
for (let s of value) {
selectValue.push(command.eq(s))
}
where[field] = command.or(selectValue)
}
break;
case "range":
if (value.length) {
let gt = value[0]
let lt = value[1]
where[field] = command.and([command.gte(gt), command.lte(lt)])
}
break;
case "date":
if (value.length) {
let [s, e] = value
let startDate = new Date(s)
let endDate = new Date(e)
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
case "timestamp":
if (value.length) {
let [startDate, endDate] = value
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
}
}
return where
}
export { validator, enumConverter, filterToWhere }
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const validator = {
"content": {
"rules": [
{
"format": "string"
}
],
"title": "内容",
"label": "内容"
},
"date": {
"rules": [
{
"format": "string"
}
],
"title": "发布时间",
"label": "发布时间"
},
"likes": {
"rules": [
{
"format": "int"
}
],
"title": "点赞数",
"label": "点赞数"
},
"owner_id": {
"rules": [
{
"format": "string"
}
],
"title": "发帖人id",
"label": "发帖人id"
},
"check_status": {
"rules": [
{
"format": "bool"
}
],
"title": "审核状态",
"label": "审核状态"
},
"comment_num": {
"rules": [
{
"format": "int"
}
],
"title": "评论数",
"label": "评论数"
},
"url": {
"rules": [
{
"format": "array"
}
],
"title": "图片url",
"label": "图片url"
}
}
const enumConverter = {}
function filterToWhere(filter, command) {
let where = {}
for (let field in filter) {
let { type, value } = filter[field]
switch (type) {
case "search":
if (typeof value === 'string' && value.length) {
where[field] = new RegExp(value)
}
break;
case "select":
if (value.length) {
let selectValue = []
for (let s of value) {
selectValue.push(command.eq(s))
}
where[field] = command.or(selectValue)
}
break;
case "range":
if (value.length) {
let gt = value[0]
let lt = value[1]
where[field] = command.and([command.gte(gt), command.lte(lt)])
}
break;
case "date":
if (value.length) {
let [s, e] = value
let startDate = new Date(s)
let endDate = new Date(e)
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
case "timestamp":
if (value.length) {
let [startDate, endDate] = value
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
}
}
return where
}
export { validator, enumConverter, filterToWhere }
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const validator = {
"title": {
"rules": [
{
"format": "string"
}
],
"title": "标题",
"label": "标题"
},
"content": {
"rules": [
{
"format": "string"
}
],
"title": "内容",
"label": "内容"
},
"start_date": {
"rules": [
{
"format": "string"
}
],
"title": "开始时间",
"label": "开始时间"
},
"end_date": {
"rules": [
{
"format": "string"
}
],
"title": "结束时间",
"label": "结束时间"
},
"owner_id": {
"rules": [
{
"format": "string"
}
],
"title": "发布者id",
"label": "发布者id"
},
"background_picture": {
"rules": [
{
"format": "string"
}
],
"title": "背景图片",
"label": "背景图片"
},
"place": {
"rules": [
{
"format": "string"
}
],
"title": "地点",
"label": "地点"
},
"status": {
"rules": [
{
"format": "int"
}
],
"title": "活动状态",
"label": "活动状态"
},
"contact": {
"rules": [
{
"format": "string"
}
],
"title": "联系方式",
"label": "联系方式"
},
"invitee": {
"rules": [
{
"format": "string"
}
],
"title": "面向对象",
"label": "面向对象"
}
}
const enumConverter = {}
function filterToWhere(filter, command) {
let where = {}
for (let field in filter) {
let { type, value } = filter[field]
switch (type) {
case "search":
if (typeof value === 'string' && value.length) {
where[field] = new RegExp(value)
}
break;
case "select":
if (value.length) {
let selectValue = []
for (let s of value) {
selectValue.push(command.eq(s))
}
where[field] = command.or(selectValue)
}
break;
case "range":
if (value.length) {
let gt = value[0]
let lt = value[1]
where[field] = command.and([command.gte(gt), command.lte(lt)])
}
break;
case "date":
if (value.length) {
let [s, e] = value
let startDate = new Date(s)
let endDate = new Date(e)
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
case "timestamp":
if (value.length) {
let [startDate, endDate] = value
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
}
}
return where
}
export { validator, enumConverter, filterToWhere }
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const validator = {
"title": {
"rules": [
{
"format": "string"
}
],
"title": "标题",
"label": "标题"
},
"content": {
"rules": [
{
"format": "string"
}
],
"title": "内容",
"label": "内容"
},
"start_date": {
"rules": [
{
"format": "string"
}
],
"title": "开始时间",
"label": "开始时间"
},
"end_date": {
"rules": [
{
"format": "string"
}
],
"title": "结束时间",
"label": "结束时间"
},
"owner_id": {
"rules": [
{
"format": "string"
}
],
"title": "发布者id",
"label": "发布者id"
},
"background_picture": {
"rules": [
{
"format": "string"
}
],
"title": "背景图片",
"label": "背景图片"
},
"place": {
"rules": [
{
"format": "string"
}
],
"title": "地点",
"label": "地点"
},
"status": {
"rules": [
{
"format": "int"
}
],
"title": "活动状态",
"label": "活动状态"
},
"participants": {
"rules": [
{
"format": "int"
}
],
"title": "参与人数",
"label": "参与人数"
},
"contact": {
"rules": [
{
"format": "string"
}
],
"title": "联系方式",
"label": "联系方式"
},
"team_id": {
"rules": [
{
"format": "string"
}
],
"title": "小队id",
"label": "小队id"
}
}
const enumConverter = {}
function filterToWhere(filter, command) {
let where = {}
for (let field in filter) {
let { type, value } = filter[field]
switch (type) {
case "search":
if (typeof value === 'string' && value.length) {
where[field] = new RegExp(value)
}
break;
case "select":
if (value.length) {
let selectValue = []
for (let s of value) {
selectValue.push(command.eq(s))
}
where[field] = command.or(selectValue)
}
break;
case "range":
if (value.length) {
let gt = value[0]
let lt = value[1]
where[field] = command.and([command.gte(gt), command.lte(lt)])
}
break;
case "date":
if (value.length) {
let [s, e] = value
let startDate = new Date(s)
let endDate = new Date(e)
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
case "timestamp":
if (value.length) {
let [startDate, endDate] = value
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
}
}
return where
}
export { validator, enumConverter, filterToWhere }
......@@ -47,14 +47,14 @@ const validator = {
"title": "距离",
"label": "距离"
},
"steps": {
"pace": {
"rules": [
{
"format": "int"
"format": "double"
}
],
"title": "步数",
"label": "步数"
"title": "配速",
"label": "配速"
},
"start_point": {
"rules": [
......
......@@ -310,6 +310,66 @@
"style": {
"navigationBarTitleText": "列表"
}
}, {
"path": "mustgo-post/add",
"style": {
"navigationBarTitleText": "新增"
}
}, {
"path": "mustgo-post/edit",
"style": {
"navigationBarTitleText": "编辑"
}
}, {
"path": "mustgo-post/list",
"style": {
"navigationBarTitleText": "列表"
}
}, {
"path": "mustgo-comment/add",
"style": {
"navigationBarTitleText": "新增"
}
}, {
"path": "mustgo-comment/edit",
"style": {
"navigationBarTitleText": "编辑"
}
}, {
"path": "mustgo-comment/list",
"style": {
"navigationBarTitleText": "列表"
}
}, {
"path": "mustgo-activity/school/add",
"style": {
"navigationBarTitleText": "新增"
}
}, {
"path": "mustgo-activity/school/edit",
"style": {
"navigationBarTitleText": "编辑"
}
}, {
"path": "mustgo-activity/school/list",
"style": {
"navigationBarTitleText": "列表"
}
}, {
"path": "mustgo-activity/team/add",
"style": {
"navigationBarTitleText": "新增"
}
}, {
"path": "mustgo-activity/team/edit",
"style": {
"navigationBarTitleText": "编辑"
}
}, {
"path": "mustgo-activity/team/list",
"style": {
"navigationBarTitleText": "列表"
}
}]
},
{
......
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validateTrigger="bind">
<uni-forms-item name="title" label="标题">
<uni-easyinput placeholder="校园活动标题" v-model="formData.title"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="content" label="内容">
<uni-easyinput placeholder="校园活动内容" v-model="formData.content"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="start_date" label="开始时间">
<uni-easyinput placeholder="校园活动开始时间" v-model="formData.start_date"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="end_date" label="结束时间">
<uni-easyinput placeholder="校园活动结束时间" v-model="formData.end_date"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="owner_id" label="发布者id">
<uni-easyinput placeholder="校园活动发布者id" v-model="formData.owner_id"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="background_picture" label="背景图片" @click="avatarChoose">
<image :src="formData.background_picture" style="width: 120px; height: 80px; background-color: darkgray;">
</image>
<!-- <uni-easyinput placeholder="校园活动背景图片" v-model="formData.background_picture"></uni-easyinput> -->
</uni-forms-item>
<uni-forms-item name="place" label="地点">
<uni-easyinput placeholder="校园活动地点" v-model="formData.place"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="status" label="活动状态">
<uni-easyinput placeholder="校园活动状态" type="number" v-model="formData.status"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="contact" label="联系方式">
<uni-easyinput placeholder="校园活动发布者联系方式" v-model="formData.contact"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="invitee" label="面向对象">
<uni-easyinput placeholder="校园活动面向对象" v-model="formData.invitee"></uni-easyinput>
</uni-forms-item>
<view class="uni-button-group">
<button type="primary" class="uni-button" style="width: 100px;" @click="submit">提交</button>
<navigator open-type="navigateBack" style="margin-left: 15px;">
<button class="uni-button" style="width: 100px;">返回</button>
</navigator>
</view>
</uni-forms>
</view>
</template>
<script>
import {
validator
} from '../../../../js_sdk/validator/mustgo-school-activity.js';
const db = uniCloud.database();
const dbCmd = db.command;
const dbCollectionName = 'mustgo-school-activity';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.includes(key)) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"title": "",
"content": "",
"start_date": "",
"end_date": "",
"owner_id": "",
"background_picture": "",
"place": "",
"status": null,
"contact": "",
"invitee": ""
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
avatarChoose() {
let that = this;
console.log("upload image loading")
uniCloud.chooseAndUploadFile({
type: 'image',
success(res) {
that.formData.icon = res["tempFiles"][0]["url"]
console.log(res)
},
fail() {
console.log("upload icon failed")
},
complete() {}
});
},
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使用 clientDB 提交数据
return db.collection(dbCollectionName).add(value).then((res) => {
uni.showToast({
title: '新增成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
}
}
}
</script>
\ No newline at end of file
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validateTrigger="bind">
<uni-forms-item name="title" label="标题">
<uni-easyinput placeholder="校园活动标题" v-model="formData.title"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="content" label="内容">
<uni-easyinput placeholder="校园活动内容" v-model="formData.content"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="start_date" label="开始时间">
<uni-easyinput placeholder="校园活动开始时间" v-model="formData.start_date"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="end_date" label="结束时间">
<uni-easyinput placeholder="校园活动结束时间" v-model="formData.end_date"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="owner_id" label="发布者id">
<uni-easyinput placeholder="校园活动发布者id" v-model="formData.owner_id"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="background_picture" label="背景图片" @click="avatarChoose">
<image :src="formData.background_picture" style="width: 120px; height: 80px;"></image>
<!-- <uni-easyinput placeholder="校园活动背景图片" v-model="formData.background_picture"></uni-easyinput> -->
</uni-forms-item>
<uni-forms-item name="place" label="地点">
<uni-easyinput placeholder="校园活动地点" v-model="formData.place"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="status" label="活动状态">
<uni-easyinput placeholder="校园活动状态" type="number" v-model="formData.status"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="contact" label="联系方式">
<uni-easyinput placeholder="校园活动发布者联系方式" v-model="formData.contact"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="invitee" label="面向对象">
<uni-easyinput placeholder="校园活动面向对象" v-model="formData.invitee"></uni-easyinput>
</uni-forms-item>
<view class="uni-button-group">
<button type="primary" class="uni-button" style="width: 100px;" @click="submit">提交</button>
<navigator open-type="navigateBack" style="margin-left: 15px;">
<button class="uni-button" style="width: 100px;">返回</button>
</navigator>
</view>
</uni-forms>
</view>
</template>
<script>
import { validator } from '../../../../js_sdk/validator/mustgo-school-activity.js';
const db = uniCloud.database();
const dbCmd = db.command;
const dbCollectionName = 'mustgo-school-activity';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.includes(key)) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"title": "",
"content": "",
"start_date": "",
"end_date": "",
"owner_id": "",
"background_picture": "",
"place": "",
"status": null,
"contact": "",
"invitee": ""
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onLoad(e) {
if (e.id) {
const id = e.id
this.formDataId = id
this.getDetail(id)
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
avatarChoose() {
let that = this;
console.log("upload image loading")
uniCloud.chooseAndUploadFile({
type: 'image',
success(res) {
that.formData.icon = res["tempFiles"][0]["url"]
console.log(res)
},
fail() {
console.log("upload icon failed")
},
complete() {}
});
},
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {
}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使用 clientDB 提交数据
return db.collection(dbCollectionName).doc(this.formDataId).update(value).then((res) => {
uni.showToast({
title: '修改成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
},
/**
* 获取表单数据
* @param {Object} id
*/
getDetail(id) {
uni.showLoading({
mask: true
})
db.collection(dbCollectionName).doc(id).field("title,content,start_date,end_date,owner_id,background_picture,place,status,contact,invitee").get().then((res) => {
const data = res.result.data[0]
if (data) {
this.formData = data
}
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
}).finally(() => {
uni.hideLoading()
})
}
}
}
</script>
<template>
<view>
<view class="uni-header">
<view class="uni-group">
<view class="uni-title"></view>
<view class="uni-sub-title"></view>
</view>
<view class="uni-group">
<input class="uni-search" type="text" v-model="query" @confirm="search" placeholder="请输入搜索内容" />
<button class="uni-button" type="default" size="mini" @click="search">搜索</button>
<button class="uni-button" type="default" size="mini" @click="navigateTo('./add')">新增</button>
<button class="uni-button" type="default" size="mini" :disabled="!selectedIndexs.length" @click="delTable">批量删除</button>
<download-excel class="hide-on-phone" :fields="exportExcel.fields" :data="exportExcelData" :type="exportExcel.type" :name="exportExcel.filename">
<button class="uni-button" type="primary" size="mini">导出 Excel</button>
</download-excel>
</view>
</view>
<view class="uni-container">
<unicloud-db ref="udb" :collection="collectionList" field="title,content,start_date,end_date,owner_id,background_picture,place,status,contact,invitee" :where="where" page-data="replace"
:orderby="orderby" :getcount="true" :page-size="options.pageSize" :page-current="options.pageCurrent"
v-slot:default="{data,pagination,loading,error,options}" :options="options" loadtime="manual" @load="onqueryload">
<uni-table ref="table" :loading="loading" :emptyText="error.message || '没有更多数据'" border stripe type="selection" @selection-change="selectionChange">
<uni-tr>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'title')" sortable @sort-change="sortChange($event, 'title')">标题</uni-th>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'content')" sortable @sort-change="sortChange($event, 'content')">内容</uni-th>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'start_date')" sortable @sort-change="sortChange($event, 'start_date')">开始时间</uni-th>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'end_date')" sortable @sort-change="sortChange($event, 'end_date')">结束时间</uni-th>
<uni-th align="center" sortable @sort-change="sortChange($event, 'owner_id')">发布者id</uni-th>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'background_picture')" sortable @sort-change="sortChange($event, 'background_picture')">背景图片</uni-th>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'place')" sortable @sort-change="sortChange($event, 'place')">地点</uni-th>
<uni-th align="center" sortable @sort-change="sortChange($event, 'status')">活动状态</uni-th>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'contact')" sortable @sort-change="sortChange($event, 'contact')">联系方式</uni-th>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'invitee')" sortable @sort-change="sortChange($event, 'invitee')">面向对象</uni-th>
<uni-th align="center">操作</uni-th>
</uni-tr>
<uni-tr v-for="(item,index) in data" :key="index">
<uni-td align="center">{{item.title}}</uni-td>
<uni-td align="center">{{item.content}}</uni-td>
<uni-td align="center">{{item.start_date}}</uni-td>
<uni-td align="center">{{item.end_date}}</uni-td>
<uni-td align="center">{{item.owner_id}}</uni-td>
<uni-td align="center">
<image :src="item.background_picture" style="width: 120px; height: 80px;"></image>
</uni-td>
<uni-td align="center">{{item.place}}</uni-td>
<uni-td align="center">{{item.status}}</uni-td>
<uni-td align="center">{{item.contact}}</uni-td>
<uni-td align="center">{{item.invitee}}</uni-td>
<uni-td align="center">
<view class="uni-group">
<button @click="navigateTo('./edit?id='+item._id, false)" class="uni-button" size="mini" type="primary">修改</button>
<button @click="confirmDelete(item._id)" class="uni-button" size="mini" type="warn">删除</button>
</view>
</uni-td>
</uni-tr>
</uni-table>
<view class="uni-pagination-box">
<uni-pagination show-icon :page-size="pagination.size" v-model="pagination.current" :total="pagination.count" @change="onPageChanged" />
</view>
</unicloud-db>
</view>
</view>
</template>
<script>
import { enumConverter, filterToWhere } from '../../../../js_sdk/validator/mustgo-school-activity.js';
const db = uniCloud.database()
// 表查询配置
const dbOrderBy = '' // 排序字段
const dbSearchFields = [] // 模糊搜索字段,支持模糊搜索的字段列表。联表查询格式: 主表字段名.副表字段名,例如用户表关联角色表 role.role_name
// 分页配置
const pageSize = 20
const pageCurrent = 1
const orderByMapping = {
"ascending": "asc",
"descending": "desc"
}
export default {
data() {
return {
collectionList: "mustgo-school-activity",
query: '',
where: '',
orderby: dbOrderBy,
orderByFieldName: "",
selectedIndexs: [],
options: {
pageSize,
pageCurrent,
filterData: {},
...enumConverter
},
imageStyles: {
width: 64,
height: 64
},
exportExcel: {
"filename": "mustgo-school-activity.xls",
"type": "xls",
"fields": {
"标题": "title",
"内容": "content",
"开始时间": "start_date",
"结束时间": "end_date",
"发布者id": "owner_id",
"背景图片": "background_picture",
"地点": "place",
"活动状态": "status",
"联系方式": "contact",
"面向对象": "invitee"
}
},
exportExcelData: []
}
},
onLoad() {
this._filter = {}
},
onReady() {
this.$refs.udb.loadData()
},
methods: {
onqueryload(data) {
this.exportExcelData = data
},
getWhere() {
const query = this.query.trim()
if (!query) {
return ''
}
const queryRe = new RegExp(query, 'i')
return dbSearchFields.map(name => queryRe + '.test(' + name + ')').join(' || ')
},
search() {
const newWhere = this.getWhere()
this.where = newWhere
this.$nextTick(() => {
this.loadData()
})
},
loadData(clear = true) {
this.$refs.udb.loadData({
clear
})
},
onPageChanged(e) {
this.selectedIndexs.length = 0
this.$refs.table.clearSelection()
this.$refs.udb.loadData({
current: e.current
})
},
navigateTo(url, clear) {
// clear 表示刷新列表时是否清除页码,true 表示刷新并回到列表第 1 页,默认为 true
uni.navigateTo({
url,
events: {
refreshData: () => {
this.loadData(clear)
}
}
})
},
// 多选处理
selectedItems() {
var dataList = this.$refs.udb.dataList
return this.selectedIndexs.map(i => dataList[i]._id)
},
// 批量删除
delTable() {
this.$refs.udb.remove(this.selectedItems(), {
success:(res) => {
this.$refs.table.clearSelection()
}
})
},
// 多选
selectionChange(e) {
this.selectedIndexs = e.detail.index
},
confirmDelete(id) {
this.$refs.udb.remove(id, {
success:(res) => {
this.$refs.table.clearSelection()
}
})
},
sortChange(e, name) {
this.orderByFieldName = name;
if (e.order) {
this.orderby = name + ' ' + orderByMapping[e.order]
} else {
this.orderby = ''
}
this.$refs.table.clearSelection()
this.$nextTick(() => {
this.$refs.udb.loadData()
})
},
filterChange(e, name) {
this._filter[name] = {
type: e.filterType,
value: e.filter
}
let newWhere = filterToWhere(this._filter, db.command)
if (Object.keys(newWhere).length) {
this.where = newWhere
} else {
this.where = ''
}
this.$nextTick(() => {
this.$refs.udb.loadData()
})
}
}
}
</script>
<style>
</style>
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validateTrigger="bind">
<uni-forms-item name="title" label="标题">
<uni-easyinput placeholder="小队活动标题" v-model="formData.title"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="content" label="内容">
<uni-easyinput placeholder="小队活动内容" v-model="formData.content"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="start_date" label="开始时间">
<uni-easyinput placeholder="小队活动开始时间" v-model="formData.start_date"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="end_date" label="结束时间">
<uni-easyinput placeholder="小队活动结束时间" v-model="formData.end_date"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="owner_id" label="发布者id">
<uni-easyinput placeholder="小队活动发布者id" v-model="formData.owner_id"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="background_picture" label="背景图片">
<uni-easyinput placeholder="小队活动背景图片" v-model="formData.background_picture"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="place" label="地点">
<uni-easyinput placeholder="小队活动地点" v-model="formData.place"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="status" label="活动状态">
<uni-easyinput placeholder="小队活动状态" type="number" v-model="formData.status"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="participants" label="参与人数">
<uni-easyinput placeholder="小队活动参与人数" type="number" v-model="formData.participants"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="contact" label="联系方式">
<uni-easyinput placeholder="小队活动发布者联系方式" v-model="formData.contact"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="team_id" label="小队id">
<uni-easyinput placeholder="活动所属小队id" v-model="formData.team_id"></uni-easyinput>
</uni-forms-item>
<view class="uni-button-group">
<button type="primary" class="uni-button" style="width: 100px;" @click="submit">提交</button>
<navigator open-type="navigateBack" style="margin-left: 15px;">
<button class="uni-button" style="width: 100px;">返回</button>
</navigator>
</view>
</uni-forms>
</view>
</template>
<script>
import { validator } from '../../../../js_sdk/validator/mustgo-team-activity.js';
const db = uniCloud.database();
const dbCmd = db.command;
const dbCollectionName = 'mustgo-team-activity';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.includes(key)) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"title": "",
"content": "",
"start_date": "",
"end_date": "",
"owner_id": "",
"background_picture": "",
"place": "",
"status": null,
"participants": null,
"contact": "",
"team_id": ""
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {
}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使用 clientDB 提交数据
return db.collection(dbCollectionName).add(value).then((res) => {
uni.showToast({
title: '新增成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
}
}
}
</script>
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validateTrigger="bind">
<uni-forms-item name="title" label="标题">
<uni-easyinput placeholder="小队活动标题" v-model="formData.title"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="content" label="内容">
<uni-easyinput placeholder="小队活动内容" v-model="formData.content"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="start_date" label="开始时间">
<uni-easyinput placeholder="小队活动开始时间" v-model="formData.start_date"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="end_date" label="结束时间">
<uni-easyinput placeholder="小队活动结束时间" v-model="formData.end_date"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="owner_id" label="发布者id">
<uni-easyinput placeholder="小队活动发布者id" v-model="formData.owner_id"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="background_picture" label="背景图片">
<uni-easyinput placeholder="小队活动背景图片" v-model="formData.background_picture"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="place" label="地点">
<uni-easyinput placeholder="小队活动地点" v-model="formData.place"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="status" label="活动状态">
<uni-easyinput placeholder="小队活动状态" type="number" v-model="formData.status"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="participants" label="参与人数">
<uni-easyinput placeholder="小队活动参与人数" type="number" v-model="formData.participants"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="contact" label="联系方式">
<uni-easyinput placeholder="小队活动发布者联系方式" v-model="formData.contact"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="team_id" label="小队id">
<uni-easyinput placeholder="活动所属小队id" v-model="formData.team_id"></uni-easyinput>
</uni-forms-item>
<view class="uni-button-group">
<button type="primary" class="uni-button" style="width: 100px;" @click="submit">提交</button>
<navigator open-type="navigateBack" style="margin-left: 15px;">
<button class="uni-button" style="width: 100px;">返回</button>
</navigator>
</view>
</uni-forms>
</view>
</template>
<script>
import { validator } from '../../../../js_sdk/validator/mustgo-team-activity.js';
const db = uniCloud.database();
const dbCmd = db.command;
const dbCollectionName = 'mustgo-team-activity';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.includes(key)) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"title": "",
"content": "",
"start_date": "",
"end_date": "",
"owner_id": "",
"background_picture": "",
"place": "",
"status": null,
"participants": null,
"contact": "",
"team_id": ""
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onLoad(e) {
if (e.id) {
const id = e.id
this.formDataId = id
this.getDetail(id)
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {
}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使用 clientDB 提交数据
return db.collection(dbCollectionName).doc(this.formDataId).update(value).then((res) => {
uni.showToast({
title: '修改成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
},
/**
* 获取表单数据
* @param {Object} id
*/
getDetail(id) {
uni.showLoading({
mask: true
})
db.collection(dbCollectionName).doc(id).field("title,content,start_date,end_date,owner_id,background_picture,place,status,participants,contact,team_id").get().then((res) => {
const data = res.result.data[0]
if (data) {
this.formData = data
}
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
}).finally(() => {
uni.hideLoading()
})
}
}
}
</script>
<template>
<view>
<view class="uni-header">
<view class="uni-group">
<view class="uni-title"></view>
<view class="uni-sub-title"></view>
</view>
<view class="uni-group">
<input class="uni-search" type="text" v-model="query" @confirm="search" placeholder="请输入搜索内容" />
<button class="uni-button" type="default" size="mini" @click="search">搜索</button>
<button class="uni-button" type="default" size="mini" @click="navigateTo('./add')">新增</button>
<button class="uni-button" type="default" size="mini" :disabled="!selectedIndexs.length" @click="delTable">批量删除</button>
<download-excel class="hide-on-phone" :fields="exportExcel.fields" :data="exportExcelData" :type="exportExcel.type" :name="exportExcel.filename">
<button class="uni-button" type="primary" size="mini">导出 Excel</button>
</download-excel>
</view>
</view>
<view class="uni-container">
<unicloud-db ref="udb" :collection="collectionList" field="title,content,start_date,end_date,owner_id,background_picture,place,status,participants,contact,team_id" :where="where" page-data="replace"
:orderby="orderby" :getcount="true" :page-size="options.pageSize" :page-current="options.pageCurrent"
v-slot:default="{data,pagination,loading,error,options}" :options="options" loadtime="manual" @load="onqueryload">
<uni-table ref="table" :loading="loading" :emptyText="error.message || '没有更多数据'" border stripe type="selection" @selection-change="selectionChange">
<uni-tr>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'title')" sortable @sort-change="sortChange($event, 'title')">标题</uni-th>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'content')" sortable @sort-change="sortChange($event, 'content')">内容</uni-th>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'start_date')" sortable @sort-change="sortChange($event, 'start_date')">开始时间</uni-th>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'end_date')" sortable @sort-change="sortChange($event, 'end_date')">结束时间</uni-th>
<uni-th align="center" sortable @sort-change="sortChange($event, 'owner_id')">发布者id</uni-th>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'background_picture')" sortable @sort-change="sortChange($event, 'background_picture')">背景图片</uni-th>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'place')" sortable @sort-change="sortChange($event, 'place')">地点</uni-th>
<uni-th align="center" sortable @sort-change="sortChange($event, 'status')">活动状态</uni-th>
<uni-th align="center" filter-type="range" @filter-change="filterChange($event, 'participants')" sortable @sort-change="sortChange($event, 'participants')">参与人数</uni-th>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'contact')" sortable @sort-change="sortChange($event, 'contact')">联系方式</uni-th>
<uni-th align="center" sortable @sort-change="sortChange($event, 'team_id')">小队id</uni-th>
<uni-th align="center">操作</uni-th>
</uni-tr>
<uni-tr v-for="(item,index) in data" :key="index">
<uni-td align="center">{{item.title}}</uni-td>
<uni-td align="center">{{item.content}}</uni-td>
<uni-td align="center">{{item.start_date}}</uni-td>
<uni-td align="center">{{item.end_date}}</uni-td>
<uni-td align="center">{{item.owner_id}}</uni-td>
<uni-td align="center">{{item.background_picture}}</uni-td>
<uni-td align="center">{{item.place}}</uni-td>
<uni-td align="center">{{item.status}}</uni-td>
<uni-td align="center">{{item.participants}}</uni-td>
<uni-td align="center">{{item.contact}}</uni-td>
<uni-td align="center">{{item.team_id}}</uni-td>
<uni-td align="center">
<view class="uni-group">
<button @click="navigateTo('./edit?id='+item._id, false)" class="uni-button" size="mini" type="primary">修改</button>
<button @click="confirmDelete(item._id)" class="uni-button" size="mini" type="warn">删除</button>
</view>
</uni-td>
</uni-tr>
</uni-table>
<view class="uni-pagination-box">
<uni-pagination show-icon :page-size="pagination.size" v-model="pagination.current" :total="pagination.count" @change="onPageChanged" />
</view>
</unicloud-db>
</view>
</view>
</template>
<script>
import { enumConverter, filterToWhere } from '../../../../js_sdk/validator/mustgo-team-activity.js';
const db = uniCloud.database()
// 表查询配置
const dbOrderBy = '' // 排序字段
const dbSearchFields = [] // 模糊搜索字段,支持模糊搜索的字段列表。联表查询格式: 主表字段名.副表字段名,例如用户表关联角色表 role.role_name
// 分页配置
const pageSize = 20
const pageCurrent = 1
const orderByMapping = {
"ascending": "asc",
"descending": "desc"
}
export default {
data() {
return {
collectionList: "mustgo-team-activity",
query: '',
where: '',
orderby: dbOrderBy,
orderByFieldName: "",
selectedIndexs: [],
options: {
pageSize,
pageCurrent,
filterData: {},
...enumConverter
},
imageStyles: {
width: 64,
height: 64
},
exportExcel: {
"filename": "mustgo-team-activity.xls",
"type": "xls",
"fields": {
"标题": "title",
"内容": "content",
"开始时间": "start_date",
"结束时间": "end_date",
"发布者id": "owner_id",
"背景图片": "background_picture",
"地点": "place",
"活动状态": "status",
"参与人数": "participants",
"联系方式": "contact",
"小队id": "team_id"
}
},
exportExcelData: []
}
},
onLoad() {
this._filter = {}
},
onReady() {
this.$refs.udb.loadData()
},
methods: {
onqueryload(data) {
this.exportExcelData = data
},
getWhere() {
const query = this.query.trim()
if (!query) {
return ''
}
const queryRe = new RegExp(query, 'i')
return dbSearchFields.map(name => queryRe + '.test(' + name + ')').join(' || ')
},
search() {
const newWhere = this.getWhere()
this.where = newWhere
this.$nextTick(() => {
this.loadData()
})
},
loadData(clear = true) {
this.$refs.udb.loadData({
clear
})
},
onPageChanged(e) {
this.selectedIndexs.length = 0
this.$refs.table.clearSelection()
this.$refs.udb.loadData({
current: e.current
})
},
navigateTo(url, clear) {
// clear 表示刷新列表时是否清除页码,true 表示刷新并回到列表第 1 页,默认为 true
uni.navigateTo({
url,
events: {
refreshData: () => {
this.loadData(clear)
}
}
})
},
// 多选处理
selectedItems() {
var dataList = this.$refs.udb.dataList
return this.selectedIndexs.map(i => dataList[i]._id)
},
// 批量删除
delTable() {
this.$refs.udb.remove(this.selectedItems(), {
success:(res) => {
this.$refs.table.clearSelection()
}
})
},
// 多选
selectionChange(e) {
this.selectedIndexs = e.detail.index
},
confirmDelete(id) {
this.$refs.udb.remove(id, {
success:(res) => {
this.$refs.table.clearSelection()
}
})
},
sortChange(e, name) {
this.orderByFieldName = name;
if (e.order) {
this.orderby = name + ' ' + orderByMapping[e.order]
} else {
this.orderby = ''
}
this.$refs.table.clearSelection()
this.$nextTick(() => {
this.$refs.udb.loadData()
})
},
filterChange(e, name) {
this._filter[name] = {
type: e.filterType,
value: e.filter
}
let newWhere = filterToWhere(this._filter, db.command)
if (Object.keys(newWhere).length) {
this.where = newWhere
} else {
this.where = ''
}
this.$nextTick(() => {
this.$refs.udb.loadData()
})
}
}
}
</script>
<style>
</style>
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validateTrigger="bind">
<uni-forms-item name="owner_id" label="评论人id">
<uni-easyinput placeholder="评论人id" v-model="formData.owner_id"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="date" label="发布时间">
<uni-easyinput placeholder="评论发布时间" v-model="formData.date"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="likes" label="点赞数">
<uni-easyinput placeholder="评论点赞数" type="number" v-model="formData.likes"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="post_id" label="帖子id">
<uni-easyinput placeholder="帖子id" v-model="formData.post_id"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="check_status" label="状态">
<switch @change="binddata('check_status', $event.detail.value)" :checked="formData.check_status"></switch>
</uni-forms-item>
<uni-forms-item name="content" label="评论内容">
<uni-easyinput placeholder="评论内容" v-model="formData.content"></uni-easyinput>
</uni-forms-item>
<view class="uni-button-group">
<button type="primary" class="uni-button" style="width: 100px;" @click="submit">提交</button>
<navigator open-type="navigateBack" style="margin-left: 15px;">
<button class="uni-button" style="width: 100px;">返回</button>
</navigator>
</view>
</uni-forms>
</view>
</template>
<script>
import { validator } from '../../../js_sdk/validator/mustgo-post-comment.js';
const db = uniCloud.database();
const dbCmd = db.command;
const dbCollectionName = 'mustgo-post-comment';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.includes(key)) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"owner_id": "",
"date": "",
"likes": null,
"post_id": "",
"check_status": null,
"content": ""
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {
}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使用 clientDB 提交数据
return db.collection(dbCollectionName).add(value).then((res) => {
uni.showToast({
title: '新增成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
}
}
}
</script>
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validateTrigger="bind">
<uni-forms-item name="owner_id" label="评论人id">
<uni-easyinput placeholder="评论人id" v-model="formData.owner_id"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="date" label="发布时间">
<uni-easyinput placeholder="评论发布时间" v-model="formData.date"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="likes" label="点赞数">
<uni-easyinput placeholder="评论点赞数" type="number" v-model="formData.likes"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="post_id" label="帖子id">
<uni-easyinput placeholder="帖子id" v-model="formData.post_id"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="check_status" label="状态">
<switch @change="binddata('check_status', $event.detail.value)" :checked="formData.check_status"></switch>
</uni-forms-item>
<uni-forms-item name="content" label="评论内容">
<uni-easyinput placeholder="评论内容" v-model="formData.content"></uni-easyinput>
</uni-forms-item>
<view class="uni-button-group">
<button type="primary" class="uni-button" style="width: 100px;" @click="submit">提交</button>
<navigator open-type="navigateBack" style="margin-left: 15px;">
<button class="uni-button" style="width: 100px;">返回</button>
</navigator>
</view>
</uni-forms>
</view>
</template>
<script>
import { validator } from '../../../js_sdk/validator/mustgo-post-comment.js';
const db = uniCloud.database();
const dbCmd = db.command;
const dbCollectionName = 'mustgo-post-comment';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.includes(key)) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"owner_id": "",
"date": "",
"likes": null,
"post_id": "",
"check_status": null,
"content": ""
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onLoad(e) {
if (e.id) {
const id = e.id
this.formDataId = id
this.getDetail(id)
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {
}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使用 clientDB 提交数据
return db.collection(dbCollectionName).doc(this.formDataId).update(value).then((res) => {
uni.showToast({
title: '修改成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
},
/**
* 获取表单数据
* @param {Object} id
*/
getDetail(id) {
uni.showLoading({
mask: true
})
db.collection(dbCollectionName).doc(id).field("owner_id,date,likes,post_id,check_status,content").get().then((res) => {
const data = res.result.data[0]
if (data) {
this.formData = data
}
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
}).finally(() => {
uni.hideLoading()
})
}
}
}
</script>
<template>
<view>
<view class="uni-header">
<view class="uni-group">
<view class="uni-title"></view>
<view class="uni-sub-title"></view>
</view>
<view class="uni-group">
<input class="uni-search" type="text" v-model="query" @confirm="search" placeholder="请输入搜索内容" />
<button class="uni-button" type="default" size="mini" @click="search">搜索</button>
<button class="uni-button" type="default" size="mini" @click="navigateTo('./add')">新增</button>
<button class="uni-button" type="default" size="mini" :disabled="!selectedIndexs.length" @click="delTable">批量删除</button>
<download-excel class="hide-on-phone" :fields="exportExcel.fields" :data="exportExcelData" :type="exportExcel.type" :name="exportExcel.filename">
<button class="uni-button" type="primary" size="mini">导出 Excel</button>
</download-excel>
</view>
</view>
<view class="uni-container">
<unicloud-db ref="udb" :collection="collectionList" field="owner_id,date,likes,post_id,check_status,content" :where="where" page-data="replace"
:orderby="orderby" :getcount="true" :page-size="options.pageSize" :page-current="options.pageCurrent"
v-slot:default="{data,pagination,loading,error,options}" :options="options" loadtime="manual" @load="onqueryload">
<uni-table ref="table" :loading="loading" :emptyText="error.message || '没有更多数据'" border stripe type="selection" @selection-change="selectionChange">
<uni-tr>
<uni-th align="center" sortable @sort-change="sortChange($event, 'owner_id')">评论人id</uni-th>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'date')" sortable @sort-change="sortChange($event, 'date')">发布时间</uni-th>
<uni-th align="center" filter-type="range" @filter-change="filterChange($event, 'likes')" sortable @sort-change="sortChange($event, 'likes')">点赞数</uni-th>
<uni-th align="center" sortable @sort-change="sortChange($event, 'post_id')">帖子id</uni-th>
<uni-th align="center" sortable @sort-change="sortChange($event, 'check_status')">状态</uni-th>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'content')" sortable @sort-change="sortChange($event, 'content')">评论内容</uni-th>
<uni-th align="center">操作</uni-th>
</uni-tr>
<uni-tr v-for="(item,index) in data" :key="index">
<uni-td align="center">{{item.owner_id}}</uni-td>
<uni-td align="center">{{item.date}}</uni-td>
<uni-td align="center">{{item.likes}}</uni-td>
<uni-td align="center">{{item.post_id}}</uni-td>
<uni-td align="center">{{item.check_status == true ? '' : ''}}</uni-td>
<uni-td align="center">{{item.content}}</uni-td>
<uni-td align="center">
<view class="uni-group">
<button @click="navigateTo('./edit?id='+item._id, false)" class="uni-button" size="mini" type="primary">修改</button>
<button @click="confirmDelete(item._id)" class="uni-button" size="mini" type="warn">删除</button>
</view>
</uni-td>
</uni-tr>
</uni-table>
<view class="uni-pagination-box">
<uni-pagination show-icon :page-size="pagination.size" v-model="pagination.current" :total="pagination.count" @change="onPageChanged" />
</view>
</unicloud-db>
</view>
</view>
</template>
<script>
import { enumConverter, filterToWhere } from '../../../js_sdk/validator/mustgo-post-comment.js';
const db = uniCloud.database()
// 表查询配置
const dbOrderBy = '' // 排序字段
const dbSearchFields = [] // 模糊搜索字段,支持模糊搜索的字段列表。联表查询格式: 主表字段名.副表字段名,例如用户表关联角色表 role.role_name
// 分页配置
const pageSize = 20
const pageCurrent = 1
const orderByMapping = {
"ascending": "asc",
"descending": "desc"
}
export default {
data() {
return {
collectionList: "mustgo-post-comment",
query: '',
where: '',
orderby: dbOrderBy,
orderByFieldName: "",
selectedIndexs: [],
options: {
pageSize,
pageCurrent,
filterData: {},
...enumConverter
},
imageStyles: {
width: 64,
height: 64
},
exportExcel: {
"filename": "mustgo-post-comment.xls",
"type": "xls",
"fields": {
"评论人id": "owner_id",
"发布时间": "date",
"点赞数": "likes",
"帖子id": "post_id",
"状态": "check_status",
"评论内容": "content"
}
},
exportExcelData: []
}
},
onLoad() {
this._filter = {}
},
onReady() {
this.$refs.udb.loadData()
},
methods: {
onqueryload(data) {
this.exportExcelData = data
},
getWhere() {
const query = this.query.trim()
if (!query) {
return ''
}
const queryRe = new RegExp(query, 'i')
return dbSearchFields.map(name => queryRe + '.test(' + name + ')').join(' || ')
},
search() {
const newWhere = this.getWhere()
this.where = newWhere
this.$nextTick(() => {
this.loadData()
})
},
loadData(clear = true) {
this.$refs.udb.loadData({
clear
})
},
onPageChanged(e) {
this.selectedIndexs.length = 0
this.$refs.table.clearSelection()
this.$refs.udb.loadData({
current: e.current
})
},
navigateTo(url, clear) {
// clear 表示刷新列表时是否清除页码,true 表示刷新并回到列表第 1 页,默认为 true
uni.navigateTo({
url,
events: {
refreshData: () => {
this.loadData(clear)
}
}
})
},
// 多选处理
selectedItems() {
var dataList = this.$refs.udb.dataList
return this.selectedIndexs.map(i => dataList[i]._id)
},
// 批量删除
delTable() {
this.$refs.udb.remove(this.selectedItems(), {
success:(res) => {
this.$refs.table.clearSelection()
}
})
},
// 多选
selectionChange(e) {
this.selectedIndexs = e.detail.index
},
confirmDelete(id) {
this.$refs.udb.remove(id, {
success:(res) => {
this.$refs.table.clearSelection()
}
})
},
sortChange(e, name) {
this.orderByFieldName = name;
if (e.order) {
this.orderby = name + ' ' + orderByMapping[e.order]
} else {
this.orderby = ''
}
this.$refs.table.clearSelection()
this.$nextTick(() => {
this.$refs.udb.loadData()
})
},
filterChange(e, name) {
this._filter[name] = {
type: e.filterType,
value: e.filter
}
let newWhere = filterToWhere(this._filter, db.command)
if (Object.keys(newWhere).length) {
this.where = newWhere
} else {
this.where = ''
}
this.$nextTick(() => {
this.$refs.udb.loadData()
})
}
}
}
</script>
<style>
</style>
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validateTrigger="bind">
<uni-forms-item name="content" label="内容">
<uni-easyinput placeholder="帖子内容" v-model="formData.content"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="date" label="发布时间">
<uni-easyinput placeholder="帖子发布时间" v-model="formData.date"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="likes" label="点赞数">
<uni-easyinput placeholder="帖子点赞数" type="number" v-model="formData.likes"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="owner_id" label="发帖人id">
<uni-easyinput placeholder="发帖人id" v-model="formData.owner_id"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="check_status" label="审核状态">
<switch @change="binddata('check_status', $event.detail.value)" :checked="formData.check_status"></switch>
</uni-forms-item>
<uni-forms-item name="comment_num" label="评论数">
<uni-easyinput placeholder="帖子评论数" type="number" v-model="formData.comment_num"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="url" label="图片url">
<uni-data-checkbox :multiple="true" v-model="formData.url"></uni-data-checkbox>
</uni-forms-item>
<view class="uni-button-group">
<button type="primary" class="uni-button" style="width: 100px;" @click="submit">提交</button>
<navigator open-type="navigateBack" style="margin-left: 15px;">
<button class="uni-button" style="width: 100px;">返回</button>
</navigator>
</view>
</uni-forms>
</view>
</template>
<script>
import { validator } from '../../../js_sdk/validator/mustgo-post.js';
const db = uniCloud.database();
const dbCmd = db.command;
const dbCollectionName = 'mustgo-post';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.includes(key)) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"content": "",
"date": "",
"likes": null,
"owner_id": "",
"check_status": null,
"comment_num": null,
"url": []
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {
}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使用 clientDB 提交数据
return db.collection(dbCollectionName).add(value).then((res) => {
uni.showToast({
title: '新增成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
}
}
}
</script>
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validateTrigger="bind">
<uni-forms-item name="content" label="内容">
<uni-easyinput placeholder="帖子内容" v-model="formData.content"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="date" label="发布时间">
<uni-easyinput placeholder="帖子发布时间" v-model="formData.date"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="likes" label="点赞数">
<uni-easyinput placeholder="帖子点赞数" type="number" v-model="formData.likes"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="owner_id" label="发帖人id">
<uni-easyinput placeholder="发帖人id" v-model="formData.owner_id"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="check_status" label="审核状态">
<switch @change="binddata('check_status', $event.detail.value)" :checked="formData.check_status"></switch>
</uni-forms-item>
<uni-forms-item name="comment_num" label="评论数">
<uni-easyinput placeholder="帖子评论数" type="number" v-model="formData.comment_num"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="url" label="图片url">
<uni-data-checkbox :multiple="true" v-model="formData.url"></uni-data-checkbox>
</uni-forms-item>
<view class="uni-button-group">
<button type="primary" class="uni-button" style="width: 100px;" @click="submit">提交</button>
<navigator open-type="navigateBack" style="margin-left: 15px;">
<button class="uni-button" style="width: 100px;">返回</button>
</navigator>
</view>
</uni-forms>
</view>
</template>
<script>
import { validator } from '../../../js_sdk/validator/mustgo-post.js';
const db = uniCloud.database();
const dbCmd = db.command;
const dbCollectionName = 'mustgo-post';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.includes(key)) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"content": "",
"date": "",
"likes": null,
"owner_id": "",
"check_status": null,
"comment_num": null,
"url": []
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onLoad(e) {
if (e.id) {
const id = e.id
this.formDataId = id
this.getDetail(id)
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {
}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使用 clientDB 提交数据
return db.collection(dbCollectionName).doc(this.formDataId).update(value).then((res) => {
uni.showToast({
title: '修改成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
},
/**
* 获取表单数据
* @param {Object} id
*/
getDetail(id) {
uni.showLoading({
mask: true
})
db.collection(dbCollectionName).doc(id).field("content,date,likes,owner_id,check_status,comment_num,url").get().then((res) => {
const data = res.result.data[0]
if (data) {
this.formData = data
}
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
}).finally(() => {
uni.hideLoading()
})
}
}
}
</script>
<template>
<view>
<view class="uni-header">
<view class="uni-group">
<view class="uni-title"></view>
<view class="uni-sub-title"></view>
</view>
<view class="uni-group">
<input class="uni-search" type="text" v-model="query" @confirm="search" placeholder="请输入搜索内容" />
<button class="uni-button" type="default" size="mini" @click="search">搜索</button>
<button class="uni-button" type="default" size="mini" @click="navigateTo('./add')">新增</button>
<button class="uni-button" type="default" size="mini" :disabled="!selectedIndexs.length" @click="delTable">批量删除</button>
<download-excel class="hide-on-phone" :fields="exportExcel.fields" :data="exportExcelData" :type="exportExcel.type" :name="exportExcel.filename">
<button class="uni-button" type="primary" size="mini">导出 Excel</button>
</download-excel>
</view>
</view>
<view class="uni-container">
<unicloud-db ref="udb" :collection="collectionList" field="content,date,likes,owner_id,check_status,comment_num,url" :where="where" page-data="replace"
:orderby="orderby" :getcount="true" :page-size="options.pageSize" :page-current="options.pageCurrent"
v-slot:default="{data,pagination,loading,error,options}" :options="options" loadtime="manual" @load="onqueryload">
<uni-table ref="table" :loading="loading" :emptyText="error.message || '没有更多数据'" border stripe type="selection" @selection-change="selectionChange">
<uni-tr>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'content')" sortable @sort-change="sortChange($event, 'content')">内容</uni-th>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'date')" sortable @sort-change="sortChange($event, 'date')">发布时间</uni-th>
<uni-th align="center" filter-type="range" @filter-change="filterChange($event, 'likes')" sortable @sort-change="sortChange($event, 'likes')">点赞数</uni-th>
<uni-th align="center" sortable @sort-change="sortChange($event, 'owner_id')">发帖人id</uni-th>
<uni-th align="center" sortable @sort-change="sortChange($event, 'check_status')">审核状态</uni-th>
<uni-th align="center" filter-type="range" @filter-change="filterChange($event, 'comment_num')" sortable @sort-change="sortChange($event, 'comment_num')">评论数</uni-th>
<uni-th align="center" sortable @sort-change="sortChange($event, 'url')">图片url</uni-th>
<uni-th align="center">操作</uni-th>
</uni-tr>
<uni-tr v-for="(item,index) in data" :key="index">
<uni-td align="center">{{item.content}}</uni-td>
<uni-td align="center">{{item.date}}</uni-td>
<uni-td align="center">{{item.likes}}</uni-td>
<uni-td align="center">{{item.owner_id}}</uni-td>
<uni-td align="center">{{item.check_status == true ? '' : ''}}</uni-td>
<uni-td align="center">{{item.comment_num}}</uni-td>
<uni-td align="center">{{item.url}}</uni-td>
<uni-td align="center">
<view class="uni-group">
<button @click="navigateTo('./edit?id='+item._id, false)" class="uni-button" size="mini" type="primary">修改</button>
<button @click="confirmDelete(item._id)" class="uni-button" size="mini" type="warn">删除</button>
</view>
</uni-td>
</uni-tr>
</uni-table>
<view class="uni-pagination-box">
<uni-pagination show-icon :page-size="pagination.size" v-model="pagination.current" :total="pagination.count" @change="onPageChanged" />
</view>
</unicloud-db>
</view>
</view>
</template>
<script>
import { enumConverter, filterToWhere } from '../../../js_sdk/validator/mustgo-post.js';
const db = uniCloud.database()
// 表查询配置
const dbOrderBy = '' // 排序字段
const dbSearchFields = [] // 模糊搜索字段,支持模糊搜索的字段列表。联表查询格式: 主表字段名.副表字段名,例如用户表关联角色表 role.role_name
// 分页配置
const pageSize = 20
const pageCurrent = 1
const orderByMapping = {
"ascending": "asc",
"descending": "desc"
}
export default {
data() {
return {
collectionList: "mustgo-post",
query: '',
where: '',
orderby: dbOrderBy,
orderByFieldName: "",
selectedIndexs: [],
options: {
pageSize,
pageCurrent,
filterData: {},
...enumConverter
},
imageStyles: {
width: 64,
height: 64
},
exportExcel: {
"filename": "mustgo-post.xls",
"type": "xls",
"fields": {
"内容": "content",
"发布时间": "date",
"点赞数": "likes",
"发帖人id": "owner_id",
"审核状态": "check_status",
"评论数": "comment_num",
"图片url": "url"
}
},
exportExcelData: []
}
},
onLoad() {
this._filter = {}
},
onReady() {
this.$refs.udb.loadData()
},
methods: {
onqueryload(data) {
this.exportExcelData = data
},
getWhere() {
const query = this.query.trim()
if (!query) {
return ''
}
const queryRe = new RegExp(query, 'i')
return dbSearchFields.map(name => queryRe + '.test(' + name + ')').join(' || ')
},
search() {
const newWhere = this.getWhere()
this.where = newWhere
this.$nextTick(() => {
this.loadData()
})
},
loadData(clear = true) {
this.$refs.udb.loadData({
clear
})
},
onPageChanged(e) {
this.selectedIndexs.length = 0
this.$refs.table.clearSelection()
this.$refs.udb.loadData({
current: e.current
})
},
navigateTo(url, clear) {
// clear 表示刷新列表时是否清除页码,true 表示刷新并回到列表第 1 页,默认为 true
uni.navigateTo({
url,
events: {
refreshData: () => {
this.loadData(clear)
}
}
})
},
// 多选处理
selectedItems() {
var dataList = this.$refs.udb.dataList
return this.selectedIndexs.map(i => dataList[i]._id)
},
// 批量删除
delTable() {
this.$refs.udb.remove(this.selectedItems(), {
success:(res) => {
this.$refs.table.clearSelection()
}
})
},
// 多选
selectionChange(e) {
this.selectedIndexs = e.detail.index
},
confirmDelete(id) {
this.$refs.udb.remove(id, {
success:(res) => {
this.$refs.table.clearSelection()
}
})
},
sortChange(e, name) {
this.orderByFieldName = name;
if (e.order) {
this.orderby = name + ' ' + orderByMapping[e.order]
} else {
this.orderby = ''
}
this.$refs.table.clearSelection()
this.$nextTick(() => {
this.$refs.udb.loadData()
})
},
filterChange(e, name) {
this._filter[name] = {
type: e.filterType,
value: e.filter
}
let newWhere = filterToWhere(this._filter, db.command)
if (Object.keys(newWhere).length) {
this.where = newWhere
} else {
this.where = ''
}
this.$nextTick(() => {
this.$refs.udb.loadData()
})
}
}
}
</script>
<style>
</style>
......@@ -19,15 +19,15 @@
<uni-forms-item name="pace" label="配速">
<uni-easyinput placeholder="运动配速" type="number" v-model="formData.pace"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="path_line" label="路线">
<!-- <uni-forms-item name="path_line" label="路线">
<uni-data-checkbox :multiple="true" v-model="formData.path_line"></uni-data-checkbox>
</uni-forms-item>
<uni-forms-item name="start_point" label="起始地点">
<undefined v-model="formData.start_point"></undefined>
<uni-easyinput v-model="formData.start_point"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="end_point" label="结束地点">
<undefined v-model="formData.end_point"></undefined>
</uni-forms-item>
</uni-forms-item> -->
<view class="uni-button-group">
<button type="primary" class="uni-button" style="width: 100px;" @click="submit">提交</button>
<navigator open-type="navigateBack" style="margin-left: 15px;">
......
......@@ -8,7 +8,7 @@
<view class="uni-group">
<input class="uni-search" type="text" v-model="query" @confirm="search" placeholder="请输入搜索内容" />
<button class="uni-button" type="default" size="mini" @click="search">搜索</button>
<button class="uni-button" type="default" size="mini" @click="navigateTo('./add')">新增</button>
<!-- <button class="uni-button" type="default" size="mini" @click="navigateTo('./add')">新增</button> -->
<button class="uni-button" type="default" size="mini" :disabled="!selectedIndexs.length" @click="delTable">批量删除</button>
<download-excel class="hide-on-phone" :fields="exportExcel.fields" :data="exportExcelData" :type="exportExcel.type" :name="exportExcel.filename">
<button class="uni-button" type="primary" size="mini">导出 Excel</button>
......
......@@ -16,10 +16,10 @@
<uni-forms-item name="distance" label="距离">
<uni-easyinput placeholder="运动距离" type="number" v-model="formData.distance"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="steps" label="步数">
<uni-easyinput placeholder="健走步数" type="number" v-model="formData.steps"></uni-easyinput>
<uni-forms-item name="pace" label="配速">
<uni-easyinput placeholder="运动配速" type="number" v-model="formData.pace"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="start_point" label="起始地点">
<!-- <uni-forms-item name="start_point" label="起始地点">
<undefined v-model="formData.start_point"></undefined>
</uni-forms-item>
<uni-forms-item name="end_point" label="结束地点">
......@@ -27,7 +27,7 @@
</uni-forms-item>
<uni-forms-item name="path_line" label="路线">
<uni-data-checkbox :multiple="true" v-model="formData.path_line"></uni-data-checkbox>
</uni-forms-item>
</uni-forms-item> -->
<view class="uni-button-group">
<button type="primary" class="uni-button" style="width: 100px;" @click="submit">提交</button>
<navigator open-type="navigateBack" style="margin-left: 15px;">
......@@ -65,7 +65,7 @@
"feelings": "",
"owner_id": "",
"distance": null,
"steps": null,
"pace": null,
"start_point": null,
"end_point": null,
"path_line": []
......@@ -132,7 +132,7 @@
uni.showLoading({
mask: true
})
db.collection(dbCollectionName).doc(id).field("start_date,duration,feelings,owner_id,distance,steps,start_point,end_point,path_line").get().then((res) => {
db.collection(dbCollectionName).doc(id).field("start_date,duration,feelings,owner_id,distance,pace,start_point,end_point,path_line").get().then((res) => {
const data = res.result.data[0]
if (data) {
this.formData = data
......
......@@ -8,7 +8,7 @@
<view class="uni-group">
<input class="uni-search" type="text" v-model="query" @confirm="search" placeholder="请输入搜索内容" />
<button class="uni-button" type="default" size="mini" @click="search">搜索</button>
<button class="uni-button" type="default" size="mini" @click="navigateTo('./add')">新增</button>
<!-- <button class="uni-button" type="default" size="mini" @click="navigateTo('./add')">新增</button> -->
<button class="uni-button" type="default" size="mini" :disabled="!selectedIndexs.length" @click="delTable">批量删除</button>
<download-excel class="hide-on-phone" :fields="exportExcel.fields" :data="exportExcelData" :type="exportExcel.type" :name="exportExcel.filename">
<button class="uni-button" type="primary" size="mini">导出 Excel</button>
......@@ -16,17 +16,17 @@
</view>
</view>
<view class="uni-container">
<unicloud-db ref="udb" :collection="collectionList" field="start_date,duration,feelings,owner_id,distance,steps,start_point,end_point,path_line" :where="where" page-data="replace"
<unicloud-db ref="udb" :collection="collectionList" field="start_date,duration,feelings,owner_id,distance,pace,start_point,end_point,path_line" :where="where" page-data="replace"
:orderby="orderby" :getcount="true" :page-size="options.pageSize" :page-current="options.pageCurrent"
v-slot:default="{data,pagination,loading,error,options}" :options="options" loadtime="manual" @load="onqueryload">
<uni-table ref="table" :loading="loading" :emptyText="error.message || '没有更多数据'" border stripe type="selection" @selection-change="selectionChange">
<uni-tr>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'start_date')" sortable @sort-change="sortChange($event, 'start_date')">开始时间</uni-th>
<uni-th align="center" filter-type="range" @filter-change="filterChange($event, 'duration')" sortable @sort-change="sortChange($event, 'duration')">持续时间(秒)</uni-th>
<uni-th align="center" filter-type="range" @filter-change="filterChange($event, 'duration')" sortable @sort-change="sortChange($event, 'duration')">持续时间</uni-th>
<uni-th align="center" filter-type="search" @filter-change="filterChange($event, 'feelings')" sortable @sort-change="sortChange($event, 'feelings')">感受</uni-th>
<uni-th align="center" sortable @sort-change="sortChange($event, 'owner_id')">用户id</uni-th>
<uni-th align="center" filter-type="range" @filter-change="filterChange($event, 'distance')" sortable @sort-change="sortChange($event, 'distance')">距离</uni-th>
<uni-th align="center" filter-type="range" @filter-change="filterChange($event, 'steps')" sortable @sort-change="sortChange($event, 'steps')">步数</uni-th>
<uni-th align="center" filter-type="range" @filter-change="filterChange($event, 'pace')" sortable @sort-change="sortChange($event, 'pace')">配速</uni-th>
<uni-th align="center" sortable @sort-change="sortChange($event, 'start_point')">起始地点</uni-th>
<uni-th align="center" sortable @sort-change="sortChange($event, 'end_point')">结束地点</uni-th>
<uni-th align="center" sortable @sort-change="sortChange($event, 'path_line')">路线</uni-th>
......@@ -38,7 +38,7 @@
<uni-td align="center">{{item.feelings}}</uni-td>
<uni-td align="center">{{item.owner_id}}</uni-td>
<uni-td align="center">{{item.distance}}</uni-td>
<uni-td align="center">{{item.steps}}</uni-td>
<uni-td align="center">{{item.pace}}</uni-td>
<uni-td align="center">{{item.start_point}}</uni-td>
<uni-td align="center">{{item.end_point}}</uni-td>
<uni-td align="center">{{item.path_line}}</uni-td>
......@@ -102,7 +102,7 @@
"感受": "feelings",
"用户id": "owner_id",
"距离": "distance",
"步数": "steps",
"配速": "pace",
"起始地点": "start_point",
"结束地点": "end_point",
"路线": "path_line"
......
......@@ -88,19 +88,6 @@
filterToWhere
} from '../../../js_sdk/validator/mustgo-user.js';
console.log(Date.now().toString());
uniCloud.callFunction({
name: 'fe-retrievePassword',
data: {
phone: "13950014724",
code: "123456",
password: "12345678"
}
})
.then(res => {
console.log(res);
});
const db = uniCloud.database()
// 表查询配置
const dbOrderBy = '' // 排序字段
......
......@@ -16,7 +16,15 @@ exports.main = async (event, context) => {
code: 200,
message: "登录成功",
data: {
userId: res.data[0]["_id"]
userId: res.data[0]["_id"],
name: res.data[0]["name"],
gender: res.data[0]["gender"],
phone_num: res.data[0]["phone_num"],
team_id: res.data[0]["team_id"],
school: res.data[0]["school"],
type: res.data[0]["type"],
total_running_distance: res.data[0]["total_running_distance"],
total_walking_distance: res.data[0]["total_walking_distance"]
}
}
......
{"bsonType":"object","required":[],"permission":{"read":false,"create":false,"update":false,"delete":false},"properties":{"_id":{"description":"ID,系统自动生成"}}}
\ No newline at end of file
{
"bsonType": "object",
"required": [],
"permission": {
"read": true,
"create": true,
"update": true,
"delete": true
},
"properties": {
"_id": {
"title": "id",
"description": "ID,系统自动生成"
},
"owner_id": {
"bsonType": "string",
"title": "评论人id",
"description": "评论人id",
"foreignKey": "mustgo-user._id"
},
"date": {
"bsonType": "string",
"title": "发布时间",
"description": "评论发布时间"
},
"likes": {
"bsonType": "int",
"title": "点赞数",
"description": "评论点赞数"
},
"post_id": {
"bsonType": "string",
"title": "帖子id",
"description": "帖子id",
"foreignKey": "mustgo-post._id"
},
"check_status": {
"bsonType": "bool",
"title": "状态",
"description": "评论是否过通过审查"
},
"content": {
"bsonType": "string",
"title": "评论内容",
"description": "评论内容"
}
}
}
\ No newline at end of file
{"bsonType":"object","required":[],"permission":{"read":true,"create":false,"update":false,"delete":false},"properties":{"_id":{"title":"id","description":"ID,系统自动生成"},"content":{"bsonType":"string","title":"内容","description":"帖子内容"},"date":{"bsonType":"string","title":"发布时间","description":"帖子发布时间"},"likes":{"bsonType":"int","title":"点赞数","description":"帖子点赞数"},"owner_id":{"bsonType":"string","title":"发帖人id","description":"发帖人id","foreignKey":"mustgo-user._id"},"check_status":{"bsonType":"bool","title":"审核状态","description":"帖子审核状态"},"comment_num":{"bsonType":"int","title":"评论数","description":"帖子评论数"},"url":{"bsonType":"array","title":"图片url","description":"帖子中图片url的数组"}}}
\ No newline at end of file
{
"bsonType": "object",
"required": [],
"permission": {
"read": true,
"create": false,
"update": false,
"delete": false
},
"properties": {
"_id": {
"title": "id",
"description": "ID,系统自动生成"
},
"content": {
"bsonType": "string",
"title": "内容",
"description": "帖子内容"
},
"date": {
"bsonType": "string",
"title": "发布时间",
"description": "帖子发布时间"
},
"likes": {
"bsonType": "int",
"title": "点赞数",
"description": "帖子点赞数"
},
"owner_id": {
"bsonType": "string",
"title": "发帖人id",
"description": "发帖人id",
"foreignKey": "mustgo-user._id"
},
"check_status": {
"bsonType": "bool",
"title": "审核状态",
"description": "帖子审核状态"
},
"comment_num": {
"bsonType": "int",
"title": "评论数",
"description": "帖子评论数"
},
"url": {
"bsonType": "array",
"title": "图片url",
"description": "帖子中图片url的数组"
}
}
}
\ No newline at end of file
{"bsonType":"object","required":[],"permission":{"read":true,"create":true,"update":true,"delete":true},"properties":{"_id":{"title":"id","description":"ID,系统自动生成"},"title":{"bsonType":"string","title":"标题","description":"校园活动标题"},"content":{"bsonType":"string","title":"内容","description":"校园活动内容"},"start_date":{"bsonType":"string","title":"开始时间","description":"校园活动开始时间"},"end_date":{"bsonType":"string","title":"结束时间","description":"校园活动结束时间"},"owner_id":{"bsonType":"string","foreignKey":"mustgo-user._id","title":"发布者id","description":"校园活动发布者id"},"background_picture":{"bsonType":"string","title":"背景图片","description":"校园活动背景图片"},"place":{"bsonType":"string","title":"地点","description":"校园活动地点"},"status":{"bsonType":"int","foreignKey":"mustgo-activity-status.id","title":"活动状态","description":"校园活动状态"},"contact":{"bsonType":"string","title":"联系方式","description":"校园活动发布者联系方式"},"invitee":{"bsonType":"string","title":"面向对象","description":"校园活动面向对象"}}}
\ No newline at end of file
{
"bsonType": "object",
"required": [],
"permission": {
"read": true,
"create": true,
"update": true,
"delete": true
},
"properties": {
"_id": {
"title": "id",
"description": "ID,系统自动生成"
},
"title": {
"bsonType": "string",
"title": "标题",
"description": "校园活动标题"
},
"content": {
"bsonType": "string",
"title": "内容",
"description": "校园活动内容"
},
"start_date": {
"bsonType": "string",
"title": "开始时间",
"description": "校园活动开始时间"
},
"end_date": {
"bsonType": "string",
"title": "结束时间",
"description": "校园活动结束时间"
},
"owner_id": {
"bsonType": "string",
"foreignKey": "mustgo-user._id",
"title": "发布者id",
"description": "校园活动发布者id"
},
"background_picture": {
"bsonType": "string",
"title": "背景图片",
"description": "校园活动背景图片"
},
"place": {
"bsonType": "string",
"title": "地点",
"description": "校园活动地点"
},
"status": {
"bsonType": "int",
"foreignKey": "mustgo-activity-status.id",
"title": "活动状态",
"description": "校园活动状态"
},
"contact": {
"bsonType": "string",
"title": "联系方式",
"description": "校园活动发布者联系方式"
},
"invitee": {
"bsonType": "string",
"title": "面向对象",
"description": "校园活动面向对象"
}
}
}
\ No newline at end of file
{"bsonType":"object","required":[],"permission":{"read":true,"create":true,"update":true,"delete":true},"properties":{"_id":{"title":"id","description":"ID,系统自动生成"},"title":{"bsonType":"string","title":"标题","description":"小队活动标题"},"content":{"bsonType":"string","title":"内容","description":"小队活动内容"},"start_date":{"bsonType":"string","title":"开始时间","description":"小队活动开始时间"},"end_date":{"bsonType":"string","title":"结束时间","description":"小队活动结束时间"},"owner_id":{"bsonType":"string","foreignKey":"mustgo-user._id","title":"发布者id","description":"小队活动发布者id"},"background_picture":{"bsonType":"string","title":"背景图片","description":"小队活动背景图片"},"place":{"bsonType":"string","title":"地点","description":"小队活动地点"},"status":{"bsonType":"int","foreignKey":"mustgo-activity-status.id","title":"活动状态","description":"小队活动状态"},"participants":{"bsonType":"int","title":"参与人数","description":"小队活动参与人数"},"contact":{"bsonType":"string","title":"联系方式","description":"小队活动发布者联系方式"},"team_id":{"bsonType":"string","foreignKey":"mustgo-team._id","title":"小队id","description":"活动所属小队id"}}}
\ No newline at end of file
{
"bsonType": "object",
"required": [],
"permission": {
"read": true,
"create": true,
"update": true,
"delete": true
},
"properties": {
"_id": {
"title": "id",
"description": "ID,系统自动生成"
},
"title": {
"bsonType": "string",
"title": "标题",
"description": "小队活动标题"
},
"content": {
"bsonType": "string",
"title": "内容",
"description": "小队活动内容"
},
"start_date": {
"bsonType": "string",
"title": "开始时间",
"description": "小队活动开始时间"
},
"end_date": {
"bsonType": "string",
"title": "结束时间",
"description": "小队活动结束时间"
},
"owner_id": {
"bsonType": "string",
"foreignKey": "mustgo-user._id",
"title": "发布者id",
"description": "小队活动发布者id"
},
"background_picture": {
"bsonType": "string",
"title": "背景图片",
"description": "小队活动背景图片"
},
"place": {
"bsonType": "string",
"title": "地点",
"description": "小队活动地点"
},
"status": {
"bsonType": "int",
"foreignKey": "mustgo-activity-status.id",
"title": "活动状态",
"description": "小队活动状态"
},
"participants": {
"bsonType": "int",
"title": "参与人数",
"description": "小队活动参与人数"
},
"contact": {
"bsonType": "string",
"title": "联系方式",
"description": "小队活动发布者联系方式"
},
"team_id": {
"bsonType": "string",
"foreignKey": "mustgo-team._id",
"title": "小队id",
"description": "活动所属小队id"
}
}
}
\ No newline at end of file
{"bsonType":"object","required":[],"permission":{"read":true,"create":true,"update":true,"delete":true},"properties":{"_id":{"title":"id","description":"ID,系统自动生成"},"start_date":{"bsonType":"string","title":"开始时间","description":"运动开始时间"},"duration":{"bsonType":"int","title":"持续时间","description":"运动持续时间"},"feelings":{"bsonType":"string","title":"感受","description":"运动感受"},"owner_id":{"bsonType":"string","title":"用户id","description":"用户id","foreignKey":"mustgo-user._id"},"distance":{"bsonType":"double","title":"距离","description":"运动距离"},"steps":{"bsonType":"int","title":"步数","description":"健走步数"},"start_point":{"bsonType":"object","title":"起始地点","description":"运动起始地点,经纬度"},"end_point":{"bsonType":"object","title":"结束地点","description":"运动结束地点,经纬度"},"path_line":{"bsonType":"array","title":"路线","description":"运动路线"}}}
\ No newline at end of file
{
"bsonType": "object",
"required": [],
"permission": {
"read": true,
"create": true,
"update": true,
"delete": true
},
"properties": {
"_id": {
"title": "id",
"description": "ID,系统自动生成"
},
"start_date": {
"bsonType": "string",
"title": "开始时间",
"description": "运动开始时间"
},
"duration": {
"bsonType": "int",
"title": "持续时间",
"description": "运动持续时间"
},
"feelings": {
"bsonType": "string",
"title": "感受",
"description": "运动感受"
},
"owner_id": {
"bsonType": "string",
"title": "用户id",
"description": "用户id",
"foreignKey": "mustgo-user._id"
},
"distance": {
"bsonType": "double",
"title": "距离",
"description": "运动距离"
},
"pace": {
"bsonType": "double",
"title": "配速",
"description": "运动配速"
},
"start_point": {
"bsonType": "object",
"title": "起始地点",
"description": "运动起始地点,经纬度"
},
"end_point": {
"bsonType": "object",
"title": "结束地点",
"description": "运动结束地点,经纬度"
},
"path_line": {
"bsonType": "array",
"title": "路线",
"description": "运动路线"
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册