|
@@ -0,0 +1,385 @@
|
|
|
|
|
+<template>
|
|
|
|
|
+ <div class="app-container">
|
|
|
|
|
+ <!-- 搜索栏 -->
|
|
|
|
|
+ <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="80px">
|
|
|
|
|
+ <el-form-item label="客户姓名" prop="customerName">
|
|
|
|
|
+ <el-input v-model="queryParams.customerName" placeholder="请输入客户姓名" clearable size="small" @keyup.enter.native="handleQuery" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="电话" prop="phone">
|
|
|
|
|
+ <el-input v-model="queryParams.phone" placeholder="请输入电话" clearable size="small" @keyup.enter.native="handleQuery" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="客服姓名" prop="companyUserName">
|
|
|
|
|
+ <el-input v-model="queryParams.companyUserName" placeholder="请输入客服姓名" clearable size="small" @keyup.enter.native="handleQuery" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="建档时间">
|
|
|
|
|
+ <el-date-picker
|
|
|
|
|
+ v-model="dateRange"
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ style="width: 240px"
|
|
|
|
|
+ value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
|
|
+ type="daterange"
|
|
|
|
|
+ range-separator="-"
|
|
|
|
|
+ start-placeholder="开始日期"
|
|
|
|
|
+ end-placeholder="结束日期"
|
|
|
|
|
+ :default-time="['00:00:00', '23:59:59']"
|
|
|
|
|
+ ></el-date-picker>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item>
|
|
|
|
|
+ <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
|
|
+ <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-form>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 工具栏 -->
|
|
|
|
|
+ <el-row :gutter="10" class="mb8">
|
|
|
|
|
+ <el-col :span="1.5">
|
|
|
|
|
+ <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+ <el-col :span="1.5">
|
|
|
|
|
+ <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate">修改</el-button>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+ <el-col :span="1.5">
|
|
|
|
|
+ <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete">删除</el-button>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+ <el-col :span="1.5">
|
|
|
|
|
+ <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+ <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
|
|
+ </el-row>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 表格 -->
|
|
|
|
|
+ <el-table v-loading="loading" :data="customerList" @selection-change="handleSelectionChange">
|
|
|
|
|
+ <el-table-column type="selection" width="55" align="center" />
|
|
|
|
|
+ <el-table-column label="客户姓名" align="center" prop="customerName" />
|
|
|
|
|
+ <el-table-column label="性别" align="center" prop="sex" :formatter="sexFormat" />
|
|
|
|
|
+ <el-table-column label="年龄" align="center" prop="age" />
|
|
|
|
|
+ <el-table-column label="地址" align="center" prop="address" show-overflow-tooltip />
|
|
|
|
|
+ <el-table-column label="电话" align="center" prop="phone" />
|
|
|
|
|
+ <el-table-column label="建档时间" align="center" prop="filingTime" width="180">
|
|
|
|
|
+ <template slot-scope="scope">{{ parseTime(scope.row.filingTime) }}</template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ <el-table-column label="客服姓名" align="center" prop="companyUserName" />
|
|
|
|
|
+ <el-table-column label="负责医生" align="center" prop="doctorName" />
|
|
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
|
|
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ </el-table>
|
|
|
|
|
+
|
|
|
|
|
+ <pagination
|
|
|
|
|
+ v-show="total > 0"
|
|
|
|
|
+ :total="total"
|
|
|
|
|
+ :page.sync="queryParams.pageNum"
|
|
|
|
|
+ :limit.sync="queryParams.pageSize"
|
|
|
|
|
+ @pagination="getList"
|
|
|
|
|
+ />
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 新增/编辑弹窗(优化布局) -->
|
|
|
|
|
+ <el-dialog :title="title" :visible.sync="open" width="1100px" append-to-body :close-on-click-modal="false">
|
|
|
|
|
+ <el-form ref="form" :model="form" :rules="rules" label-width="100px" size="small">
|
|
|
|
|
+ <!-- 第一行:客户姓名、性别、年龄、电话 -->
|
|
|
|
|
+ <div style="display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 15px;">
|
|
|
|
|
+ <el-form-item label="客户姓名" prop="customerName" style="flex: 1; min-width: 140px; margin-bottom: 0;">
|
|
|
|
|
+ <el-input v-model="form.customerName" placeholder="请输入客户姓名" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="性别" prop="sex" style="flex: 0.6; min-width: 100px; margin-bottom: 0;">
|
|
|
|
|
+ <el-select v-model="form.sex" placeholder="请选择" style="width: 100%">
|
|
|
|
|
+ <el-option v-for="dict in sexOptions" :key="dict.value" :label="dict.label" :value="dict.value" />
|
|
|
|
|
+ </el-select>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="年龄" prop="age" style="flex: 0.7; min-width: 120px; margin-bottom: 0;">
|
|
|
|
|
+ <el-input-number
|
|
|
|
|
+ v-model="form.age"
|
|
|
|
|
+ :min="18"
|
|
|
|
|
+ :max="200"
|
|
|
|
|
+ placeholder="年龄"
|
|
|
|
|
+ controls-position="right"
|
|
|
|
|
+ style="width: 100%"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="电话" prop="phone" style="flex: 1.2; min-width: 150px; margin-bottom: 0;">
|
|
|
|
|
+ <el-input v-model="form.phone" placeholder="请输入电话" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 第二行:地址、建档时间 -->
|
|
|
|
|
+ <div style="display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 15px;">
|
|
|
|
|
+ <el-form-item label="地址" prop="address" style="flex: 2; min-width: 200px; margin-bottom: 0;">
|
|
|
|
|
+ <el-input v-model="form.address" placeholder="请输入地址" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="建档时间" prop="filingTime" style="flex: 1; min-width: 180px; margin-bottom: 0;">
|
|
|
|
|
+ <el-date-picker
|
|
|
|
|
+ v-model="form.filingTime"
|
|
|
|
|
+ type="datetime"
|
|
|
|
|
+ placeholder="选择建档时间"
|
|
|
|
|
+ value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
|
|
+ style="width: 100%"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 第三行:客服姓名、约诊时间、负责医生(新增时客服与医生只读,并带隐藏ID) -->
|
|
|
|
|
+ <div style="display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 15px;">
|
|
|
|
|
+ <el-form-item label="客服姓名" prop="companyUserName" style="flex: 1; min-width: 130px; margin-bottom: 0;">
|
|
|
|
|
+ <el-input v-model="form.companyUserName" placeholder="客服姓名" :disabled="!form.id" />
|
|
|
|
|
+ <!-- 隐藏的客服ID -->
|
|
|
|
|
+ <input type="hidden" v-model="form.companyUserId" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="约诊时间" prop="appointmentTime" style="flex: 1.2; min-width: 180px; margin-bottom: 0;">
|
|
|
|
|
+ <el-date-picker
|
|
|
|
|
+ v-model="form.appointmentTime"
|
|
|
|
|
+ type="datetime"
|
|
|
|
|
+ placeholder="选择约诊时间"
|
|
|
|
|
+ value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
|
|
+ style="width: 100%"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="负责医生" prop="doctorName" style="flex: 1; min-width: 130px; margin-bottom: 0;">
|
|
|
|
|
+ <el-input v-model="form.doctorName" placeholder="负责医生" :disabled="!form.id" />
|
|
|
|
|
+ <!-- 隐藏的医生ID -->
|
|
|
|
|
+ <input type="hidden" v-model="form.doctorId" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 独占行文本域 -->
|
|
|
|
|
+ <div style="margin-bottom: 15px;">
|
|
|
|
|
+ <el-form-item label="现病史" prop="presentIllness" style="margin-bottom: 0;">
|
|
|
|
|
+ <el-input type="textarea" v-model="form.presentIllness" placeholder="请输入现病史" :rows="3" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div style="margin-bottom: 15px;">
|
|
|
|
|
+ <el-form-item label="现用药情况" prop="currentMedication" style="margin-bottom: 0;">
|
|
|
|
|
+ <el-input type="textarea" v-model="form.currentMedication" placeholder="请输入现用药情况" :rows="3" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div style="margin-bottom: 0;">
|
|
|
|
|
+ <el-form-item label="过敏史" prop="allergyHistory" style="margin-bottom: 0;">
|
|
|
|
|
+ <el-input type="textarea" v-model="form.allergyHistory" placeholder="请输入过敏史" :rows="3" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-form>
|
|
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
|
|
+ <el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
|
|
+ <el-button @click="cancel">取 消</el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-dialog>
|
|
|
|
|
+ </div>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script>
|
|
|
|
|
+import {
|
|
|
|
|
+ listCustomer, getCustomer, addCustomer, updateCustomer, delCustomer, exportCustomer,
|
|
|
|
|
+ getCompanyUserAndDoctor
|
|
|
|
|
+} from '@/api/qw/companyCustomer'
|
|
|
|
|
+import { parseTime } from '@/utils/common'
|
|
|
|
|
+
|
|
|
|
|
+export default {
|
|
|
|
|
+ name: "Customer",
|
|
|
|
|
+ data() {
|
|
|
|
|
+ const validatePhone = (rule, value, callback) => {
|
|
|
|
|
+ if (!value) {
|
|
|
|
|
+ callback(new Error('电话号码不能为空'));
|
|
|
|
|
+ } else if (!/^1[3-9]\d{9}$/.test(value)) {
|
|
|
|
|
+ callback(new Error('请输入有效的手机号码'));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ callback();
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ const validateAge = (rule, value, callback) => {
|
|
|
|
|
+ if (value === null || value === undefined || value === '') {
|
|
|
|
|
+ callback(new Error('年龄不能为空'));
|
|
|
|
|
+ } else if (value < 18) {
|
|
|
|
|
+ callback(new Error('年龄必须大于等于18岁'));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ callback();
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ return {
|
|
|
|
|
+ loading: true,
|
|
|
|
|
+ ids: [],
|
|
|
|
|
+ single: true,
|
|
|
|
|
+ multiple: true,
|
|
|
|
|
+ showSearch: true,
|
|
|
|
|
+ total: 0,
|
|
|
|
|
+ customerList: [],
|
|
|
|
|
+ title: "",
|
|
|
|
|
+ open: false,
|
|
|
|
|
+ dateRange: [],
|
|
|
|
|
+ queryParams: {
|
|
|
|
|
+ pageNum: 1,
|
|
|
|
|
+ pageSize: 10,
|
|
|
|
|
+ customerName: null,
|
|
|
|
|
+ phone: null,
|
|
|
|
|
+ companyUserName: null
|
|
|
|
|
+ },
|
|
|
|
|
+ form: {},
|
|
|
|
|
+ rules: {
|
|
|
|
|
+ customerName: [{ required: true, message: "客户姓名不能为空", trigger: "blur" }],
|
|
|
|
|
+ sex: [{ required: true, message: "请选择性别", trigger: "change" }],
|
|
|
|
|
+ age: [
|
|
|
|
|
+ { required: true, message: "年龄不能为空", trigger: "blur" },
|
|
|
|
|
+ { validator: validateAge, trigger: "blur" }
|
|
|
|
|
+ ],
|
|
|
|
|
+ phone: [
|
|
|
|
|
+ { required: true, message: "电话不能为空", trigger: "blur" },
|
|
|
|
|
+ { validator: validatePhone, trigger: "blur" }
|
|
|
|
|
+ ],
|
|
|
|
|
+ filingTime: [{ required: true, message: "建档时间不能为空", trigger: "blur" }],
|
|
|
|
|
+ companyUserName: [{ required: true, message: "客服姓名不能为空", trigger: "blur" }],
|
|
|
|
|
+ doctorName: [{ required: true, message: "负责医生不能为空", trigger: "blur" }],
|
|
|
|
|
+ presentIllness: [{ required: true, message: "现病史不能为空", trigger: "blur" }],
|
|
|
|
|
+ currentMedication: [{ required: true, message: "现用药情况不能为空", trigger: "blur" }],
|
|
|
|
|
+ allergyHistory: [{ required: true, message: "过敏史不能为空", trigger: "blur" }]
|
|
|
|
|
+ },
|
|
|
|
|
+ sexOptions: [
|
|
|
|
|
+ { label: '女', value: '0' },
|
|
|
|
|
+ { label: '男', value: '1' },
|
|
|
|
|
+ { label: '未知', value: '2' }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ created() {
|
|
|
|
|
+ this.getList()
|
|
|
|
|
+ },
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ parseTime,
|
|
|
|
|
+ getList() {
|
|
|
|
|
+ this.loading = true;
|
|
|
|
|
+ listCustomer(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
|
|
|
|
+ const data = response; // 若依 request 解包后直接返回 data 对象
|
|
|
|
|
+ this.customerList = data.rows; // 数据在 rows 中
|
|
|
|
|
+ this.total = data.total; // 总记录数
|
|
|
|
|
+ this.loading = false;
|
|
|
|
|
+ }).catch(() => {
|
|
|
|
|
+ this.loading = false;
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ sexFormat(row) {
|
|
|
|
|
+ return this.sexOptions.find(o => o.value === row.sex)?.label ?? row.sex;
|
|
|
|
|
+ },
|
|
|
|
|
+ cancel() {
|
|
|
|
|
+ this.open = false;
|
|
|
|
|
+ this.reset();
|
|
|
|
|
+ },
|
|
|
|
|
+ reset() {
|
|
|
|
|
+ this.form = {
|
|
|
|
|
+ id: null,
|
|
|
|
|
+ customerName: null,
|
|
|
|
|
+ sex: '0',
|
|
|
|
|
+ age: 18,
|
|
|
|
|
+ address: null,
|
|
|
|
|
+ phone: null,
|
|
|
|
|
+ filingTime: null,
|
|
|
|
|
+ companyUserId: null,
|
|
|
|
|
+ companyUserName: null,
|
|
|
|
|
+ appointmentTime: null,
|
|
|
|
|
+ doctorId: null,
|
|
|
|
|
+ doctorName: null,
|
|
|
|
|
+ presentIllness: null,
|
|
|
|
|
+ currentMedication: null,
|
|
|
|
|
+ allergyHistory: null
|
|
|
|
|
+ };
|
|
|
|
|
+ this.resetForm("form");
|
|
|
|
|
+ },
|
|
|
|
|
+ handleQuery() {
|
|
|
|
|
+ this.queryParams.pageNum = 1;
|
|
|
|
|
+ this.getList();
|
|
|
|
|
+ },
|
|
|
|
|
+ resetQuery() {
|
|
|
|
|
+ this.dateRange = [];
|
|
|
|
|
+ this.resetForm("queryForm");
|
|
|
|
|
+ this.handleQuery();
|
|
|
|
|
+ },
|
|
|
|
|
+ handleSelectionChange(selection) {
|
|
|
|
|
+ this.ids = selection.map(item => item.id);
|
|
|
|
|
+ this.single = selection.length !== 1;
|
|
|
|
|
+ this.multiple = !selection.length;
|
|
|
|
|
+ },
|
|
|
|
|
+ handleAdd() {
|
|
|
|
|
+ this.reset();
|
|
|
|
|
+ getCompanyUserAndDoctor().then(response => {
|
|
|
|
|
+ const data = response.data;
|
|
|
|
|
+ if (data) {
|
|
|
|
|
+ this.form.companyUserId = data.companyUserId;
|
|
|
|
|
+ this.form.companyUserName = data.companyUserName;
|
|
|
|
|
+ this.form.doctorId = data.doctorId;
|
|
|
|
|
+ this.form.doctorName = data.doctorName;
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(() => {
|
|
|
|
|
+ this.$modal.msgError("获取销售与医生信息失败");
|
|
|
|
|
+ });
|
|
|
|
|
+ this.open = true;
|
|
|
|
|
+ this.title = "添加客户信息";
|
|
|
|
|
+ },
|
|
|
|
|
+ handleUpdate(row) {
|
|
|
|
|
+ this.reset();
|
|
|
|
|
+ const id = row.id || this.ids[0];
|
|
|
|
|
+ getCustomer(id).then(response => {
|
|
|
|
|
+ this.form = response.data;
|
|
|
|
|
+ if (this.form.sex !== undefined && this.form.sex !== null) {
|
|
|
|
|
+ this.form.sex = String(this.form.sex);
|
|
|
|
|
+ }
|
|
|
|
|
+ this.open = true;
|
|
|
|
|
+ this.title = "修改客户信息";
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ async submitForm() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const valid = await this.$refs["form"].validate();
|
|
|
|
|
+ if (!valid) return;
|
|
|
|
|
+ if (this.form.id != null) {
|
|
|
|
|
+ await updateCustomer(this.form);
|
|
|
|
|
+ this.$modal.msgSuccess("修改成功");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ await addCustomer(this.form);
|
|
|
|
|
+ this.$modal.msgSuccess("新增成功");
|
|
|
|
|
+ }
|
|
|
|
|
+ this.open = false;
|
|
|
|
|
+ this.getList();
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.warn("提交失败", e);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ handleDelete(row) {
|
|
|
|
|
+ const ids = row.id || this.ids.join(",");
|
|
|
|
|
+ this.$modal.confirm('是否确认删除该客户信息?').then(function() {
|
|
|
|
|
+ return delCustomer(ids);
|
|
|
|
|
+ }).then(() => {
|
|
|
|
|
+ this.getList();
|
|
|
|
|
+ this.$modal.msgSuccess("删除成功");
|
|
|
|
|
+ }).catch(() => {});
|
|
|
|
|
+ },
|
|
|
|
|
+ handleExport() {
|
|
|
|
|
+ this.$modal.confirm('是否确认导出所有客户信息?').then(() => {
|
|
|
|
|
+ return exportCustomer(this.addDateRange(this.queryParams, this.dateRange));
|
|
|
|
|
+ }).then(response => {
|
|
|
|
|
+ this.download(response.msg, "客户信息数据.xlsx");
|
|
|
|
|
+ }).catch(() => {});
|
|
|
|
|
+ },
|
|
|
|
|
+ download(content, fileName) {
|
|
|
|
|
+ const blob = new Blob([content]);
|
|
|
|
|
+ const url = window.URL.createObjectURL(blob);
|
|
|
|
|
+ const a = document.createElement('a');
|
|
|
|
|
+ a.href = url;
|
|
|
|
|
+ a.download = fileName;
|
|
|
|
|
+ a.click();
|
|
|
|
|
+ window.URL.revokeObjectURL(url);
|
|
|
|
|
+ },
|
|
|
|
|
+ addDateRange(params, dateRange) {
|
|
|
|
|
+ if (dateRange && dateRange.length === 2) {
|
|
|
|
|
+ params.beginTime = dateRange[0];
|
|
|
|
|
+ params.endTime = dateRange[1];
|
|
|
|
|
+ }
|
|
|
|
|
+ return params;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+<style scoped>
|
|
|
|
|
+.mb8 {
|
|
|
|
|
+ margin-bottom: 8px;
|
|
|
|
|
+}
|
|
|
|
|
+</style>
|