From cf5c251714eb8574518777063afa339f95dcbda6 Mon Sep 17 00:00:00 2001
From: wwl <xchao828@163.com>
Date: 星期五, 23 五月 2025 17:10:14 +0800
Subject: [PATCH] 项目部位维护

---
 src/views/hosp/biaoben/index.vue |  413 +++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 305 insertions(+), 108 deletions(-)

diff --git a/src/views/hosp/biaoben/index.vue b/src/views/hosp/biaoben/index.vue
index aacb526..f0afc9b 100644
--- a/src/views/hosp/biaoben/index.vue
+++ b/src/views/hosp/biaoben/index.vue
@@ -1,123 +1,320 @@
 <template>
-    <div class="app-container">
-
-        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
-            <el-form-item label="椤圭洰鍚嶇О" prop="tjh">
-                <el-input v-model="queryParams.tjh" placeholder="璇疯緭鍏ラ」鐩悕绉�" clearable />
-            </el-form-item>
-            <el-form-item>
-                <el-button type="primary" size="mini" @click="handleManual">鏌ヨ</el-button>
-                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">閲嶇疆</el-button>
-            </el-form-item>
+  <div class="app-container">
+    <el-row :gutter="24">
+      <!-- 绗竴鍒楋細鍗曢�夋爣鏈� -->
+      <el-col :span="8" :xs="24">
+        <el-form
+          :model="queryParams"
+          ref="queryForm"
+          size="small"
+          :inline="true"
+          label-width="68px"
+          style="height: 45px"
+          @submit.native.prevent
+        >
+          <el-form-item label="椤圭洰鍚嶇О" prop="tjh">
+            <el-input
+              v-model="queryParams.tjh"
+              placeholder="璇疯緭鍏ラ」鐩悕绉�"
+              clearable
+              @keyup.enter.native="handleManual"
+            />
+          </el-form-item>
+          <el-form-item>
+            <el-button type="primary" size="mini" @click="handleManual">鏌ヨ</el-button>
+            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">閲嶇疆</el-button>
+          </el-form-item>
         </el-form>
-        <el-table border v-loading="loading" :data="partList" height="350">
-            <el-table-column type="selection" width="40px" align="center" />
-            <el-table-column label="搴忓彿" align="center" prop="newID" width="50px" />
-            <el-table-column label="椤圭洰鍚嶇О" align="center" prop="groupingName" />
+
+        <!-- 鏍囨湰鍗曢�夎〃鏍硷紙甯﹀閫夋鏍峰紡锛� -->
+        <el-table
+          border
+          v-loading="loading"
+          :data="filteredSpecimenData"
+          height="478"
+          style="width: 100%"
+          ref="specimenTable"
+          :row-key="row => row.value"
+          @select="handleSpecimenSelect"
+        >
+          <el-table-column type="selection" width="40px" align="center" />
+          <el-table-column label="搴忓彿" align="center" type="index" width="50px" />
+          <el-table-column label="鏍囨湰鍚嶇О" align="center" prop="label" show-overflow-tooltip />
         </el-table>
+      </el-col>
 
+      <!-- 绗簩鍒楋細涓棿閫変腑椤圭洰鍒楄〃 -->
+      <el-col :span="8" :xs="24">
+        <el-form :model="form" size="small" :inline="true" label-width="68px" style="height: 45px" @submit.native.prevent />
+        <el-table
+          border
+          v-loading="loading"
+          :data="OnenewpacName"
+          height="478"
+          style="width: 100%"
+        >
+          <el-table-column label="宸查�夐」鐩垪琛�" align="center" prop="proName" />
+          <el-table-column label="鎿嶄綔" align="center" width="85">
+            <template slot-scope="scope">
+              <el-button size="mini" type="text" icon="el-icon-delete" @click="handledbelete(scope.row)">鍒犻櫎</el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+        <div class="dialog-footer1" style="margin-top: 60px; text-align: center;">
+          <el-button type="primary" @click="submitrighr">纭骞朵繚瀛�</el-button>
+          <el-button @click="cancell">鍙� 娑�</el-button>
+        </div>
+      </el-col>
 
