Browse Source

【优化】移动端代码生成模板优化

pull/141/MERGE
877617829 1 year ago
parent
commit
e6f4ee7f4d
  1. 16
      snowy-plugin/snowy-plugin-gen/src/main/resources/mobile/form.vue.btl
  2. 11
      snowy-plugin/snowy-plugin-gen/src/main/resources/mobile/index.vue.btl
  3. 7
      snowy-plugin/snowy-plugin-gen/src/main/resources/mobile/more.vue.btl
  4. 17
      snowy-plugin/snowy-plugin-gen/src/main/resources/mobile/search.vue.btl

16
snowy-plugin/snowy-plugin-gen/src/main/resources/mobile/form.vue.btl

@ -49,20 +49,6 @@
</view>
</template>
<script setup name="${classNameFirstLower}Form">
<%
var iptTool = 0;
for(var i = 0; i < configList.~size; i++) {
if(!configList[i].needTableId) {
if(configList[i].effectType == 'select' || configList[i].effectType == 'radio' || configList[i].effectType == 'checkbox') {
iptTool++;
}
}
}
%>
<% if(iptTool > 0) { %>
import tool from '@/plugins/tool'
<% } %>
import XEUtils from "xe-utils"
import { onLoad } from "@dcloudio/uni-app"
import { ${classNameFirstLower}Detail, ${classNameFirstLower}SubmitForm } from '@/api/${moduleName}/${classNameFirstLower}Api'
import { reactive, ref, getCurrentInstance } from "vue"
@ -101,7 +87,7 @@
<% for(var i = 0; i < configList.~size; i++) { %>
<% if(!configList[i].needTableId) { %>
<% if(configList[i].effectType == 'select' || configList[i].effectType == 'radio' || configList[i].effectType == 'checkbox') { %>
${configList[i].fieldNameCamelCase}Options.value = tool.dictList('${configList[i].dictTypeCode}')
${configList[i].fieldNameCamelCase}Options.value = uni.$snowy.tool.dictList('${configList[i].dictTypeCode}')
<% } %>
<% } %>
<% } %>

11
snowy-plugin/snowy-plugin-gen/src/main/resources/mobile/index.vue.btl

@ -35,8 +35,8 @@
<% } %>
</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>
<snowy-empty :fixed="true" v-show="$xeu.isEmpty(${classNameFirstLower}Data)" />
<snowy-float-btn v-if="$snowy.hasPerm('mobile${className}Add')" @click="add"></snowy-float-btn>
<more ref="moreRef" @handleOk="loadData(true)"></more>
</template>
@ -46,7 +46,6 @@
<% } %>
import { ${classNameFirstLower}Page } from '@/api/${moduleName}/${classNameFirstLower}Api'
import more from './more.vue'
import XEUtils from 'xe-utils'
import { onLoad, onShow, onReady, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app"
import { reactive, ref, getCurrentInstance } from "vue"
const { proxy } = getCurrentInstance()
@ -71,7 +70,7 @@
}
Object.assign(parameter, searchFormState)
${classNameFirstLower}Page(parameter).then(res => {
if (XEUtils.isEmpty(res?.data?.records)){
if (uni.$xeu.isEmpty(res?.data?.records)){
return
}
${classNameFirstLower}Data.value = ${classNameFirstLower}Data.value.concat(res.data.records)
@ -83,7 +82,7 @@
loadData(true)
onShow(() => {
uni.$once('formBack', (data) => {
loadData(true)
loadData(true)
})
})
// 下拉刷新
@ -97,7 +96,7 @@
// 新增
const add = () => {
uni.navigateTo({
url: '/pages/${moduleName}/${busName}/form'
url: '/pages/${moduleName}/${busName}/form'
})
}
// 更多操作

7
snowy-plugin/snowy-plugin-gen/src/main/resources/mobile/more.vue.btl

@ -2,10 +2,10 @@
<uv-popup ref="popRef" mode="bottom" bg-color="null" z-index="99">
<view class="container">
<tui-list-view unlined="all" background-color="transparent">
<tui-list-cell v-if="hasPerm('mobile${className}Edit')" :hover="true" :arrow="false" @click="edit" :radius="10" >
<tui-list-cell v-if="$snowy.hasPerm('mobile${className}Edit')" :hover="true" :arrow="false" @click="edit" :radius="10" >
<view class="item"> 编辑 </view>
</tui-list-cell>
<tui-list-cell v-if="hasPerm('mobile${className}Delete')" :hover="true" :arrow="false" @click="del" :radius="10" :margin-top="2">
<tui-list-cell v-if="$snowy.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">
@ -17,7 +17,6 @@
</template>
<script setup name="${classNameFirstLower}More">
import { ${classNameFirstLower}Delete } from '@/api/${moduleName}/${classNameFirstLower}Api'
import modal from '@/plugins/modal'
import { reactive, ref, getCurrentInstance } from "vue"
const emits = defineEmits(['handleOk'])
const popRef = ref()
@ -35,7 +34,7 @@
}
// 删除
const del = () => {
modal.confirm(`确定要删除吗?`).then(() => {
uni.$snowy.modal.confirm(`确定要删除吗?`).then(() => {
${classNameFirstLower}Delete([{
id: record.value.id
}]).then(res => {

17
snowy-plugin/snowy-plugin-gen/src/main/resources/mobile/search.vue.btl

@ -44,21 +44,6 @@
</uv-popup>
</template>
<script setup name="${classNameFirstLower}Search">
<%
var iptTool = 0;
if (searchCount > 0) {
for(var i = 0; i < configList.~size; i++) {
if(!configList[i].needTableId) {
if(configList[i].effectType == 'select' || configList[i].effectType == 'radio' || configList[i].effectType == 'checkbox') {
iptTool++;
}
}
}
}
%>
<% if(iptTool > 0) { %>
import tool from '@/plugins/tool'
<% } %>
import { ref } from "vue"
const emits = defineEmits(['reset', 'confirm'])
const props = defineProps({
@ -71,7 +56,7 @@
<% for(var i = 0; i < configList.~size; i++) { %>
<% if(!configList[i].needTableId && configList[i].needPage) { %>
<% if (configList[i].effectType == 'select' || configList[i].effectType == 'radio' || configList[i].effectType == 'checkbox') { %>
const ${configList[i].fieldNameCamelCase}Options = tool.dictList('${configList[i].dictTypeCode}')
const ${configList[i].fieldNameCamelCase}Options = uni.$snowy.tool.dictList('${configList[i].dictTypeCode}')
<% } %>
<% } %>
<% } %>

Loading…
Cancel
Save