<template>
|
<div class="app-container">
|
<div class="search_form">
|
<div>
|
<span class="search_title">工序:</span>
|
<el-input
|
v-model="searchForm.process"
|
style="width: 240px"
|
placeholder="请输入工序搜索"
|
@change="handleQuery"
|
clearable
|
/>
|
<span style="margin-left: 10px" class="search_title">巡检日期:</span>
|
<el-date-picker v-model="searchForm.checkDate"
|
value-format="YYYY-MM-DD HH:mm:ss"
|
format="YYYY-MM-DD HH:mm:ss"
|
type="datetimerange"
|
placeholder="请选择"
|
clearable
|
@change="changeDaterange" />
|
<el-button type="primary" @click="handleQuery" style="margin-left: 10px"
|
>搜索</el-button
|
>
|
</div>
|
<div>
|
<el-button type="primary" @click="openForm('add')">新增</el-button>
|
<el-button type="danger" plain @click="handleDelete">删除</el-button>
|
<el-button type="success" plain @click="handleNotify">通知</el-button>
|
</div>
|
</div>
|
<div class="table_list">
|
<PIMTable
|
rowKey="id"
|
:column="tableColumn"
|
:tableData="tableData"
|
:page="page"
|
:isSelection="true"
|
@selection-change="handleSelectionChange"
|
:tableLoading="tableLoading"
|
@pagination="pagination"
|
:total="page.total"
|
></PIMTable>
|
</div>
|
<FormDia ref="formDia" @close="handleQuery"></FormDia>
|
</div>
|
</template>
|
|
<script setup>
|
import { onMounted, ref, reactive, toRefs } from "vue";
|
import FormDia from "./components/formDia.vue";
|
import {ElMessage, ElMessageBox} from "element-plus";
|
import {
|
productInspectionRecordListPage,
|
delProductInspectionRecord,
|
notifyProductInspectionRecord
|
} from "@/api/qualityManagement/productInspectionRecord.js";
|
|
const data = reactive({
|
searchForm: {
|
keyword: "",
|
checkDate: undefined,
|
checkDateStart: undefined,
|
checkDateEnd: undefined,
|
},
|
});
|
const { searchForm } = toRefs(data);
|
|
const tableData = ref([]);
|
const tableLoading = ref(false);
|
const page = reactive({
|
current: 1,
|
size: 10,
|
total: 0,
|
});
|
const ids = ref([]);
|
|
const tableColumn = ref([
|
{
|
label: "工序",
|
prop: "process",
|
},
|
{
|
label: "检测项",
|
prop: "inspectionItem",
|
},
|
{
|
label: "标准要求",
|
prop: "standardRequirement",
|
},
|
{
|
label: "实测值",
|
prop: "actualValue",
|
},
|
{
|
label: "判定",
|
prop: "judgement",
|
dataType: "tag",
|
formatData: (params) => {
|
if (params === 'yes') {
|
return "合格";
|
} else if (params === 'no') {
|
return "不合格";
|
}
|
return params;
|
},
|
formatType: (params) => {
|
if (params === 'yes') {
|
return "success";
|
} else if (params === 'no') {
|
return "danger";
|
}
|
return null;
|
},
|
},
|
{
|
label: "不合格订单",
|
prop: "unqualifiedOrder",
|
},
|
{
|
label: "巡检日期",
|
prop: "inspectionTime",
|
width: 160
|
},
|
{
|
label: "巡检员",
|
prop: "inspector",
|
},
|
{
|
label: "创建人",
|
prop: "createUser",
|
},
|
{
|
label: "创建时间",
|
prop: "createTime",
|
width: 160
|
},
|
{
|
dataType: "action",
|
label: "操作",
|
align: "center",
|
fixed: "right",
|
width: 150,
|
operation: [
|
{
|
name: "编辑",
|
type: "text",
|
clickFun: (row) => {
|
openForm("edit", row);
|
},
|
},
|
{
|
name: "删除",
|
type: "text",
|
clickFun: (row) => {
|
handleDelete(row);
|
},
|
},
|
],
|
},
|
]);
|
|
const formDia = ref(null);
|
|
const openForm = (type, row) => {
|
formDia.value.open(type, row);
|
};
|
|
const changeDaterange = (val) => {
|
if (val) {
|
searchForm.value.startTime = val[0];
|
searchForm.value.endTime = val[1];
|
} else {
|
searchForm.value.startTime = undefined;
|
searchForm.value.endTime = undefined;
|
}
|
handleQuery();
|
};
|
|
const handleQuery = () => {
|
page.current = 1;
|
getList();
|
};
|
|
const pagination = (obj) => {
|
page.current = obj.page;
|
page.size = obj.limit;
|
getList();
|
};
|
|
const getList = async () => {
|
tableLoading.value = true;
|
try {
|
const res = await productInspectionRecordListPage({
|
...searchForm.value,
|
current: page.current,
|
size: page.size,
|
});
|
tableData.value = res.data.records || [];
|
page.total = res.data.total || 0;
|
} finally {
|
tableLoading.value = false;
|
}
|
};
|
|
const handleSelectionChange = (selection) => {
|
ids.value = selection.map((item) => item.id);
|
};
|
|
const handleDelete = (row) => {
|
const _ids = row ? [row.id] : ids.value;
|
if (_ids.length === 0) {
|
ElMessage.warning("请选择要删除的数据");
|
return;
|
}
|
ElMessageBox.confirm("是否确认删除选中的数据?", "警告", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
}).then(async () => {
|
await delProductInspectionRecord(_ids);
|
ElMessage.success("删除成功");
|
getList();
|
});
|
};
|
|
const handleNotify = () => {
|
if (ids.value.length === 0) {
|
ElMessage.warning("请选择要通知的数据");
|
return;
|
}
|
ElMessageBox.confirm("是否确认发送通知?", "警告", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
}).then(async () => {
|
await notifyProductInspectionRecord(ids.value);
|
ElMessage.success("发送通知成功");
|
})
|
};
|
|
onMounted(() => {
|
getList();
|
});
|
</script>
|
|
<style scoped lang="scss">
|
.search_form {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
margin-bottom: 16px;
|
}
|
|
.search_title {
|
font-size: 14px;
|
color: #606266;
|
}
|
</style>
|