invitation.vue 8.55 KB
<!-- 邀约 -->
<template>
  <d2-container class="invitation">
    <div slot="header"
         class="header">
      <AppointTable />
      <TimeDate :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"
                          end-placeholder="结束日期"
                          range-separator="至"
                          start-placeholder="开始日期"
                          type="daterange" />
        </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"
                     style="margin-left: 0px;"
                     type="primary">
            查询
          </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"
                    :get-list-api="getListApi"
                    :has-num="false"
                    :search-form="searchForm"
                    :table-params="tableParams">
            <template slot="auth-button"
                      slot-scope="scope">
              <auth-button show-btn-ids="['9020301', '9020302', '9020303', '9020304']"
                           :data="scope.scope" />
            </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"
                    :get-list-api="getListApi"
                    :has-num="false"
                    :search-form="searchForm"
                    :table-params="tableSecondParams">
            <template slot="auth-button"
                      slot-scope="scope">
              <auth-button show-btn-ids="['9020305', '9020306', '9020307']"
                           :data="scope.scope" />
            </template>
          </d2-table>
        </el-tab-pane>
      </el-tabs>
    </div>
    <d2-dialog title="正在为客户预约"
               :is-visible="appointDialogVisible"
               @closeDialog="handleAppointClose"
               @confirmDialog="handleAppointConfirm">
      <el-form label-width="120px"
               :model="appointForm">
        <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"
                            placeholder="选择日期"
                            type="date"
                            :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"
                         :disabled="((appointForm.date == new Date().toLocaleDateString()) && (+item.hour.split(':')[0] <= new Date().getHours()) || fullList[index])"
                         :label="item.hour"
                         :value="item.hour" />
            </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 AppointTable from "./invitation-component/AppointTable";
import TimeDate from "./invitation-component/TimeDate";

export default {
	name: "Invitation",

	components: {
		TimeDate,
		AppointTable,
	},
	data() {
		return {
			// 邀约弹窗
			afterTodayOptions,
			appointDialogVisible: false,
			appointForm: {},
			fullList: Array.from({ length: 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: Array.from({ length: 10 }).fill(null).map((subItem) => {
						return {
							status: Number.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() + Number.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() + Number.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: "",
				}],
			},
		};
	},

	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>