|
@@ -96,50 +96,67 @@
|
|
|
</el-form>
|
|
|
|
|
|
<el-tree
|
|
|
- :data="data"
|
|
|
+ :data="treeData"
|
|
|
node-key="id"
|
|
|
:props="defaultProps"
|
|
|
:default-expanded-keys="ids"
|
|
|
@node-click="handleNodeClick"
|
|
|
- ></el-tree>
|
|
|
+ ><span slot-scope="{ data }" class="custom-tree-node">
|
|
|
+ <span>{{ data.name }}({{ data.code }})</span>
|
|
|
+ </span></el-tree
|
|
|
+ >
|
|
|
</div>
|
|
|
- <el-dialog :title="title" :visible.sync="propertyDialog">
|
|
|
- <el-form :model="propertyForm">
|
|
|
- <el-row v-show="parentName">
|
|
|
- <el-form-item label="一级名称">
|
|
|
+ <el-dialog
|
|
|
+ :title="title"
|
|
|
+ :visible.sync="propertyDialog"
|
|
|
+ @close="closeModel"
|
|
|
+ >
|
|
|
+ <el-form
|
|
|
+ ref="propertyForm"
|
|
|
+ :model="propertyForm"
|
|
|
+ :inline="true"
|
|
|
+ :rules="rules"
|
|
|
+ :inline-message="true"
|
|
|
+ >
|
|
|
+ <el-row>
|
|
|
+ <el-form-item label="编号" label-width="100px" prop="code">
|
|
|
+ <el-input
|
|
|
+ v-model="propertyForm.code"
|
|
|
+ auto-complete="off"
|
|
|
+ style="width: 220px"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-row>
|
|
|
+ <el-row v-if="isFirstLev()">
|
|
|
+ <el-form-item label="一级名称" label-width="100px" prop="name">
|
|
|
<el-input
|
|
|
- v-model="propertyForm.parentName"
|
|
|
+ v-model="propertyForm.name"
|
|
|
auto-complete="off"
|
|
|
style="width: 220px"
|
|
|
- @change="showTitle"
|
|
|
></el-input>
|
|
|
- <span v-show="showParentName" style="color: red">请输一级名称</span>
|
|
|
</el-form-item>
|
|
|
</el-row>
|
|
|
- <el-row v-show="sonName">
|
|
|
- <el-form-item label="二级名称">
|
|
|
+ <el-row v-if="isSecondLev()">
|
|
|
+ <el-form-item label="二级名称" label-width="100px" prop="name">
|
|
|
<el-input
|
|
|
- v-model="propertyForm.sonName"
|
|
|
+ v-model="propertyForm.name"
|
|
|
auto-complete="off"
|
|
|
style="width: 220px"
|
|
|
- @change="showTitle"
|
|
|
></el-input>
|
|
|
- <span v-show="showSonName" style="color: red">请输二级名称</span>
|
|
|
</el-form-item>
|
|
|
</el-row>
|
|
|
<el-row>
|
|
|
- <el-form-item label="名称备注">
|
|
|
+ <el-form-item label="名称备注" label-width="100px">
|
|
|
<el-input
|
|
|
v-model="propertyForm.remark"
|
|
|
auto-complete="off"
|
|
|
style="width: 220px"
|
|
|
- @change="showTitle"
|
|
|
></el-input>
|
|
|
</el-form-item>
|
|
|
</el-row>
|
|
|
</el-form>
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="propertyDialog = false">取 消</el-button>
|
|
|
+ <el-button @click="closeModel">取 消</el-button>
|
|
|
<el-button type="primary" @click="submit">确 定</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
@@ -160,16 +177,19 @@ export default {
|
|
|
courseList: [],
|
|
|
ids: [],
|
|
|
loading: false,
|
|
|
- parentName: false,
|
|
|
- sonName: false,
|
|
|
propertyDialog: false,
|
|
|
propertyForm: {
|
|
|
- parentName: "",
|
|
|
- sonName: "",
|
|
|
+ id: "",
|
|
|
+ code: "",
|
|
|
+ name: "",
|
|
|
+ parentId: "",
|
|
|
+ number: "",
|
|
|
+ coursePropertyId: "",
|
|
|
remark: "",
|
|
|
},
|
|
|
- property: {
|
|
|
+ curProperty: {
|
|
|
id: "",
|
|
|
+ code: "",
|
|
|
name: "",
|
|
|
parentId: "",
|
|
|
number: "",
|
|
@@ -178,15 +198,28 @@ export default {
|
|
|
},
|
|
|
showButton: true,
|
|
|
showSonButtton: true,
|
|
|
- showParentName: false,
|
|
|
- showSonName: false,
|
|
|
- data: [],
|
|
|
+ showMoveButtton: true,
|
|
|
+ treeData: [],
|
|
|
defaultProps: {
|
|
|
children: "propertyList",
|
|
|
- label: "name",
|
|
|
},
|
|
|
title: "新增属性",
|
|
|
- showMoveButtton: true,
|
|
|
+ rules: {
|
|
|
+ code: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请输入编码",
|
|
|
+ trigger: "blur",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ name: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请输入名称",
|
|
|
+ trigger: "blur",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -208,25 +241,40 @@ export default {
|
|
|
this.searchProperty();
|
|
|
},
|
|
|
methods: {
|
|
|
+ disAllBtn() {
|
|
|
+ this.showButton = true;
|
|
|
+ this.showSonButtton = true;
|
|
|
+ this.showMoveButtton = true;
|
|
|
+ },
|
|
|
+ isFirstLev() {
|
|
|
+ if (this.propertyForm.parentId == "0") {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ isSecondLev() {
|
|
|
+ if (this.propertyForm.parentId && this.propertyForm.parentId != "0") {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ closeModel() {
|
|
|
+ this.propertyDialog = false;
|
|
|
+ this.$refs.propertyForm.resetFields();
|
|
|
+ },
|
|
|
//树形节点选中
|
|
|
handleNodeClick(object) {
|
|
|
- //得到选中的节点
|
|
|
- console.log(object);
|
|
|
this.showButton = false;
|
|
|
//判断选中节点,如果是父节点,可以新增二级
|
|
|
if (object.parentId == "0") {
|
|
|
this.showSonButtton = false;
|
|
|
- this.showMoveButtton = false;
|
|
|
} else {
|
|
|
this.showSonButtton = true;
|
|
|
- this.showMoveButtton = true;
|
|
|
}
|
|
|
- this.property.id = object.id;
|
|
|
- this.property.name = object.name;
|
|
|
- this.property.parentId = object.parentId;
|
|
|
- this.property.number = object.number;
|
|
|
- this.property.coursePropertyId = object.coursePropertyId;
|
|
|
- this.property.remark = object.remark;
|
|
|
+ this.showMoveButtton = false;
|
|
|
+ this.curProperty = Object.assign({}, object);
|
|
|
},
|
|
|
//查询所有课程
|
|
|
getCourses(query) {
|
|
@@ -252,9 +300,9 @@ export default {
|
|
|
this.$http
|
|
|
.get(QUESTION_API + "/property/all/" + this.coursePropertyId)
|
|
|
.then((response) => {
|
|
|
- this.data = response.data;
|
|
|
- for (var i = 0; i < this.data.length; i++) {
|
|
|
- var property = this.data[i];
|
|
|
+ this.treeData = response.data;
|
|
|
+ for (var i = 0; i < this.treeData.length; i++) {
|
|
|
+ var property = this.treeData[i];
|
|
|
this.ids.push(property.id);
|
|
|
}
|
|
|
this.loading = false;
|
|
@@ -262,113 +310,70 @@ export default {
|
|
|
},
|
|
|
//新增一级
|
|
|
insertParent() {
|
|
|
+ this.disAllBtn();
|
|
|
this.title = "新增属性";
|
|
|
- this.showParentName = false;
|
|
|
- this.property = {
|
|
|
+ this.propertyForm = {
|
|
|
id: "",
|
|
|
+ code: "",
|
|
|
name: "",
|
|
|
parentId: "0",
|
|
|
number: "",
|
|
|
coursePropertyId: this.coursePropertyId,
|
|
|
remark: "",
|
|
|
};
|
|
|
- this.propertyForm.parentName = "";
|
|
|
- this.propertyForm.remark = "";
|
|
|
- this.sonName = false;
|
|
|
- this.parentName = true;
|
|
|
this.propertyDialog = true;
|
|
|
},
|
|
|
//新增二级
|
|
|
insertSon() {
|
|
|
+ this.disAllBtn();
|
|
|
this.title = "新增属性";
|
|
|
- this.showSonName = false;
|
|
|
//父对象id赋值
|
|
|
- this.property.parentId = this.property.id;
|
|
|
- this.property.id = "";
|
|
|
- this.property.name = "";
|
|
|
- this.property.remark = "";
|
|
|
- this.property.coursePropertyId = this.coursePropertyId;
|
|
|
- this.propertyForm.sonName = "";
|
|
|
- this.propertyForm.remark = "";
|
|
|
- this.parentName = false;
|
|
|
- this.sonName = true;
|
|
|
+ this.propertyForm = {
|
|
|
+ id: "",
|
|
|
+ code: "",
|
|
|
+ name: "",
|
|
|
+ parentId: this.curProperty.id,
|
|
|
+ number: "",
|
|
|
+ coursePropertyId: this.coursePropertyId,
|
|
|
+ remark: "",
|
|
|
+ };
|
|
|
this.propertyDialog = true;
|
|
|
},
|
|
|
//修改
|
|
|
updateProperty() {
|
|
|
+ this.disAllBtn();
|
|
|
this.title = "修改属性";
|
|
|
- //判断是父节点还是子节点
|
|
|
- if (this.property.parentId == "0") {
|
|
|
- this.propertyForm.parentName = this.property.name;
|
|
|
- this.propertyForm.remark = this.property.remark;
|
|
|
- this.sonName = false;
|
|
|
- this.parentName = true;
|
|
|
- } else {
|
|
|
- this.propertyForm.sonName = this.property.name;
|
|
|
- this.propertyForm.remark = this.property.remark;
|
|
|
- this.parentName = false;
|
|
|
- this.sonName = true;
|
|
|
- }
|
|
|
+ this.propertyForm = Object.assign({}, this.curProperty);
|
|
|
this.propertyDialog = true;
|
|
|
},
|
|
|
//保存
|
|
|
- submit() {
|
|
|
- if (this.property.parentId == "0") {
|
|
|
- //非空判断
|
|
|
- if (!this.propertyForm.parentName) {
|
|
|
- this.showParentName = true;
|
|
|
- return 0;
|
|
|
- }
|
|
|
- this.property.name = this.propertyForm.parentName;
|
|
|
- } else {
|
|
|
- //非空判断
|
|
|
- if (!this.propertyForm.sonName) {
|
|
|
- this.showSonName = true;
|
|
|
- return 0;
|
|
|
- }
|
|
|
- this.property.name = this.propertyForm.sonName;
|
|
|
+ async submit() {
|
|
|
+ const res = await this.$refs.propertyForm.validate();
|
|
|
+ if (res === false) {
|
|
|
+ return;
|
|
|
}
|
|
|
- this.property.remark = this.propertyForm.remark;
|
|
|
- if (this.property.id) {
|
|
|
- this.$http
|
|
|
- .put(QUESTION_API + "/property/save", this.property)
|
|
|
- .then(() => {
|
|
|
- this.$notify({
|
|
|
- message: "修改成功",
|
|
|
- type: "success",
|
|
|
- });
|
|
|
- this.propertyDialog = false;
|
|
|
- this.searchProperty();
|
|
|
- })
|
|
|
- .catch((error) => {
|
|
|
- this.$notify({
|
|
|
- type: "error",
|
|
|
- message: error.response.data.desc,
|
|
|
- });
|
|
|
+ this.$http
|
|
|
+ .post(QUESTION_API + "/property/save", this.propertyForm)
|
|
|
+ .then(() => {
|
|
|
+ this.$notify({
|
|
|
+ message: this.propertyForm.id ? "修改成功" : "新增成功",
|
|
|
+ type: "success",
|
|
|
});
|
|
|
- } else {
|
|
|
- this.$http
|
|
|
- .post(QUESTION_API + "/property/save", this.property)
|
|
|
- .then(() => {
|
|
|
- this.$notify({
|
|
|
- message: "新增成功",
|
|
|
- type: "success",
|
|
|
- });
|
|
|
- this.propertyDialog = false;
|
|
|
- this.searchProperty();
|
|
|
- })
|
|
|
- .catch((error) => {
|
|
|
- this.$notify({
|
|
|
- type: "error",
|
|
|
- message: error.response.data.desc,
|
|
|
- });
|
|
|
+ this.propertyDialog = false;
|
|
|
+ this.searchProperty();
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ this.$notify({
|
|
|
+ type: "error",
|
|
|
+ message: error.response.data.desc,
|
|
|
});
|
|
|
- }
|
|
|
+ });
|
|
|
this.showButton = true;
|
|
|
this.showSonButtton = true;
|
|
|
},
|
|
|
//删除
|
|
|
deleteProperty() {
|
|
|
+ this.disAllBtn();
|
|
|
this.$confirm("确认删除属性吗?", "提示", {
|
|
|
type: "warning",
|
|
|
}).then(() => {
|
|
@@ -377,9 +382,9 @@ export default {
|
|
|
.delete(
|
|
|
QUESTION_API +
|
|
|
"/property/delete/" +
|
|
|
- this.property.id +
|
|
|
+ this.curProperty.id +
|
|
|
"/" +
|
|
|
- this.property.coursePropertyId
|
|
|
+ this.curProperty.coursePropertyId
|
|
|
)
|
|
|
.then(() => {
|
|
|
this.$notify({
|
|
@@ -388,31 +393,16 @@ export default {
|
|
|
});
|
|
|
this.searchProperty();
|
|
|
})
|
|
|
- .catch(() => {
|
|
|
+ .catch((error) => {
|
|
|
this.$notify({
|
|
|
type: "error",
|
|
|
- message: "删除失败",
|
|
|
+ message: error.response.data.desc,
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
this.showButton = true;
|
|
|
this.showSonButtton = true;
|
|
|
},
|
|
|
- //效验
|
|
|
- showTitle() {
|
|
|
- if (this.propertyForm.parentName) {
|
|
|
- this.showParentName = false;
|
|
|
- }
|
|
|
- if (!this.propertyForm.parentName) {
|
|
|
- this.showParentName = true;
|
|
|
- }
|
|
|
- if (this.propertyForm.sonName) {
|
|
|
- this.showSonName = false;
|
|
|
- }
|
|
|
- if (!this.propertyForm.sonName) {
|
|
|
- this.showSonName = true;
|
|
|
- }
|
|
|
- },
|
|
|
//返回
|
|
|
back() {
|
|
|
this.$router.push({
|
|
@@ -421,32 +411,34 @@ export default {
|
|
|
},
|
|
|
//上移
|
|
|
moveUp() {
|
|
|
+ this.disAllBtn();
|
|
|
this.$http
|
|
|
- .put(QUESTION_API + "/property/moveUp", this.property)
|
|
|
+ .put(QUESTION_API + "/property/moveUp", this.curProperty)
|
|
|
.then(() => {
|
|
|
this.searchProperty();
|
|
|
this.showMoveButtton = true;
|
|
|
})
|
|
|
- .catch(() => {
|
|
|
+ .catch((error) => {
|
|
|
this.$notify({
|
|
|
type: "error",
|
|
|
- message: "无法上移",
|
|
|
+ message: error.response.data.desc,
|
|
|
});
|
|
|
this.showMoveButtton = true;
|
|
|
});
|
|
|
},
|
|
|
//下移
|
|
|
moveDown() {
|
|
|
+ this.disAllBtn();
|
|
|
this.$http
|
|
|
- .put(QUESTION_API + "/property/moveDown", this.property)
|
|
|
+ .put(QUESTION_API + "/property/moveDown", this.curProperty)
|
|
|
.then(() => {
|
|
|
this.searchProperty();
|
|
|
this.showMoveButtton = true;
|
|
|
})
|
|
|
- .catch(() => {
|
|
|
+ .catch((error) => {
|
|
|
this.$notify({
|
|
|
type: "error",
|
|
|
- message: "无法下移",
|
|
|
+ message: error.response.data.desc,
|
|
|
});
|
|
|
this.showMoveButtton = true;
|
|
|
});
|