Browse Source

查看json的detail只存在同一条数据bug处理+api删除开发

noToken
安虹睿 1 year ago
parent
commit
7d65ceab0b
  1. 28
      PC/UI.WinIn.FasterZ.Store/src/api/wms-api.js
  2. 28
      PC/UI.WinIn.FasterZ.Store/src/components/addEditFromApiPop/index.vue
  3. 16
      PC/UI.WinIn.FasterZ.Store/src/components/umyTable/index.vue
  4. 34
      PC/UI.WinIn.FasterZ.Store/src/mixins/TableMixins.js
  5. 1
      PC/UI.WinIn.FasterZ.Store/src/store/getters.js
  6. 18
      PC/UI.WinIn.FasterZ.Store/src/store/modules/definition.js
  7. 112
      PC/UI.WinIn.FasterZ.Store/src/views/demo/demo_api_handle.vue
  8. 196
      PC/UI.WinIn.FasterZ.Store/src/views/demo/demo_base_handle.vue

28
PC/UI.WinIn.FasterZ.Store/src/api/wms-api.js

@ -2,6 +2,7 @@ import request from '@/utils/request'
import store from '@/store'
// let baseURL = process.env.VUE_APP_BASE_API + '/'
let baseAPI = localStorage.getItem('baseApi') + '/'
let baseURL = localStorage.getItem('baseApi') + '/api/'
//新建
@ -148,3 +149,30 @@ export function getVsersion() {
method: 'get'
})
}
// fast-new
//API-POST
export function ApiTypePost(data, url) {
return request({
url: baseAPI + url,
method: 'post',
data
})
}
//API-PUT
export function ApiTypePut(data, id, url) {
return request({
url: baseAPI + url,
method: 'put',
data,
params:{id:id}
})
}
//API-DELETE
export function ApiTypeDelete(id, url) {
return request({
url: baseAPI + url,
method: 'delete',
params:{id:id}
})
}

28
PC/UI.WinIn.FasterZ.Store/src/components/addEditFromApiPop/index.vue

