invitation.vue 8.94 KB
<!-- 邀约 -->
<template>
  <d2-container class="invitation">
    <div class="header"
         slot="header">
      <appoint-table />
      <time-date :appoint-data="appointData"
                 :hours-list="hoursList"
                 @handleAppoint="handleAppoint" />
    </div>
    <div class="d2-container-content">
      <el-form :inline="true">
        <el-form-item label="日期:">
          <el-date-picker v-model="searchForm.date"
                          type="daterange"
                          range-separator="至"
                          start-placeholder="开始日期"
                          end-placeholder="结束日期" />
        </el-form-item>
        <el-form-item label="">
          <el-input v-model="searchForm.name"
                    placeholder="客户姓名或车架号" />
        </el-form-item>
        <el-form-item>
          <el-button v-show="activeName === 'first'"
                     :id="tableParams.btnId"
                     size="small"
                     type="primary">
            查询
          </el-button>
          <el-button v-show="activeName === 'second'"
                     :id="tableSecondParams.btnId"
                     size="small"
                     type="primary"
                     style="margin-left: 0px;">
            查询
          </el-button>
          <el-button size="small"
                     @click="handleReset">
            重置
          </el-button>
        </el-form-item>
      </el-form>
      <el-tabs v-model="activeName"
               type="card">
        <el-tab-pane name="first">
          <span slot="label"><i class="el-icon-date" />已预约({{ totalCount.inviteCount }})</span>
          <d2-table ref="invitationFirstTable"
                    :has-num="false"
                    :search-form="searchForm"
                    :table-params="tableParams"
                    :get-list-api="getListApi">
            <template slot="auth-button"
                      slot-scope="scope">
              <auth-button :data="scope.scope"
                           show-btn-ids="['9020301', '9020302', '9020303', '9020304']" />
            </template>
          </d2-table>
        </el-tab-pane>
        <el-tab-pane name="second">
          <span slot="label"><i class="el-icon-date" />待预约({{ totalCount.customerCount }})</span>
          <d2-table ref="invitationSecondTable"
                    :has-num="false"
                    :search-form="searchForm"
                    :table-params="tableSecondParams"
                    :get-list-api="getListApi">
            <template slot="auth-button"
                      slot-scope="scope">
              <auth-button :data="scope.scope"
                           show-btn-ids="['9020305', '9020306', '9020307']" />
            </template>
          </d2-table>
        </el-tab-pane>
      </el-tabs>
    </div>
    <d2-dialog title="正在为客户预约"
               :is-visible="appointDialogVisible"
               @closeDialog="handleAppointClose"
               @confirmDialog="handleAppointConfirm">
      <el-form :model="appointForm"
               label-width="120px">
        <el-form-item label="客户姓名:"
                      prop="name">
          <el-input v-model="appointForm.name"
                    placeholder="请输入客户姓名" />
        </el-form-item>
        <el-form-item label="车架号后6位:"
                      prop="carNo">
          <el-input v-model="appointForm.carNo"
                    placeholder="请输入车架号后6位" />
        </el-form-item>
        <el-form-item label="具体时间:">
          <el-col :span="10">
            <el-date-picker v-model="appointForm.date"
                            type="date"
                            placeholder="选择日期"
                            :picker-options="afterTodayOptions"
                            @change="handleChangeDate(1)" />
          </el-col>
          <el-col :span="10">
            <el-select v-model="appointForm.hour"
                       placeholder="选择时间">
              <el-option v-for="(item, index) in hoursList"
                         :key="index"
                         :label="item.hour"
                         :value="item.hour"
                         :disabled="((appointForm.date == new Date().toLocaleDateString()) && (+item.hour.split(':')[0] <= new Date().getHours()) || fullList[index])" />
            </el-select>
          </el-col>
        </el-form-item>
        <el-form-item label="预约项目:"
                      prop="project">
          <el-select v-model="appointForm.project"
                     placeholder="请输入预约项目" />
        </el-form-item>
      </el-form>
    </d2-dialog>
  </d2-container>
