接口调整

This commit is contained in:
fan 2021-07-20 09:04:06 +08:00
parent 7673c039ef
commit 90a539c4b7
6 changed files with 173 additions and 71 deletions

50
src/api/circuitryDraft.js Normal file
View File

@ -0,0 +1,50 @@
import request from '@/utils/request';
/** 查询用户所有电路数据 */
export function queryCircuitryDraftList() {
return request({
url: `/api/circuitryDraft/list/users`,
method: 'get'
});
}
/** 分页查询用户电路数据 */
export function queryCircuitryDraftListPaging(params) {
return request({
url: `/api/circuitryDraft/page/users`,
method: 'get',
params
});
}
/** 根据id获取数据 */
export function getCircuitryDraftDataById(id) {
return request({
url: `/api/circuitryDraft/${id}`,
method: 'get'
});
}
/** 创建草稿 */
export function createCircuitryDraft(data) {
return request({
url: `/api/circuitryDraft`,
method: 'post',
data
});
}
/** 更新草稿数据 */
export function updateCircuitryDraft(id, data) {
return request({
url: `/api/circuitryDraft/${id}/data`,
method: 'put',
data
});
}
/** 删除草稿 */
export function deleteCircuitryDarft(id) {
return request({
url: `/api/circuitryDraft/${id}`,
method: 'delete'
});
}

View File

@ -6,7 +6,7 @@ export function createModelDraft(data) {
url: `/draft/model2d/`, url: `/draft/model2d/`,
method: 'post', method: 'post',
data data
}) });
} }
/** 分页查询用户2d模型草稿*/ /** 分页查询用户2d模型草稿*/
@ -15,7 +15,7 @@ export function getModelDraftList(params) {
url: `/draft/model2d/paging`, url: `/draft/model2d/paging`,
method: 'get', method: 'get',
params params
}) });
} }
/** 更新2d模型基本信息 */ /** 更新2d模型基本信息 */
@ -24,7 +24,7 @@ export function updateModelDraftInfo(data) {
url: `/draft/model2d/${data.id}/basic`, url: `/draft/model2d/${data.id}/basic`,
method: 'put', method: 'put',
data data
}) });
} }
/** 更新2d模型数据 */ /** 更新2d模型数据 */
@ -33,15 +33,15 @@ export function updateModelDraftData(data) {
url: `/draft/model2d/${data.id}/data`, url: `/draft/model2d/${data.id}/data`,
method: 'put', method: 'put',
data data
}) });
} }
/** 根据id查询2d模型草稿数据 */ /** 根据id查询2d模型草稿数据 */
export function getModelDraftData(id) { export function getModelDraftData(id) {
return request({ return request({
url: `/draft/model2d/${id}`, url: `/draft/model2d/${id}`,
method: 'get', method: 'get'
}) });
} }
/** 发布模型 */ /** 发布模型 */
@ -49,7 +49,7 @@ export function publishModelDraft(id) {
return request({ return request({
url: `/draft/model2d/${id}/publish`, url: `/draft/model2d/${id}/publish`,
method: 'post' method: 'post'
}) });
} }
/** 删除草稿模型 */ /** 删除草稿模型 */
@ -57,15 +57,22 @@ export function deleteModelDraft(id) {
return request({ return request({
url: `/draft/model2d/${id}`, url: `/draft/model2d/${id}`,
method: 'delete' method: 'delete'
}) });
} }
/** 分页查询模型数据 */ /** 分页查询模型数据 */
export function getModelList() { export function getModelList() {
return request({ return request({
url: `/api/model2d/paging`, url: `/api/model2d/paging`,
method: 'get', method: 'get'
}) });
}
/** 查询模型数据 */
export function getModelListUnpage() {
return request({
url: '/api/model2d/list',
method: 'get'
});
} }
/** 查询某个模型所有历史版本数据 */ /** 查询某个模型所有历史版本数据 */
@ -73,7 +80,7 @@ export function getModelVersions(code) {
return request({ return request({
url: `/api/model2d/${code}/versions`, url: `/api/model2d/${code}/versions`,
method: 'get' method: 'get'
}) });
} }
/** 分页查询模型历史版本 */ /** 分页查询模型历史版本 */
@ -81,7 +88,7 @@ export function getModelVersionsPaging(code) {
return request({ return request({
url: `/api/model2d/${code}/versions/paging`, url: `/api/model2d/${code}/versions/paging`,
method: 'get' method: 'get'
}) });
} }
/** 更新2d模型基础信息 */ /** 更新2d模型基础信息 */
@ -89,7 +96,7 @@ export function updateModelBasicInfo(id) {
return request({ return request({
url: `/api/model2d/{id}/basic`, url: `/api/model2d/{id}/basic`,
method: 'put' method: 'put'
}) });
} }
/** 回滚版本 */ /** 回滚版本 */
@ -97,12 +104,6 @@ export function setModelVersion(code, version) {
return request({ return request({
url: `/api/model2d/${code}/version/${version}`, url: `/api/model2d/${code}/version/${version}`,
method: 'put' method: 'put'
}) });
} }

