qx
qx
2025-04-15 d65aa7fee641733e13fcbcd6c326d6bd27a45d96
src/views/reservation/reservations/index.vue
@@ -197,6 +197,16 @@
        >
        <!-- v-hasPermi="['reservation:reservation:remove']" -->
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          size="mini"
          :disabled="multiple"
          @click="Groupsignin"
          >团体签到</el-button
        >
        <!-- v-hasPermi="['reservation:reservation:remove']" -->
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
@@ -811,18 +821,136 @@
                  </el-form>
                </template>
                <div style="text-align: center; margin-bottom: 10px">
                <div
                  style="
                    display: flex;
                    align-items: center;
                    justify-content: flex-start;
                    width: 100%;
                  "
                >
                  <div
                    style="
                      white-space: nowrap;
                      overflow: hidden;
                      text-overflow: ellipsis;
                      margin-left: 46px;
                      font-size: 16px;
                      margin-right: 20px;
                    "
                  >
                    已选项目条数:<span
                      style="font-weight: 700; color: red; margin-right: 5px"
                      >{{ this.tableData1.length || 0 }}</span
                    >条
                  </div>
                  已选项目列表
                </div>
                <div
                  style="
                    padding: 0px 6px;
                    border: 1px solid #e6ebf5;
                    max-height: 650%;
                    overflow: auto;
                    width: 916px;
                    margin-left: 35px;
                  "
                >
                  <el-table :data="tableData1" border style="width: 100%">
                    <el-table-column
                      prop="proName"
                      label="项目"
                      width="180"
                      align="center"
                    >
                    </el-table-column>
                    <el-table-column
                      prop="proType"
                      label="性别"
                      width="50"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <template v-if="isAll(scope.row.proType)">
                          全部
                        </template>
                        <template v-else>
                          <dict-tag
                            :options="dict.type.sys_user_sex"
                            :value="scope.row.proType"
                          />
                        </template>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="ordPrice"
                      label="应收金额"
                      align="center"
                    >
                    </el-table-column>
                    <el-table-column label="折扣" width="160px" align="center">
                      <template slot-scope="scope">
                        <el-input-number
                          v-model.number="scope.row.discount"
                          @input="validateDiscount(scope.row)"
                          placeholder="输入折扣"
                          size="small"
                          type="number"
                          :precision="1"
                          :step="0.1"
                          :max="10"
                          :min="0"
                          :disabled="true"
                        >
                        </el-input-number>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="nowPrice"
                      label="实收金额"
                      align="center"
                    >
                    </el-table-column>
                    <el-table-column
                      prop="proCheckMethod"
                      label="是否空腹"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <dict-tag
                          :options="dict.type.sys_yes_no"
                          :value="scope.row.proCheckMethod"
                        />
                      </template>
                    </el-table-column>
                    <el-table-column label="操作" align="center" width="80px">
                      <template slot-scope="scope">
                        <el-button
                          size="mini"
                          type="text"
                          icon="el-icon-delete"
                          @click="handleDelete1(scope.row)"
                          title="删除"
                        >
                        </el-button>
                      </template>
                    </el-table-column>
                  </el-table>
                </div>
                <!-- <div style="text-align: center; margin-bottom: 10px">
                  已选项目列表
                </div> -->
                <!-- <div
                  style="
                    padding: 0px 6px;
                    border: 1px solid #e6ebf5;
                    max-height: 420px;
                    overflow: auto;
                  "
                >
                  <el-collapse v-model="index" accordion v-if="list3">
                > -->
                <!-- <el-collapse v-model="index" accordion v-if="list3">
                    <div
                      class="info1"
                      v-for="(item, index) in tableData1"
@@ -840,6 +968,16 @@
                            item.nowPrice +
                            "元)"
                          }}
                          <div style="font-size: 16px; margin-left: 20px">
                            已选项目条数:<span
                              style="
                                font-weight: 700 !important;
                                color: red;
                                margin-right: 5px;
                              "
                              >{{ item.list.length || 0 }}</span
                            >条
                          </div>
                        </template>
                        <el-table
                          :data="item.list"
