yyb
21 小时以前 dacc95761cf7090c628fc37a5d4f8bb825ccbbb0
src/views/productionManagement/productionProcess/index.vue
@@ -44,17 +44,18 @@
            <div class="card-body">
              <!-- <div class="process-name">{{ process.name }}</div> -->
              <div class="process-desc">{{ process.remark || '暂无描述' }}</div>
              <div class="process-device">关联设备: {{ process.deviceName || '未关联' }}</div>
              <div class="process-device">关联设备: {{ deviceOptions.find(item => item.id === Number(process.deviceLedgerId))?.deviceName|| '未关联' }}</div>
            </div>
            <div class="card-footer">
              <div class="status-tag"> <el-tag size="small"
                        :type="process.status ? 'success' : 'info'">
                  {{ process.status ? '启用' : '停用' }}
              <div class="status-tag">
                <el-tag size="small"
                        :type="process.isQuality ? 'warning' : 'info'">
                  {{ process.isQuality ? '质检' : '非质检' }}
                </el-tag>
                <el-tag size="small"
                        :type="process.isQuality ? 'warning' : 'info'"
                        style="margin-left: 8px">
                  {{ process.isQuality ? '质检' : '非质检' }}
                        style="margin-left: 8px"
                        :type="process.isProduction ? 'warning' : 'info'">
                  {{ process.isProduction ? '生产' : '不生产' }}
                </el-tag>
                <el-tag v-if="process.type !== null && process.type !== undefined"
                        size="small"
@@ -127,6 +128,10 @@
                      prop="isQuality">
          <el-switch v-model="processForm.isQuality" />
        </el-form-item>
        <el-form-item label="是否生产"
                      prop="isProduction">
          <el-switch v-model="processForm.isProduction" />
        </el-form-item>
        <el-form-item label="计费类型"
                      prop="type">
          <el-radio-group v-model="processForm.type">
@@ -154,19 +159,12 @@
                    :rows="3"
                    placeholder="请输入工序描述" />
        </el-form-item>
        <el-form-item label="状态"
                      prop="status">
          <el-radio-group v-model="processForm.status">
            <el-radio :label="true">启用</el-radio>
            <el-radio :label="false">停用</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="processDialogVisible = false">取消</el-button>
          <el-button type="primary"
                     @click="handleProcessSubmit">确定</el-button>
          <el-button @click="processDialogVisible = false">取消</el-button>
        </span>
      </template>
    </el-dialog>
@@ -245,7 +243,6 @@
            </el-form-item>
            <el-form-item label="标准值">
              <el-input v-model="selectedParam.standardValue"
                        type="number"
                        placeholder="请输入默认值" />
            </el-form-item>
          </el-form>
@@ -255,10 +252,10 @@
      </div>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="paramDialogVisible = false">取消</el-button>
          <el-button type="primary"
                     :disabled="!selectedParam"
                     @click="handleParamSubmit">确定</el-button>
          <el-button @click="paramDialogVisible = false">取消</el-button>
        </span>
      </template>
    </el-dialog>
@@ -276,15 +273,14 @@
        <el-form-item label="标准值"
                      prop="standardValue">
          <el-input v-model="editParamForm.standardValue"
                    type="number"
                    placeholder="请输入标准值" />
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="editParamDialogVisible = false">取消</el-button>
          <el-button type="primary"
                     @click="handleEditParamSubmit">确定</el-button>
          <el-button @click="editParamDialogVisible = false">取消</el-button>
        </span>
      </template>
    </el-dialog>
@@ -292,7 +288,7 @@
</template>
<script setup>
  import { ref, reactive, onMounted } from "vue";
  import { ref, reactive, computed, onMounted } from "vue";
  import { ElMessage, ElMessageBox } from "element-plus";
  import { Plus, Edit, Delete, Search } from "@element-plus/icons-vue";
  import PIMTable from "@/components/PIMTable/PIMTable.vue";
@@ -317,8 +313,19 @@
  const processLoading = ref(false);
  const deviceOptions = ref([]);
  // 参数列表数据
  const paramList = ref([]);
  // 工序已选参数表格分页(接口一次返回全量)
  const paramPage2 = ref({
    current: 1,
    size: 10,
    total: 0,
  });
  const paramListRaw = ref([]);
  const paramList = computed(() => {
    const all = paramListRaw.value;
    const { current, size } = paramPage2.value;
    const start = (current - 1) * size;
    return all.slice(start, start + size);
  });
  const paramLoading = ref(false);
  // 数据字典
@@ -334,8 +341,8 @@
    name: "",
    salaryQuota: null,
    isQuality: false,
    isProduction: false,
    remark: "",
    status: true,
    deviceLedgerId: null,
    type: 0,
  });
