diff --git a/src/utils/request.js b/src/utils/request.js
index 568683f..1739a4b 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -12,110 +12,110 @@ let downloadLoadingInstance
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
// 创建axios实例
const service = axios.create({
- // axios中请求配置有baseURL选项,表示请求URL公共部分
- baseURL: import.meta.env.VITE_APP_BASE_API,
- // 超时
- timeout: 30000
+ // axios中请求配置有baseURL选项,表示请求URL公共部分
+ baseURL: import.meta.env.VITE_APP_BASE_API,
+ // 超时
+ timeout: 30000
})
// request拦截器
service.interceptors.request.use(
- (config) => {
- // 是否需要设置 token
- if (getToken()) {
- //将token放到请求头发送给服务器,将tokenkey放在请求头中
- config.headers['Authorization'] = 'Bearer ' + getToken()
- config.headers['userid'] = useUserStore().userId
- config.headers['userName'] = encodeURIComponent(useUserStore().userName)
- }
- const method = config?.method || 'get'
- const header = config?.headers['Content-Type'] ?? ''
+ (config) => {
+ // 是否需要设置 token
+ if (getToken()) {
+ //将token放到请求头发送给服务器,将tokenkey放在请求头中
+ config.headers['Authorization'] = 'Bearer ' + getToken()
+ config.headers['userid'] = useUserStore().userId
+ config.headers['userName'] = encodeURIComponent(useUserStore().userName)
+ }
+ const method = config?.method || 'get'
+ const header = config?.headers['Content-Type'] ?? ''
- if ((method.toLowerCase() === 'post' || method.toLowerCase() === 'put') && header != 'multipart/form-data') {
- config.data = delEmptyQueryNodes(config.data)
+ if ((method.toLowerCase() === 'post' || method.toLowerCase() === 'put') && header != 'multipart/form-data') {
+ config.data = delEmptyQueryNodes(config.data)
+ }
+ return config
+ },
+ (error) => {
+ console.log(error)
+ Promise.reject(error)
}
- return config
- },
- (error) => {
- console.log(error)
- Promise.reject(error)
- }
)
// 响应拦截器
service.interceptors.response.use(
- (res) => {
- if (res.status !== 200) {
- Promise.reject('network error')
- return
- }
- // 未设置状态码则默认成功状态
- const { code, msg } = res.data
- // 二进制数据则直接返回
- if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
- return res
- }
- var token = res.headers['x-refresh-token']
- if (token) {
- useUserStore().refreshToken(token)
- }
- if (code == 401) {
- ElMessageBox.confirm('登录状态已过期,请重新登录', '系统提示', {
- confirmButtonText: '重新登陆',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- useUserStore()
- .logOut()
- .then(() => {
- location.href = import.meta.env.VITE_APP_ROUTER_PREFIX + 'index'
- })
- })
+ (res) => {
+ if (res.status !== 200) {
+ Promise.reject('network error')
+ return
+ }
+ // 未设置状态码则默认成功状态
+ const { code, msg } = res.data
+ // 二进制数据则直接返回
+ if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
+ return res
+ }
+ var token = res.headers['x-refresh-token']
+ if (token) {
+ useUserStore().refreshToken(token)
+ }
+ if (code == 401) {
+ ElMessageBox.confirm('登录状态已过期,请重新登录', '系统提示', {
+ confirmButtonText: '重新登陆',
+ cancelButtonText: '取消',
+ type: 'warning'
+ }).then(() => {
+ useUserStore()
+ .logOut()
+ .then(() => {
+ location.href = import.meta.env.VITE_APP_ROUTER_PREFIX + 'index'
+ })
+ })
- return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
- } else if (code == 0 || code == 1 || code == 110 || code == 101 || code == 403 || code == 500 || code == 429) {
- ElMessage({
- message: msg,
- type: 'error'
- })
- return Promise.reject(res.data)
- } else {
- //返回标准 code/msg/data字段
- return res.data
- }
- },
- (error) => {
- console.error('axios err', error)
- var duration = 3000
- let { message, response } = error
+ return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
+ } else if (code == 0 || code == 1 || code == 110 || code == 101 || code == 403 || code == 500 || code == 429) {
+ ElMessage({
+ message: msg,
+ type: 'error'
+ })
+ return Promise.reject(res.data)
+ } else {
+ //返回标准 code/msg/data字段
+ return res.data
+ }
+ },
+ (error) => {
+ console.error('axios err', error)
+ var duration = 3000
+ let { message, response } = error
- if (response.status == 404) {
- message = '接口404'
- } else if (response.status == 403) {
- window.location.href = import.meta.env.VITE_APP_ROUTER_PREFIX + '401'
- } else if (message == 'Network Error') {
- message = '后端接口连接异常'
- } else if (message.includes('timeout')) {
- message = '系统接口请求超时'
- } else if (message.includes('code 429')) {
- message = '请求过于频繁,请稍后再试'
- } else if (message.includes('Request failed with status code')) {
- message = '系统接口' + message.substr(message.length - 3) + '异常,请联系管理员'
+ if (response.status == 404) {
+ message = '接口404'
+ } else if (response.status == 403) {
+ window.location.href = import.meta.env.VITE_APP_ROUTER_PREFIX + '401'
+ } else if (message == 'Network Error') {
+ message = '后端接口连接异常'
+ } else if (message.includes('timeout')) {
+ message = '系统接口请求超时'
+ } else if (message.includes('code 429')) {
+ message = '请求过于频繁,请稍后再试'
+ } else if (message.includes('Request failed with status code')) {
+ message = '系统接口' + message.substr(message.length - 3) + '异常,请联系管理员'
- if (import.meta.env.DEV) {
- message = 'Oops,后端出错了,你不会连错误日志都不会看吧'
- duration = 0
- }
+ if (import.meta.env.DEV) {
+ message = '服务器正在重启中'
+ duration = 0
+ }
+ }
+ ElMessage({
+ message: message,
+ type: 'error',
+ duration: duration,
+ showClose: true,
+ grouping: true
+ })
+ return Promise.reject({ code: 500, msg: message })
}
- ElMessage({
- message: message,
- type: 'error',
- duration: duration,
- showClose: true,
- grouping: true
- })
- return Promise.reject({ code: 500, msg: message })
- }
)
/**
@@ -124,33 +124,33 @@ service.interceptors.response.use(
* @param {Object} params [请求时携带的参数]
*/
export function get(url, params) {
- return new Promise((resolve, reject) => {
- service
- .get(url, {
- params: params
- })
- .then((res) => {
- resolve(res)
- })
- .catch((err) => {
- reject(err)
- })
- })
+ return new Promise((resolve, reject) => {
+ service
+ .get(url, {
+ params: params
+ })
+ .then((res) => {
+ resolve(res)
+ })
+ .catch((err) => {
+ reject(err)
+ })
+ })
}
export function post(url, params) {
- return new Promise((resolve, reject) => {
- service
- .post(url, {
- params: params
- })
- .then((res) => {
- resolve(res)
- })
- .catch((err) => {
- reject(err)
- })
- })
+ return new Promise((resolve, reject) => {
+ service
+ .post(url, {
+ params: params
+ })
+ .then((res) => {
+ resolve(res)
+ })
+ .catch((err) => {
+ reject(err)
+ })
+ })
}
/**
@@ -159,16 +159,16 @@ export function post(url, params) {
* @param {*} data
*/
export function postForm(url, data, config) {
- return new Promise((resolve, reject) => {
- service
- .post(url, data, config)
- .then((res) => {
- resolve(res)
- })
- .catch((err) => {
- reject(err)
- })
- })
+ return new Promise((resolve, reject) => {
+ service
+ .post(url, data, config)
+ .then((res) => {
+ resolve(res)
+ })
+ .catch((err) => {
+ reject(err)
+ })
+ })
}
/**
@@ -179,48 +179,48 @@ export function postForm(url, data, config) {
* @returns
*/
export async function downFile(url, params, config) {
- downloadLoadingInstance = ElLoading.service({ text: '正在下载数据,请稍候', background: 'rgba(0, 0, 0, 0.7)' })
+ downloadLoadingInstance = ElLoading.service({ text: '正在下载数据,请稍候', background: 'rgba(0, 0, 0, 0.7)' })
- service
- .get(url, {
- params,
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
- responseType: 'blob',
- ...config
- })
- .then(async (resp) => {
- const { data } = resp
-
- const isLogin = await blobValidate(data)
- if (isLogin) {
- var patt = new RegExp('filename=([^;]+\\.[^\\.;]+);*')
- var contentDisposition = decodeURI(resp.headers['content-disposition'])
- var result = patt.exec(contentDisposition)
- var fileName = result[1]
- fileName = fileName.replace(/\"/g, '')
-
- const blob = new Blob([data])
- saveAs(blob, fileName)
- } else {
- const resText = await data.text()
- const rspObj = JSON.parse(resText)
- const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default']
-
- ElMessage({
- message: errMsg,
- type: 'error'
+ service
+ .get(url, {
+ params,
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
+ responseType: 'blob',
+ ...config
+ })
+ .then(async (resp) => {
+ const { data } = resp
+
+ const isLogin = await blobValidate(data)
+ if (isLogin) {
+ var patt = new RegExp('filename=([^;]+\\.[^\\.;]+);*')
+ var contentDisposition = decodeURI(resp.headers['content-disposition'])
+ var result = patt.exec(contentDisposition)
+ var fileName = result[1]
+ fileName = fileName.replace(/\"/g, '')
+
+ const blob = new Blob([data])
+ saveAs(blob, fileName)
+ } else {
+ const resText = await data.text()
+ const rspObj = JSON.parse(resText)
+ const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default']
+
+ ElMessage({
+ message: errMsg,
+ type: 'error'
+ })
+ }
+ })
+ .catch(() => {
+ ElMessage({
+ message: '下载文件出现错误,请联系管理员!',
+ type: 'error'
+ })
+ })
+ .finally(() => {
+ downloadLoadingInstance.close()
})
- }
- })
- .catch(() => {
- ElMessage({
- message: '下载文件出现错误,请联系管理员!',
- type: 'error'
- })
- })
- .finally(() => {
- downloadLoadingInstance.close()
- })
}
export default service
diff --git a/src/views/productManagement/ProWorkorder/components/WorkorderDetailDialog.vue b/src/views/productManagement/ProWorkorder/components/WorkorderDetailDialog.vue
index 5c30626..033bc6e 100644
--- a/src/views/productManagement/ProWorkorder/components/WorkorderDetailDialog.vue
+++ b/src/views/productManagement/ProWorkorder/components/WorkorderDetailDialog.vue
@@ -50,6 +50,12 @@
+
+
+
+
+
+
diff --git a/src/views/productManagement/ProWorkorder/components/WorkorderMaterialPickDialog.vue b/src/views/productManagement/ProWorkorder/components/WorkorderMaterialPickDialog.vue
index a660640..46bb66a 100644
--- a/src/views/productManagement/ProWorkorder/components/WorkorderMaterialPickDialog.vue
+++ b/src/views/productManagement/ProWorkorder/components/WorkorderMaterialPickDialog.vue
@@ -485,19 +485,15 @@ function handleCancel(row) {
type: 'warning'
})
.then(() => {
- cancelMmInventory({ id: row.id, type: 2 })
- .then((response) => {
- if (response.code === 200) {
- proxy.$message.success('撤销成功')
- loadPickRecords()
- loadInventoryList()
- } else {
- proxy.$message.error('撤销失败: ' + (response.msg || '未知错误'))
- }
- })
- .catch((error) => {
- proxy.$message.error('撤销失败: ' + error.message)
- })
+ cancelMmInventory({ id: row.id, type: 2 }).then((response) => {
+ if (response.code === 200) {
+ proxy.$message.success('撤销成功')
+ loadPickRecords()
+ loadInventoryList()
+ } else {
+ proxy.$message.error('撤销失败: ' + (response.msg || '未知错误'))
+ }
+ })
})
.catch(() => {
// 取消操作
@@ -532,13 +528,12 @@ function submitForm() {
// 刷新数据
loadPickRecords()
loadInventoryList()
+ // 触发外部工单列表更新
+ emit('submit', { type: 'materialPick', data: requestData })
} else {
proxy.$message.error('领料失败: ' + (response.msg || '未知错误'))
}
})
- .catch((error) => {
- proxy.$message.error('领料失败: ' + error.message)
- })
.finally(() => {
// 关闭加载状态
proxy.$modal.closeLoading()
diff --git a/src/views/productManagement/ProWorkorder/components/WorkorderProductStorageDialog.vue b/src/views/productManagement/ProWorkorder/components/WorkorderProductStorageDialog.vue
index 1343f0f..cbd7f3a 100644
--- a/src/views/productManagement/ProWorkorder/components/WorkorderProductStorageDialog.vue
+++ b/src/views/productManagement/ProWorkorder/components/WorkorderProductStorageDialog.vue
@@ -313,7 +313,13 @@ function handleStorageMaterial() {
if (props.workorderInfo) {
formData.productionCode = props.workorderInfo.productionCode || ''
formData.productionName = props.workorderInfo.productionName || ''
- formData.storageQuantity = props.workorderInfo.planNum || 1
+ // 重新计算入库数量,使用最新的工单数据
+ // 计划数量减去已入库数量
+ formData.storageQuantity = (props.workorderInfo.planNum || 0) - (props.workorderInfo.productNum || 0)
+ // 确保入库数量至少为1
+ if (formData.storageQuantity < 1) {
+ formData.storageQuantity = 1
+ }
}
// 显示入库单据弹窗
showStorageForm.value = true
@@ -328,19 +334,15 @@ function handleCancel(row) {
type: 'warning'
})
.then(() => {
- cancelMmInventory({ id: row.id, type: 1 })
- .then((response) => {
- if (response.code === 200) {
- proxy.$message.success('撤销成功')
- loadStorageRecords()
- loadInventoryList()
- } else {
- proxy.$message.error('撤销失败: ' + (response.msg || '未知错误'))
- }
- })
- .catch((error) => {
- proxy.$message.error('撤销失败: ' + error.message)
- })
+ cancelMmInventory({ id: row.id, type: 1 }).then((response) => {
+ if (response.code === 200) {
+ proxy.$message.success('撤销成功')
+ loadStorageRecords()
+ loadInventoryList()
+ } else {
+ proxy.$message.error('撤销失败: ' + (response.msg || '未知错误'))
+ }
+ })
})
.catch(() => {
// 取消操作
@@ -372,13 +374,12 @@ function submitForm() {
// 刷新数据
loadStorageRecords()
loadInventoryList()
+ // 触发外部工单列表更新
+ emit('submit', { type: 'productStorage', data: requestData })
} else {
proxy.$message.error('入库失败: ' + (response.msg || '未知错误'))
}
})
- .catch((error) => {
- proxy.$message.error('入库失败: ' + error.message)
- })
.finally(() => {
// 关闭加载状态
proxy.$modal.closeLoading()
diff --git a/src/views/productManagement/ProWorkorder/components/WorkorderShipmentDialog.vue b/src/views/productManagement/ProWorkorder/components/WorkorderShipmentDialog.vue
index aa3878e..a6c329d 100644
--- a/src/views/productManagement/ProWorkorder/components/WorkorderShipmentDialog.vue
+++ b/src/views/productManagement/ProWorkorder/components/WorkorderShipmentDialog.vue
@@ -285,8 +285,8 @@ function resetForm() {
// 重置表单数据
Object.assign(formData, {
selectedOrderNo: '',
- shipmentQuantity: props.workorderInfo?.planNum - props.workorderInfo?.defectNum || 1,
- operator: '',
+ shipmentQuantity: 1,
+ operator: '解建雄',
orderId: ''
})
// 如果有工单信息,保持工单相关数据
@@ -315,7 +315,13 @@ function handleShipmentMaterial(product) {
formData.productionName = product.materialName
formData.selectedOrderNo = product.orderNoMes
formData.orderId = product.id
- formData.shipmentQuantity = props.workorderInfo?.planNum || 1
+ // 重新计算出货数量,使用最新的工单数据
+ // 已入库数量减去已出货数量
+ formData.shipmentQuantity = (props.workorderInfo.productNum || 0) - (props.workorderInfo.shipmentNum || 0)
+ // 确保出货数量至少为1
+ if (formData.shipmentQuantity < 1) {
+ formData.shipmentQuantity = 1
+ }
// 显示出货单据弹窗
showShipmentForm.value = true
}
@@ -374,13 +380,13 @@ function submitForm() {
// 刷新数据
loadShipmentRecords()
loadInventoryList()
+ // 触发外部工单列表更新
+ emit('submit', { type: 'shipment', data: requestData })
} else {
+ console.log('response1', response)
proxy.$message.error('出货失败: ' + (response.msg || '未知错误'))
}
})
- .catch((error) => {
- proxy.$message.error('出货失败: ' + error.message)
- })
.finally(() => {
// 关闭加载状态
proxy.$modal.closeLoading()
diff --git a/src/views/productManagement/ProWorkorder/index.vue b/src/views/productManagement/ProWorkorder/index.vue
index e977cbc..7358c14 100644
--- a/src/views/productManagement/ProWorkorder/index.vue
+++ b/src/views/productManagement/ProWorkorder/index.vue
@@ -105,6 +105,7 @@
+