调整 基础数据、运力、车船务
This commit is contained in:
@@ -0,0 +1,52 @@
|
|||||||
|
import request from '@/axios';
|
||||||
|
|
||||||
|
export const getList = (current, size, params) => {
|
||||||
|
return request({
|
||||||
|
url: '/blade-system/measurement-unit/list',
|
||||||
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
...params,
|
||||||
|
current,
|
||||||
|
size,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getDetail = id => {
|
||||||
|
return request({
|
||||||
|
url: '/blade-system/measurement-unit/detail',
|
||||||
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const remove = ids => {
|
||||||
|
return request({
|
||||||
|
url: '/blade-system/measurement-unit/remove',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
ids,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const submit = row => {
|
||||||
|
return request({
|
||||||
|
url: '/blade-system/measurement-unit/submit',
|
||||||
|
method: 'post',
|
||||||
|
data: row,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const changeStatus = (id, status) => {
|
||||||
|
return request({
|
||||||
|
url: '/blade-system/measurement-unit/status',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
id,
|
||||||
|
status,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import request from '@/axios';
|
||||||
|
|
||||||
|
const baseUrl = '/blade-transport/vehicle-dispatch';
|
||||||
|
|
||||||
|
export const getList = (current, size, params) =>
|
||||||
|
request({ url: `${baseUrl}/list`, method: 'get', params: { ...params, current, size } });
|
||||||
|
|
||||||
|
export const getDetail = id => request({ url: `${baseUrl}/detail`, method: 'get', params: { id } });
|
||||||
|
|
||||||
|
export const submit = row => request({ url: `${baseUrl}/submit`, method: 'post', data: row });
|
||||||
|
|
||||||
|
export const remove = ids => request({ url: `${baseUrl}/remove`, method: 'post', params: { ids } });
|
||||||
|
|
||||||
|
export const submitApproval = id =>
|
||||||
|
request({ url: `${baseUrl}/submit-approval`, method: 'post', params: { id } });
|
||||||
|
|
||||||
|
export const approve = id => request({ url: `${baseUrl}/approve`, method: 'post', params: { id } });
|
||||||
|
|
||||||
|
export const exportVehicleDispatch = params =>
|
||||||
|
request({
|
||||||
|
url: `${baseUrl}/export-vehicle-dispatch`,
|
||||||
|
method: 'get',
|
||||||
|
params,
|
||||||
|
responseType: 'blob',
|
||||||
|
});
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
const dimensionOptions = [
|
||||||
|
{ label: '重量', value: '重量' },
|
||||||
|
{ label: '体积', value: '体积' },
|
||||||
|
{ label: '数量', value: '数量' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const statusOptions = [
|
||||||
|
{ label: '启用', value: 1 },
|
||||||
|
{ label: '停用', value: 2 },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const createOption = () => ({
|
||||||
|
height: 'auto',
|
||||||
|
calcHeight: 32,
|
||||||
|
dialogWidth: 680,
|
||||||
|
labelPosition: 'right',
|
||||||
|
labelWidth: 'auto',
|
||||||
|
tip: false,
|
||||||
|
searchBtnText: '查询',
|
||||||
|
emptyBtnText: '重置',
|
||||||
|
saveBtnText: '提交',
|
||||||
|
updateBtnText: '提交',
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 24,
|
||||||
|
searchIcon: true,
|
||||||
|
searchIndex: 4,
|
||||||
|
searchMenuPosition: 'right',
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
indexLabel: '序号',
|
||||||
|
indexWidth: 70,
|
||||||
|
addBtn: false,
|
||||||
|
viewBtn: false,
|
||||||
|
editBtn: false,
|
||||||
|
delBtn: false,
|
||||||
|
selection: true,
|
||||||
|
dialogClickModal: false,
|
||||||
|
menuWidth: 240,
|
||||||
|
menuFixed: 'right',
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '计量单位',
|
||||||
|
prop: 'unitName',
|
||||||
|
minWidth: 150,
|
||||||
|
search: true,
|
||||||
|
searchOrder: 3,
|
||||||
|
searchSpan: 6,
|
||||||
|
maxlength: 50,
|
||||||
|
showWordLimit: true,
|
||||||
|
rules: [
|
||||||
|
{ required: true, message: '请输入计量单位', trigger: 'blur' },
|
||||||
|
{ max: 50, message: '计量单位不能超过50个字', trigger: 'blur' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '计量维度',
|
||||||
|
prop: 'dimension',
|
||||||
|
type: 'select',
|
||||||
|
minWidth: 130,
|
||||||
|
search: true,
|
||||||
|
searchOrder: 2,
|
||||||
|
searchSpan: 6,
|
||||||
|
dicData: dimensionOptions,
|
||||||
|
rules: [{ required: true, message: '请选择计量维度', trigger: 'change' }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '备注',
|
||||||
|
prop: 'remark',
|
||||||
|
type: 'textarea',
|
||||||
|
minRows: 2,
|
||||||
|
span: 24,
|
||||||
|
minWidth: 200,
|
||||||
|
maxlength: 200,
|
||||||
|
showWordLimit: true,
|
||||||
|
overHidden: true,
|
||||||
|
rules: [{ max: 200, message: '备注不能超过200个字', trigger: 'blur' }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '状态',
|
||||||
|
prop: 'status',
|
||||||
|
type: 'select',
|
||||||
|
search: true,
|
||||||
|
searchOrder: 1,
|
||||||
|
searchSpan: 6,
|
||||||
|
slot: true,
|
||||||
|
dataType: 'number',
|
||||||
|
dicData: statusOptions,
|
||||||
|
clearable: true,
|
||||||
|
value: 1,
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
minWidth: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '创建人',
|
||||||
|
prop: 'createUserName',
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
viewDisplay: false,
|
||||||
|
display: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '更新人',
|
||||||
|
prop: 'updateUserName',
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
viewDisplay: false,
|
||||||
|
display: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '创建时间',
|
||||||
|
prop: 'createTime',
|
||||||
|
type: 'datetime',
|
||||||
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
sortable: true,
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
display: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '更新时间',
|
||||||
|
prop: 'updateTime',
|
||||||
|
type: 'datetime',
|
||||||
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
sortable: true,
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
display: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
const approvalStatusOptions = [
|
||||||
|
{ label: '草稿', value: 'draft' },
|
||||||
|
{ label: '审批中', value: 'reviewing' },
|
||||||
|
{ label: '已驳回', value: 'rejected' },
|
||||||
|
{ label: '审批通过', value: 'approved' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const statusName = status =>
|
||||||
|
approvalStatusOptions.find(item => item.value === status)?.label || status || '-';
|
||||||
|
|
||||||
|
export const option = {
|
||||||
|
height: 'auto',
|
||||||
|
calcHeight: 32,
|
||||||
|
dialogWidth: 1200,
|
||||||
|
labelPosition: 'right',
|
||||||
|
labelWidth: 'auto',
|
||||||
|
tip: false,
|
||||||
|
searchBtnText: '查询',
|
||||||
|
emptyBtnText: '重置',
|
||||||
|
saveBtnText: '提交',
|
||||||
|
updateBtnText: '提交',
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 24,
|
||||||
|
searchIndex: 4,
|
||||||
|
searchMenuPosition: 'right',
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
indexLabel: '序号',
|
||||||
|
indexWidth: 70,
|
||||||
|
addBtn: false,
|
||||||
|
editBtn: false,
|
||||||
|
delBtn: false,
|
||||||
|
viewBtn: false,
|
||||||
|
selection: false,
|
||||||
|
dialogClickModal: false,
|
||||||
|
menuFixed: 'right',
|
||||||
|
menuWidth: 320,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '申请单号',
|
||||||
|
prop: 'applicationNo',
|
||||||
|
search: true,
|
||||||
|
searchOrder: 5,
|
||||||
|
searchPlaceholder: '请输入',
|
||||||
|
minWidth: 180,
|
||||||
|
slot: true,
|
||||||
|
addDisplay: true,
|
||||||
|
editDisabled: true,
|
||||||
|
disabled: true,
|
||||||
|
placeholder: '保存后自动生成',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '调度车辆',
|
||||||
|
prop: 'plateNo',
|
||||||
|
search: true,
|
||||||
|
searchOrder: 4,
|
||||||
|
searchPlaceholder: '请输入',
|
||||||
|
minWidth: 120,
|
||||||
|
formslot: true,
|
||||||
|
rules: [{ required: true, message: '请输入车牌号', trigger: 'blur' }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '所属组织',
|
||||||
|
prop: 'organizationName',
|
||||||
|
search: true,
|
||||||
|
searchOrder: 3,
|
||||||
|
searchPlaceholder: '请输入',
|
||||||
|
minWidth: 140,
|
||||||
|
disabled: true,
|
||||||
|
placeholder: '选择调度车辆后自动填充',
|
||||||
|
rules: [{ required: true, message: '请输入所属组织', trigger: 'blur' }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '使用部门',
|
||||||
|
prop: 'useDepartment',
|
||||||
|
search: true,
|
||||||
|
searchOrder: 2,
|
||||||
|
searchPlaceholder: '请输入',
|
||||||
|
minWidth: 140,
|
||||||
|
formslot: true,
|
||||||
|
span: 12,
|
||||||
|
rules: [{ required: true, message: '请输入使用部门', trigger: 'blur' }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '审批状态',
|
||||||
|
prop: 'approvalStatus',
|
||||||
|
search: true,
|
||||||
|
searchOrder: 1,
|
||||||
|
type: 'select',
|
||||||
|
dicData: approvalStatusOptions,
|
||||||
|
slot: true,
|
||||||
|
minWidth: 120,
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '当前节点',
|
||||||
|
prop: 'currentNode',
|
||||||
|
minWidth: 120,
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '当前处理人',
|
||||||
|
prop: 'currentProcessor',
|
||||||
|
minWidth: 130,
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '申请人',
|
||||||
|
prop: 'createUserName',
|
||||||
|
hide: true,
|
||||||
|
display: true,
|
||||||
|
addDisplay: true,
|
||||||
|
editDisplay: true,
|
||||||
|
viewDisplay: true,
|
||||||
|
disabled: true,
|
||||||
|
span: 12,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '申请时间',
|
||||||
|
prop: 'createTime',
|
||||||
|
type: 'datetime',
|
||||||
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
hide: true,
|
||||||
|
display: true,
|
||||||
|
addDisplay: true,
|
||||||
|
editDisplay: true,
|
||||||
|
viewDisplay: true,
|
||||||
|
disabled: true,
|
||||||
|
span: 12,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '创建人',
|
||||||
|
prop: 'createUserName',
|
||||||
|
minWidth: 120,
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '创建时间',
|
||||||
|
prop: 'createTime',
|
||||||
|
type: 'datetime',
|
||||||
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
minWidth: 170,
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '备注',
|
||||||
|
prop: 'remark',
|
||||||
|
type: 'textarea',
|
||||||
|
span: 24,
|
||||||
|
maxlength: 200,
|
||||||
|
showWordLimit: true,
|
||||||
|
rules: [{ max: 200, message: '备注不能超过200个字', trigger: 'blur' }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '附件',
|
||||||
|
prop: 'attachments',
|
||||||
|
hide: true,
|
||||||
|
span: 24,
|
||||||
|
minWidth: 100,
|
||||||
|
slot: true,
|
||||||
|
formslot: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
@@ -0,0 +1,255 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container class="measurement-unit-page">
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
v-model:page="page"
|
||||||
|
v-model="form"
|
||||||
|
ref="crud"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
v-if="hasPermission('measurement_unit_add')"
|
||||||
|
type="primary"
|
||||||
|
@click="$refs.crud.rowAdd()"
|
||||||
|
>
|
||||||
|
新增
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="hasPermission('measurement_unit_delete')"
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
:disabled="!selectionList.length"
|
||||||
|
@click="handleDelete"
|
||||||
|
>
|
||||||
|
批量删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #dimension="{ row }">
|
||||||
|
{{ row.dimension || '-' }}
|
||||||
|
</template>
|
||||||
|
<template #status="{ row }">
|
||||||
|
<el-tag :type="row.status === 1 ? 'primary' : 'info'" class="status-text">
|
||||||
|
{{ row.status === 1 ? '启用' : '停用' }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
<template #menu="{ row, index }">
|
||||||
|
<el-link
|
||||||
|
v-if="hasPermission('measurement_unit_edit')"
|
||||||
|
type="primary"
|
||||||
|
@click="$refs.crud.rowEdit(row, index)"
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</el-link>
|
||||||
|
<el-link
|
||||||
|
v-if="hasPermission('measurement_unit_status')"
|
||||||
|
type="primary"
|
||||||
|
@click="handleStatus(row)"
|
||||||
|
>
|
||||||
|
{{ row.status === 1 ? '停用' : '启用' }}
|
||||||
|
</el-link>
|
||||||
|
<el-link
|
||||||
|
v-if="hasPermission('measurement_unit_delete')"
|
||||||
|
type="danger"
|
||||||
|
@click="handleDelete(row.id)"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</el-link>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
<empty-pagination
|
||||||
|
:page="page"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@load="onLoad(page, query)"
|
||||||
|
/>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import { changeStatus, getDetail, getList, remove, submit } from '@/api/base/measurement-unit';
|
||||||
|
import { createOption } from '@/option/base/measurement-unit';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
data: [],
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
pageSizes: [10, 20, 50, 100],
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
selectionList: [],
|
||||||
|
option: createOption(),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission', 'userInfo']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.hasPermission('measurement_unit_add'),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
return this.selectionList.map(item => item.id).join(',');
|
||||||
|
},
|
||||||
|
isAdmin() {
|
||||||
|
return String(this.userInfo?.authority || '').includes('admin');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
hasPermission(code) {
|
||||||
|
return this.isAdmin || this.permission?.[code] === true;
|
||||||
|
},
|
||||||
|
normalizeRow(row) {
|
||||||
|
row.unitName = String(row.unitName || '').trim();
|
||||||
|
row.dimension = String(row.dimension || '').trim();
|
||||||
|
row.remark = String(row.remark || '').trim();
|
||||||
|
if (!row.status) row.status = 1;
|
||||||
|
return row;
|
||||||
|
},
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
submit(this.normalizeRow(row)).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
this.$message.success('操作成功');
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
() => loading()
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
submit(this.normalizeRow(row)).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
this.$message.success('操作成功');
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
() => loading()
|
||||||
|
);
|
||||||
|
},
|
||||||
|
handleDelete(ids = '') {
|
||||||
|
const targetIds = ids || this.ids;
|
||||||
|
if (!targetIds) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定删除所选数据,删除后不可恢复?', '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => remove(targetIds))
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
this.$message.success('操作成功');
|
||||||
|
this.selectionList = [];
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleStatus(row) {
|
||||||
|
const nextStatus = row.status === 1 ? 2 : 1;
|
||||||
|
const actionName = nextStatus === 1 ? '启用' : '停用';
|
||||||
|
this.$confirm(`是否确认${actionName}该计量单位?`, '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => changeStatus(row.id, nextStatus))
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
this.$message.success('操作成功');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDetail(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data || {};
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.form.status = 1;
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = { ...params };
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page = this.page, params = this.query) {
|
||||||
|
this.loading = true;
|
||||||
|
return getList(page.currentPage, page.pageSize, params)
|
||||||
|
.then(res => {
|
||||||
|
const pageData = res.data.data || {};
|
||||||
|
this.data = pageData.records || [];
|
||||||
|
this.page.total = pageData.total || 0;
|
||||||
|
this.selectionList = [];
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.measurement-unit-page {
|
||||||
|
:deep(.avue-crud__menu) {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.avue-crud__search .el-form-item__label) {
|
||||||
|
min-width: 160px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.avue-crud__menu-column) {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.avue-crud__menu .el-link) {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -251,7 +251,12 @@ export default {
|
|||||||
prop: 'regionLevel',
|
prop: 'regionLevel',
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
dicUrl: '/blade-system/dict/dictionary?code=region',
|
dicUrl: '/blade-system/dict/dictionary?code=region',
|
||||||
dicFormatter: list => list.filter(item => Number(item.dictKey) !== 0),
|
dicFormatter: response => {
|
||||||
|
const list = Array.isArray(response) ? response : response?.data;
|
||||||
|
return (Array.isArray(list) ? list : [])
|
||||||
|
.filter(item => Number(item.dictKey) !== 0)
|
||||||
|
.map(item => ({ ...item, dictKey: Number(item.dictKey) }));
|
||||||
|
},
|
||||||
props: {
|
props: {
|
||||||
label: 'dictValue',
|
label: 'dictValue',
|
||||||
value: 'dictKey',
|
value: 'dictKey',
|
||||||
|
|||||||
@@ -4796,6 +4796,13 @@ export default {
|
|||||||
},
|
},
|
||||||
normalizeRow(row, saveAsDraft = false) {
|
normalizeRow(row, saveAsDraft = false) {
|
||||||
const submitRow = { ...row };
|
const submitRow = { ...row };
|
||||||
|
const isAddMode =
|
||||||
|
this.crudDialogType === 'add' ||
|
||||||
|
(this.isStandaloneWaybillFormPage && this.$route.query.mode === 'add');
|
||||||
|
if (isAddMode) {
|
||||||
|
delete submitRow.id;
|
||||||
|
delete submitRow.waybillNo;
|
||||||
|
}
|
||||||
const skipValidation = saveAsDraft && this.config.skipDraftValidation === true;
|
const skipValidation = saveAsDraft && this.config.skipDraftValidation === true;
|
||||||
if (
|
if (
|
||||||
!skipValidation &&
|
!skipValidation &&
|
||||||
@@ -5166,6 +5173,7 @@ export default {
|
|||||||
// 清除不应该复制的字段
|
// 清除不应该复制的字段
|
||||||
delete sourceData.id;
|
delete sourceData.id;
|
||||||
delete sourceData.code;
|
delete sourceData.code;
|
||||||
|
delete sourceData.waybillNo;
|
||||||
delete sourceData.waybillStatus;
|
delete sourceData.waybillStatus;
|
||||||
delete sourceData.createTime;
|
delete sourceData.createTime;
|
||||||
delete sourceData.updateTime;
|
delete sourceData.updateTime;
|
||||||
@@ -5236,6 +5244,10 @@ export default {
|
|||||||
['quantity', 'mileage', 'unitPrice'].forEach(prop => {
|
['quantity', 'mileage', 'unitPrice'].forEach(prop => {
|
||||||
if (Number(this.form[prop]) === -1) this.form[prop] = '';
|
if (Number(this.form[prop]) === -1) this.form[prop] = '';
|
||||||
});
|
});
|
||||||
|
if ([this.form.planId, this.form.planName].some(value => Number(value) === -1)) {
|
||||||
|
this.form.planId = '';
|
||||||
|
this.form.planName = '';
|
||||||
|
}
|
||||||
this.form.mileage = this.normalizeMileageValue(this.form.mileage);
|
this.form.mileage = this.normalizeMileageValue(this.form.mileage);
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.suppressTransportTypeClear = false;
|
this.suppressTransportTypeClear = false;
|
||||||
|
|||||||
@@ -1199,9 +1199,7 @@ export default {
|
|||||||
this.selectedAttachmentRows = [];
|
this.selectedAttachmentRows = [];
|
||||||
this.invoices = data.invoices || [];
|
this.invoices = data.invoices || [];
|
||||||
this.sortAttachments();
|
this.sortAttachments();
|
||||||
this.contracts = this.allContracts.filter(
|
this.contracts = this.filterContracts(this.allContracts, this.form.projectId);
|
||||||
item => String(item.projectId) === String(this.form.projectId)
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
async initialize() {
|
async initialize() {
|
||||||
const newRecordAudit = this.recordId
|
const newRecordAudit = this.recordId
|
||||||
@@ -1211,6 +1209,11 @@ export default {
|
|||||||
createTime: this.$dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
createTime: this.$dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||||
};
|
};
|
||||||
this.form = createFormalSettlementForm();
|
this.form = createFormalSettlementForm();
|
||||||
|
if (['receivable', 'payable'].includes(this.initialData?.settlementType)) {
|
||||||
|
this.form.settlementType = this.initialData.settlementType;
|
||||||
|
this.form.settlementTypeName =
|
||||||
|
this.initialData.settlementType === 'receivable' ? '应收' : '应付';
|
||||||
|
}
|
||||||
if (newRecordAudit) Object.assign(this.form, newRecordAudit);
|
if (newRecordAudit) Object.assign(this.form, newRecordAudit);
|
||||||
this.sources = [];
|
this.sources = [];
|
||||||
this.details = [];
|
this.details = [];
|
||||||
@@ -1276,7 +1279,7 @@ export default {
|
|||||||
if (!rows.length) return;
|
if (!rows.length) return;
|
||||||
const first = rows[0];
|
const first = rows[0];
|
||||||
const settlementType = this.initialData.settlementType || first.settlementType || 'payable';
|
const settlementType = this.initialData.settlementType || first.settlementType || 'payable';
|
||||||
const matchedContract = this.allContracts.find(
|
const matchedContract = this.filterContracts(this.allContracts, null, settlementType).find(
|
||||||
item =>
|
item =>
|
||||||
(first.contractId && String(item.id) === String(first.contractId)) ||
|
(first.contractId && String(item.id) === String(first.contractId)) ||
|
||||||
(first.contractNo && String(item.contractNo) === String(first.contractNo))
|
(first.contractNo && String(item.contractNo) === String(first.contractNo))
|
||||||
@@ -1284,9 +1287,7 @@ export default {
|
|||||||
const contractId = first.contractId || matchedContract?.id || null;
|
const contractId = first.contractId || matchedContract?.id || null;
|
||||||
const projectId = first.projectId || matchedContract?.projectId || null;
|
const projectId = first.projectId || matchedContract?.projectId || null;
|
||||||
const projectName = first.projectName || matchedContract?.projectName || '';
|
const projectName = first.projectName || matchedContract?.projectName || '';
|
||||||
this.contracts = this.allContracts.filter(
|
this.contracts = this.filterContracts(this.allContracts, projectId, settlementType);
|
||||||
item => projectId && String(item.projectId) === String(projectId)
|
|
||||||
);
|
|
||||||
if (projectId && !this.projects.some(item => String(item.id) === String(projectId))) {
|
if (projectId && !this.projects.some(item => String(item.id) === String(projectId))) {
|
||||||
this.projects.push({ id: projectId, name: projectName });
|
this.projects.push({ id: projectId, name: projectName });
|
||||||
}
|
}
|
||||||
@@ -1404,6 +1405,25 @@ export default {
|
|||||||
this.projects = [...projectMap.values()];
|
this.projects = [...projectMap.values()];
|
||||||
this.contracts = [];
|
this.contracts = [];
|
||||||
},
|
},
|
||||||
|
contractCategory(settlementType = this.form.settlementType) {
|
||||||
|
if (settlementType === 'receivable') return '客户合同';
|
||||||
|
if (settlementType === 'payable') return '承运商合同';
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
filterContracts(items, projectId, settlementType = this.form.settlementType) {
|
||||||
|
const category = this.contractCategory(settlementType);
|
||||||
|
return (items || []).filter(item => {
|
||||||
|
if (projectId && String(item.projectId) !== String(projectId)) return false;
|
||||||
|
if (!category) return true;
|
||||||
|
const itemCategory = String(item.contractCategory || '').trim();
|
||||||
|
if (itemCategory) return itemCategory === category;
|
||||||
|
const itemSettlementType = String(item.settlementType || '').trim();
|
||||||
|
return (
|
||||||
|
(category === '客户合同' && itemSettlementType === 'receivable') ||
|
||||||
|
(category === '承运商合同' && itemSettlementType === 'payable')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
async loadContracts(keyword = '') {
|
async loadContracts(keyword = '') {
|
||||||
const projectId = this.form.projectId;
|
const projectId = this.form.projectId;
|
||||||
if (!projectId) {
|
if (!projectId) {
|
||||||
@@ -1412,7 +1432,7 @@ export default {
|
|||||||
}
|
}
|
||||||
const response = await getContractOptions(keyword, projectId);
|
const response = await getContractOptions(keyword, projectId);
|
||||||
if (String(this.form.projectId) === String(projectId)) {
|
if (String(this.form.projectId) === String(projectId)) {
|
||||||
this.contracts = this.unwrapData(response) || [];
|
this.contracts = this.filterContracts(this.unwrapData(response), projectId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async loadFeeOptions() {
|
async loadFeeOptions() {
|
||||||
@@ -1444,16 +1464,24 @@ export default {
|
|||||||
const contract = this.contracts.find(item => String(item.id) === String(id));
|
const contract = this.contracts.find(item => String(item.id) === String(id));
|
||||||
if (!contract) return;
|
if (!contract) return;
|
||||||
const formalSettlementId = this.form.id;
|
const formalSettlementId = this.form.id;
|
||||||
|
const settlementType =
|
||||||
|
contract.settlementType ||
|
||||||
|
(contract.contractCategory === '客户合同'
|
||||||
|
? 'receivable'
|
||||||
|
: contract.contractCategory === '承运商合同'
|
||||||
|
? 'payable'
|
||||||
|
: this.form.settlementType);
|
||||||
Object.assign(this.form, contract, {
|
Object.assign(this.form, contract, {
|
||||||
id: formalSettlementId,
|
id: formalSettlementId,
|
||||||
contractId: contract.id,
|
contractId: contract.id,
|
||||||
payerName:
|
payerName:
|
||||||
contract.payerName ||
|
contract.payerName ||
|
||||||
(contract.settlementType === 'receivable' ? contract.partyB : contract.partyA),
|
(settlementType === 'receivable' ? contract.partyB : contract.partyA),
|
||||||
payeeName:
|
payeeName:
|
||||||
contract.payeeName ||
|
contract.payeeName ||
|
||||||
(contract.settlementType === 'receivable' ? contract.partyA : contract.partyB),
|
(settlementType === 'receivable' ? contract.partyA : contract.partyB),
|
||||||
settlementTypeName: contract.settlementType === 'receivable' ? '应收' : '应付',
|
settlementType,
|
||||||
|
settlementTypeName: settlementType === 'receivable' ? '应收' : '应付',
|
||||||
});
|
});
|
||||||
this.sources = [];
|
this.sources = [];
|
||||||
this.details = [];
|
this.details = [];
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
page-mode
|
page-mode
|
||||||
:record-id="recordId"
|
:record-id="recordId"
|
||||||
:readonly="readonly"
|
:readonly="readonly"
|
||||||
:initial-data="transferPayload"
|
:initial-data="editorInitialData"
|
||||||
/>
|
/>
|
||||||
</basic-container>
|
</basic-container>
|
||||||
</template>
|
</template>
|
||||||
@@ -35,6 +35,14 @@ export default {
|
|||||||
pageTitle() {
|
pageTitle() {
|
||||||
return this.readonly ? '查看正式结算' : this.recordId ? '编辑正式结算' : '新增正式结算';
|
return this.readonly ? '查看正式结算' : this.recordId ? '编辑正式结算' : '新增正式结算';
|
||||||
},
|
},
|
||||||
|
editorInitialData() {
|
||||||
|
const settlementType = this.$route.query.settlementType;
|
||||||
|
if (!this.transferPayload && !settlementType) return null;
|
||||||
|
return {
|
||||||
|
...(this.transferPayload || {}),
|
||||||
|
...(settlementType ? { settlementType } : {}),
|
||||||
|
};
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
editorVisible(value) {
|
editorVisible(value) {
|
||||||
|
|||||||
@@ -299,7 +299,11 @@ export default {
|
|||||||
openCreate() {
|
openCreate() {
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
path: '/settlement/formal-settlement/form',
|
path: '/settlement/formal-settlement/form',
|
||||||
query: { mode: 'add', name: '新增正式结算' },
|
query: {
|
||||||
|
mode: 'add',
|
||||||
|
name: '新增正式结算',
|
||||||
|
settlementType: this.activeSettlementType,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
openEdit(row) {
|
openEdit(row) {
|
||||||
|
|||||||
@@ -143,7 +143,7 @@
|
|||||||
maxlength="18"
|
maxlength="18"
|
||||||
show-word-limit
|
show-word-limit
|
||||||
placeholder="请输入"
|
placeholder="请输入"
|
||||||
@input="driverForm.idCardNo = String(driverForm.idCardNo || '').toUpperCase()"
|
@input="handleIdCardInput"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -1121,6 +1121,26 @@ export default {
|
|||||||
removeDigits(value = '') {
|
removeDigits(value = '') {
|
||||||
return String(value).replace(/\d/g, '');
|
return String(value).replace(/\d/g, '');
|
||||||
},
|
},
|
||||||
|
handleIdCardInput(value) {
|
||||||
|
const idCardNo = String(value || '').toUpperCase();
|
||||||
|
this.driverForm.idCardNo = idCardNo;
|
||||||
|
const idCardInfo = this.parseIdCardInfo(idCardNo);
|
||||||
|
if (idCardInfo.birthday) {
|
||||||
|
this.driverForm.birthday = idCardInfo.birthday;
|
||||||
|
} else {
|
||||||
|
this.driverForm.birthday = '';
|
||||||
|
}
|
||||||
|
if (idCardInfo.gender) {
|
||||||
|
this.driverForm.gender = idCardInfo.gender;
|
||||||
|
} else {
|
||||||
|
this.driverForm.gender = '';
|
||||||
|
}
|
||||||
|
if (this.submitAttempted) {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.driverForm?.validateField(['idCardNo', 'birthday', 'gender']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
openDriver(row, readonly = false) {
|
openDriver(row, readonly = false) {
|
||||||
this.readonly = readonly;
|
this.readonly = readonly;
|
||||||
this.submitAttempted = false;
|
this.submitAttempted = false;
|
||||||
|
|||||||
@@ -0,0 +1,429 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container class="vehicle-dispatch-page">
|
||||||
|
<avue-crud
|
||||||
|
ref="crud"
|
||||||
|
v-model="form"
|
||||||
|
v-model:page="page"
|
||||||
|
:data="data"
|
||||||
|
:option="option"
|
||||||
|
:permission="permissionList"
|
||||||
|
:table-loading="loading"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
v-if="hasPermission('vehicle_dispatch_add')"
|
||||||
|
type="primary"
|
||||||
|
@click="$refs.crud.rowAdd()"
|
||||||
|
>
|
||||||
|
新增
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="hasPermission('vehicle_dispatch_export')"
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
@click="handleExport"
|
||||||
|
>
|
||||||
|
导出
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #applicationNo="{ row }">
|
||||||
|
<el-link type="primary" @click="$refs.crud.rowView(row)">{{ row.applicationNo }}</el-link>
|
||||||
|
</template>
|
||||||
|
<template #plateNo-form>
|
||||||
|
<el-autocomplete
|
||||||
|
class="vehicle-dispatch-form-control"
|
||||||
|
v-model="form.plateNo"
|
||||||
|
value-key="value"
|
||||||
|
clearable
|
||||||
|
:fetch-suggestions="fetchVehicleSuggestions"
|
||||||
|
:disabled="dialogType === 'view'"
|
||||||
|
placeholder="请选择车辆"
|
||||||
|
@input="handleVehicleInput"
|
||||||
|
@select="handleVehicleSelect"
|
||||||
|
@blur="handleVehicleBlur"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #useDepartment-form>
|
||||||
|
<el-cascader
|
||||||
|
class="vehicle-dispatch-form-control"
|
||||||
|
v-model="deptCascaderValue"
|
||||||
|
:options="deptOptions"
|
||||||
|
:props="deptCascaderProps"
|
||||||
|
:disabled="dialogType === 'view'"
|
||||||
|
clearable
|
||||||
|
filterable
|
||||||
|
placeholder="请选择使用部门"
|
||||||
|
@change="handleDepartmentChange"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #attachments="{ row }">
|
||||||
|
<span>{{ formatAttachments(row.attachments) }}</span>
|
||||||
|
</template>
|
||||||
|
<template #attachmentsForm>
|
||||||
|
<vehicle-attachment-table v-model="form.attachments" :readonly="dialogType === 'view'" />
|
||||||
|
</template>
|
||||||
|
<template #attachments-form>
|
||||||
|
<vehicle-attachment-table v-model="form.attachments" :readonly="dialogType === 'view'" />
|
||||||
|
</template>
|
||||||
|
<template #approvalStatus="{ row }">
|
||||||
|
<el-tag :type="statusTagType(row.approvalStatus)" class="status-text">
|
||||||
|
{{ statusName(row.approvalStatus) }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
<template #menu="{ row }">
|
||||||
|
<el-link
|
||||||
|
v-if="hasPermission('vehicle_dispatch_view')"
|
||||||
|
type="primary"
|
||||||
|
@click="$refs.crud.rowView(row)"
|
||||||
|
>
|
||||||
|
查看
|
||||||
|
</el-link>
|
||||||
|
<el-link
|
||||||
|
v-if="
|
||||||
|
hasPermission('vehicle_dispatch_edit') &&
|
||||||
|
['draft', 'rejected'].includes(row.approvalStatus)
|
||||||
|
"
|
||||||
|
type="primary"
|
||||||
|
@click="$refs.crud.rowEdit(row)"
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</el-link>
|
||||||
|
<el-link
|
||||||
|
v-if="hasPermission('vehicle_dispatch_submit') && row.approvalStatus === 'draft'"
|
||||||
|
type="primary"
|
||||||
|
@click="handleSubmitApproval(row)"
|
||||||
|
>
|
||||||
|
提交
|
||||||
|
</el-link>
|
||||||
|
<el-link
|
||||||
|
v-if="hasPermission('vehicle_dispatch_approve') && row.approvalStatus === 'reviewing'"
|
||||||
|
type="success"
|
||||||
|
@click="handleApprove(row)"
|
||||||
|
>
|
||||||
|
审核通过
|
||||||
|
</el-link>
|
||||||
|
<el-link
|
||||||
|
v-if="
|
||||||
|
hasPermission('vehicle_dispatch_delete') &&
|
||||||
|
['draft', 'rejected'].includes(row.approvalStatus)
|
||||||
|
"
|
||||||
|
type="danger"
|
||||||
|
@click="handleDelete(row.id)"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</el-link>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
<empty-pagination
|
||||||
|
:page="page"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@load="onLoad(page, query)"
|
||||||
|
/>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import {
|
||||||
|
approve,
|
||||||
|
exportVehicleDispatch,
|
||||||
|
getDetail,
|
||||||
|
getList,
|
||||||
|
remove,
|
||||||
|
submit,
|
||||||
|
submitApproval,
|
||||||
|
} from '@/api/transportCapacity/vehicle-dispatch';
|
||||||
|
import { getList as getVehicleList } from '@/api/transportCapacity/transport-vehicle';
|
||||||
|
import { getDeptTree } from '@/api/system/dept';
|
||||||
|
import VehicleAttachmentTable from '@/components/vehicle-attachment-table/main.vue';
|
||||||
|
import { option, statusName } from '@/option/transportCapacity/vehicle-dispatch';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
VehicleAttachmentTable,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
option,
|
||||||
|
form: {},
|
||||||
|
query: {},
|
||||||
|
dialogType: '',
|
||||||
|
deptOptions: [],
|
||||||
|
deptCascaderValue: [],
|
||||||
|
selectedVehicleValue: '',
|
||||||
|
data: [],
|
||||||
|
loading: false,
|
||||||
|
selectionList: [],
|
||||||
|
page: { pageSize: 10, pageSizes: [10, 20, 50, 100], currentPage: 1, total: 0 },
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.initDepartmentTree();
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission', 'userInfo']),
|
||||||
|
permissionList() {
|
||||||
|
return { addBtn: this.hasPermission('vehicle_dispatch_add') };
|
||||||
|
},
|
||||||
|
deptCascaderProps() {
|
||||||
|
return { label: 'title', value: 'id', children: 'children', checkStrictly: true };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
statusName,
|
||||||
|
hasPermission(code) {
|
||||||
|
return (
|
||||||
|
String(this.userInfo?.authority || '').includes('admin') || this.permission?.[code] === true
|
||||||
|
);
|
||||||
|
},
|
||||||
|
statusTagType(status) {
|
||||||
|
return { approved: 'success', reviewing: 'warning', rejected: 'danger' }[status] || 'info';
|
||||||
|
},
|
||||||
|
formatAttachments(value) {
|
||||||
|
if (!value) return '';
|
||||||
|
if (Array.isArray(value)) return `${value.length} 个`;
|
||||||
|
if (typeof value !== 'string') return '1 个';
|
||||||
|
try {
|
||||||
|
const attachments = JSON.parse(value);
|
||||||
|
return Array.isArray(attachments) ? `${attachments.length} 个` : '1 个';
|
||||||
|
} catch (error) {
|
||||||
|
return `${value.split(',').filter(item => item.trim()).length} 个`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
parseAttachments(value) {
|
||||||
|
if (!value || Array.isArray(value)) return value || [];
|
||||||
|
if (typeof value !== 'string') return [];
|
||||||
|
try {
|
||||||
|
const attachments = JSON.parse(value);
|
||||||
|
return Array.isArray(attachments) ? attachments : [];
|
||||||
|
} catch (error) {
|
||||||
|
return value
|
||||||
|
.split(',')
|
||||||
|
.map(item => ({ name: item.trim(), url: item.trim() }))
|
||||||
|
.filter(item => item.url);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
stringifyAttachments(value) {
|
||||||
|
if (!value || typeof value === 'string') return value;
|
||||||
|
return JSON.stringify(value);
|
||||||
|
},
|
||||||
|
normalizeRow(row) {
|
||||||
|
const values = { ...row };
|
||||||
|
values.attachments = this.stringifyAttachments(values.attachments);
|
||||||
|
return values;
|
||||||
|
},
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
if (!this.selectedVehicleValue || row.plateNo !== this.selectedVehicleValue) {
|
||||||
|
this.$message.warning('请选择调度车辆');
|
||||||
|
loading();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
submit(this.normalizeRow(row))
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad();
|
||||||
|
this.$message.success('操作成功');
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
.catch(() => loading());
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
this.rowSave(row, done, loading);
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
this.dialogType = type;
|
||||||
|
getDetail(this.form.id)
|
||||||
|
.then(res => {
|
||||||
|
this.form = res.data.data || {};
|
||||||
|
this.form.attachments = this.parseAttachments(this.form.attachments);
|
||||||
|
this.selectedVehicleValue = this.form.plateNo || '';
|
||||||
|
this.deptCascaderValue = this.findDepartmentPath(this.form.useDepartment);
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
.catch(() => done());
|
||||||
|
} else {
|
||||||
|
this.dialogType = 'add';
|
||||||
|
this.deptCascaderValue = [];
|
||||||
|
this.selectedVehicleValue = '';
|
||||||
|
this.form.attachments = [];
|
||||||
|
this.form.approvalStatus = 'draft';
|
||||||
|
this.form.createUserName =
|
||||||
|
this.userInfo?.realName || this.userInfo?.userName || this.userInfo?.account || '';
|
||||||
|
this.form.createTime = this.$dayjs().format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
initDepartmentTree() {
|
||||||
|
getDeptTree(this.userInfo?.tenantId)
|
||||||
|
.then(res => {
|
||||||
|
this.deptOptions = this.filterExternalDepartments(res.data.data || []);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.deptOptions = [];
|
||||||
|
});
|
||||||
|
},
|
||||||
|
filterExternalDepartments(tree) {
|
||||||
|
return (tree || [])
|
||||||
|
.filter(item => (item.title || item.deptName || item.name) !== '外部组织')
|
||||||
|
.map(item => ({
|
||||||
|
...item,
|
||||||
|
children: this.filterExternalDepartments(item.children),
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
findDepartmentPath(departmentName, tree = this.deptOptions, parents = []) {
|
||||||
|
if (!departmentName) return [];
|
||||||
|
for (const item of tree || []) {
|
||||||
|
const path = [...parents, item.id];
|
||||||
|
const itemName = item.title || item.deptName || item.name;
|
||||||
|
if (itemName === departmentName) return path;
|
||||||
|
const matched = this.findDepartmentPath(departmentName, item.children, path);
|
||||||
|
if (matched.length) return matched;
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
},
|
||||||
|
findDepartmentNode(id, tree = this.deptOptions) {
|
||||||
|
for (const item of tree || []) {
|
||||||
|
if (String(item.id) === String(id)) return item;
|
||||||
|
const matched = this.findDepartmentNode(id, item.children);
|
||||||
|
if (matched) return matched;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
handleDepartmentChange(value) {
|
||||||
|
const node = this.findDepartmentNode(value?.[value.length - 1]);
|
||||||
|
this.form.useDepartment = node ? node.title || node.deptName || node.name || '' : '';
|
||||||
|
},
|
||||||
|
fetchVehicleSuggestions(queryString, callback) {
|
||||||
|
getVehicleList(1, 9999, {
|
||||||
|
plateNo: queryString || '',
|
||||||
|
status: 1,
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
const records = res.data.data?.records || [];
|
||||||
|
callback(
|
||||||
|
records.map(item => ({
|
||||||
|
value: item.plateNo,
|
||||||
|
organizationName: item.organizationName,
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.catch(() => callback([]));
|
||||||
|
},
|
||||||
|
handleVehicleSelect(vehicle) {
|
||||||
|
this.form.plateNo = vehicle.value;
|
||||||
|
this.form.organizationName = vehicle.organizationName || '';
|
||||||
|
this.selectedVehicleValue = vehicle.value;
|
||||||
|
},
|
||||||
|
handleVehicleInput(value) {
|
||||||
|
if (value !== this.selectedVehicleValue) {
|
||||||
|
this.selectedVehicleValue = '';
|
||||||
|
this.form.organizationName = '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleVehicleBlur() {
|
||||||
|
if (this.form.plateNo && this.form.plateNo !== this.selectedVehicleValue) {
|
||||||
|
this.form.plateNo = '';
|
||||||
|
this.form.organizationName = '';
|
||||||
|
this.$message.warning('请从下拉列表中选择调度车辆');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleSubmitApproval(row) {
|
||||||
|
this.$confirm('确定提交该车辆调度申请吗?', '提示', { type: 'warning' })
|
||||||
|
.then(() => submitApproval(row.id))
|
||||||
|
.then(() => {
|
||||||
|
this.$message.success('提交成功');
|
||||||
|
this.onLoad();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleApprove(row) {
|
||||||
|
this.$confirm('审核通过后将同步更新车辆使用部门,确认继续吗?', '提示', { type: 'warning' })
|
||||||
|
.then(() => approve(row.id))
|
||||||
|
.then(() => {
|
||||||
|
this.$message.success('审核通过');
|
||||||
|
this.onLoad();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDelete(ids) {
|
||||||
|
const targetIds = ids || this.selectionList.map(item => item.id).join(',');
|
||||||
|
if (!targetIds) return this.$message.warning('请选择至少一条数据');
|
||||||
|
this.$confirm('确定删除所选数据,删除后不可恢复?', '提示', { type: 'warning' })
|
||||||
|
.then(() => remove(targetIds))
|
||||||
|
.then(() => {
|
||||||
|
this.$message.success('操作成功');
|
||||||
|
this.onLoad();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleExport() {
|
||||||
|
exportVehicleDispatch(this.query).then(res => {
|
||||||
|
const blob = new Blob([res.data]);
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = URL.createObjectURL(blob);
|
||||||
|
link.download = `车辆调度${this.$dayjs().format('YYYYMMDDHHmmss')}.xlsx`;
|
||||||
|
link.click();
|
||||||
|
URL.revokeObjectURL(link.href);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = { ...params };
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad();
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
this.onLoad();
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad();
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad();
|
||||||
|
},
|
||||||
|
onLoad() {
|
||||||
|
this.loading = true;
|
||||||
|
return getList(this.page.currentPage, this.page.pageSize, this.query)
|
||||||
|
.then(res => {
|
||||||
|
const result = res.data.data || {};
|
||||||
|
this.data = result.records || [];
|
||||||
|
this.page.total = result.total || 0;
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.vehicle-dispatch-page :deep(.avue-crud__header) {
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
.vehicle-dispatch-page :deep(.el-link + .el-link) {
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
|
.vehicle-dispatch-page :deep(.vehicle-dispatch-form-control) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user