From eef7c19891e437ef18e79ced890d6aaf0db6113d Mon Sep 17 00:00:00 2001
From: qx <1084500556@qq.com>
Date: 星期三, 11 六月 2025 10:53:28 +0800
Subject: [PATCH] Merge branch 'master' of http://101.42.27.146:5001/r/ltkj_peisweb

---
 src/views/hosp/biaoben/index.vue |  320 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 320 insertions(+), 0 deletions(-)

diff --git a/src/views/hosp/biaoben/index.vue b/src/views/hosp/biaoben/index.vue
new file mode 100644
index 0000000..f0afc9b
--- /dev/null
+++ b/src/views/hosp/biaoben/index.vue
@@ -0,0 +1,320 @@
+<template>
+  <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="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-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 { searchBiaoben, delBiaoben, editBiaoben } from "@/api/hosp/biaoben";
+import { debounce } from 'lodash';
+
+export default {
+  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,
+    },
+  },
+  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 = [];
+      }
+    },
+    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];
+
+      this.queryParams.tjCategory = null;
+      this.OnenewpacName = [];
+      this.$refs.specimenTable.clearSelection();
+
+      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>
+
+<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