feat:创建测评 创建评估 接口对接

This commit is contained in:
dongwug
2022-10-31 18:22:56 +08:00
parent a9d78e9c7c
commit f112a80bd3
5 changed files with 526 additions and 244 deletions

63
src/api/indexEval.js Normal file
View File

@@ -0,0 +1,63 @@
import http from "./config";
// import qs from 'qs';
/**
* 接口传参数方式get
* axios.get('/user', {
* params: {
* id: 12345
* name: user
* }
* }).then(res => console.log(res))
*
* 接口传参三种方式post/put/patch
*
* 1.'Content-Type'= 'multipart/form-data',传参格式为 formData。
* (全局请求头:'Content-Type'= 'application/x-www-form-urlencoded'
* request的Header:'Content-Type'= 'multipart/form-data'
* var formData=new FormData();
* formData.append('user',123456);formData.append('pass',12345678);
* axios.post("/notice",formData).then()
*
* 2.'Content-Type'= 'application/x-www-form-urlencoded',传参格式为 query 形式,使用$qs.stringify。
* (全局请求头:'Content-Type'= 'application/x-www-form-urlencoded'
* request的Header:'Content-Type'= 'application/x-www-form-urlencoded'
* let data = {"code":"1234","name":"yyyy"};
* axios.post(`${this.$url}/test/testRequest`,qs.stringify({data})).then()
*
* 3.'Content-Type'= 'application/json传参格式为 raw (JSON格式)。
* (全局请求头:'Content-Type'= 'application/x-www-form-urlencoded'
* request的Header:'Content-Type'= 'application/json;charset=UTF-8'
* let data = {"code":"1234","name":"yyyy"}
* axios.post(`${this.$url}/test/testRequest`,data).then()
*
*/
// 接口-请求
//创建测评
export const createEvaluation = (obj) => http.post('/evaluation/createEvaluation', obj,);
//上传组件
export const fileUp = (obj) => http.post('/file/upload', obj,);
//删除测评信息
export const deleteEvaluationById = (obj) => http.post('/evaluation/deleteEvaluationById', { params: obj })
//根据ID获取测评信息详情
export const queryEvaluationDetailById = (obj) => http.post('/evaluation/queryEvaluationDetailById', { params: obj })
//修改测评信息
export const updateEvaluation = (obj) => http.post('/evaluation/updateEvaluation', obj)
// 测试方法
// import * as api from '../../api/index'
// api.getLearnPath({}).then(res => {
// console.log(res)
// }).catch(err => {
// console.log(err)
// })

60
src/api/indexInvist.js Normal file
View File

@@ -0,0 +1,60 @@
import http from "./config";
// import qs from 'qs';
/**
* 接口传参数方式get
* axios.get('/user', {
* params: {
* id: 12345
* name: user
* }
* }).then(res => console.log(res))
*
* 接口传参三种方式post/put/patch
*
* 1.'Content-Type'= 'multipart/form-data',传参格式为 formData。
* (全局请求头:'Content-Type'= 'application/x-www-form-urlencoded'
* request的Header:'Content-Type'= 'multipart/form-data'
* var formData=new FormData();
* formData.append('user',123456);formData.append('pass',12345678);
* axios.post("/notice",formData).then()
*
* 2.'Content-Type'= 'application/x-www-form-urlencoded',传参格式为 query 形式,使用$qs.stringify。
* (全局请求头:'Content-Type'= 'application/x-www-form-urlencoded'
* request的Header:'Content-Type'= 'application/x-www-form-urlencoded'
* let data = {"code":"1234","name":"yyyy"};
* axios.post(`${this.$url}/test/testRequest`,qs.stringify({data})).then()
*
* 3.'Content-Type'= 'application/json传参格式为 raw (JSON格式)。
* (全局请求头:'Content-Type'= 'application/x-www-form-urlencoded'
* request的Header:'Content-Type'= 'application/json;charset=UTF-8'
* let data = {"code":"1234","name":"yyyy"}
* axios.post(`${this.$url}/test/testRequest`,data).then()
*
*/
// 接口-请求
//创建评估
export const createAppraiseMessage = (obj) => http.post('/survey/createAppraiseMessage', obj,);
//删除评估信息
export const deleteAppraise = (obj) => http.post('/survey/deleteAppraise', { params: obj })
//根据ID获取评估信息详情
export const queryAppraiseDetailById = (obj) => http.post('/survey/queryAppraiseDetailById', { params: obj })
//修改评估信息
export const updateAppraiseMessage = (obj) => http.post('/survey/updateAppraiseMessage', obj)
// 测试方法
// import * as api from '../../api/index'
// api.getLearnPath({}).then(res => {
// console.log(res)
// }).catch(err => {
// console.log(err)
// })

0
src/api/indexVote.js Normal file
View File

View File

