From b31c4a85ee6d08958dc44bc824169580dc87efaa Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期五, 13 三月 2026 17:56:06 +0800
Subject: [PATCH] 原料页面
---
src/views/qualityManagement/rawMaterial/components/filesDia.vue | 191 ++++++++
src/views/qualityManagement/rawMaterial/components/formDia.vue | 372 ++++++++++++++++
src/api/qualityManagement/rawMaterial.js | 37 +
src/views/qualityManagement/rawMaterial/index.vue | 388 +++++++++++++++++
src/views/qualityManagement/rawMaterial/components/itemSelect.vue | 185 ++++++++
src/views/qualityManagement/rawMaterial/components/inspectionFormDia.vue | 139 ++++++
6 files changed, 1,312 insertions(+), 0 deletions(-)
diff --git a/src/api/qualityManagement/rawMaterial.js b/src/api/qualityManagement/rawMaterial.js
new file mode 100644
index 0000000..43da7fa
--- /dev/null
+++ b/src/api/qualityManagement/rawMaterial.js
@@ -0,0 +1,37 @@
+import request from '@/utils/request'
+
+// 鏌ヨ鍘熸鍒楄〃
+export function findRawMaterialListPage(query) {
+ return request({
+ url: '/quality/rawMaterial/listPage',
+ method: 'get',
+ params: query,
+ })
+}
+
+// 鏂板鍘熸
+export function createRawMaterial(data) {
+ return request({
+ url: '/quality/rawMaterial',
+ method: 'post',
+ data: data,
+ })
+}
+
+// 淇敼鍘熸
+export function updateRawMaterial(data) {
+ return request({
+ url: '/quality/rawMaterial',
+ method: 'put',
+ data: data,
+ })
+}
+
+// 鍒犻櫎鍘熸
+export function deleteRawMaterial(query) {
+ return request({
+ url: '/quality/rawMaterial',
+ method: 'delete',
+ data: query,
+ })
+}
diff --git a/src/views/qualityManagement/rawMaterial/components/filesDia.vue b/src/views/qualityManagement/rawMaterial/components/filesDia.vue
new file mode 100644
index 0000000..9b89a3b
--- /dev/null
+++ b/src/views/qualityManagement/rawMaterial/components/filesDia.vue
@@ -0,0 +1,191 @@
+<template>
+ <div>
+ <el-dialog
+ v-model="dialogFormVisible"
+ title="涓婁紶闄勪欢"
+ width="50%"
+ @close="closeDia"
+ >
+ <div style="margin-bottom: 10px;text-align: right">
+ <el-upload
+ v-model:file-list="fileList"
+ class="upload-demo"
+ :action="uploadUrl"
+ :on-success="handleUploadSuccess"
+ :on-error="handleUploadError"
+ name="file"
+ :show-file-list="false"
+ :headers="headers"
+ style="display: inline;margin-right: 10px"
+ >
+ <el-button type="primary">涓婁紶闄勪欢</el-button>
+ </el-upload>
+ <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
+ </div>
+ <PIMTable
+ rowKey="id"
+ :column="tableColumn"
+ :tableData="tableData"
+ :page="page"
+ :tableLoading="tableLoading"
+ :isSelection="true"
+ @selection-change="handleSelectionChange"
+ @pagination="paginationSearch"
+ height="500"
+ >
+ </PIMTable>
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button @click="closeDia">鍙栨秷</el-button>
+ </div>
+ </template>
+ </el-dialog>
+ <filePreview ref="filePreviewRef" />
+ </div>
+</template>
+
+<script setup>
+import {ref} from "vue";
+import filePreview from '@/components/filePreview/index.vue'
+import {ElMessageBox} from "element-plus";
+import {getToken} from "@/utils/auth.js";
+import {
+ qualityInspectFileAdd,
+ qualityInspectFileDel,
+ qualityInspectFileListPage
+} from "@/api/qualityManagement/qualityInspectFile.js";
+const { proxy } = getCurrentInstance()
+const emit = defineEmits(['close'])
+
+const dialogFormVisible = ref(false);
+const currentId = ref('')
+const selectedRows = ref([]);
+const tableColumn = ref([
+ {
+ label: "鏂囦欢鍚嶇О",
+ prop: "name",
+ },
+ {
+ dataType: "action",
+ label: "鎿嶄綔",
+ align: "center",
+ operation: [
+ {
+ name: "涓嬭浇",
+ type: "text",
+ clickFun: (row) => {
+ downLoadFile(row);
+ },
+ },
+ {
+ name: "棰勮",
+ type: "text",
+ clickFun: (row) => {
+ lookFile(row);
+ },
+ }
+ ],
+ },
+]);
+const page = reactive({
+ current: 1,
+ size: 100,
+ total: 0,
+});
+const tableData = ref([]);
+const fileList = ref([]);
+const tableLoading = ref(false);
+const filePreviewRef = ref()
+const headers = ref({
+ Authorization: "Bearer " + getToken(),
+});
+const uploadUrl = ref(import.meta.env.VITE_APP_BASE_API + "/file/upload"); // 涓婁紶鐨勫浘鐗囨湇鍔″櫒鍦板潃
+
+// 鎵撳紑寮规
+const openDialog = (row) => {
+ dialogFormVisible.value = true;
+ currentId.value = row.id;
+ getList()
+}
+const paginationSearch = (obj) => {
+ page.current = obj.page;
+ page.size = obj.limit;
+ getList();
+};
+const getList = () => {
+ qualityInspectFileListPage({inspectId: currentId.value, ...page}).then(res => {
+ tableData.value = res.data.records;
+ page.total = res.data.total;
+ })
+}
+// 琛ㄦ牸閫夋嫨鏁版嵁
+const handleSelectionChange = (selection) => {
+ selectedRows.value = selection;
+};
+
+// 鍏抽棴寮规
+const closeDia = () => {
+ dialogFormVisible.value = false;
+ emit('close')
+};
+// 涓婁紶鎴愬姛澶勭悊
+function handleUploadSuccess(res, file) {
+ // 濡傛灉涓婁紶鎴愬姛
+ if (res.code == 200) {
+ const fileRow = {}
+ fileRow.name = res.data.originalName
+ fileRow.url = res.data.tempPath
+ uploadFile(fileRow)
+ } else {
+ proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
+ }
+}
+function uploadFile(file) {
+ file.inspectId = currentId.value;
+ qualityInspectFileAdd(file).then(res => {
+ proxy.$modal.msgSuccess("鏂囦欢涓婁紶鎴愬姛");
+ getList()
+ })
+}
+// 涓婁紶澶辫触澶勭悊
+function handleUploadError() {
+ proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
+}
+// 涓嬭浇闄勪欢
+const downLoadFile = (row) => {
+ proxy.$download.name(row.url);
+}
+// 棰勮闄勪欢
+const lookFile = (row) => {
+ filePreviewRef.value.open(row.url)
+}
+// 鍒犻櫎
+const handleDelete = () => {
+ let ids = [];
+ if (selectedRows.value.length > 0) {
+ ids = selectedRows.value.map((item) => item.id);
+ } else {
+ proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+ return;
+ }
+ ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "瀵煎嚭", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ }).then(() => {
+ qualityInspectFileDel(ids).then((res) => {
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ getList();
+ });
+ }).catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
+};
+defineExpose({
+ openDialog,
+});
+</script>
+
+<style scoped>
+
+</style>
\ No newline at end of file
diff --git a/src/views/qualityManagement/rawMaterial/components/formDia.vue b/src/views/qualityManagement/rawMaterial/components/formDia.vue
new file mode 100644
index 0000000..868ef66
--- /dev/null
+++ b/src/views/qualityManagement/rawMaterial/components/formDia.vue
@@ -0,0 +1,372 @@
+<template>
+ <div>
+ <el-dialog
+ v-model="dialogFormVisible"
+ :title="operationType === 'add' ? '鏂板鍘熸枡' : '缂栬緫鍘熸枡'"
+ width="70%"
+ @close="closeDia"
+ >
+ <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
+ <el-row :gutter="30">
+ <el-col :span="12">
+ <el-form-item label="浜у搧鍚嶇О锛�" prop="productId">
+ <el-tree-select
+ v-model="form.productId"
+ placeholder="璇烽�夋嫨"
+ clearable
+ check-strictly
+ @change="getModels"
+ :data="productOptions"
+ :render-after-expand="false"
+ :disabled="operationType === 'edit'"
+ style="width: 100%"
+ />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="30">
+ <el-col :span="12">
+ <el-form-item label="瑙勬牸鍨嬪彿锛�" prop="productModelId">
+ <el-select v-model="form.productModelId" placeholder="璇烽�夋嫨" clearable :disabled="operationType === 'edit'"
+ filterable readonly @change="handleChangeModel">
+ <el-option v-for="item in modelOptions" :key="item.id" :label="item.model" :value="item.id" />
+ </el-select>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="30">
+ <el-col :span="12">
+ <el-form-item label="鍗曚綅锛�" prop="unit">
+ <el-input v-model="form.unit" disabled/>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="鎵瑰彿锛�" prop="batchNo">
+ <el-input style="width: 100%" v-model="form.batchNo" placeholder="璇疯緭鍏�" clearable/>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="30">
+ <el-col :span="12">
+ <el-form-item label="妫�楠岀被鍨嬶細" prop="checkType">
+ <el-select v-model="form.checkType">
+ <el-option label="鍏ュ巶妫�" :value="0"/>
+ <el-option label="杞﹂棿妫�" :value="1"/>
+ <el-option label="鍑哄巶妫�" :value="2"/>
+ </el-select>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="妫�娴嬬粨鏋滐細" prop="checkResult">
+ <el-select v-model="form.checkResult">
+ <el-option label="鍚堟牸" :value="1"/>
+ <el-option label="涓嶅悎鏍�" :value="0"/>
+ </el-select>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="30">
+ <el-col :span="12">
+ <el-form-item label="妫�楠屽憳锛�" prop="checkName">
+ <el-select v-model="form.checkName" placeholder="璇烽�夋嫨" clearable filterable style="width: 100%">
+ <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName"
+ :value="item.nickName"/>
+ </el-select>
+
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="妫�娴嬫棩鏈燂細" prop="checkTime">
+ <el-date-picker
+ v-model="form.checkTime"
+ type="date"
+ placeholder="璇烽�夋嫨鏃ユ湡"
+ value-format="YYYY-MM-DD"
+ format="YYYY-MM-DD"
+ clearable
+ style="width: 100%"
+ />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ </el-form>
+ <div style="margin-bottom: 10px">
+ <el-button type="primary" @click="isShowItems = true">娣诲姞妫�娴嬮」鐩�</el-button>
+ </div>
+ <PIMTable
+ rowKey="id"
+ :column="tableColumn"
+ :tableData="tableData"
+ :tableLoading="tableLoading"
+ height="400"
+ >
+ <template #slot="{ row }">
+ <el-input v-model="row.testValue" clearable/>
+ </template>
+ </PIMTable>
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button type="primary" @click="submitForm">纭</el-button>
+ <el-button @click="closeDia">鍙栨秷</el-button>
+ </div>
+ </template>
+ </el-dialog>
+
+ <item-select v-model="isShowItems" @confirm="handleItemSelect" />
+ </div>
+</template>
+
+<script setup>
+import {ref, reactive, toRefs, getCurrentInstance, nextTick} from "vue";
+import {modelList, productTreeList} from "@/api/basicData/product.js";
+import {qualityInspectParamInfo} from "@/api/qualityManagement/qualityInspectParam.js";
+import {qualityInspectDetailByProductId} from "@/api/qualityManagement/metricMaintenance.js";
+import {userListNoPage} from "@/api/system/user.js";
+import {createRawMaterial, updateRawMaterial} from "@/api/qualityManagement/rawMaterial.js";
+import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue";
+
+const {proxy} = getCurrentInstance()
+const emit = defineEmits(['close'])
+const ItemSelect = defineAsyncComponent(() => import("@/views/qualityManagement/rawMaterial/components/itemSelect.vue"));
+
+const dialogFormVisible = ref(false);
+const operationType = ref('')
+const isShowItems = ref(false)
+const data = reactive({
+ form: {
+ checkTime: "",
+ supplier: "",
+ checkName: "",
+ productName: "",
+ productId: "",
+ productModelId: "",
+ model: "",
+ batchNo: "",
+ unit: "",
+ quantity: "",
+ checkCompany: "",
+ checkResult: "",
+ },
+ rules: {
+ checkTime: [{required: true, message: "璇疯緭鍏�", trigger: "blur"},],
+ supplier: [{required: true, message: "璇疯緭鍏�", trigger: "blur"}],
+ checkName: [{required: false, message: "璇疯緭鍏�", trigger: "blur"}],
+ productId: [{required: true, message: "璇疯緭鍏�", trigger: "blur"}],
+ productModelId: [{required: true, message: "璇烽�夋嫨浜у搧鍨嬪彿", trigger: "change"}],
+ batchNo: [{required: false, message: "璇疯緭鍏ユ壒娆�", trigger: "blur"}],
+ unit: [{required: false, message: "璇疯緭鍏�", trigger: "blur"}],
+ quantity: [{required: true, message: "璇疯緭鍏�", trigger: "blur"}],
+ checkCompany: [{required: false, message: "璇疯緭鍏�", trigger: "blur"}],
+ checkResult: [{required: true, message: "璇烽�夋嫨妫�娴嬬粨鏋�", trigger: "change"}],
+ },
+});
+const tableColumn = ref([
+ {
+ label: "鎸囨爣",
+ prop: "parameterItem",
+ },
+ {
+ label: "鍗曚綅",
+ prop: "unit",
+ },
+ {
+ label: "鏍囧噯鍊�",
+ prop: "standardValue",
+ },
+ {
+ label: "鍐呮帶鍊�",
+ prop: "controlValue",
+ },
+ {
+ label: "鍖栭獙鍊�",
+ prop: "testValue",
+ dataType: 'slot',
+ slot: 'slot',
+ },
+]);
+const tableData = ref([]);
+const tableLoading = ref(false);
+
+const {form, rules} = toRefs(data);
+const userList = ref([]);
+const productOptions = ref([]);
+const currentProductId = ref(0);
+const testStandardOptions = ref([]); // 鎸囨爣閫夋嫨涓嬫媺妗嗘暟鎹�
+const modelOptions = ref([]);
+
+// 鎵撳紑寮规
+const openDialog = async (type, row) => {
+ operationType.value = type;
+ userListNoPage().then(res => {
+ userList.value = res.data || [];
+ })
+ // 鍏堥噸缃〃鍗曟暟鎹紙淇濇寔瀛楁瀹屾暣锛岄伩鍏嶅脊绐楅娆℃覆鏌撴椂瑙﹀彂蹇呭~绾㈡鈥滈棯涓�涓嬧�濓級
+ form.value = {
+ checkTime: "",
+ supplier: "",
+ checkName: "",
+ productName: "",
+ productId: "",
+ productModelId: "",
+ model: "",
+ batchNo: "",
+ unit: "",
+ quantity: "",
+ checkCompany: "",
+ checkResult: "",
+ }
+ testStandardOptions.value = [];
+ tableData.value = [];
+ // 鍏堢‘淇濅骇鍝佹爲宸插姞杞斤紝鍚﹀垯缂栬緫鏃朵骇鍝�/瑙勬牸鍨嬪彿鏃犳硶鍙嶆樉
+ await getProductOptions();
+ if (operationType.value === 'edit') {
+ form.value = {...row}
+ currentProductId.value = row.productId || 0
+ // 鍏抽敭锛氱紪杈戞椂鍔犺浇瑙勬牸鍨嬪彿涓嬫媺閫夐」锛屾墠鑳藉弽鏄� productModelId
+ if (currentProductId.value) {
+ try {
+ const res = await modelList({ id: currentProductId.value });
+ modelOptions.value = res || [];
+ // 鍚屾鍥炲~ model / unit锛堟湁浜涙帴鍙h繑鍥炵殑 row 閲屽彲鑳芥病甯﹀叏锛�
+ if (form.value.productModelId) {
+ handleChangeModel(form.value.productModelId);
+ }
+ } catch (e) {
+ console.error("鍔犺浇瑙勬牸鍨嬪彿澶辫触", e);
+ modelOptions.value = [];
+ }
+ }
+ // 缂栬緫妯″紡涓嬶紝鍏堝姞杞芥寚鏍囬�夐」锛岀劧鍚庡姞杞藉弬鏁板垪琛�
+ if (currentProductId.value) {
+
+ } else {
+ getQualityInspectParamList(row.id);
+ }
+ }
+ // 鏈�鍚庡啀鎵撳紑寮圭獥锛屽苟娓呯悊鏍¢獙鎬侊紝閬垮厤蹇呭~鎻愮ず闂儊
+ dialogFormVisible.value = true;
+ nextTick(() => {
+ proxy.$refs?.formRef?.clearValidate?.();
+ });
+}
+const getProductOptions = () => {
+ return productTreeList().then((res) => {
+ productOptions.value = convertIdToValue(res);
+ return productOptions.value;
+ });
+};
+const getModels = (value) => {
+ form.value.productModelId = undefined;
+ form.value.unit = undefined;
+ modelOptions.value = [];
+ currentProductId.value = value
+ form.value.productName = findNodeById(productOptions.value, value);
+ modelList({ id: value }).then((res) => {
+ modelOptions.value = res;
+ })
+ if (currentProductId.value) {
+ getList();
+ }
+};
+
+const handleItemSelect = (value) => {
+ tableData.value.push(...value)
+}
+
+const handleChangeModel = (value) => {
+ form.value.model = modelOptions.value.find(item => item.id == value)?.model || '';
+ form.value.unit = modelOptions.value.find(item => item.id == value)?.unit || '';
+}
+
+const findNodeById = (nodes, productId) => {
+ for (let i = 0; i < nodes.length; i++) {
+ if (nodes[i].value === productId) {
+ return nodes[i].label; // 鎵惧埌鑺傜偣锛岃繑鍥炶鑺傜偣
+ }
+ if (nodes[i].children && nodes[i].children.length > 0) {
+ const foundNode = findNodeById(nodes[i].children, productId);
+ if (foundNode) {
+ return foundNode; // 鍦ㄥ瓙鑺傜偣涓壘鍒帮紝杩斿洖璇ヨ妭鐐�
+ }
+ }
+ }
+ return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull
+};
+
+function convertIdToValue(data) {
+ return data.map((item) => {
+ const {id, children, ...rest} = item;
+ const newItem = {
+ ...rest,
+ value: id, // 灏� id 鏀逛负 value
+ };
+ if (children && children.length > 0) {
+ newItem.children = convertIdToValue(children);
+ }
+
+ return newItem;
+ });
+}
+
+// 鎻愪氦浜у搧琛ㄥ崟
+const submitForm = () => {
+ proxy.$refs.formRef.validate(valid => {
+ if (valid) {
+ form.value.inspectType = 0
+ if (operationType.value === "add") {
+ tableData.value.forEach((item) => {
+ delete item.id
+ })
+ }
+ const data = {...form.value, qualityInspectParams: tableData.value}
+ if (operationType.value === "add") {
+ createRawMaterial(data).then(res => {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ closeDia();
+ })
+ } else {
+ updateRawMaterial(data).then(res => {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ closeDia();
+ })
+ }
+ }
+ })
+}
+
+const getList = () => {
+ if (!currentProductId.value) {
+ testStandardOptions.value = [];
+ tableData.value = [];
+ return;
+ }
+ let params = {
+ productId: currentProductId.value,
+ }
+ qualityInspectDetailByProductId(params).then(res => {
+ // 娓呯┖琛ㄦ牸鏁版嵁锛岀瓑寰呯敤鎴烽�夋嫨鎸囨爣
+ tableData.value = [];
+ })
+}
+
+const getQualityInspectParamList = (id) => {
+ qualityInspectParamInfo(id).then(res => {
+ tableData.value = res.data;
+ })
+}
+// 鍏抽棴寮规
+const closeDia = () => {
+ proxy.resetForm("formRef");
+ tableData.value = [];
+ testStandardOptions.value = [];
+ dialogFormVisible.value = false;
+ emit('close')
+};
+defineExpose({
+ openDialog,
+});
+</script>
+
+<style scoped>
+
+</style>
\ No newline at end of file
diff --git a/src/views/qualityManagement/rawMaterial/components/inspectionFormDia.vue b/src/views/qualityManagement/rawMaterial/components/inspectionFormDia.vue
new file mode 100644
index 0000000..12473be
--- /dev/null
+++ b/src/views/qualityManagement/rawMaterial/components/inspectionFormDia.vue
@@ -0,0 +1,139 @@
+<template>
+ <div>
+ <el-dialog
+ v-model="dialogFormVisible"
+ title="濉啓妫�楠岃褰�"
+ width="70%"
+ @close="closeDia"
+ >
+ <div style="margin-bottom: 10px;text-align: right">
+ <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
+ </div>
+ <PIMTable
+ rowKey="id"
+ :column="tableColumn"
+ :tableData="tableData"
+ :tableLoading="tableLoading"
+ :isSelection="true"
+ @selection-change="handleSelectionChange"
+ height="600"
+ >
+ <template #slot="{ row }">
+ <el-input v-model="row.testValue" clearable/>
+ </template>
+ </PIMTable>
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button type="primary" @click="submitForm">纭</el-button>
+ <el-button @click="closeDia">鍙栨秷</el-button>
+ </div>
+ </template>
+ </el-dialog>
+ </div>
+</template>
+
+<script setup>
+import {ref} from "vue";
+import {Search} from "@element-plus/icons-vue";
+import {
+ qualityInspectParamDel,
+ qualityInspectParamInfo,
+ qualityInspectParamUpdate
+} from "@/api/qualityManagement/qualityInspectParam.js";
+import {ElMessageBox} from "element-plus";
+const { proxy } = getCurrentInstance()
+const emit = defineEmits(['close'])
+
+const dialogFormVisible = ref(false);
+const operationType = ref('')
+const currentId = ref('')
+const selectedRows = ref([]);
+const tableColumn = ref([
+ {
+ label: "鎸囨爣",
+ prop: "parameterItem",
+ },
+ {
+ label: "鍗曚綅",
+ prop: "unit",
+ },
+ {
+ label: "鏍囧噯鍊�",
+ prop: "standardValue",
+ },
+ {
+ label: "鍐呮帶鍊�",
+ prop: "controlValue",
+ },
+ {
+ label: "鍖栭獙鍊�",
+ prop: "testValue",
+ dataType: 'slot',
+ slot: 'slot',
+ },
+]);
+const tableData = ref([]);
+const tableLoading = ref(false);
+
+// 鎵撳紑寮规
+const openDialog = (type, row) => {
+ operationType.value = type;
+ dialogFormVisible.value = true;
+ if (operationType.value === 'edit') {
+ currentId.value = row.id;
+ getList()
+ }
+}
+const getList = () => {
+ qualityInspectParamInfo(currentId.value).then(res => {
+ tableData.value = res.data;
+ })
+}
+// 琛ㄦ牸閫夋嫨鏁版嵁
+const handleSelectionChange = (selection) => {
+ selectedRows.value = selection;
+};
+// 鎻愪氦浜у搧琛ㄥ崟
+const submitForm = () => {
+ qualityInspectParamUpdate(tableData.value).then(res => {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ closeDia();
+ })
+}
+// 鍏抽棴寮规
+const closeDia = () => {
+ dialogFormVisible.value = false;
+ emit('close')
+};
+// 鍒犻櫎
+const handleDelete = () => {
+ let ids = [];
+ if (selectedRows.value.length > 0) {
+ ids = selectedRows.value.map((item) => item.id);
+ } else {
+ proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+ return;
+ }
+ ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "瀵煎嚭", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(() => {
+ qualityInspectParamDel(ids).then((res) => {
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ getList();
+ });
+ })
+ .catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
+};
+defineExpose({
+ openDialog,
+});
+</script>
+
+<style scoped>
+
+</style>
\ No newline at end of file
diff --git a/src/views/qualityManagement/rawMaterial/components/itemSelect.vue b/src/views/qualityManagement/rawMaterial/components/itemSelect.vue
new file mode 100644
index 0000000..4cf509c
--- /dev/null
+++ b/src/views/qualityManagement/rawMaterial/components/itemSelect.vue
@@ -0,0 +1,185 @@
+<template>
+ <el-dialog v-model="visible" title="閫夋嫨妫�娴嬮」鐩�" width="900px" destroy-on-close :close-on-click-modal="false">
+ <el-form :inline="true" :model="query" class="mb-2">
+ <el-form-item label="妫�娴嬮」鐩悕绉�">
+ <el-input v-model="query.name" placeholder="杈撳叆妫�娴嬮」鐩悕绉�" clearable @keyup.enter="onSearch" />
+ </el-form-item>
+
+ <el-form-item>
+ <el-button type="primary" @click="onSearch">鎼滅储</el-button>
+ <el-button @click="onReset">閲嶇疆</el-button>
+ </el-form-item>
+ </el-form>
+
+ <!-- 鍒楄〃 -->
+ <PIMTable
+ rowKey="id"
+ :column="tableColumn"
+ :tableData="tableData"
+ :page="page"
+ :isSelection="true"
+ :tableLoading="loading"
+ :total="total"
+ @selection-change="handleSelectionChange"
+ @pagination="pagination"
+ @select="handleSelect"
+ />
+
+ <template #footer>
+ <el-button @click="close()">鍙栨秷</el-button>
+ <el-button type="primary" :disabled="multipleSelection.length === 0" @click="onConfirm">
+ 纭畾
+ </el-button>
+ </template>
+ </el-dialog>
+</template>
+
+<script setup lang="ts">
+import { computed, onMounted, reactive, ref, watch, nextTick } from "vue";
+import { ElMessage } from "element-plus";
+import { qualityInspectItemListPage } from "@/api/qualityManagement/inspectItem.js";
+
+export type ProductRow = {
+ id: number;
+ productName: string;
+ model: string;
+ unit?: string;
+};
+
+const props = defineProps<{
+ modelValue: boolean;
+ single?: boolean; // 鏄惁鍙兘閫夋嫨涓�涓紝榛樿false锛堝彲閫夋嫨澶氫釜锛�
+}>();
+
+const emit = defineEmits(['update:modelValue', 'confirm']);
+
+const visible = computed({
+ get: () => props.modelValue,
+ set: (v) => emit("update:modelValue", v),
+});
+
+const query = reactive({
+ name: "",
+});
+
+const page = reactive({
+ pageNum: 1,
+ pageSize: 10,
+});
+
+const loading = ref(false);
+const tableData = ref<ProductRow[]>([]);
+const total = ref(0);
+const multipleSelection = ref<ProductRow[]>([]);
+const tableRef = ref();
+
+const tableColumn = ref([
+ { label: "妫�娴嬮」鐩�", prop: "name" },
+ { label: "鍗曚綅", prop: "unit", width: 120 },
+ { label: "鏍囧噯鍊�", prop: "standardValue", width: 160 },
+ { label: "鍐呮帶鍊�", prop: "internalControl", width: 160 },
+ { label: "鍖栭獙鍊�", prop: "testValue", width: 160 },
+]);
+
+function close() {
+ visible.value = false;
+}
+
+const handleSelectionChange = (val: ProductRow[]) => {
+ if (props.single && val.length > 1) {
+ // 濡傛灉闄愬埗涓哄崟涓�夋嫨锛屽彧淇濈暀鏈�鍚庝竴涓�変腑鐨�
+ const lastSelected = val[val.length - 1];
+ multipleSelection.value = [lastSelected];
+ // 娓呯┖琛ㄦ牸閫変腑鐘舵�侊紝鐒跺悗閲嶆柊閫変腑鏈�鍚庝竴涓�
+ nextTick(() => {
+ if (tableRef.value) {
+ tableRef.value.clearSelection();
+ tableRef.value.toggleRowSelection(lastSelected, true);
+ }
+ });
+ } else {
+ multipleSelection.value = val;
+ }
+}
+
+// 澶勭悊鍗曚釜閫夋嫨
+const handleSelect = (selection: ProductRow[], row: ProductRow) => {
+ if (props.single) {
+ // 濡傛灉闄愬埗涓哄崟涓紝娓呯┖鍏朵粬閫夋嫨锛屽彧淇濈暀褰撳墠琛�
+ if (selection.includes(row)) {
+ // 閫変腑褰撳墠琛屾椂锛屾竻绌哄叾浠栭�変腑
+ multipleSelection.value = [row];
+ nextTick(() => {
+ if (tableRef.value) {
+ tableData.value.forEach((item) => {
+ if (item.id !== row.id) {
+ tableRef.value.toggleRowSelection(item, false);
+ }
+ });
+ }
+ });
+ }
+ }
+}
+
+function onSearch() {
+ page.pageNum = 1;
+ loadData();
+}
+
+function onReset() {
+ query.name = "";
+ page.pageNum = 1;
+ loadData();
+}
+
+function onPageChange() {
+ loadData();
+}
+
+const pagination = (obj) => {
+ page.pageNum = obj.page;
+ page.pageSize = obj.limit;
+ loadData();
+};
+
+function onConfirm() {
+ if (multipleSelection.value.length === 0) {
+ ElMessage.warning("璇烽�夋嫨涓�鏉¢」鐩�");
+ return;
+ }
+ if (props.single && multipleSelection.value.length > 1) {
+ ElMessage.warning("鍙兘閫夋嫨涓�涓」鐩�");
+ return;
+ }
+ emit("confirm", props.single ? [multipleSelection.value[0]] : multipleSelection.value);
+ close();
+}
+
+async function loadData() {
+ loading.value = true;
+ try {
+ multipleSelection.value = []; // 缈婚〉/鎼滅储鍚庢竻绌洪�夋嫨鏇寸鍚堥鏈�
+ const res: any = await qualityInspectItemListPage({
+ name: query.name.trim(),
+ current: page.pageNum,
+ size: page.pageSize,
+ });
+ tableData.value = res.data.records;
+ total.value = res.data.total;
+ } finally {
+ loading.value = false;
+ }
+}
+
+// 鐩戝惉寮圭獥鎵撳紑锛岄噸缃�夋嫨
+watch(() => props.modelValue, (visible) => {
+ if (visible) {
+ multipleSelection.value = [];
+ }
+});
+
+onMounted(() => {
+ loadData()
+})
+</script>
diff --git a/src/views/qualityManagement/rawMaterial/index.vue b/src/views/qualityManagement/rawMaterial/index.vue
new file mode 100644
index 0000000..089272b
--- /dev/null
+++ b/src/views/qualityManagement/rawMaterial/index.vue
@@ -0,0 +1,388 @@
+<template>
+ <div class="app-container">
+ <div class="search_form">
+ <div>
+ <span class="search_title">渚涘簲鍟嗭細</span>
+ <el-input
+ v-model="searchForm.supplier"
+ style="width: 240px"
+ placeholder="璇疯緭鍏ヤ緵搴斿晢鎼滅储"
+ @change="handleQuery"
+ clearable
+ :prefix-icon="Search"
+ />
+ <span style="margin-left: 10px" class="search_title">妫�娴嬫棩鏈燂細</span>
+ <el-date-picker v-model="searchForm.entryDate" value-format="YYYY-MM-DD" format="YYYY-MM-DD" type="daterange"
+ 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 @click="handleOut">瀵煎嚭</el-button>
+ <el-button type="danger" plain @click="handleDelete">鍒犻櫎</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>
+ <InspectionFormDia ref="inspectionFormDia" @close="handleQuery"></InspectionFormDia>
+ <FormDia ref="formDia" @close="handleQuery"></FormDia>
+ <files-dia ref="filesDia" @close="handleQuery"></files-dia>
+ <el-dialog v-model="dialogFormVisible" title="缂栬緫妫�楠屽憳" width="30%"
+ @close="closeDia">
+ <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
+ <el-form-item label="妫�楠屽憳锛�" prop="checkName">
+ <el-select v-model="form.checkName" placeholder="璇烽�夋嫨" clearable>
+ <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName"
+ :value="item.nickName"/>
+ </el-select>
+ </el-form-item>
+ </el-form>
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button type="primary" @click="submitForm">纭</el-button>
+ <el-button @click="closeDia">鍙栨秷</el-button>
+ </div>
+ </template>
+ </el-dialog>
+
+ </div>
+</template>
+
+<script setup>
+import {Search} from "@element-plus/icons-vue";
+import {onMounted, ref, reactive, toRefs, getCurrentInstance, nextTick} from "vue";
+import InspectionFormDia from "@/views/qualityManagement/rawMaterial/components/inspectionFormDia.vue";
+import FormDia from "@/views/qualityManagement/rawMaterial/components/formDia.vue";
+import {ElMessageBox} from "element-plus";
+import {
+ downloadQualityInspect,
+ qualityInspectUpdate,
+ submitQualityInspect
+} from "@/api/qualityManagement/rawMaterialInspection.js";
+import FilesDia from "@/views/qualityManagement/rawMaterial/components/filesDia.vue";
+import dayjs from "dayjs";
+import {userListNoPage} from "@/api/system/user.js";
+import useUserStore from "@/store/modules/user";
+import {deleteRawMaterial, findRawMaterialListPage} from "@/api/qualityManagement/rawMaterial.js";
+
+const data = reactive({
+ searchForm: {
+ supplier: "",
+ entryDate: undefined, // 褰曞叆鏃ユ湡
+ entryDateStart: undefined,
+ entryDateEnd: undefined,
+ },
+ rules: {
+ checkName: [{required: true, message: "璇烽�夋嫨", trigger: "change"}],
+ },
+});
+const {searchForm, rules} = toRefs(data);
+const tableColumn = ref([
+ {
+ label: "妫�娴嬫棩鏈�",
+ prop: "checkTime",
+ width: 120
+ },
+ {
+ label: "妫�楠屽憳",
+ prop: "checkName",
+ },
+ {
+ label: "浜у搧鍚嶇О",
+ prop: "productName",
+ },
+ {
+ label: "瑙勬牸鍨嬪彿",
+ prop: "model",
+ },
+ {
+ label: "鍗曚綅",
+ prop: "unit",
+ },
+ {
+ label: "鏁伴噺",
+ prop: "quantity",
+ width: 120
+ },
+ {
+ label: "妫�楠岀被鍨�",
+ prop: "checkTypeText",
+ width: 120
+ },
+ {
+ label: "妫�娴嬬粨鏋�",
+ prop: "checkResult",
+ dataType: "tag",
+ formatType: (params) => {
+ if (params === 1) {
+ return "danger";
+ } else if (params === 0) {
+ return "success";
+ } else {
+ return null;
+ }
+ },
+ },
+ {
+ label: "鎻愪氦鐘舵��",
+ prop: "inspectState",
+ formatData: (params) => {
+ if (params) {
+ return "宸叉彁浜�";
+ } else {
+ return "鏈彁浜�";
+ }
+ },
+ },
+ {
+ dataType: "action",
+ label: "鎿嶄綔",
+ align: "center",
+ fixed: "right",
+ width: 280,
+ operation: [
+ {
+ name: "缂栬緫",
+ type: "text",
+ clickFun: (row) => {
+ openForm("edit", row);
+ },
+ disabled: (row) => {
+ // 宸叉彁浜ゅ垯绂佺敤
+ if (row.inspectState == 1) return true;
+ // 濡傛灉妫�楠屽憳鏈夊�硷紝鍙湁褰撳墠鐧诲綍鐢ㄦ埛鑳界紪杈�
+ if (row.checkName) {
+ return row.checkName !== userStore.nickName;
+ }
+ return false;
+ }
+ },
+ {
+ name: "闄勪欢",
+ type: "text",
+ clickFun: (row) => {
+ openFilesFormDia(row);
+ },
+ },
+ {
+ name: "鎻愪氦",
+ type: "text",
+ clickFun: (row) => {
+ submit(row.id);
+ },
+ disabled: (row) => {
+ // 宸叉彁浜ゅ垯绂佺敤
+ if (row.inspectState == 1) return true;
+ // 濡傛灉妫�楠屽憳鏈夊�硷紝鍙湁褰撳墠鐧诲綍鐢ㄦ埛鑳芥彁浜�
+ if (row.checkName) {
+ return row.checkName !== userStore.nickName;
+ }
+ return false;
+ }
+ },
+ {
+ name: "鍒嗛厤妫�楠屽憳",
+ type: "text",
+ clickFun: (row) => {
+ if (!row.checkName) {
+ open(row)
+ } else {
+ proxy.$modal.msgError("妫�楠屽憳宸插瓨鍦�");
+ }
+ },
+ disabled: (row) => {
+ return row.inspectState == 1 || row.checkName;
+ }
+ },
+ {
+ name: "涓嬭浇",
+ type: "text",
+ clickFun: (row) => {
+ downLoadFile(row);
+ },
+ },
+ ],
+ },
+]);
+const tableData = ref([]);
+const selectedRows = ref([]);
+const tableLoading = ref(false);
+const userList = ref([]);
+const dialogFormVisible = ref(false);
+const form = ref({
+ checkName: ""
+});
+const page = reactive({
+ current: 1,
+ size: 100,
+ total: 0
+});
+const currentRow = ref(null)
+const formDia = ref()
+const filesDia = ref()
+const inspectionFormDia = ref()
+const {proxy} = getCurrentInstance()
+const userStore = useUserStore()
+const changeDaterange = (value) => {
+ searchForm.value.entryDateStart = undefined;
+ searchForm.value.entryDateEnd = undefined;
+ if (value) {
+ searchForm.value.entryDateStart = dayjs(value[0]).format("YYYY-MM-DD");
+ searchForm.value.entryDateEnd = dayjs(value[1]).format("YYYY-MM-DD");
+ }
+ getList();
+};
+// 鏌ヨ鍒楄〃
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+ page.current = 1;
+ getList();
+};
+const pagination = (obj) => {
+ page.current = obj.page;
+ page.size = obj.limit;
+ getList();
+};
+const getList = () => {
+ tableLoading.value = true;
+ const params = {...searchForm.value, ...page};
+ params.entryDate = undefined
+ findRawMaterialListPage({...params}).then(res => {
+ tableLoading.value = false;
+ tableData.value = res.data.records
+ page.total = res.data.total;
+ }).catch(err => {
+ tableLoading.value = false;
+ })
+};
+// 琛ㄦ牸閫夋嫨鏁版嵁
+const handleSelectionChange = (selection) => {
+ selectedRows.value = selection;
+};
+
+// 鎵撳紑寮规
+const openForm = (type, row) => {
+ nextTick(() => {
+ formDia.value?.openDialog(type, row)
+ })
+};
+// 鎵撳紑闄勪欢寮规
+const openFilesFormDia = (type, row) => {
+ nextTick(() => {
+ filesDia.value?.openDialog(type, row)
+ })
+};
+
+// 鍒犻櫎
+const handleDelete = () => {
+ let ids = [];
+ if (selectedRows.value.length > 0) {
+ ids = selectedRows.value.map((item) => item.id);
+ } else {
+ proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+ return;
+ }
+ ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "瀵煎嚭", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(() => {
+ deleteRawMaterial(ids).then((res) => {
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ getList();
+ });
+ })
+ .catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
+};
+// 瀵煎嚭
+const handleOut = () => {
+ ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(() => {
+ proxy.download("/quality/qualityInspect/export", {inspectType: 0}, "鍘熸潗鏂欐楠�.xlsx");
+ })
+ .catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
+};
+
+// 鎻愪环
+const submit = async (id) => {
+ const res = await submitQualityInspect({id: id})
+ if (res.code === 200) {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ getList();
+ }
+}
+
+// 鍏抽棴寮规
+const closeDia = () => {
+ proxy.resetForm("formRef");
+ dialogFormVisible.value = false;
+};
+
+const submitForm = () => {
+ if (currentRow.value) {
+ const data = {
+ ...form.value,
+ id: currentRow.value.id
+ }
+ qualityInspectUpdate(data).then(res => {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ closeDia();
+ getList();
+ })
+ }
+};
+
+const open = async (row) => {
+ let userLists = await userListNoPage();
+ userList.value = userLists.data;
+ currentRow.value = row
+ dialogFormVisible.value = true
+}
+
+const downLoadFile = (row) => {
+ downloadQualityInspect({ id: row.id }).then((blobData) => {
+ const blob = new Blob([blobData], {
+ type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+ })
+ const downloadUrl = window.URL.createObjectURL(blob)
+
+ const link = document.createElement('a')
+ link.href = downloadUrl
+ link.download = '鍘熸潗鏂欐楠屾姤鍛�.docx'
+ document.body.appendChild(link)
+ link.click()
+
+ document.body.removeChild(link)
+ window.URL.revokeObjectURL(downloadUrl)
+ })
+};
+
+onMounted(() => {
+ getList();
+});
+</script>
+
+<style scoped></style>
--
Gitblit v1.9.3