@@ -855,7 +993,39 @@
                          </el-table-column>
                          <el-table-column prop="ordPrice" label="应收金额">
                          </el-table-column>
                          <el-table-column label="折扣">
                            <template slot-scope="scope">
                              <el-input-number
                                v-model.number="scope.row.discount"
                                @input="validateDiscount(scope.row)"
                                placeholder="输入折扣"
                                size="small"
                                type="number"
                                :precision="1"
                                :step="0.1"
                                :max="10"
                                :min="0"
                              >
                              </el-input-number>
                            </template>
                          </el-table-column>
                          <el-table-column prop="nowPrice" label="实收金额">
                          </el-table-column>
                          <el-table-column
                            label="操作"
                            align="center"
                            width="80px"
                          >
                            <template slot-scope="scope">
                              <el-button
                                size="mini"
                                type="text"
                                icon="el-icon-delete"
                                @click="handleDelete1(scope.row)"
                                title="删除"
                              >
                              </el-button>
                            </template>
                          </el-table-column>
                        </el-table>
                      </el-collapse-item>
@@ -926,8 +1096,8 @@
                        </el-table>
                      </el-collapse-item>
                    </div>
                  </el-collapse>
                </div>
                  </el-collapse> -->
                <!-- </div> -->
              </div>
            </el-col>
          </el-row>
@@ -949,6 +1119,49 @@
        </div>
      </template>
    </el-drawer>
    <el-dialog
      title="PDF 预览"
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
    >
      <div class="main">
        <iframe
          id="printIframe"
          :src="url"
          frameborder="0"
          style="width: 100%; height: 100%"
        ></iframe>
      </div>
    </el-dialog>
    <el-dialog
      :title="title"
      :visible.sync="open2"
      width="800px"
      append-to-body
    >
      <el-form ref="form" :model="forms" label-width="100px" :inline="true">
        <el-form-item label="体检类别">
          <el-select
            style="width: 150px"
            v-model="forms.tjCategory"
            placeholder="请选择体检类别"
          >
            <el-option
              v-for="dict in dict.type.dict_tjtype"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer2">
        <el-button type="primary" @click="submitType">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <div
      style="
@@ -1361,9 +1574,6 @@
                        ></el-option>
                      </el-select>
                    </el-form-item>
                    <!-- <div class="tab1"> -->
                    <!-- <el-form :inline="true" class="tab1"> -->
                    <el-form-item label="应收金额">
                      <el-input
                        placeholder="应收金额"
@@ -1373,7 +1583,6 @@
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="优惠折扣">
                      <!-- <el-input style="width: 100px" type="number" v-model="discount" :value="discount"></el-input> -->
                      <el-input-number
                        ref="inputNumber"
                        style="width: 130px"
@@ -1411,7 +1620,101 @@
                <div style="text-align: center; margin-bottom: 10px">
                  已选项目列表
                </div>
                <div
                  style="
                    padding: 0px 6px;
                    border: 1px solid #e6ebf5;
                    max-height: 650%;
                    overflow: auto;
                    width: 916px;
                    margin-left: 35px;
                  "
                >
                  <el-table :data="tableData1" border style="width: 100%">
                    <el-table-column
                      prop="proName"
                      label="项目"
                      width="180"
                      align="center"
                    >
                    </el-table-column>
                    <el-table-column
                      prop="proType"
                      label="性别"
                      width="50"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <template v-if="isAll(scope.row.proType)">
                          全部
                        </template>
                        <template v-else>
                          <dict-tag
                            :options="dict.type.sys_user_sex"
                            :value="scope.row.proType"
                          />
                        </template>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="ordPrice"
                      label="应收金额"
                      align="center"
                    >
                    </el-table-column>
                    <el-table-column label="折扣" width="160px" align="center">
                      <template slot-scope="scope">
                        <el-input-number
                          v-model.number="scope.row.discount"
                          @input="validateDiscount(scope.row)"
                          placeholder="输入折扣"
                          size="small"
                          type="number"
                          :precision="1"
                          :step="0.1"
                          :max="10"
                          :min="0"
                          :disabled="true"
                        >
                        </el-input-number>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="nowPrice"
                      label="实收金额"
                      align="center"
                    >
                    </el-table-column>
                    <el-table-column
                      prop="proCheckMethod"
                      label="是否空腹"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <dict-tag
                          :options="dict.type.sys_yes_no"
                          :value="scope.row.proCheckMethod"
                        />
                      </template>
                    </el-table-column>
                    <el-table-column label="操作" align="center" width="80px">
                      <template slot-scope="scope">
                        <el-button
                          size="mini"
                          type="text"
                          icon="el-icon-delete"
                          @click="handleDelete1(scope.row)"
                          title="删除"
                        >
                        </el-button>
                      </template>
                    </el-table-column>
                  </el-table>
                </div>
                <!--  <div
                  style="
                    padding: 0px 6px;
                    border: 1px solid #e6ebf5;
