From e09b848b65d7fda7264e9e536e37ad8e45f65e9c Mon Sep 17 00:00:00 2001
From: Fixiaobai <fixiaobai@163.com>
Date: 星期三, 06 九月 2023 17:42:47 +0800
Subject: [PATCH] 	modified:   src/views/inspectionManagement/commissionInspection/index.vue 	modified:   src/views/standardLibrary/index.vue

---
 src/views/standardLibrary/index.vue |  179 ++++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 126 insertions(+), 53 deletions(-)

diff --git a/src/views/standardLibrary/index.vue b/src/views/standardLibrary/index.vue
index 9dea403..5cbf919 100644
--- a/src/views/standardLibrary/index.vue
+++ b/src/views/standardLibrary/index.vue
@@ -2,23 +2,30 @@
 	<div class="standard-library-main">
 		<div class="content-main">
 			<div class="library-bom" style="width: 300px">
-				<el-input v-model="filterText" placeholder="杈撳叆鍏抽敭瀛楄繘琛岃繃婊�"></el-input>
-				<el-button type="text">鍏ㄩ儴</el-button>
+				<el-row :gutter="10">
+					<el-col :span="19">
+					<el-input size="small" clearable v-model="filterText" placeholder="杈撳叆鍏抽敭瀛楄繘琛岃繃婊�"></el-input>
+					</el-col>
+					<el-col :span="5">
+						<el-button size="small" type="primary" icon="el-icon-plus" @click="addTreeFormVisible = true"></el-button>
+					</el-col>
+				</el-row>
+				<el-button size="small" type="text">鍏ㄩ儴</el-button>
 				<el-tree ref="tree" style="width: 100%" class="filter-tree" :data="standardTree" :props="defaultProps"
-					node-key="id" highlight-current default-expand-all :filter-node-method="filterNode"
+					node-key="id" :highlight-current="true" :default-expand-all="true" :filter-node-method="filterNode"
 					:render-content="renderContent" @node-click="nodeClick" />
 			</div>
 			<div class="library-table" style="width: 80%">
 				<div class="table-header">
 					<div class="serve-btn">
 						<span class="tipMsg">{{ msg !== "" ? msg : "" }}</span>
-						<el-select v-model="versionValue" @change="changeSelect" placeholder="璇烽�夋嫨鐗堟湰鍙�">
+						<el-select size="small" v-model="versionValue" @change="changeSelect" placeholder="璇烽�夋嫨鐗堟湰鍙�">
 							<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
 							</el-option>
 						</el-select>
-						<el-button type="primary" @click="addVersionFun">鏂板鐗堟湰鍙�</el-button>
-						<el-button type="primary" icon="el-icon-plus" @click="addTreeFormVisible = true">鏂板</el-button>
-						<el-button class="top_div_button" icon="el-icon-delete-solid" style="color: #00a5ff"
+						<el-button size="small" type="primary" @click="addVersionFun">鏂板鐗堟湰鍙�</el-button>
+						<el-button size="small" type="primary" @click="centerDialogVisible = true">鏂板椤圭洰</el-button>
+						<el-button size="small" class="top_div_button" icon="el-icon-delete-solid" style="color: #00a5ff"
 							@click="deleteListClick">鍒犻櫎</el-button>
 					</div>
 				</div>
@@ -83,6 +90,33 @@
 				<el-button @click="clear">鍙� 娑�</el-button>
 			</div>
 		</el-dialog>
+		<el-dialog :visible.sync="centerDialogVisible" width="30%" title="鏂板" :hide-required-asterisk="false">
+			<el-form :model="form" :rules="rules" ref="ruleForm" class="addForm">
+				<el-form-item prop="father">
+					<span>椤圭洰鍒嗙粍锛�</span>
+					<el-autocomplete class="inline-input" v-model="form.father" :fetch-suggestions="querySearch"
+						placeholder="璇疯緭鍏ユ牱鍝佸垎缁�" style="width: calc(100% - 70px);"></el-autocomplete>
+				</el-form-item>
+				<el-row :gutter="24">
+					<el-col :span="12">
+						<el-form-item prop="name">
+							<span>椤圭洰鍚嶇О锛�</span>
+							<el-input style="width: calc(100% - 70px);" v-model="form.name" placeholder="璇疯緭鍏ラ」鐩悕绉�"></el-input>
+						</el-form-item>
+					</el-col>
+					<el-col :span="12">
+						<el-form-item prop="unit">
+							<span v-html="'鍗�&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;浣嶏細'"></span>
+							<el-input style="width: calc(100% - 70px);" v-model="form.unit" placeholder="璇疯緭鍏ュ崟浣�"></el-input>
+						</el-form-item>
+					</el-col>
+				</el-row>
+			</el-form>
+			<span slot="footer" class="dialog-footer">
+				<el-button @click="centerDialogVisible = false" size="small ">鍙� 娑�</el-button>
+				<el-button type="primary" @click="submitAdd" size="small ">纭</el-button>
+			</span>
+		</el-dialog>
 	</div>
 </template>
 
@@ -97,17 +131,33 @@
 		blurUpdateApi,
 		getVersion,
 		addVersion,
+		addProduct
 	} from "@/api/standardLibrary";
-
 	import {
-		selectproductModelApi
+		addStandardProjectGroupApi,
 	} from "@/api/basicData/index";
