diff --git a/src/api/repairTest/repair.js b/src/api/repairTest/repair.js
index 9d235c5..fbc2ec1 100644
--- a/src/api/repairTest/repair.js
+++ b/src/api/repairTest/repair.js
@@ -93,6 +93,35 @@ export function submitRepairApplyApiNew(data) {
data: data
})
}
+
+//机具设备管理--保存
+export function saveRepairApplyApiNew(data) {
+ return request({
+ url: '/material/base/repair/saveRepairApplyNew',
+ method: 'post',
+ contentType: 'application/json',
+ data: data
+ })
+}
+
+//清除 维修暂存
+export function clearSaveApi(data) {
+ return request({
+ url: '/material/base/repair/clearSaveRepairApplyNew',
+ method: 'post',
+ contentType: 'application/json',
+ data: data
+ })
+}
+
+//机具设备管理--获取维修暂存信息
+export function getSaveInfo(params) {
+ return request({
+ url: '/material/base/repair/getSaveInfo',
+ method: 'get',
+ params
+ })
+}
// 用户下拉选
export function getUserSelectApi(params) {
return request({
diff --git a/src/views/repairTest/repair/dialogOneForm.vue b/src/views/repairTest/repair/dialogOneForm.vue
index bffa4e0..f0be100 100644
--- a/src/views/repairTest/repair/dialogOneForm.vue
+++ b/src/views/repairTest/repair/dialogOneForm.vue
@@ -230,7 +230,9 @@
@@ -477,7 +479,9 @@
@@ -489,7 +493,10 @@ import {
listPartType,
getCostByPidAndNumApi,
- submitRepairApplyApiNew
+ submitRepairApplyApiNew,
+ saveRepairApplyApiNew,
+ getSaveInfo,
+ clearSaveApi,
} from '@/api/repairTest/repair'
// import { listPartType, } from "@/api/store/tools";
import Treeselect from '@riophae/vue-treeselect'
@@ -549,7 +556,7 @@ export default {
},
// 根据 manageType 动态返回要监听的表单数据
formToWatch() {
- return this.rowObj.manageType === 0 ? this.dynamicValidateForm.premiumList : this.dynamicValidateFormTwo.premiumListTwo;
+ return this.rowObj.manageType == 0 ? this.dynamicValidateForm.premiumList : this.dynamicValidateFormTwo.premiumListTwo;
}
},
data() {
@@ -654,7 +661,7 @@ export default {
if (value === '' || reg.test(value)) {
callback()
} else {
- callback(new Error('请输入大于0的数,最多2为小数'))
+ callback(new Error('请输入大于0的数,最多2位小数'))
}
},
//正则校验配件数量--维修数量
@@ -715,37 +722,69 @@ export default {
}
})
},
- init() {
+ async init() {
console.log('this.rowObj', this.rowObj)
- getInfo()
- .then((res) => {
- this.companyId = res.user.companyId
- this.currentUserId = res.user.userId
- // 返回 getUserSelectApi 的 Promise
- return getUserSelectApi({ roleIds: [133] })
+ try {
+ // 清空原有数据
+ this.dynamicValidateForm.premiumList = []
+ this.dynamicValidateFormTwo.premiumListTwo = []
+
+ if (this.rowObj.submitStatus === 1 && this.rowObj.manageType ==1) {
+ const res = await getSaveInfo({ typeId: this.rowObj.typeId,maId:this.rowObj.maId })
+ this.dynamicValidateFormTwo.premiumListTwo = res.data.partList.map((item, index) => ({
+ ...item,
+ key: `${Date.now()}_${index}` // 生成唯一 key
+ }))
+ this.dynamicValidateFormTwo.premiumListTwo.forEach((domain, index) => {
+ if (domain.partId) {
+ this.handleSelectTreeNum(domain.partId, index)
+ }
+ })
+ if(res.data.partList.length==0){
+ this.dynamicValidateFormTwo.premiumListTwo.push({repairer:res.data.repairer,updateTime:res.data.createTime,repairNum:res.data.repairNum})
+ }
+ }else if(this.rowObj.submitStatus === 1 && this.rowObj.manageType ==0){
+ const res = await getSaveInfo({ typeId: this.rowObj.typeId,maId:this.rowObj.maId })
+ this.dynamicValidateForm.premiumList = res.data.partList.map((item, index) => ({
+ ...item,
+ key: `${Date.now()}_${index}` // 生成唯一 key
+ }))
+ this.dynamicValidateForm.premiumList.forEach((domain, index) => {
+ if (domain.partId) {
+ this.handleSelectTreeNum(domain.partId, index)
+ }
+ })
+ if(res.data.partList.length==0){
+ this.dynamicValidateForm.premiumList.push({repairer:res.data.repairer,updateTime:res.data.createTime,repairNum:res.data.repairNum})
+ }
+
+ }else {
+ if (this.rowObj.manageType === 0) {
+ this.addDomainOne()
+ } else {
+ this.addDomainTwo()
+ }
+ this.dynamicValidateForm.premiumList.forEach((item) => {
+ item.repairRemark = this.rowObj.repairRemark
})
- .then((response) => {
- this.userSelectList = response.data
- if (this.rowObj.manageType == 0) {
- this.dynamicValidateForm.premiumList = []
- this.dynamicValidateFormTwo.premiumListTwo = []
- this.addDomainOne()
- } else {
- this.dynamicValidateForm.premiumList = []
- this.dynamicValidateFormTwo.premiumListTwo = []
- this.addDomainTwo()
- }
- this.dynamicValidateForm.premiumList.forEach((item) => {
- item.repairRemark = this.rowObj.repairRemark
- })
- this.dynamicValidateFormTwo.premiumListTwo.forEach((item) => {
- item.repairRemark = this.rowObj.repairRemark
- })
- })
- .catch((error) => {
- console.error('初始化出错:', error)
- })
- },
+ this.dynamicValidateFormTwo.premiumListTwo.forEach((item) => {
+ item.repairRemark = this.rowObj.repairRemark
+ })
+
+ }
+
+
+ // 获取用户信息和用户选择列表
+ const userInfoRes = await getInfo()
+ this.companyId = userInfoRes.user.companyId
+ this.currentUserId = userInfoRes.user.userId
+
+ const userSelectRes = await getUserSelectApi({ roleIds: [133] })
+ this.userSelectList = userSelectRes.data
+ } catch (error) {
+ console.error('初始化出错:', error)
+ }
+ },
// 取消按钮
cancel() {
this.dialogShowFlag = false
@@ -831,7 +870,6 @@ export default {
if (valid) {
// 编码管理传递参数
console.log('this.dynamicValidateForm.premiumList1111)', this.dynamicValidateForm.premiumList)
-
let params = {
maId: this.rowObj.maId,
typeId: this.rowObj.typeId,
@@ -864,9 +902,53 @@ export default {
}
})
},
+
+ save() {
+ this.$refs['dynamicValidateForm'].validate((valid) => {
+ if (valid) {
+ // 编码管理传递参数
+ console.log('this.dynamicValidateForm.premiumList1111)', this.dynamicValidateForm.premiumList)
+ let params = {
+ maId: this.rowObj.maId,
+ typeId: this.rowObj.typeId,
+ id: this.rowObj.id,
+ repairType: 1,
+ companyId: this.companyId,
+ partStrList: JSON.stringify(this.dynamicValidateForm.premiumList),
+ manageType: 0,
+ repairNum: this.dynamicValidateForm.premiumList[0]?.repairNum ?? 1,
+ maId: this.rowObj.maId,
+ }
+ this.fullscreenLoading = true
+ saveRepairApplyApiNew(params)
+ .then((res) => {
+ if (res.code == 200) {
+ this.getList()
+ this.fullscreenLoading = false
+ this.dialogShowFlag = false
+ this.index = null
+ this.$message.success('操作成功!')
+ this.$emit('domainChangeTwo', res.code)
+ }
+ })
+ .catch(() => {
+ this.index = null
+ this.fullscreenLoading = false
+ })
+ } else {
+ return false
+ }
+ })
+ },
+
+
submitTwo() {
this.$refs['dynamicValidateFormTwo'].validate((valid) => {
if (valid) {
+ if(this.dynamicValidateFormTwo.premiumListTwo[0]?.repairNum > this.rowObj.repairNotFinishNum){
+ this.$message.error('维修数量不能大于待维修数量')
+ return
+ }
// 数量管理传递参数
let params = {
maId: this.rowObj.maId,
@@ -900,6 +982,131 @@ export default {
}
})
},
+ //保存
+ saveTwo() {
+ this.$refs['dynamicValidateFormTwo'].validate((valid) => {
+ if (valid) {
+ if(this.dynamicValidateFormTwo.premiumListTwo[0]?.repairNum > this.rowObj.repairNotFinishNum){
+ this.$message.error('维修数量不能大于待维修数量')
+ return
+ }
+ // 数量管理传递参数
+ let params = {
+ maId: this.rowObj.maId,
+ typeId: this.rowObj.typeId,
+ id: this.rowObj.id,
+ companyId: this.companyId,
+ repairType: 1,
+ partStrList: JSON.stringify(this.dynamicValidateFormTwo.premiumListTwo),
+ manageType: 1,
+ repairNum: this.dynamicValidateFormTwo.premiumListTwo[0]?.repairNum ?? 1,
+ }
+ this.fullscreenLoading = true
+ console.log("xxxxxxxxxxxxxxxxxxx",params)
+ saveRepairApplyApiNew(params)
+ .then((res) => {
+ if (res.code == 200) {
+ this.getList()
+ this.fullscreenLoading = false
+ this.dialogShowFlag = false
+ this.index = null
+ this.$message.success('操作成功!')
+ this.$emit('domainChange', res.code)
+ }
+ })
+ .catch(() => {
+ this.index = null
+ this.fullscreenLoading = false
+ })
+ } else {
+ return false
+ }
+ })
+ },
+
+ async clearSave() {
+ try {
+ // 弹出确认对话框
+ await this.$confirm('是否确认清除保存?', '提示', {
+ confirmButtonText: '确定',
+ cancelButtonText: '取消',
+ type: 'warning'
+ });
+
+ // 用户确认后调用清除保存接口
+ const params = {
+ maId: this.rowObj.maId,
+ typeId: this.rowObj.typeId,
+ id: this.rowObj.id
+ };
+ this.fullscreenLoading = true
+ const res = await clearSaveApi(params);
+
+ if (res.code === 200) {
+
+ // 清除成功提示
+ this.$message.success('清除保存成功');
+
+ this.fullscreenLoading = false
+ this.dialogShowFlag = false
+ this.$emit('domainChangeTwo', res.code)
+ } else {
+ // 清除失败提示
+ this.fullscreenLoading = false
+ this.$message.error('清除保存失败,请稍后重试');
+
+ }
+ } catch (error) {
+ if (error !== 'cancel') {
+ // 接口调用出错提示
+ this.fullscreenLoading = false
+ this.$message.error('操作出错,请稍后重试');
+
+ }
+ }
+ },
+
+ async clearSaveTwo() {
+ try {
+ // 弹出确认对话框
+ await this.$confirm('是否确认清除保存?', '提示', {
+ confirmButtonText: '确定',
+ cancelButtonText: '取消',
+ type: 'warning'
+ });
+
+ // 用户确认后调用清除保存接口
+ const params = {
+ maId: this.rowObj.maId,
+ typeId: this.rowObj.typeId,
+ id: this.rowObj.id
+ };
+ this.fullscreenLoading = true
+ const res = await clearSaveApi(params);
+
+ if (res.code === 200) {
+
+ // 清除成功提示
+ this.$message.success('清除保存成功');
+ this.fullscreenLoading = false
+ this.dialogShowFlag = false
+ this.$emit('domainChange', res.code)
+ } else {
+ // 清除失败提示
+ this.fullscreenLoading = false
+ this.$message.error('清除保存失败,请稍后重试');
+
+ }
+ } catch (error) {
+ if (error !== 'cancel') {
+ // 接口调用出错提示
+ this.fullscreenLoading = false
+ this.$message.error('操作出错,请稍后重试');
+
+ }
+ }
+ },
+
handleSelectTree(value, index) {
if (value) {
this.isRequired = true;
@@ -979,6 +1186,7 @@ export default {
console.log('🚀 ~ domain.fileList:', domain.fileList)
},
handlePreview(file) {
+ console.log("ccccccccccccccccc",file)
if (file.response) {
window.open(file.response.data.fileUrl)
} else {
diff --git a/src/views/repairTest/repair/dialogThreeForm.vue b/src/views/repairTest/repair/dialogThreeForm.vue
index f8f3b1e..c1c5406 100644
--- a/src/views/repairTest/repair/dialogThreeForm.vue
+++ b/src/views/repairTest/repair/dialogThreeForm.vue
@@ -73,7 +73,9 @@
@@ -155,7 +157,9 @@
@@ -163,7 +167,7 @@