From 830adfef9c17ff8915761ff218f9d8e8a04bc3ea Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 03 二月 2026 15:33:11 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_新_双奇点' into dev_新_双奇点
---
src/views/basicData/product/index.vue | 835 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 700 insertions(+), 135 deletions(-)
diff --git a/src/views/basicData/product/index.vue b/src/views/basicData/product/index.vue
index 0275185..4b36793 100644
--- a/src/views/basicData/product/index.vue
+++ b/src/views/basicData/product/index.vue
@@ -3,35 +3,62 @@
<div class="left">
<div>
<el-input
- v-model="search"
- style="width: 240px"
- placeholder="杈撳叆鍏抽敭瀛楄繘琛屾悳绱�"
- @change="searchFilter"
- @clear="searchFilter"
- clearable
- prefix-icon="Search"
+ v-model="search"
+ style="width: 210px"
+ placeholder="杈撳叆鍏抽敭瀛楄繘琛屾悳绱�"
+ @change="searchFilter"
+ @clear="searchFilter"
+ clearable
+ prefix-icon="Search"
/>
- <el-button type="primary" @click="openProDia('add')" style="margin-left: 10px">鏂板浜у搧</el-button>
+ <el-button
+ type="primary"
+ @click="openProDia('addOne')"
+ style="margin-left: 10px"
+ >鏂板浜у搧澶х被</el-button
+ >
</div>
- <div>
- <el-tree ref="tree" v-loading="treeLoad" :data="list"
- :default-expanded-keys="expandedKeys" :draggable="true" :filter-node-method="filterNode"
- :props="{ children: 'children', label: 'label' }" highlight-current node-key="label"
- style="height: calc(100vh - 190px);overflow-y: scroll;scrollbar-width: none;">
+ <div ref="containerRef">
+ <el-tree
+ ref="tree"
+ v-loading="treeLoad"
+ :data="list"
+ @node-click="handleNodeClick"
+ :expand-on-click-node="false"
+ :default-expanded-keys="expandedKeys"
+ :filter-node-method="filterNode"
+ :props="{ children: 'children', label: 'label' }"
+ highlight-current
+ node-key="id"
+ class="product-tree-scroll"
+ style="height: calc(100vh - 190px); overflow-y: auto"
+ >
<template #default="{ node, data }">
<div class="custom-tree-node">
- <span>{{ node.label }}</span>
+ <span class="tree-node-content">
+ <el-icon class="orange-icon">
+ <component :is="data.children && data.children.length > 0
+ ? node.expanded ? 'FolderOpened' : 'Folder' : 'Tickets'" />
+ </el-icon>
+ <span class="tree-node-label">{{ data.label }}</span>
+ </span>
<div>
- <el-button type="primary" link @click="openProDia('edit', data)">
+ <el-button
+ type="primary"
+ link
+ @click="openProDia('edit', data)"
+ >
缂栬緫
</el-button>
- <!-- 淇敼姝ゅ -->
+ <el-button type="primary" link @click="openProDia('add', data)" :disabled="node.level >= 3">
+ 娣诲姞浜у搧
+ </el-button>
<el-button
- v-if="!node.childNodes.length"
- style="margin-left: 4px"
- type="danger"
- link
- @click="remove(node, data)"
+ v-if="!node.childNodes.length"
+ style="margin-left: 4px"
+ type="danger"
+ link
+ @click="remove(node, data)"
>
鍒犻櫎
</el-button>
@@ -42,19 +69,61 @@
</div>
</div>
<div class="right">
- <div style="margin-bottom: 10px">
- <el-button type="primary" @click="modelDia = true">鏂板瑙勬牸鍨嬪彿</el-button>
- <el-button type="danger" @click="handleDelete" style="margin-left: 10px" plain>鍒犻櫎</el-button>
+ <div style="margin-bottom: 10px" v-if="isShowButton">
+ <el-button type="primary" @click="openModelDia('add')">
+ 鏂板瑙勬牸鍨嬪彿
+ </el-button>
+ <ImportExcel @uploadSuccess="getModelList" />
+ <el-button
+ type="danger"
+ @click="handleDelete"
+ style="margin-left: 10px"
+ plain
+ >
+ 鍒犻櫎
+ </el-button>
</div>
- <PIMTable :column="tableColumn" :tableData="tableData" :page="page" :isSelection="true" :handleSelectionChange="handleSelectionChange"
- :tableLoading="tableLoading" @pagination="pagination" :total="total"></PIMTable>
+ <PIMTable
+ rowKey="id"
+ :column="tableColumn"
+ :tableData="tableData"
+ :page="page"
+ :isSelection="true"
+ @selection-change="handleSelectionChange"
+ :tableLoading="tableLoading"
+ @pagination="pagination"
+ >
+ <template #productImage="{ row }">
+ <img
+ v-if="row.url"
+ class="upload-img"
+ :src="javaApiUrl + row.url"
+ @click="previewImage(row.url)"
+ style="cursor: pointer"
+ />
+ <span v-else style="color: #909399">鏆傛棤鍥剧墖</span>
+ </template>
+ </PIMTable>
</div>
- <el-dialog :visible.sync="productDia" title="浜у搧" width="400px">
- <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
+ <el-dialog v-model="productDia" title="浜у搧" width="400px" @keydown.enter.prevent>
+ <el-form
+ :model="form"
+ label-width="140px"
+ label-position="top"
+ :rules="rules"
+ ref="formRef"
+ >
<el-row :gutter="30">
<el-col :span="24">
<el-form-item label="浜у搧鍚嶇О锛�" prop="productName">
- <el-input v-model="form.productName" placeholder="璇疯緭鍏ヤ骇鍝佸悕绉�" clearable/>
+ <el-input
+ v-model="form.productName"
+ placeholder="璇疯緭鍏ヤ骇鍝佸悕绉�"
+ maxlength="20"
+ show-word-limit
+ clearable
+ @keydown.enter.prevent
+ />
</el-form-item>
</el-col>
</el-row>
@@ -66,173 +135,577 @@
</div>
</template>
</el-dialog>
+ <el-dialog
+ v-model="modelDia"
+ title="瑙勬牸鍨嬪彿"
+ width="600px"
+ @close="closeModelDia"
+ @keydown.enter.prevent
+ >
+ <el-form
+ :model="modelForm"
+ label-width="140px"
+ label-position="top"
+ :rules="modelRules"
+ ref="modelFormRef"
+ >
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="瑙勬牸鍨嬪彿锛�" prop="model">
+ <el-input
+ v-model="modelForm.model"
+ placeholder="璇疯緭鍏ヨ鏍煎瀷鍙�"
+ clearable
+ @keydown.enter.prevent
+ />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="鍗曚綅锛�" prop="unit">
+ <el-input
+ v-model="modelForm.unit"
+ placeholder="璇疯緭鍏ュ崟浣�"
+ clearable
+ @keydown.enter.prevent
+ />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="楂樺害锛�" prop="height">
+ <el-input
+ v-model="modelForm.height"
+ placeholder="璇疯緭鍏ラ珮搴�"
+ clearable
+ @keydown.enter.prevent
+ />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="姣忎欢鏁伴噺/鏀細" prop="boxNum">
+ <el-input-number
+ :step="1"
+ :min="0"
+ style="width: 100%"
+ v-model="modelForm.boxNum"
+ @change="calculateTotalPrice"
+ placeholder="璇疯緭鍏ユ瘡浠舵暟閲�"
+ />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="鍗曚环(鍏�)/浠讹細" prop="taxInclusiveUnitPrice">
+ <el-input-number
+ :step="0.01"
+ :min="0"
+ style="width: 100%"
+ v-model="modelForm.taxInclusiveUnitPrice"
+ @change="calculateTotalPrice"
+ placeholder="璇疯緭鍏ュ崟浠�"
+ />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="鍗曚环(缇庡厓)/浠讹細" prop="dollarPrice">
+ <el-input-number
+ :step="0.01"
+ :min="0"
+ style="width: 100%"
+ v-model="modelForm.dollarPrice"
+ placeholder="璇疯緭鍏ョ編鍏冨崟浠�"
+ />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="24">
+ <el-form-item label="浜у搧鍥剧墖锛�" prop="url">
+ <el-upload
+ :action="uploadUrl"
+ :before-upload="handleBeforeUpload"
+ :on-success="(res, file) => handleUploadSuccess(res, file)"
+ :on-error="handleUploadError"
+ name="file"
+ :show-file-list="false"
+ :headers="headers"
+ accept="image/*"
+ :data="{ type: 13 }"
+ >
+ <img
+ v-if="modelForm.url"
+ class="upload-img-dialog"
+ :src="javaApiUrl + modelForm.url"
+ />
+ <el-icon v-else class="avatar-uploader-icon-dialog"><Plus /></el-icon>
+ </el-upload>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ </el-form>
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button type="primary" @click="submitModelForm">纭</el-button>
+ <el-button @click="closeModelDia">鍙栨秷</el-button>
+ </div>
+ </template>
+ </el-dialog>
</div>
</template>
<script setup>
-import {ref} from "vue";
-import {listCustomer} from "@/api/basicData/customerFile.js";
-import {ElMessageBox} from "element-plus";
-import {productTreeList} from "@/api/basicData/product.js";
-const { proxy } = getCurrentInstance()
+import { ref, reactive, toRefs, getCurrentInstance, nextTick } from "vue";
+import { ElMessageBox } from "element-plus";
+import { Plus } from "@element-plus/icons-vue";
+import { getToken } from "@/utils/auth";
+import {
+ addOrEditProduct,
+ addOrEditProductModel,
+ delProduct,
+ delProductModel,
+ modelListPage,
+ productTreeList,
+} from "@/api/basicData/product.js";
+import ImportExcel from "./ImportExcel/index.vue";
+import PIMTable from "@/components/PIMTable/PIMTable.vue";
-const search = ref('')
-const treeLoad = ref(false)
-const list = ref([])
-const expandedKeys = ref([])
+const { proxy } = getCurrentInstance();
+const tree = ref(null);
+const containerRef = ref(null);
+
+const productDia = ref(false);
+const modelDia = ref(false);
+const modelOperationType = ref("");
+const search = ref("");
+const currentId = ref("");
+const currentParentId = ref("");
+const operationType = ref("");
+const treeLoad = ref(false);
+const list = ref([]);
+const expandedKeys = ref([]);
const tableColumn = ref([
{
- label: '瑙勬牸鍨嬪彿',
- prop: 'model',
+ label: "浜у搧鍥剧墖",
+ prop: "url",
+ dataType: "slot",
+ slot: "productImage",
+ align: "center",
+ width: 100,
},
{
- label: '鍗曚綅',
- prop: 'model',
+ label: "瑙勬牸鍨嬪彿",
+ prop: "model",
+ },
+ {
+ label: "鍗曚綅",
+ prop: "unit",
+ },
+ {
+ label: "楂樺害",
+ prop: "height",
+ width: 120,
+ },
+ {
+ label: "姣忎欢鏁伴噺/鏀�",
+ prop: "boxNum",
+ width: 120,
+ },
+ {
+ label: "鍗曚环(鍏�)/浠�",
+ prop: "taxInclusiveUnitPrice",
+ width: 120,
+ },
+ {
+ label: "鍗曚环(缇庡厓)/浠�",
+ prop: "dollarPrice",
+ width: 130,
},
{
dataType: "action",
label: "鎿嶄綔",
- align: 'center',
+ align: "center",
operation: [
{
name: "缂栬緫",
type: "text",
clickFun: (row) => {
- openForm('edit', row);
+ openModelDia("edit", row);
},
},
],
},
-])
-const tableData = ref([])
-const tableLoading = ref(false)
-const total = ref(0)
-const selectedRows = ref([])
+]);
+const tableData = ref([]);
+const tableLoading = ref(false);
+const isShowButton = ref(false);
+const selectedRows = ref([]);
+
+// 涓婁紶閰嶇疆
+const uploadUrl = ref(import.meta.env.VITE_APP_BASE_API + "/file/upload"); // 涓婁紶鐨勫浘鐗囨湇鍔″櫒鍦板潃
+const headers = ref({ Authorization: "Bearer " + getToken() });
+const javaApiUrl = proxy.javaApi || import.meta.env.VITE_APP_BASE_API;
const page = reactive({
current: 1,
size: 10,
-})
-const productDia = ref(false)
-const modelDia = ref(false)
+ total: 0,
+});
const data = reactive({
form: {
- productName: '',
+ productName: "",
},
rules: {
- productName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- }
-})
-const { form, rules } = toRefs(data)
+ productName: [
+ { required: true, message: "璇疯緭鍏�", trigger: "blur" },
+ { max: 20, message: "浜у搧鍚嶇О涓嶈兘瓒呰繃20涓瓧绗�", trigger: "blur" },
+ ],
+ },
+ modelForm: {
+ model: "",
+ unit: "",
+ url: "",
+ height: "",
+ boxNum: null,
+ taxInclusiveUnitPrice: null,
+ dollarPrice: null,
+ },
+ modelRules: {
+ model: [{ required: true, message: "璇疯緭鍏ヨ鏍煎瀷鍙�", trigger: "blur" }],
+ unit: [{ required: true, message: "璇疯緭鍏ュ崟浣�", trigger: "blur" }],
+ url: [{ required: true, message: "璇蜂笂浼犱骇鍝佸浘鐗�", trigger: "change" }],
+ height: [{ required: true, message: "璇疯緭鍏ラ珮搴�", trigger: "blur" }],
+ boxNum: [{ required: true, message: "璇疯緭鍏ユ瘡浠舵暟閲�/鏀�", trigger: "change" }],
+ taxInclusiveUnitPrice: [{ required: true, message: "璇疯緭鍏ュ崟浠�(鍏�)/浠�", trigger: "change" }],
+ dollarPrice: [{ required: true, message: "璇疯緭鍏ュ崟浠�(缇庡厓)/浠�", trigger: "change" }],
+ },
+});
+const { form, rules, modelForm, modelRules } = toRefs(data);
+// 鏌ヨ浜у搧鏍�
const getProductTreeList = () => {
treeLoad.value = true;
- productTreeList().then(res => {
- list.value = res
- list.value.forEach((a) => {
- expandedKeys.value.push(a.label);
+ productTreeList()
+ .then((res) => {
+ list.value = res;
+ list.value.forEach((a) => {
+ expandedKeys.value.push(a.label);
+ });
+ treeLoad.value = false;
+ })
+ .catch((err) => {
+ treeLoad.value = false;
});
- treeLoad.value = false;
- }).catch(err => {
- treeLoad.value = false;
- })
-}
+};
+// 杩囨护浜у搧鏍�
const searchFilter = () => {
proxy.$refs.tree.filter(search.value);
-}
+};
+// 鎵撳紑浜у搧寮规
const openProDia = (type, data) => {
- productDia.value = true
- console.log('openEditDia', data)
-}
+ operationType.value = type;
+ productDia.value = true;
+ form.value.productName = "";
+ if (type === "edit") {
+ form.value.productName = data.productName;
+ }
+};
+// 鎵撳紑瑙勬牸鍨嬪彿寮规
+const openModelDia = (type, data) => {
+ modelOperationType.value = type;
+ modelDia.value = true;
+ // 閲嶇疆琛ㄥ崟
+ modelForm.value = {
+ model: "",
+ unit: "",
+ url: "",
+ height: "",
+ boxNum: null,
+ taxInclusiveUnitPrice: null,
+ dollarPrice: null,
+ id: "",
+ };
+ if (type === "edit" && data) {
+ // 濡傛灉 url 鏄� Windows 璺緞锛岄渶瑕佽浆鎹�
+ let url = data.url || "";
+ if (url && url.indexOf("\\") > -1) {
+ url = processFileUrl(url);
+ }
+ modelForm.value = {
+ ...data,
+ url: url,
+ boxNum: data.boxNum || null,
+ taxInclusiveUnitPrice: data.taxInclusiveUnitPrice || null,
+ dollarPrice: data.dollarPrice || null,
+ };
+ }
+};
+// 鎻愪氦浜у搧鍚嶇О淇敼
const submitForm = () => {
-}
+ proxy.$refs.formRef.validate((valid) => {
+ if (valid) {
+ if (operationType.value === "add") {
+ form.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 = "";
+ }
+ addOrEditProduct(form.value).then((res) => {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ closeProDia();
+ getProductTreeList();
+ });
+ }
+ });
+};
+// 鍏抽棴浜у搧寮规
const closeProDia = () => {
proxy.$refs.formRef.resetFields();
productDia.value = false;
-}
-const remove = (value) => {
+};
-}
+// 鍒犻櫎浜у搧
+const remove = (node, data) => {
+ let ids = [];
+ ids.push(data.id);
+ ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(() => {
+ tableLoading.value = true;
+ delProduct(ids)
+ .then((res) => {
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ getProductTreeList();
+ })
+ .finally(() => {
+ tableLoading.value = false;
+ });
+ })
+ .catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
+};
+// 閫夋嫨浜у搧
+const handleNodeClick = (val, node, el) => {
+ // 鍒ゆ柇鏄惁涓哄彾瀛愯妭鐐�
+ isShowButton.value = !(val.children && val.children.length > 0);
+ // 鍙湁鍙跺瓙鑺傜偣鎵嶆墽琛屼互涓嬮�昏緫
+ currentId.value = val.id;
+ currentParentId.value = val.parentId;
+ getModelList();
+};
+
+// 鎻愪氦瑙勬牸鍨嬪彿淇敼
+const submitModelForm = () => {
+ proxy.$refs.modelFormRef.validate((valid) => {
+ if (valid) {
+ modelForm.value.productId = currentId.value;
+ addOrEditProductModel(modelForm.value).then((res) => {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ closeModelDia();
+ getModelList();
+ });
+ }
+ });
+};
+// 鍏抽棴鍨嬪彿寮规
+const closeModelDia = () => {
+ proxy.$refs.modelFormRef.resetFields();
+ modelDia.value = false;
+};
// 琛ㄦ牸閫夋嫨鏁版嵁
const handleSelectionChange = (selection) => {
- selectedRows.value = selection
-}
-// 鍒犻櫎
-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(() => {
- tableLoading.value = true
- delCustomer(ids).then(res => {
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛")
- getList()
- }).finally(() => {
- tableLoading.value = false
- })
- }).catch(() => {
- proxy.$modal.msg("宸插彇娑�")
- })
-}
+ selectedRows.value = selection;
+};
+
// 鏌ヨ瑙勬牸鍨嬪彿
-const pagination = ({ current, limit }) => {
- page.current = current;
- page.size = limit;
- getList()
-}
-const getList = () => {
- tableLoading.value = true
- listCustomer({...searchForm.value, ...page}).then(res => {
- tableLoading.value = false
- tableData.value = res.rows
- total.value = res.total
+const pagination = (obj) => {
+ page.current = obj.page;
+ page.size = obj.limit;
+ getModelList();
+};
+const getModelList = () => {
+ tableLoading.value = true;
+ modelListPage({
+ id: currentId.value,
+ current: page.current,
+ size: page.size,
+ }).then((res) => {
+ console.log("res", res);
+ // 澶勭悊杩斿洖鐨勬暟鎹紝杞崲 Windows 璺緞涓哄彲璁块棶鐨� URL
+ tableData.value = (res.records || []).map((item) => {
+ if (item.url && item.url.indexOf("\\") > -1) {
+ item.url = processFileUrl(item.url);
+ }
+ return item;
+ });
+ page.total = res.total;
+ tableLoading.value = false;
+ });
+};
+
+// 涓婁紶鍓嶆牎楠�
+const handleBeforeUpload = (file) => {
+ const isImage = file.type.startsWith("image/");
+ const isLt5M = file.size / 1024 / 1024 < 5;
+
+ if (!isImage) {
+ proxy.$modal.msgError("涓婁紶鏂囦欢鍙兘鏄浘鐗囨牸寮�!");
+ return false;
+ }
+ if (!isLt5M) {
+ proxy.$modal.msgError("涓婁紶鍥剧墖澶у皬涓嶈兘瓒呰繃 5MB!");
+ return false;
+ }
+ return true;
+};
+
+// 澶勭悊鏂囦欢璺緞锛氬皢 Windows 璺緞杞崲涓哄彲璁块棶鐨� URL
+const processFileUrl = (filePath) => {
+ if (!filePath) return "";
+
+ // 濡傛灉璺緞鏄� Windows 璺緞鏍煎紡锛堝寘鍚弽鏂滄潬锛夛紝闇�瑕佽浆鎹�
+ if (filePath && filePath.indexOf("\\") > -1) {
+ // 鏌ユ壘 temp 鎴� uploads 鍏抽敭瀛楃殑浣嶇疆
+ const tempIndex = filePath.toLowerCase().indexOf("temp");
+ const uploadsIndex = filePath.toLowerCase().indexOf("uploads");
+
+ if (tempIndex > -1) {
+ // 浠� temp 寮�濮嬫彁鍙栫浉瀵硅矾寰勶紝骞跺皢鍙嶆枩鏉犳浛鎹负姝f枩鏉�
+ const relativePath = filePath.substring(tempIndex).replace(/\\/g, "/");
+ filePath = "/" + relativePath;
+ } else if (uploadsIndex > -1) {
+ // 浠� uploads 寮�濮嬫彁鍙栫浉瀵硅矾寰�
+ const relativePath = filePath.substring(uploadsIndex).replace(/\\/g, "/");
+ filePath = "/" + relativePath;
+ } else {
+ // 濡傛灉娌℃湁鎵惧埌鍏抽敭瀛楋紝鎻愬彇鏂囦欢鍚�
+ const parts = filePath.split("\\");
+ const fileName = parts[parts.length - 1];
+ filePath = "/temp/uploads/" + fileName;
+ }
+ }
+
+ // 纭繚璺緞浠� / 寮�澶�
+ if (filePath && !filePath.startsWith("/")) {
+ filePath = "/" + filePath;
+ }
+
+ return filePath;
+};
+
+// 涓婁紶鎴愬姛
+const handleUploadSuccess = (res, file) => {
+ if (res.code === 200) {
+ // 浠� res.data 涓幏鍙� tempPath锛屽苟杞崲涓哄彲璁块棶鐨� URL
+ const tempPath = res.data?.tempPath || res.tempPath;
+ if (tempPath) {
+ const relativePath = processFileUrl(tempPath);
+ modelForm.value.url = relativePath;
+ proxy.$modal.msgSuccess("涓婁紶鎴愬姛");
+ // 瑙﹀彂琛ㄥ崟楠岃瘉
+ nextTick(() => {
+ proxy.$refs.modelFormRef?.validateField("url");
+ });
+ } else {
+ proxy.$modal.msgError("涓婁紶鎴愬姛浣嗘湭杩斿洖鏂囦欢璺緞");
+ }
+ } else {
+ proxy.$modal.msgError(res.msg || "涓婁紶澶辫触");
+ }
+};
+
+// 涓婁紶澶辫触
+const handleUploadError = () => {
+ proxy.$modal.msgError("涓婁紶澶辫触锛岃閲嶈瘯");
+};
+
+// 璁$畻鎬讳环
+const calculateTotalPrice = () => {
+ // 濡傛灉闇�瑕佽绠楁�讳环锛屽彲浠ュ湪杩欓噷娣诲姞閫昏緫
+ // if (modelForm.value.boxNum && modelForm.value.taxInclusiveUnitPrice) {
+ // modelForm.value.totalPrice = modelForm.value.boxNum * modelForm.value.taxInclusiveUnitPrice;
+ // }
+};
+
+// 棰勮鍥剧墖
+const previewImage = (url) => {
+ if (url) {
+ window.open(javaApiUrl + url, "_blank");
+ }
+};
+// 鍒犻櫎瑙勬牸鍨嬪彿
+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(() => {
+ tableLoading.value = true;
+ delProductModel(ids)
+ .then((res) => {
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ getModelList();
+ })
+ .finally(() => {
+ tableLoading.value = false;
+ });
+ })
+ .catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
+};
// 璋冪敤tree杩囨护鏂规硶 涓枃鑻辫繃婊�
const filterNode = (value, data, node) => {
- if (!value) {銆�銆�銆�銆�//濡傛灉鏁版嵁涓虹┖锛屽垯杩斿洖true,鏄剧ず鎵�鏈夌殑鏁版嵁椤�
- return true
+ if (!value) {
+ //濡傛灉鏁版嵁涓虹┖锛屽垯杩斿洖true,鏄剧ず鎵�鏈夌殑鏁版嵁椤�
+ return true;
}
// 鏌ヨ鍒楄〃鏄惁鏈夊尮閰嶆暟鎹紝灏嗗�煎皬鍐欙紝鍖归厤鑻辨枃鏁版嵁
- let val = value.toLowerCase()
- return chooseNode(val, data, node) // 璋冪敤杩囨护浜屽眰鏂规硶
-}
+ let val = value.toLowerCase();
+ return chooseNode(val, data, node); // 璋冪敤杩囨护浜屽眰鏂规硶
+};
// 杩囨护鐖惰妭鐐� / 瀛愯妭鐐� (濡傛灉杈撳叆鐨勫弬鏁版槸鐖惰妭鐐逛笖鑳藉尮閰嶏紝鍒欒繑鍥炶鑺傜偣浠ュ強鍏朵笅鐨勬墍鏈夊瓙鑺傜偣锛涘鏋滃弬鏁版槸瀛愯妭鐐癸紝鍒欒繑鍥炶鑺傜偣鐨勭埗鑺傜偣銆俷ame鏄腑鏂囧瓧绗︼紝enName鏄嫳鏂囧瓧绗�.
const chooseNode = (value, data, node) => {
if (data.label.indexOf(value) !== -1) {
- return true
+ return true;
}
- const level = node.level
+ const level = node.level;
// 濡傛灉浼犲叆鐨勮妭鐐规湰韬氨鏄竴绾ц妭鐐瑰氨涓嶇敤鏍¢獙浜�
if (level === 1) {
- return false
+ return false;
}
// 鍏堝彇褰撳墠鑺傜偣鐨勭埗鑺傜偣
- let parentData = node.parent
+ let parentData = node.parent;
// 閬嶅巻褰撳墠鑺傜偣鐨勭埗鑺傜偣
- let index = 0
+ let index = 0;
while (index < level - 1) {
// 濡傛灉鍖归厤鍒扮洿鎺ヨ繑鍥烇紝姝ゅname鍊兼槸涓枃瀛楃锛宔nName鏄嫳鏂囧瓧绗︺�傚垽鏂尮閰嶄腑鑻辨枃杩囨护
if (parentData.data.label.indexOf(value) !== -1) {
- return true
+ return true;
}
// 鍚﹀垯鐨勮瘽鍐嶅線涓婁竴灞傚仛鍖归厤
- parentData = parentData.parent
- index++
+ parentData = parentData.parent;
+ index++;
}
// 娌″尮閰嶅埌杩斿洖false
- return false
-}
-getProductTreeList()
+ return false;
+};
+getProductTreeList();
</script>
<style scoped>
@@ -240,22 +713,114 @@
display: flex;
}
.left {
- width: 380px;
+ width: 450px;
+ min-width: 450px;
padding: 16px;
background: #ffffff;
}
.right {
- width: calc(100% - 380px);
+ flex: 1;
+ min-width: 0;
padding: 16px;
margin-left: 20px;
background: #ffffff;
}
.custom-tree-node {
flex: 1;
+ min-width: 0;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding-right: 8px;
}
-</style>
\ No newline at end of file
+.tree-node-content {
+ flex: 1;
+ min-width: 0;
+ display: flex;
+ align-items: center;
+ height: 100%;
+ overflow: hidden;
+}
+.tree-node-content .orange-icon {
+ flex-shrink: 0;
+}
+.tree-node-label {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+.orange-icon {
+ color: orange;
+ font-size: 18px;
+ margin-right: 8px; /* 鍥炬爣涓庢枃瀛椾箣闂村姞鐐归棿璺� */
+}
+.product-tree-scroll {
+ scrollbar-width: thin;
+ scrollbar-color: #c0c4cc #f5f7fa;
+}
+.product-tree-scroll::-webkit-scrollbar {
+ width: 8px;
+}
+.product-tree-scroll::-webkit-scrollbar-track {
+ background: #f5f7fa;
+ border-radius: 4px;
+}
+.product-tree-scroll::-webkit-scrollbar-thumb {
+ background: #c0c4cc;
+ border-radius: 4px;
+}
+.product-tree-scroll::-webkit-scrollbar-thumb:hover {
+ background: #909399;
+}
+
+.upload-img {
+ width: 50px;
+ height: 50px;
+ object-fit: cover;
+ cursor: pointer;
+ border-radius: 4px;
+}
+
+.avatar-uploader-icon {
+ font-size: 28px;
+ color: #8c939d;
+ width: 50px;
+ height: 50px;
+ line-height: 50px;
+ text-align: center;
+ border: 1px dashed #d9d9d9;
+ border-radius: 4px;
+ cursor: pointer;
+}
+
+.avatar-uploader-icon:hover {
+ border-color: #409eff;
+}
+
+.upload-img-dialog {
+ width: 100px;
+ height: 100px;
+ object-fit: cover;
+ cursor: pointer;
+ border-radius: 4px;
+ border: 1px solid #dcdfe6;
+}
+
+.avatar-uploader-icon-dialog {
+ font-size: 28px;
+ color: #8c939d;
+ width: 100px;
+ height: 100px;
+ line-height: 100px;
+ text-align: center;
+ border: 1px dashed #d9d9d9;
+ border-radius: 4px;
+ cursor: pointer;
+ display: block;
+}
+
+.avatar-uploader-icon-dialog:hover {
+ border-color: #409eff;
+}
+</style>
--
Gitblit v1.9.3