【优化】代码生成器适配uv版本移动端

pull/165/head
877617829 2023-09-17 20:26:27 +08:00
parent ecd9131930
commit 543373d58a
14 changed files with 241 additions and 246 deletions

View File

@ -86,6 +86,7 @@
:options="mobileModuleList" :options="mobileModuleList"
style="width: 100%" style="width: 100%"
placeholder="请选择移动端所属模块" placeholder="请选择移动端所属模块"
allow-clear
> >
</a-select> </a-select>
</a-form-item> </a-form-item>
@ -312,7 +313,6 @@
generateType: [required('请选择生成方式')], generateType: [required('请选择生成方式')],
module: [required('请选择所属模块')], module: [required('请选择所属模块')],
menuPid: [required('请选择上级目录')], menuPid: [required('请选择上级目录')],
mobileModule: [required('请选择移动端所属模块')],
functionName: [required('请输入功能名')], functionName: [required('请输入功能名')],
busName: [required('请输入业务名')], busName: [required('请输入业务名')],
className: [required('请输入类名')], className: [required('请输入类名')],

View File

@ -54,11 +54,6 @@
codeTypeTitle: '前端代码', codeTypeTitle: '前端代码',
codeTypeList: data.genBasicCodeFrontendResultList codeTypeList: data.genBasicCodeFrontendResultList
}, },
{
codeTypeKey: 'mobile',
codeTypeTitle: '移动端代码',
codeTypeList: data.genBasicCodeMobileResultList
},
{ {
codeTypeKey: 'backend', codeTypeKey: 'backend',
codeTypeTitle: '后端代码', codeTypeTitle: '后端代码',
@ -70,6 +65,13 @@
codeTypeList: data.genBasicCodeSqlResultList codeTypeList: data.genBasicCodeSqlResultList
} }
] ]
if (data.genBasicCodeMobileResultList){
codeTypeArray.value.push({
codeTypeKey: 'mobile',
codeTypeTitle: '移动端代码',
codeTypeList: data.genBasicCodeMobileResultList
})
}
} else { } else {
message.warning('预览失败:请检查问题或反馈小诺官方') message.warning('预览失败:请检查问题或反馈小诺官方')
} }

View File

