Browse Source

封装消息函数

dev-xx
马远东 1 year ago
parent
commit
d835185933
  1. 13
      src/api/basicdata/basicdataFreight.js
  2. 67
      src/utils/poptxt.js
  3. 120
      src/views/basicdata/brand/basicdataFreight.vue
  4. 67
      src/views/basicdata/brand/basicdataFreightFrom.vue

13
src/api/basicdata/basicdataFreight.js

@ -85,4 +85,15 @@ export const $_getDeptLazyTree = params => {
method: 'get',
params
});
};
};
export const $_basicdataFreight = (row) => {
return request({
url: '/api/logpm-basicdata/basicdataFreight/import',
method: 'post',
data: row
})
}

67
src/utils/poptxt.js

@ -0,0 +1,67 @@
import { ElMessage } from 'element-plus' // 引入 ElMessage 组件
export function popmsg(res) {
// 显示成功消息
if (res.msg == '导入成功') {
ElMessage({
message: res.msg,
type: 'success',
});
return;
}else{
// 创建包含 p 标签的内容的 div 元素
var fragment = document.createDocumentFragment();
var div = document.createElement('div');
div.id = 'createdDiv';
var timeout; // 用于设置定时器
// 设置 div 样式
div.style.zIndex = '9999';
div.style.position = 'fixed';
div.style.fontSize = '16px';
div.style.top = '50%';
div.style.left = '50%';
div.style.transform = 'translate(-50%, -50%)';
div.style.width = '50%';
div.style.height = '200px';
div.style.backgroundColor = '#ffffff';
div.style.borderRadius = '4px';
div.style.overflow = 'scroll';
div.style.border = '1px solid #ccc';
div.style.padding = '10px';
// 将后端返回的内容作为 HTML 插入到 div 中
div.innerHTML = res.msg;
// 遍历所有的 <p> 标签并设置首行缩进
var pTags = div.querySelectorAll('p');
pTags.forEach(function (pTag) {
pTag.style.textIndent = '2em';
});
fragment.appendChild(div);
// 添加鼠标事件监听
// div.addEventListener('mouseover', function () {
// clearTimeout(timeout); // 清除自动消失的定时器
// });
// div.addEventListener('mouseout', function () {
// timeout = setTimeout(function () {
// div.remove(); // 3 秒后自动消失
// }, 3000);
// });
document.body.appendChild(fragment);
// 初始化定时器
// timeout = setTimeout(function () {
// div.remove(); // 自动消失
// }, 3000);
function closePopupOnClickOutside(event) {
if (div && !div.contains(event.target)) {
div.remove(); // 点击弹窗之外的地方,移除弹窗
document.removeEventListener('click', closePopupOnClickOutside); // 移除监听器
}
}
// 添加点击事件监听
document.addEventListener('click', closePopupOnClickOutside);
}
}

120
src/views/basicdata/brand/basicdataFreight.vue