@@ -61,7 +61,10 @@
</div>
<div class="btnbox">
<a-range-picker
style="width: 424px;"
style="width: 424px"
v-model:value="time"
format="YYYY-MM-DD HH:mm:ss"
@change="onChange"
:placeholder="[' 开始时间', ' 结束时间']"
/>
</div>
@@ -77,7 +80,7 @@
list-type="picture-card"
class="avatar-uploader"
:show-upload-list="false"
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
action="/api/file/upload"
:before-upload="beforeUpload"
@change="handleChange"
>
@@ -93,15 +96,20 @@
</div>
</div>
<div class="main_btns">
<button class="btn1">取消</button>
<button class="btn2">确定</button>
<button class="btn1" @click="closeDrawer">取消</button>
<button class="btn2" @click="createEvalText">确定</button>
</div>
</div>
</a-drawer>
</template>
</template>
<script>
import { reactive, toRefs, ref } from "vue";
const rowSelection = ref({
import { reactive, toRefs, ref } from "vue";
import { useRouter } from "vue-router";
import * as api from "../../api/indexEval";
import { message } from "ant-design-vue";
// import { toDate } from "../../api/method";
const router = useRouter();
const rowSelection = ref({
checkStrictly: false,
onChange: (selectedRowKeys, selectedRows) => {
console.log(
@@ -116,8 +124,13 @@
onSelectAll: (selected, selectedRows, changeRows) => {
console.log(selected, selectedRows, changeRows);
},
});
export default {
});
function getBase64(img, callback) {
const reader = new FileReader();
reader.addEventListener('load', () => callback(reader.result));
reader.readAsDataURL(img);
}
export default {
name: "AddEval",
// components: {
// },
@@ -130,28 +143,130 @@
setup(props, ctx) {
const state = reactive({
inputV1: "",
inputV2:"",
inputV2: "",
time: undefined,
endTime: undefined,
startTime: undefined,
});
const closeDrawer = () => {
ctx.emit("update:addevalVisible", false);
state.inputV1 = "";
state.inputV2 = "";
state.time = undefined;
};
const afterVisibleChange = (bool) => {
console.log("state", bool);
};
const onChange = () => {
state.endTime = state.time[0].$d.toString;
state.startTime = state.time[1].$d.toString;
}
//上传组件
const fileList = ref([]);
const loading = ref(false);
const imageUrl = ref('');
const handleChange = info => {
if (info.file.status === 'uploading') {
loading.value = true;
return;
}
if (info.file.status === 'done') {
// Get this url from response in real world.
getBase64(info.file.originFileObj, base64Url => {
imageUrl.value = base64Url;
loading.value = false;
});
}
if (info.file.status === 'error') {
loading.value = false;
message.error('upload error');
}
}
const beforeUpload = file => {
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
if (!isJpgOrPng) {
message.error('You can only upload JPG file!');
}
const isLt2M = file.size / 1024 / 1024 < 2;
if (!isLt2M) {
message.error('Image must smaller than 2MB!');
}
return isJpgOrPng && isLt2M;
}
// const fileUp = () => {
// let obj = {
// file
// }
// }
//创建测评信息
const createEvalText = () => {
if (!state.inputV1) return message.info("请输入测评名称");
console.log(state.time);
console.log(state.time[0]);
console.log(state.time[0].$d.toString);
console.log(state.time[1].$d.toString);
let obj = {
evaluationName: state.inputV1,
createTime: "",
createUser: 0,
evaluationEndTime: state.endTime,
evaluationFlag: "",
evaluationId: "",
evaluationPictureAddress: "",
evaluationStartTime: state.startTime,
evaluationTag: "",
evaluationTypeId: 0,
evaluationTypeName: "",
updateTime: "",
updateUser: 0,
};
api
.createEvaluation(obj)
.then((res) => {
setTimeout(() => {
console.log("创建成功", res);
message.success("创建成功");
console.log(obj);
// state.createLoading = false;
router.push("/leveladd");
// getLearnPath();
}, 1000);
})
.catch((err) => {
console.log("创建失败", err);
// state.createLoading = false;
});
};
return {
...toRefs(state),
afterVisibleChange,
closeDrawer,
rowSelection,
createEvalText,
onChange,
//上传组件
fileList,
loading,
imageUrl,
handleChange,
beforeUpload,
};
},
};
</script>
};
</script>
<style lang="scss">
.ant-table-striped :deep(.table-striped) td {
.ant-table-striped :deep(.table-striped) td {
background-color: #fafafa !important;
}
.addevalDrawer {
}
.addevalDrawer {
.drawerMain {
.header {
height: 73px;
@@ -284,6 +399,6 @@
}
}
}
}
</style>
}
</style>

View File

@@ -85,14 +85,18 @@
</div>
</div>
<div class="main_btns">
<button class="btn1">取消</button>
<button class="btn2">确定</button>
<button class="btn1" @click="closeDrawer">取消</button>
<button class="btn2" @click="createInvist">确定</button>
</div>
</div>
</a-drawer>
</template>
<script>
import { reactive, toRefs, ref } from "vue";
import { useRouter } from "vue-router";
import * as api from "../../api/indexInvist";
import { message } from "ant-design-vue";
const router = useRouter();
const options1 = ref([
{
value: "value1",
@@ -132,16 +136,56 @@ export default {
});
const closeDrawer = () => {
ctx.emit("update:addinvistVisible", false);
state.inputV1 = "";
state.textV1 = "";
};
const afterVisibleChange = (bool) => {
console.log("state", bool);
};
//创建评估信息
const createInvist = () => {
if (!state.inputV1) return message.info("请输入测评名称");
// if (!state.inputV2) return message.info("请选择测评");
// if (!state.organizationSelectName) return message.info("请选择归属组织");
// state.createLoading = true;
let obj = {
appraiseName: state.inputV1,
appraiseEndTime: "",
appraiseExplain: state.textV1,
appraiseFlag: "",
appraiseId: 0,
appraiseStartTime: "",
appraiseTag: "",
createTime: "",
createUser: 0,
researchId: 0,
researchName: "",
updateTime: "",
updateUser: 0,
};
api
.createAppraiseMessage(obj)
.then((res) => {
setTimeout(() => {
console.log("创建成功", res);
message.success("创建成功");
// state.createLoading = false;
router.push("/leveladd");
// getLearnPath();
}, 1000);
})
.catch((err) => {
console.log("创建失败", err);
// state.createLoading = false;
});
};
return {
...toRefs(state),
afterVisibleChange,
closeDrawer,
rowSelection,
options1,
createInvist,
};
},
};