</template>

<script>
import { getList, getTotalCount } from '@api/invitation'
import { afterTodayOptions, appointDays } from '@/common/format'
import TimeDate from './invitation-component/TimeDate'
import AppointTable from './invitation-component/AppointTable'
export default {
  name: 'Invitation',
  data() {
    return {
      // 邀约弹窗
      afterTodayOptions: afterTodayOptions,
      appointDialogVisible: false,
      appointForm: {},
      fullList: new Array(10).fill(false),
      appointData: new Array(appointDays).fill(null).map((item, index) => {
        return {
          date: new Date(new Date().setDate(new Date().getDate() + index)).toLocaleDateString(),
          infoList: new Array(10).fill(null).map(subItem => {
            return {
              status: parseInt(Math.random() * 3),
              appointInfo: [{
                name: 'zhangsan',
                time: 'time',
                project: 'project'
              }]
            }
          })
        }
      }),
      hoursList: [
        { hour: '9:00' }, { hour: '10:00' },
        { hour: '11:00' }, { hour: '12:00' },
        { hour: '13:00' }, { hour: '14:00' },
        { hour: '15:00' }, { hour: '16:00' },
        { hour: '17:00' }, { hour: '18:00' }],
      // table
      activeName: 'first',
      totalCount: {
        customerCount: 0,
        inviteCount: 0
      },
      searchForm: {
        date: '',
        name: ''
      },
      getListApi: getList,
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableOption: true,
        tableColumns: [{
          label: '操作日期',
          prop: ''
        }, {
          label: '客户信息',
          prop: 'customerInfo',
          addHtml: 'customerInfo'
        }, {
          label: '状态',
          prop: 'status'
        }, {
          label: '预约信息',
          prop: 'customerInfo',
          addHtml: ''
        }, {
          label: '备注信息',
          prop: 'customerInfo',
          addHtml: ''
        }]
      },
      tableSecondParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000) + 'second',
        listName: 'list',
        tableOption: true,
        tableColumns: [{
          label: '操作日期',
          prop: ''
        }, {
          label: '客户信息',
          prop: 'customerInfo',
          addHtml: 'customerInfo'
        }, {
          label: '录入时间',
          prop: 'status'
        }, {
          label: '来源',
          prop: 'customerInfo',
          addHtml: ''
        }, {
          label: '状态',
          prop: 'customerInfo',
          addHtml: ''
        }, {
          label: '操作记录',
          prop: 'customerInfo',
          addHtml: ''
        }, {
          label: '备注信息',
          prop: 'customerInfo',
          addHtml: ''
        }]
      }
    }
  },

  components: {
    TimeDate,
    AppointTable
  },

  mounted() {
    getTotalCount({}).then(res => {
      this.totalCount.inviteCount = res.inviteCount
      this.totalCount.customerCount = res.customerCount
    })
  },

  methods: {
    handleAppoint(obj) {
      // console.log(obj)
      this.appointForm = {
        name: '',
        carNo: '',
        ...obj
      }
      this.fullList = this.appointData.find(item => item.date == this.appointForm.date).infoList.map(subItem => subItem.status === 2)
      this.appointDialogVisible = true
    },
    handleAppointClose() {
      this.appointDialogVisible = false
    },
    handleAppointConfirm() {
      this.handleAppointClose()
    },
    handleChangeDate(index) {
      this.appointForm.date = this.appointForm.date.toLocaleDateString()
      this.appointForm.hour = ''
      this.fullList = this.appointData.find(item => item.date == this.appointForm.date).infoList.map(subItem => subItem.status === 2)
    }
  }
}

</script>
<style lang="scss">
.invitation {
  .header {
    min-width: 1176px;
    display: flex;
    justify-content: space-around;
    padding: 20px 20px;
  }
}
</style>