@ -12,6 +12,8 @@
*/ */
package vip.xiaonuo.gen.modular.basic.entity; package vip.xiaonuo.gen.modular.basic.entity;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
@ -67,6 +69,7 @@ public class GenBasic extends CommonEntity {
/** 移动端所属模块 */ /** 移动端所属模块 */
@ApiModelProperty(value = "移动端所属模块", position = 10) @ApiModelProperty(value = "移动端所属模块", position = 10)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String mobileModule; private String mobileModule;
/** 功能名 */ /** 功能名 */

View File

@ -70,7 +70,6 @@ public class GenBasicAddParam {
/** 移动端所属模块 */ /** 移动端所属模块 */
@ApiModelProperty(value = "移动端所属模块", required = true, position = 9) @ApiModelProperty(value = "移动端所属模块", required = true, position = 9)
@NotNull(message = "mobileModule不能为空")
private String mobileModule; private String mobileModule;
/** 功能名 */ /** 功能名 */

View File

@ -75,7 +75,6 @@ public class GenBasicEditParam {
/** 移动端所属模块 */ /** 移动端所属模块 */
@ApiModelProperty(value = "移动端所属模块", required = true, position = 10) @ApiModelProperty(value = "移动端所属模块", required = true, position = 10)
@NotNull(message = "mobileModule不能为空")
private String mobileModule; private String mobileModule;
/** 功能名 */ /** 功能名 */

View File

@ -459,6 +459,9 @@ public class GenBasicServiceImpl extends ServiceImpl<GenBasicMapper, GenBasic> i
FileUtil.writeUtf8String(genBasicCodeResult.getCodeFileContent(), FileUtil.file(tempFolder + File.separator FileUtil.writeUtf8String(genBasicCodeResult.getCodeFileContent(), FileUtil.file(tempFolder + File.separator
+ "backend" + File.separator + genBasicCodeResult.getCodeFileWithPathName()))); + "backend" + File.separator + genBasicCodeResult.getCodeFileWithPathName())));
// 生成移动端代码到临时目录 // 生成移动端代码到临时目录
if (ObjectUtil.isEmpty(genBasic.getMobileModule())){
return tempFolder;
}
genBasicPreviewResult.getGenBasicCodeMobileResultList().forEach(genBasicCodeResult -> genBasicPreviewResult.getGenBasicCodeMobileResultList().forEach(genBasicCodeResult ->
FileUtil.writeUtf8String(genBasicCodeResult.getCodeFileContent(), FileUtil.file(tempFolder + File.separator FileUtil.writeUtf8String(genBasicCodeResult.getCodeFileContent(), FileUtil.file(tempFolder + File.separator
+ "mobile" + File.separator + genBasicCodeResult.getCodeFileWithPathName()))); + "mobile" + File.separator + genBasicCodeResult.getCodeFileWithPathName())));
@ -541,6 +544,9 @@ public class GenBasicServiceImpl extends ServiceImpl<GenBasicMapper, GenBasic> i
genBasicPreviewResult.setGenBasicCodeBackendResultList(genBasicCodeBackendResultList); genBasicPreviewResult.setGenBasicCodeBackendResultList(genBasicCodeBackendResultList);
// 移动端基础路径 // 移动端基础路径
if (ObjectUtil.isEmpty(genBasic.getMobileModule())){
return genBasicPreviewResult;
}
String genMobileBasicPath = ""; String genMobileBasicPath = "";
// 移动端 // 移动端
GroupTemplate groupTemplateMobile = new GroupTemplate(new ClasspathResourceLoader("mobile"), Configuration.defaultConfiguration()); GroupTemplate groupTemplateMobile = new GroupTemplate(new ClasspathResourceLoader("mobile"), Configuration.defaultConfiguration());

View File

@ -2,7 +2,7 @@ import request from '@/utils/request'
// 获取${functionName}分页 // 获取${functionName}分页
export function ${classNameFirstLower}Page(data) { export function ${classNameFirstLower}Page(data) {
return request({ return request({
url: '/${moduleName}/${busName}/page', url: '/${moduleName}/${busName}/page',
method: 'get', method: 'get',
data: data data: data
@ -10,7 +10,7 @@ export function ${classNameFirstLower}Page(data) {
} }
// 提交${functionName}表单 add为false时为编辑默认为新增 // 提交${functionName}表单 add为false时为编辑默认为新增
export function ${classNameFirstLower}SubmitForm(data, add = true) { export function ${classNameFirstLower}SubmitForm(data, add = true) {
return request({ return request({
url: '/${moduleName}/${busName}/'+ (add ? 'add' : 'edit'), url: '/${moduleName}/${busName}/'+ (add ? 'add' : 'edit'),
method: 'post', method: 'post',
data: data data: data
@ -18,7 +18,7 @@ export function ${classNameFirstLower}SubmitForm(data, add = true) {
} }
// 删除${functionName} // 删除${functionName}
export function ${classNameFirstLower}Delete(data) { export function ${classNameFirstLower}Delete(data) {
return request({ return request({
url: '/${moduleName}/${busName}/delete', url: '/${moduleName}/${busName}/delete',
method: 'post', method: 'post',
data: data data: data
@ -26,7 +26,7 @@ export function ${classNameFirstLower}Delete(data) {
} }
// 获取${functionName}详情 // 获取${functionName}详情
export function ${classNameFirstLower}Detail(data) { export function ${classNameFirstLower}Detail(data) {
return request({ return request({
url: '/${moduleName}/${busName}/detail', url: '/${moduleName}/${busName}/detail',
method: 'get', method: 'get',
data: data data: data

View File

@ -1,44 +1,53 @@
<template> <template>
<view class="container"> <view class="container snowy-shadow">
<uni-forms ref="formRef" :model="formData" label-position="top" :rules="rules" validate-trigger="blur" labelWidth="100px"> <uv-form ref="formRef" :model="formData" :rules="rules" label-position="top" labelWidth="auto" :labelStyle="{marginBottom: '25rpx', fontSize: '27rpx', color: '#606266'}">
<% for(var i = 0; i < configList.~size; i++) { %> <% for(var i = 0; i < configList.~size; i++) { %>
<% if(!configList[i].needTableId && configList[i].whetherAddUpdate && configList[i].fieldNameCamelCase != 'tenantId') { %> <% if(!configList[i].needTableId && configList[i].whetherAddUpdate && configList[i].fieldNameCamelCase != 'tenantId') { %>
<% if(configList[i].effectType == 'input') { %> <% if(configList[i].effectType == 'input') { %>
<uni-forms-item label="${configList[i].fieldRemark}" name="${configList[i].fieldNameCamelCase}" :required="${configList[i].required}" :rules="[{ required: ${configList[i].required}, errorMessage: '请输入${configList[i].fieldRemark}' }]"> <uv-form-item label="${configList[i].fieldRemark}" prop="${configList[i].fieldNameCamelCase}" :required="${configList[i].required}">
<uni-easyinput v-model="formData.${configList[i].fieldNameCamelCase}" placeholder="请输入${configList[i].fieldRemark}"></uni-easyinput> <uv-input v-model="formData.${configList[i].fieldNameCamelCase}" placeholder="请输入${configList[i].fieldRemark}"></uv-input>
</uni-forms-item> </uv-form-item>
<% } else if (configList[i].effectType == 'textarea') {%> <% } else if (configList[i].effectType == 'textarea') {%>
<uni-forms-item label="${configList[i].fieldRemark}" name="${configList[i].fieldNameCamelCase}" :required="${configList[i].required}" :rules="[{ required: ${configList[i].required}, errorMessage: '请输入${configList[i].fieldRemark}' }]"> <uv-form-item label="${configList[i].fieldRemark}" prop="${configList[i].fieldNameCamelCase}" :required="${configList[i].required}">
<uni-easyinput type="textarea" v-model="formData.${configList[i].fieldNameCamelCase}" placeholder="请输入${configList[i].fieldRemark}"></uni-easyinput> <uv-textarea v-model="formData.${configList[i].fieldNameCamelCase}" placeholder="请输入${configList[i].fieldRemark}"></uv-textarea>
</uni-forms-item> </uv-form-item>
<% } else if (configList[i].effectType == 'select') {%> <% } else if (configList[i].effectType == 'select') {%>
<uni-forms-item label="${configList[i].fieldRemark}" name="${configList[i].fieldNameCamelCase}" :required="${configList[i].required}" :rules="[{ required: ${configList[i].required}, errorMessage: '请输入${configList[i].fieldRemark}' }]"> <uv-form-item label="${configList[i].fieldRemark}" prop="${configList[i].fieldNameCamelCase}" :required="${configList[i].required}">
<snowy-sel-picker :map="{key: 'value', label: 'text'}" v-model="formData.${configList[i].fieldNameCamelCase}" :rangeData="${configList[i].fieldNameCamelCase}Options" placeholder="请选择${configList[i].fieldRemark}"></snowy-sel-picker> <snowy-sel-picker :map="{key: 'value', label: 'text'}" v-model="formData.${configList[i].fieldNameCamelCase}" :rangeData="${configList[i].fieldNameCamelCase}Options" placeholder="请选择${configList[i].fieldRemark}"></snowy-sel-picker>
</uni-forms-item> </uv-form-item>
<% } else if (configList[i].effectType == 'radio' || configList[i].effectType == 'checkbox') {%> <% } else if (configList[i].effectType == 'radio') {%>
<uni-forms-item label="${configList[i].fieldRemark}" name="${configList[i].fieldNameCamelCase}" :required="${configList[i].required}" :rules="[{ required: ${configList[i].required}, errorMessage: '请选择${configList[i].fieldRemark}' }]"> <uv-form-item label="${configList[i].fieldRemark}" prop="${configList[i].fieldNameCamelCase}" :required="${configList[i].required}">
<uni-data-checkbox :multiple="${configList[i].effectType == 'checkbox'?true:false}" :map="{key: 'value', label: 'text'}" v-model="searchFormState.${configList[i].fieldNameCamelCase}" :rangeData="${configList[i].fieldNameCamelCase}Options" placeholder="请选择${configList[i].fieldRemark}"> </uni-data-checkbox> <uv-radio-group v-model="formData.${configList[i].fieldNameCamelCase}">
</uni-forms-item> <uv-radio :customStyle="{marginRight: '50rpx'}" v-for="(item, index) in ${configList[i].fieldNameCamelCase}Options" :key="index" :name="item.value" :label="item.text"></uv-radio>
<% } else if (configList[i].effectType == 'datepicker' || configList[i].effectType == 'timepicker') {%> </uv-radio-group>
<uni-forms-item label="${configList[i].fieldRemark}" name="${configList[i].fieldNameCamelCase}" :required="${configList[i].required}" :rules="[{ required: ${configList[i].required}, errorMessage: '请选择${configList[i].fieldRemark}' }]"> </uv-form-item>
<uni-datetime-picker type=${configList[i].effectType == 'timepicker'?'datetime':'date'} v-model="formData.${configList[i].fieldNameCamelCase}" > </uni-datetime-picker> <% } else if (configList[i].effectType == 'checkbox') {%>
</uni-forms-item> <uv-form-item label="${configList[i].fieldRemark}" prop="${configList[i].fieldNameCamelCase}" :required="${configList[i].required}">
<uv-checkbox-group v-model="formData.${configList[i].fieldNameCamelCase}">
<uv-checkbox :customStyle="{marginRight: '50rpx'}" v-for="(item, index) in ${configList[i].fieldNameCamelCase}Options" :key="index" :name="item.value" :label="item.text"></uv-checkbox>
</uv-checkbox-group>
</uv-form-item>
<% } else if (configList[i].effectType == 'datepicker') {%>
<uv-form-item label="${configList[i].fieldRemark}" prop="${configList[i].fieldNameCamelCase}" :required="${configList[i].required}">
<snowy-calendar v-model="formData.${configList[i].fieldNameCamelCase}" placeholder="请输入${configList[i].fieldRemark}"></snowy-calendar>
</uv-form-item>
<% } else if (configList[i].effectType == 'timepicker') {%>
<% } else if (configList[i].effectType == 'inputNumber') {%> <% } else if (configList[i].effectType == 'inputNumber') {%>
<uni-forms-item label="${configList[i].fieldRemark}" name="${configList[i].fieldNameCamelCase}" :required="${configList[i].required}" :rules="[{ required: ${configList[i].required}, errorMessage: '请输入${configList[i].fieldRemark}' }]"> <uv-form-item label="${configList[i].fieldRemark}" prop="${configList[i].fieldNameCamelCase}" :required="${configList[i].required}">
<uni-number-box v-model="formData.${configList[i].fieldNameCamelCase}" :min="1" :max="100"></uni-number-box> <uv-number-box v-model="formData.${configList[i].fieldNameCamelCase}" :min="1" :max="100"></uv-number-box>
</uni-forms-item> </uv-form-item>
<% } else if (configList[i].effectType == 'slider') {%> <% } else if (configList[i].effectType == 'slider') {%>
<uni-forms-item label="${configList[i].fieldRemark}" name="${configList[i].fieldNameCamelCase}" :required="${configList[i].required}" :rules="[{ required: ${configList[i].required}, errorMessage: '请输入${configList[i].fieldRemark}' }]"> <uv-form-item label="${configList[i].fieldRemark}" prop="${configList[i].fieldNameCamelCase}" :required="${configList[i].required}">
<slider :value="formData.${configList[i].fieldNameCamelCase}" :min="1" :max="100" :step="1" @change="(e)=>{formData.${configList[i].fieldNameCamelCase} = e.detail.value}"></slider> <slider :value="formData.${configList[i].fieldNameCamelCase}" :min="1" :max="100" :step="1" @change="(e)=>{formData.${configList[i].fieldNameCamelCase} = e.detail.value}"></slider>
</uni-forms-item> </uv-form-item>
<% } %> <% } %>
<% } %> <% } %>
<% } %> <% } %>
</uni-forms> </uv-form>
<button class="btn-sub" type="primary" @click="submit">提交</button> <tui-button margin="50rpx 0" :preventClick="true" :shadow="true" @click="submit">提交</tui-button>
</view> </view>
</template> </template>
<script setup name="${classNameFirstLower}Form"> <script setup name="${classNameFirstLower}Form">
<% <%
var iptTool = 0; var iptTool = 0;
@ -52,7 +61,6 @@
%> %>
<% if(iptTool > 0) { %> <% if(iptTool > 0) { %>
import tool from '@/plugins/tool' import tool from '@/plugins/tool'
import SnowySelPicker from '@/components/snowy-sel-picker.vue'
<% } %> <% } %>
import XEUtils from "xe-utils" import XEUtils from "xe-utils"
import { onLoad } from "@dcloudio/uni-app" import { onLoad } from "@dcloudio/uni-app"
@ -61,14 +69,27 @@
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const formRef = ref() const formRef = ref()
const formData = ref({}) const formData = ref({
<% for(var i = 0; i < configList.~size; i++) { %>
// 常用正则规则大全https://any86.github.io/any-rule/ <% if(!configList[i].needTableId && configList[i].whetherAddUpdate && configList[i].fieldNameCamelCase != 'tenantId') { %>
${configList[i].fieldNameCamelCase}: '',
<% } %>
<% } %>
})
// https://www.uvui.cn/components/form.html
// 去pages/biz/user/form.vue中寻找示例 // 去pages/biz/user/form.vue中寻找示例
const rules = reactive({ const rules = reactive({
<% for(var i = 0; i < configList.~size; i++) { %>
}) <% if(!configList[i].needTableId && configList[i].whetherAddUpdate && configList[i].fieldNameCamelCase != 'tenantId' && configList[i].required) { %>
${configList[i].fieldNameCamelCase}: [{
type: 'string',
required: true,
message: '请输入${configList[i].fieldRemark}',
trigger: ['blur', 'change']
}],
<% } %>
<% } %>
})
<% for(var i = 0; i < configList.~size; i++) { %> <% for(var i = 0; i < configList.~size; i++) { %>
<% if(!configList[i].needTableId) { %> <% if(!configList[i].needTableId) { %>
<% if(configList[i].effectType == 'select' || configList[i].effectType == 'radio' || configList[i].effectType == 'checkbox') { %> <% if(configList[i].effectType == 'select' || configList[i].effectType == 'radio' || configList[i].effectType == 'checkbox') { %>
@ -96,24 +117,19 @@
const submit = () => { const submit = () => {
formRef.value.validate().then(res => { formRef.value.validate().then(res => {
${classNameFirstLower}SubmitForm(formData.value, !formData.value.id).then(respond => { ${classNameFirstLower}SubmitForm(formData.value, !formData.value.id).then(respond => {
uni.$emit('formBack', { uni.$emit('formBack', {
data: respond.data data: respond.data
}) })
uni.navigateBack({ uni.navigateBack({
delta: 1 delta: 1
}) })
}) })
}) })
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.container { .container {
margin: 15upx; margin: 80rpx 0 0;
border-radius: 5upx; padding: 30rpx;
padding: 25upx; }
background-color: $uni-white;
.btn-sub {
background-color: $uni-primary;
}
}
</style> </style>

View File

@ -6,87 +6,59 @@
<% for(var i = 0; i < configList.~size; i++) { %> <% for(var i = 0; i < configList.~size; i++) { %>
<% if(!configList[i].needTableId && configList[i].needPage) { searchCount ++; }%> <% if(!configList[i].needTableId && configList[i].needPage) { searchCount ++; }%>
<% } %> <% } %>
<view> <% if (searchCount > 0) { %>
<% if (searchCount > 0) { %> <% for(var i = 0; i < configList.~size; i++) { %>
<view class="sticky"> <% if(!configList[i].needTableId && configList[i].needPage) { row ++; %>
<% if(row <= 1) { %>
<snowy-search placeholder="请输入${configList[i].fieldRemark}" v-model="searchFormState.${configList[i].fieldNameCamelCase}" @confirm="loadData(true)" @clear="loadData(true)" :enableSenior="true" @seniorSearch="$refs.searchRef.open()"></snowy-search>
<% } %>
<% } %>
<% } %>
<search ref="searchRef" :searchFormState="searchFormState" @confirm="loadData(true)"></search>
<% } %>
<view class="${busName}-list">
<view class="item" v-for="(item, index) in ${classNameFirstLower}Data" :key="index" :index="index" @tap="moreTapItem(item, index)">
<% for(var i = 0; i < configList.~size; i++) { %> <% for(var i = 0; i < configList.~size; i++) { %>
<% if(!configList[i].needTableId && configList[i].needPage) { row ++; %> <% if(!configList[i].needTableId && configList[i].whetherTable && configList[i].fieldNameCamelCase != 'tenantId') { %>
<% if(row <= 1) { %> <uv-row customStyle="margin-bottom: 15rpx">
<uni-row> <uv-col :span="1">
<view style="display: flex; align-items: center; justify-content: center;"> <uv-icon size="18" name="tags-fill" color="#5677fc"></uv-icon>
<uni-col :span="22"> </uv-col>
<uni-search-bar v-model="searchFormState.${configList[i].fieldNameCamelCase}" placeholder="请输入${configList[i].fieldRemark}" @confirm="loadData(true)" cancelButton="none"></uni-search-bar> <uv-col :span="5">
</uni-col> <view class="item-left">${configList[i].fieldRemark}</view>
<uni-col :span="2"> </uv-col>
<view style="color: #2979ff;" @click="$refs.searchRef.open()"> <uv-col :span="6" textAlign="right">
<text>高级\n搜索</text> <view class="item-right snowy-bold snowy-ellipsis"> {{ item.${configList[i].fieldNameCamelCase} }} </view>
</view> </uv-col>
</uni-col> </uv-row>
</view>
</uni-row>
<% } %>
<% } %> <% } %>
<% } %> <% } %>
</view> </view>
<search ref="searchRef" :searchFormState="searchFormState" @confirm="loadData(true)"></search>
<% } %>
<view class="${busName}-list">
<uni-list>
<uni-list-item v-for="(item, index) in ${classNameFirstLower}Data" :key="index" :showArrow="false" :clickable="true" @tap="moreTapItem(item, index)">
<template v-slot:body>
<view class="item">
<% for(var i = 0; i < configList.~size; i++) { %>
<% if(!configList[i].needTableId && configList[i].whetherTable && configList[i].fieldNameCamelCase != 'tenantId') { %>
<view class="item-row">
<uni-row>
<uni-col :span="4">
<view class="item-row-title">${configList[i].fieldRemark}</view>
</uni-col>
<uni-col :span="20">
<view class="item-row-content">{{ item.${configList[i].fieldNameCamelCase} }}</view>
</uni-col>
</uni-row>
</view>
<% } %>
<% } %>
</view>
</template>
</uni-list-item>
</uni-list>
<snowy-empty v-if="$utils.isEmpty(${classNameFirstLower}Data)" />
</view>
<!-- 新增悬浮按钮 -->
<uni-fab
v-if="hasPerm('mobile${className}Add')"
horizontal="right"
vertical="bottom"
direction="horizontal"
@fabClick="add"
:pattern="{
color: '#7A7E83',
backgroundColor: '#fff',
selectedColor: '#007AFF',
buttonColor: '#007AFF',
iconColor: '#fff'
}">
</uni-fab>
<more ref="moreRef" @handleOk="loadData(true)"></more>
</view> </view>
<snowy-empty :fixed="true" v-if="$utils.isEmpty(${classNameFirstLower}Data)" />
<snowy-float-btn v-if="hasPerm('mobile${className}Add')" @click="add"></snowy-float-btn>
<more ref="moreRef" @handleOk="loadData(true)"></more>
</template> </template>
<script setup name="${busName}"> <script setup name="${busName}">
<% if (searchCount > 0) { %> <% if (searchCount > 0) { %>
import search from './search.vue' import search from './search.vue'
<% } %> <% } %>
import SnowyEmpty from "@/components/snowy-empty.vue"
import { ${classNameFirstLower}Page } from '@/api/${moduleName}/${classNameFirstLower}Api' import { ${classNameFirstLower}Page } from '@/api/${moduleName}/${classNameFirstLower}Api'
import more from './more.vue' import more from './more.vue'
import XEUtils from 'xe-utils' import XEUtils from 'xe-utils'
import { onLoad, onShow, onReady, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app" import { onLoad, onShow, onReady, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app"
import { reactive, ref, getCurrentInstance } from "vue" import { reactive, ref, getCurrentInstance } from "vue"
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const searchFormState = reactive({}) const searchFormState = reactive({
<% if (searchCount > 0) { %>
<% for(var i = 0; i < configList.~size; i++) { %>
<% if(!configList[i].needTableId && configList[i].needPage) { %>
${configList[i].fieldNameCamelCase}: '',
<% } %>
<% } %>
<% } %>
})
const parameter = reactive({ const parameter = reactive({
current: 1, current: 1,
size: 10 size: 10
@ -136,22 +108,22 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.${busName}-list { .${busName}-list {}
margin: 15upx; .item {
border-radius: 5upx; background: #ffffff;
.item { margin: 20rpx 0;
width: 100vw; padding: 25rpx;
.item-row { box-shadow: 0 1px 2px #ccc;
margin: 20upx 10upx; border-radius: 15rpx;
.item-row-title { .item-left {
font-size: 25upx; color: #999;
color: #999; font-size: 26rpx;
} }
.item-row-content { .item-right {
font-size: 25upx; font-size: 26rpx;
text-align: right; }
} }
} .item:hover {
} box-shadow: 1upx 5upx 5upx #5677fc;
} }
</style> </style>

View File

@ -1,30 +1,35 @@
<template> <template>
<uni-popup ref="popupRef" type="bottom" safeArea> <uv-popup ref="popRef" mode="bottom" bg-color="null" z-index="99">
<view class="container"> <view class="container">
<uni-list :border="false"> <tui-list-view unlined="all" background-color="transparent">
<uni-list-item v-if="hasPerm('mobile${className}Edit')" title="编辑" class="item" :clickable="true" @click="edit"/> <tui-list-cell v-if="hasPerm('mobile${className}Edit')" :hover="true" :arrow="false" @click="edit" :radius="10" >
<uni-list-item v-if="hasPerm('mobile${className}Delete')" title="刪除" class="item" :clickable="true" @click="del"/> <view class="item"> 编辑 </view>
<uni-list-item title="取消" class="item" :clickable="true" @click="cancel"/> </tui-list-cell>
</uni-list> <tui-list-cell v-if="hasPerm('mobile${className}Delete')" :hover="true" :arrow="false" @click="del" :radius="10" :margin-top="2">
<view class="item"> 刪除 </view>
</tui-list-cell>
<tui-list-cell :hover="true" :arrow="false" @click="cancel" :margin-top="10" :radius="10">
<view class="item"> 取消 </view>
</tui-list-cell>
</tui-list-view>
</view> </view>
</uni-popup> </uv-popup>
</template> </template>
<script setup name="${classNameFirstLower}More"> <script setup name="${classNameFirstLower}More">
import { ${classNameFirstLower}Delete } from '@/api/${moduleName}/${classNameFirstLower}Api' import { ${classNameFirstLower}Delete } from '@/api/${moduleName}/${classNameFirstLower}Api'
import modal from '@/plugins/modal' import modal from '@/plugins/modal'
import { reactive, ref, getCurrentInstance } from "vue" import { reactive, ref, getCurrentInstance } from "vue"
const emits = defineEmits(['handleOk']) const emits = defineEmits(['handleOk'])
const popupRef = ref() const popRef = ref()
const record = ref({}) const record = ref({})
const open = (data) => { const open = (data) => {
record.value = data record.value = data
popupRef.value.open("bottom") popRef.value.open()
} }
// 编辑 // 编辑
const edit = () => { const edit = () => {
uni.navigateTo({ uni.navigateTo({
url: '/pages/${moduleName}/${busName}/form?id=' + record.value.id url: '/pages/${moduleName}/${busName}/form?id=' + record.value.id
}) })
popupRef.value.close() popupRef.value.close()
} }
@ -49,12 +54,10 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.container { .container {
margin: 15upx; padding: 5upx;
border-radius: 5upx; background-color: transparent;
padding: 5upx; .item {
background-color: $uni-white; text-align: center;
.item { }
text-align:center; }
}
}
</style> </style>

View File

@ -2,46 +2,46 @@
// 不使用分包 // 不使用分包
{ {
"path": "pages/${moduleName}/${busName}/index", "path": "pages/${moduleName}/${busName}/index",
"style": { "style": {
"navigationBarTitleText": "${functionName}管理", "navigationBarTitleText": "${functionName}管理",
"enablePullDownRefresh": true, "enablePullDownRefresh": true,
//#ifdef H5 //#ifdef H5
"navigationStyle": "custom" "navigationStyle": "custom"
//#endif //#endif
} }
}, { }, {
"path": "pages/${moduleName}/${busName}/form", "path": "pages/${moduleName}/${busName}/form",
"style": { "style": {
"navigationBarTitleText": "${functionName}管理", "navigationBarTitleText": "${functionName}管理",
"enablePullDownRefresh": false, "enablePullDownRefresh": false,
//#ifdef H5 //#ifdef H5
"navigationStyle": "custom" "navigationStyle": "custom"
//#endif //#endif
} }
}, },
// 使用分包微信小程序开发主包不能超过2m所以建议使用分包 // 使用分包微信小程序开发主包不能超过2m所以建议使用分包
{ {
"root": "pages/${moduleName}/${busName}", "root": "pages/${moduleName}/${busName}",
"pages": [{ "pages": [{
"path": "index", "path": "index",
"style": { "style": {
"navigationBarTitleText": "${functionName}管理", "navigationBarTitleText": "${functionName}管理",
"enablePullDownRefresh": true, "enablePullDownRefresh": true,
//#ifdef H5 //#ifdef H5
"navigationStyle": "custom" "navigationStyle": "custom"
//#endif //#endif
} }
},{ },{
"path": "form", "path": "form",
"style": { "style": {
"navigationBarTitleText": "${functionName}管理", "navigationBarTitleText": "${functionName}管理",
"enablePullDownRefresh": false, "enablePullDownRefresh": false,
//#ifdef H5 //#ifdef H5
"navigationStyle": "custom" "navigationStyle": "custom"
//#endif //#endif
} }
}] }]
} }

View File

@ -6,47 +6,42 @@
<% for(var i = 0; i < configList.~size; i++) { %> <% for(var i = 0; i < configList.~size; i++) { %>
<% if(!configList[i].needTableId && configList[i].needPage) { searchCount ++; }%> <% if(!configList[i].needTableId && configList[i].needPage) { searchCount ++; }%>
<% } %> <% } %>
<uni-popup ref="popupRef" type="bottom" safeArea background-color="#ffffff"> <uv-popup ref="popRef" mode="bottom" bg-color="null" z-index="99">
<view class="container"> <view class="container">
<view class="close">
<icon type="clear" :size="20" color="#5677fc" @click="close"></icon>
</view>
<% if (searchCount > 0) { %> <% if (searchCount > 0) { %>
<uni-forms ref="formRef" :model="searchFormState" label-position="top" labelWidth="100px"> <uv-form ref="formRef" :model="searchFormState" label-position="top" labelWidth="auto" :labelStyle="{marginBottom: '25rpx', fontSize: '27rpx', color: '#606266'}">
<% for(var i = 0; i < configList.~size; i++) { %> <% for(var i = 0; i < configList.~size; i++) { %>
<% if(!configList[i].needTableId && configList[i].needPage) { %> <% if(!configList[i].needTableId && configList[i].needPage) { %>
<% if(configList[i].effectType == 'input' || configList[i].effectType == 'textarea') { %> <% if(configList[i].effectType == 'input' || configList[i].effectType == 'textarea') { %>
<uni-forms-item label="${configList[i].fieldRemark}" name="${configList[i].fieldNameCamelCase}"> <uv-form-item label="${configList[i].fieldRemark}" prop="${configList[i].fieldNameCamelCase}">
<uni-easyinput v-model="searchFormState.${configList[i].fieldNameCamelCase}" placeholder="请输入${configList[i].fieldRemark}"></uni-easyinput> <uv-input v-model="searchFormState.${configList[i].fieldNameCamelCase}" placeholder="请输入${configList[i].fieldRemark}"></uv-input>
</uni-forms-item> </uv-form-item>
<% } else if (configList[i].effectType == 'select' || configList[i].effectType == 'radio' || configList[i].effectType == 'checkbox') {%> <% } else if (configList[i].effectType == 'select' || configList[i].effectType == 'radio' || configList[i].effectType == 'checkbox') {%>
<uni-forms-item label="${configList[i].fieldRemark}" name="${configList[i].fieldNameCamelCase}"> <uv-form-item label="${configList[i].fieldRemark}" prop="${configList[i].fieldNameCamelCase}">
<snowy-sel-picker :map="{key: 'value', label: 'text'}" v-model="searchFormState.${configList[i].fieldNameCamelCase}" :rangeData="${configList[i].fieldNameCamelCase}Options" placeholder="请选择${configList[i].fieldRemark}"></snowy-sel-picker> <snowy-sel-picker :map="{key: 'value', label: 'text'}" v-model="searchFormState.${configList[i].fieldNameCamelCase}" :rangeData="${configList[i].fieldNameCamelCase}Options" placeholder="请选择${configList[i].fieldRemark}"></snowy-sel-picker>
</uni-forms-item> </uv-form-item>
<% } else if (configList[i].effectType == 'inputNumber' || configList[i].effectType == 'slider') {%>
<uni-forms-item label="${configList[i].fieldRemark}" name="${configList[i].fieldNameCamelCase}">
<uni-number-box v-model="searchFormState.${configList[i].fieldNameCamelCase}" placeholder="请输入${configList[i].fieldRemark}"/>
</uni-forms-item>
<% } else if (configList[i].effectType == 'datepicker') {%>
<uni-forms-item label="${configList[i].fieldRemark}" name="${configList[i].fieldNameCamelCase}">
<uni-datetime-picker v-model="searchFormState.${configList[i].fieldNameCamelCase}" type="datetimerange"/>
</uni-forms-item>
<% } else {%> <% } else {%>
<uni-forms-item label="${configList[i].fieldRemark}" name="${configList[i].fieldNameCamelCase}"> <uv-form-item label="${configList[i].fieldRemark}" prop="${configList[i].fieldNameCamelCase}">
<uni-easyinput v-model="searchFormState.${configList[i].fieldNameCamelCase}" placeholder="请输入${configList[i].fieldRemark}"></uni-easyinput> <uv-input v-model="searchFormState.${configList[i].fieldNameCamelCase}" placeholder="请输入${configList[i].fieldRemark}"></uv-input>
</uni-forms-item> </uv-form-item>
<% } %> <% } %>
<% } %> <% } %>
<% } %> <% } %>
</uni-forms> </uv-form>
<% } %> <% } %>
<uni-row :gutter="10"> <uv-row :gutter="10">
<uni-col :span="12"> <uv-col :span="6">
<button class="btn-reset" type="default" @click="reset">重置</button> <tui-button height="90rpx" type="gray" @click="reset">重置</tui-button>
</uni-col> </uv-col>
<uni-col :span="12"> <uv-col :span="6">
<button class="btn-sub" type="primary" @click="confirm">确认</button> <tui-button height="90rpx" type="primary" @click="confirm">确认</tui-button>
</uni-col> </uv-col>
</uni-row> </uv-row>
</view> </view>
</uni-popup> </uv-popup>
</template> </template>
<script setup name="${classNameFirstLower}Search"> <script setup name="${classNameFirstLower}Search">
<% <%
@ -63,17 +58,15 @@
%> %>
<% if(iptTool > 0) { %> <% if(iptTool > 0) { %>
import tool from '@/plugins/tool' import tool from '@/plugins/tool'
import SnowySelPicker from '@/components/snowy-sel-picker.vue'
<% } %> <% } %>
import { ref } from "vue" import { ref } from "vue"
const emits = defineEmits(['reset', 'confirm']) const emits = defineEmits(['reset', 'confirm'])
const props = defineProps({ const props = defineProps({
searchFormState: { searchFormState: {
type: Object, type: Object,
required: true required: true
}, },
}) })
<% if (searchCount > 0) { %> <% if (searchCount > 0) { %>
<% for(var i = 0; i < configList.~size; i++) { %> <% for(var i = 0; i < configList.~size; i++) { %>
<% if(!configList[i].needTableId && configList[i].needPage) { %> <% if(!configList[i].needTableId && configList[i].needPage) { %>
@ -83,12 +76,9 @@
<% } %> <% } %>
<% } %> <% } %>
<% } %> <% } %>
const popRef = ref()
// 弹出ref
const popupRef = ref()
// 打开
const open = () => { const open = () => {
popupRef.value.open() popRef.value.open()
} }
const reset = () =>{ const reset = () =>{
// 重置数据 // 重置数据
@ -100,24 +90,25 @@
emits('reset', props.searchFormState) emits('reset', props.searchFormState)
} }
const confirm = () => { const confirm = () => {
popupRef.value.close() popRef.value.close()
emits('confirm', props.searchFormState) emits('confirm', props.searchFormState)
} }
const close = () => {
popRef.value.close()
}
defineExpose({ defineExpose({
open open
}) })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.container { .container {
margin: 15upx; margin: 5rpx;
border-radius: 5upx; border-radius: 10rpx;
padding: 5upx; padding: 20rpx;
background-color: $uni-white; background-color: white;
.btn-reset { .close {
display: flex;
} justify-content: flex-end;
.btn-sub { }
background-color: $uni-primary; }
}
}
</style> </style>

View File

@ -14,6 +14,7 @@ INSERT INTO `SYS_RESOURCE` VALUES ('${editButtonId}', '${menuId}', '编辑${func
INSERT INTO `SYS_RESOURCE` VALUES ('${deleteButtonId}', '${menuId}', '删除${functionName}', NULL, '${classNameFirstLower}Delete', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, 4, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL); INSERT INTO `SYS_RESOURCE` VALUES ('${deleteButtonId}', '${menuId}', '删除${functionName}', NULL, '${classNameFirstLower}Delete', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, 4, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
<% if (mobileModuleId != null && mobileModuleId != '') { %>
INSERT INTO `MOBILE_RESOURCE` VALUES ('${menuId}', '0', '${functionName}管理', NULL, 'MENU', '${mobileModuleId}', 'MENU', '/pages/${moduleName}/${busName}/index', 'apartment-outlined', '#1890ff', 'YES', 'ENABLE', 99, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL); INSERT INTO `MOBILE_RESOURCE` VALUES ('${menuId}', '0', '${functionName}管理', NULL, 'MENU', '${mobileModuleId}', 'MENU', '/pages/${moduleName}/${busName}/index', 'apartment-outlined', '#1890ff', 'YES', 'ENABLE', 99, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
INSERT INTO `MOBILE_RESOURCE` VALUES ('${addButtonId}', '${menuId}', '新增${functionName}', 'mobile${className}Add', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL); INSERT INTO `MOBILE_RESOURCE` VALUES ('${addButtonId}', '${menuId}', '新增${functionName}', 'mobile${className}Add', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
@ -21,3 +22,4 @@ INSERT INTO `MOBILE_RESOURCE` VALUES ('${addButtonId}', '${menuId}', '新增${fu
INSERT INTO `MOBILE_RESOURCE` VALUES ('${editButtonId}', '${menuId}', '编辑${functionName}', 'mobile${className}Edit', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 2, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL); INSERT INTO `MOBILE_RESOURCE` VALUES ('${editButtonId}', '${menuId}', '编辑${functionName}', 'mobile${className}Edit', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 2, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
INSERT INTO `MOBILE_RESOURCE` VALUES ('${deleteButtonId}', '${menuId}', '删除${functionName}', 'mobile${className}Delete', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 3, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL); INSERT INTO `MOBILE_RESOURCE` VALUES ('${deleteButtonId}', '${menuId}', '删除${functionName}', 'mobile${className}Delete', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 3, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
<% } %>

View File

@ -14,6 +14,7 @@ INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${editButtonId}', '${menuId}', '编
INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${deleteButtonId}', '${menuId}', '删除${functionName}', NULL, '${classNameFirstLower}Delete', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, '4', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL); INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${deleteButtonId}', '${menuId}', '删除${functionName}', NULL, '${classNameFirstLower}Delete', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, '4', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
<% if (mobileModuleId != null && mobileModuleId != '') { %>
INSERT INTO "SNOWY"."MOBILE_RESOURCE" VALUES ('${menuId}', '0', '${functionName}管理', NULL, 'MENU', '${mobileModuleId}', 'MENU', '/pages/${moduleName}/${busName}/index', 'apartment-outlined', '#1890ff', 'YES', 'ENABLE', 99, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL); INSERT INTO "SNOWY"."MOBILE_RESOURCE" VALUES ('${menuId}', '0', '${functionName}管理', NULL, 'MENU', '${mobileModuleId}', 'MENU', '/pages/${moduleName}/${busName}/index', 'apartment-outlined', '#1890ff', 'YES', 'ENABLE', 99, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
INSERT INTO "SNOWY"."MOBILE_RESOURCE" VALUES ('${addButtonId}', '${menuId}', '新增${functionName}', 'mobile${className}Add', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL); INSERT INTO "SNOWY"."MOBILE_RESOURCE" VALUES ('${addButtonId}', '${menuId}', '新增${functionName}', 'mobile${className}Add', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
@ -21,3 +22,4 @@ INSERT INTO "SNOWY"."MOBILE_RESOURCE" VALUES ('${addButtonId}', '${menuId}', '
INSERT INTO "SNOWY"."MOBILE_RESOURCE" VALUES ('${editButtonId}', '${menuId}', '编辑${functionName}', 'mobile${className}Edit', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 2, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL); INSERT INTO "SNOWY"."MOBILE_RESOURCE" VALUES ('${editButtonId}', '${menuId}', '编辑${functionName}', 'mobile${className}Edit', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 2, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
INSERT INTO "SNOWY"."MOBILE_RESOURCE" VALUES ('${deleteButtonId}', '${menuId}', '删除${functionName}', 'mobile${className}Delete', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 3, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL); INSERT INTO "SNOWY"."MOBILE_RESOURCE" VALUES ('${deleteButtonId}', '${menuId}', '删除${functionName}', 'mobile${className}Delete', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 3, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
<% } %>