-	import {
-		Tree
-	} from "element-ui";
 	export default {
 		data() {
 			return {
+				projectGroupingOptions:[],
+				form: {
+					father: "", // 椤圭洰鍒嗙粍
+					name: "", // 椤圭洰鍚嶇О
+					unit: "", // 鍗曚綅
+				},
+				rules: {
+					fater:[{required:true,message:"璇烽�夋嫨椤圭洰鍚嶇О",trigger:"blur"}],
+					name: [
+						{required: true,message: "璇疯緭鍏ラ」鐩悕绉�",trigger: "blur"},
+						{min: 2,max: 25,message: "闀垮害鍦� 2 鍒� 25 涓瓧绗�",trigger: "blur",},
+					],
+					unit: [
+						{required: true,message: "璇疯緭鍏ュ崟浣�",trigger: "blur"},
+						{min: 1,max: 25,message: "闀垮害鍦� 1 鍒� 25 涓瓧绗�",trigger: "blur"}
+					],
+				},
+				centerDialogVisible : false,
+				filterNodeData: [],
 				options: [],
 				versionValue: "",
 				deleteList: [],
@@ -131,19 +181,59 @@
 				formTypeOptions: [],
 				addTreeForm: {
 					addTypeArr: [],
+					specificationsName: "",
+					materialName: "",
+					standardName: "",
 				}
 			};
 		},
 		watch: {
 			filterText(val) {
 				this.$refs.tree.filter(val);
-			}
+			},
+			addTreeFormVisible(newVal){
+				if(newVal === false){
+					this.clear();
+				}
+			},
+			centerDialogVisible: {
+				handler(newVal, oldVal) {
+					if (newVal == true) {
+						addStandardProjectGroupApi().then((res) => {
+							this.projectGroupingOptions = res.data;
+						});
+					} else {
+						// 璇锋眰鎴愬姛娓呴櫎鏁版嵁
+						this.form = {};
+						// 鎻愪氦鎴愬姛娓呴櫎妫�楠�
+						this.$refs.ruleForm.resetFields();
+					}
+				},
+			},
 		},
 		created() {
 			this.getStandardTree();
 		},
-		mounted() {},
+		mounted() {
+
+		},
 		methods: {
+			querySearch(queryString, cb) {
+				var restaurants = []
+				this.projectGroupingOptions.forEach(a => {
+					restaurants.push({
+						value: a
+					})
+				})
+				var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
+				// 璋冪敤 callback 杩斿洖寤鸿鍒楄〃鐨勬暟鎹�
+				cb(results);
+			},
+			createFilter(queryString) {
+				return (restaurant) => {
+					return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
+				};
+			},
 			clear(){
 				this.addTreeFormVisible = false;
 				this.addTreeForm.addTypeArr=[];
@@ -152,9 +242,6 @@
 				this.addTreeForm.standardName=''
 			},
 			changeSample(){
-				// console.log(this.standardTree);
-				// console.log(this.addTreeForm);
-				// console.log(this.addTreeForm.addTypeArr.length);
 				let selectType=this.standardTree.filter(item=>{
 					return item.id===this.addTreeForm.addTypeArr[0]
 				})[0];
@@ -200,6 +287,22 @@
 				this.tableData = [];
 				this.getTableByClick(this.selectData, this.versionValue);
 			},
+			async submitAdd(){
+				await addProduct({
+					father : this.form.father,
+					name : this.form.name,
+					specificationId: this.selectData.id,
+					unit : this.form.unit,
+					version : this.versionValue
+				}).then(res=>{
+					console.log(res);
+					this.$message.success(res.message);
+					this.centerDialogVisible = false;
+					this.getTableByClick(this.selectData, this.versionValue);
+				}).catch(error=>{
+					this.$message.error(error.message);
+				})
+			},
 			async insertVersion() {
 				const resp = await addVersion({
 					specificationsId: this.selectData.id,
@@ -224,7 +327,7 @@
 					})
 					.catch(() => {});
 			},
-			filterNode(value, data) {
+			filterNode(value, data,node) {
 				if (!value) return true;
 				return data.name.indexOf(value) !== -1;
 			},
@@ -277,6 +380,7 @@
 						//TODO handle the exception
 					}
 				});
+
 			},
 			getDefault(arr, index) {
 				for (const item of arr) {
@@ -343,26 +447,10 @@
 			}) {
 				// 鍒ゆ柇鏄惁鏄埗鑺傜偣鎴栨枃浠跺す
 				const isFolder = "children" in data;
-				return ( <
-					span class = "tree-node" > {
-						isFolder ? ( <
-							i class = {
-								node.expanded ?
-								"el-icon-folder-opened blue-folder" : "el-icon-folder blue-folder"
-							} >
-							<
-							/i>
-						) : ( <
-							i class = "el-icon-document blue-folder" > < /i>
-						)
-					} <
-					div class = "tree-lable" > [{
-						node.level
-					}] {
-						data.name
-					} <
-					/div> < /
-					span >
+				return ( <span class="tree-node"> {
+						isFolder ? ( <i class = {node.expanded ?"el-icon-folder-opened blue-folder" : "el-icon-folder blue-folder"} ></i>
+						) : ( <i class = "el-icon-document blue-folder" > </i>)
+					} <div class = "tree-lable" > [{node.level}] {data.name} </div> </span>
 				);
 			},
 			async subAddTreeForm() {
@@ -414,21 +502,6 @@
 			},
 			changeCascader(data) {
 				this.addTreeForm.addTypeArr = data;
-			},
-			selectProductModelTable() {
-				selectproductModelApi(this.params).then((res) => {
-					res.data.forEach((i) => {
-						if (i.name === undefined) {
-							i.name = i.children[0].name;
-							i.unit = i.children[0].unit;
-							i.id = i.children[0].id;
-							i.edit = true;
-							delete i.children;
-						}
-					});
-					this.tableData = res.data;
-					this.selectDataList();
-				});
 			},
 			selectDataList() {
 				let i=0

--
Gitblit v1.9.3