快递打单账号管理系统
This commit is contained in:
parent
188dbedbe6
commit
9c405513f4
27
src/api/modules/fastMail.js
Normal file
27
src/api/modules/fastMail.js
Normal file
@ -0,0 +1,27 @@
|
||||
import instance from '../../utils/axios.js'
|
||||
|
||||
// 过滤设置相关API
|
||||
const fastMailApi = {
|
||||
|
||||
//listFastMail, getFastMail, delFastMail, addFastMail, updateFastMail
|
||||
|
||||
listFastMail: (params) => instance.get('/fastMail/list', { params }),
|
||||
|
||||
// 获取过滤设置详细信息
|
||||
getFastMail: (id) => instance.get(`/fastMail/${id}`),
|
||||
|
||||
//删除
|
||||
delFastMail: (ids) => {
|
||||
const idStr = Array.isArray(ids) ? ids.join(',') : ids;
|
||||
instance.delete(`/fastMail/${idStr}`);
|
||||
},
|
||||
// 添加
|
||||
addFastMail: (data) => instance.post('/fastMail', data),
|
||||
|
||||
// 更新
|
||||
updateFastMail: (data) => instance.put('/fastMail', data)
|
||||
|
||||
};
|
||||
|
||||
// 导出模块
|
||||
export { fastMailApi };
|
||||
@ -139,6 +139,10 @@ const menuData = shallowRef([
|
||||
{
|
||||
title: '物流模板',
|
||||
path: '/warehouse/logistics'
|
||||
},
|
||||
{
|
||||
title: '快递打单账号管理',
|
||||
path: '/account/management'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@ -183,8 +183,17 @@ const routes = [{
|
||||
path: '/shop/pddGoods',
|
||||
component: () => import('@/views/pddGoods/index.vue'),
|
||||
meta: { title: '店铺商品' }
|
||||
},
|
||||
//快递打单账号管理 src/views/fastMail
|
||||
{
|
||||
path: '/account/management',
|
||||
component: () => import('@/views/fastMail/index.vue'),
|
||||
meta: { title: '货区管理', permission: 'warehouse:depot:view' }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
]
|
||||
}]
|
||||
|
||||
|
||||
480
src/views/fastMail/index.vue
Normal file
480
src/views/fastMail/index.vue
Normal file
@ -0,0 +1,480 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
|
||||
<div class="filter-set-container">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
|
||||
<!-- <el-form-item label="快递类型" prop="type">
|
||||
<el-select v-model="queryParams.type" placeholder="快递类型" clearable >
|
||||
<el-option v-for="dict in t_fast_mail_type" :key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||
</el-select>
|
||||
</el-form-item> -->
|
||||
|
||||
<el-form-item label="快递类型" prop="type">
|
||||
<el-select v-model="queryParams.type" filterable placeholder="请选择快递类型" style="width: 240px" clearable>
|
||||
|
||||
<el-option v-for="dict in t_fast_mail_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="创建时间" prop="createTime">
|
||||
<el-date-picker clearable
|
||||
v-model="queryParams.createTime"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择创建时间"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="更新时间" prop="updateTime">
|
||||
<el-date-picker clearable
|
||||
v-model="queryParams.updateTime"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择更新时间"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header >
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" >新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate(this)" >修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete(this)" >删除</el-button>
|
||||
</el-col>
|
||||
<!-- <el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['zhishu:fastMail:export']">导出</el-button>
|
||||
</el-col> -->
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="fastMailList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<!-- <el-table-column label="主键" align="center" prop="id" v-if="true" /> -->
|
||||
|
||||
<el-table-column label="快递类型" align="center" prop="type">
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.typetext}}</span>
|
||||
<!-- <dict-tag :options="t_fast_mail_type" :value="scope.row.typetext" /> -->
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="账号" align="center" prop="partnerId" />
|
||||
<el-table-column label="联调密码" align="center" prop="secret" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.createdTime}}</span>
|
||||
</template>
|
||||
|
||||
</el-table-column>
|
||||
<el-table-column label="更新时间" align="center" prop="updateTime" width="180">
|
||||
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.updatedTime}}</span>
|
||||
</template>
|
||||
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['zhishu:fastMail:edit']"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['zhishu:fastMail:remove']"></el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-card>
|
||||
|
||||
<!-- 添加或修改快递打单账号管理对话框 -->
|
||||
<el-dialog title="账号新增" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="fastMailFormRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="快递类型" prop="type">
|
||||
<el-select v-model="form.type" placeholder="请选择快递类型">
|
||||
<el-option
|
||||
v-for="dict in t_fast_mail_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="账号" prop="partnerId">
|
||||
<el-input v-model="form.partnerId" placeholder="请输入账号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="联调密码" prop="secret">
|
||||
<el-input v-model="form.secret" placeholder="请输入联调密码" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
<script setup>
|
||||
import { getCurrentInstance } from 'vue';
|
||||
import { ref, reactive, toRefs, onMounted } from 'vue';
|
||||
//import { listFastMail, getFastMail, delFastMail, addFastMail, updateFastMail } from '@/api/modules/fastMail';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { fastMailApi } from '@/api/modules/fastMail';
|
||||
const { proxy } = getCurrentInstance();
|
||||
|
||||
|
||||
|
||||
|
||||
//const { value, label } = toRefs(mail_type) // 解构后每个属性都是 ref
|
||||
|
||||
|
||||
|
||||
// 字典数据
|
||||
let t_fast_mail_type = ref([]);
|
||||
// 列表数据
|
||||
const fastMailList = ref([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref([]);
|
||||
const partnerIds = ref([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
|
||||
// 表单引用
|
||||
const queryFormRef = ref(null);
|
||||
const fastMailFormRef = ref(null);
|
||||
|
||||
// 对话框状态
|
||||
const dialog = reactive({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
// 初始化表单数据
|
||||
const initFormData = {
|
||||
id: undefined,
|
||||
type: undefined,
|
||||
partnerId: undefined,
|
||||
secret: undefined,
|
||||
status: undefined,
|
||||
};
|
||||
|
||||
// 响应式数据对象
|
||||
const data = reactive({
|
||||
form:initFormData,
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
type: undefined,
|
||||
partnerId: undefined,
|
||||
secret: undefined,
|
||||
createTime: undefined,
|
||||
updateTime: undefined,
|
||||
status: undefined,
|
||||
params: {}
|
||||
},
|
||||
rules: {
|
||||
id: [
|
||||
{ required: true, message: "主键不能为空", trigger: "blur" }
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
// 解构响应式数据
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询快递打单账号管理列表 */
|
||||
const getList = async () => {
|
||||
|
||||
loading.value = true;
|
||||
const res = await fastMailApi.listFastMail(queryParams.value);
|
||||
|
||||
fastMailList.value = res.data.list;
|
||||
console.log("fastMailList.value"+fastMailList.value);
|
||||
total.value = res.data.total;
|
||||
|
||||
|
||||
//循环给数组赋值
|
||||
for (const item of res.data.list) {
|
||||
try {
|
||||
//const result = await db.insert(item);
|
||||
let mail_type = reactive({ value: '', label: '' })
|
||||
mail_type.value=item.type;
|
||||
if("1"===item.type){
|
||||
mail_type.label="韵达";
|
||||
item.typetext="韵达"
|
||||
}if("2"===item.type){
|
||||
mail_type.label="圆通";
|
||||
item.typetext="圆通"
|
||||
}
|
||||
t_fast_mail_type.value.push(mail_type);
|
||||
|
||||
|
||||
|
||||
// console.log(`插入成功,ID:`+t_fast_mail_type);
|
||||
|
||||
//时间串串换
|
||||
// 正则匹配 14 位时间串(年4位+月2位+日2位+时2位+分2位+秒2位)
|
||||
let createdTime = `${JSON.stringify(item.createdTime).slice(0,4)}-${JSON.stringify(item.createdTime).slice(4,6)}-${JSON.stringify(item.createdTime).slice(6,8)} ${JSON.stringify(item.createdTime).slice(8,10)}:${JSON.stringify(item.createdTime).slice(10,12)}:${JSON.stringify(item.createdTime).slice(12,14)}`;
|
||||
|
||||
let updateTime = `${JSON.stringify(item.updatedTime).slice(0,4)}-${JSON.stringify(item.updatedTime).slice(4,6)}-${JSON.stringify(item.updatedTime).slice(6,8)} ${JSON.stringify(item.updatedTime).slice(8,10)}:${JSON.stringify(item.updatedTime).slice(10,12)}:${JSON.stringify(item.updatedTime).slice(12,14)}`;
|
||||
|
||||
//let updateTime = item.updateTime.match(regex);
|
||||
|
||||
// 2. 创建 Date 对象
|
||||
let createddate = new Date(createdTime);
|
||||
let updatedate = new Date(updateTime);
|
||||
|
||||
// 3. 提取年月日(自动补零)
|
||||
let year = createddate.getFullYear(); // 2025
|
||||
let month = String(createddate.getMonth() + 1).padStart(2, '0'); // 07(月份+1后补零)
|
||||
let day = String(createddate.getDate()).padStart(2, '0'); // 14(补零)
|
||||
|
||||
let updateyear = updatedate.getFullYear(); // 2025
|
||||
let updatemonth = String(updatedate.getMonth() + 1).padStart(2, '0'); // 07(月份+1后补零)
|
||||
let updateday = String(updatedate.getDate()).padStart(2, '0'); // 14(补零)
|
||||
|
||||
|
||||
// 4. 拼接结果
|
||||
let creatymd = `${year}-${month}-${day}`;
|
||||
|
||||
let updateymd = `${updateyear}-${updatemonth}-${updateday}`;
|
||||
item.createdTime=creatymd
|
||||
item.updatedTime=updateymd
|
||||
|
||||
|
||||
|
||||
|
||||
console.log(`插入成功:`+item);
|
||||
} catch (error) {
|
||||
console.error(`第 条失败,跳过:`, item);
|
||||
// 可选:continue 跳过当前项,或 break 终止循环
|
||||
}
|
||||
}
|
||||
|
||||
if(Array.isArray(t_fast_mail_type.value) && t_fast_mail_type.value.length > 0){
|
||||
const uniqueArrLast = uniqueByIdLast(t_fast_mail_type.value, 'value');
|
||||
console.log(uniqueArrLast);
|
||||
t_fast_mail_type=uniqueArrLast;
|
||||
console.log(t_fast_mail_type);
|
||||
|
||||
console.log(`t_fast_mail_type:`+t_fast_mail_type);
|
||||
}
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
|
||||
const uniqueByIdLast = (arr, key = 'value') => {
|
||||
console.log(arr)
|
||||
const map = new Map(); // 存储 key 到对象的映射
|
||||
arr.forEach(obj => {
|
||||
const currentKey = obj[key];
|
||||
if (currentKey !== undefined && currentKey !== null) {
|
||||
map.set(currentKey, obj); // 后续重复的会覆盖之前的
|
||||
}
|
||||
});
|
||||
return Array.from(map.values()); // 转换为数组
|
||||
};
|
||||
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
|
||||
Object.assign(form, initFormData);
|
||||
|
||||
fastMailFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection) => {
|
||||
|
||||
ids.value = selection.map(item => item.id);
|
||||
partnerIds.value=selection.map(item => item.partnerId);
|
||||
|
||||
single.value = selection.length !== 1;
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
reset();
|
||||
dialog.visible = true;
|
||||
dialog.title = "添加快递打单账号";
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row) => {
|
||||
|
||||
// reset();
|
||||
//resetForm();
|
||||
const _id = row?.id || ids.value[0];
|
||||
|
||||
try {
|
||||
const res = await fastMailApi.getFastMail(_id);
|
||||
if (res.code === 200 && res.data) {
|
||||
|
||||
Object.keys(form.value).forEach(key => {
|
||||
console.log(form.value)
|
||||
if (res.data[key] !== undefined) {
|
||||
console.log(res.data[key])
|
||||
form.value[key] = res.data[key]
|
||||
}
|
||||
dialog.visible = true;
|
||||
dialog.title = "修改快递打单账号";
|
||||
})
|
||||
console.log(form.value)
|
||||
} else {
|
||||
ElMessage.error(res.message || '获取过滤设置信息失败')
|
||||
dialogVisible.value = false
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
ElMessage.error(error.message || '获取过滤设置信息失败')
|
||||
dialogVisible.value = false
|
||||
}finally {
|
||||
// submitLoading.value = false
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Object.assign(form, res.data);
|
||||
// dialog.visible = true;
|
||||
// dialog.title = "修改快递打单账号";
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
fastMailFormRef.value?.validate(async (valid) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
|
||||
if (form.value.id) {
|
||||
await fastMailApi.updateFastMail(form.value).finally(() => { buttonLoading.value = false; });
|
||||
} else {
|
||||
|
||||
const newadd= await fastMailApi.addFastMail(form.value);
|
||||
debugger;
|
||||
console.log(newadd);
|
||||
if (newadd.code === 200 && newadd.data) {
|
||||
ElMessage.success("操作成功")
|
||||
}else{
|
||||
ElMessage.confirm(res.test)
|
||||
}
|
||||
}
|
||||
// proxy.$modal.msgSuccess("操作成功");
|
||||
|
||||
|
||||
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row) => {
|
||||
|
||||
// const partnerIds=row?.partnerId || ids.partnerId;
|
||||
const _ids = row?.id || ids.value;
|
||||
await ElMessageBox.confirm(`是否确认删除快递打单账号管理编号为"${partnerIds.value}"的数据项?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
await fastMailApi.delFastMail(_ids);
|
||||
|
||||
ElMessage.success("删除成功")
|
||||
await getList();
|
||||
};
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
proxy.download('zhishu/fastMail/export', {
|
||||
...queryParams.value
|
||||
}, `fastMail_${new Date().getTime()}.xlsx`);
|
||||
};
|
||||
|
||||
|
||||
// 重置表单
|
||||
const resetForm = () => {
|
||||
if (fastMailFormRef.value) {
|
||||
fastMailFormRef.value.resetFields()
|
||||
}
|
||||
|
||||
Object.keys(form).forEach(key => {
|
||||
if (key === 'id') {
|
||||
form[key] = null
|
||||
} else if (key === 'addWay') {
|
||||
form[key] = '0'
|
||||
} else {
|
||||
form[key] = ''
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<style scoped>
|
||||
.filter-set-container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user