@@ -1419,6 +1722,14 @@
                    overflow: auto;
                  "
                >
                  <div
                    style="
                      padding: 0px 6px;
                      border: 1px solid #e6ebf5;
                      max-height: 420px;
                      overflow: auto;
                    "
                  ></div>
                  <el-collapse v-model="index" accordion v-if="list3">
                    <div
                      class="info1"
@@ -1437,7 +1748,18 @@
                            item.nowPrice +
                            ".00元)"
                          }}
                          <div style="font-size: 16px; margin-left: 20px">
                            已选项目条数:<span
                              style="
                                font-weight: 700 !important;
                                color: red;
                                margin-right: 5px;
                              "
                              >{{ item.list.length || 0 }}</span
                            >条
                          </div>
                        </template>
                        <el-table
                          :data="item.list"
                          border
@@ -1457,6 +1779,22 @@
                          >
                          </el-table-column>
                          <el-table-column prop="ordPrice" label="应收金额">
                          </el-table-column>
                          <el-table-column label="折扣">
                            <template slot-scope="scope">
                              <el-input-number
                                v-model.number="scope.row.discount"
                                @input="validateDiscount(scope.row)"
                                placeholder="输入折扣"
                                size="small"
                                type="number"
                                :precision="1"
                                :step="0.1"
                                :max="10"
                                :min="0"
                              >
                              </el-input-number>
                            </template>
                          </el-table-column>
                          <el-table-column prop="nowPrice" label="实收金额">
                          </el-table-column>
@@ -1532,7 +1870,7 @@
                      </el-collapse-item>
                    </div>
                  </el-collapse>
                </div>
                </div> -->
              </div>
            </el-col>
          </el-row>
@@ -1558,8 +1896,9 @@
</template>
<script>
import { addComp } from "@/api/system/comp";
import { addComp, addPlOrderAndDetail } from "@/api/system/comp";
import Big from "big.js";
import { Loading } from "element-ui";
import {
  listReservation,
  gettjCancel,
@@ -1575,6 +1914,8 @@
  getaddtTransition,
  getTransitionList,
  getconfigKey,
  delTbBycusCardIdAndProId,
  getTransitionList1,
} from "@/api/system/tijian";
import { getCompany, queryCompany } from "@/api/team/tuanti";
import user from "@/store/modules/user";
@@ -1599,7 +1940,6 @@
  ],
  data() {
    let checkPhoneNum = (rule, value, callback) => {
      console.log(value);
      let patter = new RegExp(/^1\s*[3456789]\s*(\d\s*){9}$/);
      if (value == "" && value == undefined && !value) {
        return callback("");
@@ -1621,7 +1961,9 @@
          return time.getTime() < Date.now() - 8.64e7; // 不可选历史天、不可选当前天、可选未来天
        },
      },
      discount: 10,
      taocan: false,
      webSocket: null,
      defaultKeys: [],
      value1: "",
      pacName: "",
@@ -1632,6 +1974,10 @@
      dialogVisibles: false,
      src: "",
      url: "",
      open2: false,
      forms: {
        tjCategory: "12",
      },
      dialogVisible: false,
      /** 照相机弹窗模块-start */
      videoWidth: 200,
@@ -1689,6 +2035,7 @@
      // 是否显示弹出层
      pacId: "",
      cusIds: [],
      // 结果
      result: "",
      proIds: [],
@@ -1732,7 +2079,29 @@
        cusNumber: null,
        cusIsvip: null,
      },
      formIn: {},
      formIn: {
        name: "",
        age: "",
        idCard: "",
        remark: null,
        pacName: "",
        cusaddr: null,
        idType: null,
        ageUnit: null,
        sex: null,
        phoe: "",
        nation: null,
        email: "",
        marriage: null,
        address: "",
        tjCategory: null,
        company: "",
        career: null,
        reservationTime: null,
        timeRegion: null,
        indexCard: "",
        department: "",
      },
      fmobj: {},
      // 表单校验
      form1: {},
