|
@@ -52,7 +52,6 @@
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- tableData: [],
|
|
|
dialogVisible: false,
|
|
|
form: {
|
|
|
name: '',
|
|
@@ -64,6 +63,11 @@
|
|
|
type: ''
|
|
|
}
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ ...mapGetters({
|
|
|
+ tableData: 'data'
|
|
|
+ })
|
|
|
+ },
|
|
|
methods: {
|
|
|
handleEdit(index, row) {
|
|
|
this.dialogVisible = true;
|
|
@@ -82,18 +86,10 @@
|
|
|
console.log(this.form)
|
|
|
const form = this.form;
|
|
|
if(this.type == 'add') {
|
|
|
- addCompanyList(form).then(res => {
|
|
|
- companyList().then(res => {
|
|
|
- if(res.code == 200) {
|
|
|
- this.tableData = res.data;
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
+ this.$store.dispatch('addCompanyList', form)
|
|
|
}else {
|
|
|
const index = this.setIndex;
|
|
|
- setCompanyList(form).then(res => {
|
|
|
- this.tableData[index].name = form.name;
|
|
|
- });
|
|
|
+ this.$store.dispatch('setCompanyList', {form, index})
|
|
|
}
|
|
|
this.dialogVisible = false;
|
|
|
} else {
|
|
@@ -109,11 +105,7 @@
|
|
|
}
|
|
|
},
|
|
|
created () {
|
|
|
- companyList().then(res => {
|
|
|
- if(res.code == 200) {
|
|
|
- this.tableData = res.data;
|
|
|
- }
|
|
|
- })
|
|
|
+ this.$store.dispatch('getCompanyList')
|
|
|
}
|
|
|
}
|
|
|
</script>
|