View File

@ -0,0 +1,57 @@
<template>
<el-dialog v-dialogDrag :visible.sync="visible" :title="title" width="300px" center :destroy-on-close="true">
<el-form ref="form" :model="formData" :rules="formRules" label-width="80px">
<el-form-item label="草稿名称" prop="name">
<el-input v-model="formData.name" size="mini" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="close"> </el-button>
<el-button type="primary" @click="confirmHandler"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { createCircuitryDraft } from '@/api/circuitryDraft';
export default {
name: 'CreateModelDraftDialog',
data() {
return {
visible: false,
formData: { name: ''},
formRules: {
name: [{ required: true, message: '请输入草稿名称', trigger: 'blur' }]
}
};
},
computed: {
title() {
return '新建草稿';
}
},
methods: {
show() {
this.formData = { name: '' };
this.visible = true;
},
close() {
this.visible = false;
},
confirmHandler() {
this.$refs.form.validate(valid => {
if (valid) {
createCircuitryDraft(this.formData).then(resp => {
this.close();
this.$emit('close');
}).catch(() => {
this.$message.error('创建草稿失败!');
});
}
});
}
}
};
</script>
<style lang="scss" scoped></style>

View File

@ -92,7 +92,7 @@ export default {
}; };
}, },
save() { save() {
const data = ''; this.$emit('save');
}, },
back() { back() {
this.$router.go(-1); this.$router.go(-1);

View File

@ -3,8 +3,8 @@
<!--<jl-model-builder type="测试类型" composeName="测试名称" :model="model" @save="save"></jl-model-builder>--> <!--<jl-model-builder type="测试类型" composeName="测试名称" :model="model" @save="save"></jl-model-builder>-->
<jl-picture-builder ref="jlPictureBuilder" :model="model" :compose-map="composeMap" @selectChange="selectChange" /> <jl-picture-builder ref="jlPictureBuilder" :model="model" :compose-map="composeMap" @selectChange="selectChange" />
<div style="height: 300px;background: #fff;z-index: 999;position: absolute;top: 70px;left: 0;"> <div style="height: 300px;background: #fff;z-index: 999;position: absolute;top: 70px;left: 0;">
<div v-for="item in modelList"> <div v-for="item in modelList" :key="item.code">
<el-button :key="item.code" size="mini" style="margin: 5px" @click="addModel(item)">{{ item.name }}</el-button> <el-button size="mini" style="margin: 5px" @click="addModel(item)">{{ item.name }}</el-button>
</div> </div>
</div> </div>
<draw-form <draw-form
@ -13,13 +13,15 @@
style="position: absolute;right: 0;top: 60px;height: calc(100% - 60px);" style="position: absolute;right: 0;top: 60px;height: calc(100% - 60px);"
@updateCompose="updateCompose" @updateCompose="updateCompose"
@deleteCompose="deleteCompose" @deleteCompose="deleteCompose"
@save="save"
/> />
</div> </div>
</template> </template>
<script> <script>
import DrawForm from './drawForm'; import DrawForm from './drawForm';
import { getModelList } from '@/api/management/model'; import { getModelListUnpage } from '@/api/management/model';
import { getCircuitryDraftDataById, updateCircuitryDraft } from '@/api/circuitryDraft';
export default { export default {
name: 'Edit', name: 'Edit',
components: { components: {
@ -32,10 +34,20 @@ export default {
modelList: [] modelList: []
}; };
}, },
async created() {
const res = await getCircuitryDraftDataById(this.$route.params.id);
const resp = await getModelListUnpage();
this.modelList = resp.data;
if (res.data.drawData) {
const data = JSON.parse(res.data.drawData);
this.model = data.model || [];
data.compose.forEach(item => {
const compose = this.modelList.find(elem => elem.code === item);
this.composeMap[item] = compose;
});
}
},
mounted() { mounted() {
getModelList().then(res=>{
this.modelList = res.data;
});
}, },
methods: { methods: {
test() { test() {
@ -43,6 +55,15 @@ export default {
}, },
save(model) { save(model) {
console.log(JSON.stringify(model)); console.log(JSON.stringify(model));
const data = {
id: this.$route.params.id,
drawData: JSON.stringify({ model:this.model, compose: Object.keys(this.composeMap) })
};
updateCircuitryDraft(this.$route.params.id, data).then(resp => {
this.$message.success('保存草稿数据成功!');
}).catch(() => {
this.$message.error('保存草稿数据错误!');
});
}, },
addModel(model) { addModel(model) {
if (!this.composeMap[model.code]) { if (!this.composeMap[model.code]) {

View File

@ -1,15 +1,18 @@
<template> <template>
<div class="container"> <div class="container">
<QueryListPage :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" /> <QueryListPage :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
<el-button @click="getList">queryPublishedModel</el-button> <create-dialog ref="createDialog" @close="closeCreate" />
</div> </div>
</template> </template>
<script> <script>
import { getModelDraftList, publishModelDraft, deleteModelDraft, getModelList } from '@/api/management/model'; import { queryCircuitryDraftListPaging, deleteCircuitryDarft } from '@/api/circuitryDraft';
import CreateDialog from './create';
export default { export default {
name: 'UserModelDesign', name: 'UserModelDesign',
components: {
CreateDialog
},
data() { data() {
return { return {
dialogs: { dialogs: {
@ -41,7 +44,7 @@ export default {
columns: [ columns: [
{ {
title: '地图编号', title: '地图编号',
prop: 'code' prop: 'id'
}, },
{ {
title: '地图名称', title: '地图名称',
@ -67,39 +70,28 @@ export default {
{ {
name: '绘图', name: '绘图',
handleClick: this.handleDraw handleClick: this.handleDraw
},
{
name: this.$t('global.delete'),
handleClick: this.handleDelete,
type: 'danger'
} }
// {
// name: '',
// handleClick: this.handlePublish,
// type: 'success'
// },
// {
// name: this.$t('global.delete'),
// handleClick: this.handleDelete,
// type: 'danger'
// }
] ]
} }
] ],
// actions: [{ text: this.$t('global.add'), handler: this.handleCreate }] actions: [{ text: this.$t('global.add'), handler: this.handleCreate }]
}, },
pubdModel: '' pubdModel: ''
}; };
}, },
methods: { methods: {
getList() {
getModelList().then(res=>{
console.log(res.data);
});
},
queryModelDraftList(params) { queryModelDraftList(params) {
return getModelDraftList(params); return queryCircuitryDraftListPaging(params);
}, },
handleCreate() { handleCreate() {
this.$refs.createDialog.show('create'); this.$refs.createDialog.show();
}, },
closeCreate(e) { closeCreate(e) {
@ -118,7 +110,7 @@ export default {
}) })
.then( .then(
() => { () => {
deleteModelDraft(data.id).then(() => { deleteCircuitryDarft(data.id).then(() => {
this.reloadTable(); this.reloadTable();
}); });
}, },
@ -133,25 +125,6 @@ export default {
this.$router.push({ path: `newdraw/${data.id}/edit` }); this.$router.push({ path: `newdraw/${data.id}/edit` });
}, },
handlePublish(idx, data) {
this.$confirm('确认发布?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
center: true
})
.then(
() => {
publishModelDraft(data.id).then(() => {
this.reloadTable();
});
},
() => {}
)
.catch(e => {
this.$message(e);
});
},
reloadTable() { reloadTable() {
this.queryList.reload(); this.queryList.reload();
} }