mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-27 01:32:03 +08:00
!761 代码生成:vue2 代码模版格式调整;代码生成:准备 CodegenEngineVue2Test 所需测试文件
Merge pull request !761 from puhui999/feature/sub-table
This commit is contained in:
commit
d3a565f011
@ -89,7 +89,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
|
||||
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}';
|
||||
#if ($hasImageUploadColumn)
|
||||
import ImageUpload from '@/components/ImageUpload';
|
||||
#end
|
||||
|
@ -8,12 +8,12 @@
|
||||
<div class="app-container">
|
||||
#if ( $subTable.subJoinMany )## 情况一:一对多,table + form
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
v-loading="formLoading"
|
||||
label-width="0px"
|
||||
:inline-message="true"
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
v-loading="formLoading"
|
||||
label-width="0px"
|
||||
:inline-message="true"
|
||||
>
|
||||
<el-table :data="formData" class="-mt-10px">
|
||||
<el-table-column label="序号" type="index" width="100" />
|
||||
@ -137,11 +137,11 @@
|
||||
</el-row>
|
||||
#else## 情况二:一对一,form
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
#foreach($column in $subColumns)
|
||||
#if ($column.createOperation || $column.updateOperation)
|
||||
@ -221,7 +221,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
|
||||
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}';
|
||||
#if ($hasImageUploadColumn)
|
||||
import ImageUpload from '@/components/ImageUpload';
|
||||
#end
|
||||
|
@ -61,9 +61,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
|
||||
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}';
|
||||
#if ($table.templateType == 11)
|
||||
import ${subSimpleClassName}Form from './${subSimpleClassName}Form.vue'
|
||||
import ${subSimpleClassName}Form from './${subSimpleClassName}Form.vue';
|
||||
#end
|
||||
export default {
|
||||
name: "${subSimpleClassName}List",
|
||||
|
@ -12,10 +12,10 @@
|
||||
#if ( $table.templateType == 2 && $column.id == $treeParentColumn.id )
|
||||
<el-form-item label="${comment}" prop="${javaField}">
|
||||
<TreeSelect
|
||||
v-model="formData.${javaField}"
|
||||
:options="${classNameVar}Tree"
|
||||
:normalizer="normalizer"
|
||||
placeholder="请选择${comment}"
|
||||
v-model="formData.${javaField}"
|
||||
:options="${classNameVar}Tree"
|
||||
:normalizer="normalizer"
|
||||
placeholder="请选择${comment}"
|
||||
/>
|
||||
</el-form-item>
|
||||
#elseif ($column.htmlType == "input" && !$column.primaryKey)## 忽略主键,不用在表单里
|
||||
@ -107,7 +107,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
|
||||
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}';
|
||||
#if ($hasImageUploadColumn)
|
||||
import ImageUpload from '@/components/ImageUpload';
|
||||
#end
|
||||
@ -212,7 +212,7 @@
|
||||
this.title = "新增${table.classComment}";
|
||||
## 特殊:树表专属逻辑
|
||||
#if ( $table.templateType == 2 )
|
||||
this.get${simpleClassName}Tree();
|
||||
await this.get${simpleClassName}Tree();
|
||||
#end
|
||||
},
|
||||
/** 提交按钮 */
|
||||
@ -263,7 +263,7 @@
|
||||
this.#[[$modal]]#.msgSuccess("新增成功");
|
||||
this.dialogVisible = false;
|
||||
this.#[[$]]#emit('success');
|
||||
}finally {
|
||||
} finally {
|
||||
this.formLoading = false;
|
||||
}
|
||||
},
|
||||
|
@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
#foreach($column in $columns)
|
||||
@ -68,24 +67,24 @@
|
||||
## 特殊:主子表专属逻辑
|
||||
#if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 )
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="list"
|
||||
:stripe="true"
|
||||
:highlight-current-row="true"
|
||||
:show-overflow-tooltip="true"
|
||||
@current-change="handleCurrentChange"
|
||||
v-loading="loading"
|
||||
:data="list"
|
||||
:stripe="true"
|
||||
:highlight-current-row="true"
|
||||
:show-overflow-tooltip="true"
|
||||
@current-change="handleCurrentChange"
|
||||
>
|
||||
## 特殊:树表专属逻辑
|
||||
#elseif ( $table.templateType == 2 )
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="list"
|
||||
:stripe="true"
|
||||
:show-overflow-tooltip="true"
|
||||
v-if="refreshTable"
|
||||
row-key="id"
|
||||
:default-expand-all="isExpandAll"
|
||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||
v-loading="loading"
|
||||
:data="list"
|
||||
:stripe="true"
|
||||
:show-overflow-tooltip="true"
|
||||
v-if="refreshTable"
|
||||
row-key="id"
|
||||
:default-expand-all="isExpandAll"
|
||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||
>
|
||||
#else
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||
@ -183,7 +182,7 @@ import Editor from '@/components/Editor';
|
||||
#if ( $table.templateType != 10 )
|
||||
#if ( $subTables && $subTables.size() > 0 )
|
||||
#foreach ($subSimpleClassName in $subSimpleClassNames)
|
||||
import ${subSimpleClassName}List from './components/${subSimpleClassName}List.vue'
|
||||
import ${subSimpleClassName}List from './components/${subSimpleClassName}List.vue';
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
@ -298,7 +297,7 @@ export default {
|
||||
await this.#[[$modal]]#.confirm('是否确认删除${table.classComment}编号为"' + ${primaryColumn.javaField} + '"的数据项?')
|
||||
try {
|
||||
await ${simpleClassName}Api.delete${simpleClassName}(${primaryColumn.javaField});
|
||||
this.getList();
|
||||
await this.getList();
|
||||
this.#[[$modal]]#.msgSuccess("删除成功");
|
||||
} catch {}
|
||||
},
|
||||
|
@ -43,7 +43,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as StudentApi from '@/api/infra/demo'
|
||||
import * as StudentApi from '@/api/infra/demo';
|
||||
import ImageUpload from '@/components/ImageUpload';
|
||||
import FileUpload from '@/components/FileUpload';
|
||||
import Editor from '@/components/Editor';
|
||||
@ -90,19 +90,17 @@
|
||||
},
|
||||
methods: {
|
||||
/** 打开弹窗 */
|
||||
open(id, studentId) {
|
||||
async open(id, studentId) {
|
||||
this.dialogVisible = true;
|
||||
this.reset();
|
||||
const that = this;
|
||||
this.formData.studentId = studentId;
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
this.formLoading = true;
|
||||
try {
|
||||
StudentApi.getStudentContact(id).then(res=>{
|
||||
that.formData = res.data;
|
||||
that.dialogTitle = "修改学生联系人";
|
||||
})
|
||||
const res = await StudentApi.getStudentContact(id);
|
||||
this.formData = res.data;
|
||||
this.dialogTitle = "修改学生联系人";
|
||||
} finally {
|
||||
this.formLoading = false;
|
||||
}
|
||||
@ -110,32 +108,26 @@
|
||||
this.dialogTitle = "新增学生联系人";
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
async submitForm() {
|
||||
await this.$refs["formRef"].validate();
|
||||
this.formLoading = true;
|
||||
try {
|
||||
let data = this.formData;
|
||||
this.$refs["formRef"].validate(valid => {
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
const data = this.formData;
|
||||
// 修改的提交
|
||||
if (data.id) {
|
||||
StudentApi.updateStudentContact(data).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
});
|
||||
await StudentApi.updateStudentContact(data);
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
return;
|
||||
}
|
||||
// 添加的提交
|
||||
StudentApi.createStudentContact(data).then(response => {
|
||||
await StudentApi.createStudentContact(data);
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
});
|
||||
});
|
||||
}finally {
|
||||
this.formLoading = false
|
||||
this.formLoading = false;
|
||||
}
|
||||
},
|
||||
/** 表单重置 */
|
||||
|
@ -52,8 +52,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as StudentApi from '@/api/infra/demo'
|
||||
import StudentContactForm from './StudentContactForm.vue'
|
||||
import * as StudentApi from '@/api/infra/demo';
|
||||
import StudentContactForm from './StudentContactForm.vue';
|
||||
export default {
|
||||
name: "StudentContactList",
|
||||
components: {
|
||||
@ -91,14 +91,12 @@
|
||||
},
|
||||
methods: {
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
async getList() {
|
||||
try {
|
||||
this.loading = true;
|
||||
const that = this;
|
||||
StudentApi.getStudentContactPage(this.queryParams).then(response => {
|
||||
that.list = response.data.list;
|
||||
that.total = response.data.total;
|
||||
});
|
||||
const res = await StudentApi.getStudentContactPage(this.queryParams);
|
||||
this.list = res.data.list;
|
||||
this.total = res.data.total;
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
@ -111,22 +109,19 @@
|
||||
/** 添加/修改操作 */
|
||||
openForm(id) {
|
||||
if (!this.studentId) {
|
||||
that.$modal.msgError('请选择一个学生');
|
||||
this.$modal.msgError('请选择一个学生');
|
||||
return;
|
||||
}
|
||||
this.$refs["formRef"].open(id, this.studentId);
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const that = this;
|
||||
async handleDelete(row) {
|
||||
const id = row.id;
|
||||
await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?');
|
||||
try {
|
||||
const id = row.id;
|
||||
this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?').then(()=>{
|
||||
return StudentApi.deleteStudentContact(id);
|
||||
}).then(() => {
|
||||
that.getList();
|
||||
that.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
await StudentApi.deleteStudentContact(id);
|
||||
await this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
} catch {}
|
||||
},
|
||||
}
|
||||
|
@ -43,7 +43,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as StudentApi from '@/api/infra/demo'
|
||||
import * as StudentApi from '@/api/infra/demo';
|
||||
import ImageUpload from '@/components/ImageUpload';
|
||||
import FileUpload from '@/components/FileUpload';
|
||||
import Editor from '@/components/Editor';
|
||||
@ -89,18 +89,16 @@
|
||||
},
|
||||
methods: {
|
||||
/** 打开弹窗 */
|
||||
open(id) {
|
||||
async open(id) {
|
||||
this.dialogVisible = true;
|
||||
this.reset();
|
||||
const that = this;
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
this.formLoading = true;
|
||||
try {
|
||||
StudentApi.getStudent(id).then(res=>{
|
||||
that.formData = res.data;
|
||||
that.title = "修改学生";
|
||||
})
|
||||
const res = await StudentApi.getStudent(id);
|
||||
this.formData = res.data;
|
||||
this.title = "修改学生";
|
||||
} finally {
|
||||
this.formLoading = false;
|
||||
}
|
||||
@ -108,41 +106,28 @@
|
||||
this.title = "新增学生";
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.formLoading = true;
|
||||
async submitForm() {
|
||||
// 校验主表
|
||||
await this.$refs["formRef"].validate();
|
||||
this.formLoading = true;
|
||||
try {
|
||||
const that = this;
|
||||
let data = this.formData;
|
||||
let validate = false;
|
||||
// 校验主表
|
||||
this.getRef("formRef").validate(valid => {
|
||||
validate = valid;
|
||||
});
|
||||
// 所有表单校验通过后方可提交
|
||||
if (!validate) {
|
||||
return;
|
||||
}
|
||||
// 修改的提交
|
||||
const data = this.formData;
|
||||
// 修改的提交
|
||||
if (data.id) {
|
||||
StudentApi.updateStudent(data).then(response => {
|
||||
that.$modal.msgSuccess("修改成功");
|
||||
that.dialogVisible = false;
|
||||
that.$emit('success');
|
||||
});
|
||||
await StudentApi.updateStudent(data);
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
return;
|
||||
}
|
||||
// 添加的提交
|
||||
StudentApi.createStudent(data).then(response => {
|
||||
that.$modal.msgSuccess("新增成功");
|
||||
that.dialogVisible = false;
|
||||
that.$emit('success');
|
||||
});
|
||||
}finally {
|
||||
await StudentApi.createStudent(data);
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
} finally {
|
||||
this.formLoading = false;
|
||||
}
|
||||
},
|
||||
getRef(refName){
|
||||
return this.$refs[refName];
|
||||
},
|
||||
/** 表单重置 */
|
||||
reset() {
|
||||
@ -158,7 +143,7 @@
|
||||
memo: undefined,
|
||||
};
|
||||
this.resetForm("formRef");
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -43,7 +43,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as StudentApi from '@/api/infra/demo'
|
||||
import * as StudentApi from '@/api/infra/demo';
|
||||
import ImageUpload from '@/components/ImageUpload';
|
||||
import FileUpload from '@/components/FileUpload';
|
||||
import Editor from '@/components/Editor';
|
||||
@ -90,19 +90,17 @@
|
||||
},
|
||||
methods: {
|
||||
/** 打开弹窗 */
|
||||
open(id, studentId) {
|
||||
async open(id, studentId) {
|
||||
this.dialogVisible = true;
|
||||
this.reset();
|
||||
const that = this;
|
||||
this.formData.studentId = studentId;
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
this.formLoading = true;
|
||||
try {
|
||||
StudentApi.getStudentTeacher(id).then(res=>{
|
||||
that.formData = res.data;
|
||||
that.dialogTitle = "修改学生班主任";
|
||||
})
|
||||
const res = await StudentApi.getStudentTeacher(id);
|
||||
this.formData = res.data;
|
||||
this.dialogTitle = "修改学生班主任";
|
||||
} finally {
|
||||
this.formLoading = false;
|
||||
}
|
||||
@ -110,32 +108,26 @@
|
||||
this.dialogTitle = "新增学生班主任";
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
async submitForm() {
|
||||
await this.$refs["formRef"].validate();
|
||||
this.formLoading = true;
|
||||
try {
|
||||
let data = this.formData;
|
||||
this.$refs["formRef"].validate(valid => {
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
const data = this.formData;
|
||||
// 修改的提交
|
||||
if (data.id) {
|
||||
StudentApi.updateStudentTeacher(data).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
});
|
||||
await StudentApi.updateStudentTeacher(data);
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
return;
|
||||
}
|
||||
// 添加的提交
|
||||
StudentApi.createStudentTeacher(data).then(response => {
|
||||
await StudentApi.createStudentTeacher(data);
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
});
|
||||
});
|
||||
}finally {
|
||||
this.formLoading = false
|
||||
this.formLoading = false;
|
||||
}
|
||||
},
|
||||
/** 表单重置 */
|
||||
|
@ -52,8 +52,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as StudentApi from '@/api/infra/demo'
|
||||
import StudentTeacherForm from './StudentTeacherForm.vue'
|
||||
import * as StudentApi from '@/api/infra/demo';
|
||||
import StudentTeacherForm from './StudentTeacherForm.vue';
|
||||
export default {
|
||||
name: "StudentTeacherList",
|
||||
components: {
|
||||
@ -91,14 +91,12 @@
|
||||
},
|
||||
methods: {
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
async getList() {
|
||||
try {
|
||||
this.loading = true;
|
||||
const that = this;
|
||||
StudentApi.getStudentTeacherPage(this.queryParams).then(response => {
|
||||
that.list = response.data.list;
|
||||
that.total = response.data.total;
|
||||
});
|
||||
const res = await StudentApi.getStudentTeacherPage(this.queryParams);
|
||||
this.list = res.data.list;
|
||||
this.total = res.data.total;
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
@ -111,22 +109,19 @@
|
||||
/** 添加/修改操作 */
|
||||
openForm(id) {
|
||||
if (!this.studentId) {
|
||||
that.$modal.msgError('请选择一个学生');
|
||||
this.$modal.msgError('请选择一个学生');
|
||||
return;
|
||||
}
|
||||
this.$refs["formRef"].open(id, this.studentId);
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const that = this;
|
||||
async handleDelete(row) {
|
||||
const id = row.id;
|
||||
await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?');
|
||||
try {
|
||||
const id = row.id;
|
||||
this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?').then(()=>{
|
||||
return StudentApi.deleteStudentTeacher(id);
|
||||
}).then(() => {
|
||||
that.getList();
|
||||
that.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
await StudentApi.deleteStudentTeacher(id);
|
||||
await this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
} catch {}
|
||||
},
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="名字" prop="name">
|
||||
@ -45,12 +44,12 @@
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="list"
|
||||
:stripe="true"
|
||||
:highlight-current-row="true"
|
||||
:show-overflow-tooltip="true"
|
||||
@current-change="handleCurrentChange"
|
||||
v-loading="loading"
|
||||
:data="list"
|
||||
:stripe="true"
|
||||
:highlight-current-row="true"
|
||||
:show-overflow-tooltip="true"
|
||||
@current-change="handleCurrentChange"
|
||||
>
|
||||
<el-table-column label="编号" align="center" prop="id">
|
||||
<template v-slot="scope">
|
||||
@ -131,8 +130,8 @@
|
||||
<script>
|
||||
import * as StudentApi from '@/api/infra/demo';
|
||||
import StudentForm from './StudentForm.vue';
|
||||
import StudentContactList from './components/StudentContactList.vue'
|
||||
import StudentTeacherList from './components/StudentTeacherList.vue'
|
||||
import StudentContactList from './components/StudentContactList.vue';
|
||||
import StudentTeacherList from './components/StudentTeacherList.vue';
|
||||
export default {
|
||||
name: "Student",
|
||||
components: {
|
||||
@ -177,13 +176,12 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
async getList() {
|
||||
try {
|
||||
this.loading = true;
|
||||
StudentApi.getStudentPage(this.queryParams).then(response => {
|
||||
this.list = response.data.list;
|
||||
this.total = response.data.total;
|
||||
});
|
||||
const res = await StudentApi.getStudentPage(this.queryParams);
|
||||
this.list = res.data.list;
|
||||
this.total = res.data.total;
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
@ -203,31 +201,25 @@ export default {
|
||||
this.$refs["formRef"].open(id);
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const that = this;
|
||||
try {
|
||||
async handleDelete(row) {
|
||||
const id = row.id;
|
||||
this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?').then(()=>{
|
||||
return StudentApi.deleteStudent(id);
|
||||
}).then(() => {
|
||||
that.getList();
|
||||
that.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?')
|
||||
try {
|
||||
await StudentApi.deleteStudent(id);
|
||||
await this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
} catch {}
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
const that = this;
|
||||
async handleExport() {
|
||||
await this.$modal.confirm('是否确认导出所有学生数据项?');
|
||||
try {
|
||||
this.$modal.confirm('是否确认导出所有学生数据项?').then(() => {
|
||||
that.exportLoading = true;
|
||||
return StudentApi.exportStudentExcel(params);
|
||||
}).then(response => {
|
||||
that.$download.excel(response, '学生.xls');
|
||||
});
|
||||
this.exportLoading = true;
|
||||
const res = await StudentApi.exportStudentExcel(this.queryParams);
|
||||
this.$download.excel(res.data, '学生.xls');
|
||||
} catch {
|
||||
} finally {
|
||||
that.exportLoading = false;
|
||||
this.exportLoading = false;
|
||||
}
|
||||
},
|
||||
/** 选中行操作 */
|
||||
|
@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
v-loading="formLoading"
|
||||
label-width="0px"
|
||||
:inline-message="true"
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
v-loading="formLoading"
|
||||
label-width="0px"
|
||||
:inline-message="true"
|
||||
>
|
||||
<el-table :data="formData" class="-mt-10px">
|
||||
<el-table-column label="序号" type="index" width="100" />
|
||||
@ -86,7 +86,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as StudentApi from '@/api/infra/demo'
|
||||
import * as StudentApi from '@/api/infra/demo';
|
||||
import ImageUpload from '@/components/ImageUpload';
|
||||
import FileUpload from '@/components/FileUpload';
|
||||
import Editor from '@/components/Editor';
|
||||
@ -130,8 +130,9 @@
|
||||
}
|
||||
try {
|
||||
this.formLoading = true;
|
||||
// 这里还是需要获取一下 this 的不然取不到 formData
|
||||
const that = this;
|
||||
StudentApi.getStudentContactListByStudentId(val).then(res=>{
|
||||
StudentApi.getStudentContactListByStudentId(val).then(function (res){
|
||||
that.formData = res.data;
|
||||
})
|
||||
} finally {
|
||||
@ -156,20 +157,20 @@
|
||||
video: undefined,
|
||||
memo: undefined,
|
||||
}
|
||||
row.studentId = this.studentId
|
||||
this.formData.push(row)
|
||||
row.studentId = this.studentId;
|
||||
this.formData.push(row);
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(index) {
|
||||
this.formData.splice(index, 1)
|
||||
this.formData.splice(index, 1);
|
||||
},
|
||||
/** 表单校验 */
|
||||
validate(){
|
||||
return this.$refs["formRef"].validate()
|
||||
return this.$refs["formRef"].validate();
|
||||
},
|
||||
/** 表单值 */
|
||||
getData(){
|
||||
return this.formData
|
||||
return this.formData;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -40,7 +40,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as StudentApi from '@/api/infra/demo'
|
||||
import * as StudentApi from '@/api/infra/demo';
|
||||
export default {
|
||||
name: "StudentContactList",
|
||||
props:[
|
||||
@ -70,13 +70,11 @@
|
||||
},
|
||||
methods: {
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
async getList() {
|
||||
try {
|
||||
this.loading = true;
|
||||
const that = this;
|
||||
StudentApi.getStudentContactListByStudentId(this.studentId).then(response=>{
|
||||
that.list = response.data;
|
||||
})
|
||||
const res = await StudentApi.getStudentContactListByStudentId(this.studentId);
|
||||
this.list = res.data;
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as StudentApi from '@/api/infra/demo'
|
||||
import * as StudentApi from '@/api/infra/demo';
|
||||
import ImageUpload from '@/components/ImageUpload';
|
||||
import FileUpload from '@/components/FileUpload';
|
||||
import Editor from '@/components/Editor';
|
||||
@ -104,18 +104,16 @@
|
||||
},
|
||||
methods: {
|
||||
/** 打开弹窗 */
|
||||
open(id) {
|
||||
async open(id) {
|
||||
this.dialogVisible = true;
|
||||
this.reset();
|
||||
const that = this;
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
this.formLoading = true;
|
||||
try {
|
||||
StudentApi.getStudent(id).then(res=>{
|
||||
that.formData = res.data;
|
||||
that.title = "修改学生";
|
||||
})
|
||||
const res = await StudentApi.getStudent(id);
|
||||
this.formData = res.data;
|
||||
this.title = "修改学生";
|
||||
} finally {
|
||||
this.formLoading = false;
|
||||
}
|
||||
@ -123,83 +121,44 @@
|
||||
this.title = "新增学生";
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
async submitForm() {
|
||||
// 校验主表
|
||||
await this.$refs["formRef"].validate();
|
||||
// 校验子表
|
||||
try {
|
||||
await this.$refs['studentContactFormRef'].validate();
|
||||
} catch (e) {
|
||||
this.subTabsName = 'studentContact';
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await this.$refs['studentTeacherFormRef'].validate();
|
||||
} catch (e) {
|
||||
this.subTabsName = 'studentTeacher';
|
||||
return;
|
||||
}
|
||||
this.formLoading = true;
|
||||
try {
|
||||
const that = this;
|
||||
let data = this.formData;
|
||||
let validate = false;
|
||||
// 校验主表
|
||||
this.getRef("formRef").validate(valid => {
|
||||
validate = valid;
|
||||
});
|
||||
// 校验子表
|
||||
this.validateSubFrom01().then(() => {
|
||||
// 全部校验通过-拼接子表的数据
|
||||
// 拼接子表的数据
|
||||
data.studentContacts = that.getRef('studentContactFormRef').getData();
|
||||
data.studentTeacher = that.getRef('studentTeacherFormRef').getData();
|
||||
}).catch((err) => {
|
||||
validate = false;
|
||||
that.subTabsName = err.replace("FormRef", ""); // 定位到没有校验通过的子表单
|
||||
})
|
||||
// 所有表单校验通过后方可提交
|
||||
if (!validate) {
|
||||
return;
|
||||
}
|
||||
const data = this.formData;
|
||||
// 拼接子表的数据
|
||||
data.studentContacts = this.$refs['studentContactFormRef'].getData();
|
||||
data.studentTeacher = this.$refs['studentTeacherFormRef'].getData();
|
||||
// 修改的提交
|
||||
if (data.id) {
|
||||
StudentApi.updateStudent(data).then(response => {
|
||||
that.$modal.msgSuccess("修改成功");
|
||||
that.dialogVisible = false;
|
||||
that.$emit('success');
|
||||
});
|
||||
await StudentApi.updateStudent(data);
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
return;
|
||||
}
|
||||
// 添加的提交
|
||||
StudentApi.createStudent(data).then(response => {
|
||||
that.$modal.msgSuccess("新增成功");
|
||||
that.dialogVisible = false;
|
||||
that.$emit('success');
|
||||
});
|
||||
}finally {
|
||||
await StudentApi.createStudent(data);
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
} finally {
|
||||
this.formLoading = false;
|
||||
}
|
||||
},
|
||||
getRef(refName){
|
||||
return this.$refs[refName];
|
||||
},
|
||||
/** 校验子表单 */
|
||||
validateSubFrom(item) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.getRef(item).validate()
|
||||
.then(() => {
|
||||
resolve();
|
||||
})
|
||||
.catch(() => {
|
||||
reject(item);
|
||||
})
|
||||
})
|
||||
},
|
||||
/** 校验所有子表单 */
|
||||
validateSubFrom01() {
|
||||
// 需要校验的表单 ref
|
||||
const validFormRefArr = [
|
||||
"studentContactFormRef",
|
||||
"studentTeacherFormRef",
|
||||
];
|
||||
const validArr = []; // 校验
|
||||
for (const item of validFormRefArr) {
|
||||
validArr.push(this.validateSubFrom(item));
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
// 校验所有
|
||||
Promise.all(validArr).then(() => {
|
||||
resolve();
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
})
|
||||
})
|
||||
},
|
||||
/** 表单重置 */
|
||||
reset() {
|
||||
@ -215,7 +174,7 @@
|
||||
memo: undefined,
|
||||
};
|
||||
this.resetForm("formRef");
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<el-form-item label="名字" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入名字" />
|
||||
@ -42,7 +42,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as StudentApi from '@/api/infra/demo'
|
||||
import * as StudentApi from '@/api/infra/demo';
|
||||
import ImageUpload from '@/components/ImageUpload';
|
||||
import FileUpload from '@/components/FileUpload';
|
||||
import Editor from '@/components/Editor';
|
||||
@ -97,8 +97,9 @@
|
||||
}
|
||||
try {
|
||||
this.formLoading = true;
|
||||
// 这里还是需要获取一下 this 的不然取不到 formData
|
||||
const that = this;
|
||||
StudentApi.getStudentTeacherByStudentId(val).then(res=>{
|
||||
StudentApi.getStudentTeacherByStudentId(val).then(function (res){
|
||||
const data = res.data;
|
||||
if (!data) {
|
||||
return
|
||||
@ -115,11 +116,11 @@
|
||||
methods: {
|
||||
/** 表单校验 */
|
||||
validate(){
|
||||
return this.$refs["formRef"].validate()
|
||||
return this.$refs["formRef"].validate();
|
||||
},
|
||||
/** 表单值 */
|
||||
getData(){
|
||||
return this.formData
|
||||
return this.formData;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -40,7 +40,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as StudentApi from '@/api/infra/demo'
|
||||
import * as StudentApi from '@/api/infra/demo';
|
||||
export default {
|
||||
name: "StudentTeacherList",
|
||||
props:[
|
||||
@ -70,17 +70,15 @@
|
||||
},
|
||||
methods: {
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
async getList() {
|
||||
try {
|
||||
this.loading = true;
|
||||
const that = this;
|
||||
StudentApi.getStudentTeacherByStudentId(this.studentId).then(response=>{
|
||||
const data = response.data;
|
||||
if (!data) {
|
||||
return
|
||||
}
|
||||
that.list.push(data)
|
||||
})
|
||||
const res = await StudentApi.getStudentTeacherByStudentId(this.studentId);
|
||||
const data = res.data;
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
this.list.push(data);
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="名字" prop="name">
|
||||
@ -128,8 +127,8 @@
|
||||
<script>
|
||||
import * as StudentApi from '@/api/infra/demo';
|
||||
import StudentForm from './StudentForm.vue';
|
||||
import StudentContactList from './components/StudentContactList.vue'
|
||||
import StudentTeacherList from './components/StudentTeacherList.vue'
|
||||
import StudentContactList from './components/StudentContactList.vue';
|
||||
import StudentTeacherList from './components/StudentTeacherList.vue';
|
||||
export default {
|
||||
name: "Student",
|
||||
components: {
|
||||
@ -172,13 +171,12 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
async getList() {
|
||||
try {
|
||||
this.loading = true;
|
||||
StudentApi.getStudentPage(this.queryParams).then(response => {
|
||||
this.list = response.data.list;
|
||||
this.total = response.data.total;
|
||||
});
|
||||
const res = await StudentApi.getStudentPage(this.queryParams);
|
||||
this.list = res.data.list;
|
||||
this.total = res.data.total;
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
@ -198,31 +196,25 @@ export default {
|
||||
this.$refs["formRef"].open(id);
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const that = this;
|
||||
try {
|
||||
async handleDelete(row) {
|
||||
const id = row.id;
|
||||
this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?').then(()=>{
|
||||
return StudentApi.deleteStudent(id);
|
||||
}).then(() => {
|
||||
that.getList();
|
||||
that.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?')
|
||||
try {
|
||||
await StudentApi.deleteStudent(id);
|
||||
await this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
} catch {}
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
const that = this;
|
||||
async handleExport() {
|
||||
await this.$modal.confirm('是否确认导出所有学生数据项?');
|
||||
try {
|
||||
this.$modal.confirm('是否确认导出所有学生数据项?').then(() => {
|
||||
that.exportLoading = true;
|
||||
return StudentApi.exportStudentExcel(params);
|
||||
}).then(response => {
|
||||
that.$download.excel(response, '学生.xls');
|
||||
});
|
||||
this.exportLoading = true;
|
||||
const res = await StudentApi.exportStudentExcel(this.queryParams);
|
||||
this.$download.excel(res.data, '学生.xls');
|
||||
} catch {
|
||||
} finally {
|
||||
that.exportLoading = false;
|
||||
this.exportLoading = false;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
v-loading="formLoading"
|
||||
label-width="0px"
|
||||
:inline-message="true"
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
v-loading="formLoading"
|
||||
label-width="0px"
|
||||
:inline-message="true"
|
||||
>
|
||||
<el-table :data="formData" class="-mt-10px">
|
||||
<el-table-column label="序号" type="index" width="100" />
|
||||
@ -86,7 +86,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as StudentApi from '@/api/infra/demo'
|
||||
import * as StudentApi from '@/api/infra/demo';
|
||||
import ImageUpload from '@/components/ImageUpload';
|
||||
import FileUpload from '@/components/FileUpload';
|
||||
import Editor from '@/components/Editor';
|
||||
@ -130,8 +130,9 @@
|
||||
}
|
||||
try {
|
||||
this.formLoading = true;
|
||||
// 这里还是需要获取一下 this 的不然取不到 formData
|
||||
const that = this;
|
||||
StudentApi.getStudentContactListByStudentId(val).then(res=>{
|
||||
StudentApi.getStudentContactListByStudentId(val).then(function (res){
|
||||
that.formData = res.data;
|
||||
})
|
||||
} finally {
|
||||
@ -156,20 +157,20 @@
|
||||
video: undefined,
|
||||
memo: undefined,
|
||||
}
|
||||
row.studentId = this.studentId
|
||||
this.formData.push(row)
|
||||
row.studentId = this.studentId;
|
||||
this.formData.push(row);
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(index) {
|
||||
this.formData.splice(index, 1)
|
||||
this.formData.splice(index, 1);
|
||||
},
|
||||
/** 表单校验 */
|
||||
validate(){
|
||||
return this.$refs["formRef"].validate()
|
||||
return this.$refs["formRef"].validate();
|
||||
},
|
||||
/** 表单值 */
|
||||
getData(){
|
||||
return this.formData
|
||||
return this.formData;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -52,7 +52,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as StudentApi from '@/api/infra/demo'
|
||||
import * as StudentApi from '@/api/infra/demo';
|
||||
import ImageUpload from '@/components/ImageUpload';
|
||||
import FileUpload from '@/components/FileUpload';
|
||||
import Editor from '@/components/Editor';
|
||||
@ -104,18 +104,16 @@
|
||||
},
|
||||
methods: {
|
||||
/** 打开弹窗 */
|
||||
open(id) {
|
||||
async open(id) {
|
||||
this.dialogVisible = true;
|
||||
this.reset();
|
||||
const that = this;
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
this.formLoading = true;
|
||||
try {
|
||||
StudentApi.getStudent(id).then(res=>{
|
||||
that.formData = res.data;
|
||||
that.title = "修改学生";
|
||||
})
|
||||
const res = await StudentApi.getStudent(id);
|
||||
this.formData = res.data;
|
||||
this.title = "修改学生";
|
||||
} finally {
|
||||
this.formLoading = false;
|
||||
}
|
||||
@ -123,83 +121,44 @@
|
||||
this.title = "新增学生";
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
async submitForm() {
|
||||
// 校验主表
|
||||
await this.$refs["formRef"].validate();
|
||||
// 校验子表
|
||||
try {
|
||||
await this.$refs['studentContactFormRef'].validate();
|
||||
} catch (e) {
|
||||
this.subTabsName = 'studentContact';
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await this.$refs['studentTeacherFormRef'].validate();
|
||||
} catch (e) {
|
||||
this.subTabsName = 'studentTeacher';
|
||||
return;
|
||||
}
|
||||
this.formLoading = true;
|
||||
try {
|
||||
const that = this;
|
||||
let data = this.formData;
|
||||
let validate = false;
|
||||
// 校验主表
|
||||
this.getRef("formRef").validate(valid => {
|
||||
validate = valid;
|
||||
});
|
||||
// 校验子表
|
||||
this.validateSubFrom01().then(() => {
|
||||
// 全部校验通过-拼接子表的数据
|
||||
// 拼接子表的数据
|
||||
data.studentContacts = that.getRef('studentContactFormRef').getData();
|
||||
data.studentTeacher = that.getRef('studentTeacherFormRef').getData();
|
||||
}).catch((err) => {
|
||||
validate = false;
|
||||
that.subTabsName = err.replace("FormRef", ""); // 定位到没有校验通过的子表单
|
||||
})
|
||||
// 所有表单校验通过后方可提交
|
||||
if (!validate) {
|
||||
return;
|
||||
}
|
||||
const data = this.formData;
|
||||
// 拼接子表的数据
|
||||
data.studentContacts = this.$refs['studentContactFormRef'].getData();
|
||||
data.studentTeacher = this.$refs['studentTeacherFormRef'].getData();
|
||||
// 修改的提交
|
||||
if (data.id) {
|
||||
StudentApi.updateStudent(data).then(response => {
|
||||
that.$modal.msgSuccess("修改成功");
|
||||
that.dialogVisible = false;
|
||||
that.$emit('success');
|
||||
});
|
||||
await StudentApi.updateStudent(data);
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
return;
|
||||
}
|
||||
// 添加的提交
|
||||
StudentApi.createStudent(data).then(response => {
|
||||
that.$modal.msgSuccess("新增成功");
|
||||
that.dialogVisible = false;
|
||||
that.$emit('success');
|
||||
});
|
||||
}finally {
|
||||
await StudentApi.createStudent(data);
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
} finally {
|
||||
this.formLoading = false;
|
||||
}
|
||||
},
|
||||
getRef(refName){
|
||||
return this.$refs[refName];
|
||||
},
|
||||
/** 校验子表单 */
|
||||
validateSubFrom(item) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.getRef(item).validate()
|
||||
.then(() => {
|
||||
resolve();
|
||||
})
|
||||
.catch(() => {
|
||||
reject(item);
|
||||
})
|
||||
})
|
||||
},
|
||||
/** 校验所有子表单 */
|
||||
validateSubFrom01() {
|
||||
// 需要校验的表单 ref
|
||||
const validFormRefArr = [
|
||||
"studentContactFormRef",
|
||||
"studentTeacherFormRef",
|
||||
];
|
||||
const validArr = []; // 校验
|
||||
for (const item of validFormRefArr) {
|
||||
validArr.push(this.validateSubFrom(item));
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
// 校验所有
|
||||
Promise.all(validArr).then(() => {
|
||||
resolve();
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
})
|
||||
})
|
||||
},
|
||||
/** 表单重置 */
|
||||
reset() {
|
||||
@ -215,7 +174,7 @@
|
||||
memo: undefined,
|
||||
};
|
||||
this.resetForm("formRef");
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<el-form-item label="名字" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入名字" />
|
||||
@ -42,7 +42,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as StudentApi from '@/api/infra/demo'
|
||||
import * as StudentApi from '@/api/infra/demo';
|
||||
import ImageUpload from '@/components/ImageUpload';
|
||||
import FileUpload from '@/components/FileUpload';
|
||||
import Editor from '@/components/Editor';
|
||||
@ -97,8 +97,9 @@
|
||||
}
|
||||
try {
|
||||
this.formLoading = true;
|
||||
// 这里还是需要获取一下 this 的不然取不到 formData
|
||||
const that = this;
|
||||
StudentApi.getStudentTeacherByStudentId(val).then(res=>{
|
||||
StudentApi.getStudentTeacherByStudentId(val).then(function (res){
|
||||
const data = res.data;
|
||||
if (!data) {
|
||||
return
|
||||
@ -115,11 +116,11 @@
|
||||
methods: {
|
||||
/** 表单校验 */
|
||||
validate(){
|
||||
return this.$refs["formRef"].validate()
|
||||
return this.$refs["formRef"].validate();
|
||||
},
|
||||
/** 表单值 */
|
||||
getData(){
|
||||
return this.formData
|
||||
return this.formData;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="名字" prop="name">
|
||||
@ -155,13 +154,12 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
async getList() {
|
||||
try {
|
||||
this.loading = true;
|
||||
StudentApi.getStudentPage(this.queryParams).then(response => {
|
||||
this.list = response.data.list;
|
||||
this.total = response.data.total;
|
||||
});
|
||||
const res = await StudentApi.getStudentPage(this.queryParams);
|
||||
this.list = res.data.list;
|
||||
this.total = res.data.total;
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
@ -181,31 +179,25 @@ export default {
|
||||
this.$refs["formRef"].open(id);
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const that = this;
|
||||
try {
|
||||
async handleDelete(row) {
|
||||
const id = row.id;
|
||||
this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?').then(()=>{
|
||||
return StudentApi.deleteStudent(id);
|
||||
}).then(() => {
|
||||
that.getList();
|
||||
that.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?')
|
||||
try {
|
||||
await StudentApi.deleteStudent(id);
|
||||
await this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
} catch {}
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
const that = this;
|
||||
async handleExport() {
|
||||
await this.$modal.confirm('是否确认导出所有学生数据项?');
|
||||
try {
|
||||
this.$modal.confirm('是否确认导出所有学生数据项?').then(() => {
|
||||
that.exportLoading = true;
|
||||
return StudentApi.exportStudentExcel(params);
|
||||
}).then(response => {
|
||||
that.$download.excel(response, '学生.xls');
|
||||
});
|
||||
this.exportLoading = true;
|
||||
const res = await StudentApi.exportStudentExcel(this.queryParams);
|
||||
this.$download.excel(res.data, '学生.xls');
|
||||
} catch {
|
||||
} finally {
|
||||
that.exportLoading = false;
|
||||
this.exportLoading = false;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@ -43,7 +43,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as StudentApi from '@/api/infra/demo'
|
||||
import * as StudentApi from '@/api/infra/demo';
|
||||
import ImageUpload from '@/components/ImageUpload';
|
||||
import FileUpload from '@/components/FileUpload';
|
||||
import Editor from '@/components/Editor';
|
||||
@ -89,18 +89,16 @@
|
||||
},
|
||||
methods: {
|
||||
/** 打开弹窗 */
|
||||
open(id) {
|
||||
async open(id) {
|
||||
this.dialogVisible = true;
|
||||
this.reset();
|
||||
const that = this;
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
this.formLoading = true;
|
||||
try {
|
||||
StudentApi.getStudent(id).then(res=>{
|
||||
that.formData = res.data;
|
||||
that.title = "修改学生";
|
||||
})
|
||||
const res = await StudentApi.getStudent(id);
|
||||
this.formData = res.data;
|
||||
this.title = "修改学生";
|
||||
} finally {
|
||||
this.formLoading = false;
|
||||
}
|
||||
@ -108,41 +106,28 @@
|
||||
this.title = "新增学生";
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.formLoading = true;
|
||||
async submitForm() {
|
||||
// 校验主表
|
||||
await this.$refs["formRef"].validate();
|
||||
this.formLoading = true;
|
||||
try {
|
||||
const that = this;
|
||||
let data = this.formData;
|
||||
let validate = false;
|
||||
// 校验主表
|
||||
this.getRef("formRef").validate(valid => {
|
||||
validate = valid;
|
||||
});
|
||||
// 所有表单校验通过后方可提交
|
||||
if (!validate) {
|
||||
return;
|
||||
}
|
||||
// 修改的提交
|
||||
const data = this.formData;
|
||||
// 修改的提交
|
||||
if (data.id) {
|
||||
StudentApi.updateStudent(data).then(response => {
|
||||
that.$modal.msgSuccess("修改成功");
|
||||
that.dialogVisible = false;
|
||||
that.$emit('success');
|
||||
});
|
||||
await StudentApi.updateStudent(data);
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
return;
|
||||
}
|
||||
// 添加的提交
|
||||
StudentApi.createStudent(data).then(response => {
|
||||
that.$modal.msgSuccess("新增成功");
|
||||
that.dialogVisible = false;
|
||||
that.$emit('success');
|
||||
});
|
||||
}finally {
|
||||
await StudentApi.createStudent(data);
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
} finally {
|
||||
this.formLoading = false;
|
||||
}
|
||||
},
|
||||
getRef(refName){
|
||||
return this.$refs[refName];
|
||||
},
|
||||
/** 表单重置 */
|
||||
reset() {
|
||||
@ -158,7 +143,7 @@
|
||||
memo: undefined,
|
||||
};
|
||||
this.resetForm("formRef");
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="名字" prop="name">
|
||||
@ -155,13 +154,12 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
async getList() {
|
||||
try {
|
||||
this.loading = true;
|
||||
StudentApi.getStudentPage(this.queryParams).then(response => {
|
||||
this.list = response.data.list;
|
||||
this.total = response.data.total;
|
||||
});
|
||||
const res = await StudentApi.getStudentPage(this.queryParams);
|
||||
this.list = res.data.list;
|
||||
this.total = res.data.total;
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
@ -181,31 +179,25 @@ export default {
|
||||
this.$refs["formRef"].open(id);
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const that = this;
|
||||
try {
|
||||
async handleDelete(row) {
|
||||
const id = row.id;
|
||||
this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?').then(()=>{
|
||||
return StudentApi.deleteStudent(id);
|
||||
}).then(() => {
|
||||
that.getList();
|
||||
that.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?')
|
||||
try {
|
||||
await StudentApi.deleteStudent(id);
|
||||
await this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
} catch {}
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
const that = this;
|
||||
async handleExport() {
|
||||
await this.$modal.confirm('是否确认导出所有学生数据项?');
|
||||
try {
|
||||
this.$modal.confirm('是否确认导出所有学生数据项?').then(() => {
|
||||
that.exportLoading = true;
|
||||
return StudentApi.exportStudentExcel(params);
|
||||
}).then(response => {
|
||||
that.$download.excel(response, '学生.xls');
|
||||
});
|
||||
this.exportLoading = true;
|
||||
const res = await StudentApi.exportStudentExcel(this.queryParams);
|
||||
this.$download.excel(res.data, '学生.xls');
|
||||
} catch {
|
||||
} finally {
|
||||
that.exportLoading = false;
|
||||
this.exportLoading = false;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@ -8,10 +8,10 @@
|
||||
</el-form-item>
|
||||
<el-form-item label="父编号" prop="parentId">
|
||||
<TreeSelect
|
||||
v-model="formData.parentId"
|
||||
:options="categoryTree"
|
||||
:normalizer="normalizer"
|
||||
placeholder="请选择父编号"
|
||||
v-model="formData.parentId"
|
||||
:options="categoryTree"
|
||||
:normalizer="normalizer"
|
||||
placeholder="请选择父编号"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@ -24,7 +24,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as CategoryApi from '@/api/infra/demo'
|
||||
import * as CategoryApi from '@/api/infra/demo';
|
||||
import TreeSelect from "@riophae/vue-treeselect";
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
export default {
|
||||
@ -56,71 +56,54 @@
|
||||
},
|
||||
methods: {
|
||||
/** 打开弹窗 */
|
||||
open(id) {
|
||||
async open(id) {
|
||||
this.dialogVisible = true;
|
||||
this.reset();
|
||||
const that = this;
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
this.formLoading = true;
|
||||
try {
|
||||
CategoryApi.getCategory(id).then(res=>{
|
||||
that.formData = res.data;
|
||||
that.title = "修改分类";
|
||||
})
|
||||
const res = await CategoryApi.getCategory(id);
|
||||
this.formData = res.data;
|
||||
this.title = "修改分类";
|
||||
} finally {
|
||||
this.formLoading = false;
|
||||
}
|
||||
}
|
||||
this.title = "新增分类";
|
||||
this.getCategoryTree();
|
||||
await this.getCategoryTree();
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.formLoading = true;
|
||||
async submitForm() {
|
||||
// 校验主表
|
||||
await this.$refs["formRef"].validate();
|
||||
this.formLoading = true;
|
||||
try {
|
||||
const that = this;
|
||||
let data = this.formData;
|
||||
let validate = false;
|
||||
// 校验主表
|
||||
this.getRef("formRef").validate(valid => {
|
||||
validate = valid;
|
||||
});
|
||||
// 所有表单校验通过后方可提交
|
||||
if (!validate) {
|
||||
return;
|
||||
}
|
||||
// 修改的提交
|
||||
const data = this.formData;
|
||||
// 修改的提交
|
||||
if (data.id) {
|
||||
CategoryApi.updateCategory(data).then(response => {
|
||||
that.$modal.msgSuccess("修改成功");
|
||||
that.dialogVisible = false;
|
||||
that.$emit('success');
|
||||
});
|
||||
await CategoryApi.updateCategory(data);
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
return;
|
||||
}
|
||||
// 添加的提交
|
||||
CategoryApi.createCategory(data).then(response => {
|
||||
that.$modal.msgSuccess("新增成功");
|
||||
that.dialogVisible = false;
|
||||
that.$emit('success');
|
||||
});
|
||||
}finally {
|
||||
await CategoryApi.createCategory(data);
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
} finally {
|
||||
this.formLoading = false;
|
||||
}
|
||||
},
|
||||
getRef(refName){
|
||||
return this.$refs[refName];
|
||||
},
|
||||
/** 获得分类树 */
|
||||
getCategoryTree() {
|
||||
const that = this;
|
||||
that.categoryTree = [];
|
||||
CategoryApi.getCategoryList().then(res=>{
|
||||
const root = { id: 0, name: '顶级分类', children: [] };
|
||||
root.children = this.handleTree(res.data, 'id', 'parentId')
|
||||
that.categoryTree.push(root)
|
||||
});
|
||||
async getCategoryTree() {
|
||||
this.categoryTree = [];
|
||||
const res = await CategoryApi.getCategoryList();
|
||||
const root = { id: 0, name: '顶级分类', children: [] };
|
||||
root.children = this.handleTree(res.data, 'id', 'parentId')
|
||||
this.categoryTree.push(root)
|
||||
},
|
||||
/** 转换分类数据结构 */
|
||||
normalizer(node) {
|
||||
@ -141,7 +124,7 @@
|
||||
parentId: undefined,
|
||||
};
|
||||
this.resetForm("formRef");
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="名字" prop="name">
|
||||
@ -31,14 +30,14 @@
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="list"
|
||||
:stripe="true"
|
||||
:show-overflow-tooltip="true"
|
||||
v-if="refreshTable"
|
||||
row-key="id"
|
||||
:default-expand-all="isExpandAll"
|
||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||
v-loading="loading"
|
||||
:data="list"
|
||||
:stripe="true"
|
||||
:show-overflow-tooltip="true"
|
||||
v-if="refreshTable"
|
||||
row-key="id"
|
||||
:default-expand-all="isExpandAll"
|
||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||
>
|
||||
<el-table-column label="编号" align="center" prop="id">
|
||||
<template v-slot="scope">
|
||||
@ -104,12 +103,11 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
async getList() {
|
||||
try {
|
||||
this.loading = true;
|
||||
CategoryApi.getCategoryList(this.queryParams).then(response => {
|
||||
this.list = this.handleTree(response.data, 'id', 'parentId');
|
||||
})
|
||||
const res = await CategoryApi.getCategoryList(this.queryParams);
|
||||
this.list = this.handleTree(res.data, 'id', 'parentId');
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
@ -129,31 +127,25 @@ export default {
|
||||
this.$refs["formRef"].open(id);
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const that = this;
|
||||
try {
|
||||
async handleDelete(row) {
|
||||
const id = row.id;
|
||||
this.$modal.confirm('是否确认删除分类编号为"' + id + '"的数据项?').then(()=>{
|
||||
return CategoryApi.deleteCategory(id);
|
||||
}).then(() => {
|
||||
that.getList();
|
||||
that.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
await this.$modal.confirm('是否确认删除分类编号为"' + id + '"的数据项?')
|
||||
try {
|
||||
await CategoryApi.deleteCategory(id);
|
||||
await this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
} catch {}
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
const that = this;
|
||||
async handleExport() {
|
||||
await this.$modal.confirm('是否确认导出所有分类数据项?');
|
||||
try {
|
||||
this.$modal.confirm('是否确认导出所有分类数据项?').then(() => {
|
||||
that.exportLoading = true;
|
||||
return CategoryApi.exportCategoryExcel(params);
|
||||
}).then(response => {
|
||||
that.$download.excel(response, '分类.xls');
|
||||
});
|
||||
this.exportLoading = true;
|
||||
const res = await CategoryApi.exportCategoryExcel(this.queryParams);
|
||||
this.$download.excel(res.data, '分类.xls');
|
||||
} catch {
|
||||
} finally {
|
||||
that.exportLoading = false;
|
||||
this.exportLoading = false;
|
||||
}
|
||||
},
|
||||
/** 展开/折叠操作 */
|
||||
|
Loading…
Reference in New Issue
Block a user