|
|
@@ -32,6 +32,7 @@
|
|
|
import { ACTION_ADD, ACTION_UPDATE } from '@/utils/actionType'
|
|
|
import { getPositionById, createPosition, updatePosition } from '@/api/system/positionApi'
|
|
|
export default {
|
|
|
+ name: 'Position',
|
|
|
props: {
|
|
|
title: {
|
|
|
type: String,
|
|
|
@@ -58,23 +59,21 @@ export default {
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
- // Show Add Model
|
|
|
+ // 新增
|
|
|
showAddModel() {
|
|
|
this.actionType = ACTION_ADD
|
|
|
this.resetFormData()
|
|
|
this.dialogVisible = true
|
|
|
},
|
|
|
|
|
|
- // Show Edit Model
|
|
|
+ // 编辑
|
|
|
showEditModel(id) {
|
|
|
this.actionType = ACTION_UPDATE
|
|
|
this.resetFormData()
|
|
|
this.dialogVisible = true
|
|
|
getPositionById(id).then((resp) => {
|
|
|
- const { code, data } = resp
|
|
|
- if (code === 200) {
|
|
|
- this.formData = data
|
|
|
- }
|
|
|
+ const { data } = resp
|
|
|
+ this.formData = data
|
|
|
}).catch((error) => {
|
|
|
console.log(error)
|
|
|
})
|
|
|
@@ -107,14 +106,10 @@ export default {
|
|
|
switch (actionType) {
|
|
|
case ACTION_ADD:
|
|
|
createPosition(this.formData).then((resp) => {
|
|
|
- const { code, msg } = resp
|
|
|
- if (code === 200) {
|
|
|
- this.dialogVisible = false
|
|
|
- this.$message.success(msg)
|
|
|
- this.formSuccess()
|
|
|
- } else {
|
|
|
- this.$message.error(msg)
|
|
|
- }
|
|
|
+ const { msg } = resp
|
|
|
+ this.dialogVisible = false
|
|
|
+ this.$message.success(msg)
|
|
|
+ this.formSuccess()
|
|
|
}).catch((error) => {
|
|
|
console.log(error)
|
|
|
})
|
|
|
@@ -122,14 +117,10 @@ export default {
|
|
|
|
|
|
case ACTION_UPDATE:
|
|
|
updatePosition(this.formData).then((resp) => {
|
|
|
- const { code, msg } = resp
|
|
|
- if (code === 200) {
|
|
|
- this.dialogVisible = false
|
|
|
- this.$message.success(msg)
|
|
|
- this.formSuccess()
|
|
|
- } else {
|
|
|
- this.$message.error(msg)
|
|
|
- }
|
|
|
+ const { msg } = resp
|
|
|
+ this.dialogVisible = false
|
|
|
+ this.$message.success(msg)
|
|
|
+ this.formSuccess()
|
|
|
}).catch((error) => {
|
|
|
console.log(error)
|
|
|
})
|