-        <el-dialog :title="title" :visible.sync="openOne" width="1400px" append-to-body :close-on-click-modal="false">
-            <el-row :gutter="24">
-                <el-col :span="15" :xs="24">
-                    <el-form :model="form" ref="queryForm" size="small" :inline="true" label-width="46px"
-                        style="height: 35px" @submit.native.prevent>
-                        <el-form-item label="鏍囨湰绫诲瀷">
-                            <el-input ref="inputName" v-model="form.price" placeholder="鏍囨湰绫诲瀷" clearable
-                                style="width: 140px" />
-                        </el-form-item>
-                        <el-form-item>
-                            <el-button icon="el-icon-refresh" size="mini" @click="resetQuerys">閲嶇疆</el-button>
-                        </el-form-item>
-                    </el-form>
-                    <el-table border v-loading="loading" :data="OnenewpacName" :row-class-name="tableRowClassName"
-                        height="478">
-                        <el-table-column label="鍘熶环" align="center" prop="proPrice" width="85"></el-table-column>
-                        <el-table-column label="鎿嶄綔" align="center" width="85">
-                            <template slot-scope="scope">
-                                <el-button size="mini" type="text" icon="el-icon-delete"
-                                    @click="handledbelete(scope.row)">鍒犻櫎</el-button>
-                            </template>
-                        </el-table-column>
-                    </el-table>
-                </el-col>
-
-                <el-col :span="7" :xs="24">
-                    <el-form :model="queryParams1" ref="queryForm" size="small" :inline="true" v-show="showSearch"
-                        label-width="68px" @submit.native.prevent>
-
-
-                        <el-form-item label="椤圭洰鍚嶇О" prop="proName">
-                            <el-input ref="inputName" v-model="queryParams1.proName" placeholder="璇疯緭鍏ラ」鐩悕绉�" clearable
-                                @keyup.enter.native="handleSearchFor" style="width: 140px" />
-                        </el-form-item>
-                        <el-form-item>
-                            <el-button type="primary" icon="el-icon-search" size="mini"
-                                @click="handleSearchFor">鎼滅储</el-button>
-                        </el-form-item>
-                    </el-form>
-                    <el-table border v-loading="loading" ref="tre" :data="Treedata"
-                        @selection-change="handleChangesingle" height="478" style="width: 100%">
-                        <el-table-column type="selection" width="40px" align="center" />
-                        <el-table-column label="椤圭洰鍚嶇О" align="center" prop="proName" width="230px" />
-                        <el-table-column label="椤圭洰浠锋牸/鍏�" align="center" prop="proPrice" width="100px" />
-                    </el-table>
-                </el-col>
-            </el-row>
-            <div slot="footer" class="dialog-footer1">
-                <el-button type="primary" @click="submitrighr">纭骞朵繚瀛�</el-button>
-                <el-button @click="cancell">鍙� 娑�</el-button>
-            </div>
-        </el-dialog>
-    </div>
+      <!-- 绗笁鍒楋細鎼滅储 + 椤圭洰閫夋嫨 -->
+      <el-col :span="8" :xs="24">
+        <el-form
+          :model="queryParams1"
+          ref="queryForm"
+          size="small"
+          :inline="true"
+          v-show="showSearch"
+          label-width="68px"
+          style="height: 45px"
+          @submit.native.prevent
+        >
+          <el-form-item label="椤圭洰鍚嶇О" prop="proName">
+            <el-input
+              ref="inputName"
+              v-model="queryParams1.proName"
+              placeholder="璇疯緭鍏ラ」鐩悕绉�"
+              clearable
+              @keyup.enter.native="handleSearchFor"
+              style="width: 140px"
+            />
+          </el-form-item>
+          <el-form-item>
+            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleSearchFor">鎼滅储</el-button>
+          </el-form-item>
+        </el-form>
+        <el-table
+          border
+          v-loading="loading"
+          ref="tre"
+          :data="Treedata"
+          @selection-change="handleChangesingle"
+          height="478"
+          style="width: 100%"
+        >
+          <el-table-column type="selection" width="40px" align="center" />
+          <el-table-column label="椤圭洰鍚嶇О" align="center" prop="proName" show-overflow-tooltip />
+        </el-table>
+      </el-col>
+    </el-row>
+  </div>
 </template>
 
 <script>