@@ -1801,6 +2170,7 @@
      reservationList: [],
      // 弹出层标题
      title: "",
      valueUrls: "ws://127.0.0.1:6789/websocket",
      drawer: false,
      drawer1: false,
      // 查询参数
@@ -1857,6 +2227,65 @@
    this.getList();
  },
  methods: {
    isAll(value) {
      return value === "" || value === null;
    },
    validateDiscount(row) {
      if (row.discount == null || isNaN(row.discount)) {
        row.discount = 10;
      }
      if (row.discount > 10) {
        row.discount = 10; // 强制将值设置为最大值
      } else if (row.discount < 0) {
        row.discount = 0; // 强制将值设置为最小值
      }
      this.updateProPrice(row); // 更新价格或其他逻辑
    },
    updateProPrice(row) {
      const ordPrice = new Big(row.ordPrice || 0);
      const discount = new Big(row.discount || 0);
      const result = ordPrice.times(discount.div(10)); // ordPrice * (discount / 10)
      row.nowPrice = result.toNumber();
      this.TotalPrice = this.tableData1.reduce((sum, item) => {
        return sum.plus(new Big(item.nowPrice || "0"));
      }, new Big(0));
      this.discount =
        (Math.floor((this.TotalPrice / this.TotalPrice1) * 100) / 100) * 10;
    },
    /** 删除按钮操作 */
    handleDelete1(row) {
      // console.log(row);
      let data = {
        cusCardId: row.cusId,
        proId: row.parentProId,
      };
      this.$modal
        .confirm("是否确认删除?")
        .then(() => {
          return delTbBycusCardIdAndProId(data);
        })
        .then(() => {
          this.TotalPrice1 = 0;
          getTransitionList1(row.cusId).then((response) => {
            this.tableData1 = response.data;
            this.tableData1.forEach((item) => {
              this.TotalPrice1 += item.ordPrice;
              this.TotalPrice += item.nowPrice;
            });
            this.TotalPrice = this.tableData1.reduce((sum, item) => {
              return sum.plus(new Big(item.nowPrice || "0"));
            }, new Big(0));
            this.discount =
              (Math.floor((this.TotalPrice / this.TotalPrice1) * 100) / 100) *
              10;
          });
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    getCompanyList() {
      this.loading = true;
      getconfigKey("team_reservation_default_day").then((res) => {
@@ -1928,6 +2357,7 @@
    // 取消按钮
    cancel() {
      this.open = false;
      this.open2 = false;
      this.reset();
    },
@@ -1991,10 +2421,10 @@
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.cusIds = selection.map((item) => item.idCard);
      selection.forEach((item) => {
        this.fmobj = item;
      });
      console.log(this.fmobj);
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
@@ -2009,7 +2439,6 @@
    /** 修改按钮操作 */
    handleUpdate(row) {
      console.log(row);
      this.title = "修改体检预约";
      this.formIn = row;
      this.form.tjType = this.formIn.tjType;
@@ -2073,14 +2502,13 @@
          getReservation(id).then((response) => {
            if (response.data) {
              let cusId = response.data.idCard;
              getTransitionList(cusId).then((response) => {
              getTransitionList1(cusId).then((response) => {
                if (response.data) {
                  this.tableData1 = response.data;
                  if (this.tableData1.length != 0) {
                    this.TotalPrice1 = 0;
                    this.tableData1.forEach((item) => {
                      this.TotalPrice1 += item.nowPrice;
                      console.log(this.discount);
                      this.TotalPrice = (
                        this.TotalPrice1 *
                        (this.discount / 10)
@@ -2184,9 +2612,10 @@
        getReservation(id).then((response) => {
          if (response.data) {
            let cusId = response.data.idCard;
            getTransitionList(cusId).then((response) => {
            getTransitionList1(cusId).then((response) => {
              if (response.data) {
                this.tableData1 = response.data;
                if (this.tableData1.length != 0) {
                  this.TotalPrice1 = 0;
                  this.tableData1.forEach((item) => {
@@ -2291,6 +2720,143 @@
      }
    },
    Groupsignin() {
      this.open2 = true;
    },
    submitType() {
      // let cusIds = [];
      // this.selectList.forEach((item) => {
      //   cusIds.push(item.idCard);
      // });
      let loadingInstance1 = Loading.service({
        fullscreen: true,
        text: "签到中",
      });
      let data = {
        cusIds: this.cusIds,
        tjCategory: this.forms.tjCategory,
      };
      this.open2 = false;
      addPlOrderAndDetail(data).then((res) => {
        if (res.code == 200) {
          this.open2 = false;
          this.$modal.msgSuccess("签到成功");
          if (res.file) {
            let base64 = res.file;
            this.base64ToBlob({
              b64data: base64,
              contentType: "application/pdf",
            }).then((res) => {
              this.dialogVisible = true;
              // 转后后的blob对象
              try {
                this.url = res.preview;
              } catch (error) {
                this.url = window.webkitURL.createObjectURL(res.preview);
              }
            });
          } else {
            let _this = this;
            this.$nextTick(() => {
              // 以服务的方式调用的 Loading 需要异步关闭
              loadingInstance1.close();
            });
            var websocket = null;
            var url = _this.valueUrls;
            if ("WebSocket" in window) {
              websocket = new WebSocket(url);
            } else if ("MozWebSocket" in window) {
              websocket = new MozWebSocket(url);
            } else {
            }
            if (websocket == null) {
              alert("11111");
            }
            websocket.onopen = function () {
              console.log('res',res);
              try {
                // 连接设备
                var jsonObjs = {
                  type: 4,
                  data: res,
                };
                var jStrs = JSON.stringify(jsonObjs);
                websocket.send(jStrs);
              } catch (err) {
                var tryTime = 0;
                // 重试10次,每次之间间隔3秒
                if (tryTime < 1) {
                  var t1 = setTimeout(function () {
                    tryTime++;
                    var jsonObjs = {
                      type: 4,
                      data: res,
                    };
                    var jStrs = JSON.stringify(jsonObjs);
                    websocket.send(jStrs);
                  }, 1 * 1000);
                } else {
                  console.error("重连失败.");
                }
              }
            };
            websocket.onclose = function () {
              alert("连接关闭");
            };
            websocket.onmessage = function (event) {
              var resultObj = JSON.parse(event.data);
              _this.cardreader = false;
            };
            //连接发生错误的回调方法
            websocket.onerror = function () {
              alert("请检查连接是否正常");
            };
            this.getList();
          }
        } else {
          this.$nextTick(() => {
            // 以服务的方式调用的 Loading 需要异步关闭
            loadingInstance1.close();
          });
        }
      });
    },
    base64ToBlob({ b64data = "", contentType = "", sliceSize = 512 } = {}) {
      return new Promise((resolve, reject) => {
        // 使用 atob() 方法将数据解码
        let byteCharacters = atob(b64data);
        let byteArrays = [];
        for (
          let offset = 0;
          offset < byteCharacters.length;
          offset += sliceSize
        ) {
          let slice = byteCharacters.slice(offset, offset + sliceSize);
          let byteNumbers = [];
          for (let i = 0; i < slice.length; i++) {
            byteNumbers.push(slice.charCodeAt(i));
          }
          // 8 位无符号整数值的类型化数组。内容将初始化为 0。
          // 如果无法分配请求数目的字节,则将引发异常。
          byteArrays.push(new Uint8Array(byteNumbers));
        }
        let result = new Blob(byteArrays, {
          type: contentType,
        });
        result = Object.assign(result, {
          // jartto: 这里一定要处理一下 URL.createObjectURL
          preview: URL.createObjectURL(result),
          // name: `图片示例.png`,
        });
        resolve(result);
      });
    },
    // 点击获取每个树节点
    handleCurrentChecked(data, checked, checkedNodes) {
      if (checked === true) {