wwl
2024-12-07 d194f4cd74da499f741100e5e3da5bcc3a0dc387
src/views/hosp/customer/index.vue
@@ -632,23 +632,23 @@
            style="width: 200px"
          />
        </el-form-item>
        <el-form-item label="单位名称" prop="dictCompId">
        <el-form-item label="单位名称" prop="compName">
          <el-select
            :remote-method="getRemoteData"
            v-model="form.compName"
            remote
            style="width: 300px"
                default-first-option
                allow-create
                filterable
                style="width: 200px"
            placeholder="请选择单位名称"
            clearable
            @change="idFn1"
          >
            <el-option
              v-for="dict in CompanyList"
              :key="dict.cnName"
              :label="dict.cnName"
              :value="dict.drugManufacturerId"
                  :value="dict.cnName"
            />
          </el-select>
          <i class="el-icon-circle-plus-outline" @click="handleAdd1"></i>
@@ -1128,6 +1128,7 @@
    submitFormS() {
      this.$refs["form1"].validate((valid) => {
        if (valid) {
          addComp(this.form1).then((response) => {
            this.$modal.msgSuccess("新增成功");
            this.open1 = false;
@@ -1137,14 +1138,24 @@
      });
    },
    idFn1(value) {
      console.log(value);
      if (value) {
        this.form.dictCompId = value;
        // 保存修改前的 dictCompId
        const originalCompId = this.form.dictCompId;
        // 更新公司名称
        this.form.compName = value;
        // 遍历公司列表,根据公司名称设置对应的 drugManufacturerId
        this.CompanyList.forEach((item) => {
          if (item.drugManufacturerId == this.form.dictCompId) {
            this.form.compName = item.cnName;
          if (item.cnName == this.form.compName) {
            this.form.dictCompId = item.drugManufacturerId;
          }
        });
        // 如果 dictCompId 没有变化,重置为空
        if (this.form.dictCompId === originalCompId) {
          this.form.dictCompId = '';
        }
      }
    },
    // 搜索
@@ -1427,10 +1438,6 @@
.dialog-footer {
  display: flex;
  justify-content: center;
}
.el-icon-circle-plus-outline {
  line-height: 20px;
  font-size: 20px;
}
.dialog-footer2 {
  width: 960px;