diff --git a/mock/example/index.ts b/mock/example/index.ts index d6d6893..ace8349 100644 --- a/mock/example/index.ts +++ b/mock/example/index.ts @@ -1,34 +1,28 @@ import Mock from 'mockjs' import { toAnyString } from '@/utils' -const List: any[] = [] +let List: any[] = [] const count = 100 const baseContent = '

I am testing data, I am testing data.

' -const image_uri = 'https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3' +// const image_uri = 'https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3' for (let i = 0; i < count; i++) { List.push(Mock.mock({ id: toAnyString(), - timestamp: +Mock.Random.date('T'), + // timestamp: +Mock.Random.date('T'), author: '@first', - reviewer: '@first', title: '@title(5, 10)', - content_short: 'mock data', content: baseContent, - forecast: '@float(0, 100, 2, 2)', importance: '@integer(1, 3)', - 'type|1': ['CN', 'US', 'JP', 'EU'], - 'status|1': ['published', 'draft', 'deleted'], display_time: '@datetime', - comment_disabled: true, - pageviews: '@integer(300, 5000)', - image_uri, - platforms: ['a-platform'] + pageviews: '@integer(300, 5000)' + // image_uri })) } export default [ + // 列表接口 { url: 'http://mockjs.test.cn/example/list', type: 'get', @@ -51,17 +45,33 @@ export default [ } }, + // 删除接口 { url: 'http://mockjs.test.cn/example/delete', type: 'post', response: (config: any) => { - return { - code: '0000', - data: '删除成功' + const ids = config.body.ids + if (!ids) { + return { + code: '500', + message: '请选择需要删除的数据' + } + } else { + let i = List.length + while (i--) { + if (ids.indexOf(List[i].id) !== -1) { + List.splice(i, 1) + } + } + return { + code: '0000', + data: 'success' + } } } }, + // 详情接口 { url: 'http://mockjs.test.cn/example/detail', type: 'get', @@ -78,13 +88,34 @@ export default [ } }, + // 保存接口 { url: 'http://mockjs.test.cn/example/save', type: 'post', response: (config: any) => { - return { - code: '0000', - data: 'success' + const data = config.body + if (!data.id) { + List = [Object.assign(data, { id: toAnyString(), importance: Number(data.importance) })].concat(List) + return { + code: '0000', + data: 'success' + } + } else { + List.map(item => { + if (item.id === data.id) { + for (const key in item) { + if (key === 'importance') { + item[key] = Number(data[key]) + } else { + item[key] = data[key] + } + } + } + }) + return { + code: '0000', + data: 'success' + } } } } diff --git a/src/components/Dialog/index.vue b/src/components/Dialog/index.vue new file mode 100644 index 0000000..7784715 --- /dev/null +++ b/src/components/Dialog/index.vue @@ -0,0 +1,45 @@ + + + + + diff --git a/src/components/Editor/props.ts b/src/components/Editor/props.ts index c53c1d1..2c42310 100644 --- a/src/components/Editor/props.ts +++ b/src/components/Editor/props.ts @@ -11,7 +11,7 @@ export const editorProps = { default: () => { return { height: 500, - zIndex: 500, + zIndex: 0, placeholder: '请输入文本', focus: false, onchangeTimeout: 500, diff --git a/src/components/Table/index.vue b/src/components/Table/index.vue index f76586f..2afcfc2 100644 --- a/src/components/Table/index.vue +++ b/src/components/Table/index.vue @@ -5,7 +5,8 @@