Selaa lähdekoodia

'表单修改'

chending1994 4 vuotta sitten
vanhempi
commit
60ef3cfec2

+ 19 - 0
src/api/markting.js

@@ -0,0 +1,19 @@
+import request from '@/utils/request'
+
+// 新建市场活动
+export function getMarketActivityList(params) {
+  return request({
+    url: 'sale/market',
+    method: 'get',
+    params
+  })
+}
+
+export function saveOrUptMarketActivity(data) {
+  return request({
+    url: 'sale/market',
+    method: data.id ? 'put' : 'post',
+    data
+  })
+}
+

+ 11 - 10
src/components/Table/index.js

@@ -82,7 +82,7 @@ export default {
         ...this.$route,
         name: this.$route.name,
         params: Object.assign({}, this.$route.params, {
-          pageNo: val
+          curPage: val
         })
       })
       // change pagination, reset total data
@@ -107,8 +107,8 @@ export default {
     }
   },
   created () {
-    const { pageNo } = this.$route.params
-    const localPageNum = this.pageURI && (pageNo && parseInt(pageNo)) || this.pageNum
+    const { curPage } = this.$route.params
+    const localPageNum = this.pageURI && (curPage && parseInt(curPage)) || this.pageNum
     this.localPagination = ['auto', true].includes(this.showPagination) && Object.assign({}, this.localPagination, {
       current: localPageNum,
       pageSize: this.pageSize,
@@ -138,7 +138,7 @@ export default {
     loadData (pagination, filters, sorter) {
       this.localLoading = true
       const parameter = Object.assign({
-        pageNo: (pagination && pagination.current) ||
+        curPage: (pagination && pagination.current) ||
           this.showPagination && this.localPagination.current || this.pageNum,
         pageSize: (pagination && pagination.pageSize) ||
           this.showPagination && this.localPagination.pageSize || this.pageSize
@@ -153,28 +153,29 @@ export default {
       }
       )
       const result = this.data(parameter)
-      // 对接自己的通用数据接口需要修改下方代码中的 r.pageNo, r.totalCount, r.data
+      // 对接自己的通用数据接口需要修改下方代码中的 r.curPage, r.totalCount, r.data
       // eslint-disable-next-line
       if ((typeof result === 'object' || typeof result === 'function') && typeof result.then === 'function') {
         result.then(r => {
+          console.log(r);
           this.localPagination = this.showPagination && Object.assign({}, this.localPagination, {
-            current: r.pageNo, // 返回结果中的当前分页数
-            total: r.totalCount, // 返回结果中的总记录数
+            current: r.current, // 返回结果中的当前分页数
+            total: r.total, // 返回结果中的总记录数
             showSizeChanger: this.showSizeChanger,
             pageSize: (pagination && pagination.pageSize) ||
               this.localPagination.pageSize
           }) || false
           // 为防止删除数据后导致页面当前页面数据长度为 0 ,自动翻页到上一页
-          if (r.data.length === 0 && this.showPagination && this.localPagination.current > 1) {
+          if (r.records && r.records.length === 0 && this.showPagination && this.localPagination.current > 1) {
             this.localPagination.current--
             this.loadData()
             return
           }
 
-          // 这里用于判断接口是否有返回 r.totalCount 且 this.showPagination = true 且 pageNo 和 pageSize 存在 且 totalCount 小于等于 pageNo * pageSize 的大小
+          // 这里用于判断接口是否有返回 r.totalCount 且 this.showPagination = true 且 curPage 和 pageSize 存在 且 totalCount 小于等于 curPage * pageSize 的大小
           // 当情况满足时,表示数据不满足分页大小,关闭 table 分页功能
           try {
-            if ((['auto', true].includes(this.showPagination) && r.totalCount <= (r.pageNo * this.localPagination.pageSize))) {
+            if ((['auto', true].includes(this.showPagination) && r.totalCount <= (r.curPage * this.localPagination.pageSize))) {
               this.localPagination.hideOnSinglePage = true
             }
           } catch (e) {

+ 2 - 2
src/utils/request.js

@@ -46,11 +46,11 @@ const errorHandler = (error) => {
 // request interceptor
 request.interceptors.request.use(config => {
   // const token = storage.get(ACCESS_TOKEN)
-  const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b3duSWQiOjIxMzIxMjEyMzI0NSwiZXhwIjoxNjA5MjI0NTIyLCJ1c2VySWQiOjg1NTEyNTQ0MTU1NH0.p3B0oZGrcVhvGmoRBp6oAqVGW5OcCtraKobO07SO_zc'
+  const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b3duSWQiOiIyMTMyMTIxMjMyNDVMIiwiZXhwIjoxNjA5MzI4MzA3LCJ1c2VySWQiOiI4NTUxMjU0NDE1NTRMIn0.SXvI_IqDNwl8DmW1DKUgr9TUfTrriLKg_ctLvRmzyX8'
   // 如果 token 存在
   // 让每个请求携带自定义 token 请根据实际情况自行修改
   if (token) {
-    config.headers['Access-Token'] = token
+    config.headers['access_token'] = token
   }
   return config
 }, errorHandler)

+ 68 - 40
src/views/markting/active/list.vue

@@ -62,6 +62,7 @@
 import moment from 'moment'
 import { STable, Ellipsis } from '@/components';
 import { getRoleList, getServiceList } from '@/api/manage';
+import { getMarketActivityList, saveOrUptMarketActivity } from '@/api/markting';
 import ActiveForm from '../modules/ActiveForm';
 
 const columns = [
@@ -70,30 +71,36 @@ const columns = [
     scopedSlots: { customRender: 'serial' }
   },
   {
-    title: '规则编号',
-    dataIndex: 'no'
+    title: '市场活动名称',
+    dataIndex: 'label'
   },
   {
-    title: '描述',
-    dataIndex: 'description',
-    scopedSlots: { customRender: 'description' }
+    title: '活动类型',
+    dataIndex: 'typeLabel',
   },
   {
-    title: '服务调用次数',
-    dataIndex: 'callNo',
-    sorter: true,
-    needTotal: true,
-    customRender: (text) => text + ' 次'
+    title: '开始时间',
+    dataIndex: 'startDate',
   },
   {
-    title: '状态',
-    dataIndex: 'status',
-    scopedSlots: { customRender: 'status' }
+    title: '结束时间',
+    dataIndex: 'endDate',
   },
   {
-    title: '更新时间',
-    dataIndex: 'updatedAt',
-    sorter: true
+    title: '采单人',
+    dataIndex: 'orderLabel',
+  },
+  {
+    title: '归属部门',
+    dataIndex: 'departmentLabel',
+  },
+  {
+    title: '创建人',
+    dataIndex: 'creatorLabel',
+  },
+  {
+    title: '创建时间',
+    dataIndex: 'createTime',
   }
 ]
 
@@ -137,13 +144,15 @@ export default {
       // 高级搜索 展开/关闭
       advanced: false,
       // 查询参数
-      queryParam: {},
+      queryParam: {
+        curPage: 1
+      },
       loadData: parameter => {
         const requestParameters = Object.assign({}, parameter, this.queryParam)
         console.log('loadData request parameters:', requestParameters)
-        return getServiceList(requestParameters)
+        return getMarketActivityList(requestParameters)
           .then(res => {
-            return res.result
+            return res.data
           })
       },
       selectedRowKeys: [],
@@ -219,41 +228,60 @@ export default {
       const form = this.$refs.createModal.form;
       const ruleForm = this.$refs.createModal.$refs.ruleForm
       this.confirmLoading = true
-      ruleForm.validate(valid  => {
+      ruleForm.validate(async valid  => {
         if (valid) {
           if (form.id > 0) {
-            // 修改 e.g.
-            new Promise((resolve, reject) => {
-              setTimeout(() => {
-                resolve()
-                console.log(form)
-              }, 1000)
-            }).then(res => {
+            const { data, code } = await saveOrUptMarketActivity(form);
+            if(code === 0) {
+              console.log(data);
               this.visible = false
               this.confirmLoading = false
-              // 重置表单数据
               ruleForm.resetFields()
-              // 刷新表格
               this.$refs.table.refresh()
               this.$message.info('修改成功')
-            })
+            }
+            // 修改 e.g.
+            // new Promise((resolve, reject) => {
+            //   setTimeout(() => {
+            //     resolve()
+            //     console.log(form)
+            //   }, 1000)
+            // }).then(res => {
+            //   this.visible = false
+            //   this.confirmLoading = false
+            //   // 重置表单数据
+            //   // ruleForm.resetFields()
+            //   // 刷新表格
+            //   this.$refs.table.refresh()
+            //   this.$message.info('修改成功')
+            // })
           } else {
             // 新增
-            new Promise((resolve, reject) => {
-              setTimeout(() => {
-                resolve()
-                console.log(form)
-              }, 1000)
-            }).then(res => {
+            const { data, code } = await saveOrUptMarketActivity(form);
+            if(code === 0) {
+              console.log(data);
               this.visible = false
               this.confirmLoading = false
-              // 重置表单数据
               ruleForm.resetFields()
-              // 刷新表格
               this.$refs.table.refresh()
-
               this.$message.info('新增成功')
-            })
+            }
+
+            // new Promise((resolve, reject) => {
+            //   setTimeout(() => {
+            //     resolve()
+            //     console.log(form)
+            //   }, 1000)
+            // }).then(res => {
+            //   this.visible = false
+            //   this.confirmLoading = false
+            //   // 重置表单数据
+            //   // ruleForm.resetFields()
+            //   // 刷新表格
+            //   this.$refs.table.refresh()
+
+            //   this.$message.info('新增成功')
+            // })
           }
         } else {
           this.confirmLoading = false

+ 50 - 46
src/views/markting/modules/ActiveForm.vue

@@ -18,36 +18,24 @@
             </div>
           </a-col>
           <a-col :md="12" :sm="24">
-            <a-form-model-item prop="name" label="市场活动名称">
-              <a-select v-model="form.name" placeholder="请选择跟进状态" default-value="0">
-                <a-select-option value="0">全部</a-select-option>
-                <a-select-option value="1">关闭</a-select-option>
-                <a-select-option value="2">运行中</a-select-option>
-              </a-select>
-              <!-- <a-input v-decorator="['description', {rules: [{required: true, min: 5, message: '请输入至少五个字符的规则描述!'}]}]" /> -->
+            <a-form-model-item prop="label" label="市场活动名称">
+              <a-input v-model="form.label" placeholder="请输入市场活动名称"/>
             </a-form-model-item>
           </a-col>
           <a-col :md="12" :sm="24">
-            <a-form-model-item prop="id" label="开始日期">
-              <a-select v-model="form.name" placeholder="请选择销售负责人" default-value="0">
-                <a-select-option value="0">全部</a-select-option>
-                <a-select-option value="1">关闭</a-select-option>
-                <a-select-option value="2">运行中</a-select-option>
-              </a-select>
+            <a-form-model-item prop="startDate" label="开始日期">
+              <a-date-picker v-model="form.startDate" valueFormat="YYYY-MM-DD" style="width: 100%" placeholder="请选择回访日期"/>
             </a-form-model-item>
           </a-col>
           <a-col :md="12" :sm="24">
-            <a-form-model-item prop="name" label="结束日期">
-              <a-select v-model="form.name" placeholder="请选择意向度" default-value="0">
-                <a-select-option value="0">全部</a-select-option>
-                <a-select-option value="1">关闭</a-select-option>
-                <a-select-option value="2">运行中</a-select-option>
-              </a-select>
+            <a-form-model-item prop="endDate" label="结束日期">
+              <a-date-picker v-model="form.endDate" valueFormat="YYYY-MM-DD" style="width: 100%" placeholder="请选择回访日期"/>
             </a-form-model-item>
           </a-col>
           <a-col :md="12" :sm="24">
-            <a-form-model-item prop="name" label="采单人">
-              <a-select v-model="form.name" placeholder="请选择意向度" default-value="0">
+            <a-form-model-item prop="orderId" label="采单人">
+              <a-select v-model="form.orderId" @select="handleSelectOrder" labelInValue placeholder="请选择意向度" default-value="0">
+              <!-- <a-select v-model="form.order" @select="handleSelectOrder" labelInValue placeholder="请选择意向度" default-value="0"> -->
                 <a-select-option value="0">全部</a-select-option>
                 <a-select-option value="1">关闭</a-select-option>
                 <a-select-option value="2">运行中</a-select-option>
@@ -55,8 +43,9 @@
             </a-form-model-item>
           </a-col>
           <a-col :md="12" :sm="24">
-            <a-form-model-item prop="name" label="活动类型">
-              <a-select v-model="form.name" placeholder="请选择意向度" default-value="0">
+            <a-form-model-item prop="typeId" label="活动类型">
+              <a-select v-model="form.typeId" labelInValue placeholder="请选择意向度" default-value="0">
+              <!-- <a-select v-model="form.type" labelInValue placeholder="请选择意向度" default-value="0"> -->
                 <a-select-option value="0">全部</a-select-option>
                 <a-select-option value="1">关闭</a-select-option>
                 <a-select-option value="2">运行中</a-select-option>
@@ -64,26 +53,19 @@
             </a-form-model-item>
           </a-col>
           <a-col :md="12" :sm="24">
-            <a-form-model-item prop="name" label="地点">
-              <a-select v-model="form.name" placeholder="请选择意向度" default-value="0">
-                <a-select-option value="0">全部</a-select-option>
-                <a-select-option value="1">关闭</a-select-option>
-                <a-select-option value="2">运行中</a-select-option>
-              </a-select>
+            <a-form-model-item prop="address" label="地点">
+              <a-input v-model="form.address" placeholder="请输入市场活动名称"/>
             </a-form-model-item>
           </a-col>
           <a-col :md="12" :sm="24">
-            <a-form-model-item prop="name" label="描述">
-              <a-select v-model="form.name" placeholder="请选择意向度" default-value="0">
-                <a-select-option value="0">全部</a-select-option>
-                <a-select-option value="1">关闭</a-select-option>
-                <a-select-option value="2">运行中</a-select-option>
-              </a-select>
+            <a-form-model-item prop="description" label="描述">
+              <a-input v-model="form.description" placeholder="请输入描述"/>
             </a-form-model-item>
           </a-col>
           <a-col :md="12" :sm="24">
-            <a-form-model-item prop="name" label="归属部门">
-              <a-select v-model="form.name" placeholder="请选择意向度" default-value="0">
+            <a-form-model-item prop="departmentId" label="归属部门">
+              <a-select v-model="form.departmentId" labelInValue placeholder="请选择意向度" default-value="0">
+              <!-- <a-select v-model="form.department" labelInValue placeholder="请选择意向度" default-value="0"> -->
                 <a-select-option value="0">全部</a-select-option>
                 <a-select-option value="1">关闭</a-select-option>
                 <a-select-option value="2">运行中</a-select-option>
@@ -97,10 +79,6 @@
 </template>
 
 <script>
-import pick from 'lodash.pick'
-
-// 表单字段
-const fields = ['description', 'id']
 
 export default {
   props: {
@@ -130,13 +108,33 @@ export default {
     }
     return {
       form: {
-        id: '',
-        name: undefined
+        label: '',
+        startDate: undefined,
+        endDate: undefined,
+        orderId: undefined,
+        orderLabel: undefined,
+        typeId: undefined,
+        typeLabel: undefined,
+        description: '',
+        departmentId: undefined,
+        departmentLabel: undefined
       },
       rules: {
-        // name: [
-        //   { required: true, message: '请选择销售人员' },
-        // ],
+        label: [
+          { required: true, message: '请输入市场活动名称' },
+        ],
+        startDate: [
+          { required: true, message: '请选择开始时间' },
+        ],
+        endDate: [
+          { required: true, message: '请选择结束时间' },
+        ],
+        orderId: [
+          { required: true, message: '请选择采单人' },
+        ],
+        typeId: [
+          { required: true, message: '请选择活动类型' },
+        ]
       },
     }
   },
@@ -150,6 +148,12 @@ export default {
     // this.$watch('model', () => {
     //   this.model && this.form.setFieldsValue(pick(this.model, fields))
     // })
+  },
+  methods: {
+    handleSelectOrder(value) {
+      // this.form.orderId = value.key;
+      // this.form.orderLabel = value.label;
+    }
   }
 }
 </script>

+ 1 - 1
src/views/markting/modules/AddLeads.vue

@@ -1,6 +1,6 @@
 <template>
   <a-modal
-    title="添加记录"
+    title="分配名单"
     :width="640"
     :visible="visible"
     :confirmLoading="loading"