9 changed files with 1569 additions and 11 deletions
@ -0,0 +1,28 @@
|
||||
import request from '@/axios'; |
||||
|
||||
/** 获取页面数据 */ |
||||
export const postPageList = (data = {}) => { |
||||
return request({ |
||||
url: '/api/logpm-basicdata/forwardingUnit/pageList', |
||||
method: 'post', |
||||
data, |
||||
}); |
||||
}; |
||||
|
||||
/** 新增编辑默认发货单位 */ |
||||
export const postEditUnit = (data = {}) => { |
||||
return request({ |
||||
url: '/api/logpm-basicdata/forwardingUnit/editUnit', |
||||
method: 'post', |
||||
data, |
||||
}); |
||||
}; |
||||
|
||||
/** 删除默认发货单位 */ |
||||
export const postRemoveUnit = (data = {}) => { |
||||
return request({ |
||||
url: '/api/logpm-basicdata/forwardingUnit/removeUnit', |
||||
method: 'post', |
||||
data, |
||||
}); |
||||
}; |
@ -0,0 +1,49 @@
|
||||
export const columnList = [ |
||||
{ |
||||
prop: '', |
||||
label: '复选框', |
||||
type: 0, |
||||
width: 55, |
||||
fixed: true, |
||||
}, |
||||
{ |
||||
prop: '', |
||||
label: '序号', |
||||
type: 12, |
||||
values: '', |
||||
width: 55, |
||||
fixed: true, |
||||
}, |
||||
{ |
||||
label: '仓库名称', |
||||
prop: 'warehouseName', |
||||
type: 2, |
||||
values: '', |
||||
width: '150', |
||||
checkarr: [], |
||||
fixed: false, |
||||
sortable: true, |
||||
isTitleSearch: false, |
||||
}, |
||||
{ |
||||
label: '客户名称', |
||||
prop: 'clientName', |
||||
type: 2, |
||||
values: '', |
||||
width: '150', |
||||
checkarr: [], |
||||
fixed: false, |
||||
sortable: true, |
||||
isTitleSearch: false, |
||||
}, |
||||
{ |
||||
label: '操作', |
||||
prop: '', |
||||
type: 6, |
||||
values: '', |
||||
width: '150', |
||||
checkarr: [], |
||||
fixed: false, |
||||
sortable: true, |
||||
}, |
||||
]; |
@ -0,0 +1,699 @@
|
||||
<template> |
||||
<basic-container v-loading="details.loadingObj.pageLoading"> |
||||
<div class="avue-crud"> |
||||
<!-- 搜索模块 --> |
||||
<div v-h5uShow="!search"> |
||||
<!-- 查询模块 --> |
||||
<el-form :inline="true" :model="query" class="header_search"> |
||||
<template v-for="item in details.columnList" :key="item.prop"> |
||||
<el-form-item v-if="item.isTitleSearch" :label="item.label"> |
||||
<!-- 普通输入框 --> |
||||
<template v-if="item.type === 2"> |
||||
<el-input |
||||
class="w100" |
||||
:placeholder="`请输入${item.label}`" |
||||
v-model="details.query[item.prop]" |
||||
clearable |
||||
></el-input> |
||||
</template> |
||||
|
||||
<!-- 下拉框 --> |
||||
<template v-else-if="item.type === 3"> |
||||
<el-select |
||||
v-model="details.query[item.prop.replace('Name', '')]" |
||||
:placeholder="`请选择${item.label}`" |
||||
class="w100" |
||||
clearable |
||||
filterable |
||||
@change=" |
||||
val => { |
||||
!val && delete details.query[item.prop.replace('Name', '')]; |
||||
} |
||||
" |
||||
:multiple="item.multiple || false" |
||||
> |
||||
<el-option |
||||
v-for="val in item.checkarr" |
||||
:key="val.value" |
||||
:label="val.label" |
||||
:value="val.value" |
||||
/> |
||||
</el-select> |
||||
</template> |
||||
</el-form-item> |
||||
</template> |
||||
|
||||
<!-- 查询按钮 --> |
||||
<el-form-item class="el-btn"> |
||||
<el-button type="primary" icon="el-icon-search" @click="searchChange">搜 索</el-button> |
||||
<el-button icon="el-icon-delete" @click="searchReset">清 空</el-button> |
||||
</el-form-item> |
||||
</el-form> |
||||
</div> |
||||
|
||||
<div class="avue-crud__header"> |
||||
<!-- 头部左侧按钮模块 --> |
||||
<div class="avue-crud__left"> |
||||
<el-button type="primary" icon="Plus" @click="handleAdd">新 增</el-button> |
||||
<el-button type="primary" icon="Delete" @click="handleBatchDelete">批量删除</el-button> |
||||
</div> |
||||
<!-- 头部右侧按钮模块 --> |
||||
<div class="avue-crud__right"> |
||||
<el-button icon="Download" @click="handleExportData" circle></el-button> |
||||
<el-button icon="el-icon-refresh" @click="searchChange" circle></el-button> |
||||
<el-button icon="Operation" @click="showdrawer(true)" circle></el-button> |
||||
<el-button icon="Search" @click="searchHide" circle></el-button> |
||||
</div> |
||||
</div> |
||||
|
||||
<!-- 表格 --> |
||||
<tablecmt |
||||
ref="tableNodeRef" |
||||
:columnList="details.columnList" |
||||
:tableData="details.data" |
||||
:loading="details.loadingObj.list" |
||||
@inputTxt="inputsc" |
||||
@timeCheck="timesc" |
||||
@selectCheck="selectsc" |
||||
@selection="selectionChange" |
||||
> |
||||
<template #default="slotProps"> |
||||
<template v-if="slotProps.scope.column.label === '操作'"> |
||||
<!-- 车次详情 --> |
||||
<el-text @click="() => handleEdit(slotProps.scope)"> 编 辑 </el-text> |
||||
<el-text @click="() => handleDelete(slotProps.scope)"> 删 除 </el-text> |
||||
</template> |
||||
</template> |
||||
</tablecmt> |
||||
|
||||
<!-- 分页模块 --> |
||||
<div class="avue-crud__pagination flex-c-sb mt10" style="width: 100%"> |
||||
<div style="font-size: 14px">勾选数量: {{ selectionList.length }}</div> |
||||
<!-- 分页模块 --> |
||||
<el-pagination |
||||
align="right" |
||||
background |
||||
@size-change="sizeChange" |
||||
@current-change="currentChange" |
||||
:current-page="page.pageNum" |
||||
:page-sizes="[30, 50, 80, 120, 5000]" |
||||
:page-size="page.pageSize" |
||||
layout="total, sizes, prev, pager, next, jumper" |
||||
:total="page.total" |
||||
> |
||||
</el-pagination> |
||||
</div> |
||||
|
||||
<!-- 新增 --> |
||||
<el-dialog |
||||
destroy-on-close |
||||
:modal-append-to-body="false" |
||||
:append-to-body="false" |
||||
:title="details.title" |
||||
width="50%" |
||||
v-model="details.popUpShow.addVisited" |
||||
draggable |
||||
align-center |
||||
> |
||||
<div v-loading="details.loadingObj.addTagLoading"> |
||||
<el-form ref="ruleFormRef" :model="details.form" inline label-width="100px"> |
||||
<el-form-item |
||||
label="品类" |
||||
style="width: 350px" |
||||
:rules="[ |
||||
{ |
||||
required: true, |
||||
message: '请选择品类', |
||||
trigger: ['blur', 'change'], |
||||
}, |
||||
]" |
||||
prop="categoryId" |
||||
> |
||||
<!-- 下拉框 --> |
||||
<el-select |
||||
v-model="details.form.categoryId" |
||||
placeholder="请选择" |
||||
class="w100" |
||||
clearable |
||||
filterable |
||||
remote |
||||
reserve-keyword |
||||
default-first-option |
||||
:remote-method="value => debounce(getMaterialTree(value), 500)" |
||||
@change="() => handleChange(details.materialArr, 'categoryId', 'category')" |
||||
> |
||||
<el-option |
||||
v-for="val in details.materialArr" |
||||
:key="val.id" |
||||
:label="val.name" |
||||
:value="val.id" |
||||
/> |
||||
</el-select> |
||||
</el-form-item> |
||||
|
||||
<el-form-item |
||||
label="主体" |
||||
style="width: 350px" |
||||
:rules="[ |
||||
{ |
||||
required: true, |
||||
message: '请选择主体', |
||||
trigger: ['blur', 'change'], |
||||
}, |
||||
]" |
||||
prop="mainId" |
||||
> |
||||
<!-- 下拉框 --> |
||||
<el-select |
||||
v-model="details.form.mainId" |
||||
placeholder="请选择" |
||||
class="w100" |
||||
clearable |
||||
filterable |
||||
remote |
||||
reserve-keyword |
||||
default-first-option |
||||
:remote-method="value => debounce(getMainList(value), 500)" |
||||
@change="() => handleChange(details.mainList, 'mainId', 'mainName')" |
||||
> |
||||
<el-option |
||||
v-for="val in details.mainList" |
||||
:key="val.id" |
||||
:label="val.name" |
||||
:value="val.id" |
||||
/> |
||||
</el-select> |
||||
</el-form-item> |
||||
</el-form> |
||||
</div> |
||||
|
||||
<div class="flex-c-c dialog-footer"> |
||||
<el-button icon="Close" @click="details.popUpShow.addVisited = false"> 取 消 </el-button> |
||||
|
||||
<!-- 提交 --> |
||||
<el-button |
||||
icon="Position" |
||||
type="primary" |
||||
:loading="details.loadingObj.addTagLoading" |
||||
@click="handleSubmit" |
||||
> |
||||
提 交 |
||||
</el-button> |
||||
</div> |
||||
</el-dialog> |
||||
</div> |
||||
</basic-container> |
||||
|
||||
<MyPrint |
||||
width="780px" |
||||
:html="details.html" |
||||
v-model="details.popUpShow.dialogVisible" |
||||
:isShowExport="false" |
||||
/> |
||||
|
||||
<!-- 列表配置显示 --> |
||||
<edittablehead |
||||
@closce="showdrawer" |
||||
:drawerShow="drawerShow" |
||||
v-model="details.columnList" |
||||
></edittablehead> |
||||
</template> |
||||
|
||||
<script setup lang="ts"> |
||||
import { ref, reactive, toRefs, computed, onMounted, nextTick } from 'vue'; |
||||
import functions from '@/utils/functions.js'; |
||||
import dayjs from 'dayjs'; |
||||
import { mapGetters } from 'vuex'; |
||||
/** 获取字典 */ |
||||
import { getDictionaryBiz } from '@/api/system/dict'; |
||||
import { |
||||
setNodeHeight, |
||||
handleClearTableQuery, |
||||
handleInputQuery, |
||||
handleSelectQuery, |
||||
handleTranslationDataSeclect, |
||||
getObjType, |
||||
debounce, |
||||
} from '@/utils/util'; |
||||
import { columnListDetail } from '@/option/basicdata/TripartiteMaterial'; |
||||
import { useRoute, useRouter } from 'vue-router'; |
||||
import { deepClone } from '@/utils/util'; |
||||
import { |
||||
postBasicdataMainCategoryPageList, |
||||
postEditMainCategory, |
||||
postRemoveMainCategory, |
||||
postMainList, |
||||
postLazyTree, |
||||
} from '@/api/basicdata/TripartiteMaterial'; |
||||
import { ElMessage, ElMessageBox } from 'element-plus'; |
||||
import { exportExcel } from '@/utils/exportData'; |
||||
import { detail } from '@/api/flow/flow'; |
||||
|
||||
// 获取路由实例 |
||||
const $router = useRouter(); |
||||
const $route = useRoute(); |
||||
|
||||
// 组件实例 |
||||
const ruleFormRef = ref(); |
||||
const myUpload = ref(); |
||||
|
||||
const details = reactive<any>({ |
||||
/** 是否开启搜索 */ |
||||
search: true, |
||||
/** 表格搜索条件 */ |
||||
query: {}, |
||||
/** 时间快捷选择设置 */ |
||||
shortcuts: [ |
||||
{ |
||||
text: '最近一周', |
||||
value: () => { |
||||
const end = new Date(); |
||||
const start = new Date(); |
||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7); |
||||
return [start, end]; |
||||
}, |
||||
}, |
||||
{ |
||||
text: '最近一个月', |
||||
value: () => { |
||||
const end = new Date(); |
||||
const start = new Date(); |
||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30); |
||||
return [start, end]; |
||||
}, |
||||
}, |
||||
{ |
||||
text: '最近三个月', |
||||
value: () => { |
||||
const end = new Date(); |
||||
const start = new Date(); |
||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90); |
||||
return [start, end]; |
||||
}, |
||||
}, |
||||
], |
||||
/** 列表 */ |
||||
columnList: deepClone(columnListDetail), |
||||
/** 列表数据 */ |
||||
data: [], |
||||
/** 页面loading */ |
||||
loadingObj: { |
||||
/** 列表加载loading */ |
||||
list: false, |
||||
pageLoading: false, |
||||
}, |
||||
/** 列表复选框选中的数据 */ |
||||
selectionList: [], |
||||
/** 是否显示设置表格 */ |
||||
drawerShow: false, |
||||
/** 分页参数 */ |
||||
page: { |
||||
pageNum: 1, |
||||
pageSize: 30, |
||||
total: 0, |
||||
}, |
||||
/** 列表Dom节点 */ |
||||
listNode: '', |
||||
form: {}, |
||||
popUpShow: { |
||||
/** 查看二维码 */ |
||||
addVisited: false, |
||||
/** 上传 */ |
||||
UploadPackageDelivery: false, |
||||
}, |
||||
fullscreenObj: { |
||||
addVisited: false, |
||||
}, |
||||
title: '新增' as '新增' | '编辑', |
||||
materialArr: [], |
||||
mainList: [], |
||||
}); |
||||
|
||||
const tableNodeRef = ref(); |
||||
|
||||
const { search, query, shortcuts, selectionList, drawerShow, page } = toRefs(details); |
||||
|
||||
/** vuex */ |
||||
const permission = computed(() => mapGetters(['permission', 'tagWel', 'tagList'])); |
||||
console.log('permission :>> ', permission); |
||||
|
||||
onMounted(() => { |
||||
const timer = setTimeout(() => { |
||||
details.listNode = document.querySelector('.maboxhi'); |
||||
details.listNode.style.transition = 'all .5s ease-out'; |
||||
clearTimeout(timer); |
||||
}, 100); |
||||
}); |
||||
|
||||
/** 请求页面数据 */ |
||||
const onLoad = async (params = {}) => { |
||||
try { |
||||
// 开启列表loading动画 |
||||
details.loadingObj.list = true; |
||||
const submitData = { |
||||
...details.page, |
||||
...details.query, |
||||
...params, |
||||
factoryCategoryId: $route.query.factoryCategoryId, |
||||
}; |
||||
|
||||
delete submitData.total; |
||||
|
||||
// 获取暂存单列表 |
||||
const res = await postBasicdataMainCategoryPageList(submitData); |
||||
console.log('res :>> ', res); |
||||
const { code, data } = res.data; |
||||
if (code !== 200) return; |
||||
details.data = data.records; |
||||
details.page.total = data.total; |
||||
|
||||
handleTranslationDataSeclect(details.data, details.columnList); |
||||
|
||||
return res.data; |
||||
} catch (error) { |
||||
console.log('error :>> ', error); |
||||
} finally { |
||||
details.loadingObj.list = false; |
||||
} |
||||
}; |
||||
|
||||
const initOnLoad = (params = {}) => { |
||||
details.page.pageNum = 1; |
||||
details.page.total = 0; |
||||
onLoad(params); |
||||
}; |
||||
|
||||
initOnLoad(); |
||||
|
||||
const handleData = (key, res) => { |
||||
const { code, data } = res.data; |
||||
if (code !== 200) return; |
||||
for (let i = 0; i < details.columnList.length; i++) { |
||||
const value = details.columnList[i]; |
||||
|
||||
if (value.label === key) |
||||
return (value.checkarr = |
||||
getObjType(data) === 'array' |
||||
? data.map(val => { |
||||
val.label = val.dictValue; |
||||
val.value = val.dictKey; |
||||
return val; |
||||
}) |
||||
: []); |
||||
} |
||||
}; |
||||
|
||||
// 获取字典数据 |
||||
const initData = async () => { |
||||
try { |
||||
details.page.pageNum = 1; |
||||
|
||||
details.loadingObj.pageLoading = true; |
||||
|
||||
await Promise.all([ |
||||
// 车辆来源 |
||||
getDictionaryBiz('category').then(res => handleData('类型', res)), |
||||
onLoad(false), |
||||
]); |
||||
|
||||
await nextTick(); |
||||
handleTranslationDataSeclect(details.data, details.columnList); |
||||
console.log('details.columnList :>> ', details.columnList); |
||||
} catch (error) { |
||||
console.log('error :>> ', error); |
||||
} finally { |
||||
details.loadingObj.pageLoading = false; |
||||
} |
||||
}; |
||||
|
||||
initData(); |
||||
|
||||
/** 搜索 */ |
||||
const searchChange = () => { |
||||
const { time } = details.query; |
||||
if (time?.length) { |
||||
[details.query.taskTimeStart, details.query.taskTimeEnd] = time; |
||||
} else { |
||||
delete details.query.taskTimeStart; |
||||
delete details.query.taskTimeEnd; |
||||
} |
||||
|
||||
initOnLoad(); |
||||
}; |
||||
|
||||
/** 清空表单 */ |
||||
const searchReset = () => { |
||||
details.query = {}; |
||||
details.page.pageNum = 1; |
||||
handleClearTableQuery(details.columnList); |
||||
initOnLoad(); |
||||
}; |
||||
|
||||
/** 展开列表控件 */ |
||||
const showdrawer = (_flag?: boolean) => { |
||||
details.drawerShow = _flag; |
||||
}; |
||||
|
||||
/** 是否开启搜索区 */ |
||||
const searchHide = () => { |
||||
details.search = !details.search; |
||||
|
||||
setNodeHeight(tableNodeRef.value.$el, '', true); |
||||
}; |
||||
|
||||
/** 表格表头输入框搜索 */ |
||||
const inputsc = (index, col) => { |
||||
handleInputQuery(index, col, details.query); |
||||
initOnLoad(); |
||||
}; |
||||
|
||||
/** 表格表头时间选择 */ |
||||
const timesc = (index, row) => { |
||||
console.log(index, row); |
||||
if (!!index) { |
||||
index = dayjs(index).format('YYYY-MM-DD'); |
||||
} |
||||
details.query[row.prop] = index; |
||||
if (!index) { |
||||
delete details.query[row.prop]; |
||||
} |
||||
initOnLoad(); |
||||
}; |
||||
|
||||
/** 表格表头下拉框选择 */ |
||||
const selectsc = (index, colors) => { |
||||
handleSelectQuery(index, colors, details.query); |
||||
initOnLoad(); |
||||
}; |
||||
|
||||
/** 表格表头复选框选择 */ |
||||
const selectionChange = (list: any) => { |
||||
details.selectionList = list; |
||||
}; |
||||
|
||||
/** 每页数量改变执行的回调 */ |
||||
const sizeChange = (size: number) => { |
||||
details.page.pageSize = size; |
||||
initOnLoad(); |
||||
}; |
||||
|
||||
/** 页码改变执行的回调 */ |
||||
const currentChange = pageNum => { |
||||
details.page.pageNum = pageNum; |
||||
onLoad(); |
||||
}; |
||||
|
||||
/** 搜索物料 */ |
||||
const getMaterialTree = async value => { |
||||
// if(value) |
||||
const res = await postLazyTree({ name: value }); |
||||
|
||||
const { code, data } = res.data; |
||||
if (code !== 200) return; |
||||
details.materialArr = data; |
||||
console.log('data :>> ', data); |
||||
}; |
||||
|
||||
getMaterialTree(''); |
||||
|
||||
const getMainList = async value => { |
||||
// if(value) |
||||
const res = await postMainList({ name: value }); |
||||
|
||||
const { code, data } = res.data; |
||||
if (code !== 200) return; |
||||
details.mainList = data; |
||||
console.log('data :>> ', data); |
||||
}; |
||||
|
||||
getMainList(''); |
||||
|
||||
/** |
||||
* 赋值 |
||||
* @param list 循环数组 |
||||
* @param key 对比key |
||||
* @param key2 赋值key |
||||
*/ |
||||
const handleChange = (list, key, key2) => { |
||||
const _list = [...list]; |
||||
let _value = ''; |
||||
for (let i = 0; i < _list.length; i++) { |
||||
const val = _list[i]; |
||||
|
||||
if (val.id !== details.form[key]) continue; |
||||
_value = val.name; |
||||
} |
||||
details.form[key2] = _value; |
||||
}; |
||||
|
||||
/** 查看详情 */ |
||||
const viewDetails = ({ row }) => { |
||||
$router.push({ |
||||
path: '/warehouse/prewarehousing/PreStoragePackage', |
||||
query: { |
||||
waybillNumber: row.waybillNumber, |
||||
distrCarNumber: row.distrCarNumber, |
||||
orderCode: row.orderCode, |
||||
}, |
||||
}); |
||||
}; |
||||
|
||||
/** 导出表格数据 */ |
||||
const handleExportData = () => { |
||||
exportExcel(details.columnList, details.data, '产品 - ' + new Date().getTime()); |
||||
}; |
||||
|
||||
/** |
||||
* 是否开启全屏 |
||||
* @params(_type) 开启或关闭 |
||||
*/ |
||||
const handleFullScrean = (_type: 'open' | 'close', _name: string) => { |
||||
let _node: any = ''; |
||||
if (_name) _node = document.querySelector(`.${_name} .maboxhi`); |
||||
|
||||
switch (_name) { |
||||
case 'packageOrderListlVisited': |
||||
details.fullscreenObj.packageOrderListlVisited = |
||||
!details.fullscreenObj.packageOrderListlVisited; |
||||
|
||||
if (_type === 'close') { |
||||
if (_node) setNodeHeight(_node, '500px'); |
||||
} else { |
||||
if (_node) setNodeHeight(_node, '800px'); |
||||
} |
||||
break; |
||||
|
||||
default: |
||||
details.fullscreenObj[_name] = !details.fullscreenObj[_name]; |
||||
break; |
||||
} |
||||
}; |
||||
|
||||
/** 新增 */ |
||||
const handleAdd = () => { |
||||
details.form = {}; |
||||
details.title = '新增'; |
||||
details.popUpShow.addVisited = true; |
||||
}; |
||||
|
||||
/** 编辑 */ |
||||
const handleEdit = ({ row }) => { |
||||
details.title = '编辑'; |
||||
|
||||
for (let i = 0; i < details.columnList.length; i++) { |
||||
const value = details.columnList[i]; |
||||
|
||||
if (!value.isTitleSearch) continue; |
||||
const _key = value.prop.replace('Name', ''); |
||||
|
||||
details.form[_key] = row[_key]; |
||||
} |
||||
|
||||
details.form.id = row.id; |
||||
details.popUpShow.addVisited = true; |
||||
}; |
||||
|
||||
/** 提交 */ |
||||
const handleSubmit = () => { |
||||
ruleFormRef.value.validate(async valid => { |
||||
if (!valid) return; |
||||
try { |
||||
details.popUpShow.addVisited = false; |
||||
details.loadingObj.pageLoading = true; |
||||
|
||||
const submitData = { ...details.form, factoryCategoryId: $route.query.factoryCategoryId }; |
||||
|
||||
const res = await postEditMainCategory(submitData); |
||||
|
||||
const { code, data } = res.data; |
||||
|
||||
if (code !== 200) return; |
||||
|
||||
ElMessage.success('操作成功'); |
||||
onLoad(); |
||||
} catch (error) { |
||||
console.log('error :>> ', error); |
||||
} finally { |
||||
details.loadingObj.pageLoading = false; |
||||
} |
||||
}); |
||||
}; |
||||
|
||||
/** 删除 */ |
||||
const handleDelete = ({ row }) => { |
||||
ElMessageBox.confirm('确认删除', '提示', { |
||||
type: 'warning', |
||||
}).then(async () => { |
||||
try { |
||||
details.loadingObj.pageLoading = true; |
||||
|
||||
const res = await postRemoveMainCategory({ ids: [row.id] }); |
||||
const { code, msg } = res.data; |
||||
if (code !== 200) return; |
||||
ElMessage.success(msg); |
||||
onLoad(); |
||||
} catch (error) { |
||||
console.log('error :>> ', error); |
||||
} finally { |
||||
details.loadingObj.pageLoading = false; |
||||
} |
||||
}); |
||||
}; |
||||
|
||||
/** 批量删除 */ |
||||
const handleBatchDelete = () => { |
||||
if (details.selectionList.length === 0) return ElMessage.warning('请选择需要删除的数据'); |
||||
|
||||
ElMessageBox.confirm('确认删除', '提示', { |
||||
type: 'warning', |
||||
}).then(async () => { |
||||
try { |
||||
details.loadingObj.pageLoading = true; |
||||
|
||||
const res = await postRemoveMainCategory({ |
||||
ids: details.selectionList.map(val => val.id), |
||||
}); |
||||
const { code, msg } = res.data; |
||||
if (code !== 200) return; |
||||
ElMessage.success(msg); |
||||
onLoad(); |
||||
} catch (error) { |
||||
console.log('error :>> ', error); |
||||
} finally { |
||||
details.loadingObj.pageLoading = false; |
||||
} |
||||
}); |
||||
}; |
||||
</script> |
||||
|
||||
<style scoped lang="scss"> |
||||
// 日期选择器 |
||||
:deep(.el-date-editor.el-input) { |
||||
height: 100% !important; |
||||
width: 100% !important; |
||||
} |
||||
|
||||
:deep(.el-range-editor.el-input__wrapper) { |
||||
height: 100% !important; |
||||
} |
||||
</style> |
@ -0,0 +1,616 @@
|
||||
<template> |
||||
<basic-container v-loading="details.loadingObj.pageLoading"> |
||||
<div class="avue-crud"> |
||||
<!-- 搜索模块 --> |
||||
<div v-h5uShow="!search"> |
||||
<!-- 查询模块 --> |
||||
<el-form :inline="true" :model="query" class="header_search"> |
||||
<template v-for="item in details.columnList" :key="item.prop"> |
||||
<el-form-item v-if="item.isTitleSearch" :label="item.label"> |
||||
<!-- 普通输入框 --> |
||||
<template v-if="item.type === 2"> |
||||
<el-input |
||||
class="w100" |
||||
:placeholder="`请输入${item.label}`" |
||||
v-model="details.query[item.prop]" |
||||
clearable |
||||
></el-input> |
||||
</template> |
||||
|
||||
<!-- 下拉框 --> |
||||
<template v-else-if="item.type === 3"> |
||||
<el-select |
||||
v-model="details.query[item.prop.replace('Name', '')]" |
||||
:placeholder="`请选择${item.label}`" |
||||
class="w100" |
||||
clearable |
||||
filterable |
||||
@change=" |
||||
val => { |
||||
!val && delete details.query[item.prop.replace('Name', '')]; |
||||
} |
||||
" |
||||
:multiple="item.multiple || false" |
||||
> |
||||
<el-option |
||||
v-for="val in item.checkarr" |
||||
:key="val.value" |
||||
:label="val.label" |
||||
:value="val.value" |
||||
/> |
||||
</el-select> |
||||
</template> |
||||
</el-form-item> |
||||
</template> |
||||
|
||||
<!-- 查询按钮 --> |
||||
<el-form-item class="el-btn"> |
||||
<el-button type="primary" icon="el-icon-search" @click="searchChange">搜 索</el-button> |
||||
<el-button icon="el-icon-delete" @click="searchReset">清 空</el-button> |
||||
</el-form-item> |
||||
</el-form> |
||||
</div> |
||||
|
||||
<div class="avue-crud__header"> |
||||
<!-- 头部左侧按钮模块 --> |
||||
<div class="avue-crud__left"> |
||||
<el-button type="primary" icon="Plus" @click="handleAdd">新 增</el-button> |
||||
<el-button type="primary" icon="Delete" @click="handleBatchDelete">批量删除</el-button> |
||||
</div> |
||||
<!-- 头部右侧按钮模块 --> |
||||
<div class="avue-crud__right"> |
||||
<el-button icon="Download" @click="handleExportData" circle></el-button> |
||||
<el-button icon="el-icon-refresh" @click="searchChange" circle></el-button> |
||||
<el-button icon="Operation" @click="showdrawer(true)" circle></el-button> |
||||
<el-button icon="Search" @click="searchHide" circle></el-button> |
||||
</div> |
||||
</div> |
||||
|
||||
<!-- 表格 --> |
||||
<tablecmt |
||||
ref="tableNodeRef" |
||||
:columnList="details.columnList" |
||||
:tableData="details.data" |
||||
:loading="details.loadingObj.list" |
||||
@inputTxt="inputsc" |
||||
@timeCheck="timesc" |
||||
@selectCheck="selectsc" |
||||
@selection="selectionChange" |
||||
> |
||||
<template #default="slotProps"> |
||||
<template v-if="slotProps.scope.column.label === '操作'"> |
||||
<!-- 车次详情 --> |
||||
<el-text @click="() => handleEdit(slotProps.scope)"> 编 辑 </el-text> |
||||
<el-text @click="() => handleDelete(slotProps.scope)"> 删 除 </el-text> |
||||
</template> |
||||
</template> |
||||
</tablecmt> |
||||
|
||||
<!-- 分页模块 --> |
||||
<div class="avue-crud__pagination flex-c-sb mt10" style="width: 100%"> |
||||
<div style="font-size: 14px">勾选数量: {{ selectionList.length }}</div> |
||||
<!-- 分页模块 --> |
||||
<el-pagination |
||||
align="right" |
||||
background |
||||
@size-change="sizeChange" |
||||
@current-change="currentChange" |
||||
:current-page="page.current" |
||||
:page-sizes="[30, 50, 80, 120, 5000]" |
||||
:page-size="page.size" |
||||
layout="total, sizes, prev, pager, next, jumper" |
||||
:total="page.total" |
||||
> |
||||
</el-pagination> |
||||
</div> |
||||
|
||||
<!-- 开标签 --> |
||||
<el-dialog |
||||
destroy-on-close |
||||
:modal-append-to-body="false" |
||||
:append-to-body="false" |
||||
:title="details.title" |
||||
width="50%" |
||||
v-model="details.popUpShow.addVisited" |
||||
draggable |
||||
align-center |
||||
> |
||||
<div v-loading="details.loadingObj.addTagLoading"> |
||||
<el-form ref="ruleFormRef" :model="details.form" inline label-width="100px"> |
||||
<template v-for="item in details.columnList" :key="item.prop"> |
||||
<el-form-item |
||||
v-if="item.isTitleSearch" |
||||
:label="item.label" |
||||
style="width: 350px" |
||||
:rules="[ |
||||
{ |
||||
required: true, |
||||
message: `${{ 2: '请输入', 3: '请选择' }[item.type] + item.label}`, |
||||
trigger: ['blur', 'change'], |
||||
}, |
||||
]" |
||||
:prop="item.prop.replace('Name', '')" |
||||
> |
||||
<!-- 普通输入框 --> |
||||
<template v-if="item.type === 2"> |
||||
<el-input |
||||
class="w100" |
||||
:placeholder="`请输入${item.label}`" |
||||
v-model="details.form[item.prop]" |
||||
clearable |
||||
></el-input> |
||||
</template> |
||||
|
||||
<!-- 下拉框 --> |
||||
<template v-else-if="item.type === 3"> |
||||
<el-select |
||||
v-model="details.form[item.prop.replace('Name', '')]" |
||||
:placeholder="`请选择${item.label}`" |
||||
class="w100" |
||||
clearable |
||||
filterable |
||||
:multiple="item.multiple || false" |
||||
> |
||||
<el-option |
||||
v-for="val in item.checkarr" |
||||
:key="val.value" |
||||
:label="val.label" |
||||
:value="val.value" |
||||
/> |
||||
</el-select> |
||||
</template> |
||||
</el-form-item> |
||||
</template> |
||||
</el-form> |
||||
</div> |
||||
|
||||
<div class="flex-c-c dialog-footer"> |
||||
<el-button icon="Close" @click="details.popUpShow.addVisited = false"> 取 消 </el-button> |
||||
|
||||
<!-- 提交 --> |
||||
<el-button |
||||
icon="Position" |
||||
type="primary" |
||||
:loading="details.loadingObj.addTagLoading" |
||||
@click="handleSubmit" |
||||
> |
||||
提 交 |
||||
</el-button> |
||||
</div> |
||||
</el-dialog> |
||||
</div> |
||||
</basic-container> |
||||
|
||||
<MyPrint |
||||
width="780px" |
||||
:html="details.html" |
||||
v-model="details.popUpShow.dialogVisible" |
||||
:isShowExport="false" |
||||
/> |
||||
|
||||
<!-- 列表配置显示 --> |
||||
<edittablehead |
||||
@closce="showdrawer" |
||||
:drawerShow="drawerShow" |
||||
v-model="details.columnList" |
||||
></edittablehead> |
||||
</template> |
||||
|
||||
<script setup lang="ts"> |
||||
import { ref, reactive, toRefs, computed, onMounted, nextTick } from 'vue'; |
||||
import functions from '@/utils/functions.js'; |
||||
import dayjs from 'dayjs'; |
||||
import { mapGetters } from 'vuex'; |
||||
/** 获取字典 */ |
||||
import { getDictionaryBiz } from '@/api/system/dict'; |
||||
import { |
||||
downloadXls, |
||||
setNodeHeight, |
||||
handleClearTableQuery, |
||||
handleInputQuery, |
||||
handleSelectQuery, |
||||
handleTranslationDataSeclect, |
||||
getObjType, |
||||
} from '@/utils/util'; |
||||
import { columnList } from '@/option/basicdata/defaultShipper'; |
||||
import { useRouter } from 'vue-router'; |
||||
import { deepClone } from '@/utils/util'; |
||||
import { postEditUnit, postPageList, postRemoveUnit } from '@/api/basicdata/defaultShipper'; |
||||
import { ElMessage, ElMessageBox } from 'element-plus'; |
||||
import { exportExcel } from '@/utils/exportData'; |
||||
|
||||
// 获取路由实例 |
||||
const $router = useRouter(); |
||||
|
||||
// 组件实例 |
||||
const ruleFormRef = ref(); |
||||
const myUpload = ref(); |
||||
|
||||
const details = reactive<any>({ |
||||
/** 是否开启搜索 */ |
||||
search: true, |
||||
/** 表格搜索条件 */ |
||||
query: {}, |
||||
/** 时间快捷选择设置 */ |
||||
shortcuts: [ |
||||
{ |
||||
text: '最近一周', |
||||
value: () => { |
||||
const end = new Date(); |
||||
const start = new Date(); |
||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7); |
||||
return [start, end]; |
||||
}, |
||||
}, |
||||
{ |
||||
text: '最近一个月', |
||||
value: () => { |
||||
const end = new Date(); |
||||
const start = new Date(); |
||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30); |
||||
return [start, end]; |
||||
}, |
||||
}, |
||||
{ |
||||
text: '最近三个月', |
||||
value: () => { |
||||
const end = new Date(); |
||||
const start = new Date(); |
||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90); |
||||
return [start, end]; |
||||
}, |
||||
}, |
||||
], |
||||
/** 列表 */ |
||||
columnList: deepClone(columnList), |
||||
/** 列表数据 */ |
||||
data: [], |
||||
/** 页面loading */ |
||||
loadingObj: { |
||||
/** 列表加载loading */ |
||||
list: false, |
||||
pageLoading: false, |
||||
}, |
||||
/** 列表复选框选中的数据 */ |
||||
selectionList: [], |
||||
/** 是否显示设置表格 */ |
||||
drawerShow: false, |
||||
/** 分页参数 */ |
||||
page: { |
||||
current: 1, |
||||
size: 30, |
||||
total: 0, |
||||
}, |
||||
/** 列表Dom节点 */ |
||||
listNode: '', |
||||
form: {}, |
||||
popUpShow: { |
||||
/** 查看二维码 */ |
||||
addVisited: false, |
||||
/** 上传 */ |
||||
UploadPackageDelivery: false, |
||||
}, |
||||
fullscreenObj: { |
||||
addVisited: false, |
||||
}, |
||||
title: '新增' as '新增' | '编辑', |
||||
}); |
||||
|
||||
const tableNodeRef = ref(); |
||||
|
||||
const { search, query, shortcuts, selectionList, drawerShow, page } = toRefs(details); |
||||
|
||||
/** vuex */ |
||||
const permission = computed(() => mapGetters(['permission', 'tagWel', 'tagList'])); |
||||
console.log('permission :>> ', permission); |
||||
|
||||
onMounted(() => { |
||||
const timer = setTimeout(() => { |
||||
details.listNode = document.querySelector('.maboxhi'); |
||||
details.listNode.style.transition = 'all .5s ease-out'; |
||||
clearTimeout(timer); |
||||
}, 100); |
||||
}); |
||||
|
||||
/** 请求页面数据 */ |
||||
const onLoad = async (params = {}) => { |
||||
try { |
||||
// 开启列表loading动画 |
||||
details.loadingObj.list = true; |
||||
const submitData = { ...details.page, ...details.query, ...params }; |
||||
|
||||
delete submitData.total; |
||||
|
||||
// 获取暂存单列表 |
||||
const res = await postPageList(submitData); |
||||
console.log('res :>> ', res); |
||||
const { code, data } = res.data; |
||||
if (code !== 200) return; |
||||
details.data = data.records; |
||||
details.page.total = data.total; |
||||
|
||||
handleTranslationDataSeclect(details.data, details.columnList); |
||||
|
||||
return res.data; |
||||
} catch (error) { |
||||
console.log('error :>> ', error); |
||||
} finally { |
||||
details.loadingObj.list = false; |
||||
} |
||||
}; |
||||
|
||||
const initOnLoad = (params = {}) => { |
||||
details.page.current = 1; |
||||
details.page.total = 0; |
||||
onLoad(params); |
||||
}; |
||||
|
||||
initOnLoad(); |
||||
|
||||
const handleData = (key, res) => { |
||||
const { code, data } = res.data; |
||||
if (code !== 200) return; |
||||
for (let i = 0; i < details.columnList.length; i++) { |
||||
const value = details.columnList[i]; |
||||
|
||||
if (value.label === key) |
||||
return (value.checkarr = |
||||
getObjType(data) === 'array' |
||||
? data.map(val => { |
||||
val.label = val.dictValue; |
||||
val.value = val.dictKey; |
||||
return val; |
||||
}) |
||||
: []); |
||||
} |
||||
}; |
||||
|
||||
// 获取字典数据 |
||||
const initData = async () => { |
||||
try { |
||||
details.page.current = 1; |
||||
|
||||
details.loadingObj.pageLoading = true; |
||||
|
||||
await Promise.all([ |
||||
// 车辆来源 |
||||
getDictionaryBiz('category').then(res => handleData('类型', res)), |
||||
onLoad(false), |
||||
]); |
||||
|
||||
await nextTick(); |
||||
handleTranslationDataSeclect(details.data, details.columnList); |
||||
console.log('details.columnList :>> ', details.columnList); |
||||
} catch (error) { |
||||
console.log('error :>> ', error); |
||||
} finally { |
||||
details.loadingObj.pageLoading = false; |
||||
} |
||||
}; |
||||
|
||||
initData(); |
||||
|
||||
/** 搜索 */ |
||||
const searchChange = () => { |
||||
const { time } = details.query; |
||||
if (time?.length) { |
||||
[details.query.taskTimeStart, details.query.taskTimeEnd] = time; |
||||
} else { |
||||
delete details.query.taskTimeStart; |
||||
delete details.query.taskTimeEnd; |
||||
} |
||||
|
||||
initOnLoad(); |
||||
}; |
||||
|
||||
/** 清空表单 */ |
||||
const searchReset = () => { |
||||
details.query = {}; |
||||
details.page.current = 1; |
||||
handleClearTableQuery(details.columnList); |
||||
initOnLoad(); |
||||
}; |
||||
|
||||
/** 展开列表控件 */ |
||||
const showdrawer = (_flag?: boolean) => { |
||||
details.drawerShow = _flag; |
||||
}; |
||||
|
||||
/** 是否开启搜索区 */ |
||||
const searchHide = () => { |
||||
details.search = !details.search; |
||||
|
||||
setNodeHeight(tableNodeRef.value.$el, '', true); |
||||
}; |
||||
|
||||
/** 表格表头输入框搜索 */ |
||||
const inputsc = (index, col) => { |
||||
handleInputQuery(index, col, details.query); |
||||
initOnLoad(); |
||||
}; |
||||
|
||||
/** 表格表头时间选择 */ |
||||
const timesc = (index, row) => { |
||||
console.log(index, row); |
||||
if (!!index) { |
||||
index = dayjs(index).format('YYYY-MM-DD'); |
||||
} |
||||
details.query[row.prop] = index; |
||||
if (!index) { |
||||
delete details.query[row.prop]; |
||||
} |
||||
initOnLoad(); |
||||
}; |
||||
|
||||
/** 表格表头下拉框选择 */ |
||||
const selectsc = (index, colors) => { |
||||
handleSelectQuery(index, colors, details.query); |
||||
initOnLoad(); |
||||
}; |
||||
|
||||
/** 表格表头复选框选择 */ |
||||
const selectionChange = (list: any) => { |
||||
details.selectionList = list; |
||||
}; |
||||
|
||||
/** 每页数量改变执行的回调 */ |
||||
const sizeChange = (size: number) => { |
||||
details.page.size = size; |
||||
initOnLoad(); |
||||
}; |
||||
|
||||
/** 页码改变执行的回调 */ |
||||
const currentChange = current => { |
||||
details.page.current = current; |
||||
onLoad(); |
||||
}; |
||||
|
||||
/** 查看详情 */ |
||||
const viewDetails = ({ row }) => { |
||||
$router.push({ |
||||
path: '/warehouse/prewarehousing/PreStoragePackage', |
||||
query: { |
||||
waybillNumber: row.waybillNumber, |
||||
distrCarNumber: row.distrCarNumber, |
||||
orderCode: row.orderCode, |
||||
}, |
||||
}); |
||||
}; |
||||
|
||||
/** 导出表格数据 */ |
||||
const handleExportData = () => { |
||||
exportExcel(details.columnList, details.data, '产品 - ' + new Date().getTime()); |
||||
}; |
||||
|
||||
/** |
||||
* 是否开启全屏 |
||||
* @params(_type) 开启或关闭 |
||||
*/ |
||||
const handleFullScrean = (_type: 'open' | 'close', _name: string) => { |
||||
let _node: any = ''; |
||||
if (_name) _node = document.querySelector(`.${_name} .maboxhi`); |
||||
|
||||
switch (_name) { |
||||
case 'packageOrderListlVisited': |
||||
details.fullscreenObj.packageOrderListlVisited = |
||||
!details.fullscreenObj.packageOrderListlVisited; |
||||
|
||||
if (_type === 'close') { |
||||
if (_node) setNodeHeight(_node, '500px'); |
||||
} else { |
||||
if (_node) setNodeHeight(_node, '800px'); |
||||
} |
||||
break; |
||||
|
||||
default: |
||||
details.fullscreenObj[_name] = !details.fullscreenObj[_name]; |
||||
break; |
||||
} |
||||
}; |
||||
|
||||
/** 新增 */ |
||||
const handleAdd = () => { |
||||
details.form = {}; |
||||
details.title = '新增'; |
||||
details.popUpShow.addVisited = true; |
||||
}; |
||||
|
||||
/** 编辑 */ |
||||
const handleEdit = ({ row }) => { |
||||
details.title = '编辑'; |
||||
|
||||
for (let i = 0; i < details.columnList.length; i++) { |
||||
const value = details.columnList[i]; |
||||
|
||||
if (!value.isTitleSearch) continue; |
||||
const _key = value.prop.replace('Name', ''); |
||||
|
||||
details.form[_key] = row[_key]; |
||||
} |
||||
|
||||
details.form.id = row.id; |
||||
details.popUpShow.addVisited = true; |
||||
}; |
||||
|
||||
/** 提交 */ |
||||
const handleSubmit = () => { |
||||
ruleFormRef.value.validate(async valid => { |
||||
if (!valid) return; |
||||
try { |
||||
details.popUpShow.addVisited = false; |
||||
details.loadingObj.pageLoading = true; |
||||
|
||||
const submitData = { ...details.form }; |
||||
|
||||
const res = await postEditUnit(submitData); |
||||
|
||||
const { code, data } = res.data; |
||||
|
||||
if (code !== 200) return; |
||||
|
||||
ElMessage.success('操作成功'); |
||||
onLoad(); |
||||
} catch (error) { |
||||
console.log('error :>> ', error); |
||||
} finally { |
||||
details.loadingObj.pageLoading = false; |
||||
} |
||||
}); |
||||
}; |
||||
|
||||
/** 删除 */ |
||||
const handleDelete = ({ row }) => { |
||||
ElMessageBox.confirm('确认删除', '提示', { |
||||
type: 'warning', |
||||
}).then(async () => { |
||||
try { |
||||
details.loadingObj.pageLoading = true; |
||||
|
||||
const res = await postRemoveUnit({ ids: row.id }); |
||||
const { code, msg } = res.data; |
||||
if (code !== 200) return; |
||||
ElMessage.success(msg); |
||||
onLoad(); |
||||
} catch (error) { |
||||
console.log('error :>> ', error); |
||||
} finally { |
||||
details.loadingObj.pageLoading = false; |
||||
} |
||||
}); |
||||
}; |
||||
|
||||
/** 批量删除 */ |
||||
const handleBatchDelete = () => { |
||||
if (details.selectionList.length === 0) return ElMessage.warning('请选择需要删除的数据'); |
||||
|
||||
ElMessageBox.confirm('确认删除', '提示', { |
||||
type: 'warning', |
||||
}).then(async () => { |
||||
try { |
||||
details.loadingObj.pageLoading = true; |
||||
|
||||
const res = await postRemoveUnit({ ids: details.selectionList.map(val => val.id).join(',') }); |
||||
const { code, msg } = res.data; |
||||
if (code !== 200) return; |
||||
ElMessage.success(msg); |
||||
onLoad(); |
||||
} catch (error) { |
||||
console.log('error :>> ', error); |
||||
} finally { |
||||
details.loadingObj.pageLoading = false; |
||||
} |
||||
}); |
||||
}; |
||||
</script> |
||||
|
||||
<style scoped lang="scss"> |
||||
// 日期选择器 |
||||
:deep(.el-date-editor.el-input) { |
||||
height: 100% !important; |
||||
width: 100% !important; |
||||
} |
||||
|
||||
:deep(.el-range-editor.el-input__wrapper) { |
||||
height: 100% !important; |
||||
} |
||||
</style> |
Loading…
Reference in new issue