@ -10,6 +10,7 @@
:permission="permissionList"
:before-open="beforeOpen"
ref="crud"
:upload-after="uploadAfter"
@row-update="rowUpdate"
@row-save="rowSave"
@row-del="rowDel"
@ -38,8 +39,14 @@
@click="handleDelete"
>
</el-button>
<el-button icon="UploadFilled" type="danger" plain @click="handleImport"> </el-button>
<el-button type="danger" plain @click="UploadTemplate">导入数据</el-button>
<el-button type="danger" plain @click="DownloadTemplate">下载模板</el-button>
<!-- <el-button
type="danger"
plain
@click="ExportPrice"
>
</el-button> -->
<!-- <el-button type="warning"
plain
icon="el-icon-download"
@ -150,15 +157,27 @@
</template>
</el-dialog>
<el-dialog title="用户基础价格导入" append-to-body v-model="excelBox" width="555px">
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
<template #excelTemplate>
<el-button type="primary" @click="handleTemplate">
点击下载<i class="el-icon-download el-icon--right"></i>
</el-button>
</template>
</avue-form>
<el-dialog v-model="SCdialogVisible" title="数据导入" width="500">
<el-upload
class="upload-demo"
drag
action="/api/logpm-basicdata/basicdataFreight/import"
multiple
:headers="doubledCount"
:on-success="doubledCountSuce"
>
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
<div class="el-upload__text">上传EXCEL文档 <em>click to upload</em></div>
</el-upload>
<template #footer>
<div class="dialog-footer">
<el-button @click="SCdialogVisible = false">关闭</el-button>
</div>
</template>
</el-dialog>
<div id="content"></div>
</basic-container>
</template>
@ -173,17 +192,20 @@ import {
$_brand,
$_category,
$_getDeptLazyTree,
$_basicdataFreight,
} from '@/api/basicdata/basicdataFreight';
// import option from "@/option/basicdata/basicdataFreight";
import { ElMessage } from 'element-plus';
import { mapGetters } from 'vuex';
import { exportBlob } from '@/api/common';
import { getDictionaryBiz } from '@/api/system/dict'; //
import { getToken } from '@/utils/auth';
import { popmsg } from '@/utils/poptxt';
import { downloadXls } from '@/utils/util';
import { dateNow } from '@/utils/date';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
import { ElNotification } from 'element-plus';
export default {
data() {
return {
@ -193,6 +215,7 @@ export default {
excelBox: false,
excelForm: {},
loading: true,
SCdialogVisible: false,
Detailspop: false,
excelOption: {
submitBtn: false,
@ -209,7 +232,7 @@ export default {
res: 'data',
},
tip: '请上传 .xls,.xlsx 标准格式文件',
action: '/api/logpm-basicdata/driverArtery/import-stockArticle',
action: '/api/logpm-basicdata/basicdataFreight/import',
},
{
label: '模板下载',
@ -639,6 +662,7 @@ export default {
data: [],
};
},
created() {
//
// updateDictionary(targetArray, dictionaryType) {
@ -702,25 +726,30 @@ export default {
});
return ids.join(',');
},
doubledCount() {
return { 'Blade-Auth': 'Bearer ' + getToken() };
},
},
methods: {
//
doubledCountSuce(res) {
popmsg(res);
},
uploadAfter(res, done, loading, column) {
console.log('121221');
window.console.log(column);
console.log(res, 'res');
this.excelBox = false;
this.refreshChange();
done();
this.$message.success('上传成功');
},
//
handleTemplate() {
console.log('下载模板!!!');
exportBlob(
`/api/logpm-basicdata/driverArtery/export-basicdataDriverArteryMb?${
this.website.tokenHeader
}=${getToken()}`
).then(res => {
downloadXls(res.data, '用户基础价格导入模板.xlsx');
});
success(res) {
console.log(res);
},
//
handleTemplate() {},
fuzhi(led, ed) {
// console.log(">>>>",led,ed);
this.option.column[27].dicData = led;
@ -957,6 +986,36 @@ export default {
handleImport() {
this.excelBox = true;
},
//
UploadTemplate() {
this.SCdialogVisible = true;
// $_basicdataFreight().then(res=>{
// console.log(res,'');
// })
},
//
DownloadTemplate() {
var notification = ElNotification({
title: '下载通知',
message: '正在下载中',
type: 'info',
});
console.log('下载模板!!!');
exportBlob(
`/api/logpm-basicdata/basicdataFreight/export-basicdataFreight?${
this.website.tokenHeader
}=${getToken()}&templateFlag=1`
).then(res => {
ElMessage({
message: '下载成功',
type: 'success',
});
notification.close();
downloadXls(res.data, '用户基础价格导入模板.xlsx');
});
},
//
ExportPrice() {},
onLoad(page, params = {}) {
this.loading = true;
@ -1074,4 +1133,21 @@ export default {
flex-direction: row;
flex-wrap: nowrap !important;
}
#createdDiv {
z-index: 9999;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 50%;
height: 200px;
background-color: #ffffff;
overflow: scroll;
padding: 10px;
border-radius: 4px;
font-size: 16px;
br {
margin-top: 10px;
}
}
</style>

67
src/views/basicdata/brand/basicdataFreightFrom.vue

@ -4,7 +4,7 @@
<el-form :disabled="view" ref="form" :model="form" label-width="120px" :rules="rules">
<el-row :gutter="20">
<el-col :span="10">
<el-form-item label="客户名称" prop="province">
<el-form-item label="客户名称" prop="clientIds">
<el-select
style="width: 100%"
v-model="form.clientIds"
@ -26,7 +26,7 @@
</el-form-item>
</el-col>
<el-col :span="10">
<el-form-item label="品牌" prop="goalGranary">
<el-form-item label="品牌" prop="brand">
<el-select
style="width: 100%"
v-model="form.brand"
@ -93,7 +93,7 @@
</el-form-item>
</el-col> -->
<el-col :span="10" v-if="buyNow && eachRide">
<el-form-item label="品类" prop="brand">
<el-form-item label="品类" prop="category">
<el-cascader
:props="propsType"
:show-all-levels="false"
@ -104,10 +104,10 @@
</el-form-item>
</el-col>
<el-col :span="10">
<el-form-item label="发货单位" prop="province">
<el-form-item label="发货单位" prop="forwardingUnitId">
<el-select
style="width: 100%"
v-model="form.forwarding"
v-model="form.forwardingUnitId"
filterable
remote
reserve-keyword
@ -126,7 +126,7 @@
</el-form-item>
</el-col>
<el-col :span="10" v-if="buyNow && eachRide">
<el-form-item label="生效时间" prop="brand">
<el-form-item label="生效时间" prop="effectiveTime">
<el-date-picker
style="width: 100%"
v-model="form.effectiveTime"
@ -138,7 +138,7 @@
</el-form-item>
</el-col>
<el-col :span="10" v-if="buyNow && eachRide">
<el-form-item label="截止时间" prop="brand">
<el-form-item label="截止时间" prop="expirationTime">
<el-date-picker
style="width: 100%"
v-model="form.expirationTime"
@ -151,7 +151,7 @@
</el-col>
<el-col :span="10" v-if="buyNow && eachRide">
<el-form-item label="服务类型" prop="goalGranary">
<el-form-item label="服务类型" prop="typeService">
<el-select
v-model="form.typeService"
multiple
@ -323,7 +323,7 @@ import { mapGetters } from 'vuex';
import { getDetail, add, update } from '@/api/basicdata/basicdataFreight';
export default {
name: 'basicdataFreightFrom',
name: 'forwardingUnitId',
data() {
return {
able: '',
@ -379,10 +379,36 @@ export default {
//
form: {},
rules: {
// province: [
// { required: true, message: '', trigger: 'blur' },
// // { min: 3, max: 5, message: ' 3 5 ', trigger: 'blur' }
// ],
clientIds: [
{ required: true, message: '请输入客户名称', trigger: 'blur' },
// { min: 3, max: 5, message: ' 3 5 ', trigger: 'blur' }
],
forwardingUnitId: [
{ required: true, message: '请输入发货单位', trigger: 'blur' },
// { min: 3, max: 5, message: ' 3 5 ', trigger: 'blur' }
],
brand: [
{ required: true, message: '请输入品牌', trigger: 'blur' },
// { min: 3, max: 5, message: ' 3 5 ', trigger: 'blur' }
],
category: [
{ required: true, message: '请选择品类', trigger: 'blur' },
// { min: 3, max: 5, message: ' 3 5 ', trigger: 'blur' }
],
effectiveTime: [
{ required: true, message: '请选择生效时间', trigger: 'blur' },
// { min: 3, max: 5, message: ' 3 5 ', trigger: 'blur' }
],
expirationTime: [
{ required: true, message: '请选择截至时间', trigger: 'blur' },
// { min: 3, max: 5, message: ' 3 5 ', trigger: 'blur' }
],
typeService: [
{ required: true, message: '请选择服务类型', trigger: 'blur' },
// { min: 3, max: 5, message: ' 3 5 ', trigger: 'blur' }
],
},
propsType: {
lazy: true,
@ -531,12 +557,15 @@ export default {
}).filter(item => item !== null); // null
console.log(matchedData,'筛选出来的值');
this.form.categoryName = matchedData.map(res=>res.name).join(',')
console.log(this.sendgoods,'发货单位');
console.log(this.form.forwardingUnitId,'当前发货单位');
this.form.name = this.CustomerName.find(res=>res.id==this.form.clientIds).clientName;//
this.form.sendgoods=this.sendgoods.find(res=>res.id==this.form.forwarding).clientName;//
this.form.forwardingUnitName=this.sendgoods.find(res=>res.id==this.form.forwardingUnitId).clientName;//
this.form.brandName= this.brandList.find(res=>res.brandId==this.form.brand).brandName;//
this.form.fixedPrice='0'
console.log('提交的数据》》》', this.form);
add(this.form).then(() => {
this.$store.commit('DEL_TAG_CURRENT'); //
this.$router.push('/basicdata/brand/basicdataFreight'); //
@ -620,6 +649,14 @@ export default {
this.buyNow = true;
}
},
// // TOKEN
// const headers = computed(() => {
// return { 'Blade-Auth': 'Bearer ' + getToken() };
// });
// //
// const doubledCount = computed(() => {
// return '/api/blade-resource/oss/endpoint/put-file';
// });
choiceRide(a) {
//
console.log(a);

Loading…
Cancel
Save