活动模块增删查改

master
panqihua 3 years ago
parent 3832db6fa9
commit 580440ffa1
  1. 14
      src/components/Layout/Sider.vue
  2. 1
      src/main.js
  3. 57
      src/mock.js
  4. 52
      src/router/index.js
  5. 6
      src/services/customer-api.js
  6. 7
      src/utils/axios-util.js
  7. 2
      src/views/Login.vue
  8. 65
      src/views/activity/components/edit.vue
  9. 96
      src/views/activity/components/list.vue
  10. 120
      src/views/activity/index.vue
  11. 13
      vue.config.js

@ -113,11 +113,8 @@ export default {
path: '/business', path: '/business',
title: '交易', title: '交易',
type: 'pay-circle' type: 'pay-circle'
},{ },
path: '/activities', {
title: '活動',
type: 'schedule'
},{
path: '/custList', path: '/custList',
title: '客戶', title: '客戶',
type: 'user' type: 'user'
@ -130,7 +127,12 @@ export default {
path: '/more', path: '/more',
title: '更多..導入資料', title: '更多..導入資料',
type: 'small-dash' type: 'small-dash'
} },
{
path: '/activities',
title: '活動',
type: 'schedule'
},
], ],
subMenu: [{ subMenu: [{

@ -20,6 +20,7 @@ import {Chart} from 'chart.js';
import Chartkick from 'vue-chartkick'; import Chartkick from 'vue-chartkick';
import Api from './services/api'; import Api from './services/api';
import Util from './utils/util';///引入工具类 import Util from './utils/util';///引入工具类
import './mock'
import VueCloneya from 'vue-cloneya'; import VueCloneya from 'vue-cloneya';
Vue.use(VueCloneya) Vue.use(VueCloneya)

@ -9,6 +9,9 @@
// 引入mockjs, 在线文档: https://github.com/nuysoft/Mock/wiki // 引入mockjs, 在线文档: https://github.com/nuysoft/Mock/wiki
const Mock = require('mockjs'); const Mock = require('mockjs');
console.debug('初始化Mock')
// 获取 mock.Random 对象 // 获取 mock.Random 对象
const Random = Mock.Random; const Random = Mock.Random;
// 配置响应时间 // 配置响应时间
@ -16,28 +19,31 @@ Mock.setup({
timeout: '200-600' timeout: '200-600'
}); });
let base = 'http://localhost:8080/'; let base = 'http://localhost:8081/';
// 语法:Mock.mock( url, post/get , 返回的数据); // 语法:Mock.mock( url, post/get , 返回的数据);
// Mail部分 // Mail部分
Mock.mock(base + 'context/mail/getAccountList','post', getRadomAccountList()); Mock.mock(base + 'context/mail/getAccountList', 'post', getRadomAccountList());
Mock.mock(base + 'context/mail/getFolderList', 'post', getRadomFolderList());
Mock.mock(base + 'context/mail/getFolderList','post', getRadomFolderList()); Mock.mock(base + 'context/mail/getMessageList', 'post', getRadomMailList());
Mock.mock(base + 'context/mail/getMessageList','post', getRadomMailList()); Mock.mock(base + 'context/mail/getMessageDetail', 'post', getRadomMessage());
Mock.mock(base + 'context/mail/getMessageDetail','post', getRadomMessage()); Mock.mock(base + 'context/mail/send', 'post', send());
Mock.mock(base + 'context/mail/send','post', send()); //活动列表数据mock
Mock.mock('/mock/activity/getActivityList','get',options=>getActivityList(options))
function getRadomAccountList () { function getRadomAccountList() {
return { return {
"errCode": 0, "errCode": 0,
"errMsg": "请求成功", "errMsg": "请求成功",
"data": { "data": {
"mailAccountList": [ "mailAccountList": [
{ {
"id": Random.integer(0,20), "id": Random.integer(0, 20),
"createTime": Random.date() + ' ' + Random.time(), "createTime": Random.date() + ' ' + Random.time(),
"updateTime": Random.date() + ' ' + Random.time(), "updateTime": Random.date() + ' ' + Random.time(),
"type": "imap_smtp", "type": "imap_smtp",
@ -59,12 +65,12 @@ function getRadomAccountList () {
} }
} }
function getRadomFolderList () { function getRadomFolderList() {
let folderList = []; let folderList = [];
for (let i = 0; i < 5; i++) { for (let i = 0; i < 5; i++) {
let item = { let item = {
"id": Random.integer(0,20), "id": Random.integer(0, 20),
"createTime": Random.date() + ' ' + Random.time(), "createTime": Random.date() + ' ' + Random.time(),
"updateTime": Random.date() + ' ' + Random.time(), "updateTime": Random.date() + ' ' + Random.time(),
"parent": Random.cword(3), "parent": Random.cword(3),
@ -92,7 +98,7 @@ function getRadomFolderList () {
} }
function getRadomMailList () { function getRadomMailList() {
let mailList = []; let mailList = [];
@ -141,7 +147,7 @@ function getRadomMailList () {
"errCode": 0, "errCode": 0,
"errMsg": "请求成功", "errMsg": "请求成功",
"data": { "data": {
"mailList": mailList, "mailList": mailList,
"total": 15 "total": 15
} }
@ -149,7 +155,7 @@ function getRadomMailList () {
} }
function getRadomMessage () { function getRadomMessage() {
return { return {
"errCode": 0, "errCode": 0,
"errMsg": "请求成功", "errMsg": "请求成功",
@ -159,7 +165,7 @@ function getRadomMessage () {
} }
} }
function send () { function send() {
return { return {
"errCode": 0, "errCode": 0,
"errMsg": "请求成功", "errMsg": "请求成功",
@ -168,3 +174,26 @@ function send () {
} }
} }
} }
function getActivityList(options) {
console.debug(options)
let data = Array.from(new Array(Mock.Random.integer(1, 10)).keys()).map(() => Mock.mock({
id:Mock.Random.id(),
finish: Mock.Random.boolean(),
subject: Mock.Random.title(),
deal: /[a-z][A-Z][0-9]/,
participants: Mock.Random.cname(),
email: Mock.Random.email(),
phone: /^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/,
organization: Mock.Random.ctitle(),
date: Mock.Random.date('yyyy-MM-dd'),
time: Mock.Random.integer(),
user: Mock.Random.cname()
}))
return {
"errCode": 0,
"errMsg": "请求成功",
data
}
}

@ -102,12 +102,12 @@ const routes = [
] ]
}, },
//客户 //客户
{ // {
path: "/custList", // path: "/custList",
name: "CustList", // name: "CustList",
component: () => // component: () =>
import("../views/CustList.vue"), // import("../views/CustList.vue"),
}, // },
{ {
path: "/persons", //info: 重写的联络人模块, 2021.12.27 path: "/persons", //info: 重写的联络人模块, 2021.12.27
name: "Persons", name: "Persons",
@ -129,34 +129,6 @@ const routes = [
name: "CalendarView", name: "CalendarView",
component: () => import("../components/Calendar/CalendarView.vue"), component: () => import("../components/Calendar/CalendarView.vue"),
}, },
{
path: "/activities",
name: "ActivitiesList",
component: () => import("../views/ActivitiesList.vue"),
children: [
{
path: '/activities/Activities',
component: resolve => require(['@/components/Calendar/Activities'], resolve),
},
{
path: '/activities/CalendarView',
component: resolve => require(['@/components/Calendar/CalendarView'], resolve),
},
{
path: '/activities/CalendarFullView',
component: resolve => require(['@/components/Calendar/CalendarFullView'], resolve),
},
{
path: '/activities/CalendarSetting',
component: resolve => require(['@/components/Calendar/CalendarSetting'], resolve),
},
]
},
// {
// path: "/businessList",
// name: "BusinessList1",
// component: () => import("../views/BusinessList.vue"),
// },
{ {
path: "/insightsChartList", path: "/insightsChartList",
name: "InsightsChartList", name: "InsightsChartList",
@ -177,6 +149,18 @@ const routes = [
name: "UserProfile", name: "UserProfile",
component: () => import("../components/Customer/UserProfile.vue"), component: () => import("../components/Customer/UserProfile.vue"),
}, },
//活动
{
path: "/activities",
name: "ActivitiesList",
component: () => import("../views/activity/index"),
children: [
// {
// path: '/activities/Activities',
// component: resolve => require(['@/components/Calendar/Activities'], resolve),
// },
]
},
] ]
}, },
// { // {

@ -7,7 +7,7 @@
* @LastEditTime: 2021-12-14 20:25:42 * @LastEditTime: 2021-12-14 20:25:42
*/ */
// import Axios from '../utils/axios-util-customer' // import Axios from '../utils/axios-util-customer'
import Axios from '../utils/axios-util' import Axios, {DEFAULT_GET} from '../utils/axios-util'
// console.log('mail-api打印', Axios); // console.log('mail-api打印', Axios);
//info: mail文档地址: //info: mail文档地址:
@ -408,4 +408,8 @@ export default {
//console.log("updateParams", updateParams) //console.log("updateParams", updateParams)
return Axios.POST(custBase + 'browseRecord/selectBrowseRecordList', updateParams); return Axios.POST(custBase + 'browseRecord/selectBrowseRecordList', updateParams);
}, },
getActivityList:()=>{
return Axios.DEFAULT_GET('/mock/activity/getActivityList')
}
} }

@ -120,8 +120,13 @@ base = 'http://52.221.25.56:9230/';
return httpAxios.patch(`${base}${url}`, params).then(res => res.data) return httpAxios.patch(`${base}${url}`, params).then(res => res.data)
} }
export const DEFAULT_GET = (url, params) => {
return httpAxios.get(`${url}`, {params: params}).then(res => res.data)
}
export default { export default {
POST, POST,
TEST_POST TEST_POST,
DEFAULT_GET
} }

@ -173,7 +173,7 @@ export default {
if (this.$route.query.redirect == location.hostname) { if (this.$route.query.redirect == location.hostname) {
this.$router.go(-1); this.$router.go(-1);
} else { } else {
this.$router.push('/custList'); this.$router.push('/activities');
} }
}, },
resetForm() { resetForm() {

@ -0,0 +1,65 @@
<template>
<div>
<h1>{{ action }}</h1>
<a-form-model ref="ruleForm" :model="editData" :rules="rules" >
<a-form-model-item label="主题" prop="subject">
<a-input v-model="editData.subject"/>
</a-form-model-item>
<a-form-model-item label="交易" prop="deal">
<a-input v-model="editData.deal"/>
</a-form-model-item>
<a-form-model-item>
<a-button type="primary" @click="onSubmit">确认</a-button>
</a-form-model-item>
</a-form-model>
</div>
</template>
<script>
import {Modal} from "ant-design-vue";
export default {
name: "edit",
data() {
return {
rules: {
subject: [
{ required: true, message: '请输入主题', trigger: 'change' }
],
deal: [
{ required: true, message: '请输入交易', trigger: 'change' }
]
},
editData:this.form
}
},
methods:{
onSubmit:function (){
let that=this
this.$refs.ruleForm.validate(valid => {
if (valid) {
if(this.action.includes('编辑')) {
that.$emit('close')
}else{
that.$emit('onAdd')
}
} else {
Modal.error({
title:'错误提示',
content:'表单校验失败'
})
return false;
}
});
}
},
props: {
action: String,
form: Object,
}
}
</script>
<style scoped>
</style>

@ -0,0 +1,96 @@
<template>
<a-table :columns="columns" :data-source="data" rowKey="id" :scroll="{x:true}">
<template slot="finish" slot-scope="text, record">
<a-checkbox :default-checked="record.finish"/>
</template>
<template slot="action" slot-scope="text, record,index">
<a-space>
<a-button @click="$emit('onEdit',record,index)">{{ action.edit }}</a-button>
<a-popconfirm
v-if="data.length"
:title="deleteTip"
@confirm="() => $emit('onDelete',record.id)"
>
<a-button type="danger">{{ action.delete }}</a-button>
</a-popconfirm>
</a-space>
</template>
</a-table>
</template>
<script>
const columns = [
{
title: '完成',
dataIndex: 'finish',
scopedSlots: {customRender: 'finish'}
},
{
title: '主题',
dataIndex: 'subject'
},
{
title: '交易',
dataIndex: 'deal'
},
{
title: '联络人',
dataIndex: 'participants'
},
{
title: '电子邮件',
dataIndex: 'email'
},
{
title: '电话',
dataIndex: 'phone'
},
{
title: '组织',
dataIndex: 'organization'
},
{
title: '到期日',
dataIndex: 'date'
},
{
title: '期间',
dataIndex: 'time'
},
{
title: '指派给使用者',
dataIndex: 'user'
},
{
title: '操作',
dataIndex: 'action',
scopedSlots: {customRender: 'action'}
}
]
export default {
name: "list",
props:{
data:Array
},
data() {
return {
//
columns,
action: {
edit: '编辑',
delete: '删除',
refresh: '刷新'
},
deleteTip: '确认删除此活动记录?',
}
},
mounted() {
this.$emit('load')
}
}
</script>
<style scoped>
</style>

@ -1,13 +1,129 @@
<template> <template>
<h1>这是一个活动模块Demo</h1> <div>
<h1>{{ menuTitle }}</h1>
<div class="space"/>
<a-space>
<a-button type="primary" @click="load">{{ action.refresh }}</a-button>
<a-button @click="currentTitle=addTitle;showDrawer()">{{ action.add }}</a-button>
</a-space>
<div class="space"/>
<a-row>
<a-col :span="6">
<a-input-search :placeholder="keywordPlaceHolder" @search="load" v-model="keyword"/>
</a-col>
</a-row>
<div class="space"/>
<a-spin :spinning="spinning" :delay="500">
<List v-on:onEdit="onEdit"
v-on:onDelete="onDelete"
v-on:load="load"
:data="data"
/>
</a-spin>
<a-drawer
:title="action.edit"
placement="right"
:closable="false"
:visible="visible"
@close="onClose"
>
<Edit v-if="visible" :action="currentTitle" :form="currentForm"
v-on:close="onClose"
v-on:onAdd="onAdd"/>
</a-drawer>
</div>
</template> </template>
<script> <script>
import Edit from "./components/edit";
import List from "./components/list"
import Mock from "mockjs";
export default { export default {
name: "index.vue" name: "index.vue",
components: {List, Edit},
data() {
return {
//
spinning: false,
modelName: '活动记录',
//
visible: false,
//
data: [],
action: {
add: '新增',
edit: '编辑',
delete: '删除',
refresh: '刷新'
},
menuTitle: '这是一个活动模块Demo',
currentForm: {},
currentIndex: -1,
currentTitle: null,
//
keyword: '',
keywordPlaceHolder: '输入主题关键字'
}
},
methods: {
showDrawer() {
this.visible = true;
},
onClose() {
this.visible = false;
this.currentForm = {}
this.currentIndex = -1
this.currentTitle = null
},
onDelete(id) {
this.data = this.data.filter(item => item.id !== id);
},
onEdit(record, index) {
console.info('编辑记录:%o', record)
this.currentForm = record
this.currentIndex = index
this.currentTitle = this.editTitle
this.showDrawer()
},
onAdd() {
console.info('新增记录:%o', this.currentForm)
this.data.push({...this.currentForm, ...{id: Mock.Random.id()}})
this.onClose()
},
load() {
this.spinning = true
let that = this
this.$api.customer.getActivityList().then(res => {
if (res.errCode === 0) {
that.data = res.data.filter(item => that.keyword === '' || item.subject.includes(that.keyword))
} else {
console.error('无法解析列表数据:%o', res)
}
}
).catch(err => {
console.error(err)
}).finally(() => this.spinning = false)
}
},
computed: {
editTitle: function () {
return this.action.edit + this.modelName
},
addTitle: function () {
return this.action.add + this.modelName
}
}
} }
</script> </script>
<style scoped> <style scoped>
.space {
height: 10px;
}
.ant-table td {
white-space: nowrap;
}
</style> </style>

@ -9,9 +9,9 @@
//vue 官方关于vue.config.js中配置的详细文档: https://cli.vuejs.org/zh/config/#vue-config-js //vue 官方关于vue.config.js中配置的详细文档: https://cli.vuejs.org/zh/config/#vue-config-js
module.exports = { module.exports = {
publicPath: process.env.NODE_ENV === 'production' publicPath: process.env.NODE_ENV === 'production'
// ? '/crm-project/' // ? '/crm-project/'
? '/crm/' ? '/crm/'
: '/', : '/',
devServer: { devServer: {
overlay: { overlay: {
warnings: false, warnings: false,
@ -62,5 +62,12 @@ module.exports = {
lintOnSave: false,//是否开启selint lintOnSave: false,//是否开启selint
css: { css: {
extract: false extract: false
},
configureWebpack:{
watch:true,
watchOptions: {
poll: 1000,
},
} }
} }

Loading…
Cancel
Save