Browse Source

api新增编辑暂存

master
安虹睿 1 year ago
parent
commit
262b478ca2
  1. 75
      Code/Fe/src/components/addEditFromApiPop/index.vue
  2. 312
      Code/Fe/src/components/addEditFromApiPop/index_mst.vue
  3. 18
      Code/Fe/src/components/currenTableFlex/index.vue
  4. 182
      Code/Fe/src/components/umyTable/index.vue
  5. 2
      Code/Fe/src/store/modules/definition.js
  6. 2
      Code/Fe/src/views/demo/demo_api_handle.vue

75
Code/Fe/src/components/addEditFromApiPop/index.vue

@ -11,10 +11,12 @@
style="width:calc(100% - 28px);left:14px;top:14px;height:calc(100% - 28px)"
v-loading="Loading.addEditApiLoading"
>
<!-- 表单 -->
<!-- 数据填写 -->
<div v-if="active === 0" style="height: 100%;">
<!-- 标题 -->
<div class="dialogOuterTitle">{{formTitle}}</div>
<div class="centerInnerContent">
<!-- 左侧主表 -->
<div class="leftMainForm">
<div class="dialogOuterTitle">{{formTitle}} 主表信息</div>
<!-- 表单 -->
<el-form
class="addEditFrom"
@ -32,6 +34,7 @@
<el-form-item
:label="item.label"
:prop="item.prop"
v-if="item.label.toUpperCase() != 'DETAILS'"
>
<!-- 数值 -->
<el-input-number
@ -93,6 +96,23 @@
</el-col>
</el-row>
</el-form>
</div>
<!-- 右侧子表 -->
<div class="rightDetailTable">
<div class="dialogOuterTitle">{{formTitle}} 子表信息</div>
<!-- 子表 -->
<currenTableFlex
ref="currenTableFlex_Ref"
:isShowIndex="true"
:isEditable="true"
:setUTableHeight="230"
class="currenTableFlex"
v-if="flexTableData"
:flexTableData="flexTableData"
:flexTableColumns="flexTableColumns"
></currenTableFlex>
</div>
</div>
<!-- 操作按钮 -->
<div slot="footer" class="dialog-footer">
<el-button @click="show = false"> </el-button>
@ -128,9 +148,13 @@
import { ApiTypePost, ApiTypePut } from "@/api/wms-api"
import { LoadingMixins } from "@/mixins/LoadingMixins";
import { tableMixins } from "@/mixins/TableMixins"
import currenTableFlex from "@/components/currenTableFlex"
import * as allUrlOption from '@/utils/baseData/urlOption'
import { timeAgo } from "@/filters";
export default {
name:"addEditFromApiPop",
mixins:[ LoadingMixins,tableMixins ],
components: { currenTableFlex },
props: {
//
editRowData:{
@ -156,10 +180,13 @@ export default {
editSubmitUrl:{
type: String,
default: null
}
},
},
data () {
return {
//-
URLOption_detailList:allUrlOption[this.$route.name].detailListURL,
// dto
currentDtos:this.$store.getters.dtoColumnTypes[this.$route.name],
active:0,//0 1 2
show:true,
@ -167,6 +194,9 @@ export default {
formData:{},//
formItemData:null,//item
formRules: {},//
flexTableData:null,//table
// flexTableColumns:null,//table
flexTableColumns: null,
}
},
mounted(){
@ -191,6 +221,22 @@ export default {
}else{
this.formData = {}
}
//
let _list = this.formItemData.filter(item=>{
return item.prop.toUpperCase() == 'DETAILS'
})
if(_list && _list.length > 0){
if(this.handleType == 'edit'){
this.flexTableData = this.formData[_list[0].prop]
}else{
this.flexTableData = []
}
}
//
let _detailApi = this.URLOption_detailList.slice(0,this.URLOption_detailList.lastIndexOf('/'))
let _detailDtos = this.$store.getters.dtoColumnTypes[_detailApi].S.dtoList
this.flexTableColumns = _detailDtos
//
this.formRules={}
_dtoList.forEach(item=>{
@ -229,6 +275,7 @@ export default {
this.submitForm(valid,this.formData,this.handleType,this.formItemData,this.formRules)
return
}
this.formData.details = this.flexTableData
this.Loading.addEditApiLoading = true
if (valid) {
//
@ -294,7 +341,7 @@ export default {
width: 100%;
}
::v-deep .addEditFrom{
height: calc(100% - 120px);
height: calc(100%);
overflow: auto;
}
::v-deep .el-form-item__label{
@ -309,4 +356,22 @@ export default {
padding-top: 15px;
text-align: right;
}
.centerInnerContent{
height: calc(100% - 60px);
overflow: auto;
display: flex;
.leftMainForm{
width: 50%;
flex-shrink: 0;
height: calc(100% - 60px);
}
.rightDetailTable{
height: calc(100% - 60px);
width: calc(50%);
padding-left:40px;
border-left: #ddd solid 1px;
}
}
</style>

312
Code/Fe/src/components/addEditFromApiPop/index_mst.vue

@ -0,0 +1,312 @@
<template>
<!-- 组件功能普通新增编辑目前只有主表参数配置从api获取 -->
<el-dialog
:visible.sync="show"
:modal="false"
:modal-append-to-body="false"
:show-close="true"
@close="close"
class="searchPageComponents"
:fullscreen="true"
style="width:calc(100% - 28px);left:14px;top:14px;height:calc(100% - 28px)"
v-loading="Loading.addEditApiLoading"
>
<!-- 表单 -->
<div v-if="active === 0" style="height: 100%;">
<!-- 标题 -->
<div class="dialogOuterTitle">{{formTitle}}</div>
<!-- 表单 -->
<el-form
class="addEditFrom"
ref="addEditFrom_Ref"
v-if="formData"
:model="formData"
:rules="formRules"
>
<el-row :gutter="40">
<el-col
:span="item.colSpan || 12"
v-for="(item, index) in formItemData"
:key="index"
>
<el-form-item
:label="item.label"
:prop="item.prop"
>
<!-- 数值 -->
<el-input-number
v-if="item.apiBaseType === 'number'"
v-model="formData[item.prop]"
:min="item.minimum || undefined"
:max="item.maximum || undefined"
:maxlength="item.maxLength || undefined"
:minlength="item.minLength || undefined"
:disabled="Boolean(item.disabled)"
:placeholder="item.placeholder || '请输入' + item.label"
@change="changeValue(item.prop,item,$event)"
@clear="clearValue(item.prop,$event)"
></el-input-number>
<!-- 时间转换 -->
<el-date-picker
v-else-if="item.apiBaseType === 'datetime'"
v-model="formData[item.prop]"
type="datetime"
placeholder="选择日期时间"
format="yyyy-MM-dd HH:mm:ss"
value-format="yyyy-MM-ddTHH:mm:ss"
:disabled="Boolean(item.disabled)"
></el-date-picker>
<!-- 布尔枚举 -->
<el-select
v-else-if="item.isEnums || item.apiBaseType === 'boolean'"
v-model="formData[item.prop]"
:placeholder="item.placeholder || '请选择' + item.label"
:disabled="Boolean(item.disabled)"
>
<el-option
v-for="item in getItemEnums(item)"
:key="item.value"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
<!-- 文本框 -->
<!-- <el-input
v-else
type="textarea"
autosize
resize="none"
v-model="formData[item.prop]"
:placeholder="item.placeholder || '请输入' + item.label"
:disabled="Boolean(item.disabled)"
></el-input> -->
<el-input
v-else
v-model="formData[item.prop]"
:placeholder="item.placeholder || '请输入' + item.label"
:disabled="Boolean(item.disabled)"
></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<!-- 操作按钮 -->
<div slot="footer" class="dialog-footer">
<el-button @click="show = false"> </el-button>
<el-button type="primary" @click="submitHandle()"> </el-button>
</div>
</div>
<!-- 成功提示 -->
<div v-if="active === 1">
<el-result icon="success" title="成功提示" :subTitle="formTitle + '成功'">
<template slot="extra">
<el-button type="primary" size="medium" @click="exitHandle"
>退出</el-button
>
</template>
</el-result>
</div>
<!-- 错误提示 -->
<div v-if="active === 2">
<el-result icon="error" title="错误提示" :subTitle="formTitle + '失败'">
<template slot="extra">
<el-button type="primary" size="medium" @click="changeActive(0)"
>返回</el-button
>
<el-button type="primary" size="medium" @click="exitHandle"
>退出</el-button
>
</template>
</el-result>
</div>
</el-dialog>
</template>
<script>
import { ApiTypePost, ApiTypePut } from "@/api/wms-api"
import { LoadingMixins } from "@/mixins/LoadingMixins";
import { tableMixins } from "@/mixins/TableMixins"
export default {
name:"addEditFromApiPop",
mixins:[ LoadingMixins,tableMixins ],
props: {
//
editRowData:{
type: Object,
default: null
},
// add/edit
handleType:{
type: String,
default: null
},
//
submitForm:{
type:Function,
default:null
},
//
addSubmitUrl:{
type: String,
default: null
},
//
editSubmitUrl:{
type: String,
default: null
}
},
data () {
return {
currentDtos:this.$store.getters.dtoColumnTypes[this.$route.name],
active:0,//0 1 2
show:true,
formTitle:null,//form
formData:{},//
formItemData:null,//item
formRules: {},//
}
},
mounted(){
this.initTitle()
this.initFormItems()
},
methods: {
// form
initTitle(){
if(this.handleType){
this.formTitle = this.handleType == 'add' ? '新增'+this.$route.name : '编辑'+this.$route.name
}
},
// rules
initFormItems(){
let _dtoList_type = this.handleType == 'add' ? 'C' : 'U'
let _dtoList = this.currentDtos[_dtoList_type].dtoList
this.formItemData = JSON.parse(JSON.stringify(_dtoList))
//
if(this.handleType == 'edit' && this.editRowData){
this.formData = JSON.parse(JSON.stringify(this.editRowData))
}else{
this.formData = {}
}
//
this.formRules={}
_dtoList.forEach(item=>{
if(item.isRequired){
this.formRules[item.prop] = [{ required: true, trigger: "blur", message: "不可为空" }]
}
})
},
//
getItemEnums(item){
let _option = []
//
if(item.apiBaseType == 'boolean'){
_option = [{
value: true,
label: '是'
},{
value: false,
label: '否'
},]
}
if(item.isEnums){
_option = item.enums_list
}
return _option
},
//
close() {
this.show = false
this.$emit("closePop")
},
//
submitHandle(){
this.$refs.addEditFrom_Ref.validate((valid) => {
if(this.submitForm){
this.submitForm(valid,this.formData,this.handleType,this.formItemData,this.formRules)
return
}
this.Loading.addEditApiLoading = true
if (valid) {
//
if(this.handleType == 'add'){
ApiTypePost(
this.formData,
this.currentDtos.C.actionsUrl
).then(res => {
this.changeActive(1)
}).catch(err => {
this.changeActive(2)
})
}
//
else{
ApiTypePut(
this.formData,
this.formData.id,
this.currentDtos.U.actionsUrl
).then(res => {
this.changeActive(1)
}).catch(err => {
this.changeActive(2)
})
}
} else {
return false;
}
});
},
// 退
exitHandle(){
this.close()
if(this.active == '1')this.oldSkipCount = 1;
this.show = false
this.paging()
this.$nextTick(()=>{
this.active = 0
})
},
//
changeActive(sta){
this.active = sta
this.Loading.addEditApiLoading = false
},
//
changeValue(prop,item,val) {
this.$emit("changeValue", prop, item, val)
},
//
clearValue(prop,item,val) {
this.$emit("clearValue", prop, item, val)
},
}
}
</script>
<style lang="scss" scoped>
::v-deep .el-dialog__header{
padding: 0 !important;
}
::v-deep .el-row{
width: 100%;
}
::v-deep .addEditFrom{
height: calc(100% - 120px);
overflow: auto;
}
::v-deep .el-form-item__label{
float: unset;
}
::v-deep .el-input,.el-select,.el-input-number{
width: 100% !important;
}
.dialog-footer{
padding-top: 15px;
text-align: right;
}
</style>

18
Code/Fe/src/components/currenTableFlex/index.vue

@ -11,13 +11,15 @@
<slot name="headerBtns"></slot>
</div>
<!-- todo:多选处理selectionTable -->
<currenTable
<umyTable
:isEditable="isEditable"
class="flexTable"
:tableData="flexTableData"
:searchOptions="flexSearchOptions"
:tableColumns="flexTableColumns"
:selectionTable="selectionTable"
:isShowIndex="isShowIndex"
:setUTableHeight="setUTableHeight"
@push="detailsDataPush(arguments)"
>
<template v-if="showAllDeleteButton">
@ -38,7 +40,7 @@
</template>
</el-table-column>
</template>
</currenTable>
</umyTable>
</div>
</template>
<script>
@ -85,6 +87,18 @@ export default {
// }
},
props: {
// table
isEditable:{
type: Boolean,
default: false
},
// app-main100%
setUTableHeight: {
type: Number,
default: () => {
return 280;
}
},
//
showAddBtn:{
type: Boolean,

182
Code/Fe/src/components/umyTable/index.vue

@ -13,57 +13,10 @@
style="width: 100%"
:cell-style="cellStyle"
use-virtual
:row-height="50"
:height="uTableHeight"
header-row-class-name="uTableHeader"
>
<!-- :tree-props="treeProps" height 不能共存 此组件暂不支持tree的格式-->
<!-- 操作列 左侧-->
<u-table-column
v-if="buttonOperationList_left"
:fixed="'left'"
width="auto"
min-width="120px"
:align="'center'"
:header-align="'center'"
>
<template #header>
<span>{{ $t('common.handle') }}</span>
</template>
<template slot-scope="scope">
<el-button
v-for="(itemButton, indexButton) in buttonOperationList_left"
:key="indexButton"
type="text"
size="mini"
@click="buttonOperationClick_left(scope.row, itemButton, indexButton)"
>{{itemButton.label}}</el-button>
</template>
</u-table-column>
<!-- 操作列 右侧-->
<u-table-column
v-if="buttonOperationList_right"
:fixed="'right'"
width="auto"
min-width="120px"
:align="'center'"
:header-align="'center'"
>
<template #header>
<span>{{ $t('common.handle') }}</span>
</template>
<template slot-scope="scope">
<el-button
v-for="(itemButton, indexButton) in buttonOperationList_right(scope.row)"
v-show="!itemButton.hide"
:key="indexButton"
type="text"
size="mini"
:style="{color:itemButton.color || '#409EFF'}"
@click="buttonOperationClick_right(scope.row, itemButton, indexButton)"
>{{itemButton.label}}</el-button>
</template>
</u-table-column>
<u-table-column v-if="selectionTable" fixed="left" type="selection" :reserve-selection="true" />
<u-table-column v-if="isShowIndex" type="index" fixed="left" label="序号" width="50" />
<template v-for="(item, index) in TableSize">
@ -84,6 +37,8 @@
<i style="color: #f56c6c" v-if="item.rules && requiredRules">*</i>
</template>
<template slot-scope="scope">
<!-- 正常表格回显 -->
<div v-if="!isEditable">
<!-- 时间转换 -->
<span v-if="item.apiBaseType == 'datetime'"
@click="showDetailInfo(scope.row[item.prop],'time')"
@ -115,9 +70,107 @@
>
{{ initApiOtherType(scope.row[item.prop])[0] }}
</span>
</div>
<!-- 可编辑表格 -->
<div v-else>
<!-- 时间转换 -->
<el-date-picker
v-if="item.apiBaseType === 'datetime'"
v-model="scope.row[item.prop]"
type="datetime"
placeholder="选择日期时间"
format="yyyy-MM-dd HH:mm:ss"
value-format="yyyy-MM-ddTHH:mm:ss"
:disabled="Boolean(item.disabled)"
size="mini"
></el-date-picker>
<!-- 布尔枚举 -->
<el-select
v-else-if="item.isEnums || item.apiBaseType === 'boolean'"
v-model="scope.row[item.prop]"
:placeholder="item.placeholder || '请选择' + item.label"
:disabled="Boolean(item.disabled)"
size="mini"
>
<el-option
v-for="item in getItemEnums(item)"
:key="item.value"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
<!-- 数值 -->
<el-input-number
v-else-if="item.apiBaseType === 'number'"
v-model="scope.row[item.prop]"
:min="item.minimum || undefined"
:max="item.maximum || undefined"
:maxlength="item.maxLength || undefined"
:minlength="item.minLength || undefined"
:disabled="Boolean(item.disabled)"
:placeholder="item.placeholder || '请输入' + item.label"
@change="changeValue(item.prop,item,$event)"
@clear="clearValue(item.prop,$event)"
size="mini"
></el-input-number>
<!-- 文本值 -->
<el-input
v-else
v-model="scope.row[item.prop]"
:placeholder="item.placeholder || '请输入' + item.label"
:disabled="Boolean(item.disabled)"
size="mini"
></el-input>
</div>
</template>
</u-table-column>
</template>
<!-- 操作列 左侧-->
<u-table-column
v-if="buttonOperationList_left"
:fixed="'left'"
width="auto"
min-width="120px"
:align="'center'"
:header-align="'center'"
>
<template #header>
<span>{{ $t('common.handle') }}</span>
</template>
<template slot-scope="scope">
<el-button
v-for="(itemButton, indexButton) in buttonOperationList_left"
:key="indexButton"
type="text"
size="mini"
@click="buttonOperationClick_left(scope.row, itemButton, indexButton)"
>{{itemButton.label}}</el-button>
</template>
</u-table-column>
<!-- 操作列 右侧-->
<u-table-column
v-if="buttonOperationList_right"
:fixed="'right'"
width="auto"
min-width="120px"
:align="'center'"
:header-align="'center'"
>
<template #header>
<span>{{ $t('common.handle') }}</span>
</template>
<template slot-scope="scope">
<el-button
v-for="(itemButton, indexButton) in buttonOperationList_right(scope.row)"
v-show="!itemButton.hide"
:key="indexButton"
type="text"
size="mini"
:style="{color:itemButton.color || '#409EFF'}"
@click="buttonOperationClick_right(scope.row, itemButton, indexButton)"
>{{itemButton.label}}</el-button>
</template>
</u-table-column>
<slot></slot>
<!-- 点开查看全部弹窗 -->
@ -271,6 +324,11 @@ export default {
},
},
props: {
// table
isEditable:{
type: Boolean,
default: false
},
//
buttonOperationList_left:{
type: Array,
@ -788,6 +846,32 @@ export default {
if(type == 'detail')this.showDetailInfo(row)
if(type == 'json')this.showJsonTable(row)
},
//
getItemEnums(item){
let _option = []
//
if(item.apiBaseType == 'boolean'){
_option = [{
value: true,
label: '是'
},{
value: false,
label: '否'
},]
}
if(item.isEnums){
_option = item.enums_list
}
return _option
},
//
changeValue(prop,item,val) {
this.$emit("changeValue", prop, item, val)
},
//
clearValue(prop,item,val) {
this.$emit("clearValue", prop, item, val)
},
},
};
</script>
@ -805,8 +889,8 @@ export default {
}
::v-deep .el-table__fixed {
display: block-inline !important;
height: auto !important;
bottom: 13px !important;
height: 100% !important;
// bottom: 13px !important;
.el-table__fixed-header-wrapper {
z-index: auto !important;
}

2
Code/Fe/src/store/modules/definition.js

@ -74,7 +74,7 @@ export function initDtoTypesAndEnums(res,typeName,apiName) {
}
}
d.baseApiName = apiName + d.name
d.label = zhApiColumnsLable(apiName + d.name,res.types) || d.name
d.label = zhApiColumnsLable(apiName + d.name) || d.name
d.prop = firstWordSizeChange(d.name)
})
return _dtos

2
Code/Fe/src/views/demo/demo_api_handle.vue

@ -1,6 +1,6 @@
<template>
<div class="page-box" v-loading="Loading.tableLoading">
<!-- DEMO:只有主表查询 API新增编辑删除 -->
<!-- DEMO: API新增编辑删除 根据details判断是否有子表编辑-->
<tablePagination
v-if="apiColumns_Table"
:currenButtonData="currenButtonData"

Loading…
Cancel
Save