factory_web/src/views/ofm/vehicle.vue

303 lines
7.4 KiB
Vue

<template>
<el-container>
<el-header>
<div class="left-panel-group">
<el-button
type="primary"
icon="el-icon-plus"
@click="handleAdd"
v-auth="'vehicle.create'"
></el-button>
</div>
</el-header>
<el-main class="nopadding">
<scTable ref="table" :apiObj="apiObj" row-key="id">
<el-table-column label="#" type="index"></el-table-column>
<el-table-column
label="日期"
prop="create_time"
min-width="100"
></el-table-column>
<el-table-column
label="用车部门"
prop="belong_dept_name"
min-width="100"
></el-table-column>
<el-table-column
label="用车人"
prop="create_by_name"
min-width="120">
</el-table-column>
<el-table-column
label="用车事由"
prop="reason"
min-width="120">
</el-table-column>
<el-table-column label="市内用车" prop="is_city" mim-width="100">
<template #default="scope">
<span :style="{color: scope.row.is_city ? '#67C23A' : '#F56C6C'}">
{{ scope.row.is_city ? '是' : '否'}}
</span>
</template>
</el-table-column>
<el-table-column
label="出车时间"
prop="start_time"
min-width="100"
></el-table-column>
<el-table-column
label="发车地点"
prop="location"
min-width="100"
></el-table-column>
<el-table-column
label="途经地点"
prop="via"
min-width="100"
></el-table-column>
<el-table-column
label="到底地点"
prop="destination"
min-width="100"
></el-table-column>
<el-table-column
label="收车时间"
prop="end_time"
min-width="100"
></el-table-column>
<el-table-column
label="出发公里(km)"
prop="start_km"
min-width="100"
></el-table-column>
<el-table-column
label="结束公里(km)"
prop="end_km"
min-width="100"
></el-table-column>
<el-table-column
label="使用公里(km)"
prop="actual_km"
min-width="100"
></el-table-column>
<el-table-column label="操作" fixed="right" align="center" width="250">
<template #default="scope">
<el-button
link
size="small"
type="primary"
@click="vehicleEidt(scope.row)"
v-auth="'vehicle.update'"
>详情
</el-button>
<el-popconfirm
title="确定删除吗?"
@confirm="vehicleDel(scope.row)"
>
<template #reference>
<el-button
link
size="small"
type="danger"
v-auth="'vehicle.delete'"
>删除</el-button
>
</template>
</el-popconfirm>
</template>
</el-table-column>
</scTable>
</el-main>
</el-container>
<el-drawer
:title="drawerTitle[type]"
v-model="limitedVisible"
:destroy-on-close="true"
direction="rtl"
size="70%">
<div style="display: flex; height: calc(100% - 60px);">
<div style="flex: 1; padding-right: 20px; overflow-y: auto;">
<VehicleForm
:mode="type"
v-model="addForm"
:lending_type="lending_type"
:transitions="transitions"
@success="()=>{handleQuery(); limitedVisible = false}"
@closed="limitedVisible = false"
/>
</div>
</div>
</el-drawer>
</template>
<script>
import VehicleForm from "./vehicleForm.vue";
export default {
components: {
VehicleForm
},
name: "index",
data() {
return {
workflowName:"",
workFlowId:'',
apiObj: this.$API.ofm.vehicle.list,
selection: [],
checkList: [],
transitions:[],
drawerTitle: {
add: "新增车辆使用",
edit: "编辑车辆使用",
view: "查看车辆使用",
},
timeRange: [],
lending_type: "",
choiceOption: [],
query: {},
editId: null,
isSaving: false,
limitedVisible: false,
limitedWatch: false,
type: "add",
//表单数据
addForm: {
start_time: null,
end_time: null,
location: null,
via: null,
destination: null,
start_km: null,
end_km: null,
is_city: true,
reason: null,
ticket_:null
},
};
},
mounted(){
let that = this;
that.getInit();
},
methods: {
getInit() {
let that = this;
if(this.addForm.ticket_!==null){
this.$API.wf.ticket_.ticketTransitions.req(this.addForm.ticket_).then((res) => {
that.transitions = res;
})
}else{
that.$API.wf.workflow.initkey.req("vehicle").then((res) => {
that.initForm = res;
that.transitions = res.transitions;
});
}
},
handleAdd() {
this.type = "add";
this.addForm = this.getDefaultForm();
this.limitedVisible = true;
},
getDefaultForm(){
return {
start_time: null,
end_time: null,
location: null,
via: null,
destination: null,
start_km: null,
end_km: null,
is_city: true,
reason: null,
ticket_:null
}
},
// 审批流结束之后才可以编辑
vehicleEidt(row) {
this.type = "view";
this.editId = row.id;
this.limitedVisible = true;
this.addForm = Object.assign({}, row);
},
// 更新审批流
saveVehicle() {
this.isSaving = true;
this.$API.ofm.vehicle.update.req(this.addForm.id, this.addForm).then((res) => {
this.isSaving = false;
if (res.err_code) {
this.$message.error(res.err_msg);
} else {
this.$message.success("更新成功");
this.limitedVisible = false;
this.$refs.table.refresh();
}
});
},
async vehicleDel(row) {
var id = row.id;
var res = await this.$API.ofm.vehicle.delete.req(id);
if (res.err_msg) {
this.$message.error(res.err_msg);
} else {
this.$refs.table.refresh();
this.$message.success("删除成功");
}
},
//搜索
handleQuery() {
this.$refs.table.queryData(this.query);
},
}
};
</script>
<style scoped>
.treeMain {
height: 280px;
overflow: auto;
border: 1px solid #dcdfe6;
margin-bottom: 10px;
}
::-webkit-scrollbar {
width: 10px;
}
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.2);
background-color: #fefefe;
border-radius: 5px;
}
::-webkit-scrollbar-thumb {
border-radius: 5px;
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.5);
background-color: #f5f5f5;
}
.node rect {
stroke: #606266;
fill: #fff;
}
.edgePath path {
stroke: #606266;
fill: #333;
stroke-width: 1.5px;
}
g.conditions > rect {
fill: #00ffd0;
stroke: #000;
}
.el-icon-close {
cursor: pointer;
}
.left-panel-group {
display: flex;
align-items: center;
gap: 6px; /* 按钮之间的间隙,可以调小点 */
margin-left: 0; /* 靠左 */
}
</style>