暂存uniapp代码生成

This commit is contained in:
xiangheng
2024-05-24 09:09:48 +08:00
parent fd3798ec0c
commit 6502d6b27f
10 changed files with 461 additions and 22 deletions

View File

@@ -10,7 +10,7 @@ export function monitor_client_list_all(params?: Record<string, any>) {
} }
// 客户端信息详情 // 客户端信息详情
export function monitor_client_detail(params: Record<string, any>) { export function monitor_client_detail(params: { id: string }) {
return request.get({ url: '/monitor_client/detail', params }) return request.get({ url: '/monitor_client/detail', params })
} }

View File

@@ -163,14 +163,27 @@ const formRules = {
} }
const handleSubmit = async () => { const handleSubmit = async () => {
try { formRef.value
await formRef.value?.validate() ?.validate()
const data: any = { ...formData } .then(() => {
mode.value == 'edit' ? await monitor_client_edit(data) : await monitor_client_add(data) try {
popupRef.value?.close() const data: any = { ...formData }
feedback.msgSuccess('操作成功') let req = null
emit('success') if (mode.value == 'edit') {
} catch (error) {} req = monitor_client_edit(data)
} else {
req = monitor_client_add(data)
}
req.then(() => {
popupRef.value?.close()
feedback.msgSuccess('操作成功')
emit('success')
}).catch((err) => {
feedback.msgError(err.msg)
})
} catch (error) {}
})
.catch(() => {})
} }
const open = (type = 'add') => { const open = (type = 'add') => {
@@ -181,7 +194,6 @@ const open = (type = 'add') => {
const setFormData = async (data: Record<string, any>) => { const setFormData = async (data: Record<string, any>) => {
for (const key in formData) { for (const key in formData) {
if (data[key] != null && data[key] != undefined) { if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key] formData[key] = data[key]
} }
} }

View File

@@ -87,18 +87,18 @@ func (Service flowHistoryService) List(page request.PageReq, listReq FlowHistory
return return
} }
// 数据 // 数据
var objs []model.FlowHistory var modelList []model.FlowHistory
err = dbModel.Limit(limit).Offset(offset).Order("id desc").Find(&objs).Error err = dbModel.Limit(limit).Offset(offset).Order("id desc").Find(&modelList).Error
if e = response.CheckErr(err, "列表获取失败"); e != nil { if e = response.CheckErr(err, "列表获取失败"); e != nil {
return return
} }
resps := []FlowHistoryResp{} list := []FlowHistoryResp{}
response.Copy(&resps, objs) response.Copy(&list, modelList)
return response.PageResp{ return response.PageResp{
PageNo: page.PageNo, PageNo: page.PageNo,
PageSize: page.PageSize, PageSize: page.PageSize,
Count: count, Count: count,
Lists: resps, Lists: list,
}, nil }, nil
} }
@@ -117,12 +117,12 @@ func (Service flowHistoryService) ListAll(listReq FlowHistoryListReq) (res []Flo
dbModel = dbModel.Where("node_type =?", listReq.NodeType) dbModel = dbModel.Where("node_type =?", listReq.NodeType)
} }
// 数据 // 数据
var objs []model.FlowHistory var modelList []model.FlowHistory
err := dbModel.Find(&objs).Error err := dbModel.Find(&modelList).Error
if e = response.CheckErr(err, "获取列表失败"); e != nil { if e = response.CheckErr(err, "获取列表失败"); e != nil {
return return
} }
response.Copy(&res, objs) response.Copy(&res, modelList)
return res, nil return res, nil
} }
@@ -208,6 +208,12 @@ func (Service flowHistoryService) GetApprover(ApplyId int) (res []admin.SystemAu
var userId = userTask.UserId var userId = userTask.UserId
var deptId = userTask.DeptId var deptId = userTask.DeptId
var postId = userTask.PostId var postId = userTask.PostId
if userType == 0 && userId == 0 && deptId == 0 && postId == 0 {
// return nil, errors.New("未设置审批人")
// 未设置审批人时默认为2用户部门负责人
userType = 2
}
adminTbName := core.DBTableName(&system_model.SystemAuthAdmin{}) adminTbName := core.DBTableName(&system_model.SystemAuthAdmin{})
adminModel := Service.db.Table(adminTbName+" AS admin").Where("admin.is_delete = ?", 0) adminModel := Service.db.Table(adminTbName+" AS admin").Where("admin.is_delete = ?", 0)
@@ -523,7 +529,7 @@ func (Service flowHistoryService) GetNextNode(ApplyId int) (res []FlowTree, appl
func DeepNextNode(nextNodes []FlowTree, flowTree *[]FlowTree, formValue map[string]interface{}) []FlowTree { func DeepNextNode(nextNodes []FlowTree, flowTree *[]FlowTree, formValue map[string]interface{}) []FlowTree {
for _, v := range *flowTree { for _, v := range *flowTree {
if v.Type == "bpmn:startEvent" { if v.Type == "bpmn:startEvent" {
nextNodes = append(nextNodes, v) // nextNodes = append(nextNodes, v)
// 开始节点 // 开始节点
if v.Children == nil { if v.Children == nil {

View File

@@ -0,0 +1,58 @@
import { request } from '@/utils/request'
// {{{.FunctionName}}}列表
export function {{{.ModuleName}}}_list(params?: Record<string, any>) {
return request({
url: '/{{{.ModuleName}}}/list',
method: 'GET',
data: params
})
}
// {{{.FunctionName}}}列表-所有
export function {{{.ModuleName}}}_list_all(params?: Record<string, any>) {
return request({
url: '/{{{.ModuleName}}}/listAll',
method: 'GET',
data: params
})
}
// {{{.FunctionName}}}详情
export function {{{.ModuleName}}}_detail({{{ .PrimaryKey }}}: number | string) {
return request({
url: '/{{{.ModuleName}}}/detail',
method: 'GET',
data: { {{{ .PrimaryKey }}} }
})
}
// {{{.FunctionName}}}新增
export function {{{.ModuleName}}}_add(data: Record<string, any>) {
return request({
url: '/{{{.ModuleName}}}/add',
method: "POST",
data,
});
}
// {{{.FunctionName}}}编辑
export function {{{.ModuleName}}}_edit(data: Record<string, any>) {
return request({
url: '/{{{.ModuleName}}}/edit',
method: "POST",
data,
});
}
// {{{.FunctionName}}}删除
export function {{{.ModuleName}}}_delete({{{ .PrimaryKey }}}: number | string) {
return request.post({ url: '/{{{.ModuleName}}}/del', { {{{ .PrimaryKey }}} } })
return request({
url: '/{{{.ModuleName}}}/del',
method: "POST",
data:{
{{{ .PrimaryKey }}}
},
});
}

View File

@@ -0,0 +1,108 @@
<template>
<view class="page-content">
<uv-form labelPosition="left" :model="form" :rules="rules" ref="formRef">
<uv-form-item label="IMEI" prop="imei" borderBottom>
<uv-input v-model="form.imei" border="surround">
</uv-input>
</uv-form-item>
<uv-form-item label="位置" prop="location" borderBottom>
<uv-input v-model="form.location" border="surround">
</uv-input>
</uv-form-item>
<uv-form-item label="关联表号" prop="meters" borderBottom>
<uv-textarea v-model="form.meters" border="surround"></uv-textarea>
</uv-form-item>
<uv-form-item label="卡1" prop="sim0" borderBottom>
<uv-input v-model="form.sim0" border="surround">
</uv-input>
</uv-form-item>
<uv-form-item label="卡2" prop="sim1" borderBottom>
<uv-input v-model="form.sim1" border="surround">
</uv-input>
</uv-form-item>
<uv-form-item label="备注" prop="remark" borderBottom>
<uv-textarea v-model="form.remark" border="surround"></uv-textarea>
</uv-form-item>
<uv-button type="primary" text="提交" customStyle="margin-top: 20rpx"
@click="submit"></uv-button>
</uv-form>
</view>
</template>
<script setup>
import {
reactive,
ref,
computed
} from "vue";
import {
onLoad
} from "@dcloudio/uni-app";
import {
equipment_list,
equipment_edit,
} from "@/api/equipment.js";
import {
toast,
alert
} from "@/utils/utils";
let formRef = ref();
let form = ref({});
let rules = {};
onLoad((e) => {
console.log("onLoad", e);
// form.value = e;
getDetails(e.id);
});
function getDetails(id) {
equipment_list({
id
})
.then((res) => {
if (res.code == 200) {
// form.value = e;
if (res?.result?.records?.length == 1) {
form.value = res?.result?.records[0];
}
}
})
.catch((err) => {});
}
function submit(item) {
console.log("submit", form);
equipment_edit(form.value).then((res) => {
if (res.code == 200) {
toast("编辑成功");
getDetails(form.value?.id);
} else {
toast(res.message);
}
});
}
</script>
<style lang="scss" scoped>
.page-content {
padding: 10rpx 20rpx 300rpx;
}
</style>

View File

@@ -0,0 +1,116 @@
<template>
<view>
<uv-sticky :customNavHeight="0" bgColor="#fff">
<uv-status-bar></uv-status-bar>
<uv-navbar
leftText=""
:safeAreaInsetTop="false"
:fixed="false"
title="{{{.FunctionName}}}"
autoBack
>
<template v-slot:right>
<uv-icon v-if="!fromSearch" name="search" size="24" @click="moreSearch"></uv-icon>
</template>
</uv-navbar>
<view class="search">
<uv-search
placeholder="请输入搜索内容"
shape="square"
v-model="queryParams.key"
:showAction="false"
bgColor="#fff"
borderColor="rgba(0, 0, 0, .1)"
@search="resetPage"
></uv-search>
</view>
</uv-sticky>
<uv-list>
<uv-list-item
v-for="item of pager.lists"
:key="item.id"
clickable
show-arrow
:title="item.name"
:note="item.placedPostion+'('+item.placedName+')'"
:right-text="item.status == 1 ? '在线' : ''"
@click="toDetails(item)"
></uv-list-item>
</uv-list>
<uv-back-top :scroll-top="scrollTop"></uv-back-top>
<uv-loading-page
:loading="pager.pageNo == 1 && pager.loading == 'loading'"
loading-text="加载中..."
font-size="24rpx"
></uv-loading-page>
<uv-load-more
:status="pager.loading"
:loading-text="pager.loadingText"
:loadmore-text="pager.loadmoreText"
:nomore-text="pager.nomoreText"
@loadmore="NextPage"
/>
</view>
</template>
<script setup>
import { reactive, ref } from "vue";
import {
onLoad,
onPullDownRefresh,
onReachBottom,
onPageScroll,
} from "@dcloudio/uni-app";
import { equipment_list } from "@/api/equipment.js";
import { usePaging } from "@/utils/usePaging";
import { toPath } from "@/utils/utils";
const queryParams = reactive({
key: "",
});
let fromSearch=ref(false);
onLoad((e) => {
console.log("equipment onLoad", e);
if (e) {
for (const key in e) {
if (Object.hasOwnProperty.call(e, key)) {
fromSearch.value = true;
queryParams[key] = e[key];
}
}
}
getLists();
});
const { pager, getLists, NextPage, resetPage, resetParams } = usePaging({
fetchFun: equipment_list,
params: queryParams,
});
let scrollTop = ref(0);
onPageScroll((e) => {
scrollTop.value = e.scrollTop;
});
onPullDownRefresh(() => {
resetPage();
});
onReachBottom(() => {
NextPage();
});
function toDetails(item) {
toPath("/pages/equipment/details", { id: item.id });
}
function moreSearch() {
toPath("/pages/equipment/search");
}
</script>
<style lang="scss" scoped>
.search {
padding: 5rpx;
background-color: #fff;
}
</style>

View File

@@ -0,0 +1,128 @@
<!-- 产品分组IMEISIm卡1、2安装位置在线状态 ,启用状态-->
<template>
<view class="page-content">
<uv-form labelPosition="left" labelWidth="80" :model="form" ref="formRef">
<!-- <uv-form-item label="所属产品" prop="productId" borderBottom>
<x-picker valueKey="id" labelKey="name" :columns="fotaProductList" v-model="form.productId"></x-picker>
</uv-form-item>
<uv-form-item label="所属产品" prop="groupId" borderBottom>
<x-picker valueKey="id" labelKey="name" :columns="showFotaGroupList" v-model="form.groupId"></x-picker>
</uv-form-item> -->
<uv-form-item label="在线状态" prop="status" borderBottom>
<x-picker valueKey="value" labelKey="label" :columns="dictData.devices_status"
v-model="form.status"></x-picker>
</uv-form-item>
<uv-form-item label="位置" prop="placedName" borderBottom>
<uv-input v-model="form.placedName"> </uv-input>
</uv-form-item>
<uv-form-item label="开始时间" prop="startTime" borderBottom>
<uv-input v-model="form.startTime" :readonly="true" placeholder="请选择时间"
@click="startTimePicker.open()"> </uv-input>
<uv-datetime-picker ref="startTimePicker" :minDate="minDate" :maxDate="maxDate" :value="form.startTime"
mode="datetime" @confirm="startTimeConfirm">
</uv-datetime-picker>
</uv-form-item>
<uv-form-item label="结束时间" prop="endTime" borderBottom>
<uv-input v-model="form.endTime" :readonly="true" placeholder="请选择时间"
@click="endTimePicker.open()"> </uv-input>
<uv-datetime-picker ref="endTimePicker" :minDate="minDate" :maxDate="maxDate" :value="form.endTime" mode="datetime"
@confirm="endTimeConfirm">
</uv-datetime-picker>
</uv-form-item>
<uv-button type="primary" text="搜索" customStyle="margin-top: 20rpx" @click="submit"></uv-button>
</uv-form>
</view>
</template>
<script setup>
import dayjs from 'dayjs'
import {
onLoad
} from "@dcloudio/uni-app";
import {
reactive,
ref,
computed
} from "vue";
import {
toPath,
toast,
clearObjEmpty
} from "@/utils/utils";
import {
useDictData
} from "@/methods/useDictOptions";
const startTimePicker = ref();
const endTimePicker = ref();
const {
dictData
} = useDictData(["devices_status"]);
let formRef = ref();
let form = ref({
location: "",
placedName: "",
status: "",
startTime: '',
endTime: '',
});
let minDate = dayjs('2022-01-01 00:00:00').valueOf()
let maxDate = dayjs().endOf('month').valueOf()
function startTimeConfirm(e) {
form.value.startTime = dayjs(e.value).format('YYYY-MM-DD HH:mm:ss')
}
function endTimeConfirm(e) {
form.value.endTime = dayjs(e.value).format('YYYY-MM-DD HH:mm:ss')
}
function submit() {
console.log("submit", form.value);
const search = clearObjEmpty(form.value);
if (Object.keys(search).length === 0) {
return toast("请输入查询条件");
}
toPath("/pages/equipment/equipment", search);
}
// const fotaProductList = ref([]);
// const fotaGroupList = ref([]);
// const showFotaGroupList = computed(() => {
// return fotaGroupList.value.filter((item) => {
// if (form.value.productId === "") {
// return true;
// }
// return item.productId == form.value.productId;
// });
// });
// function getList() {
// product_listAll().then((r) => {
// fotaProductList.value = r.result;
// });
// group_listAll().then((r) => {
// fotaGroupList.value = r.result;
// });
// }
// getList();
</script>
<style lang="scss" scoped>
.page-content {
padding: 10rpx 20rpx 300rpx;
}
</style>

View File

@@ -69,7 +69,7 @@
v-for="(item, index) in dictData.{{{ .DictType }}}" v-for="(item, index) in dictData.{{{ .DictType }}}"
:key="index" :key="index"
:label="item.name" :label="item.name"
{{{- if eq .GoType "Integer" }}} {{{- if eq .GoType "int" }}}
:value="parseInt(item.value)" :value="parseInt(item.value)"
{{{- else }}} {{{- else }}}
:value="item.value" :value="item.value"
@@ -89,7 +89,7 @@
<el-radio <el-radio
v-for="(item, index) in dictData.{{{ .DictType }}}" v-for="(item, index) in dictData.{{{ .DictType }}}"
:key="index" :key="index"
{{{- if eq .GoType "Integer" }}} {{{- if eq .GoType "int" }}}
:label="parseInt(item.value)" :label="parseInt(item.value)"
{{{- else }}} {{{- else }}}
:label="item.value" :label="item.value"

View File

@@ -164,6 +164,11 @@ func (tu templateUtil) GetTemplatePaths(genTpl string) []string {
"gocode/controller.go.tpl", "gocode/controller.go.tpl",
"vue/api.ts.tpl", "vue/api.ts.tpl",
"vue/edit.vue.tpl", "vue/edit.vue.tpl",
"uniapp/api.ts.tpl",
"uniapp/edit.vue.tpl",
"uniapp/index.vue.tpl",
"uniapp/search.vue.tpl",
} }
if genTpl == GenConstants.TplCrud { if genTpl == GenConstants.TplCrud {
tplPaths = append(tplPaths, "vue/index.vue.tpl") tplPaths = append(tplPaths, "vue/index.vue.tpl")
@@ -175,6 +180,7 @@ func (tu templateUtil) GetTemplatePaths(genTpl string) []string {
//go:embed templates/gocode //go:embed templates/gocode
//go:embed templates/vue //go:embed templates/vue
//go:embed templates/uniapp
var templatesFs embed.FS var templatesFs embed.FS
/** /**
@@ -215,6 +221,11 @@ func (tu templateUtil) GetFilePaths(tplCodeMap map[string]string, ModuleName str
"vue/edit.vue.tpl": strings.Join([]string{"admin/src/views/", ModuleName, "/edit.vue"}, ""), // "admin/src/views/%s/edit.vue", "vue/edit.vue.tpl": strings.Join([]string{"admin/src/views/", ModuleName, "/edit.vue"}, ""), // "admin/src/views/%s/edit.vue",
"vue/index.vue.tpl": strings.Join([]string{"admin/src/views/", ModuleName, "/index.vue"}, ""), // "admin/src/views/%s/index.vue", "vue/index.vue.tpl": strings.Join([]string{"admin/src/views/", ModuleName, "/index.vue"}, ""), // "admin/src/views/%s/index.vue",
"vue/index-tree.vue.tpl": strings.Join([]string{"admin/src/views/", ModuleName, "/index-tree.vue"}, ""), // "admin/src/views/%s/index-tree.vue", "vue/index-tree.vue.tpl": strings.Join([]string{"admin/src/views/", ModuleName, "/index-tree.vue"}, ""), // "admin/src/views/%s/index-tree.vue",
"uniapp/api.ts.tpl": strings.Join([]string{"uniapp/src/api/", ModuleName, ".ts"}, ""), // "admin/src/api/%s.ts",
"uniapp/edit.vue.tpl": strings.Join([]string{"uniapp/pages/", ModuleName, "/edit.vue"}, ""), // "uniapp/pages/%s/edit.vue",
"uniapp/index.vue.tpl": strings.Join([]string{"uniapp/pages/", ModuleName, "/index.vue"}, ""), // "uniapp/pages/%s/index.vue",
"uniapp/search.vue.tpl": strings.Join([]string{"uniapp/pages/", ModuleName, "/search.vue"}, ""), // "uniapp/pages/%s/index-tree.vue",
} }
filePath := make(map[string]string) filePath := make(map[string]string)
for tplPath, tplCode := range tplCodeMap { for tplPath, tplCode := range tplCodeMap {

View File

@@ -43,6 +43,6 @@ func (cSrv settingCopyrightService) Save(cReqs []SettingCopyrightItemReq) (e err
return return
} }
err = util.ConfigUtil.Set(cSrv.db, "website", "copyright", json) err = util.ConfigUtil.Set(cSrv.db, "website", "copyright", json)
e = response.CheckErr(err, "Save Set err") e = response.CheckErr(err, "保存失败")
return return
} }