gongchunyi
12 小时以前 9689c0418e2a71a36ae2ebef79a0db329ca428bf
src/views/qualityManagement/rawMaterialInspection/components/formDia.vue
@@ -14,6 +14,7 @@
                  v-model="form.supplier"
                  placeholder="请选择"
                  clearable
                  :disabled="supplierQuantityDisabled"
              >
                <el-option
                    v-for="item in supplierList"
@@ -71,13 +72,20 @@
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="单位:" prop="unit">
              <el-input v-model="form.unit" disabled/>
              <el-input v-model="form.unit" placeholder="自动带出" readonly class="readonly-display"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="厚度:" prop="thickness">
              <el-input v-model="form.thickness" placeholder="自动带出" readonly class="readonly-display"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="数量:" prop="quantity">
              <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="form.quantity" placeholder="请输入"
                               clearable :precision="2"/>
                               clearable :precision="2" :disabled="supplierQuantityDisabled"/>
            </el-form-item>
          </el-col>
        </el-row>
@@ -144,7 +152,7 @@
</template>
<script setup>
import {ref, reactive, toRefs, getCurrentInstance, nextTick} from "vue";
import {ref, reactive, toRefs, computed, getCurrentInstance, nextTick} from "vue";
import {getOptions} from "@/api/procurementManagement/procurementLedger.js";
import {modelList, productTreeList} from "@/api/basicData/product.js";
import {qualityInspectAdd, qualityInspectUpdate} from "@/api/qualityManagement/rawMaterialInspection.js";
@@ -168,6 +176,7 @@
    model: "",
    testStandardId: "",
    unit: "",
    thickness: "",
    quantity: "",
    checkCompany: "",
    checkResult: "",
@@ -180,6 +189,7 @@
    productModelId: [{required: true, message: "请选择产品型号", trigger: "change"}],
    testStandardId: [{required: false, message: "请选择指标", trigger: "change"}],
    unit: [{required: false, message: "请输入", trigger: "blur"}],
    thickness: [{required: false, message: "请输入", trigger: "blur"}],
    quantity: [{required: true, message: "请输入", trigger: "blur"}],
    checkCompany: [{required: false, message: "请输入", trigger: "blur"}],
    checkResult: [{required: true, message: "请选择检测结果", trigger: "change"}],
@@ -220,6 +230,12 @@
const modelOptions = ref([]);
const userList = ref([]); // 检验员下拉列表
// 编辑时:productMainId 或 purchaseLedgerId 任一有值则供应商、数量置灰
const supplierQuantityDisabled = computed(() => {
  const v = form.value || {};
  return !!(v.productMainId != null || v.purchaseLedgerId != null);
});
// 打开弹框
const openDialog = async (type, row) => {
  operationType.value = type;
@@ -245,6 +261,7 @@
    model: "",
    testStandardId: "",
    unit: "",
    thickness: "",
    quantity: "",
    checkCompany: "",
    checkResult: "",
@@ -327,6 +344,7 @@
const getModels = (value) => {
  form.value.productModelId = undefined;
  form.value.unit = undefined;
  form.value.thickness = undefined;
  modelOptions.value = [];
  currentProductId.value = value
  form.value.productName = findNodeById(productOptions.value, value);
@@ -339,8 +357,10 @@
};
const handleChangeModel = (value) => {
  form.value.model = modelOptions.value.find(item => item.id == value)?.model || '';
  form.value.unit = modelOptions.value.find(item => item.id == value)?.unit || '';
  const selectedModel = modelOptions.value.find(item => item.id == value);
  form.value.model = selectedModel?.model || '';
  form.value.unit = selectedModel?.unit || '';
  form.value.thickness = selectedModel?.thickness ?? '';
}
const findNodeById = (nodes, productId) => {
@@ -457,4 +477,15 @@
<style scoped>
:deep(.readonly-display .el-input__wrapper) {
  background-color: var(--el-disabled-bg-color);
  box-shadow: 0 0 0 1px var(--el-disabled-border-color) inset;
}
:deep(.readonly-display .el-input__inner) {
  color: var(--el-disabled-text-color);
  -webkit-text-fill-color: var(--el-disabled-text-color);
  cursor: not-allowed;
}
</style>