2023-08-09 14:54:37 +08:00
|
|
|
import {
|
|
|
|
|
observable,
|
|
|
|
|
action
|
|
|
|
|
} from 'mobx';
|
|
|
|
|
import * as mobx from 'mobx';
|
|
|
|
|
import * as API from '../apis/quickSearch';
|
|
|
|
|
import {
|
|
|
|
|
WeaForm
|
|
|
|
|
} from 'comsMobx';
|
|
|
|
|
import {
|
|
|
|
|
Modal,
|
|
|
|
|
message,
|
|
|
|
|
} from 'antd'
|
|
|
|
|
import {
|
|
|
|
|
i18n
|
|
|
|
|
} from '../public/i18n';
|
|
|
|
|
import { WeaLocaleProvider } from 'ecCom';
|
|
|
|
|
|
|
|
|
|
const toJS = mobx.toJS;
|
|
|
|
|
const getLabel = WeaLocaleProvider.getLabel;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export class QuickSearchStore {
|
|
|
|
|
|
|
|
|
|
@observable quickSearchForm = new WeaForm();
|
|
|
|
|
@observable qcSelectedRowKeys = [];
|
|
|
|
|
@observable quickSearchData = {
|
|
|
|
|
datas: [],//表格记录record
|
|
|
|
|
setting: {},
|
|
|
|
|
options: [],
|
|
|
|
|
};
|
|
|
|
|
@observable quickSearchDetailVisable = false;
|
|
|
|
|
@observable qcData = { qcType: '', cid: '', fieldid: '' };//快速查询明细type
|
|
|
|
|
@observable quickSearchDetailData = [];
|
|
|
|
|
@observable precision = 0;
|
2023-08-09 16:37:35 +08:00
|
|
|
@observable qcDetailRowKeys = [];
|
|
|
|
|
quickSearchRefObj = {};
|
2023-08-09 14:54:37 +08:00
|
|
|
|
|
|
|
|
/**** ==============quickSearchForm ===============*/
|
|
|
|
|
@observable quickSearchFields = [
|
|
|
|
|
{
|
|
|
|
|
domkey: ['isquicksearch'],
|
|
|
|
|
conditionType: 'SWITCH',
|
|
|
|
|
label: getLabel('387493', "快捷搜索条件"),
|
|
|
|
|
labelcol: 5,
|
|
|
|
|
fieldcol: 19,
|
|
|
|
|
viewAttr: 3,
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@action("初始化页面") initList = () => {
|
|
|
|
|
this.quickSearchForm.initFormFields([{ items: this.quickSearchFields.slice() }]);
|
|
|
|
|
this.getQuickSearchInfo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@action clearQuciSearchData = () => {
|
|
|
|
|
this.quickSearchData.setting = {};
|
|
|
|
|
this.quickSearchData.datas = [];
|
|
|
|
|
this.quickSearchData.options = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@action("数据获取") getQuickSearchInfo = () => {
|
|
|
|
|
this.clearQuciSearchData();
|
2023-08-09 17:14:53 +08:00
|
|
|
API.getQuickSearchInfo({ customid: 382 }).then(action(({ code, data, msg }) => {
|
|
|
|
|
if (code == 200) {
|
|
|
|
|
this.quickSearchData.setting = data.setting;
|
2023-08-09 14:54:37 +08:00
|
|
|
this.quickSearchData.datas = datas.map(d => {
|
|
|
|
|
return { ...d, visible: false }
|
|
|
|
|
});
|
2023-08-09 17:14:53 +08:00
|
|
|
this.quickSearchData.groupidOptions = data.groupidOptions;
|
|
|
|
|
this.quickSearchData.options = data.options;
|
2023-08-09 14:54:37 +08:00
|
|
|
this.quickSearchForm.updateFields({
|
2023-08-09 17:14:53 +08:00
|
|
|
isquicksearch: data.setting.isquicksearch,
|
2023-08-09 14:54:37 +08:00
|
|
|
});
|
|
|
|
|
} else {
|
2023-08-09 17:14:53 +08:00
|
|
|
message.error(`[${getLabel(127353, "错误") + code}]:${msg}`);
|
2023-08-09 14:54:37 +08:00
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-09 17:14:53 +08:00
|
|
|
@action("保存页面") saveQuickSearchInfo = () => {
|
|
|
|
|
let datas = this.quickSearchData.datas;
|
|
|
|
|
datas.map((data, index) => {
|
|
|
|
|
data.orderid = index
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let formparm = this.quickSearchForm.getFormParams();
|
|
|
|
|
if (!this.checkQuickSearchData()) {
|
|
|
|
|
message.error(getLabel('387954', "条件字段不能重复"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let id = this.quickSearchData.setting.id;
|
|
|
|
|
if (id == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
API.saveQuickSearchInfo({
|
|
|
|
|
id: id,
|
|
|
|
|
customid: this.customid,
|
|
|
|
|
data: JSON.stringify(datas), ...formparm
|
|
|
|
|
}).then(({ status, errorCode, error, setting, datas, options }) => {
|
|
|
|
|
if (status == '1') {
|
|
|
|
|
message.success(getLabel(83551, '保存成功!'));
|
|
|
|
|
this.qcSelectedRowKeys = [];
|
|
|
|
|
this.getQuickSearchInfo();
|
|
|
|
|
} else {
|
|
|
|
|
message.error(`[${getLabel(127353, "错误") + errorCode}]:${error}`);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.quickSearchData.setting.id = null;
|
2023-08-09 14:54:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-09 17:14:53 +08:00
|
|
|
checkQuickSearchData = () => {
|
|
|
|
|
let map = new Map();
|
|
|
|
|
let result = true;
|
|
|
|
|
this.quickSearchData.datas.map(data => {
|
|
|
|
|
if (map.has(data.fieldid)) {
|
|
|
|
|
result = false;
|
|
|
|
|
}
|
|
|
|
|
map.set(data.fieldid, data.customname);
|
|
|
|
|
});
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2023-08-09 14:54:37 +08:00
|
|
|
|
|
|
|
|
@action setQuickSearchData = (datas) => {
|
|
|
|
|
this.quickSearchData.datas = datas;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-09 17:14:53 +08:00
|
|
|
@action setQuickSearchData = (datas) => {
|
|
|
|
|
this.quickSearchData.datas = datas;
|
|
|
|
|
}
|
2023-08-09 14:54:37 +08:00
|
|
|
|
|
|
|
|
/**============================quickdetail===================== */
|
|
|
|
|
@action("设置") openQuickSearchDetail = (record) => {
|
|
|
|
|
this.quickSearchDetailVisable = true;
|
|
|
|
|
this.qcData.qcType = record.type;
|
|
|
|
|
this.qcData.cid = record.cid;
|
|
|
|
|
this.qcData.fieldid = record.fieldid;
|
|
|
|
|
this.getQuickSearchDetailInfo(record.cid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@action getQuickSearchDetailInfo = (cid) => {
|
|
|
|
|
API.getQuickSearchDetailInfo({ cid: cid }).then(({ status, errorCode, error, setting, datas, precision }) => {
|
|
|
|
|
if (status == '1') {
|
|
|
|
|
this.quickSearchDetailData = datas;
|
|
|
|
|
this.precision = precision;
|
|
|
|
|
} else {
|
|
|
|
|
message.error(`[${getLabel(127353, "错误") + errorCode}]:${error}`);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-08-09 16:37:35 +08:00
|
|
|
@action("明细保存") saveQuickSearchDetailInfo = () => {
|
|
|
|
|
// let datas = this.quickSearchDetailData;
|
|
|
|
|
// if (!this.checkQuickSearchDetailData()) {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// API.saveQuickSearchDetailInfo({
|
|
|
|
|
// cid: this.qcData.cid,
|
|
|
|
|
// data: JSON.stringify(datas)
|
|
|
|
|
// }).then(({ status, errorCode, error, setting, datas, options }: any) => {
|
|
|
|
|
// if (status == '1') {
|
|
|
|
|
// message.success(getLabel(83551, '保存成功!'));
|
|
|
|
|
// this.qcDetailRowKeys = [];
|
|
|
|
|
// this.getQuickSearchDetailInfo(this.qcData.cid);
|
|
|
|
|
// } else {
|
|
|
|
|
// message.error(`[${getLabel(127353, "错误") + errorCode}]:${error}`);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-09 14:54:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**===========================buttons=========================== */
|
|
|
|
|
rightMenu = [
|
|
|
|
|
{
|
|
|
|
|
"isBatch": "0",
|
|
|
|
|
"isTop": "1",
|
|
|
|
|
"menuFun": "save",
|
|
|
|
|
"menuIcon": "icon-coms-Preservation",
|
|
|
|
|
"menuName": "保存",
|
|
|
|
|
"type": "BTN_save"
|
|
|
|
|
},
|
|
|
|
|
// {
|
|
|
|
|
// "isBatch": "0",
|
|
|
|
|
// "isTop": "0",
|
|
|
|
|
// "menuFun": "log",
|
|
|
|
|
// "menuIcon": "icon-coms-Print-log",
|
|
|
|
|
// "menuName": "日志",
|
|
|
|
|
// "type": "BTN_log"
|
|
|
|
|
// }
|
|
|
|
|
];
|
|
|
|
|
topMenu = [
|
|
|
|
|
{
|
|
|
|
|
"isBatch": "1",
|
|
|
|
|
"isTop": "1",
|
|
|
|
|
"menuFun": "save",
|
|
|
|
|
"menuIcon": "icon-coms-Preservation",
|
|
|
|
|
"menuName": "保存",
|
|
|
|
|
"type": "BTN_save"
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
}
|