@@ -381,11 +388,10 @@
  const editParamFormRef = ref(null);
  const editParamForm = reactive({
    id: null,
    processId: null,
    paramId: null,
    technologyOperationId: null,
    technologyParamId: null,
    paramName: "",
    standardValue: null,
    tenantId: 1,
  });
  const editParamRules = {
    standardValue: [
@@ -436,13 +442,6 @@
    {
      label: "取值格式",
      prop: "paramFormat",
      formatData: (val, row) => {
        if (row.paramType == "3") {
          const dict = dictTypes.value.find(item => item.dictType === val);
          return dict ? "字典:" + dict.dictName : val;
        }
        return val;
      },
    },
    {
      label: "标准值",
@@ -472,9 +471,13 @@
  // 获取工序列表
  const getProcessList = () => {
    processLoading.value = true;
    getProcessListApi()
    getProcessListApi({ size: -1, current: -1 })
      .then(res => {
        processValueList.value = res.data.records || [];
        console.log(
          processValueList.value,
          "reprocessValueList.value==========s"
        );
      })
      .catch(() => {
        ElMessage.error("获取工序列表失败");
@@ -493,23 +496,21 @@
    }
  };
  const paramPage2 = ref({
    current: 1,
    size: 10,
    total: 0,
  });
  // 获取参数列表
  const getParamList = processId => {
    paramLoading.value = true;
    console.log(paramPage2.value, "paramPage2.value");
    getProcessParamList(processId, {
      current: paramPage2.value.current,
      size: paramPage2.value.size,
    })
    getProcessParamList({ technologyOperationId: processId })
      .then(res => {
        paramList.value = res.data.records || [];
        paramPage2.value.total = res.data.total;
        const list = res.data || [];
        paramListRaw.value = Array.isArray(list) ? list : [];
        paramPage2.value.total = paramListRaw.value.length;
        const maxPage = Math.max(
          1,
          Math.ceil(paramPage2.value.total / paramPage2.value.size) || 1
        );
        if (paramPage2.value.current > maxPage) {
          paramPage2.value.current = maxPage;
        }
      })
      .catch(() => {
        ElMessage.error("获取参数列表失败");
@@ -522,6 +523,7 @@
  // 选择工序
  const selectProcess = process => {
    selectedProcess.value = process;
    paramPage2.value.current = 1;
    getParamList(process.id);
  };
@@ -533,24 +535,22 @@
    processForm.name = "";
    processForm.salaryQuota = null;
    processForm.isQuality = false;
    processForm.isProduction = false;
    processForm.remark = "";
    processForm.status = true;
    processForm.deviceLedgerId = null;
    processForm.type = 0;
    loadDeviceName();
    processDialogVisible.value = true;
  };
  const handleEditProcess = async process => {
    isProcessEdit.value = true;
    await loadDeviceName(); // Ensure deviceOptions is loaded before setting deviceLedgerId
    processForm.id = process.id;
    processForm.no = process.no;
    processForm.name = process.name;
    processForm.salaryQuota = process.salaryQuota;
    processForm.isQuality = !!process.isQuality;
    processForm.isProduction = !!process.isProduction;
    processForm.remark = process.remark || "";
    processForm.status = process.status;
    processForm.deviceLedgerId = Number(process.deviceLedgerId);
    processForm.type = process.type;
    processDialogVisible.value = true;
@@ -568,7 +568,8 @@
          getProcessList();
          if (selectedProcess.value?.id === process.id) {
            selectedProcess.value = null;
            paramList.value = [];
            paramListRaw.value = [];
            paramPage2.value.total = 0;
          }
        })
        .catch(() => {
@@ -712,11 +713,10 @@
  const handleEditParam = row => {
    editParamForm.id = row.id;
    editParamForm.processId = row.processId;
    editParamForm.paramId = row.paramId;
    editParamForm.technologyOperationId = row.technologyOperationId;
    editParamForm.technologyParamId = row.technologyParamId;
    editParamForm.paramName = row.paramName;
    editParamForm.standardValue = row.standardValue;
    editParamForm.tenantId = 1;
    editParamDialogVisible.value = true;
  };
@@ -742,10 +742,9 @@
      return;
    }
    addProcessParam({
      processId: selectedProcess.value.id,
      paramId: selectedParam.value.id,
      technologyOperationId: selectedProcess.value.id,
      technologyParamId: selectedParam.value.id,
      standardValue: selectedParam.value.standardValue,
      tenantId: 1,
    })
      .then(() => {
        ElMessage.success("添加成功");
@@ -758,10 +757,8 @@
  };
  const handleParamPagination = obj => {
    console.log(obj, "obj");
    paramPage2.value.current = obj.page;
    paramPage2.value.size = obj.limit;
    getParamList(selectedProcess.value.id);
  };
  // 获取数据字典
@@ -772,6 +769,7 @@
  };
  onMounted(() => {
    loadDeviceName();
    getProcessList();
    getDictTypes();
  });