/**
|
* 消息中心工具函数
|
* 提供保存消息记录和更新接口记录的功能
|
*/
|
|
import Vue from 'vue';
|
import store from '@/store';
|
|
/**
|
* 保存消息记录
|
* @param {Object} options - 配置选项
|
* @param {String} options.type - 消息类型,A-审核,B-反审核等
|
* @param {Object} options.requestInfo - 请求信息,包含url和data
|
* @param {Object} options.messageCenter - 消息中心数据
|
* @param {String} options.billNo - 单据编号
|
* @param {String} options.billType - 单据类型,如"采购入库单"
|
* @param {String} options.userName - 用户账号
|
* @param {Function} options.callback - 保存成功后的回调函数,参数为消息ID
|
*/
|
function saveMessage(options) {
|
const { type, requestInfo, messageCenter, billNo, billType, userName, callback } = options;
|
|
let title = `${billType}${billNo}审核`;
|
let tableName = `MES_INV_ITEM_INS_${type}`;
|
|
if (type === "B") {
|
title = `${billType}${billNo}反审核`;
|
}
|
|
const entity = {
|
data: JSON.stringify(requestInfo.data),
|
url: requestInfo.url,
|
pid: messageCenter.id,
|
dealWith: 0,
|
result: 0,
|
status: 1,
|
seq: messageCenter.seq + 1,
|
createBy: userName,
|
title: title,
|
route: billNo,
|
tableName: tableName,
|
contentType: "application/json",
|
};
|
|
// 使用Vue.prototype.$post方法
|
if (Vue.prototype.$post) {
|
Vue.prototype.$post({
|
url: "/MessageCenter/Insert",
|
data: entity
|
}).then(res => {
|
if (callback && typeof callback === 'function') {
|
callback(res.data.tbBillList);
|
}
|
});
|
} else {
|
// 兼容性处理,直接使用uni.request
|
uni.request({
|
url: store.state.serverInfo.serverAPI + "/MessageCenter/Insert",
|
method: "POST",
|
data: entity,
|
success: (res) => {
|
if (callback && typeof callback === 'function') {
|
callback(res.data.tbBillList);
|
}
|
}
|
});
|
}
|
}
|
|
/**
|
* 更新接口记录表
|
* @param {Object} messageCenter - 消息中心数据对象
|
* @param {Function} callback - 更新成功后的回调函数,参数为成功状态和消息
|
*/
|
function updateMessage(messageCenter, callback) {
|
// 使用Vue.prototype.$post方法
|
if (Vue.prototype.$post) {
|
Vue.prototype.$post({
|
url: "/MessageCenter/ResetUpdate",
|
data: messageCenter
|
}).then(res => {
|
const success = res.data.tbBillList > 0;
|
const message = success ? "问题记录成功!" : "问题记录失败!!!";
|
|
if (callback && typeof callback === 'function') {
|
callback(success, message);
|
}
|
});
|
} else {
|
// 兼容性处理,直接使用uni.request
|
uni.request({
|
url: store.state.serverInfo.serverAPI + "/MessageCenter/ResetUpdate",
|
method: "POST",
|
data: messageCenter,
|
success: (res) => {
|
const success = res.data.tbBillList > 0;
|
const message = success ? "问题记录成功!" : "问题记录失败!!!";
|
|
if (callback && typeof callback === 'function') {
|
callback(success, message);
|
}
|
}
|
});
|
}
|
}
|
|
export default {
|
saveMessage,
|
updateMessage
|
};
|