修正一些语法错误

This commit is contained in:
zhl 2021-04-19 19:35:47 +08:00
parent d27e40602c
commit 7d2e069349
5 changed files with 29 additions and 34 deletions

View File

@ -3,8 +3,7 @@ import { IShopData } from './types'
export const defaultShopData: IShopData = {
name: '',
id: ''
_id: ''
}
export const getShops = (params: any) =>

2
src/api/types.d.ts vendored
View File

@ -42,7 +42,7 @@ export interface IQuestionData {
}
export interface IShopData {
id: string,
_id: string,
name: string,
createdAt?: Date
}

View File

@ -50,7 +50,7 @@ const shopRoutes: RouteConfig = {
permissions: ['question:read'],
icon: 'game'
}
},
}
]
}

View File

@ -51,7 +51,7 @@
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
import { Component, Vue } from 'vue-property-decorator'
import { AppModule } from '@/store/modules/app'
import { TagsViewModule, ITagView } from '@/store/modules/tags-view'
import MaterialInput from '@/components/MaterialInput/index.vue'
@ -109,7 +109,6 @@ export default class extends Vue {
if (id) {
this.fetchData(id)
}
this.tempTagView = Object.assign({}, this.$route)
}
@ -125,7 +124,6 @@ export default class extends Vue {
console.log(data)
this.postForm = data
// Just for test
this.postForm.title += ` 店铺 Id:${this.postForm._id}`
const title = this.lang === 'zh' ? '编辑店铺' : 'Edit Shop'
// Set tagsview title
this.setTagsViewTitle(title)
@ -149,18 +147,16 @@ export default class extends Vue {
}
private submitForm() {
(this.$refs.postForm as Form).validate(valid => {
(this.$refs.postForm as Form).validate(async valid => {
if (valid) {
this.loading = true
saveShop(this.postForm)
.then(() => {
this.loading = false
this.$notify({
title: 'Success',
message: 'The post published successfully',
type: 'success',
duration: 2000
})
await saveShop(this.postForm)
this.loading = false
this.$notify({
title: 'Success',
message: 'The post published successfully',
type: 'success',
duration: 2000
})
} else {
console.error('Submit Error!')
@ -181,7 +177,6 @@ export default class extends Vue {
}
</script>
<style lang="scss" scoped>
.createPost-container {
position: relative;

View File

@ -93,7 +93,7 @@ import { IShopData } from '@/api/types'
import Pagination from '@/components/Pagination/index.vue'
import { deleteShop, getShops } from '@/api/shop'
import { parseTime } from '@/utils'
import { deleteRole } from '@/api/roles'
import { Form } from 'element-ui'
@Component({
name: 'ShopList',
@ -123,6 +123,9 @@ export default class extends Vue {
created() {
this.getList()
}
activated() {
this.getList()
}
private async getList() {
this.listLoading = true
@ -131,27 +134,23 @@ export default class extends Vue {
this.list = data.records
this.total = data.total
}
private handleDelete(scope: any) {
private async handleDelete(scope: any) {
const { $index, row } = scope
console.log($index, scope)
this.$confirm('确认删除该店铺?', 'Warning', {
await this.$confirm('确认删除该店铺?', 'Warning', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(async() => {
await deleteShop(row._id)
this.list.splice($index, 1)
this.$message({
type: 'success',
message: '删除成功!'
})
})
.catch(err => { console.error(err) })
await deleteShop(row._id)
this.list.splice($index, 1)
this.$message({
type: 'success',
message: '删除成功!'
})
}
private search() {
this.tableData = this.filterData()
this.currentPage = 1
this.filterData()
}
private filterData() {
@ -161,8 +160,10 @@ export default class extends Vue {
}
private resetFilterForm() {
this.$refs.filterForm.resetFields()
const ref = <Form>this.$refs.filterForm
ref.resetFields()
}
}
</script>