|
@@ -0,0 +1,406 @@
|
|
|
+<template>
|
|
|
+ <!-- 添加或修改项目信息对话框 -->
|
|
|
+ <el-dialog
|
|
|
+ title="废品回用"
|
|
|
+ v-model="visible"
|
|
|
+ width="900px"
|
|
|
+ append-to-body
|
|
|
+ draggable
|
|
|
+ >
|
|
|
+ <div class="form-container">
|
|
|
+ <el-row :gutter="20" style="margin: 20px 0 0 38px">
|
|
|
+ <el-col :span="9">
|
|
|
+ <span>产品描述</span>
|
|
|
+ <span style="margin-left: 10px">{{
|
|
|
+ detailsRow.productDescription
|
|
|
+ }}</span>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-form
|
|
|
+ ref="wasteRecyclingRef"
|
|
|
+ class="master-container"
|
|
|
+ v-loading="loading"
|
|
|
+ :model="form"
|
|
|
+ label-width="100px"
|
|
|
+ :rules="rules"
|
|
|
+ >
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="参考批号" label-width="90px">
|
|
|
+ <el-input
|
|
|
+ v-model.trim="detailsRow.lotCode"
|
|
|
+ :disabled="true"
|
|
|
+ >
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="生成批数" label-width="90px" prop="lotNumber">
|
|
|
+ <el-input
|
|
|
+ v-model="form.lotNumber"
|
|
|
+ style="width: 200px"
|
|
|
+ @input="handleUpdateLotNumber"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="单批量" label-width="90px" prop="productionQuantity">
|
|
|
+ <el-input-number
|
|
|
+ v-model="form.productionQuantity"
|
|
|
+ controls-position="right"
|
|
|
+ style="width: 150px"
|
|
|
+ :min="0"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="新生成批号" label-width="90px">
|
|
|
+ <el-input
|
|
|
+ type="textarea"
|
|
|
+ v-model.trim="form.newLots"
|
|
|
+ :disabled="true"
|
|
|
+ style="width: 660px"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ <div>
|
|
|
+ <span style="font-size: 18px; font-weight: 700; line-height: 25px"
|
|
|
+ >工序</span
|
|
|
+ >
|
|
|
+ <!-- <div style="float: inline-end">
|
|
|
+ <span
|
|
|
+ style="
|
|
|
+ color: rgba(0, 203, 117, 1);
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: 400;
|
|
|
+ line-height: 23px;
|
|
|
+ cursor: pointer;
|
|
|
+ display: inline-block;
|
|
|
+ "
|
|
|
+ @click="handleAddPreProcess"
|
|
|
+ >+从历史工艺添加</span
|
|
|
+ >
|
|
|
+ <span
|
|
|
+ style="
|
|
|
+ margin-left: 30px;
|
|
|
+ color: rgba(232, 122, 0, 1);
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: 400;
|
|
|
+ line-height: 23px;
|
|
|
+ cursor: pointer;
|
|
|
+ display: inline-block;
|
|
|
+ "
|
|
|
+ @click="handleAddProcess"
|
|
|
+ >+从工序库添加</span
|
|
|
+ >
|
|
|
+ </div> -->
|
|
|
+ </div>
|
|
|
+ <div id="insideProcessForm">
|
|
|
+ <el-table
|
|
|
+ class="elTable"
|
|
|
+ ref="dialogTable"
|
|
|
+ :data="processList"
|
|
|
+ :row-key="getRowKey"
|
|
|
+ size="small"
|
|
|
+ v-loading="loading"
|
|
|
+ border
|
|
|
+ height="360px"
|
|
|
+ header-row-class-name="list-header-row"
|
|
|
+ row-class-name="currentRow"
|
|
|
+ >
|
|
|
+ <el-table-column label="移动" width="50" align="center">
|
|
|
+ <div class="move-handle">
|
|
|
+ <el-icon>
|
|
|
+ <Rank />
|
|
|
+ </el-icon>
|
|
|
+ </div>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="工序编码" align="center" prop="processCode" />
|
|
|
+ <el-table-column
|
|
|
+ label="工序简称"
|
|
|
+ align="center"
|
|
|
+ prop="processAlias"
|
|
|
+ />
|
|
|
+ <el-table-column
|
|
|
+ fixed="right"
|
|
|
+ label="操作"
|
|
|
+ align="center"
|
|
|
+ width="140px"
|
|
|
+ >
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button
|
|
|
+ link
|
|
|
+ type="danger"
|
|
|
+ icon="Delete"
|
|
|
+ @click="handleDeleteProcess(scope.row)"
|
|
|
+ >删除
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ <!-- 分页 -->
|
|
|
+ <pagination
|
|
|
+ v-show="total > 0"
|
|
|
+ :total="total"
|
|
|
+ v-model:page="queryParams.pageNum"
|
|
|
+ v-model:limit="queryParams.pageSize"
|
|
|
+ @pagination="getTechnologicalProcessDetail"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <template #footer>
|
|
|
+ <el-button type="primary" icon="Check" @click="handleSave"
|
|
|
+ >保存</el-button
|
|
|
+ >
|
|
|
+ <el-button icon="Close" @click="handleCancel">取 消</el-button>
|
|
|
+ </template>
|
|
|
+ <!-- 工序库选择工序 -->
|
|
|
+ <processChoice
|
|
|
+ ref="processChoiceRef"
|
|
|
+ :multiple-selected="handleProcessSelected"
|
|
|
+ />
|
|
|
+ </el-dialog>
|
|
|
+</template>
|
|
|
+<script setup>
|
|
|
+import { getLastLot } from "@/api/business/lot";
|
|
|
+import processChoice from "./DialogProcessChoice";
|
|
|
+import { onMounted, ref } from "vue";
|
|
|
+import Sortable from "sortablejs";
|
|
|
+const { proxy } = getCurrentInstance();
|
|
|
+const emit = defineEmits(["handleUpdateSuccess"]);
|
|
|
+/**工艺版本变更变量 */
|
|
|
+const loading = ref(false);
|
|
|
+let currentUID = ref(0);
|
|
|
+const processLoading = ref(false);
|
|
|
+const total = ref(0);
|
|
|
+const visible = ref(false);
|
|
|
+const detailsRow = ref({});
|
|
|
+const processList = ref([]);
|
|
|
+const referenceLotInfo = ref({});
|
|
|
+//校验生成批数
|
|
|
+const validateLotNumber = (rule, value, callback) => {
|
|
|
+ const min = 0;
|
|
|
+ if (value %1 !== 0) { // 检查是否无法解析为整数
|
|
|
+ callback(new Error(`当前生成批数不能是小数`));
|
|
|
+ } else if (value <= min) {
|
|
|
+ callback(new Error("当前生成批数应大于0"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+};
|
|
|
+//校验单批量
|
|
|
+const validateproductionQuantity = (rule, value, callback) => {
|
|
|
+ const min = 0;
|
|
|
+ if (value %1 !== 0) {
|
|
|
+ callback(new Error(`当前单批量不能是小数`));
|
|
|
+ } else if (value <= min) {
|
|
|
+ callback(new Error("当前单批量应大于0"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+};
|
|
|
+/**查询对象 */
|
|
|
+const data = reactive({
|
|
|
+ form: {},
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ referenceLot: null,
|
|
|
+ lotNumber: null,
|
|
|
+ productionQuantity: null,
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ lotNumber: [
|
|
|
+ { required: true, message: "生成批数不能为空", trigger: "blur" },
|
|
|
+ { validator: validateLotNumber, trigger: "blur" },
|
|
|
+ ],
|
|
|
+ productionQuantity: [
|
|
|
+ { required: true, message: "单批量不能为空", trigger: "blur" },
|
|
|
+ { validator: validateproductionQuantity, trigger: "blur" },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+});
|
|
|
+const { queryParams, form, rules } = toRefs(data);
|
|
|
+
|
|
|
+/*********************** 方法区 ****************************/
|
|
|
+/** 打开抽屉 */
|
|
|
+const open = (data) => {
|
|
|
+ reset();
|
|
|
+ detailsRow.value = proxy.deepClone(data[0]);
|
|
|
+ processList.value = [];
|
|
|
+ console.log(detailsRow.value);
|
|
|
+ visible.value = true;
|
|
|
+};
|
|
|
+//获得工艺版本列表
|
|
|
+function getTechnologicalProcessDetail() {
|
|
|
+ processLoading.value = true;
|
|
|
+ processLoading.value = false;
|
|
|
+}
|
|
|
+
|
|
|
+/** 表单重置 */
|
|
|
+const reset = () => {
|
|
|
+ form.value = {
|
|
|
+ id: null,
|
|
|
+ referenceLot: null,
|
|
|
+ lotNumber: null,
|
|
|
+ productionQuantity: null,
|
|
|
+ };
|
|
|
+ proxy.resetForm("wasteRecyclingRef");
|
|
|
+};
|
|
|
+/**生成批数变化*/
|
|
|
+function handleUpdateLotNumber() {
|
|
|
+ if (form.value.lotNumber > 0) {
|
|
|
+ //查询该计划单最后一个批数(排除分批的批次)
|
|
|
+ getLastLot({
|
|
|
+ productionPlanDetailId: detailsRow.value.productionPlanDetailId,
|
|
|
+ }).then((res) => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ var lastLot = res.data.lotCode;
|
|
|
+ var partOne = lastLot.substring(0, 8);
|
|
|
+ var partTwo = lastLot.substring(8, 11);
|
|
|
+ //获取生成批号
|
|
|
+ var prefix = partTwo.replace(/[0-9]/g, "");
|
|
|
+ var number = parseInt(partTwo.match(/[0-9]+/)[0]);
|
|
|
+ var numbers = [];
|
|
|
+ let currentNumber = number;
|
|
|
+ for (let i = 0; i < form.value.lotNumber; i++) {
|
|
|
+ var newNumber = currentNumber + (i + 1);
|
|
|
+ numbers.push(
|
|
|
+ prefix +
|
|
|
+ newNumber
|
|
|
+ .toString()
|
|
|
+ .padStart(partTwo.match(/[0-9]+/)[0].length, "0")
|
|
|
+ );
|
|
|
+ }
|
|
|
+ var lots = [];
|
|
|
+ for (let i = 0; i < numbers.length; i++) {
|
|
|
+ lots.push(partOne + numbers[i] + "0");
|
|
|
+ }
|
|
|
+ form.value.newLots = lots;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**工序删除 */
|
|
|
+function handleDeleteProcess(row) {
|
|
|
+ processList.value.splice(processList.value.indexOf(row), 1);
|
|
|
+}
|
|
|
+/** 提交按钮 */
|
|
|
+const handleSave = () => {
|
|
|
+ proxy.$refs["wasteRecyclingRef"].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ var wasteRecyclingInfo = {}
|
|
|
+ for (var i = 0; i < processList.value.length; i++) {
|
|
|
+ processList.value[i].processStepNumber= 1000 + i * 10;
|
|
|
+ }
|
|
|
+ wasteRecyclingInfo.lotCodeList = form.value.newLots;
|
|
|
+ wasteRecyclingInfo.productionPlanDetailId = detailsRow.value.productionPlanDetailId
|
|
|
+ wasteRecyclingInfo.technologicalProcessId = referenceLotInfo.value.technologicalProcessId
|
|
|
+ wasteRecyclingInfo.technologyVersion = referenceLotInfo.value.technologyVersion
|
|
|
+ wasteRecyclingInfo.productId = detailsRow.value.product.id
|
|
|
+ wasteRecyclingInfo.productionQuantity = form.value.productionQuantity
|
|
|
+ wasteRecyclingInfo.processList = processList.value
|
|
|
+ //废品回用的批号
|
|
|
+ wasteRecyclingInfo.lotCode = detailsRow.value.lotCode
|
|
|
+ console.log(wasteRecyclingInfo)
|
|
|
+ //保存废品回用
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+/**参考批次带回 */
|
|
|
+function handleLotSelected(selection) {
|
|
|
+ console.log(selection);
|
|
|
+ referenceLotInfo.value = selection;
|
|
|
+ form.value.referenceLot = selection.lotCode;
|
|
|
+ processList.value = []
|
|
|
+}
|
|
|
+/**添加历史工艺 */
|
|
|
+function handleAddPreProcess() {
|
|
|
+ currentUID = processList.value.length + 1;
|
|
|
+ processList.value = []
|
|
|
+ for(var i = 0; i < referenceLotInfo.value.technologicalProcessDetailList.length; i++) {
|
|
|
+ let process = {}
|
|
|
+ process.technologicalProcessId = referenceLotInfo.value.technologicalProcessId
|
|
|
+ process.technologyVersion = referenceLotInfo.value.technologyVersion
|
|
|
+ process.productId = detailsRow.value.product.id
|
|
|
+ process.productCode = referenceLotInfo.value.technologicalProcessDetailList[i].productCode
|
|
|
+ process.processId = referenceLotInfo.value.technologicalProcessDetailList[i].processId
|
|
|
+ process.processKey = referenceLotInfo.value.technologicalProcessDetailList[i].processKey
|
|
|
+ process.processCode = referenceLotInfo.value.technologicalProcessDetailList[i].processCode
|
|
|
+ process.processAlias = referenceLotInfo.value.technologicalProcessDetailList[i].processAlias
|
|
|
+ process.productShaftCategory = referenceLotInfo.value.technologicalProcessDetailList[i].productShaftCategory
|
|
|
+ process.productShaftCategoryName = referenceLotInfo.value.productShaftCategoryName
|
|
|
+ process.productDescription = referenceLotInfo.value.technologicalProcessDetailList[i].productDescription
|
|
|
+ process.uuid = currentUID++;
|
|
|
+ processList.value.push(process)
|
|
|
+ }
|
|
|
+ console.log(processList.value)
|
|
|
+
|
|
|
+ rowDrop()
|
|
|
+}
|
|
|
+/** 行拖拽 */
|
|
|
+function rowDrop() {
|
|
|
+ // 要侦听拖拽响应的DOM对象
|
|
|
+ const tbody = document.querySelector('#insideProcessForm .el-table__body-wrapper tbody')
|
|
|
+ Sortable.create(tbody, {
|
|
|
+ // 指定父元素下可被拖拽的子元素
|
|
|
+ handle: '.move-handle',
|
|
|
+ // 结束拖拽后的回调函数
|
|
|
+ onEnd({ newIndex, oldIndex }) {
|
|
|
+ const currentRow = processList.value.splice(oldIndex, 1)[0]
|
|
|
+ processList.value.splice(newIndex, 0, currentRow)
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+/**工序库添加工序 */
|
|
|
+function handleAddProcess() {
|
|
|
+ proxy.$refs.processChoiceRef.open();
|
|
|
+}
|
|
|
+
|
|
|
+/**工序库添加工序带回 */
|
|
|
+function handleProcessSelected(selection) {
|
|
|
+ console.log(detailsRow.value.product)
|
|
|
+ currentUID = processList.value.length + 1;
|
|
|
+ for (var i = 0; i < selection.length; i++) {
|
|
|
+ var processAdd = {};
|
|
|
+ //工艺从参考工艺取
|
|
|
+ processAdd.technologicalProcessId = referenceLotInfo.value.technologicalProcessId
|
|
|
+ processAdd.technologyVersion = referenceLotInfo.value.technologyVersion
|
|
|
+ processAdd.productId = detailsRow.value.product.id;
|
|
|
+ processAdd.productCode = detailsRow.value.product.productCode;
|
|
|
+ processAdd.processId = selection[i].id;
|
|
|
+ processAdd.processAlias = selection[i].processAlias;
|
|
|
+ processAdd.processCode = selection[i].processCode;
|
|
|
+ processAdd.productShaftCategory =detailsRow.value.product.shaftCategoryCode;
|
|
|
+ processAdd.productShaftCategoryName = referenceLotInfo.value.productShaftCategoryName;
|
|
|
+ processAdd.processKey = selection[i].processKey;
|
|
|
+ processAdd.productDescription = referenceLotInfo.value.productDescription
|
|
|
+ processAdd.uuid = currentUID++;
|
|
|
+ processList.value.push(processAdd);
|
|
|
+ }
|
|
|
+ console.log(processList.value);
|
|
|
+ rowDrop()
|
|
|
+}
|
|
|
+/** 获取行 id */
|
|
|
+function getRowKey(row) {
|
|
|
+ return row.uuid;
|
|
|
+}
|
|
|
+/** 取消按钮 */
|
|
|
+const handleCancel = () => {
|
|
|
+ visible.value = false;
|
|
|
+ reset();
|
|
|
+};
|
|
|
+
|
|
|
+/** 暴露给父组件的方法 */
|
|
|
+defineExpose({
|
|
|
+ open,
|
|
|
+});
|
|
|
+</script>
|