feat(钢卷信息): 添加暂存功能及暂存数据恢复功能
实现钢卷信息编辑的暂存功能,包括: 1. 添加暂存按钮及暂存逻辑 2. 添加暂存数据检测及恢复弹窗 3. 实现暂存数据的展示、使用和删除功能
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
<span>钢卷信息更新</span>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<el-button size="small" @click="saveTemp" :loading="loading">暂存内容</el-button>
|
||||
<el-button type="primary" size="small" @click="handleSave" :loading="loading">保存更新</el-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -331,6 +332,38 @@
|
||||
<el-button type="primary" @click="saveAbnormal">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 暂存数据展示弹窗 -->
|
||||
<el-dialog title="发现暂存数据" :visible.sync="cacheDialogVisible" width="800px" append-to-body>
|
||||
<div>
|
||||
<el-alert title="检测到您之前有暂存的钢卷信息,是否恢复使用?" type="info" show-icon :closable="false"></el-alert>
|
||||
<el-divider content-position="left">暂存的表单数据</el-divider>
|
||||
<el-descriptions :column="2" border size="small">
|
||||
<el-descriptions-item label="当前钢卷号">{{ parsedCacheData && parsedCacheData.updateForm && parsedCacheData.updateForm.currentCoilNo || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="班组">{{ parsedCacheData && parsedCacheData.updateForm && parsedCacheData.updateForm.team || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="材料类型">{{ parsedCacheData && parsedCacheData.updateForm && parsedCacheData.updateForm.materialType || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="质量状态">{{ parsedCacheData && parsedCacheData.updateForm && parsedCacheData.updateForm.qualityStatus || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="净重">{{ parsedCacheData && parsedCacheData.updateForm && parsedCacheData.updateForm.netWeight || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="备注">{{ parsedCacheData && parsedCacheData.updateForm && parsedCacheData.updateForm.remark || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-divider v-if="parsedCacheData && parsedCacheData.abnormals && parsedCacheData.abnormals.length > 0" content-position="left">暂存的异常信息({{ parsedCacheData.abnormals.length }}条)</el-divider>
|
||||
<div v-if="parsedCacheData && parsedCacheData.abnormals && parsedCacheData.abnormals.length > 0" class="abnormal-container" style="margin-bottom: 20px;">
|
||||
<div v-for="(abnormal, index) in parsedCacheData.abnormals" :key="index" class="abnormal-item">
|
||||
<div class="abnormal-content">
|
||||
<div class="abnormal-info">
|
||||
<div class="abnormal-position">{{ getAbnormalPositionText(abnormal.position) }}</div>
|
||||
<div class="abnormal-code">{{ getAbnormalCodeText(abnormal.defectCode) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="cacheDialogVisible = false">暂不使用</el-button>
|
||||
<el-button type="danger" @click="deleteCache">删除暂存</el-button>
|
||||
<el-button type="primary" @click="useCacheData">使用暂存数据</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -339,6 +372,7 @@ import { getMaterialCoil, updateMaterialCoil, getMaterialCoilTrace } from '@/api
|
||||
import { completeAction, getPendingAction } from '@/api/wms/pendingAction';
|
||||
import { listWarehouse } from '@/api/wms/warehouse';
|
||||
import { getAcidTypingPrefill } from '@/api/pocket/acidTyping';
|
||||
import { saveCoilCache, getCoilCacheByCoilId, delCoilCache } from '@/api/wms/coilCache';
|
||||
import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect";
|
||||
import RawMaterialSelect from "@/components/KLPService/RawMaterialSelect";
|
||||
import ProductSelect from "@/components/KLPService/ProductSelect";
|
||||
@@ -489,6 +523,10 @@ export default {
|
||||
remark: null
|
||||
},
|
||||
contractList: [],
|
||||
// 缓存相关
|
||||
cacheDialogVisible: false,
|
||||
currentCache: null,
|
||||
parsedCacheData: null,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -625,6 +663,27 @@ export default {
|
||||
if (actionId) {
|
||||
this.actionId = actionId;
|
||||
}
|
||||
|
||||
// 检测是否有暂存数据
|
||||
if (coilId) {
|
||||
try {
|
||||
const res = await getCoilCacheByCoilId(coilId);
|
||||
if (res.code === 200 && res.data) {
|
||||
this.currentCache = res.data;
|
||||
try {
|
||||
this.parsedCacheData = JSON.parse(res.data.coilJson);
|
||||
} catch (e) {
|
||||
this.parsedCacheData = null;
|
||||
this.$message.warning('暂存数据解析失败');
|
||||
return;
|
||||
}
|
||||
// 显示缓存对话框
|
||||
this.cacheDialogVisible = true;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('查询暂存失败', error);
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 处理材料类型变化
|
||||
@@ -963,6 +1022,60 @@ export default {
|
||||
if (!dict) return code;
|
||||
const item = dict.find(item => item.value === code);
|
||||
return item ? item.label : code;
|
||||
},
|
||||
|
||||
// 暂存表单内容
|
||||
async saveTemp() {
|
||||
try {
|
||||
this.loading = true;
|
||||
const cacheData = {
|
||||
updateForm: this.updateForm,
|
||||
abnormals: this.abnormals
|
||||
};
|
||||
const data = {
|
||||
coilId: this.currentInfo.coilId,
|
||||
coilJson: JSON.stringify(cacheData)
|
||||
};
|
||||
const res = await saveCoilCache(data);
|
||||
if (res.code === 200) {
|
||||
this.$message.success('暂存成功');
|
||||
} else {
|
||||
this.$message.error('暂存失败:' + res.msg);
|
||||
}
|
||||
} catch (error) {
|
||||
this.$message.error('暂存异常:' + error.message);
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
// 使用暂存数据
|
||||
useCacheData() {
|
||||
if (this.parsedCacheData && this.parsedCacheData.updateForm) {
|
||||
this.updateForm = { ...this.parsedCacheData.updateForm };
|
||||
if (this.parsedCacheData.abnormals) {
|
||||
this.abnormals = [...this.parsedCacheData.abnormals];
|
||||
}
|
||||
this.$message.success('已恢复暂存数据');
|
||||
}
|
||||
this.cacheDialogVisible = false;
|
||||
},
|
||||
|
||||
// 删除暂存
|
||||
async deleteCache() {
|
||||
this.$confirm('确定要删除这个暂存吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
try {
|
||||
await delCoilCache(this.currentCache.cacheId);
|
||||
this.$message.success('删除暂存成功');
|
||||
this.cacheDialogVisible = false;
|
||||
} catch (error) {
|
||||
this.$message.error('删除暂存失败:' + error.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user