From ddc15b8f31c2d84d791b561fd24f3817c7ab81da Mon Sep 17 00:00:00 2001 From: spring <2396852758@qq.com> Date: 星期三, 02 四月 2025 10:24:48 +0800 Subject: [PATCH] 批量复制功能修改 --- src/views/standard/standardLibrary/components/BatchCopy.vue | 494 +++++++++++------------------------------------------- 1 files changed, 105 insertions(+), 389 deletions(-) diff --git a/src/views/standard/standardLibrary/components/BatchCopy.vue b/src/views/standard/standardLibrary/components/BatchCopy.vue index 7ea84b4..4d26f90 100644 --- a/src/views/standard/standardLibrary/components/BatchCopy.vue +++ b/src/views/standard/standardLibrary/components/BatchCopy.vue @@ -1,243 +1,94 @@ <template> <div> - <el-dialog - :visible.sync="batchCopyDia" - class="more-edit" - title="鎵归噺缂栬緫" - width="90%" - > + <el-dialog :visible.sync="batchCopyDia" class="more-edit" title="鎵归噺缂栬緫" width="90%"> <el-row> <el-col :span="6" class="search_thing"> <div class="search_label">鏍峰搧鍚嶇О锛�</div> <div class="search_input"> <el-input v-model="sample" disabled size="small"> - <template slot="append" - ><el-button - slot="append" - icon="el-icon-search" - @click="selectStandardTree = true" - ></el-button - ></template> + <template slot="append"><el-button slot="append" icon="el-icon-search" + @click="selectStandardTree = true"></el-button></template> </el-input> </div> </el-col> <el-col :span="6" class="search_thing"> <div class="search_label">妫�楠屾爣鍑嗭細</div> <div class="search_input"> - <el-select - v-model="standardMethodListId" - :loading="methodLoad" - clearable - placeholder="璇疯緭鍏�" - size="small" - @change="changeStandardMethodListId" - @focus="methodFocus" - > - <el-option - v-for="item in methods" - :key="item.id" - :label="item.code" - :value="item.id" - > + <el-select v-model="standardMethodListId" :loading="methodLoad" clearable placeholder="璇疯緭鍏�" size="small" + @change="changeStandardMethodListId" @focus="methodFocus"> + <el-option v-for="item in methods" :key="item.id" :label="item.code" :value="item.id"> </el-option> </el-select> </div> </el-col> <el-col :span="12" style="text-align: right"> - <el-button size="small" type="primary" @click="sortCopy" - >鎺掑簭澶嶅埗</el-button - > - <el-button size="small" type="primary" @click="compareAlone" - >鍗曠嫭瀵规瘮</el-button - > - <el-button size="small" type="primary" @click="compare" - >澶嶅埗</el-button - > + <el-button size="small" type="primary" @click="sortCopy">鎺掑簭澶嶅埗</el-button> + <el-button size="small" type="primary" @click="compareAlone">鍗曠嫭瀵规瘮</el-button> + <el-button size="small" type="primary" @click="compare">澶嶅埗</el-button> </el-col> </el-row> - <div - class="body" - style="display: flex; flex-direction: row; height: 80vh" - > + <div class="body" style="display: flex; flex-direction: row; height: 80vh"> <div v-loading="productTableLoading1" style="width: 50%"> <div>闇�瑕佸鍒剁殑妫�楠岄」</div> - <el-table - ref="productTable1" - :data="productList1" - :fit="true" - :row-key="(row) => row.id" - border - header-row-class-name="header-class" - height="90%" - highlight-current-row - stripe - style="width: 98%" - tooltip-effect="dark" - @select="handleSelectionChange1" - @select-all="handleSelectAll1" - > + <el-table ref="productTable1" :data="productList1" :fit="true" :row-key="(row) => row.id" border + header-row-class-name="header-class" height="90%" highlight-current-row stripe style="width: 98%" + tooltip-effect="dark" @select="handleSelectionChange1" @select-all="handleSelectAll1"> <el-table-column type="selection" width="50"> </el-table-column> - <el-table-column - label="浜у搧" - min-width="100" - prop="sample" - show-overflow-tooltip - ></el-table-column> - <el-table-column - label="鍨嬪彿" - min-width="100" - prop="model" - show-overflow-tooltip - ></el-table-column> - <el-table-column - label="妫�楠岄」鍒嗙被" - min-width="140" - prop="inspectionItemClass" - show-overflow-tooltip - ></el-table-column> - <el-table-column - column-key="inspectionItem" - label="妫�楠岄」" - min-width="140" - prop="inspectionItem" - show-overflow-tooltip - ></el-table-column> - <el-table-column - column-key="inspectionItemSubclass" - label="妫�楠岄」瀛愰」" - min-width="140" - prop="inspectionItemSubclass" - show-overflow-tooltip - ></el-table-column> - <el-table-column - label="瑕佹眰鍊�" - min-width="200px" - prop="ask" - ></el-table-column> - <el-table-column - label="瑕佹眰鎻忚堪" - min-width="220px" - prop="tell" - ></el-table-column> + <el-table-column label="浜у搧" min-width="100" prop="sample" show-overflow-tooltip></el-table-column> + <el-table-column label="鍨嬪彿" min-width="100" prop="model" show-overflow-tooltip></el-table-column> + <el-table-column label="妫�楠岄」鍒嗙被" min-width="140" prop="inspectionItemClass" + show-overflow-tooltip></el-table-column> + <el-table-column column-key="inspectionItem" label="妫�楠岄」" min-width="140" prop="inspectionItem" + show-overflow-tooltip></el-table-column> + <el-table-column column-key="inspectionItemSubclass" label="妫�楠岄」瀛愰」" min-width="140" + prop="inspectionItemSubclass" show-overflow-tooltip></el-table-column> + <el-table-column label="瑕佹眰鍊�" min-width="200px" prop="ask"></el-table-column> + <el-table-column label="瑕佹眰鎻忚堪" min-width="220px" prop="tell"></el-table-column> </el-table> </div> <div v-loading="productTableLoading0" style="width: 50%"> <div>褰撳墠妫�楠岄」</div> - <el-table - ref="productTable0" - :data="productList0" - :fit="true" - :row-key="(row) => row.id" - border - header-row-class-name="header-class" - height="90%" - highlight-current-row - stripe - style="width: 98%" - tooltip-effect="dark" - @select="handleSelectionChange0" - @select-all="handleSelectAll0" - > + <el-table ref="productTable0" :data="productList0" :fit="true" :row-key="(row) => row.id" border + header-row-class-name="header-class" height="90%" highlight-current-row stripe style="width: 98%" + tooltip-effect="dark" @select="handleSelectionChange0" @select-all="handleSelectAll0"> <el-table-column type="selection" width="50"> </el-table-column> - <el-table-column - label="浜у搧" - min-width="100" - prop="sample" - show-overflow-tooltip - ></el-table-column> - <el-table-column - label="鍨嬪彿" - min-width="100" - prop="model" - show-overflow-tooltip - ></el-table-column> - <el-table-column - label="妫�楠岄」鍒嗙被" - min-width="140" - prop="inspectionItemClass" - show-overflow-tooltip - ></el-table-column> - <el-table-column - column-key="inspectionItem" - label="妫�楠岄」" - min-width="140" - prop="inspectionItem" - show-overflow-tooltip - ></el-table-column> - <el-table-column - column-key="inspectionItemSubclass" - label="妫�楠岄」瀛愰」" - min-width="140" - prop="inspectionItemSubclass" - show-overflow-tooltip - ></el-table-column> - <el-table-column - label="瑕佹眰鍊�" - min-width="200px" - prop="ask" - ></el-table-column> - <el-table-column - label="瑕佹眰鎻忚堪" - min-width="220px" - prop="tell" - ></el-table-column> + <el-table-column label="浜у搧" min-width="100" prop="sample" show-overflow-tooltip></el-table-column> + <el-table-column label="鍨嬪彿" min-width="100" prop="model" show-overflow-tooltip></el-table-column> + <el-table-column label="妫�楠岄」鍒嗙被" min-width="140" prop="inspectionItemClass" + show-overflow-tooltip></el-table-column> + <el-table-column column-key="inspectionItem" label="妫�楠岄」" min-width="140" prop="inspectionItem" + show-overflow-tooltip></el-table-column> + <el-table-column column-key="inspectionItemSubclass" label="妫�楠岄」瀛愰」" min-width="140" + prop="inspectionItemSubclass" show-overflow-tooltip></el-table-column> + <el-table-column label="瑕佹眰鍊�" min-width="200px" prop="ask"></el-table-column> + <el-table-column label="瑕佹眰鎻忚堪" min-width="220px" prop="tell"></el-table-column> </el-table> </div> </div> </el-dialog> - <el-dialog - :visible.sync="selectStandardTree" - title="閫夋嫨鏍峰搧" - width="500px" - > - <div - v-if="selectStandardTree" - v-loading="selectStandardTreeLoading" - class="body" - style="height: 60vh; overflow-y: auto; user-select: none" - > + <el-dialog :visible.sync="selectStandardTree" title="閫夋嫨鏍峰搧" width="500px"> + <div v-if="selectStandardTree" v-loading="selectStandardTreeLoading" class="body" + style="height: 60vh; overflow-y: auto; user-select: none"> <el-row> <el-col :span="24"> - <el-input - v-model="search" - clearable - placeholder="杈撳叆鍏抽敭瀛楄繘琛屾悳绱�" - size="small" - style="margin-bottom: 5px" - suffix-icon="el-icon-search" - @blur="searchFilter" - @clear="searchFilter" - @keyup.enter.native="searchFilter" - ></el-input> + <el-input v-model="search" clearable placeholder="杈撳叆鍏抽敭瀛楄繘琛屾悳绱�" size="small" style="margin-bottom: 5px" + suffix-icon="el-icon-search" @blur="searchFilter" @clear="searchFilter" + @keyup.enter.native="searchFilter"></el-input> </el-col> </el-row> - <el-tree - ref="tree" - :data="list" - :default-expanded-keys="expandedKeys" - :filter-node-method="filterNode" - :props="{ children: 'children', label: 'label' }" - highlight-current - node-key="label" - @node-click="handleNodeClick" - @node-expand="nodeOpen" - @node-collapse="nodeClose" - > + <el-tree ref="tree" :data="list" :default-expanded-keys="expandedKeys" :filter-node-method="filterNode" + :props="{ children: 'children', label: 'label' }" highlight-current node-key="label" + @node-click="handleNodeClick" @node-expand="nodeOpen" @node-collapse="nodeClose"> <div slot-scope="{ node, data }" class="custom-tree-node"> <el-row> <el-col :span="24"> - <span - ><i - :class="`node_i ${ - data.children != undefined - ? data.code === '[1]' - ? 'el-icon-folder-opened' - : 'el-icon-folder' - : 'el-icon-tickets' - }`" - ></i> - {{ data.code }} {{ data.label }}</span - > + <span><i :class="`node_i ${data.children != undefined + ? data.code === '[1]' + ? 'el-icon-folder-opened' + : 'el-icon-folder' + : 'el-icon-tickets' + }`"></i> + {{ data.code }} {{ data.label }}</span> </el-col> </el-row> </div> @@ -250,196 +101,91 @@ </el-dialog> <el-dialog :visible.sync="compareDia" title="纭澶嶅埗淇℃伅" width="80%"> <div style="width: 100%"> - <el-table - ref="compareList" - :data="compareList" - :fit="true" - :row-key="(row) => row.id" - border - header-row-class-name="header-class" - height="90%" - highlight-current-row - stripe - style="width: 98%" - tooltip-effect="dark" - > - <el-table-column - label="浜у搧" - min-width="100" - prop="sample" - show-overflow-tooltip - ></el-table-column> - <el-table-column - label="鍨嬪彿" - min-width="100" - prop="model" - show-overflow-tooltip - ></el-table-column> - <el-table-column - label="妫�楠岄」鍒嗙被" - min-width="140" - prop="inspectionItemClass" - show-overflow-tooltip - ></el-table-column> - <el-table-column - column-key="inspectionItem" - label="妫�楠岄」" - min-width="140" - prop="inspectionItem" - show-overflow-tooltip - ></el-table-column> - <el-table-column - column-key="inspectionItemSubclass" - label="妫�楠岄」瀛愰」" - min-width="140" - prop="inspectionItemSubclass" - show-overflow-tooltip - ></el-table-column> + <el-table ref="compareList" :data="compareList" :fit="true" :row-key="(row) => row.id" border + header-row-class-name="header-class" height="90%" highlight-current-row stripe style="width: 98%" + tooltip-effect="dark"> + <el-table-column label="浜у搧" min-width="100" prop="sample" show-overflow-tooltip></el-table-column> + <el-table-column label="鍨嬪彿" min-width="100" prop="model" show-overflow-tooltip></el-table-column> + <el-table-column label="妫�楠岄」鍒嗙被" min-width="140" prop="inspectionItemClass" + show-overflow-tooltip></el-table-column> + <el-table-column column-key="inspectionItem" label="妫�楠岄」" min-width="140" prop="inspectionItem" + show-overflow-tooltip></el-table-column> + <el-table-column column-key="inspectionItemSubclass" label="妫�楠岄」瀛愰」" min-width="140" + prop="inspectionItemSubclass" show-overflow-tooltip></el-table-column> <el-table-column label="瑕佹眰鍊�" min-width="200px" prop="ask"> <template slot-scope="scope"> - <el-input - v-model="scope.row.ask" - :autosize="{ minRows: 1, maxRows: 3 }" - clearable - placeholder="瑕佹眰鍊�" - size="small" - type="textarea" - ></el-input> + <el-input v-model="scope.row.ask" :autosize="{ minRows: 1, maxRows: 3 }" clearable placeholder="瑕佹眰鍊�" + size="small" type="textarea"></el-input> </template> </el-table-column> <el-table-column label="瑕佹眰鎻忚堪" min-width="220px" prop="tell"> <template slot-scope="scope"> - <el-input - v-model="scope.row.tell" - :autosize="{ minRows: 1, maxRows: 3 }" - clearable - placeholder="瑕佹眰鎻忚堪" - size="small" - type="textarea" - ></el-input> + <el-input v-model="scope.row.tell" :autosize="{ minRows: 1, maxRows: 3 }" clearable placeholder="瑕佹眰鎻忚堪" + size="small" type="textarea"></el-input> </template> </el-table-column> <el-table-column label="鎿嶄綔" prop="section" width="160"> <template slot-scope="scope"> - <el-button type="text" @click="sectionUp(scope.row)" - >鍖洪棿璁剧疆</el-button - > + <el-button type="text" @click="sectionUp(scope.row)">鍖洪棿璁剧疆</el-button> </template> </el-table-column> </el-table> <span slot="footer" class="dialog-footer"> <el-button size="small" @click="compareDia = false">鍙� 娑�</el-button> - <el-button - :loading="handleCompareLoading" - size="small" - type="primary" - @click="handleCompare" - >纭� 瀹�</el-button - > + <el-button :loading="handleCompareLoading" size="small" type="primary" @click="handleCompare">纭� 瀹�</el-button> </span> </div> </el-dialog> - <el-dialog - :close-on-click-modal="false" - :visible.sync="sectionUpDia" - title="鍖洪棿璁剧疆" - width="80%" - > + <el-dialog :close-on-click-modal="false" :visible.sync="sectionUpDia" title="鍖洪棿璁剧疆" width="80%"> <div class="body" style="padding: 5px 0"> <el-table :data="sectionList" border height="350px" style="width: 100%"> <el-table-column align="center" label="搴忓彿" type="index" width="70"> </el-table-column> <el-table-column align="center" label="鍖洪棿"> <template slot-scope="scope"> - <el-input - v-model="scope.row.thing" - clearable - placeholder="鍖洪棿" - size="small" - ></el-input> + <el-input v-model="scope.row.thing" clearable placeholder="鍖洪棿" size="small"></el-input> </template> </el-table-column> <el-table-column align="center" label="鑺暟"> <template slot-scope="scope"> - <el-input - v-model="scope.row.cores" - clearable - placeholder="鑺暟" - size="small" - ></el-input> + <el-input v-model="scope.row.cores" clearable placeholder="鑺暟" size="small"></el-input> </template> </el-table-column> <el-table-column align="center" label="瑕佹眰鍊�"> <template slot-scope="scope"> - <el-input - v-model="scope.row.ask" - clearable - placeholder="瑕佹眰鍊�" - size="small" - ></el-input> + <el-input v-model="scope.row.ask" clearable placeholder="瑕佹眰鍊�" size="small"></el-input> </template> </el-table-column> <el-table-column align="center" label="瑕佹眰鎻忚堪"> <template slot-scope="scope"> - <el-input - v-model="scope.row.tell" - :autosize="{ minRows: 1, maxRows: 2 }" - clearable - placeholder="瑕佹眰鎻忚堪" - size="small" - type="textarea" - ></el-input> + <el-input v-model="scope.row.tell" :autosize="{ minRows: 1, maxRows: 2 }" clearable placeholder="瑕佹眰鎻忚堪" + size="small" type="textarea"></el-input> </template> </el-table-column> <el-table-column align="center" label="瀵间綋鏉愯川"> <template slot-scope="scope"> - <el-input - v-model="scope.row.conductorMaterial" - clearable - placeholder="瀵间綋鏉愯川" - size="small" - ></el-input> + <el-input v-model="scope.row.conductorMaterial" clearable placeholder="瀵间綋鏉愯川" size="small"></el-input> </template> </el-table-column> <el-table-column align="center" label="瀵间綋绫诲瀷"> <template slot-scope="scope"> - <el-input - v-model="scope.row.conductorType" - clearable - placeholder="瀵间綋绫诲瀷" - size="small" - ></el-input> + <el-input v-model="scope.row.conductorType" clearable placeholder="瀵间綋绫诲瀷" size="small"></el-input> </template> </el-table-column> <el-table-column align="center" label="鍗曚环" width="120"> <template slot-scope="scope"> - <el-input - v-model="scope.row.price" - clearable - placeholder="鍗曚环" - size="small" - ></el-input> + <el-input v-model="scope.row.price" clearable placeholder="鍗曚环" size="small"></el-input> </template> </el-table-column> <el-table-column align="center" label="宸ユ椂绯绘暟" width="120"> <template slot-scope="scope"> - <el-input - v-model="scope.row.manHour" - clearable - placeholder="宸ユ椂绯绘暟" - size="small" - ></el-input> + <el-input v-model="scope.row.manHour" clearable placeholder="宸ユ椂绯绘暟" size="small"></el-input> </template> </el-table-column> <el-table-column align="center" label="鎿嶄綔" width="70"> <template slot-scope="scope"> - <el-button - circle - icon="el-icon-minus" - size="mini" - type="danger" - @click="sectionList.splice(scope.$index, 1)" - ></el-button> + <el-button circle icon="el-icon-minus" size="mini" type="danger" + @click="sectionList.splice(scope.$index, 1)"></el-button> </template> </el-table-column> </el-table> @@ -447,11 +193,8 @@ <span slot="footer" class="dialog-footer"> <el-button @click="sectionUpDia = false">鍙� 娑�</el-button> <el-button type="primary" @click="sectionLoadAdd">淇� 瀛�</el-button> - <el-button - icon="el-icon-plus" - type="primary" - @click="sectionList.push({ thing: '', price: '', manHour: '' })" - ></el-button> + <el-button icon="el-icon-plus" type="primary" + @click="sectionList.push({ thing: '', price: '', manHour: '' })"></el-button> </span> </el-dialog> </div> @@ -695,38 +438,27 @@ // 閫夋嫨鏍峰搧鍚嶇О鐨勫洖璋� handleNodeClick(val, node, el) { this.selectTree = ""; - this.getNodeParent(node); - let flag = false; - if (node.level == 3) { - if (node.data.children.length > 0) { - node.data.children.forEach((a) => { - let key = Object.keys(a); - if (!key.includes("level")) { - flag = true; - } - }); - } - } - this.selectTree = this.selectTree.replace(" - ", ""); - if (flag) { - this.selectTree = " - - " + this.selectTree; - } - let data = this.selectTree.split(" - "); - let data2 = ""; - for (let index = data.length - 1; index >= 0; index--) { - data2 += " - " + data[index]; - } - this.selectTree = data2.replace(" - ", ""); + this.selectTree = this.getReversedTreePath(node); }, - getNodeParent(val) { - if (val.parent != null) { - if (val.data.children === null) { - this.selectTree += " - " + val.label + " - " + "null"; - } else { - this.selectTree += " - " + val.label; + /** + * 鑾峰彇鍙嶅悜鎷兼帴鐨勬爲璺緞瀛楃涓� + * @param {Object} node - 褰撳墠鑺傜偣 + * @returns {string} - 鍙嶅悜鎷兼帴鐨勬爲璺緞 + */ + getReversedTreePath(node) { + const pathParts = []; + // 閫掑綊鑾峰彇鐖惰妭鐐硅矾寰� + const collectParentLabels = (currentNode) => { + if (currentNode && currentNode.label) { + pathParts.unshift(currentNode.label); // 灏嗗綋鍓嶈妭鐐规爣绛炬彃鍏ュ埌鏁扮粍寮�澶� } - this.getNodeParent(val.parent); - } + if (currentNode.parent) { + collectParentLabels(currentNode.parent); // 閫掑綊澶勭悊鐖惰妭鐐� + } + }; + collectParentLabels(node); + // 鎷兼帴璺緞骞惰繑鍥� + return pathParts.join(" - "); }, changeStandardMethodListId() { // 鏍规嵁妫�楠屾爣鍑嗘煡鍙宠竟table鏁版嵁 @@ -753,25 +485,7 @@ tree: this.selectTree, }).then((res) => { this.methodLoad = false; - try { - if ( - res.data.standardMethodList.length == 0 && - this.selectTree.split("-").length == 5 - ) { - let arr = this.selectTree.split("-"); - let arr0 = arr.slice(0, arr.length - 1); - let selectTree = arr0 - .join("-") - .substring(0, arr0.join("-").length - 1); - selectsStandardMethodByFLSSM({ - tree: selectTree, - }).then((ress) => { - this.methods = ress.data.standardMethodList; - }); - } else { - this.methods = res.data.standardMethodList; - } - } catch (e) {} + this.methods = res.data.standardMethodList; }); }, activeStandardTree() { @@ -846,10 +560,12 @@ .search_input { width: calc(100% - 80px); } + .node_i { color: orange; font-size: 18px; } + .dialog-footer { display: flex; justify-content: flex-end; -- Gitblit v1.9.3