You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
udiwms-vue-frame/src/views/inventory/DeviceInspectPlanNew.vue

573 lines
18 KiB
Vue

<template>
<div>
<el-card class="el-card">
<el-form :model="filterQuery" class="query-form" size="mini" label-width="100px" v-show="showSearch">
<el-row>
<el-col :span="8">
<el-form-item class="query-form-item" label="部门:">
<el-select v-model="filterQuery.deptCode" placeholder="请选择部门" clearable="true"
@change="deptChange"
style="width: 90%"
>
<el-option
v-for="item in deptList"
:key="item.name"
:label="item.name"
:value="item.code">
<span style="float: left">{{ item.name }}</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item class="query-form-item" label="仓库:">
<el-select v-model="filterQuery.invCode" placeholder="请选择仓库" clearable="true"
style="width: 90%"
>
<el-option
v-for="item in invList"
:key="item.name"
:label="item.name"
:value="item.code">
<span style="float: left">{{ item.name }}</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item class="query-form-item" label="计划单号:">
<el-input v-model="filterQuery.orderId" placeholder="请输入计划单号" style="width: 90%"
clearable></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item class="query-form-item" label="资产编码:">
<el-input v-model="filterQuery.code" placeholder="请输入资产编码" style="width: 90%"
clearable></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="计划状态:" class="query-form-item">
<el-select v-model="filterQuery.planStatus" style="width: 90%" placeholder="请选择计划级别" clearable>
<el-option label="未启用" :value=1></el-option>
<el-option label="运行中" :value=2></el-option>
<el-option label="已结束" :value=3></el-option>
<el-option label="已过期" :value=4></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item class="query-form-item" label="开始时间:">
<el-date-picker
:picker-options="pickerOptions"
v-model="actDateRange"
type="daterange"
format="yyyy 年 MM 月 dd 日"
value-format="yyyy-MM-dd"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
style="width: 90%"
>
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item class="query-form-item" label="结束时间:">
<el-date-picker
:picker-options="pickerOptions"
v-model="endDateRange"
type="daterange"
format="yyyy 年 MM 月 dd 日"
value-format="yyyy-MM-dd"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
style="width: 90%"
>
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div class="top-right-btn">
<el-button-group>
<el-button icon="el-icon-view" type="primary" @click="hideSearch">/</el-button>
<el-button type="primary" icon="el-icon-refresh" @click="onReset"></el-button>
<el-button type="primary" icon="el-icon-search" @click="onSubmit"></el-button>
<el-button type="primary" icon="el-icon-plus" @click="addInspectPlan"></el-button>
</el-button-group>
</div>
<el-divider style="margin: 15px"></el-divider>
<el-table v-loading="loading" :data="list" style="width: 100%" @current-change="handleDetail" highlight-current-row border>
<el-table-column label="序号" type="index"></el-table-column>
<el-table-column label="计划单号" prop="orderId"></el-table-column>
<el-table-column label="部门" prop="deptName"></el-table-column>
<el-table-column label="仓库" prop="invName"></el-table-column>
<el-table-column label="设备名称" prop="deviceName"></el-table-column>
<el-table-column label="资产编码" prop="code"></el-table-column>
<el-table-column label="规格型号" prop="ggxh"></el-table-column>
<el-table-column label="批次号" prop="batchNo"></el-table-column>
<el-table-column label="开始时间" prop="startTime"></el-table-column>
<el-table-column label="结束时间" prop="endTime"></el-table-column>
<el-table-column label="计划周期">
<template slot-scope="scope">
{{ scope.row.frequency }} {{ frequencyUnitMap[scope.row.frequencyUnit] }}
</template>
</el-table-column>
<el-table-column label="创建人" prop="createUserName"></el-table-column>
<el-table-column label="计划状态" prop="planStatus">
<template slot-scope="scope">
<el-tag :type="statusFilterType(scope.row.planStatus)">{{ planStatusMap[scope.row.planStatus] }}</el-tag>
</template>
</el-table-column>
<!-- <el-table-column label="计划级别" prop="level" show-overflow-tooltip width="120">-->
<!-- <template slot-scope="scope">-->
<!-- <el-tag :type="statusFilterType(scope.row.level)">{{ levelMap[scope.row.level] }}</el-tag>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="状态" prop="status" show-overflow-tooltip width="160">
<template slot-scope="scope">
<el-tag :type="statusFilterType(scope.row.status)">{{ statusMap[scope.row.status] }}</el-tag>
</template>
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button
type="text"
size="small"
@click.native.stop="editInspectPlan(scope.row)"
>编辑
</el-button
>
<el-button
type="text"
size="small"
@click.native.stop="submitAudit(scope.row)"
>提交审核
</el-button
>
<el-button
type="text"
size="small"
@click.native.stop="deleteDialog(scope.row.id)"
>删除
</el-button
>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:limit.sync="filterQuery.limit"
:page.sync="filterQuery.page"
@pagination="getList"
></pagination>
</el-card>
<el-card class="el-card">
<el-table v-loading="loading" :data="delectList" style="width: 100%" border highlight-current-row>
<el-table-column label="序号" type="index" width="60"></el-table-column>
<el-table-column label="项目内容" prop="content" width="300"></el-table-column>
<el-table-column label="备注" prop="remark" show-overflow-tooltip="true"></el-table-column>
<el-table-column label="操作" width="100">
<template slot-scope="scope">
<el-button
type="text"
size="small"
@click.native.stop="datailSelect(scope.row)"
>详情
</el-button
>
</template>
</el-table-column>
</el-table>
</el-card>
<el-dialog
:title="formMap[formName]"
:visible.sync="formVisible"
:close-on-click-modal="false"
:close-on-press-escape="false"
width="65%"
v-if="formVisible"
>
<deviceInspectPlanModify
:inspectPlan="deviceInspectPlan"
:closeDialog="closeDialog"
>
</deviceInspectPlanModify>
</el-dialog>
<el-dialog
title="巡检配置详情"
:visible.sync="deviceProjectSelectVisible"
:close-on-click-modal="false"
:close-on-press-escape="false"
width="40%"
v-if="deviceProjectSelectVisible"
>
<DeviceInspectPlanProjectSet
:detailQuery="detailQuery"
:closeDialog="detailCloseDialogc"
>
</DeviceInspectPlanProjectSet>
</el-dialog>
</div>
</template>
<script>
import {getDeptListByUser} from "@/api/auth/authDept";
import {findInvByUser} from "@/api/system/invSubWarehouse";
import deviceInspectPlanModify from "@/views/inventory/DeviceInspectPlanModify.vue";
import {getDeviceInspectPlanList, submitAudit, deleteInspectPlan} from "@/api/inventory/deviceInspectPlan";
import {selectDeviceInspectPlanDelect} from "@/api/inventory/deviceInspectPlanDelect";
import DeviceInspectPlanProjectSet from "@/views/inventory/DeviceInspectProjectSelect";
export default {
name: "DeviceInspectPlanNew",
data() {
return {
filterQuery: {
orderId: null,
deptCode: this.$store.getters.locDeptCode,
invCode: null,
code: null,
statusList: [0,3],
page: 1,
limit: 20,
},
actDateRange: [],
endDateRange: [],
list: [],
total: 0,
deptList: [],
invList: [],
loading: false,
formVisible: false,
statusMap: {
0: "草稿",
1: "未审核",
2: "已审核",
3: "已拒绝"
},
levelMap: {
1: "低级",
2: "中级",
3: "高级"
},
planStatusMap: {
1: "未启用",
2: "启动",
3: "已结束",
4: "已过期"
},
frequencyUnitMap: {
1: "年",
2: "月",
3: "日",
4: "小时",
5: "分钟",
6: "秒",
},
formName: null,
formMap: {
add: "新增设备巡检计划",
edit: "编辑设备巡检计划"
},
deviceInspectPlan: {
id: null,
code: null,
orderId: null,
deptCode: null,
invCode: null,
deviceName: null,
endTime: '',
startTime: '',
},
delectList: [],
showSearch: true,
deviceProjectSelectVisible: false,
detailQuery: null,
orderIds:null,
pickerOptions: {
shortcuts: [
{
text: "最近一周",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit("pick", [start, end]);
},
},
{
text: "最近一个月",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit("pick", [start, end]);
},
},
{
text: "最近三个月",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
picker.$emit("pick", [start, end]);
},
},
],
},
pickerAuditOptions: {
shortcuts: [
{
text: "最近一周",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit("pick", [start, end]);
},
},
{
text: "最近一个月",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit("pick", [start, end]);
},
},
{
text: "最近三个月",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
picker.$emit("pick", [start, end]);
},
},
],
},
};
},
methods: {
statusFilterType(status) {
const statusMap = {
1: "success",
2: "warning",
3: "danger",
};
return statusMap[status];
},
hideSearch() {
this.showSearch = !this.showSearch;
},
onReset() {
this.$router.push({
path: "",
});
this.filterQuery = {
orderId: null,
deptCode: this.$store.getters.locDeptCode,
invCode: null,
code: null,
statusList: [0,3],
page: 1,
limit: 20,
};
this.actDateRange = [];
this.endDateRange = [];
this.spaceList = [];
this.getList();
},
onSubmit() {
this.filterQuery.page = 1;
this.getList();
},
getList() {
this.loading = true;
this.delectList = []
if (this.actDateRange != null) {
this.filterQuery.ksStartDate = this.actDateRange[0];
this.filterQuery.ksEndDate = this.actDateRange[1];
} else {
this.filterQuery.ksStartDate = null;
this.filterQuery.ksEndDate = null;
}
if (this.endDateRange != null) {
this.filterQuery.jsStartDate = this.endDateRange[0];
this.filterQuery.jsEndDate = this.endDateRange[1];
} else {
this.filterQuery.jsStartDate = null;
this.filterQuery.jsEndDate = null;
}
getDeviceInspectPlanList(this.filterQuery).then((res) => {
this.loading = false;
if (res.code === 20000) {
this.list = res.data.list || [];
this.total = res.data.total || 0;
} else {
this.$message.error(res.message);
this.list = [];
this.total = 0;
}
}).catch((error) => {
this.loading = false;
this.$message.error(error.message);
this.list = [];
this.total = 0;
})
},
datailSelect(row){
this.detailQuery = row
this.deviceProjectSelectVisible = true
},
deptChange() {
this.invList = [];
this.filterQuery.invCode = null;
this.getInvList();
},
getDeptList() {
getDeptListByUser().then((res) => {
this.deptList = res.data || [];
this.getInvList();
this.getList();
});
},
invChange() {
this.spaceList = [];
this.filterQuery.fromInvSpaceCode = null;
this.getSpaceList();
},
getInvList() {
let params = {deptCode: this.filterQuery.deptCode};
findInvByUser(params)
.then((response) => {
this.invList = response.data || [];
this.getList();
})
.catch(() => {
});
},
editInspectPlan(row) {
this.formVisible = true;
this.formName = 'edit';
this.deviceInspectPlan = row;
},
submitAudit(row) {
let params = {orderId: row.orderId};
submitAudit(params).then((res) => {
if (res.code === 20000) {
this.$message.success("提交成功!");
this.getList();
} else {
this.$message.error(res.message);
}
}).catch((error) => {
this.$message.error(error.message);
});
},
deleteDialog(rowId) {
this.$confirm('此操作将永久删除该巡检计划, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let params = {id: rowId};
this.loading = true;
deleteInspectPlan(params).then((res) => {
this.loading = false;
if (res.code === 20000) {
this.$message.success("删除成功!");
this.getList();
} else {
this.$message.error(res.message);
}
}).catch(() => {
this.loading = false;
});
});
},
closeDialog() {
this.formVisible = false;
this.deviceProjectSelectVisible = false
this.getList()
},
detailCloseDialogc() {
this.formVisible = false;
this.deviceProjectSelectVisible = false
this.selectDeviceInspectPlanDelect({orderIdFk:this.orderIds})
this.getList()
},
addInspectPlan() {
this.formVisible = true;
this.formName = 'add';
this.deviceInspectPlan = {
id: null,
code: null,
deptCode: this.$store.getters.locDeptCode,
invCode: null,
deviceName: null,
orderId: null,
endTime: '',
startTime: '',
};
},
handleDetail(row){
this.orderIds = row.orderId;
this.selectDeviceInspectPlanDelect({orderIdFk:row.orderId})
},
selectDeviceInspectPlanDelect(obj) {
selectDeviceInspectPlanDelect(obj).then((res) => {
this.loading = false;
if (res.code === 20000) {
this.delectList = res.data || [];
} else {
this.$message.error(res.message);
this.delectList = [];
}
}).catch((error) => {
this.loading = false;
this.$message.error(error.message);
this.delectList = [];
})
},
},
components: {
deviceInspectPlanModify,DeviceInspectPlanProjectSet
},
mounted() {
document.body.ondrop = function (event) {
event.preventDefault();
event.stopPropagation();
};
},
created() {
this.getDeptList();
},
};
</script>
<style type="text/scss" lang="scss">
</style>