Browse Source

埃驰看板detail只显示同一条数据bug处理+api删除开发

noToken
安虹睿 1 year ago
parent
commit
4d0ea7e07f
  1. 28
      PC/InterFace.Dash/src/api/wms-api.js
  2. 28
      PC/InterFace.Dash/src/components/addEditFromApiPop/index.vue
  3. 14
      PC/InterFace.Dash/src/components/umyTable/index.vue
  4. 34
      PC/InterFace.Dash/src/mixins/TableMixins.js
  5. 1
      PC/InterFace.Dash/src/store/getters.js
  6. 18
      PC/InterFace.Dash/src/store/modules/definition.js
  7. 5
      PC/InterFace.Dash/src/views/demo/demo_api_handle.vue

28
PC/InterFace.Dash/src/api/wms-api.js

@ -1,6 +1,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/'
//新建
@ -147,3 +148,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/InterFace.Dash/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)

14
PC/InterFace.Dash/src/components/umyTable/index.vue

@ -214,7 +214,7 @@
stripe
:border="true"
style="width: 100%"
height="500"
height="300"
>
<el-table-column
v-for="(head,h_key) in showJsonHeader"
@ -224,14 +224,14 @@
<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/InterFace.Dash/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的表头转义数据
initApiColumnsForDto(list,titleName){

1
PC/InterFace.Dash/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/InterFace.Dash/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)
})
})

5
PC/InterFace.Dash/src/views/demo/IncomingData.vue → PC/InterFace.Dash/src/views/demo/demo_api_handle.vue

@ -1,5 +1,6 @@
<template>
<div class="page-box" v-loading="Loading.tableLoading">
<!-- DEMO:只有主表查询 API新增编辑删除 -->
<tablePagination
v-if="apiColumns_Table"
:currenButtonData="currenButtonData"
@ -25,11 +26,9 @@
:httpOverallSearchData="httpOverallSearchData"
:buttonOperationList_left="buttonOperationClick_leftBase"
@buttonOperationClick_left="buttonOperationClick_left"
:buttonOperationList_right="(data)=>{return buttonOperationList_rightApi(data,'edit')}"
:buttonOperationList_right="(data)=>{return buttonOperationList_rightApi(data,'edit|delete')}"
@buttonOperationClick_right="buttonOperationClick_right"
></tablePagination>
<!-- :buttonOperationList_left="buttonOperationClick_leftBase"
@buttonOperationClick_left="buttonOperationClick_left" -->
<curren-Drawer
ref="currenDrawer_Ref"
:title="apiColumns_DesTions"
Loading…
Cancel
Save