-// import {  } from "@/api/system/menu";
+import { searchBiaoben, delBiaoben, editBiaoben } from "@/api/hosp/biaoben";
+import { debounce } from 'lodash';
+
 export default {
-    name: "Part",
-    //   dicts: [
-    //     "",
-    //   ],
-    data() {
-        return {
-            loading: false,
-            openOne: false,
-            partList: [],
-            Treedata: [],
-            queryParams: {
-
-            },
-            queryParams1: {
-
-            },
-            form: {
-
-            },
-
+  name: "Part",
+  data() {
+    return {
+      loading: false,
+      OnenewpacName: [],
+      Treedata: [],
+      originalTreedata: [],
+      queryParams: {
+        tjh: '',
+        tjCategory: null,
+      },
+      queryParams1: {
+        proName: '',
+      },
+      form: {
+        price: '',
+      },
+      showSearch: true,
+      filteredSpecimenData: [],
+      originalSpecimenData: [],
+    };
+  },
+  dicts: ["sys_dict_specimen"],
+  created() {
+    this.fetchInitialBiaobenData();
+    this.initializeSpecimenData();
+    this.debouncedFetchBiaobenData = debounce(this.fetchBiaobenData, 300);
+  },
+  watch: {
+    'dict.type.sys_dict_specimen': {
+      handler(newVal) {
+        if (newVal && newVal.length > 0) {
+          console.log('鏍囨湰瀛楀吀鏁版嵁鍔犺浇:', newVal);
+          this.originalSpecimenData = [...newVal];
+          this.filteredSpecimenData = [...newVal];
+        } else {
+          console.warn('鏍囨湰瀛楀吀鏁版嵁涓虹┖鎴栨湭鍔犺浇');
         }
+      },
+      deep: true,
+      immediate: true,
     },
-    created() {
+  },
+  methods: {
+    initializeSpecimenData() {
+      if (this.dict?.type?.sys_dict_specimen) {
+        this.originalSpecimenData = [...this.dict.type.sys_dict_specimen];
+        this.filteredSpecimenData = [...this.originalSpecimenData];
+        console.log('鍒濆鍖栨爣鏈暟鎹�:', this.originalSpecimenData);
+      } else {
+        this.$message.warning('鏍囨湰鏁版嵁鏈姞杞斤紝璇锋鏌ュ瓧鍏搁厤缃�');
+        this.originalSpecimenData = [];
+        this.filteredSpecimenData = [];
+      }
     },
-    methods: {
-        getList() {
+    handleSearchFor() {
+      const searchText = this.queryParams1.proName?.trim().toLowerCase() || '';
+      if (searchText) {
+        this.Treedata = this.originalTreedata.filter(item =>
+          item.proName.toLowerCase().includes(searchText)
+        );
+        this.Treedata.length
+          ? this.$message.success('鏌ヨ鎴愬姛')
+          : this.$message.warning('鏈壘鍒板尮閰嶇殑椤圭洰');
+      } else {
+        this.Treedata = [...this.originalTreedata];
+        this.$message.info('宸叉樉绀烘墍鏈夐」鐩�');
+      }
+      this.$refs.tre.clearSelection();
+    },
+    resetQuery() {
+      this.$refs.queryForm.resetFields();
+      this.queryParams.tjh = '';
+      this.queryParams.tjCategory = null;
+      this.OnenewpacName = [];
+      this.filteredSpecimenData = [...this.originalSpecimenData];
+      this.$refs.specimenTable.clearSelection();
+      this.$message.success('宸查噸缃煡璇㈡潯浠跺拰鏍囨湰鏁版嵁');
+    },
+    handleManual() {
+      const searchText = this.queryParams.tjh?.trim().toLowerCase() || '';
+      this.filteredSpecimenData = searchText
+        ? this.originalSpecimenData.filter(item => item.label.toLowerCase().includes(searchText))
+        : [...this.originalSpecimenData];
 
-        },
-        resetQuery() {
-            this.resetForm("queryForm");
-        },
-        handleManual() {
+      this.queryParams.tjCategory = null;
+      this.OnenewpacName = [];
+      this.$refs.specimenTable.clearSelection();
 
-        },
-        handleChangesingle(selection) {
-
-        },
-        cancell() {
-            this.openOne = false
-        },
-        submitrighr() {
-
-        },
-    }
+      this.$message[this.filteredSpecimenData.length ? 'success' : 'warning'](
+        this.filteredSpecimenData.length ? '鏌ヨ鎴愬姛' : '鏈壘鍒板尮閰嶇殑鏍囨湰'
+      );
+    },
+    handleSpecimenSelect(selection, row) {
+      console.log('鏍囨湰閫夋嫨瑙﹀彂:', { selection, row });
+      this.$refs.specimenTable.clearSelection();
+      if (selection.includes(row)) {
+        this.$refs.specimenTable.toggleRowSelection(row, true);
+        if (this.queryParams.tjCategory !== row.value) {
+          this.queryParams.tjCategory = row.value;
+          console.log('閫変腑鐨勬爣鏈� value:', this.queryParams.tjCategory);
+          this.debouncedFetchBiaobenData(row.value);
+        }
+      } else {
+        this.queryParams.tjCategory = null;
+        this.OnenewpacName = [];
+        console.log('鏍囨湰閫夋嫨宸叉竻绌�');
+      }
+    },
+    handleChangesingle(selection) {
+      if (selection.length > 0) {
+        selection.forEach(item => {
+          if (!this.OnenewpacName.some(existing => existing.proId === item.proId)) {
+            this.OnenewpacName.push({ ...item });
+          }
+        });
+        this.$refs.tre.clearSelection();
+      }
+    },
+    cancell() {
+      this.openOne = false;
+    },
+    submitrighr() {
+      if (!this.queryParams.tjCategory) {
+        this.$message.error('璇峰厛閫夋嫨涓�涓爣鏈�');
+        return;
+      }
+      if (!this.OnenewpacName.length) {
+        this.$message.error('璇疯嚦灏戦�夋嫨涓�涓」鐩�');
+        return;
+      }
+      const proIds = this.OnenewpacName.map(item => item.proId);
+      const bblx = this.queryParams.tjCategory;
+      this.loading = true;
+      editBiaoben({ proIds, bblx })
+        .then(() => {
+          this.$message.success('淇濆瓨鎴愬姛');
+          this.OnenewpacName = [];
+          this.queryParams.tjCategory = null;
+          this.$refs.specimenTable.clearSelection();
+          this.loading = false;
+        })
+        .catch(error => {
+          this.$message.error('淇濆瓨澶辫触');
+          console.error(error);
+          this.loading = false;
+        });
+    },
+    handledbelete(row) {
+      this.loading = true;
+      delBiaoben({ proId: row.proId })
+        .then(() => {
+          this.OnenewpacName = this.OnenewpacName.filter(item => item.proId !== row.proId);
+          this.$message.success('鍒犻櫎鎴愬姛');
+          this.loading = false;
+        })
+        .catch(error => {
+          this.$message.error('鍒犻櫎澶辫触');
+          console.error(error);
+          this.loading = false;
+        });
+    },
+    fetchBiaobenData(bblx) {
+      console.log('璋冪敤 searchBiaoben锛堜腑闂磋〃鏍硷級锛屽弬鏁�:', { bblx });
+      this.loading = true;
+      searchBiaoben({ bblx })
+        .then(response => {
+          this.OnenewpacName = response.data || [];
+          this.loading = false;
+        })
+        .catch(error => {
+          this.$message.error('鑾峰彇鏍囨湰鏁版嵁澶辫触');
+          console.error(error);
+          this.loading = false;
+        });
+    },
+    fetchInitialBiaobenData() {
+      console.log('璋冪敤 searchBiaoben锛堝垵濮嬪姞杞斤紝鍙充晶琛ㄦ牸锛夛紝鍙傛暟: {}');
+      this.loading = true;
+      searchBiaoben({})
+        .then(response => {
+          this.originalTreedata = response.data || [];
+          this.Treedata = [...this.originalTreedata];
+          this.loading = false;
+        })
+        .catch(error => {
+          this.$message.error('鑾峰彇鍒濆椤圭洰鏁版嵁澶辫触');
+          console.error(error);
+          this.loading = false;
+        });
+    },
+  },
 };
-</script>
\ No newline at end of file
+</script>
+
+<style scoped>
+.app-container {
+  padding: 20px;
+}
+.dialog-footer1 {
+  margin-top: 60px;
+  text-align: center;
+}
+</style>
\ No newline at end of file

--
Gitblit v1.8.0