调整 基础数据、运力、车船务
This commit is contained in:
@@ -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',
|
||||
type: 'radio',
|
||||
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: {
|
||||
label: 'dictValue',
|
||||
value: 'dictKey',
|
||||
|
||||
@@ -4796,6 +4796,13 @@ export default {
|
||||
},
|
||||
normalizeRow(row, saveAsDraft = false) {
|
||||
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;
|
||||
if (
|
||||
!skipValidation &&
|
||||
@@ -5166,6 +5173,7 @@ export default {
|
||||
// 清除不应该复制的字段
|
||||
delete sourceData.id;
|
||||
delete sourceData.code;
|
||||
delete sourceData.waybillNo;
|
||||
delete sourceData.waybillStatus;
|
||||
delete sourceData.createTime;
|
||||
delete sourceData.updateTime;
|
||||
@@ -5236,6 +5244,10 @@ export default {
|
||||
['quantity', 'mileage', 'unitPrice'].forEach(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.$nextTick(() => {
|
||||
this.suppressTransportTypeClear = false;
|
||||
|
||||
@@ -1199,9 +1199,7 @@ export default {
|
||||
this.selectedAttachmentRows = [];
|
||||
this.invoices = data.invoices || [];
|
||||
this.sortAttachments();
|
||||
this.contracts = this.allContracts.filter(
|
||||
item => String(item.projectId) === String(this.form.projectId)
|
||||
);
|
||||
this.contracts = this.filterContracts(this.allContracts, this.form.projectId);
|
||||
},
|
||||
async initialize() {
|
||||
const newRecordAudit = this.recordId
|
||||
@@ -1211,6 +1209,11 @@ export default {
|
||||
createTime: this.$dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
};
|
||||
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);
|
||||
this.sources = [];
|
||||
this.details = [];
|
||||
@@ -1276,7 +1279,7 @@ export default {
|
||||
if (!rows.length) return;
|
||||
const first = rows[0];
|
||||
const settlementType = this.initialData.settlementType || first.settlementType || 'payable';
|
||||
const matchedContract = this.allContracts.find(
|
||||
const matchedContract = this.filterContracts(this.allContracts, null, settlementType).find(
|
||||
item =>
|
||||
(first.contractId && String(item.id) === String(first.contractId)) ||
|
||||
(first.contractNo && String(item.contractNo) === String(first.contractNo))
|
||||
@@ -1284,9 +1287,7 @@ export default {
|
||||
const contractId = first.contractId || matchedContract?.id || null;
|
||||
const projectId = first.projectId || matchedContract?.projectId || null;
|
||||
const projectName = first.projectName || matchedContract?.projectName || '';
|
||||
this.contracts = this.allContracts.filter(
|
||||
item => projectId && String(item.projectId) === String(projectId)
|
||||
);
|
||||
this.contracts = this.filterContracts(this.allContracts, projectId, settlementType);
|
||||
if (projectId && !this.projects.some(item => String(item.id) === String(projectId))) {
|
||||
this.projects.push({ id: projectId, name: projectName });
|
||||
}
|
||||
@@ -1404,6 +1405,25 @@ export default {
|
||||
this.projects = [...projectMap.values()];
|
||||
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 = '') {
|
||||
const projectId = this.form.projectId;
|
||||
if (!projectId) {
|
||||
@@ -1412,7 +1432,7 @@ export default {
|
||||
}
|
||||
const response = await getContractOptions(keyword, projectId);
|
||||
if (String(this.form.projectId) === String(projectId)) {
|
||||
this.contracts = this.unwrapData(response) || [];
|
||||
this.contracts = this.filterContracts(this.unwrapData(response), projectId);
|
||||
}
|
||||
},
|
||||
async loadFeeOptions() {
|
||||
@@ -1444,16 +1464,24 @@ export default {
|
||||
const contract = this.contracts.find(item => String(item.id) === String(id));
|
||||
if (!contract) return;
|
||||
const formalSettlementId = this.form.id;
|
||||
const settlementType =
|
||||
contract.settlementType ||
|
||||
(contract.contractCategory === '客户合同'
|
||||
? 'receivable'
|
||||
: contract.contractCategory === '承运商合同'
|
||||
? 'payable'
|
||||
: this.form.settlementType);
|
||||
Object.assign(this.form, contract, {
|
||||
id: formalSettlementId,
|
||||
contractId: contract.id,
|
||||
payerName:
|
||||
contract.payerName ||
|
||||
(contract.settlementType === 'receivable' ? contract.partyB : contract.partyA),
|
||||
(settlementType === 'receivable' ? contract.partyB : contract.partyA),
|
||||
payeeName:
|
||||
contract.payeeName ||
|
||||
(contract.settlementType === 'receivable' ? contract.partyA : contract.partyB),
|
||||
settlementTypeName: contract.settlementType === 'receivable' ? '应收' : '应付',
|
||||
(settlementType === 'receivable' ? contract.partyA : contract.partyB),
|
||||
settlementType,
|
||||
settlementTypeName: settlementType === 'receivable' ? '应收' : '应付',
|
||||
});
|
||||
this.sources = [];
|
||||
this.details = [];
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
page-mode
|
||||
:record-id="recordId"
|
||||
:readonly="readonly"
|
||||
:initial-data="transferPayload"
|
||||
:initial-data="editorInitialData"
|
||||
/>
|
||||
</basic-container>
|
||||
</template>
|
||||
@@ -35,6 +35,14 @@ export default {
|
||||
pageTitle() {
|
||||
return this.readonly ? '查看正式结算' : this.recordId ? '编辑正式结算' : '新增正式结算';
|
||||
},
|
||||
editorInitialData() {
|
||||
const settlementType = this.$route.query.settlementType;
|
||||
if (!this.transferPayload && !settlementType) return null;
|
||||
return {
|
||||
...(this.transferPayload || {}),
|
||||
...(settlementType ? { settlementType } : {}),
|
||||
};
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
editorVisible(value) {
|
||||
|
||||
@@ -299,7 +299,11 @@ export default {
|
||||
openCreate() {
|
||||
this.$router.push({
|
||||
path: '/settlement/formal-settlement/form',
|
||||
query: { mode: 'add', name: '新增正式结算' },
|
||||
query: {
|
||||
mode: 'add',
|
||||
name: '新增正式结算',
|
||||
settlementType: this.activeSettlementType,
|
||||
},
|
||||
});
|
||||
},
|
||||
openEdit(row) {
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
maxlength="18"
|
||||
show-word-limit
|
||||
placeholder="请输入"
|
||||
@input="driverForm.idCardNo = String(driverForm.idCardNo || '').toUpperCase()"
|
||||
@input="handleIdCardInput"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -1121,6 +1121,26 @@ export default {
|
||||
removeDigits(value = '') {
|
||||
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) {
|
||||
this.readonly = readonly;
|
||||
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