xwt
2025-08-03 c47ec7b37e7f68c49b40fc4b59098e79626e66de
pages/QC/XJ/Add.vue
@@ -24,10 +24,18 @@
              <view class="info-value">{{ formData.createDate }}</view>
            </view>
            <view class="info-item">
              <view class="info-label">生产车间</view>
              <picker v-if="isUpdate" class="picker-input" name="selector" :range="departmentList" range-key="departmentname"
                      @change="onDepartmentChange">
                <view class="picker-value">{{ getSelectedDepartmentName() || '请选择车间' }}</view>
              </picker>
              <view v-else class="info-value">{{ WORKSHOP }}</view>
            </view>
            <view class="info-item">
              <view class="info-label">线体编号</view>
              <picker v-if="isUpdate" class="picker-input" name="selector" :range="DAA020List"
              <picker v-if="isUpdate" class="picker-input" name="selector" :range="filteredDAA020List"
                      @change="onDaa020Change">
                <view class="picker-value">{{ DAA020List[DAA020Index] || '请选择' }}</view>
                <view class="picker-value">{{ filteredDAA020List[DAA020Index] || '请选择' }}</view>
              </picker>
              <view v-else class="info-value">{{ formData.daa020 }}</view>
            </view>
@@ -40,7 +48,7 @@
              <view v-else class="info-value">{{ formData.itemNo }}</view>
            </view>
            <view class="info-item">
              <view class="info-label">计划编号</view>
              <view class="info-label">工单单号</view>
              <picker v-if="isUpdate" class="picker-input" name="selector" :range="DAA001List"
                      @change="onDaa001Change">
                <view class="picker-value">{{ DAA001List[DAA001Index] || '请选择' }}</view>
@@ -114,6 +122,8 @@
        <button class="action-btn warning" v-if="!isUpdate && !isShowTable" @click="saveRemarks">添加不合格描述</button>
        <button class="action-btn primary" v-if="isShowTable" @click="getTable">获取检验项目</button>
        <button class="action-btn primary" v-if="isShowTable && isUpdate" @click="saveTable">生成检验项目</button>
        <button class="action-btn success" v-if="!isUpdate && !isShowTable" @click="getGenUpdate">获取检验项目</button>
        <button class="action-btn success" v-if="!isUpdate && !isShowTable" @click="submitInspection">提交检验</button>
      </view>
      <!-- 修改不合格描述弹出框 -->
      <view v-if="remarksPopup" class="overlay">
@@ -161,6 +171,7 @@
  
        DAA020List: [],
        DAA020Index: -1,
        filteredDAA020List: [],
  
        DAA001List: [],
        DAA001Index: -1,
@@ -184,6 +195,11 @@
  
        remarks: "",
        remarksPopup: false,
        // 部门选择相关
        departmentList: [],
        selectedDepartment: '',
        WORKSHOP: '',
      };
    },
    onLoad(options) {
@@ -213,7 +229,11 @@
        }).then(res => {
          this.lineList = res.data.tbBillList;
          this.DAA020List = res.data.tbBillList.map(item => item.lineName);
          this.filteredDAA020List = this.DAA020List; // 初始时显示所有线体
        })
        // 获取部门列表
        this.loadDepartments();
      }
    },
    methods: {
@@ -260,13 +280,10 @@
      },
      getItem() {
  
        if (this.isSubmit) {
          this.$showMessage("此物料无启用的检验项目,请维护!");
          return;
        }
  
        if (!this.formData.billNo) {
          this.$showMessage("请选择计划编号");
          this.$showMessage("请选择工单单号");
          return;
        }
  
@@ -284,6 +301,81 @@
          this.isUpdate = false;
        });
      },
      // 加载部门列表
      loadDepartments() {
        this.$post({
          url: "/XJ/getDepartmentsWithLines"
        }).then(res => {
          if (res.status === 0) {
            this.departmentList = res.data.tbBillList;
          } else {
            this.$showMessage("获取部门列表失败");
          }
        });
      },
      // 部门选择变化处理
      onDepartmentChange(e) {
        const index = e.detail.value;
        if (index >= 0 && index < this.departmentList.length) {
          const selectedDept = this.departmentList[index];
          this.selectedDepartment = selectedDept.departmentid;
          this.WORKSHOP = selectedDept.departmentname;
          // 根据选中的部门过滤线体列表
          this.filterLinesByDepartment(selectedDept.departmentid);
          // 保存部门选择
          this.saveDepartmentSelection();
        }
      },
      // 获取选中的部门名称
      getSelectedDepartmentName() {
        if (!this.selectedDepartment) return '';
        const dept = this.departmentList.find(item => item.departmentid === this.selectedDepartment);
        return dept ? dept.departmentname : '';
      },
      // 保存部门选择
      saveDepartmentSelection() {
        if (this.formData.id && this.selectedDepartment) {
          this.$post({
            url: "/XJ/saveDepartmentSelection",
            data: {
              id: this.formData.id,
              departmentId: this.selectedDepartment,
              departmentName: this.WORKSHOP
            }
          }).then(res => {
            if (res.status === 0) {
              this.$showMessage("部门选择已保存");
            }
          });
        }
      },
      // 根据部门过滤线体列表
      filterLinesByDepartment(departmentId) {
        this.$post({
          url: "/XJ/getLinesByDepartment",
          data: {
            departmentId: departmentId
          }
        }).then(res => {
          if (res.status === 0) {
            this.filteredDAA020List = res.data.tbBillList.map(item => item.lineName);
            this.lineList = res.data.tbBillList;
            // 重置线体选择索引
            this.DAA020Index = -1;
            this.formData.daa020 = '';
          } else {
            this.$showMessage("获取线体列表失败");
          }
        });
      },
      //生产线别选择并初始话工单号
      onDaa020Change(event) {
        //获取生产线别的下标地址
@@ -480,6 +572,43 @@
          this.isUpdate = false;
          this.init();
        })
      },
      submitInspection() {
        if (this.formData.id) {
          this.$post({
            url: "/XJ/SjSubmit",
            data: {
              id: this.formData.id,
              userNo: this.$loginInfo.account
            }
          }).then(res => {
            if (res.data.tbBillList) {
              this.$showMessage("提交成功");
              this.init();
            }
          });
        }
      },
      getGenUpdate() {
        if (!this.formData.id || !this.formData.releaseNo) {
          this.$showMessage("请先保存检验单!");
          return;
        }
        this.$post({
          url: "/XJ/GenUpdate",
          data: {
            id: this.formData.id,
            no: this.formData.releaseNo,
            user: this.$loginInfo.account
          }
        }).then(res => {
          if (res.data.result === 0) {
            this.$showMessage("获取检验项目成功");
            this.init();
          } else {
            this.$showMessage(res.data.message || "获取失败");
          }
        });
      }
    },
    onShow() {
@@ -725,6 +854,11 @@
    color: white;
  }
  
  .action-btn.success {
    background-color: #2ecc71;
    color: white;
  }
  /* 弹出框样式 */
  .overlay {
    position: fixed;