@ -125,10 +125,9 @@
</el-dialog>
</template>
<script>
import { postCreate, postUpdate } from "@/api/wms-api"
import { ApiTypePost, ApiTypePut } from "@/api/wms-api"
import { LoadingMixins } from "@/mixins/LoadingMixins";
import { tableMixins } from "@/mixins/TableMixins"
import * as allUrlOption from '@/utils/baseData/urlOption'
export default {
name:"addEditFromApiPop",
mixins:[ LoadingMixins,tableMixins ],
@ -161,12 +160,7 @@ export default {
},
data () {
return {
//
URLOption_base:allUrlOption[this.$route.name].baseURL,
//
URLOption_add:allUrlOption[this.$route.name].addURL,
//
URLOption_edit:allUrlOption[this.$route.name].editURL,
currentDtos:this.$store.getters.dtoColumnTypes[this.$route.name],
active:0,//0 1 2
show:true,
formTitle:null,//form
@ -188,9 +182,8 @@ export default {
},
// rules
initFormItems(){
let data = this.$store.getters.dtoColumnTypes
let _dtoList_type = this.handleType == 'add' ? 'C' : 'U'
let _dtoList = data[this.$route.name][_dtoList_type].dtoList
let _dtoList = this.currentDtos[_dtoList_type].dtoList
this.formItemData = JSON.parse(JSON.stringify(_dtoList))
//
if(this.handleType == 'edit' && this.editRowData){
@ -236,14 +229,14 @@ export default {
this.submitForm(valid,this.formData,this.handleType,this.formItemData,this.formRules)
return
}
let _updata = this.handleType == 'add' ? this.URLOption_add : this.URLOption_edit
let _url = _updata ? _updata : this.URLOption_base
this.Loading.addEditApiLoading = true
if (valid) {
//
if(this.handleType == 'add'){
if(!_updata){_url = _url + '/create'}
postCreate(this.formData, _url).then(res => {
ApiTypePost(
this.formData,
this.currentDtos.C.actionsUrl
).then(res => {
this.changeActive(1)
}).catch(err => {
this.changeActive(2)
@ -251,8 +244,11 @@ export default {
}
//
else{
if(!_updata){_url = _url + '/update-by-id'}
postUpdate(this.formData, this.formData.id, _url).then(res => {
ApiTypePut(
this.formData,
this.formData.id,
this.currentDtos.U.actionsUrl
).then(res => {
this.changeActive(1)
}).catch(err => {
this.changeActive(2)

16
PC/UI.WinIn.FasterZ.Store/src/components/umyTable/index.vue

@ -214,24 +214,24 @@
stripe
:border="true"
style="width: 100%"
height="500"
height="300"
>
<el-table-column
v-for="(head) in showJsonHeader"
v-for="(head,h_key) in showJsonHeader"
:key="h_key"
min-width="120"
>
<template #header>
<span :title="head">{{ head }}</span>
</template>
<template slot-scope="scope" v-for="item in scope.row.value">
<div v-if="typeof item[head] == 'object'">
<div v-for="(o,o_key) in item[head]">
<template slot-scope="scope2">
<div v-if="typeof scope2.row[head] == 'object'">
<div v-for="(o,o_key) in scope2.row[head]">
{{ o_key }}{{ o }}
<div style="border-bottom: dashed 1px #ddd;"></div>
</div>
</div>
<div v-else>{{ item[head] }}</div>
<div v-else>{{ scope2.row[head] }}</div>
</template>
</el-table-column>
</el-table>
@ -672,7 +672,8 @@ export default {
//
if(!_json[item]){
_arr.push({name:item,value:_json[item]})
}else if(_json[item] && typeof _json[item] != 'object'){
}else{
if(typeof _json[item] != 'object'){
_arr.push({name:item,value:_json[item] + ""})
}else{
//
@ -699,6 +700,7 @@ export default {
}
}
}
}
this.showJsonData = _arr
this.$emit("showJsonTable", row);
},

34
PC/UI.WinIn.FasterZ.Store/src/mixins/TableMixins.js

@ -1,7 +1,8 @@
import {
getPageList,
getDetailed,
postDelete
postDelete,
ApiTypeDelete
} from '@/api/wms-api'
import { zhApiColumnsLable,firstWordSizeChange } from '@/utils/index'
export const tableMixins = {
@ -71,6 +72,13 @@ export const tableMixins = {
color:'#ff9000'
})
}
if(type.indexOf('delete') >= 0){
_btns.push({
label:'删除',
name:'deleteFromApi',
color:'red'
})
}
return _btns
},
// 主表-右侧操作列基础按钮操作
@ -89,7 +97,7 @@ export const tableMixins = {
this.displayDialog.editDialog = true
}
// 编辑 api
if (item.name == "editFromApi") {
else if (item.name == "editFromApi") {
this.addEditApiType = 'edit'
this.editFromApiRowData = row
this.displayDialog.addEditApiDialog = true;
@ -114,6 +122,28 @@ export const tableMixins = {
this.Loading.tableLoading = false
});
}
// 删除 api
else if (item.name == "deleteFromApi") {
this.$confirm('此操作将永久删除该消息, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.Loading.tableLoading = true
ApiTypeDelete(
row.id,
this.$store.getters.apiActions[this.$route.name].DeleteAsyncById.url
).then(res => {
this.$successMsg('删除成功!')
this.Loading.tableLoading = false
this.paging()
}).catch(err => {
this.Loading.tableLoading = false
})
}).catch(() => {
this.Loading.tableLoading = false
});
}
},
// 获取通过api的表头数据,不可以在初始化处理,因为接口返回问题
// initApiColumns(table,des,detailsTable,detailsPage){

1
PC/UI.WinIn.FasterZ.Store/src/store/getters.js

@ -15,5 +15,6 @@ const getters = {
enumList: state => state.definition.enumList,//接口获取的枚举
columZHList: state => state.definition.columZHList,//接口转义的表头
dtoColumnTypes: state => state.definition.dtoColumnTypes,//所有页面的dto类型
apiActions: state => state.definition.apiActions,//所有api的动作(增删改查等)
}
export default getters

18
PC/UI.WinIn.FasterZ.Store/src/store/modules/definition.js

@ -5,6 +5,7 @@ const state = {
enumList: [],//枚举
columZHList:null,//表头转义
dtoColumnTypes:[],//所有页面的dto类型
apiActions:[],//所有api的动作(增删改查等)
}
const mutations = {
@ -20,6 +21,10 @@ const mutations = {
SET_DTOCOLUMN_TYPES: (state, data) => {
state.dtoColumnTypes=data
},
// 所有api的动作(增删改查等)
SET_API_ACTIONS: (state, data) => {
state.apiActions=data
}
}
// 通过url做方法处理转换(S/C/U/G等)目前做了S查询/C新增/U编辑。如果有需要在丰富
@ -76,7 +81,8 @@ export function initDtoTypesAndEnums(res,typeName,apiName) {
}
// DTO列类型转义
export function initDtoColumnTypes(res) {
export function initDtoColumnTypes(res,commit) {
let _actionsObj = {}// 所有actions处理暂存数据
// modules>app>controller>这里是所有的接口
let _controller = res.modules.app.controllers
let _allData = {}
@ -84,6 +90,9 @@ export function initDtoColumnTypes(res) {
let _com = 'AppService'
// 获取简单的api(路由,如:IncomingData)
let _api = item.substring(item.lastIndexOf('.') + 1,item.length - _com.length)
// 所有actions处理
_actionsObj[_api] = _controller[item].actions;
// dto处理
let inner_item = {
baseApi:_api,
dtoList:[],
@ -101,23 +110,28 @@ export function initDtoColumnTypes(res) {
// 查询处理
let _type = _actions.returnValue.type
if(initDtoTypeByUrl(_actions.url) == 'S'){
_item.S.actionsUrl = _actions.url
let _type_value = _type.substring(_type.indexOf('<') + 1,_type.indexOf('>'))
_item.S.columnsType=_type_value
_item.S.dtoList = initDtoTypesAndEnums(res,_type_value,_api)
}
// 新增处理
if( initDtoTypeByUrl(_actions.url) == 'C' ){
_item.C.actionsUrl = _actions.url
_item.C.columnsType = _type
_item.C.dtoList = initDtoTypesAndEnums(res,_type,_api)
}
// 编辑处理
if( initDtoTypeByUrl(_actions.url) == 'U' ){
_item.U.actionsUrl = _actions.url
_item.U.columnsType = _type
_item.U.dtoList = initDtoTypesAndEnums(res,_type,_api)
}
}
_allData[_api] = _item
}
// 设置所有actions
commit('SET_API_ACTIONS', _actionsObj)
return _allData
}
@ -127,7 +141,7 @@ const actions = {
return new Promise(resolve => {
getApiDefinition().then(res=>{
commit('SET_ENUM_LIST', res.types)
commit('SET_DTOCOLUMN_TYPES', initDtoColumnTypes(res))
commit('SET_DTOCOLUMN_TYPES', initDtoColumnTypes(res,commit))
resolve(res)
})
})

112
PC/UI.WinIn.FasterZ.Store/src/views/demo/demo_api_handle.vue

@ -0,0 +1,112 @@
<template>
<div class="page-box" v-loading="Loading.tableLoading">
<!-- DEMO:只有主表查询 API新增编辑删除 -->
<tablePagination
v-if="apiColumns_Table"
:currenButtonData="currenButtonData"
:tableData="tableData"
:tableLoading="Loading.tableLoading"
:tableColumns="apiColumns_Table"
@rowDrop="rowDrop"
:totalCount="totalCount"
:multipleSelection="multipleSelection"
:MaxResultCount="PageListParams.MaxResultCount"
@topbutton="topbutton"
@inlineDialog="inlineDialog"
@sortChange="sortChange"
@alertoldSkipCount="alertoldSkipCount"
@alterResultCount="alterResultCount"
@handleSelectionChange="handleSelectionChange"
:currentPageProps="oldSkipCount"
:quicklySearchOption="quicklySearchOption"
@quicklySearchClick="quicklySearchClick"
@quicklySearchClear="quicklySearchClear"
:primarySearchOption="primarySearchOption"
@overallSearchFormClick="overallSearchFormClick"
:httpOverallSearchData="httpOverallSearchData"
:buttonOperationList_left="buttonOperationClick_leftBase"
@buttonOperationClick_left="buttonOperationClick_left"
:buttonOperationList_right="(data)=>{return buttonOperationList_rightApi(data,'edit|delete')}"
@buttonOperationClick_right="buttonOperationClick_right"
></tablePagination>
<curren-Drawer
ref="currenDrawer_Ref"
:title="apiColumns_DesTions"
@rowDrop="rowDrop"
:tableColumns="apiColumns_DetailsTable"
:tabsDesTions="apiColumns_DesTions"
:DrawerLoading="Loading.DrawerLoading"
:drawer="displayDialog.detailsDialog"
:propsData="propsData"
:Butttondata="[]"
@drawerShut="(val) => (displayDialog.detailsDialog = val)"
@drawerbutton="drawerbutton"
@handleCommand="drawerHandle"
@close-value="closeValue"
:totalCount="totalCountDetails"
:currentPage="oldSkipCountDetails"
:MaxResultCount="MaxResultCountDetails"
@alterResultCountDetails="alterResultCountDetails"
@alertoldSkipCountDetails="alertoldSkipCountDetails"
:buttonOperationList_left="operationButtonsDetail"
></curren-Drawer>
<!-- 导出弹窗 -->
<exportDrop
v-if="displayDialog.exportDialog"
@closeDialog="closeExportDrop"
@exportDropSubmit="exportDropSubmit"
></exportDrop>
<!-- Api新增 -->
<addEditFromApiPop
v-if="displayDialog.addEditApiDialog"
:handleType="addEditApiType"
:editRowData="editFromApiRowData"
@closePop="closeAddEditApiPop"
></addEditFromApiPop>
</div>
</template>
<script>
import { tableMixins } from "@/mixins/TableMixins";
import { LoadingMixins } from "@/mixins/LoadingMixins";
import { drawerMixins } from "@/mixins/drawerMixins"
import { TableHeaderMixins } from "@/mixins/TableHeaderMixins";
import { mixins } from "@/mixins/mixins";
import { filterSelectMixins } from '@/mixins/filter-Select'
import { getToken } from '@/utils/auth'
export default {
name: "IncomingData",
mixins: [
tableMixins,
LoadingMixins,
drawerMixins,
TableHeaderMixins,
mixins,
filterSelectMixins,
],
data() {
return {
//
currenButtonData: [
this.defaultAddBtn({
name:'addFromApi'
}),//
this.defaultExportBtn({
isRedundance:true,
isDetailExport:true
}),//
this.defaultFieldSettingBtn(),//
this.defaultFreshBtn(),//
this.defaultFilterBtn(),//
],
};
},
mounted() {
this.paging();
},
}
</script>
<style lang="scss" scoped>
@import "@/styles/basicData.scss";
</style>

196
PC/UI.WinIn.FasterZ.Store/src/views/demo/demo_base_handle.vue

@ -0,0 +1,196 @@
<template>
<div class="page-box" v-loading="Loading.tableLoading">
<!-- DEMO:只有主表 基础的主表增删改查 -->
<tablePagination
v-if="apiColumns_Table"
:currenButtonData="currenButtonData"
:tableData="tableData"
:tableLoading="Loading.tableLoading"
:tableColumns="apiColumns_Table"
@rowDrop="rowDrop"
:totalCount="totalCount"
:multipleSelection="multipleSelection"
:MaxResultCount="PageListParams.MaxResultCount"
@topbutton="topbutton"
@inlineDialog="inlineDialog"
@sortChange="sortChange"
@alertoldSkipCount="alertoldSkipCount"
@alterResultCount="alterResultCount"
@handleSelectionChange="handleSelectionChange"
:currentPageProps="oldSkipCount"
:quicklySearchOption="quicklySearchOption"
@quicklySearchClick="quicklySearchClick"
@quicklySearchClear="quicklySearchClear"
:primarySearchOption="primarySearchOption"
@overallSearchFormClick="overallSearchFormClick"
:httpOverallSearchData="httpOverallSearchData"
:buttonOperationList_left="buttonOperationClick_leftBase"
@buttonOperationClick_left="buttonOperationClick_left"
>
<!-- <div slot="tableTopSlot">
上方按钮插槽位置预留
</div>
<div slot="searchPrimarySlot">
普通初级搜索插槽位置预留
</div> -->
<!-- <template>表格内容插槽位置预留</template> -->
</tablePagination>
<!-- 新增与编辑 -->
<newAndEdiDialog
:loading="Loading.newAndEdiLoading"
:active="active"
:pageStatus="pageStatus"
:formReveal="formReveal"
:formTitle="formTitle"
:displayDialog="editDialog"
:FormData="formReveal ? CreateFormData : editFormData"
:Form="formReveal ? CreateForm : editForm"
:Options="editOptions"
:Handle="editHandle"
:Rules="formReveal ? editRules.cerateRule : editRules.editRule"
@FormSubmit="FormSubmit"
@close="FormClose"
@goBack="goBack"
></newAndEdiDialog>
<!-- 搜索按钮窗体组件 -->
<searchPage
ref="searchTable"
:tableLoading="Loading.autoTableLoading"
:advancedFilter="advancedFilter()"
:filterPageListParams="filterPageListParams"
:formTitle="searchTitle"
:displayDialog="displayDialog.AddNewDialog"
:searchTableData="searchData"
:searchTableColumns="searchColumns"
:searchTotalCount="searchTotalCount"
:supplierItemPage="searchPageListParams"
@handleSelectionChange="prepareFormData"
@SizeChange="searchAlterResultCount($event, searchPageListParams)"
@CurrentChange="searchAlertoldSkipCount($event, searchPageListParams)"
@tableButtonClick="searchSubmit(arguments)"
></searchPage>
<!-- 新导入 disabledMethod 导入方式禁用 disabledIsAllowPartImport 是否局部导入禁用-->
<!-- methodValue 导入方式默认选项 是否局部导入 默认选项 -->
<importFile
:loading="Loading.importLoading"
:show="displayDialog.importDialog"
:disabledMethod = {method1:false,method2:false,method3:false}
:disabledIsAllowPartImport = {isAllowPartImport1:false,isAllowPartImport2:false}
isAllowPartImportValue="1"
@importClick="postImportMergeClick(arguments)"
@postImportDown="importDown"
></importFile>
<!--抽屉-->
<curren-Drawer
ref="currenDrawer_Ref"
:title="apiColumns_DesTions"
@rowDrop="rowDrop"
:tableColumns="apiColumns_DetailsTable"
:tabsDesTions="apiColumns_DesTions"
:DrawerLoading="Loading.DrawerLoading"
:drawer="displayDialog.detailsDialog"
:propsData="propsData"
:dropdownData="dropdownData"
@drawerShut="(val) => (displayDialog.detailsDialog = val)"
@drawerbutton="drawerbutton"
@handleCommand="drawerHandle"
@close-value="closeValue"
:firstTabs="firstTabs"
:totalCount="totalCountDetails"
:currentPage="oldSkipCountDetails"
:MaxResultCount="MaxResultCountDetails"
@alterResultCountDetails="alterResultCountDetails"
@alertoldSkipCountDetails="alertoldSkipCountDetails"
:buttonOperationList_left="operationButtonsDetail"
></curren-Drawer>
</div>
</template>
<script>
import { tableMixins } from "@/mixins/TableMixins"
import { LoadingMixins } from "@/mixins/LoadingMixins"
import { drawerMixins } from "@/mixins/drawerMixins"
import { TableHeaderMixins } from "@/mixins/TableHeaderMixins"
import { newAndEdiDialogMixins } from "@/mixins/newAndEdiDialogMixins"
import { mixins } from "@/mixins/mixins"
import { filterSelectMixins } from '@/mixins/filter-Select'
import { zhApiColumnsLable } from '@/utils/index'
export default {
name: "ExportCustomUserSetting",
mixins: [
tableMixins,
LoadingMixins,
drawerMixins,
TableHeaderMixins,
mixins,
filterSelectMixins,
newAndEdiDialogMixins
],
computed: {
editDialog: {
get: function () {
return this.displayDialog.newDialog || this.displayDialog.editDialog;
},
},
},
data () {
const userInfo=this.$store.getters.currentUserInfo
return {
tableLoading:false,
//
currenButtonData: [
this.defaultAddBtn(),//
this.defaultFieldSettingBtn(),//
this.defaultFreshBtn(),//
this.defaultFilterBtn(),//
],
//
CreateFormData: {
customUserSetting: null,
exportUserName: userInfo.name,
exportUserId: userInfo.id,
exportColumnName: null,
exportTableName: null,
},
//
editFormData: {
customUserSetting: null,
exportUserName: userInfo.name,
exportUserId: userInfo.id,
exportColumnName: null,
exportTableName: null,
},
editOptions: {},
CreateForm: [
{ type: "input", label: zhApiColumnsLable('ExportCustomUserSettingCustomUserSetting'), prop: "customUserSetting", colSpan: 12 },
{ type: "input", label: zhApiColumnsLable('ExportCustomUserSettingExportColumnName'), prop: "exportColumnName", colSpan: 12 },
{ type: "input", label: zhApiColumnsLable('ExportCustomUserSettingExportTableName'), prop: "exportTableName", colSpan: 12 },
],
editForm: [
{ type: "input", label: zhApiColumnsLable('ExportCustomUserSettingCustomUserSetting'), prop: "customUserSetting", colSpan: 12 },
{ type: "input", label:zhApiColumnsLable('ExportCustomUserSettingExportColumnName'), prop: "exportColumnName", colSpan: 12 },
{ type: "input", label: zhApiColumnsLable('ExportCustomUserSettingExportTableName'), prop: "exportTableName", colSpan: 12 },
],
editRules: {
cerateRule: {
customUserSetting: [{ required: true, trigger: "blur", message: "不可为空" }],
exportColumnName: [{ required: true, trigger: "blur", message: "不可为空" }],
exportTableName: [{ required: true, trigger: "blur", message: "不可为空" }],
},
editRule: {
customUserSetting: [{ required: true, trigger: "blur", message: "不可为空" }],
exportColumnName: [{ required: true, trigger: "blur", message: "不可为空" }],
exportTableName: [{ required: true, trigger: "blur", message: "不可为空" }],
}
},
};
},
mounted () {
this.paging();
},
};
</script>
<style lang="scss" scoped>
@import "@/styles/basicData.scss";
</style>
Loading…
Cancel
Save