修正一些语法错误

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 = { export const defaultShopData: IShopData = {
name: '', name: '',
id: '' _id: ''
} }
export const getShops = (params: any) => export const getShops = (params: any) =>

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

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

View File

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

View File

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

View File

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