Browse Source

优化采集信息详情页字段展示以及常用处方的数据回填功能

cgp 2 tuần trước cách đây
mục cha
commit
ac823d7ced

+ 2 - 3
src/views/components/collection/collectionDetail.vue

@@ -35,9 +35,8 @@
 </template>
 
 <script>
-// 假设你有一个根据 userId 获取采集信息的接口
-import { getCollectionByUserId } from "@/api/collection"; // ✅ 确保这个方法存在
-
+//根据 userId 获取采集信息的接口
+import { getCollectionByUserId } from "@/api/collection";
 export default {
   name: "CollectionDetail",
   props: {

+ 348 - 38
src/views/his/prescribe/index.vue

@@ -216,34 +216,6 @@
             <el-form-item label="过敏史" prop="historyAllergic">
               <el-input v-model="form.historyAllergic" placeholder="请输入过敏史" />
             </el-form-item>
-            <!-- 诊断 -->
-            <el-form-item label="诊断" prop="diagnose">
-              <el-input v-model="form.diagnose" placeholder="请输入诊断">
-                <i
-                  slot="suffix"
-                  class="el-icon-search el-input__icon"
-                  style="cursor: pointer;"
-                  @click="handlePrescribeCommonWorlds('diagnose', 1)"
-                ></i>
-              </el-input>
-            </el-form-item>
-
-            <!-- 备注 -->
-            <el-form-item label="备注" prop="remark">
-              <div style="display: flex; align-items: center;">
-                <el-input
-                  v-model="form.remark"
-                  type="textarea"
-                  placeholder="请输入备注"
-                  style="flex: 1;"
-                ></el-input>
-                <i
-                  class="el-icon-search"
-                  style="margin-left: 8px; cursor: pointer; font-size: 18px; color: #909399;"
-                  @click="handlePrescribeCommonWorlds('remark', 2)"
-                ></i>
-              </div>
-            </el-form-item>
             <!-- 定位在右下角的按钮 -->
             <el-button
               type="primary"
@@ -258,7 +230,37 @@
         <!-- Tab 2: 处方药品信息 -->
         <el-tab-pane label="处方药品信息" name="drug">
           <div class="drug-container">
-            <!-- 药品操作按钮 -->
+            <el-form ref="drugInfoForm" :model="form" :rules="rules" label-width="120px" class="drug-container">
+              <!-- 诊断 -->
+              <el-form-item label="诊断" prop="diagnose">
+                <el-input v-model="form.diagnose" placeholder="请输入诊断">
+                  <i
+                    slot="suffix"
+                    class="el-icon-search el-input__icon"
+                    style="cursor: pointer;"
+                    @click="handlePrescribeCommonWorlds('diagnose', 1)"
+                  ></i>
+                </el-input>
+              </el-form-item>
+
+              <!-- 备注 -->
+              <el-form-item label="备注" prop="remark">
+                <div style="display: flex; align-items: center;">
+                  <el-input
+                    v-model="form.remark"
+                    type="textarea"
+                    placeholder="请输入备注"
+                    style="flex: 1;"
+                  ></el-input>
+                  <i
+                    class="el-icon-search"
+                    style="margin-left: 8px; cursor: pointer; font-size: 18px; color: #909399;"
+                    @click="handlePrescribeCommonWorlds('remark', 2)"
+                  ></i>
+                </div>
+              </el-form-item>
+            </el-form>
+              <!-- 药品操作按钮 -->
             <el-row :gutter="10" class="mb8">
               <el-col :span="1.5">
                 <el-button
@@ -270,6 +272,17 @@
                   :disabled="!form.prescribeId"
                 >新增药品</el-button>
               </el-col>
+              <el-col :span="2.5">
+                <el-button
+                  v-if="currentConfirm === 0"
+                  type="success"
+                  icon="el-icon-search"
+                  size="mini"
+                  @click="openCommonPrescribeDialog"
+                  :disabled="!form.prescribeId"
+                >常用处方</el-button>
+              </el-col>
+
             </el-row>
             <!-- 药品列表表格 -->
             <el-table
@@ -282,18 +295,18 @@
               <el-table-column label="规格" align="center" prop="drugSpec" width="100" />
               <el-table-column label="使用方法" align="center" prop="usageMethod" width="100" />
               <el-table-column label="频次" align="center" prop="usageFrequencyUnit" width="80" />
-              <el-table-column label="每次用药" align="center" width="120">
+              <el-table-column label="每次用药数量" align="center" width="120">
                 <template slot-scope="scope">
                   {{ scope.row.usagePerUseCount }}{{ scope.row.usagePerUseUnit }}
                 </template>
               </el-table-column>
-              <el-table-column label="天数" align="center" prop="usageDays" width="60" />
-              <el-table-column label="单价" align="center" prop="drugPrice" width="80" />
-              <el-table-column label="数量" align="center" width="100">
-                <template slot-scope="scope">
-                  {{ scope.row.drugNum }}{{ scope.row.drugUnit }}
-                </template>
-              </el-table-column>
+<!--              <el-table-column label="天数" align="center" prop="usageDays" width="60" />-->
+<!--              <el-table-column label="单价" align="center" prop="drugPrice" width="80" />-->
+<!--              <el-table-column label="数量" align="center" width="100">-->
+<!--                <template slot-scope="scope">-->
+<!--                  {{ scope.row.drugNum }}{{ scope.row.drugUnit }}-->
+<!--                </template>-->
+<!--              </el-table-column>-->
               <el-table-column v-if="currentConfirm === 0" label="操作" align="center" class-name="small-padding fixed-width" width="150">
                 <template slot-scope="scope">
                   <el-button
@@ -323,6 +336,46 @@
         </el-tab-pane>
         <!-- Tab 3: 用户信息采集 -->
         <el-tab-pane label="采集信息详情" name="userCollection">
+          <el-row :gutter="20" style="margin-bottom: 20px;">
+            <el-col :span="8">
+              <div class="info-item">
+                <span class="label">患者姓名:</span>
+                <span class="value">{{ form.patientName || '—' }}</span>
+              </div>
+            </el-col>
+            <el-col :span="8">
+              <div class="info-item">
+                <span class="label">患者年龄:</span>
+                <span class="value">{{ form.patientAge || '—' }}</span>
+              </div>
+            </el-col>
+            <el-col :span="8">
+              <div class="info-item">
+                <span class="label">患者性别:</span>
+                <span class="value">{{ form.patientGender === '1' ? '男' : form.patientGender === '2' ? '女' : '—' }}</span>
+              </div>
+            </el-col>
+          </el-row>
+          <el-row :gutter="20">
+            <el-col :span="8">
+              <div class="info-item">
+                <span class="label">体重:</span>
+                <span class="value">{{ form.weight ? form.weight + ' kg' : '—' }}</span>
+              </div>
+            </el-col>
+            <el-col :span="8">
+              <div class="info-item">
+                <span class="label">是否有过敏史:</span>
+                <span class="value">{{ form.isHistoryAllergic || '—' }}</span>
+              </div>
+            </el-col>
+            <el-col :span="8">
+              <div class="info-item">
+                <span class="label">过敏史:</span>
+                <span class="value">{{ form.isHistoryAllergic === '是' ? (form.historyAllergic || '—') : '无' }}</span>
+              </div>
+            </el-col>
+          </el-row>
           <collectionDetail
             :userId="form.userId"
             :prescribeId="form.prescribeId"
@@ -332,11 +385,54 @@
       </el-tabs>
       <!-- 查看采集信息的弹窗 -->
       <el-dialog :visible.sync="collectionDialogVisible" title="用户信息采集详情" width="800px" append-to-body>
+
+        <el-row :gutter="20" style="margin-bottom: 20px;">
+          <el-col :span="8">
+            <div class="info-item">
+              <span class="label">患者姓名:</span>
+              <span class="value">{{ form.patientName || '—' }}</span>
+            </div>
+          </el-col>
+          <el-col :span="8">
+            <div class="info-item">
+              <span class="label">患者年龄:</span>
+              <span class="value">{{ form.patientAge || '—' }}</span>
+            </div>
+          </el-col>
+          <el-col :span="8">
+            <div class="info-item">
+              <span class="label">患者性别:</span>
+              <span class="value">{{ form.patientGender === '1' ? '男' : form.patientGender === '2' ? '女' : '—' }}</span>
+            </div>
+          </el-col>
+        </el-row>
+        <el-row :gutter="20">
+          <el-col :span="8">
+            <div class="info-item">
+              <span class="label">体重:</span>
+              <span class="value">{{ form.weight ? form.weight + ' kg' : '—' }}</span>
+            </div>
+          </el-col>
+          <el-col :span="8">
+            <div class="info-item">
+              <span class="label">是否有过敏史:</span>
+              <span class="value">{{ form.isHistoryAllergic || '—' }}</span>
+            </div>
+          </el-col>
+          <el-col :span="8">
+            <div class="info-item">
+              <span class="label">过敏史:</span>
+              <span class="value">{{ form.isHistoryAllergic === '是' ? (form.historyAllergic || '—') : '无' }}</span>
+            </div>
+          </el-col>
+        </el-row>
+
         <collectionDetail :userId="form.userId" :prescribeId="form.prescribeId" v-if="collectionDialogVisible"/>
         <span slot="footer" class="dialog-footer">
           <el-button @click="collectionDialogVisible = false">关 闭</el-button>
         </span>
       </el-dialog>
+
       <span slot="footer" class="dialog-footer">
         <el-button @click="open = false">关 闭</el-button>
         <el-button type="primary" @click="submitForm" v-if="currentConfirm === 0">保 存</el-button>
@@ -361,7 +457,6 @@
         <el-form-item label="每次用药数量" prop="usagePerUseCount">
           <el-input v-model="drugForm.usagePerUseCount" placeholder="请输入每次用药数量" />
         </el-form-item>
-
       </el-form>
       <span slot="footer" class="dialog-footer">
         <el-button @click="drugOpen = false">取 消</el-button>
@@ -402,9 +497,81 @@
         @pagination="getSuggestList"
       />
     </el-dialog>
+
+      <!-- 常用处方选择对话框 -->
+      <el-dialog
+        title="选择常用处方"
+        :visible.sync="commonPrescribeDialogVisible"
+        width="800px"
+        append-to-body
+        @open="handleOpenCommonPrescribeDialog"
+      >
+
+        <!-- 搜索区域 -->
+        <el-form :model="commonPrescribeQuery" :inline="true" size="small" label-width="80px">
+          <el-form-item label="诊断内容" prop="diagnose">
+            <el-input
+              v-model="commonPrescribeQuery.diagnose"
+              placeholder="请输入诊断内容"
+              clearable
+              @keyup.enter.native="handleCommonPrescribeQuery"
+            />
+          </el-form-item>
+          <el-form-item>
+            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleCommonPrescribeQuery">搜索</el-button>
+            <el-button icon="el-icon-refresh" size="mini" @click="resetCommonPrescribeQuery">重置</el-button>
+          </el-form-item>
+        </el-form>
+
+        <!-- 表格 -->
+        <el-table
+          v-loading="commonPrescribeLoading"
+          :data="commonPrescribeList"
+          border
+          style="width: 100%; margin-top: 10px;"
+          max-height="400"
+        >
+          <el-table-column label="诊断" align="center" prop="diagnose" show-overflow-tooltip />
+          <el-table-column label="药品名称" align="center" show-overflow-tooltip>
+            <template slot-scope="scope">
+        <span v-for="(drug, index) in scope.row.drugs" :key="drug.drugId || index">
+          {{ drug.drugName }}
+          <span v-if="index < scope.row.drugs.length - 1">, </span>
+        </span>
+            </template>
+          </el-table-column>
+          <el-table-column label="药品种类数量" align="center" width="120">
+            <template slot-scope="scope">
+              {{ scope.row.drugs.length || 0 }}
+            </template>
+          </el-table-column>
+          <el-table-column label="操作" align="center" width="120">
+            <template slot-scope="scope">
+              <el-button
+                size="mini"
+                type="text"
+                icon="el-icon-check"
+                @click="applyCommonPrescribe(scope.row)"
+              >应用</el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+
+        <!-- 分页 -->
+        <pagination
+          v-show="commonPrescribeTotal > 0"
+          :total="commonPrescribeTotal"
+          :page.sync="commonPrescribeQuery.pageNum"
+          :limit.sync="commonPrescribeQuery.pageSize"
+          @pagination="getCommonPrescribeList"
+          style="margin-top: 10px;"
+        />
+
+      </el-dialog>
   </div>
 </template>
 <script>
+import { getDoctorPrescribeList} from "@/api/prescribe";
 import collectionDetail from '@/views/components/collection/collectionDetail.vue';
 import {listPrescribe,
   getPrescribe,
@@ -461,6 +628,16 @@ export default {
         { dictValue: '0', dictLabel: "未开" },
         { dictValue: '1', dictLabel: "已开" }
       ],
+      // 常用处方弹窗相关
+      commonPrescribeDialogVisible: false,
+      commonPrescribeLoading: false,
+      commonPrescribeList: [],
+      commonPrescribeTotal: 0,
+      commonPrescribeQuery: {
+        pageNum: 1,
+        pageSize: 10,
+        diagnose: undefined
+      },
       queryParams: {
         pageNum: 1,
         pageSize: 10,
@@ -536,6 +713,123 @@ export default {
     }
   },
   methods: {
+    /** 获取常用处方列表 */
+    getPrescribeList() {
+      this.loading = true;
+      getDoctorPrescribeList(this.commonPrescribeQuery).then(response => {
+        this.prescribeList = response.data.list;
+        this.total = response.data.total;
+        this.loading = false;
+      });
+    },
+    /**
+     * 打开常用处方对话框,并打印当前医生ID
+     */
+    openCommonPrescribeDialog() {
+      // 获取当前医生ID(假设医生ID在 form.doctorId 或从 store 中获取)
+      const doctorId = this.form.doctorId || this.$store.state.user.userId?.replace('D-', '');
+
+      console.log('当前医生ID:', doctorId);
+
+      // 打开对话框
+      this.commonPrescribeDialogVisible = true;
+    },
+
+    /** 打开常用处方对话框时加载数据 */
+    handleOpenCommonPrescribeDialog() {
+      this.commonPrescribeQuery.pageNum = 1;
+      this.getCommonPrescribeList();
+    },
+
+    /** 搜索常用处方 */
+    handleCommonPrescribeQuery() {
+      this.commonPrescribeQuery.pageNum = 1;
+      this.getCommonPrescribeList();
+    },
+
+    /** 重置常用处方搜索 */
+    resetCommonPrescribeQuery() {
+      this.commonPrescribeQuery.diagnose = undefined;
+      this.handleCommonPrescribeQuery();
+    },
+
+    /** 获取常用处方列表 */
+    getCommonPrescribeList() {
+      this.commonPrescribeLoading = true;
+      // 获取当前医生ID
+      const doctorId = this.form.doctorId || this.$store.state.user.userId?.replace('D-', '');
+      const params = {
+        ...this.commonPrescribeQuery,
+        doctorId: doctorId
+      };
+      getDoctorPrescribeList(params).then(response => {
+        this.commonPrescribeList = response.data.list || [];
+        this.commonPrescribeTotal = response.data.total || 0;
+        this.commonPrescribeLoading = false;
+      }).catch(() => {
+        this.commonPrescribeLoading = false;
+      });
+    },
+
+    /** 应用选中的常用处方到当前表单 */
+    async applyCommonPrescribe(row) {
+      // 1. 回填诊断和备注
+      this.form.diagnose = row.diagnose;
+      this.form.remark = row.remark || '';
+
+      // 2. 检查是否已保存处方(必须有 prescribeId 才能加药品)
+      if (!this.form.prescribeId) {
+        this.$message.warning('请先保存处方基本信息,再应用常用处方药品');
+        this.commonPrescribeDialogVisible = false;
+        return;
+      }
+
+      // 3. 如果没有药品,直接关闭
+      if (!row.drugs || row.drugs.length === 0) {
+        this.$message.success('已应用诊断信息,无药品数据');
+        this.commonPrescribeDialogVisible = false;
+        return;
+      }
+
+      // 4. 显示 loading
+      this.drugLoading = true;
+      this.$message.info(`正在添加 ${row.drugs.length} 条药品...`);
+
+      try {
+        // 5. 逐个添加药品(可考虑并发,但为避免后端压力,建议串行)
+        for (const drug of row.drugs) {
+          const drugData = {
+            prescribeId: this.form.prescribeId,
+            drugName: drug.drugName,
+            drugSpec: drug.drugSpec,
+            usageMethod: drug.usageMethod,
+            usageFrequencyUnit: drug.usageFrequencyUnit,
+            usagePerUseCount: drug.usagePerUseCount,
+            usagePerUseUnit: drug.usagePerUseUnit,
+            usageDays: drug.usageDays,
+            drugPrice: drug.drugPrice,
+            drugNum: drug.drugNum,
+            drugUnit: drug.drugUnit,
+            instructions: drug.instructions
+            // 注意:确保字段名与后端 API 一致!
+          };
+          await addPrescribeDrug(drugData);
+        }
+
+        // 6. 全部成功后刷新药品列表
+        await this.getDrugList();
+        this.$message.success(`成功添加 ${row.drugs.length} 条药品`);
+
+      } catch (error) {
+        console.error('应用常用处方药品失败:', error);
+        this.$message.error('部分药品添加失败,请检查后重试');
+      } finally {
+        this.drugLoading = false;
+        this.commonPrescribeDialogVisible = false;
+      }
+    },
+
+
     /**
      * 搜索关键词常用语方法 - 支持不同来源和类型
      * @param {string} type - 字段类型: 'diagnose' | 'remark'
@@ -927,4 +1221,20 @@ export default {
 .id-card-detail {
   margin-top: 20px;
 }
+/*------------这里开始是Tab3字体样式------------------*/
+.info-item {
+  display: flex;
+  align-items: center;
+  min-height: 32px;
+}
+.info-item .label {
+  font-family: SimHei, "Microsoft YaHei", sans-serif; /* 黑体优先 */
+  font-weight: bold;
+  color: #333;
+}
+.info-item .value {
+  color: #666;
+  margin-left: 6px;
+}
+/* -----------这里是Tab3字体样式结束-----------------*/
 </style>

+ 213 - 193
src/views/myDrugStore/common.vue

@@ -1,16 +1,16 @@
 <template>
   <div class="app-container">
     <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
-      <el-form-item label="处方类型" prop="prescribeType">
-        <el-select v-model="queryParams.prescribeType" placeholder="请选择处方类型" clearable size="small">
-          <el-option
-            v-for="dict in prescribeTypeOptions"
-            :key="dict.dictValue"
-            :label="dict.dictLabel"
-            :value="dict.dictValue"
-          />
-        </el-select>
-      </el-form-item>
+<!--      <el-form-item label="处方类型" prop="prescribeType">-->
+<!--        <el-select v-model="queryParams.prescribeType" placeholder="请选择处方类型" clearable size="small">-->
+<!--          <el-option-->
+<!--            v-for="dict in prescribeTypeOptions"-->
+<!--            :key="dict.dictValue"-->
+<!--            :label="dict.dictLabel"-->
+<!--            :value="dict.dictValue"-->
+<!--          />-->
+<!--        </el-select>-->
+<!--      </el-form-item>-->
       <el-form-item label="诊断内容" prop="diagnose">
         <el-input
           v-model="queryParams.diagnose"
@@ -34,26 +34,26 @@
           icon="el-icon-plus"
           size="mini"
           @click="handleAdd(1)"
-        >新建西药处方</el-button>
-      </el-col>
-      <el-col :span="1.5">
-        <el-button
-          type="success"
-          plain
-          icon="el-icon-plus"
-          size="mini"
-          @click="handleAdd(2)"
-        >新建中药处方</el-button>
+        >新建常用处方</el-button>
       </el-col>
+<!--      <el-col :span="1.5">-->
+<!--        <el-button-->
+<!--          type="success"-->
+<!--          plain-->
+<!--          icon="el-icon-plus"-->
+<!--          size="mini"-->
+<!--          @click="handleAdd(2)"-->
+<!--        >新建中药处方</el-button>-->
+<!--      </el-col>-->
     </el-row>
 
     <el-table v-loading="loading"  border :data="prescribeList" @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" align="center" />
-      <el-table-column label="处方类型" align="center" prop="prescribeType" width="100px">
-        <template slot-scope="scope">
-          <dict-tag :options="prescribeTypeOptions" :value="scope.row.prescribeType"/>
-        </template>
-      </el-table-column>
+<!--      <el-table-column label="处方类型" align="center" prop="prescribeType" width="100px">-->
+<!--        <template slot-scope="scope">-->
+<!--          <dict-tag :options="prescribeTypeOptions" :value="scope.row.prescribeType"/>-->
+<!--        </template>-->
+<!--      </el-table-column>-->
       <el-table-column label="诊断" align="center" prop="diagnose" />
       <el-table-column label="药品名称" align="center">
         <template slot-scope="scope">
@@ -107,152 +107,95 @@
         <el-form-item label="病情诊断" prop="diagnose">
           <el-input v-model="form.diagnose" placeholder="请输入病情诊断" :rows="10" type="textarea" />
         </el-form-item>
-        <el-form-item label="药房" prop="storeId" >
-          <el-select v-model="form.storeId" placeholder="选择药房" clearable size="small" filterable @change="changeStore">
-            <el-option
-              v-for="dict in storeOptions"
-              :key="dict.storeId"
-              :label="dict.storeName"
-              :value="dict.storeId"/>
-          </el-select>
-          <div style="float: right;"><el-button plain  type="primary" icon="el-icon-plus" @click="handleAddProduct">添加商品</el-button></div>
-          <div style="margin-top:10px;">
-            <el-table border width="100%"   :data="drugList">
-              <el-table-column label="药品图片" align="center" prop="drugImgUrl" width="120">
-                <template slot-scope="scope">
-                  <el-popover
-                    placement="right"
-                    title=""
-                    trigger="hover"
-                  >
-                    <img slot="reference" :src="scope.row.drugImgUrl" width="100">
-                    <img :src="scope.row.drugImgUrl" style="max-width: 150px;">
-                  </el-popover>
-                </template>
-              </el-table-column>
-              <el-table-column label="药品名称" align="center" prop="drugName" show-overflow-tooltip  width="150px"/>
-              <el-table-column label="药品类型" align="center" prop="drugType" width="100px">
-                <template slot-scope="scope">
-                  <dict-tag :options="prescribeTypeOptions" :value="scope.row.drugType"/>
-                </template>
-              </el-table-column>
-              <el-table-column label="药品规格" align="center" prop="drugSpec"  />
-              <el-table-column label="药品单价" align="center" prop="drugPrice"  />
-              <el-table-column label="药品数量" align="center"  prop="drugNum" width="150px" >
-                <template slot-scope="scope">
-                  <div>
-                      <el-input-number v-model="scope.row.drugNum"    size="mini" :min="1"   ></el-input-number>
-                  </div>
-                </template>
-              </el-table-column>
-              <el-table-column label="用药频率" align="center"  prop="usageFrequencyUnit" width="150px" v-if="form.prescribeType==1" >
-                <template slot-scope="scope">
-                  <div>
-                    <el-select v-model="scope.row.usageFrequencyUnit"  clearable size="small">
-                      <el-option
-                        v-for="dict in usageFrequencyUnits"
-                        :key="dict.dictValue"
-                        :label="dict.dictLabel"
-                        :value="dict.dictValue"
-                      />
-                    </el-select>
-                  </div>
-                </template>
-              </el-table-column>
-              <el-table-column label="单次用量" align="center"  prop="usagePerUseCount" width="150px" v-if="form.prescribeType==1">
-                <template slot-scope="scope">
-                  <div>
-                    <el-input size="mini" v-model="scope.row.usagePerUseCount"></el-input>
-                  </div>
-                </template>
-              </el-table-column>
-              <el-table-column label="用药方法" align="center"  prop="usageMethod" width="200px" v-if="form.prescribeType==1" >
-                <template slot-scope="scope">
-                  <div>
-                    <el-select v-model="scope.row.usageMethod"  clearable size="small">
-                      <el-option
-                        v-for="dict in usageMethods"
-                        :key="dict.dictValue"
-                        :label="dict.dictLabel"
-                        :value="dict.dictValue"
-                      />
-                    </el-select>
-                  </div>
-                </template>
-              </el-table-column>
-              <el-table-column label="备注" align="center"  prop="remark" width="150px" v-if="form.prescribeType==1">
-                <template slot-scope="scope">
-                  <div>
-                    <el-input size="mini" v-model="scope.row.remark"></el-input>
-                  </div>
-                </template>
-              </el-table-column>
-              <el-table-column label="操作" align="center" width="100px" fixed="right">
-                <template slot-scope="scope">
-                  <el-button
-                    size="mini"
-                    type="text"
-                    icon="el-icon-delete"
-                    @click="handleProductDelete(scope.row,scope.$index)"
-                  >删除</el-button>
-                </template>
-              </el-table-column>
-            </el-table>
-          </div>
-         
-        </el-form-item>
-      
-        <div  v-if="form.prescribeType==2">
-          <el-form-item label="用药数量"  >
-            <el-input v-model="usageJson.counts" placeholder="请输入用药数量" />
-          </el-form-item>
-          <el-form-item label="用药频率"  >
-            <el-select v-model="usageJson.usageFrequencyUnit" placeholder="请选择用药频率" clearable size="small" filterable>
-                <el-option
-                  v-for="dict in usageFrequencyUnits"
-                  :key="dict.dictValue"
-                  :label="dict.dictLabel"
-                  :value="dict.dictValue"/>
-              </el-select>
-          </el-form-item>
-          <el-form-item label="单次用量"  >
-            <el-input v-model="usageJson.usagePerUseCount" placeholder="请输入单次用量"  />
-          </el-form-item>
-         
-          <el-form-item label="用药方法"  >
-            <el-select v-model="usageJson.usageMethod" placeholder="请选择用药方法" clearable size="small" filterable>
-                <el-option
-                  v-for="dict in usageMethods"
-                  :key="dict.dictValue"
-                  :label="dict.dictLabel"
-                  :value="dict.dictValue"/>
-              </el-select>
-          </el-form-item>
-          <el-form-item label="制作方式" prop="recipeType">
-            <el-select v-model="form.recipeType" placeholder="请选择制作方式" clearable size="small" filterable>
-                <el-option
-                  v-for="dict in recipeTypes"
-                  :key="dict.dictValue"
-                  :label="dict.dictLabel"
-                  :value="dict.dictValue"/>
-              </el-select>
-          </el-form-item>
-          <el-form-item label="合计" prop="price">
-            {{totalAmount.toFixed(2)+'元'}}
-          </el-form-item>
-        </div>
-        <el-form-item label="用药周期"  >
-            <el-input-number v-model="form.cycle" :step="6" :min="6" :max="36"></el-input-number>
-        </el-form-item>
-        <el-form-item label="备注" prop="remark">
-            <el-input v-model="usageJson.remark" placeholder="请输入备注" :rows="2" type="textarea" />
+
+    <!--    添加处方药品    -->
+        <el-row :gutter="10" class="mb8">
+          <el-col :span="1.5">
+            <el-button
+              type="primary"
+              icon="el-icon-plus"
+              size="mini"
+              @click="openDrugSelect"
+            >
+              新增药品
+            </el-button>
+          </el-col>
+        </el-row>
+
+        <!-- 药品列表表格 -->
+        <el-table
+          v-if="drugList"
+          :data="drugList"
+          border
+          style="width: 100%; margin-top: 15px;margin-bottom: 20px;"
+        >
+          <el-table-column prop="drugName" label="药品名称" align="center" />
+          <el-table-column prop="drugSpec" label="规格" align="center" />
+          <el-table-column prop="usageMethod" label="使用方法" align="center" />
+          <el-table-column prop="usageFrequencyUnit" label="药品频次" align="center" />
+          <el-table-column prop="usagePerUseCount" label="每次用药数量" align="center" />
+          <el-table-column label="操作" align="center" width="160">
+            <template slot-scope="scope">
+              <el-button
+                size="mini"
+                type="text"
+                icon="el-icon-edit"
+                @click="handleDrugEdit(scope.row, scope.$index)"
+              >编辑</el-button>
+              <el-button
+                size="mini"
+                type="text"
+                icon="el-icon-delete"
+                @click="handleProductDelete(scope.row, scope.$index)"
+              >删除</el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+      <!-- 备注-->
+          <el-form-item label="备注" prop="remark">
+            <el-input v-model="form.remark" placeholder="请输入备注" :rows="10" type="text" />
           </el-form-item>
+
       </el-form>
       <div slot="footer" class="dialog-footer">
-        <el-button type="primary" @click="submitForm">确 定</el-button>
         <el-button @click="cancel">取 消</el-button>
+        <el-button type="primary" @click="submitForm">确 定</el-button>
       </div>
     </el-dialog>
+
+
+    <!-- 药品新增弹窗 -->
+    <el-dialog
+      :title="drugDialogTitle"
+      :visible.sync="drugDialogVisible"
+      width="600px"
+      append-to-body
+    >
+      <el-form ref="drugForm" :model="drugForm" :rules="drugFormRules" label-width="120px">
+        <el-form-item label="药品名称" prop="drugName">
+          <el-input v-model="drugForm.drugName" placeholder="请输入药品名称" />
+        </el-form-item>
+        <el-form-item label="规格" prop="drugSpec">
+          <el-input v-model="drugForm.drugSpec" placeholder="请输入规格" />
+        </el-form-item>
+        <el-form-item label="使用方法" prop="usageMethod">
+          <el-input v-model="drugForm.usageMethod" placeholder="请输入使用方法" />
+        </el-form-item>
+        <el-form-item label="药品频次" prop="usageFrequencyUnit">
+          <el-input v-model="drugForm.usageFrequencyUnit" placeholder="例如:每日3次" />
+        </el-form-item>
+        <el-form-item label="每次用药数量" prop="usagePerUseCount">
+          <el-input v-model="drugForm.usagePerUseCount" placeholder="请输入数量" />
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="cancelDrugDialog">取 消</el-button>
+        <el-button type="primary" @click="submitDrugForm">确 定</el-button>
+      </div>
+    </el-dialog>
+
+
+
     <el-drawer
             :with-header="false"
             size="75%"
@@ -275,6 +218,29 @@ export default {
   components:{prescribeDetails,storeProductAttrValueSelect},
   data() {
     return {
+      editingDrugIndex: -1, // 当前正在编辑的药品在 drugList 中的索引,-1 表示新增
+      // 药品弹窗控制
+      drugDialogVisible: false,
+      drugDialogTitle: "新增药品",
+
+      // 添加或修改药品弹窗参数
+      drugForm: {
+        drugName: '',
+        drugSpec: '',
+        usagePerUseCount: '',
+        usageMethod: '',
+        usageFrequencyUnit: ''
+      },
+
+      drugFormRules: {
+        drugName: [{ required: true, message: '药品名称不能为空', trigger: 'blur' }],
+        drugSpec: [{ required: true, message: '规格不能为空', trigger: 'blur' }],
+        usagePerUseCount: [{ required: true, message: '数量不能为空', trigger: 'blur' }],
+        usageMethod: [{ required: true, message: '使用方法不能为空', trigger: 'blur' }],
+        usageFrequencyUnit: [{ required: true, message: '用药频次不能为空', trigger: 'blur' }]
+      },
+
+
       orderId:null,
       productShow:{
         open:false,
@@ -292,25 +258,6 @@ export default {
       totalMoney:0.00,
       drugList:[],
       usageJson:{},
-      usageFrequencyUnits:[
-        { dictValue: '每日一次', dictLabel: '每日一次' },
-        { dictValue: '每日二次', dictLabel: '每日二次' },
-        { dictValue: '每日三次', dictLabel: '每日三次' },
-        { dictValue: '每日四次', dictLabel: '每日四次' }
-      ],
-      usageMethods:[
-        { dictValue: '口服', dictLabel: '口服' },
-        { dictValue: '外敷', dictLabel: '外敷' },
-        { dictValue: '注射', dictLabel: '注射' },
-      ],
-      recipeTypes:[
-        { dictValue: 0, dictLabel: '颗粒' },
-        { dictValue: 1, dictLabel: '膏方' },
-        { dictValue: 2, dictLabel: '饮片' }
-      ],
-      show:{
-        open:false,
-      },
       ids: [],
       // 非单个禁用
       single: true,
@@ -384,6 +331,80 @@ export default {
     this.getList();
   },
   methods: {
+    // 打开新增药品弹窗
+    openDrugSelect() {
+      this.drugDialogTitle = "新增药品";
+      this.editingDrugIndex = -1; // 明确是新增
+      this.drugForm = {
+        drugName: '',
+        drugSpec: '',
+        usageMethod: '',
+        usageFrequencyUnit: '',
+        usagePerUseCount: ''
+      };
+      if (this.$refs.drugForm) {
+        this.$refs.drugForm.clearValidate();
+      }
+      this.drugDialogVisible = true;
+    },
+
+    // 提交药品表单
+    submitDrugForm() {
+      this.$refs.drugForm.validate((valid) => {
+        if (!valid) return;
+
+        const newDrug = {
+          ...this.drugForm,
+          drugId: this.editingDrugIndex === -1 ? Date.now() + Math.random() : this.drugList[this.editingDrugIndex].drugId
+        };
+
+        if (this.editingDrugIndex === -1) {
+          // 新增
+          if (this.drugList.some(d => d.drugName === newDrug.drugName)) {
+            this.$message.warning('该药品已添加');
+            return;
+          }
+          this.drugList.push(newDrug);
+          this.$message.success('药品添加成功');
+        } else {
+          // 编辑:替换原数据
+          this.drugList.splice(this.editingDrugIndex, 1, newDrug);
+          this.$message.success('药品编辑成功');
+          this.editingDrugIndex = -1; // 重置
+        }
+
+        this.drugDialogVisible = false;
+      });
+    },
+
+
+// 打开编辑药品弹窗
+    handleDrugEdit(row, index) {
+      this.drugDialogTitle = "编辑药品";
+      this.editingDrugIndex = index; // 记录正在编辑的索引
+
+      // 深拷贝当前药品数据到 drugForm(避免引用)
+      this.drugForm = {
+        drugName: row.drugName,
+        drugSpec: row.drugSpec,
+        usageMethod: row.usageMethod,
+        usageFrequencyUnit: row.usageFrequencyUnit,
+        usagePerUseCount: row.usagePerUseCount,
+        // 如果还有其他字段,也要加上
+      };
+
+      if (this.$refs.drugForm) {
+        this.$refs.drugForm.clearValidate();
+      }
+      this.drugDialogVisible = true;
+    },
+
+    cancelDrugDialog() {
+      this.drugDialogVisible = false;
+      this.editingDrugIndex = -1;
+    },
+
+
     openDrugStore(orderId){
       this.orderId=orderId;
     },
@@ -476,12 +497,12 @@ export default {
     handleAdd(type) {
       this.reset();
       this.storeId=null,
-      this.drugList=null;
+      this.drugList=[];
       this.open = true;
       this.form.prescribeType =type;
       this.form.cycle=6;
       if(type==1){
-        this.title = "新建西药处方";
+        this.title = "新建常用处方";
       }
       else if(type==2){
         this.title = "新建中药处方";
@@ -491,13 +512,13 @@ export default {
         };
         console.log(this.form)
       }
-      
+
     },
     /** 修改按钮操作 */
     handleUpdate(row) {
       this.reset();
       this.storeId=null,
-      this.drugList=null;
+      this.drugList=[];
       const prescribeId = row.prescribeId ;
       getDoctorPrescribe(prescribeId).then(response => {
         this.form = response.data.prescribe;
@@ -510,7 +531,7 @@ export default {
         if(this.form.usageJson!=null){
           this.usageJson = JSON.parse(response.data.prescribe.usageJson);
         }
-        
+
       });
     },
     submitForm() {
@@ -557,8 +578,8 @@ export default {
         orderId :this.orderId
       }
       this.$confirm('确认开方吗?', "警告", {
-          confirmButtonText: "确定",
           cancelButtonText: "取消",
+          confirmButtonText: "确定",
           type: "warning"
         }).then(() => {
           return createPrescribe(data);
@@ -570,12 +591,11 @@ export default {
             this.msgError(res.msg);
           }
         }).catch((res) => {
-           
+
         });
     },
-   
+
   }
 };
 </script>
 
-