快递打单账号管理系统

This commit is contained in:
Ygb 2025-08-26 14:55:40 +08:00
parent 188dbedbe6
commit 9c405513f4
4 changed files with 520 additions and 0 deletions

View 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 };

View File

@ -139,6 +139,10 @@ const menuData = shallowRef([
{ {
title: '物流模板', title: '物流模板',
path: '/warehouse/logistics' path: '/warehouse/logistics'
},
{
title: '快递打单账号管理',
path: '/account/management'
} }
] ]
}, },

View File

@ -183,8 +183,17 @@ const routes = [{
path: '/shop/pddGoods', path: '/shop/pddGoods',
component: () => import('@/views/pddGoods/index.vue'), component: () => import('@/views/pddGoods/index.vue'),
meta: { title: '店铺商品' } meta: { title: '店铺商品' }
},
//快递打单账号管理 src/views/fastMail
{
path: '/account/management',
component: () => import('@/views/fastMail/index.vue'),
meta: { title: '货区管理', permission: 'warehouse:depot:view' }
} }
] ]
}] }]

View 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>