From 4dee4cb5b31a7f1dcd2c7b3d72f74b78d2fe3f29 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期五, 18 九月 2026 15:56:41 +0800
Subject: [PATCH] fix: 质检是否入库
---
src/views/basicData/product/index.vue | 129 ++++++++++++++++++++++++-------------------
1 files changed, 72 insertions(+), 57 deletions(-)
diff --git a/src/views/basicData/product/index.vue b/src/views/basicData/product/index.vue
index 99ab028..bb1dccf 100644
--- a/src/views/basicData/product/index.vue
+++ b/src/views/basicData/product/index.vue
@@ -5,10 +5,13 @@
<el-input v-model="search"
style="width: 210px"
placeholder="杈撳叆鍏抽敭瀛楄繘琛屾悳绱�"
- @change="searchFilter"
+ @input="debouncedSearch"
@clear="searchFilter"
clearable
prefix-icon="Search" />
+ <span style="margin-left: 12px">
+ <ImportExcel @uploadSuccess="handleImportSuccess" />
+ </span>
<el-button v-if="false"
type="primary"
@click="openProDia('addOne')"
@@ -43,12 +46,12 @@
<el-button type="primary"
link
:disabled="isTopLevelNode(data, node)"
- @click="openProDia('edit', data)">
+ @click="openProDia('edit', data, node)">
缂栬緫
</el-button>
<el-button type="primary"
link
- @click="openProDia('add', data)">
+ @click="openProDia('add', data, node)">
娣诲姞浜у搧
</el-button>
<el-button v-if="!node.childNodes.length"
@@ -72,8 +75,6 @@
@click="openModelDia('add')">
鏂板瑙勬牸鍨嬪彿
</el-button>
- <ImportExcel :product-id="currentId"
- @uploadSuccess="getModelList" />
<el-button type="danger"
@click="handleDelete"
style="margin-left: 10px"
@@ -104,8 +105,10 @@
<el-form-item label="浜у搧鍚嶇О锛�"
prop="productName">
<el-input v-model="form.productName"
+ type="textarea"
+ resize="vertical"
placeholder="璇疯緭鍏ヤ骇鍝佸悕绉�"
- maxlength="20"
+ maxlength="50"
show-word-limit
clearable
@keydown.enter.prevent />
@@ -132,17 +135,15 @@
:rules="modelRules"
ref="modelFormRef">
<el-row>
- <el-row>
- <el-col :span="24">
- <el-form-item label="浜у搧缂栧彿锛�"
- prop="productCode">
- <el-input v-model="modelForm.productCode"
- placeholder="璇疯緭鍏ヤ骇鍝佺紪鍙�"
- clearable
- @keydown.enter.prevent />
- </el-form-item>
- </el-col>
- </el-row>
+ <el-col :span="24">
+ <el-form-item label="浜у搧缂栧彿锛�"
+ prop="productCode">
+ <el-input v-model="modelForm.productCode"
+ placeholder="璇疯緭鍏ヤ骇鍝佺紪鍙�"
+ clearable
+ @keydown.enter.prevent />
+ </el-form-item>
+ </el-col>
<el-col :span="24">
<el-form-item label="瑙勬牸鍨嬪彿锛�"
prop="model">
@@ -285,6 +286,8 @@
const search = ref("");
const currentId = ref("");
const currentParentId = ref("");
+ /** 浜у搧寮圭獥锛歛dd 瀛樼埗鑺傜偣 id锛沞dit 瀛樺綋鍓嶈妭鐐� id 涓� parentId锛堜笉渚濊禆鏍戦�変腑椤癸級 */
+ const productDialogTarget = ref(null);
const operationType = ref("");
const treeLoad = ref(false);
const list = ref([]);
@@ -333,7 +336,7 @@
rules: {
productName: [
{ required: true, message: "璇疯緭鍏�", trigger: "blur" },
- { max: 20, message: "浜у搧鍚嶇О涓嶈兘瓒呰繃20涓瓧绗�", trigger: "blur" },
+ { max: 50, message: "浜у搧鍚嶇О涓嶈兘瓒呰繃50涓瓧绗�", trigger: "blur" },
],
},
modelForm: {
@@ -388,17 +391,28 @@
return [null, undefined, "", 0, "0"].includes(data?.parentId);
};
// 鎵撳紑浜у搧寮规
- const openProDia = (type, data) => {
- if (data && type === "edit" && isTopLevelNode(data)) {
+ const openProDia = (type, data, node) => {
+ if (data && type === "edit" && isTopLevelNode(data, node)) {
proxy.$modal.msgWarning("涓�绾ц妭鐐逛笉鑳界紪杈戞垨鍒犻櫎");
return;
}
operationType.value = type;
- productDia.value = true;
- form.value.productName = "";
- if (type === "edit") {
- form.value.productName = data.productName;
+ productDialogTarget.value = null;
+ if (type === "add" && data) {
+ productDialogTarget.value = { parentId: data.id };
+ } else if (type === "edit" && data) {
+ let parentId = data.parentId;
+ if (
+ [null, undefined, ""].includes(parentId) &&
+ node?.parent?.data?.id != null
+ ) {
+ parentId = node.parent.data.id;
+ }
+ productDialogTarget.value = { id: data.id, parentId };
}
+ productDia.value = true;
+ form.value.productName =
+ type === "edit" && data ? data.productName : "";
};
// 鎵撳紑瑙勬牸鍨嬪彿寮规
const openModelDia = (type, data) => {
@@ -417,14 +431,16 @@
proxy.$refs.formRef.validate(valid => {
if (valid) {
if (operationType.value === "add") {
- form.value.parentId = currentId.value;
+ form.value.parentId =
+ productDialogTarget.value?.parentId ?? currentId.value;
form.value.id = "";
} else if (operationType.value === "addOne") {
form.value.id = "";
form.value.parentId = "";
} else {
- form.value.id = currentId.value;
- form.value.parentId = "";
+ form.value.id =
+ productDialogTarget.value?.id ?? currentId.value;
+ form.value.parentId = productDialogTarget.value?.parentId ?? "";
}
addOrEditProduct(form.value).then(res => {
proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
@@ -437,6 +453,7 @@
// 鍏抽棴浜у搧寮规
const closeProDia = () => {
proxy.$refs.formRef.resetFields();
+ productDialogTarget.value = null;
productDia.value = false;
};
@@ -520,6 +537,13 @@
tableLoading.value = false;
});
};
+ // 瀵煎叆瀹屾垚鍚庡埛鏂颁骇鍝佹爲涓庡彸渚ц鏍煎垪琛�
+ const handleImportSuccess = () => {
+ getProductTreeList();
+ if (currentId.value) {
+ getModelList();
+ }
+ };
// 鍒犻櫎瑙勬牸鍨嬪彿
const handleDelete = () => {
let ids = [];
@@ -549,40 +573,31 @@
proxy.$modal.msg("宸插彇娑�");
});
};
- // 璋冪敤tree杩囨护鏂规硶 涓枃鑻辫繃婊�
- const filterNode = (value, data, node) => {
- if (!value) {
- //濡傛灉鏁版嵁涓虹┖锛屽垯杩斿洖true,鏄剧ず鎵�鏈夌殑鏁版嵁椤�
- return true;
- }
- // 鏌ヨ鍒楄〃鏄惁鏈夊尮閰嶆暟鎹紝灏嗗�煎皬鍐欙紝鍖归厤鑻辨枃鏁版嵁
- let val = value.toLowerCase();
- return chooseNode(val, data, node); // 璋冪敤杩囨护浜屽眰鏂规硶
+ const debounce = (fn, delay = 300) => {
+ let timer;
+ return (...args) => {
+ clearTimeout(timer);
+ timer = setTimeout(() => fn(...args), delay);
+ };
};
- // 杩囨护鐖惰妭鐐� / 瀛愯妭鐐� (濡傛灉杈撳叆鐨勫弬鏁版槸鐖惰妭鐐逛笖鑳藉尮閰嶏紝鍒欒繑鍥炶鑺傜偣浠ュ強鍏朵笅鐨勬墍鏈夊瓙鑺傜偣锛涘鏋滃弬鏁版槸瀛愯妭鐐癸紝鍒欒繑鍥炶鑺傜偣鐨勭埗鑺傜偣銆俷ame鏄腑鏂囧瓧绗︼紝enName鏄嫳鏂囧瓧绗�.
- const chooseNode = (value, data, node) => {
- if (data.label.indexOf(value) !== -1) {
+
+ const debouncedSearch = debounce(() => {
+ searchFilter();
+ }, 300);
+
+ const filterNode = (value, data) => {
+ if (!value) return true;
+ return chooseNode(value.toLowerCase(), data);
+ };
+
+ const chooseNode = (value, data) => {
+ const label = (data.label || '').toLowerCase();
+ if (label.indexOf(value) !== -1) {
return true;
}
- const level = node.level;
- // 濡傛灉浼犲叆鐨勮妭鐐规湰韬氨鏄竴绾ц妭鐐瑰氨涓嶇敤鏍¢獙浜�
- if (level === 1) {
- return false;
+ if (data.children && data.children.length > 0) {
+ return data.children.some(child => chooseNode(value, child));
}
- // 鍏堝彇褰撳墠鑺傜偣鐨勭埗鑺傜偣
- let parentData = node.parent;
- // 閬嶅巻褰撳墠鑺傜偣鐨勭埗鑺傜偣
- let index = 0;
- while (index < level - 1) {
- // 濡傛灉鍖归厤鍒扮洿鎺ヨ繑鍥烇紝姝ゅname鍊兼槸涓枃瀛楃锛宔nName鏄嫳鏂囧瓧绗︺�傚垽鏂尮閰嶄腑鑻辨枃杩囨护
- if (parentData.data.label.indexOf(value) !== -1) {
- return true;
- }
- // 鍚﹀垯鐨勮瘽鍐嶅線涓婁竴灞傚仛鍖归厤
- parentData = parentData.parent;
- index++;
- }
- // 娌″尮閰嶅埌杩斿洖false
return false;
};
getProductTreeList();
--
Gitblit v1.9.3