|
|
@@ -219,6 +219,25 @@
|
|
|
>导出</el-button
|
|
|
>
|
|
|
</el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ plain
|
|
|
+ icon="el-icon-upload2"
|
|
|
+ size="mini"
|
|
|
+ @click="handleImport"
|
|
|
+ :loading="importLoading"
|
|
|
+ >导入</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="success"
|
|
|
+ plain
|
|
|
+ icon="el-icon-download"
|
|
|
+ size="mini"
|
|
|
+ @click="downloadTemplate"
|
|
|
+ >下载导入模板</el-button>
|
|
|
+ </el-col>
|
|
|
<el-col :span="1.5">
|
|
|
<el-button type="primary" plain size="mini" @click="handleSync"
|
|
|
>同步</el-button
|
|
|
@@ -1382,7 +1401,7 @@
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
|
|
|
- <!-- 制单弹窗 -->
|
|
|
+ <!-- 问答弹窗 -->
|
|
|
<el-dialog
|
|
|
:title="template.title"
|
|
|
:visible.sync="template.open"
|
|
|
@@ -1477,7 +1496,8 @@ import {
|
|
|
addBuyTimes,
|
|
|
updateScrmPrescriptionDocumentSuccess,
|
|
|
improve,
|
|
|
- getScrmPrescribeInfo
|
|
|
+ getScrmPrescribeInfo,
|
|
|
+ importCustomer
|
|
|
} from "@/api/qw/companyCustomer";
|
|
|
import { parseTime } from "@/utils/common";
|
|
|
import { getCitys } from "@/api/hisStore/city";
|
|
|
@@ -1565,6 +1585,7 @@ export default {
|
|
|
}
|
|
|
};
|
|
|
return {
|
|
|
+ importLoading: false,
|
|
|
templateForm: {
|
|
|
id: null,
|
|
|
answers: [],
|
|
|
@@ -1807,6 +1828,86 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
methods: {
|
|
|
+ /** 下载导入模板 */
|
|
|
+ downloadTemplate() {
|
|
|
+ // 模板文件路径(放在 public/template/ 目录下)
|
|
|
+ const templateUrl = '/template/customer_import_template.xlsx';
|
|
|
+ // 下载时的文件名
|
|
|
+ const fileName = '客户导入模板.xlsx';
|
|
|
+
|
|
|
+ // 创建隐藏的 a 标签触发下载
|
|
|
+ const link = document.createElement('a');
|
|
|
+ link.style.display = 'none';
|
|
|
+ link.href = templateUrl;
|
|
|
+ link.download = fileName;
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+ document.body.removeChild(link);
|
|
|
+ },
|
|
|
+ // 导入客户数据
|
|
|
+ handleImport() {
|
|
|
+ // 创建一个隐藏的 file input
|
|
|
+ const input = document.createElement('input');
|
|
|
+ input.type = 'file';
|
|
|
+ input.accept = '.xlsx,.xls';
|
|
|
+ input.style.display = 'none';
|
|
|
+ document.body.appendChild(input);
|
|
|
+
|
|
|
+ input.onchange = (e) => {
|
|
|
+ const file = e.target.files[0];
|
|
|
+ if (!file) {
|
|
|
+ document.body.removeChild(input);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查文件类型
|
|
|
+ const ext = file.name.split('.').pop().toLowerCase();
|
|
|
+ if (!['xlsx', 'xls'].includes(ext)) {
|
|
|
+ this.$message.error('请上传 Excel 文件(.xlsx 或 .xls)');
|
|
|
+ document.body.removeChild(input);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构建 FormData
|
|
|
+ const formData = new FormData();
|
|
|
+ formData.append('file', file);
|
|
|
+
|
|
|
+ this.importLoading = true;
|
|
|
+ importCustomer(formData)
|
|
|
+ .then(response => {
|
|
|
+ if (response.code === 200) {
|
|
|
+ const result = response.data;
|
|
|
+ let msg = `成功导入 ${result.success} 条`;
|
|
|
+ if (result.errors && result.errors.length > 0) {
|
|
|
+ // 有错误信息,显示详细错误
|
|
|
+ const errorMsg = result.errors.join('\n');
|
|
|
+ this.$alert(errorMsg, '导入结果(部分失败)', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ type: 'warning',
|
|
|
+ dangerouslyUseHTMLString: false
|
|
|
+ });
|
|
|
+ msg += `,失败 ${result.errors.length} 条`;
|
|
|
+ } else {
|
|
|
+ this.$message.success(msg);
|
|
|
+ }
|
|
|
+ // 刷新列表
|
|
|
+ this.getList();
|
|
|
+ } else {
|
|
|
+ this.$message.error(response.msg || '导入失败');
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ this.$message.error(error.message || '导入请求失败');
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ this.importLoading = false;
|
|
|
+ document.body.removeChild(input);
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ // 触发文件选择
|
|
|
+ input.click();
|
|
|
+ },
|
|
|
|
|
|
handlePrescribeData(row){
|
|
|
// 2. 弹出确认框
|
|
|
@@ -2077,17 +2178,17 @@ export default {
|
|
|
this.createOrder.open = false;
|
|
|
this.createOrderReset();
|
|
|
// 调用增加客户购买次数接口
|
|
|
- if (this.currentCustomerId) {
|
|
|
- addBuyTimes(this.currentCustomerId).catch((err) => {
|
|
|
- console.error("增加购买次数失败", err);
|
|
|
- // 不阻塞主流程,仅记录错误
|
|
|
- });
|
|
|
- //制单成功更新商城处方表的制单状态为"已制单"
|
|
|
- updateScrmPrescriptionDocumentSuccess(this.currentCustomerId).catch((err) => {
|
|
|
- console.error("更新商城处方制单状态失败", err);
|
|
|
- // 不阻塞主流程,仅记录错误
|
|
|
- });
|
|
|
- }
|
|
|
+ // if (this.currentCustomerId) {
|
|
|
+ // addBuyTimes(this.currentCustomerId).catch((err) => {
|
|
|
+ // console.error("增加购买次数失败", err);
|
|
|
+ // // 不阻塞主流程,仅记录错误
|
|
|
+ // });
|
|
|
+ // //制单成功更新商城处方表的制单状态为"已制单"
|
|
|
+ // updateScrmPrescriptionDocumentSuccess(this.currentCustomerId).catch((err) => {
|
|
|
+ // console.error("更新商城处方制单状态失败", err);
|
|
|
+ // // 不阻塞主流程,仅记录错误
|
|
|
+ // });
|
|
|
+ // }
|
|
|
//根据搜索表单刷新列表
|
|
|
this.getList();
|
|
|
// 弹出提示确认框
|