From 0761dbca1d6449a65aa908fa9596c8cf00fc01cc Mon Sep 17 00:00:00 2001
From: chenhj <1263187585@qq.com>
Date: 星期二, 17 三月 2026 11:44:01 +0800
Subject: [PATCH] 印铜报工
---
src/views/productionManagement/productionProcess/index.vue | 330 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 324 insertions(+), 6 deletions(-)
diff --git a/src/views/productionManagement/productionProcess/index.vue b/src/views/productionManagement/productionProcess/index.vue
index ea2a341..df847df 100644
--- a/src/views/productionManagement/productionProcess/index.vue
+++ b/src/views/productionManagement/productionProcess/index.vue
@@ -30,6 +30,9 @@
class="mb10">
<el-button type="primary"
@click="showNewModal">鏂板宸ュ簭</el-button>
+ <el-button type="info"
+ plain
+ @click="handleImport">瀵煎叆</el-button>
<el-button type="danger"
@click="handleDelete"
:disabled="selectedRows.length === 0"
@@ -45,6 +48,50 @@
@pagination="pagination"
:total="page.total"></PIMTable>
</div>
+
+ <!-- 宸ュ簭鐢熶骇璁板綍鍒楄〃寮规 -->
+ <el-dialog v-model="isShowProcessParamModal"
+ title="鐢熶骇璁板綍"
+ width="800px">
+ <div style="text-align: right"
+ class="mb10">
+ <el-button type="primary"
+ @click="showSelectProductParamModal">鏂板</el-button>
+ <el-button type="danger"
+ plain
+ @click="handleDeleteProcessParam"
+ :disabled="processParamSelectedRows.length === 0">鎵归噺鍒犻櫎</el-button>
+ </div>
+ <PIMTable rowKey="id"
+ :column="processParamColumns"
+ :tableData="processParamTableData"
+ :page="processParamPage"
+ :isSelection="true"
+ @selection-change="handleProcessParamSelectionChange"
+ @pagination="processParamPagination"
+ :total="processParamPage.total"></PIMTable>
+ </el-dialog>
+
+ <!-- 閫夋嫨鐢熶骇璁板綍寮规 -->
+ <el-dialog v-model="isShowSelectParamModal"
+ title="閫夋嫨鐢熶骇璁板綍"
+ width="800px">
+ <PIMTable rowKey="id"
+ :column="productParamColumns"
+ :tableData="productParamTableData"
+ :page="productParamPage"
+ :isSelection="true"
+ @selection-change="handleProductParamSelectionChange"
+ @pagination="productParamPagination"
+ :total="productParamPage.total"></PIMTable>
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button type="primary"
+ @click="handleAddProcessParam">纭畾</el-button>
+ <el-button @click="isShowSelectParamModal = false">鍙栨秷</el-button>
+ </div>
+ </template>
+ </el-dialog>
<new-process v-if="isShowNewModal"
v-model:visible="isShowNewModal"
@completed="getList" />
@@ -52,14 +99,38 @@
v-model:visible="isShowEditModal"
:record="record"
@completed="getList" />
+ <ImportDialog ref="importDialogRef"
+ v-model="importDialogVisible"
+ title="瀵煎叆宸ュ簭"
+ :action="importAction"
+ :headers="importHeaders"
+ :auto-upload="false"
+ :on-success="handleImportSuccess"
+ :on-error="handleImportError"
+ @confirm="handleImportConfirm"
+ @download-template="handleDownloadTemplate"
+ @close="handleImportClose" />
</div>
</template>
<script setup>
- import { onMounted, ref } from "vue";
+ import { onMounted, ref, reactive, toRefs, getCurrentInstance } from "vue";
import NewProcess from "@/views/productionManagement/productionProcess/New.vue";
import EditProcess from "@/views/productionManagement/productionProcess/Edit.vue";
- import { listPage, del } from "@/api/productionManagement/productionProcess.js";
+ import ImportDialog from "@/components/Dialog/ImportDialog.vue";
+ import {
+ listPage,
+ del,
+ importData,
+ downloadTemplate,
+ } from "@/api/productionManagement/productionProcess.js";
+ import {
+ listPage as listProcessParamPage,
+ del as delProcessParam,
+ addProductProcessParameter,
+ } from "@/api/productionManagement/productProcessParameter.js";
+ import { listPage as listProductParamPage } from "@/api/productionManagement/productionRecords.js";
+ import { getToken } from "@/utils/auth";
const data = reactive({
searchForm: {
@@ -70,20 +141,35 @@
const { searchForm } = toRefs(data);
const tableColumn = ref([
{
- label: "宸ュ簭鍚嶇О",
- prop: "name",
- },
- {
label: "宸ュ簭缂栧彿",
prop: "no",
+ },
+ {
+ label: "宸ュ簭鍚嶇О",
+ prop: "name",
},
{
label: "宸ヨ祫瀹氶",
prop: "salaryQuota",
},
{
+ label: "鍚堟牸鐜�",
+ prop: "qualifiedRate",
+ },
+ {
+ label: "鏄惁璐ㄦ",
+ prop: "isQuality",
+ formatData: (params) => {
+ return params ? "鏄�" : "鍚�";
+ },
+ },
+ {
label: "澶囨敞",
prop: "remark",
+ },
+ {
+ label: "鏇存柊鏃堕棿",
+ prop: "updateTime",
},
{
dataType: "action",
@@ -92,6 +178,13 @@
fixed: "right",
width: 280,
operation: [
+ {
+ name: "鏌ョ湅",
+ type: "text",
+ clickFun: row => {
+ showProcessParamModal(row);
+ },
+ },
{
name: "缂栬緫",
type: "text",
@@ -102,18 +195,86 @@
],
},
]);
+ // 宸ュ簭宸茬粦瀹氱殑鐢熶骇璁板綍鍒楄〃鍒楅厤缃�
+ const processParamColumns = ref([
+ { label: "鍙傛暟缂栫爜", prop: "code" },
+ { label: "鍙傛暟椤�", prop: "parameterItem" },
+ {
+ label: "鍙傛暟绫诲瀷",
+ prop: "type",
+ formatData: val => {
+ const dictList = (proxy.useDict && proxy.useDict("parameter_tyep")?.parameter_tyep) || [];
+ const list = dictList.value || dictList;
+ const hit = (list || []).find(d => d.value === val);
+ return hit ? hit.label : val;
+ },
+ },
+ { label: "鍗曚綅", prop: "unit" },
+ { label: "鍙傛暟鏍煎紡", prop: "parameterFormat" },
+ {
+ label: "鏄惁蹇呭~",
+ prop: "isRequired",
+ formatData: v => (v === "1" || v === 1 ? "鏄�" : "鍚�"),
+ },
+ ]);
+ // 鍙�夋嫨鐨勭敓浜ц褰曞垪琛ㄥ垪閰嶇疆
+ const productParamColumns = ref([
+ { label: "鍙傛暟缂栫爜", prop: "code" },
+ { label: "鍙傛暟椤�", prop: "parameterItem" },
+ {
+ label: "鍙傛暟绫诲瀷",
+ prop: "type",
+ formatData: val => {
+ const dictList = (proxy.useDict && proxy.useDict("parameter_tyep")?.parameter_tyep) || [];
+ const list = dictList.value || dictList;
+ const hit = (list || []).find(d => d.value === val);
+ return hit ? hit.label : val;
+ },
+ },
+ { label: "鍗曚綅", prop: "unit" },
+ { label: "鍙傛暟鏍煎紡", prop: "parameterFormat" },
+ {
+ label: "鏄惁蹇呭~",
+ prop: "isRequired",
+ formatData: v => (v === "1" || v === 1 ? "鏄�" : "鍚�"),
+ },
+ ]);
const tableData = ref([]);
const selectedRows = ref([]);
const tableLoading = ref(false);
const isShowNewModal = ref(false);
const isShowEditModal = ref(false);
+ const isShowProcessParamModal = ref(false);
+ const isShowSelectParamModal = ref(false);
const record = ref({});
+ const currentProcess = ref(null);
+ const importDialogVisible = ref(false);
+ const importDialogRef = ref(null);
const page = reactive({
current: 1,
size: 100,
total: 0,
});
+ const processParamPage = reactive({
+ current: 1,
+ size: 100,
+ total: 0,
+ });
+ const productParamPage = reactive({
+ current: 1,
+ size: 100,
+ total: 0,
+ });
+ const processParamTableData = ref([]);
+ const productParamTableData = ref([]);
+ const processParamSelectedRows = ref([]);
+ const productParamSelectedRows = ref([]);
const { proxy } = getCurrentInstance();
+
+ // 瀵煎叆鐩稿叧閰嶇疆
+ const importAction =
+ import.meta.env.VITE_APP_BASE_API + "/productProcess/importData";
+ const importHeaders = { Authorization: "Bearer " + getToken() };
// 鏌ヨ鍒楄〃
/** 鎼滅储鎸夐挳鎿嶄綔 */
@@ -126,6 +287,16 @@
page.current = obj.page;
page.size = obj.limit;
getList();
+ };
+ const processParamPagination = obj => {
+ processParamPage.current = obj.page;
+ processParamPage.size = obj.limit;
+ getProcessParamList();
+ };
+ const productParamPagination = obj => {
+ productParamPage.current = obj.page;
+ productParamPage.size = obj.limit;
+ getProductParamList();
};
const getList = () => {
tableLoading.value = true;
@@ -148,6 +319,14 @@
selectedRows.value = selection;
};
+ const handleProcessParamSelectionChange = selection => {
+ processParamSelectedRows.value = selection;
+ };
+
+ const handleProductParamSelectionChange = selection => {
+ productParamSelectedRows.value = selection;
+ };
+
// 鎵撳紑鏂板寮规
const showNewModal = () => {
isShowNewModal.value = true;
@@ -156,6 +335,88 @@
const showEditModal = row => {
isShowEditModal.value = true;
record.value = row;
+ };
+
+ // 鏌ョ湅褰撳墠宸ュ簭鐨勭敓浜ц褰�
+ const showProcessParamModal = row => {
+ currentProcess.value = row;
+ isShowProcessParamModal.value = true;
+ processParamPage.current = 1;
+ getProcessParamList();
+ };
+
+ const getProcessParamList = () => {
+ if (!currentProcess.value) return;
+ const params = {
+ processId: currentProcess.value.id,
+ ...processParamPage,
+ };
+ listProcessParamPage(params).then(res => {
+ processParamTableData.value = res.data.records || [];
+ processParamPage.total = res.data.total || 0;
+ });
+ };
+
+ // 鍒犻櫎褰撳墠宸ュ簭缁戝畾鐨勭敓浜ц褰�
+ const handleDeleteProcessParam = () => {
+ const ids = processParamSelectedRows.value.map(item => item.id);
+ if (!ids.length) {
+ proxy.$modal.msgWarning("璇烽�夋嫨瑕佸垹闄ょ殑璁板綍");
+ return;
+ }
+ proxy.$modal
+ .confirm("鏄惁纭鍒犻櫎閫変腑鐨勭敓浜ц褰曪紵")
+ .then(() => delProcessParam(ids))
+ .then(() => {
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ getProcessParamList();
+ })
+ .catch(() => {});
+ };
+
+ // 鎵撳紑閫夋嫨鐢熶骇璁板綍寮规
+ const showSelectProductParamModal = () => {
+ isShowSelectParamModal.value = true;
+ productParamPage.current = 1;
+ getProductParamList();
+ };
+
+ const getProductParamList = () => {
+ const params = {
+ ...productParamPage,
+ };
+ listProductParamPage(params).then(res => {
+ const records = res.data.records || [];
+ // 宸茬粦瀹氬埌褰撳墠宸ュ簭鐨勭敓浜ц褰曪紝涓嶅厑璁稿啀娆¢�夋嫨 -> 鏍规嵁鍙傛暟缂栫爜鎵撲笂 disabled 鏍囪
+ const boundCodeSet = new Set(
+ (processParamTableData.value || [])
+ .map(item => item.code ?? item.parameterCode)
+ .filter(code => !!code)
+ );
+ productParamTableData.value = records.map(item => ({
+ ...item,
+ disabled: item.code ? boundCodeSet.has(item.code) : false,
+ }));
+ productParamPage.total = res.data.total || 0;
+ });
+ };
+
+ // 纭缁欏綋鍓嶅伐搴忔柊澧炵敓浜ц褰�
+ const handleAddProcessParam = () => {
+ if (!currentProcess.value) return;
+ const selectedList = productParamSelectedRows.value || [];
+ if (!selectedList.length) {
+ proxy.$modal.msgWarning("璇烽�夋嫨瑕佺粦瀹氱殑鐢熶骇璁板綍");
+ return;
+ }
+ // processId 鏀惧湪璺緞閲岋紝body 鐩存帴浼犻�変腑鐨勭敓浜ц褰曟暟缁�
+ addProductProcessParameter(currentProcess.value.id, selectedList)
+ .then(() => {
+ proxy.$modal.msgSuccess("鏂板鎴愬姛");
+ isShowSelectParamModal.value = false;
+ getProcessParamList();
+ })
+ .catch(() => {});
};
// 鍒犻櫎
@@ -195,6 +456,63 @@
}
}
+ // 瀵煎叆
+ const handleImport = () => {
+ importDialogVisible.value = true;
+ };
+
+ // 纭瀵煎叆
+ const handleImportConfirm = () => {
+ if (importDialogRef.value) {
+ importDialogRef.value.submit();
+ }
+ };
+
+ // 瀵煎叆鎴愬姛
+ const handleImportSuccess = response => {
+ if (response.code === 200) {
+ proxy.$modal.msgSuccess("瀵煎叆鎴愬姛");
+ importDialogVisible.value = false;
+ if (importDialogRef.value) {
+ importDialogRef.value.clearFiles();
+ }
+ getList();
+ } else {
+ proxy.$modal.msgError(response.msg || "瀵煎叆澶辫触");
+ }
+ };
+
+ // 瀵煎叆澶辫触
+ const handleImportError = error => {
+ proxy.$modal.msgError("瀵煎叆澶辫触锛�" + (error.message || "鏈煡閿欒"));
+ };
+
+ // 鍏抽棴瀵煎叆寮圭獥
+ const handleImportClose = () => {
+ if (importDialogRef.value) {
+ importDialogRef.value.clearFiles();
+ }
+ };
+
+ // 涓嬭浇妯℃澘
+ const handleDownloadTemplate = async () => {
+ try {
+ const res = await downloadTemplate();
+ const blob = new Blob([res], {
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ });
+ const url = window.URL.createObjectURL(blob);
+ const link = document.createElement("a");
+ link.href = url;
+ link.download = "宸ュ簭瀵煎叆妯℃澘.xlsx";
+ link.click();
+ window.URL.revokeObjectURL(url);
+ proxy.$modal.msgSuccess("妯℃澘涓嬭浇鎴愬姛");
+ } catch (error) {
+ proxy.$modal.msgError("妯℃澘涓嬭浇澶辫触");
+ }
+ };
+
// 瀵煎嚭
// const handleOut = () => {
// ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
--
Gitblit v1.9.3