util = window.top.util;
|
FormatCenter = window.top.FormatCenter;
|
Dictionary = window.top.Dictionary;
|
baseUrl = window.top.baseUrl;
|
Object.subClass = function(properties) {
|
if (!properties) {
|
return;
|
}
|
|
var clazz = properties.init;
|
delete properties.init;
|
|
if (!clazz) {
|
clazz = new Function();
|
}
|
|
prototyping = true;
|
try {
|
var prototype = new this();
|
}
|
finally {
|
prototyping = false;
|
}
|
|
for (var name in properties) {
|
prototype[name] = properties[name];
|
}
|
|
clazz.prototype = prototype;
|
clazz.subClass = arguments.callee;
|
|
return clazz;
|
};
|
|
Config = Object.subClass({
|
init: function(config) {
|
|
},
|
|
combine: function(obj, override) {
|
if (!obj) {
|
return;
|
}
|
|
override = (override == undefined) ? false : override;
|
|
for (var name in obj) {
|
if (override || this[name] === undefined) {
|
this[name] = obj[name];
|
}
|
}
|
}
|
});
|
|
Record = Object.subClass({
|
init: function(config) {
|
this.vue = config;
|
this.raw = {};
|
this.data = {};
|
this.prior = {};
|
this.face = {};
|
},
|
|
setData: function(raw) {
|
this.raw = raw;
|
|
var data = this.data = {};
|
var prior = this.prior = {};
|
var face = this.face = {};
|
|
for (var prop in raw) {
|
var fieldMeta = this.getFieldMeta(prop);
|
if (!fieldMeta) {
|
continue;
|
}
|
var value = raw[prop];
|
|
data[prop] = value;
|
prior[prop] = value;
|
|
if (fieldMeta.formatter) {
|
face[prop] = FormatCenter.format(value, fieldMeta.formatter);
|
}
|
else if (fieldMeta.dict) {
|
face[prop] = Dictionary.getLabel(value, fieldMeta.dict);
|
}
|
else {
|
face[prop] = value;
|
}
|
}
|
},
|
|
getFace: function() {
|
return this.face;
|
},
|
|
getData: function() {
|
return this.data;
|
},
|
setEditData: function(data) {
|
this.data = data;
|
},
|
|
apply: function() {
|
var data = this.data;
|
var face = this.face;
|
|
for (var prop in data) {
|
var value = data[prop];
|
|
if (value == this.prior[prop]) {
|
|
continue;
|
}
|
|
this.prior[prop] = value;
|
|
var fieldMeta = this.getFieldMeta(prop);
|
|
if (!fieldMeta) {
|
continue;
|
}
|
|
if (fieldMeta.formatter) {
|
value = FormatCenter.format(value, fieldMeta.formatter);
|
}
|
else if (fieldMeta.dict) {
|
value = Dictionary.getLabel(value, fieldMeta.dict);
|
}
|
|
face[prop] = value;
|
}
|
},
|
|
getChanged: function() {
|
var result = {}, raw = this.raw, data = this.data;
|
|
for (var prop in data) {
|
if (data[prop] == raw[prop]) {
|
continue;
|
}
|
|
result[prop] = data[prop];
|
}
|
|
if (raw.id && !result.id) {
|
result.id = raw.id;
|
}
|
},
|
|
commit: function() {
|
var raw = this.raw, data = this.data, prior = this.prior;
|
|
for (var prop in data) {
|
raw[prop] = prior[prop] = data[prop];
|
}
|
},
|
|
cancel: function() {
|
this.setData(this.raw);
|
},
|
|
getFieldMeta: function(prop) {
|
return this.vue.formFieldsObj[prop];
|
},
|
|
});
|
|
ListVue = Object.subClass({
|
init: function(config) {
|
var default_ = {
|
el: null,
|
data: {
|
//pageAttr.heightType:table/page都是为了设置表格的高度。
|
//table是以表格本身的条数计算高度。
|
//page是以页面给表格留下的高度为表格高度
|
pageAttr: {
|
heightType: "table"
|
},
|
|
dataname: null,
|
|
//版本
|
//绑定的数据对象
|
currentVersion: {
|
value: "1.0",
|
},
|
versionList: [
|
{value: "1.0", label: "1.0"},
|
{value: "2.0", label: "2.0"},
|
{value: "3.0", label: "3.0"}
|
],
|
|
//查询功能
|
filterFields:[],
|
filterFieldsObj: {},
|
filterObj: {},
|
filterObjBydefault: {},
|
filterTxt: "",
|
paramObjBydefault: {},
|
filterList:[
|
//注释:type: equal(等于)/in(在多个数据中)/like(模糊)/minval(最小值)/maxval(最大值)/mininclude(最小且包含该值)/maxinclude(最大且包含该值)
|
//{field: "", val: "", type: ""}
|
],
|
filterAttr: {
|
columnnumber: 4,
|
labelwidth: "100px",
|
labelposition: "right",
|
size: "medium",
|
border: "3px solid #c6c6c600"
|
},
|
|
formFields: [],
|
formFieldsObj: {},
|
|
//列表功能
|
operationtype: "",
|
isRefresh: true,
|
tableAttr: {},
|
tableFields: [],
|
tableFieldsObj: {},
|
|
tableData: [],
|
tableHeight: 320,
|
isEditTableData:false,
|
|
isPagination: true,
|
pagesize: 10,
|
pagenum: 1,
|
total: 0,
|
selectedrow: {},
|
selectCellField: {},
|
selectCellData: {},
|
orderby: "",
|
tableloading: false,
|
|
|
filter_:"",
|
pageCode: "",
|
pageObj: {},
|
title: "",
|
//窗口高度
|
clientHeight: 0,
|
tabs: {},
|
buttons: {},
|
|
tabMapPagesizeObj: {},
|
preinstallPagesizeObj: {
|
pagesize: 10,
|
pagenum: 1,
|
total: 0
|
},
|
|
//Tab项
|
tabList: [
|
{id: "1", label: "Tab1", name: "tab1"},
|
{id: "2", label: "Tab2", name: "tab2"},
|
{id: "3", label: "Tab3", name: "tab3"}
|
],
|
|
tabMapButton:{
|
page_id: {},
|
},
|
tabMapTable:{
|
page_id: {},
|
},
|
tabMapQuery:{
|
page_id: [],
|
},
|
tabMapQueryField:{
|
page_id: [],
|
},
|
tabMapField:{
|
page_id: [],
|
},
|
tabMapPagesize:{
|
page_id: {},
|
},
|
tabMapTableData:{
|
page_id: [],
|
},
|
|
tabMapFilterData:{
|
page_id: {},
|
},
|
|
//tables
|
tableList: [],
|
pageId: "",
|
activeTable: {},
|
|
dataname_records: "",
|
paramRecordsObjBydefault: {},
|
approvaltype: "",
|
|
filterFields_records: [],
|
filterFieldsObj_records: {},
|
tableFields_records: [],
|
tableFieldsObj_records: {},
|
approvalfields: [],
|
tableData_records: [],
|
tableHeight_records: 300,
|
totaltab: "",//
|
|
dataRequest: [],
|
dl_emp_codestrs: "",
|
},
|
watch: {
|
|
},
|
methods: {
|
loadRequestData(dataRequest, result, callback) {
|
this.doLoadRequestData(dataRequest, result, callback);
|
},
|
doLoadRequestData(dataRequest, result, callback) {
|
var me = this;
|
if (dataRequest && dataRequest.length) {
|
var item = dataRequest[0];
|
if (typeof(item) == "string") {
|
result[item] = dataRoot.database[item];
|
dataRequest.remove(item);
|
|
me.doLoadRequestData(dataRequest, result, callback);
|
}
|
else {
|
if (item.isClientMode) {
|
result[item.name] = dataRoot.database[item.name];
|
dataRequest.remove(item);
|
|
me.doLoadRequestData(dataRequest, result, callback);
|
}
|
else {
|
var dataname_ = item.name;
|
if (item.dataname) {
|
dataname_ = item.dataname;
|
}
|
var params = {
|
isClientMode: false,
|
dataname: dataname_,
|
}
|
if(item.filter) {
|
params.filter = item.filter
|
}
|
if (item.paramObjBydefault && item.paramObjBydefault != {}) {
|
for(var k in item.paramObjBydefault) {
|
let k_val = item.paramObjBydefault[k];
|
params[k] = k_val;
|
}
|
}
|
|
var event_ = "root/data/getEntitySet";
|
|
if (item.url) {
|
event_ = item.url;
|
}
|
|
Server.call(event_, params, function(result_) {
|
console.log(result_);
|
|
if (result_ && result_.data.entityset && result_.data.entityset.length) {
|
result[item.name] = result_.data.entityset;
|
|
if (item.isinputoption) {
|
var inputoption_ = [];
|
result_.data.entityset.map(e=>{
|
var in_op_ = {
|
value: e[item.label]
|
}
|
|
inputoption_.push(in_op_);
|
})
|
|
if (!result.map) {
|
result.map = {};
|
}
|
|
if (!result.map[item.name]) {
|
result.map[item.name] = [];
|
}
|
result.map[item.name] = inputoption_;
|
}
|
|
//不是不是选项
|
else if (!item.isnotoption) {
|
//是选项
|
result_.data.entityset.map(e=>{
|
if (!result.map) {
|
result.map = {};
|
}
|
|
if (!result.map[item.name]) {
|
result.map[item.name] = {};
|
}
|
|
result.map[item.name][e[item.code]] = e[item.label];
|
})
|
}
|
|
|
}
|
dataRequest.remove(item);
|
|
me.doLoadRequestData(dataRequest, result, callback);
|
});
|
}
|
}
|
}
|
else {
|
callback(result);
|
}
|
},
|
|
//版本
|
versionSelect: function(obj) {
|
this.currentVersion = obj;
|
if (this.onVersionSelect) {
|
this.onVersionSelect.call(this, obj);
|
return
|
}
|
this.onInitQuery();
|
},
|
|
//功能
|
onDownload: function() {
|
dealExportByPath("../../../template/area_tree.xlsx","测试数据");
|
},
|
onUpload: function() {
|
Root.message('导入');
|
},
|
//获取button权限
|
getResouresButton() {
|
this.userId = localStorage.getItem("id");
|
let me = this;
|
//按键
|
var params = {
|
dataname: "button",
|
isClientMode: false,
|
userId: this.userId
|
}
|
|
Server.call("root/data/getEntitySet", params, function(result) {
|
console.log(result);
|
if (result && result.data.entityset) {
|
result.data.entityset.map(e=>{
|
me.buttons[e.id_name] = e;
|
});
|
me.$forceUpdate();
|
}
|
|
});
|
},
|
////////////////////////////////
|
///////////////////
|
//获取资源
|
///////////////////
|
getResoures() {
|
let me = this;
|
this.getPageObj();
|
},
|
|
getPageObj() {
|
var me = this;
|
//页面信息
|
var params = {
|
dataname: "page",
|
isClientMode: false,
|
filter: "code='" + this.pageCode + "'",
|
//userId: this.userId
|
}
|
|
Server.call("root/data/getEntitySet", params, function(result) {
|
console.log(result);
|
if (result && result.data.entityset) {
|
me.pageObj = result.data.entityset[0];
|
me.title = me.pageObj.name;
|
me.pageId = me.pageObj.id;
|
//获取ButtonsByPage
|
me.getButtonsByPage(me.pageObj.id);
|
//获取TablesByPage
|
//me.getTablesByPage(me.pageObj.id);
|
|
me.$forceUpdate();
|
}
|
});
|
},
|
|
getButtonsByPage(pageid) {
|
var me = this;
|
var resource_type = "button";
|
|
var roleCode = Root.role.id;
|
var roleid_str = "";
|
roleCode.map(r=>{
|
if (!roleid_str) {
|
roleid_str = r;
|
}
|
else {
|
roleid_str += ";" + r;
|
}
|
});
|
|
var roleid_ = roleid_str.replace(/;/g,"','");
|
//按键
|
var params = {
|
dataname: "buttonByPage",//buttonByPage/buttonByPanel
|
isClientMode: false,
|
filter: "resource_page.id='" + pageid +
|
"' and EXISTS( SELECT 1 from resource_role r where r.type='" + resource_type +
|
"' and r.role_id in ('" + roleid_ + "') and r.resource_id = t.id)"
|
//userId: this.userId
|
}
|
Server.call("root/data/getEntitySet", params, function(result) {
|
console.log(result);
|
if (result && result.data.entityset) {
|
result.data.entityset.map(e=>{
|
if (!me.tabMapButton[e.page_id]) {
|
me.tabMapButton[e.page_id] = {};
|
}
|
me.tabMapButton[e.page_id][e.id_name]=e;
|
});
|
me.getButtonByTabName(me.pageId);
|
|
me.$forceUpdate();
|
}
|
});
|
},
|
|
getButtonByTabName(tab_name) {
|
var me = this;
|
me.buttons = {};
|
if (me.tabMapButton[tab_name]) {
|
me.buttons = me.tabMapButton[tab_name];
|
}
|
},
|
|
getTabsByPage(pageid) {
|
var me = this;
|
var resource_type = "tab";
|
|
var roleCode = Root.role.id;
|
var roleid_str = "";
|
roleCode.map(r=>{
|
if (!roleid_str) {
|
roleid_str = r;
|
}
|
else {
|
roleid_str += ";" + r;
|
}
|
});
|
|
var roleid_ = roleid_str.replace(/;/g,"','");
|
|
//tab
|
var params = {
|
dataname: "tabs",
|
isClientMode: false,
|
//filter: "page_id='" + pageid + "'",
|
|
filter: "page_id='" + pageid +
|
"' and EXISTS( SELECT 1 from resource_role r where r.type='" + resource_type +
|
"' and r.role_id in ('" + roleid_ + "') and r.resource_id = t.id)",
|
orderby: "orderno"
|
//userId: this.userId
|
}
|
Server.call("root/data/getEntitySet", params, function(result) {
|
console.log(result);
|
if (result && result.data.entityset) {
|
me.tabList = result.data.entityset;
|
me.activeTab = me.tabList[0].id_name;
|
result.data.entityset.map(e=>{
|
me.tabs[e.id_name] = e;
|
});
|
|
//获取ButtonsByPage
|
me.getButtonsByPageTab(me.pageObj.id);
|
//获取TablesByPage
|
//me.getTablesByPage(me.pageObj.id);
|
|
me.$forceUpdate();
|
}
|
});
|
},
|
|
getButtonsByPageTab(pageid) {
|
var me = this;
|
var resource_type = "button";
|
|
var roleCode = Root.role.id;
|
var roleid_str = "";
|
roleCode.map(r=>{
|
if (!roleid_str) {
|
roleid_str = r;
|
}
|
else {
|
roleid_str += ";" + r;
|
}
|
});
|
|
var roleid_ = roleid_str.replace(/;/g,"','");
|
|
//按键
|
var params = {
|
dataname: "buttonByTab",//buttonByPage/buttonByPanel
|
isClientMode: false,
|
//filter: "resource_tab.page_id='" + pageid + "'",
|
filter: "resource_tab.page_id='" + pageid +
|
"' and EXISTS( SELECT 1 from resource_role r where r.type='" + resource_type +
|
"' and r.role_id in ('" + roleid_ + "') and r.resource_id = t.id)"
|
//userId: this.userId
|
}
|
Server.call("root/data/getEntitySet", params, function(result) {
|
console.log(result);
|
if (result && result.data.entityset) {
|
//me.activeTab = me.tabList[0].id_name;
|
result.data.entityset.map(e=>{
|
if (!me.tabMapButton[e.tabcode]) {
|
me.tabMapButton[e.tabcode] = {};
|
}
|
me.tabMapButton[e.tabcode][e.id_name]=e;
|
});
|
me.getButtonByTabName(me.activeTab);
|
|
me.$forceUpdate();
|
}
|
});
|
},
|
|
|
|
///////////////////////////////////
|
refreshData: function() {
|
this.filterObj = {};
|
if (this.onRefreshData) {
|
this.onRefreshData.call(this, arguments);
|
return
|
}
|
this.onQuery();
|
},
|
approvalData: function(code) {
|
//1.
|
this.operationtype = "approval";
|
|
//2. get config and go
|
var config = new Config(), go = true;
|
if (this.onApproveData) {
|
go = this.onApproveData.call(this, config, code);
|
}
|
|
//3. popup
|
if (go) {
|
|
if (config.totab) {
|
if (config.url) {
|
if (config.text.length > 4) {
|
config.text = config.text.substr(0, 4) + "...";
|
}
|
}
|
var parames = {
|
totab: true,
|
url: config.url,
|
sceneCode: config.sceneCode,
|
data: config.data,
|
delta: config.delta,
|
disabled: config.disabled,
|
disabledone: config.disabledone,
|
operationtype: "approval",
|
parentOption: window.top.tab.selected.option
|
};
|
if(config.id) {
|
parames.id = config.id
|
}
|
Root.popupParames = parames;
|
window.top.tab.open(config,true);
|
|
|
}
|
else {
|
this.doPopup(config);
|
}
|
}
|
},
|
|
//表格是否编辑
|
setEditTableData: function() {
|
if (this.onSetEditTableData) {
|
this.onSetEditTableData.call(this, arguments);
|
return
|
}
|
|
this.isRefresh = false;
|
this.isEditTableData = !this.isEditTableData;
|
this.tableDataAfter();
|
},
|
|
getData: function(page) {
|
this.pagesize = page.pagesize;
|
this.pagenum = page.pagenum;
|
this.doQuery();
|
},
|
|
//查询
|
onQuery: function(total_tab) {
|
//查询
|
this.pagenum = 1;
|
this.doQuery(total_tab);
|
},
|
onInitFilter: function() {
|
//清空
|
this.filterObj = {};
|
this.onQuery();
|
},
|
|
onEditFilter: function() {
|
//选择查询字段
|
},
|
doQuery: function(total_tab) {
|
let me = this;
|
let filter_ = "1=1";
|
this.filterList = [];
|
this.selectedrow = {};
|
filter_ += this.filter_;
|
for(var k in this.filterObj) {
|
let k_val = this.filterObj[k];
|
|
if (typeof(k_val) == "string") {
|
this.filterObj[k] = k_val = k_val.replace(/(^\s*)|(\s*$)/g, "");
|
}
|
|
let fieldObj_ = this.filterFieldsObj[k];
|
|
if (!fieldObj_) {
|
continue
|
}
|
|
let type_ = fieldObj_.type;
|
let valfield_ = fieldObj_.valfield;
|
if (type_ == "popup" && valfield_) {
|
k_val = this.filterObj[valfield_];
|
if (!this.filterObj[valfield_] && this.filterObj[k]) {
|
k_val = this.filterObj[k];
|
}
|
}
|
|
let field_ = fieldObj_.field;
|
let fieldtype_ = "equal";
|
|
let isnull = false;
|
let ornullval_ = fieldObj_.ornullval;
|
if (ornullval_) {
|
var nullvals_ = ornullval_.split(";");
|
nullvals_.map(v=>{
|
if (v == k_val) {
|
isnull = true;
|
}
|
});
|
}
|
|
if (fieldObj_.fieldname) {
|
field_ = fieldObj_.fieldname
|
}
|
if (fieldObj_.fieldtype) {
|
fieldtype_ = fieldObj_.fieldtype
|
}
|
|
//传条件数组由后端拼接筛选数据
|
/* let filterListObj_ = {
|
field: field_,
|
val: k_val,
|
type: fieldtype_
|
}
|
|
this.filterList.push(filterListObj_);
|
*/
|
|
//传条件数据有前端拼接
|
if (fieldtype_ == "exists") {//自定义(子查询条件)不需要拼接
|
|
}
|
else if (type_ == "daterange" && k_val.length) {//期间筛选
|
//
|
var k_val_a = k_val[0];
|
var k_val_b = k_val[1];
|
|
if (fieldtype_ == "inScope") {//期间之内,不包含两端
|
filter_ += " and (" + field_ + ">'" + k_val_a + "' and " + field_ + "<'" + k_val_b + "')";
|
}
|
else if (fieldtype_ == "outScope") {//期间之外,不包含两端
|
filter_ += " and (" + field_ + "<'" + k_val_a + "' or " + field_ + ">'" + k_val_b + "')";
|
}
|
else if (fieldtype_ == "inScopeInclude") {//期间之内,包含两端
|
var k_val_a_ = new Date(k_val_a);
|
var k_val_b_ = new Date(k_val_b);
|
//var preDate = new Date(k_val_a_.getTime() - 24*60*60*1000); //前一天
|
var nextDate = new Date(k_val_b_.getTime() + 24*60*60*1000); //后一天
|
//当天的凌晨
|
k_val_a = dateFormat(k_val_a_, "yyyy-MM-dd") ;
|
//后一天的凌晨
|
k_val_b = dateFormat(nextDate, "yyyy-MM-dd");
|
|
//filter_ += " and ((" + field_ + ">'" + k_val_a + "' and " + field_ + "<'" + k_val_b + "') or (" + field_ + "='" + k_val_a + "' or " + field_ + "='" + k_val_b + "'))";
|
filter_ += " and ((" + field_ + ">'" + k_val_a + "' and " + field_ + "<'" + k_val_b + "') or (" + field_ + "='" + k_val_a + "'))";
|
}
|
}
|
else if (isnull && type_ != "daterange") {
|
//注释:type: equal(等于)/in(在多个数据中)/like(模糊)/minval(最小值)/maxval(最大值)/mininclude(最小且包含该值)/maxinclude(最大且包含该值)
|
if (fieldtype_ == "like") {
|
filter_ += " and (" + field_ + " like '%" + k_val +"%' or " + field_ + " is null)";
|
}
|
else if (fieldtype_ == "in") {
|
filter_ += " and (" + field_ + " in ('" + k_val +"') or " + field_ + " is null)";
|
}
|
else if (fieldtype_ == "minval") {
|
filter_ += " and (" + field_ + " > '" + k_val +"' or " + field_ + " is null)";
|
}
|
else if (fieldtype_ == "maxval") {
|
filter_ += " and (" + field_ + " < '" + k_val +"' or " + field_ + " is null)";
|
}
|
else if (fieldtype_ == "mininclude") {
|
filter_ += " and ((" + field_ + " > '" + k_val +"' or " + field_ + " = '" + k_val +"') or " + field_ + " is null)";
|
}
|
else if (fieldtype_ == "maxinclude") {
|
filter_ += " and ((" + field_ + " < '" + k_val +"' or " + field_ + " = '" + k_val +"') or " + field_ + " is null)";
|
}
|
else {
|
filter_ += " and (" + field_ + " = '" + k_val +"' or " + field_ + " is null)";
|
}
|
}
|
else if (typeof(k_val) != "string") {
|
filter_ += " and " + field_ + " = " + k_val ;
|
}
|
else if (type_ != "daterange" && k_val) {
|
//注释:type: equal(等于)/in(在多个数据中)/like(模糊)/minval(最小值)/maxval(最大值)/mininclude(最小且包含该值)/maxinclude(最大且包含该值)
|
|
|
if (fieldtype_ == "like") {
|
filter_ += " and " + field_ + " like '%" + k_val +"%'";
|
}
|
else if (fieldtype_ == "in") {
|
filter_ += " and " + field_ + " in ('" + k_val +"')";
|
}
|
else if (fieldtype_ == "minval") {
|
filter_ += " and " + field_ + " > '" + k_val +"'";
|
}
|
else if (fieldtype_ == "maxval") {
|
filter_ += " and " + field_ + " < '" + k_val +"'";
|
}
|
else if (fieldtype_ == "mininclude") {
|
filter_ += " and (" + field_ + " > '" + k_val +"' or " + field_ + " = '" + k_val +"') ";
|
}
|
else if (fieldtype_ == "maxinclude") {
|
filter_ += " and (" + field_ + " < '" + k_val +"' or " + field_ + " = '" + k_val +"') ";
|
}
|
else if (fieldtype_ == "month") {
|
var k_val_ = k_val + "-01";
|
var k_val_next_ = "";
|
var currentDate = new Date(k_val);
|
var currentY = currentDate.getFullYear();
|
var currentM = currentDate.getMonth()+1;
|
|
if (currentM == 12) {
|
var y_next_ = currentY + 1;
|
k_val_next_ = y_next_ + "-" + "01-01";
|
}
|
else {
|
var m_next_ = currentM + 1;
|
k_val_next_ = currentY + "-" + m_next_ + "-01";
|
}
|
|
var k_val_a = k_val_;
|
var k_val_b = k_val_next_;
|
|
filter_ += " and ((" + field_ + ">'" + k_val_a + "' and " + field_ + "<'" + k_val_b + "') or (" + field_ + "='" + k_val_a + "' or " + field_ + "='" + k_val_b + "'))";
|
}
|
else {
|
filter_ += " and " + field_ + " = '" + k_val +"'";
|
}
|
}
|
|
}
|
|
if (this.filterObjBydefault != {}) {
|
for(var k in this.filterObjBydefault) {
|
let k_val = this.filterObjBydefault[k];
|
filter_ += " and " + k + " = '" + k_val +"'";
|
}
|
}
|
|
if (this.filterTxt) {
|
filter_ += " and " + this.filterTxt;
|
}
|
|
let param_ = {
|
isClientMode: false,
|
dataname: this.dataname,
|
filterList: this.filterList,
|
filter: filter_,
|
orderby: this.orderby,
|
page: {
|
no: this.pagenum,
|
pagesize: this.pagesize
|
},
|
//attachmeta: true
|
}
|
|
if (this.paramObjBydefault != {}) {
|
for(var k in this.paramObjBydefault) {
|
let k_val = this.paramObjBydefault[k];
|
param_[k] = k_val;
|
}
|
}
|
|
me.tableData = [];
|
me.tableloading = true;
|
Server.call("root/data/getEntitySet", param_, function(result) {
|
console.log(result);
|
me.tableloading = false;
|
|
if (me[total_tab] || me[total_tab] == 0) {
|
me[total_tab] = 0;
|
if (me.totaltab == total_tab) {
|
me.total = me[total_tab];
|
}
|
}
|
else {
|
me.total = 0;
|
}
|
|
if (result && result.data && result.data.entityset) {
|
var data_ = result.data.entityset;
|
if (me[total_tab] || me[total_tab] == 0) {
|
me[total_tab] = result.data.page.recordcount;
|
if (me.totaltab == total_tab) {
|
me.total = me[total_tab];
|
}
|
}
|
else {
|
me.total = result.data.page.recordcount;
|
}
|
|
me.tableData = data_;
|
}
|
|
me.tableDataAfter();
|
});
|
},
|
|
getFilterData: function(filter, isnotencode) {
|
var filter_ = filter ? filter : "1=1";
|
for(var k in this.filterObj) {
|
let k_val = this.filterObj[k];
|
|
if (typeof(k_val) == "string") {
|
this.filterObj[k] = k_val = k_val.replace(/(^\s*)|(\s*$)/g, "");
|
}
|
|
let fieldObj_ = this.filterFieldsObj[k];
|
|
if (!fieldObj_) {
|
continue
|
}
|
|
let type_ = fieldObj_.type;
|
let valfield_ = fieldObj_.valfield;
|
if (type_ == "popup" && valfield_) {
|
k_val = this.filterObj[valfield_];
|
if (!this.filterObj[valfield_] && this.filterObj[k]) {
|
k_val = this.filterObj[k];
|
}
|
}
|
|
let field_ = fieldObj_.field;
|
let fieldtype_ = "equal";
|
|
let isnull = false;
|
let ornullval_ = fieldObj_.ornullval;
|
if (ornullval_) {
|
var nullvals_ = ornullval_.split(";");
|
nullvals_.map(v=>{
|
if (v == k_val) {
|
isnull = true;
|
}
|
});
|
}
|
|
if (fieldObj_.fieldname) {
|
field_ = fieldObj_.fieldname
|
}
|
if (fieldObj_.fieldtype) {
|
fieldtype_ = fieldObj_.fieldtype
|
}
|
|
if (type_ == "daterange" && k_val.length) {//期间筛选
|
//
|
var k_val_a = k_val[0];
|
var k_val_b = k_val[1];
|
|
if (fieldtype_ == "inScope") {//期间之内,不包含两端
|
filter_ += " and (" + field_ + ">'" + k_val_a + "' and " + field_ + "<'" + k_val_b + "')";
|
}
|
else if (fieldtype_ == "outScope") {//期间之外,不包含两端
|
filter_ += " and (" + field_ + "<'" + k_val_a + "' or " + field_ + ">'" + k_val_b + "')";
|
}
|
else if (fieldtype_ == "inScopeInclude") {//期间之内,包含两端
|
var k_val_a_ = new Date(k_val_a);
|
var k_val_b_ = new Date(k_val_b);
|
//var preDate = new Date(k_val_a_.getTime() - 24*60*60*1000); //前一天
|
var nextDate = new Date(k_val_b_.getTime() + 24*60*60*1000); //后一天
|
//当天的凌晨
|
k_val_a = dateFormat(k_val_a_, "yyyy-MM-dd") ;
|
//后一天的凌晨
|
k_val_b = dateFormat(nextDate, "yyyy-MM-dd");
|
|
//filter_ += " and ((" + field_ + ">'" + k_val_a + "' and " + field_ + "<'" + k_val_b + "') or (" + field_ + "='" + k_val_a + "' or " + field_ + "='" + k_val_b + "'))";
|
filter_ += " and ((" + field_ + ">'" + k_val_a + "' and " + field_ + "<'" + k_val_b + "') or (" + field_ + "='" + k_val_a + "'))";
|
}
|
}
|
else if (isnull && type_ != "daterange") {
|
//注释:type: equal(等于)/in(在多个数据中)/like(模糊)/minval(最小值)/maxval(最大值)/mininclude(最小且包含该值)/maxinclude(最大且包含该值)
|
if (fieldtype_ == "like") {
|
filter_ += " and (" + field_ + " like '%" + k_val +"%' or " + field_ + " is null)";
|
}
|
else if (fieldtype_ == "in") {
|
filter_ += " and (" + field_ + " in ('" + k_val +"') or " + field_ + " is null)";
|
}
|
else if (fieldtype_ == "minval") {
|
filter_ += " and (" + field_ + " > '" + k_val +"' or " + field_ + " is null)";
|
}
|
else if (fieldtype_ == "maxval") {
|
filter_ += " and (" + field_ + " < '" + k_val +"' or " + field_ + " is null)";
|
}
|
else if (fieldtype_ == "mininclude") {
|
filter_ += " and ((" + field_ + " > '" + k_val +"' or " + field_ + " = '" + k_val +"') or " + field_ + " is null)";
|
}
|
else if (fieldtype_ == "maxinclude") {
|
filter_ += " and ((" + field_ + " < '" + k_val +"' or " + field_ + " = '" + k_val +"') or " + field_ + " is null)";
|
}
|
else {
|
filter_ += " and (" + field_ + " = '" + k_val +"' or " + field_ + " is null)";
|
}
|
}
|
else if (typeof(k_val) != "string") {
|
filter_ += " and " + field_ + " = " + k_val ;
|
}
|
else if (type_ != "daterange" && k_val) {
|
//注释:type: equal(等于)/in(在多个数据中)/like(模糊)/minval(最小值)/maxval(最大值)/mininclude(最小且包含该值)/maxinclude(最大且包含该值)
|
|
|
if (fieldtype_ == "like") {
|
filter_ += " and " + field_ + " like '%" + k_val +"%'";
|
}
|
else if (fieldtype_ == "in") {
|
filter_ += " and " + field_ + " in ('" + k_val +"')";
|
}
|
else if (fieldtype_ == "minval") {
|
filter_ += " and " + field_ + " > '" + k_val +"'";
|
}
|
else if (fieldtype_ == "maxval") {
|
filter_ += " and " + field_ + " < '" + k_val +"'";
|
}
|
else if (fieldtype_ == "mininclude") {
|
filter_ += " and (" + field_ + " > '" + k_val +"' or " + field_ + " = '" + k_val +"') ";
|
}
|
else if (fieldtype_ == "maxinclude") {
|
filter_ += " and (" + field_ + " < '" + k_val +"' or " + field_ + " = '" + k_val +"') ";
|
}
|
else if (fieldtype_ == "month") {
|
var k_val_ = k_val + "-01";
|
var k_val_next_ = "";
|
var currentDate = new Date(k_val);
|
var currentY = currentDate.getFullYear();
|
var currentM = currentDate.getMonth()+1;
|
|
if (currentM == 12) {
|
var y_next_ = currentY + 1;
|
k_val_next_ = y_next_ + "-" + "01-01";
|
}
|
else {
|
var m_next_ = currentM + 1;
|
k_val_next_ = currentY + "-" + m_next_ + "-01";
|
}
|
|
var k_val_a = k_val_;
|
var k_val_b = k_val_next_;
|
|
filter_ += " and ((" + field_ + ">'" + k_val_a + "' and " + field_ + "<'" + k_val_b + "') or (" + field_ + "='" + k_val_a + "' or " + field_ + "='" + k_val_b + "'))";
|
}
|
else {
|
filter_ += " and " + field_ + " = '" + k_val +"'";
|
}
|
}
|
}
|
|
if (this.filterObjBydefault != {}) {
|
for(var k in this.filterObjBydefault) {
|
let k_val = this.filterObjBydefault[k];
|
filter_ += " and " + k + " = '" + k_val +"'";
|
}
|
}
|
|
if (this.filterTxt) {
|
filter_ += " and " + this.filterTxt;
|
}
|
|
|
if (isnotencode) {
|
return filter_;
|
}
|
else {
|
return encodeURI(filter_);
|
}
|
|
},
|
|
tableDataAfter: function() {
|
let me = this;
|
if (this.onTableDataAfter) {
|
this.onTableDataAfter.call(this, arguments);
|
return
|
}
|
|
if (this.tableData.length > 0){
|
this.$nextTick(function(){
|
this.isRefresh = true;
|
this.$nextTick(function(){
|
if (me.pageAttr && me.pageAttr.heightType == "table") {
|
me.tableHeight = settableHeight(me.$refs.table1.$el, me.pagesize) - 10;
|
}
|
else if (me.pageAttr && me.pageAttr.heightType == "page") {
|
var el_list = [];
|
if (me.$refs.form1 && me.$refs.form1.$el) {
|
el_list.push(me.$refs.form1.$el);
|
}
|
|
me.tableHeight = setpageHeight(me.$refs.table1.$el, el_list) - 10;
|
}
|
})
|
})
|
}
|
else if (me.pageAttr && me.pageAttr.heightType == "page") {
|
var el_list = [];
|
if (me.$refs.form1 && me.$refs.form1.$el) {
|
el_list.push(me.$refs.form1.$el);
|
}
|
me.tableHeight = setpageHeight(me.$refs.table1.$el, el_list);
|
}
|
|
},
|
|
onInitFilterApprovalRecords: function() {
|
//清空
|
this.filterObj = {};
|
this.onQueryApprovalRecords();
|
},
|
|
getApprovalRecordsData: function(page) {
|
this.pagesize = page.pagesize;
|
this.pagenum = page.pagenum;
|
this.getMyApprovalRecords();
|
},
|
|
getdlempcode(type) {
|
var me = this;
|
let param_ = {
|
isClientMode: false,
|
dataname: "actApproveEmp",
|
filter: "emp_code = '"+window.top.userinfo.employee.code+"' and type='"+type+"' and ifnull(proxy_emp_code, '') <> ''",
|
}
|
this.dl_emp_codestrs = "";
|
Server.call("root/data/getEntitySet", param_, function(result) {
|
var dl_emp_codestrs = "";
|
if (result.data.entityset) {
|
result.data.entityset.map(e=>{
|
dl_emp_codestrs += " ,'" + e.proxy_emp_code + "'";
|
})
|
};
|
me.dl_emp_codestrs = dl_emp_codestrs;
|
});
|
},
|
|
onQueryApprovalRecords: function(total_tab) {
|
//查询
|
this.pagenum = 1;
|
this.getMyApprovalRecords(total_tab);
|
},
|
|
getMyApprovalRecords: function(total_tab) {
|
let me = this;
|
let filter_ = "1=1";
|
this.filterList = [];
|
this.selectedrow = {};
|
filter_ += this.filter_;
|
for(var k in this.filterObj) {
|
let k_val = this.filterObj[k];
|
|
if (typeof(k_val) == "string") {
|
this.filterObj[k] = k_val = k_val.replace(/(^\s*)|(\s*$)/g, "");
|
}
|
|
let fieldObj_ = this.filterFieldsObj[k];
|
if(this.filterFieldsObj_records[k]) {
|
fieldObj_ = this.filterFieldsObj_records[k];
|
}
|
|
if (!fieldObj_) {
|
continue
|
}
|
|
let type_ = fieldObj_.type;
|
let valfield_ = fieldObj_.valfield;
|
if (type_ == "popup" && valfield_) {
|
k_val = this.filterObj[valfield_];
|
}
|
|
let field_ = fieldObj_.field;
|
let fieldtype_ = "equal";
|
|
let isnull = false;
|
let ornullval_ = fieldObj_.ornullval;
|
if (ornullval_) {
|
var nullvals_ = ornullval_.split(";");
|
nullvals_.map(v=>{
|
if (v == k_val) {
|
isnull = true;
|
}
|
});
|
}
|
|
if (fieldObj_.fieldname) {
|
var fieldnamelist = fieldObj_.fieldname.split(".");
|
field_ = fieldnamelist[fieldnamelist.length - 1 ];
|
//field_ = fieldObj_.fieldname
|
}
|
|
if (fieldObj_.fieldhistoryname) {
|
field_ = fieldObj_.fieldhistoryname
|
}
|
|
if (fieldObj_.fieldtype) {
|
fieldtype_ = fieldObj_.fieldtype
|
}
|
|
//传条件数据有前端拼接
|
if (type_ == "daterange" && k_val.length) {//期间筛选
|
//
|
var k_val_a = k_val[0];
|
var k_val_b = k_val[1];
|
|
if (fieldtype_ == "inScope") {//期间之内,不包含两端
|
filter_ += " and (" + field_ + ">'" + k_val_a + "' and " + field_ + "<'" + k_val_b + "')";
|
}
|
else if (fieldtype_ == "outScope") {//期间之外,不包含两端
|
filter_ += " and (" + field_ + "<'" + k_val_a + "' or " + field_ + ">'" + k_val_b + "')";
|
}
|
else if (fieldtype_ == "inScopeInclude") {//期间之内,包含两端
|
var k_val_a_ = new Date(k_val_a);
|
var k_val_b_ = new Date(k_val_b);
|
//var preDate = new Date(k_val_a_.getTime() - 24*60*60*1000); //前一天
|
var nextDate = new Date(k_val_b_.getTime() + 24*60*60*1000); //后一天
|
//当天的凌晨
|
k_val_a = dateFormat(k_val_a_, "yyyy-MM-dd") ;
|
//后一天的凌晨
|
k_val_b = dateFormat(nextDate, "yyyy-MM-dd");
|
|
//filter_ += " and ((" + field_ + ">'" + k_val_a + "' and " + field_ + "<'" + k_val_b + "') or (" + field_ + "='" + k_val_a + "' or " + field_ + "='" + k_val_b + "'))";
|
filter_ += " and ((" + field_ + ">'" + k_val_a + "' and " + field_ + "<'" + k_val_b + "') or (" + field_ + "='" + k_val_a + "'))";
|
}
|
}
|
else if (isnull && type_ != "daterange") {
|
//注释:type: equal(等于)/in(在多个数据中)/like(模糊)/minval(最小值)/maxval(最大值)/mininclude(最小且包含该值)/maxinclude(最大且包含该值)
|
if (fieldtype_ == "like") {
|
filter_ += " and (" + field_ + " like '%" + k_val +"%' or " + field_ + " is null)";
|
}
|
else if (fieldtype_ == "in") {
|
filter_ += " and (" + field_ + " in ('" + k_val +"') or " + field_ + " is null)";
|
}
|
else if (fieldtype_ == "minval") {
|
filter_ += " and (" + field_ + " > '" + k_val +"' or " + field_ + " is null)";
|
}
|
else if (fieldtype_ == "maxval") {
|
filter_ += " and (" + field_ + " < '" + k_val +"' or " + field_ + " is null)";
|
}
|
else if (fieldtype_ == "mininclude") {
|
filter_ += " and ((" + field_ + " > '" + k_val +"' or " + field_ + " = '" + k_val +"') or " + field_ + " is null)";
|
}
|
else if (fieldtype_ == "maxinclude") {
|
filter_ += " and ((" + field_ + " < '" + k_val +"' or " + field_ + " = '" + k_val +"') or " + field_ + " is null)";
|
}
|
else {
|
filter_ += " and (" + field_ + " = '" + k_val +"' or " + field_ + " is null)";
|
}
|
}
|
else if (type_ != "daterange") {
|
//注释:type: equal(等于)/in(在多个数据中)/like(模糊)/minval(最小值)/maxval(最大值)/mininclude(最小且包含该值)/maxinclude(最大且包含该值)
|
if (fieldtype_ == "like") {
|
filter_ += " and " + field_ + " like '%" + k_val +"%'";
|
}
|
else if (fieldtype_ == "in") {
|
filter_ += " and " + field_ + " in ('" + k_val +"')";
|
}
|
else if (fieldtype_ == "minval") {
|
filter_ += " and " + field_ + " > '" + k_val +"'";
|
}
|
else if (fieldtype_ == "maxval") {
|
filter_ += " and " + field_ + " < '" + k_val +"'";
|
}
|
else if (fieldtype_ == "mininclude") {
|
filter_ += " and (" + field_ + " > '" + k_val +"' or " + field_ + " = '" + k_val +"') ";
|
}
|
else if (fieldtype_ == "maxinclude") {
|
filter_ += " and (" + field_ + " < '" + k_val +"' or " + field_ + " = '" + k_val +"') ";
|
}else if (fieldtype_ == "supplyStatus") {
|
if(k_val == "1") {
|
filter_ += " and supply_cnt = 0 or supply_cnt is null";
|
}else if(k_val == "2") {
|
filter_ += " and supply_cnt < neet_cnt";
|
|
}else if(k_val == "3") {
|
filter_ += " and supply_cnt = neet_cnt";
|
}
|
}else {
|
filter_ += " and " + field_ + " = '" + k_val +"'";
|
}
|
}
|
}
|
|
if (this.filterTxt) {
|
filter_ += " and " + this.filterTxt;
|
}
|
|
var dataname_ = this.dataname;
|
if (this.dataname_records) {
|
dataname_ = this.dataname_records;
|
}
|
|
let param_ = {
|
isClientMode: false,
|
dataname: dataname_,
|
//filterList: this.filterList,
|
type: this.approvaltype,
|
fields: this.approvalfields,
|
|
filter: filter_,
|
orderby: this.orderby,
|
page: {
|
no: this.pagenum,
|
pagesize: this.pagesize
|
},
|
//attachmeta: true
|
}
|
|
if (this.paramRecordsObjBydefault != {}) {
|
for(var k in this.paramRecordsObjBydefault) {
|
let k_val = this.paramRecordsObjBydefault[k];
|
param_[k] = k_val;
|
}
|
}
|
|
me.tableData_records = [];
|
me.tableloading = true;
|
Server.call("root/api/getMyHistory", param_, function(result) {
|
console.log(result);
|
me.tableloading = false;
|
|
if (me[total_tab] || me[total_tab] == 0) {
|
me[total_tab] = 0;
|
if (me.totaltab == total_tab) {
|
me.total = me[total_tab];
|
}
|
}
|
else {
|
me.total = 0;
|
}
|
|
if (result && result.data && result.data.entityset) {
|
var data_ = result.data.entityset;
|
if (me[total_tab] || me[total_tab] == 0) {
|
me[total_tab] = result.data.page.recordcount;
|
if (me.totaltab == total_tab) {
|
me.total = me[total_tab];
|
}
|
}
|
else {
|
me.total = result.data.page.recordcount;
|
}
|
|
me.tableData_records = data_;
|
me.tableData = data_;
|
|
if(me.approvaltype == "product_plan") {
|
for (var i = 0; i < me.tableData.length; i++) {
|
if (me.tableData[i].supply_cnt == 0 || me.tableData[i].supply_cnt == null) {
|
me.tableData[i].supply_status = "待反馈";
|
} else if (me.tableData[i].supply_cnt < me.tableData[i].neet_cnt) {
|
me.tableData[i].supply_status = "部分反馈";
|
}else {
|
me.tableData[i].supply_status = "完成反馈";
|
}
|
}
|
}
|
}
|
|
me.tableDataAfter_records();
|
});
|
},
|
|
tableDataAfter_records: function() {
|
let me = this;
|
if (this.onTableDataAfterRecords) {
|
this.onTableDataAfterRecords.call(this, arguments);
|
return
|
}
|
|
if (this.tableData_records.length > 0){
|
this.$nextTick(function(){
|
this.$nextTick(function(){
|
if (me.pageAttr && me.pageAttr.heightType == "table") {
|
me.tableHeight_records = settableHeight(me.$refs.table_records.$el, me.pagesize);
|
}
|
else if (me.pageAttr && me.pageAttr.heightType == "page") {
|
var el_list = [];
|
if (me.$refs.form_records) {
|
el_list.push(me.$refs.form_records.$el);
|
}
|
if (me.$refs.table_records) {
|
me.tableHeight_records = setpageHeight(me.$refs.table_records.$el, el_list);
|
}
|
}
|
|
me.isRefresh = true;
|
})
|
})
|
}
|
else if (me.pageAttr && me.pageAttr.heightType == "page") {
|
var el_list = [];
|
if (me.$refs.form_records) {
|
el_list.push(me.$refs.form_records.$el);
|
}
|
if(me.$refs.table_records) {
|
me.tableHeight_records = setpageHeight(me.$refs.table_records.$el, el_list);
|
}
|
|
me.isRefresh = true;
|
}
|
},
|
|
|
addData: function() {
|
//1.
|
this.operationtype = "add";
|
//this.selectedrow = {};
|
|
//2. get config and go
|
var config = new Config(), go = true;
|
|
if (this.onAddData) {
|
go = this.onAddData.call(this, config);
|
}
|
|
//3. popup
|
if (go) {
|
if (config.totab) {
|
if (config.url) {
|
if (config.text.length > 4) {
|
config.text = config.text.substr(0, 4) + "...";
|
}
|
}
|
var parames = {
|
totab: true,
|
url: config.url,
|
sceneCode: config.sceneCode,
|
data: config.data,
|
delta: config.delta,
|
disabled: config.disabled,
|
disabledone: config.disabledone,
|
operationtype: "add",
|
parentOption: window.top.tab.selected.option
|
};
|
|
Root.popupParames = parames;
|
|
window.top.tab.open(config);
|
}
|
else {
|
this.doPopup(config);
|
}
|
}
|
},
|
editData: function(scope) {
|
//1.
|
this.operationtype = "edit";
|
//this.selectedrow = scope.row;
|
|
//2. get config and go
|
var config = new Config(), go = true;
|
if (this.onEditData) {
|
go = this.onEditData.call(this, config, scope);
|
}
|
|
//3. popup
|
if (go) {
|
if (config.totab) {
|
if (config.url) {
|
if (config.text.length > 4) {
|
config.text = config.text.substr(0, 4) + "...";
|
}
|
}
|
var parames = {
|
totab: true,
|
url: config.url,
|
sceneCode: config.sceneCode,
|
data: config.data,
|
delta: config.delta,
|
disabled: config.disabled,
|
disabledone: config.disabledone,
|
operationtype: "edit",
|
parentOption: window.top.tab.selected.option
|
};
|
|
Root.popupParames = parames;
|
|
window.top.tab.open(config);
|
}
|
else {
|
this.doPopup(config);
|
}
|
}
|
},
|
delData: function(scope) {
|
let me = this;
|
|
if (this.onDelData) {
|
this.onDelData.call(this, scope);
|
return
|
}
|
|
let row = scope.row;
|
let index_ = scope.$index;
|
let name_ = "该数据";
|
|
if (!this.dataname) {
|
Root.message({
|
type: 'warning',
|
message: '该事件需指定数据对象'
|
});
|
return
|
}
|
if (!row.id) {
|
Root.message({
|
type: 'warning',
|
message: '该事件需存在数据ID'
|
});
|
return
|
}
|
if (row.name) {
|
name_ = "_" + row.name + "_";
|
}
|
|
Root.confirm('确定删除' + name_ + '吗?', '删除提示', {
|
confirmButtonText: '删除',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
let param = {
|
id: row.id,
|
isClientMode: false,
|
dataname: this.dataname,
|
}
|
Server.call("root/data/deleteEntity", param, function(result) {
|
console.log(result);
|
Root.message({
|
type: 'success',
|
message: '删除成功!'
|
});
|
me.doQuery();
|
});
|
}).catch(() => {
|
Root.message({
|
type: 'info',
|
message: '已取消删除'
|
});
|
});
|
},
|
|
/*------------流程----------------*/
|
|
|
//审批通过
|
passApproval(dataType_,reason_,param_) {
|
let me = this;
|
var id = this.formData.id;
|
let isOverDue_ = true;
|
if(typeof this.formData.isOverDue == "boolean")
|
isOverDue_ = this.formData.isOverDue;
|
let param = {
|
orderId:id,
|
eventType:"approvalSuccess",
|
dataType:dataType_,
|
extra:{
|
variableMap:{ reason:reason_,
|
businessType:this.formData.business_type,
|
businessDepartType:this.formData.r_depart_type||"",
|
controlType:this.formData.control_type,
|
managerPartCode:this.formData.manager_part_code,
|
isOverDue:isOverDue_,
|
flowId:this.formData.flow_id || "",
|
attachment:this.attachment||""
|
}
|
|
},
|
isClientMode: false,
|
}
|
if(dataType_ == 'sales') {
|
param.extra.variableMap.agreementRecordId = me.formData.o_agreement_record_id ? me.formData.o_agreement_record_id: "";
|
}
|
if(param_) {
|
let keyarr = Object.keys(param_);
|
if(keyarr.length != 0) {
|
keyarr.map(key=>{
|
if(!param.extra.variableMap[key])
|
param.extra.variableMap[key] = param_[key]
|
})
|
}
|
}
|
|
Server.call("root/order/onEvent", param, function(result) {
|
console.log(result);
|
if (result.success){
|
Root.message({
|
type: 'success',
|
message: '审批成功'
|
});
|
this.reasonvisible = false;
|
if(me.fromDing) {
|
me.dingResult = true;
|
me.dingResultTxt = "审批成功"
|
return;
|
}
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, true);
|
}
|
}, function(result) {
|
|
Root.message({
|
type: 'warning',
|
message: '审批失败'
|
});
|
this.reasonvisible = false;
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, true);
|
});
|
},
|
returnApproval(flow_id) {
|
var me = this;
|
var config = {
|
hide_close: true,
|
width: "1000px",
|
height:"600px",
|
url: "../approval/ApprovalList_return.html",
|
delta: {
|
flow_id: flow_id,
|
},
|
callback:function(data,callback_) {
|
let url = window.top.RootSetting.url_act + "act/rejectByTask?userId=" + localStorage.getItem("id");
|
axios.post(url,data,{
|
contentType: "application/json;charset=utf-8",
|
timeout: 5*60*1000, //超时时间设置,单位毫秒
|
dataType: "json",
|
headers: {
|
"userId": localStorage.getItem("id")
|
}
|
}).then(data => {
|
if (data.data.success){
|
Root.message({
|
type: 'success',
|
message: '退回成功'
|
});
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, true);
|
}else{
|
Root.message({
|
type: 'warning',
|
message: data.data.data.message
|
});
|
}
|
if(callback_)
|
callback_();
|
})
|
.catch( (error) => {
|
console.log(error);
|
Root.message({
|
type: 'warning',
|
message: '退回失败'
|
});
|
|
});
|
|
}
|
};
|
this.doPopupByPublic(config);
|
},
|
//审批拒绝
|
refuseApproval(dataType_,reason_,param_) {
|
let me = this;
|
var row = this.selectedrow;
|
var id = this.formData.id;
|
let param = {
|
orderId:id,
|
eventType:"approvalFail",
|
dataType:dataType_,
|
extra:{
|
variableMap:{ reason:reason_,
|
businessType:this.formData.business_type,
|
businessDepartType:this.formData.r_depart_type||"",
|
controlType:this.formData.control_type,
|
managerPartCode:this.formData.manager_part_code,
|
isOverDue:this.formData.isOverDue||true,
|
flowId:this.formData.flow_id || "",
|
attachment:this.attachment||""
|
}
|
},
|
isClientMode: false,
|
}
|
if(dataType_ == 'sales') {
|
param.extra.variableMap.agreementRecordId = me.formData.o_agreement_record_id ? me.formData.o_agreement_record_id: "";
|
}
|
if(param_) {
|
let keyarr = Object.keys(param_);
|
if(keyarr.length != 0) {
|
keyarr.map(key=>{
|
if(!param.extra.variableMap[key])
|
param.extra.variableMap[key] = param_[key]
|
})
|
}
|
}
|
Server.call("root/order/onEvent", param, function(result) {
|
console.log(result);
|
|
Root.message({
|
type: 'success',
|
message: '拒绝审批成功'
|
});
|
this.reasonvisible = false;
|
if(me.fromDing) {
|
me.dingResult = true;
|
me.dingResultTxt = "拒绝审批成功"
|
return;
|
}
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, true);
|
},function(result) {
|
console.log(result);
|
|
Root.message({
|
type: 'error',
|
message: '拒绝审批失败'
|
});
|
this.reasonvisible = false;
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, true);
|
});
|
},
|
//作废
|
flow_Cancel: function(status_,code_,dataType_) {
|
let me = this;
|
var row = this.selectedrow;
|
|
if (!row || !row.id) {
|
Root.message({
|
type: 'warning',
|
message: '请先选择一条数据'
|
});
|
return false;
|
}
|
else if (row[status_] != "refuse" && row[status_] != "input") {
|
Root.message({
|
type: 'warning',
|
message: '当前状态不可作废'
|
});
|
return false;
|
}
|
Root.confirm('确定作废-' + row[code_] + '-吗?', '提示', {
|
confirmButtonText: "作废",
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
let param = {
|
orderId:row.id,
|
eventType:"cancellation",
|
dataType:dataType_,
|
isClientMode: false,
|
}
|
Server.call("root/order/onEvent", param, function(result) {
|
console.log(result);
|
if (result.success){
|
Root.message({
|
type: 'success',
|
message: '作废成功'
|
});
|
}else{
|
Root.message({
|
type: 'warning',
|
message: '作废失败'
|
});
|
}
|
|
me.onQuery();
|
});
|
|
}).catch(() => {
|
Root.message({
|
type: 'info',
|
message: '已取消'
|
});
|
});
|
},
|
//弹窗
|
showFilterPopup: function(obj) {
|
if (this.onshowFilterPopup) {
|
this.onshowFilterPopup.call(this, obj);
|
return;
|
}
|
},
|
|
rowClick: function(obj) {
|
this.selectedrow = obj.row;
|
if (this.onRowClick) {
|
this.onRowClick.call(this, obj);
|
return;
|
}
|
},
|
|
cellClick: function(obj) {
|
//1. get stlected
|
if (!obj.column.property){
|
return;
|
}
|
this.selectCellField = this.tableFieldsObj[obj.column.property];
|
this.selectCellData = obj.column.property ? obj.row[obj.column.property] : {};
|
|
//2. get config and go
|
var config = new Config(), go = true;
|
//2. fire
|
if (this.onCellClick) {
|
go = this.onCellClick.call(this, config, obj);
|
}
|
|
else {
|
if (this.selectCellField.clickContext && this.selectCellField.clickContext.type == "popup") {
|
config.combine({
|
url: this.selectCellField.clickContext.url,
|
sceneCode: this.selectCellField.clickContext.sceneCode,
|
data: obj.row,
|
delta: this.selectCellField.clickContext.delta ? this.selectCellField.clickContext.delta : {},
|
width: this.selectCellField.clickContext.width + "px"
|
})
|
}
|
else go = false;
|
}
|
|
//3. popup
|
if (go) {
|
config.title = clone(config.text);
|
config.operationtype = clone(this.operationtype);
|
if (config.totab) {
|
if (config.url) {
|
if (config.text.length > 4) {
|
config.text = config.text.substr(0, 4) + "...";
|
}
|
}
|
|
var callback_ = config.callback;
|
var parames = {
|
totab: true,
|
url: config.url,
|
title: config.title,
|
sceneCode: config.sceneCode,
|
data: config.data,
|
delta: config.delta,
|
disabled: config.disabled,
|
disabledone: config.disabledone,
|
parentOption: window.top.tab.selected.option,
|
callback: function(obj, callback) {
|
if (callback_) {
|
callback_(obj);
|
}
|
if (callback) {
|
callback();
|
}
|
}
|
};
|
|
Root.popupParames = parames;
|
|
window.top.tab.open(config);
|
}
|
else {
|
this.doPopup(config);
|
}
|
}
|
},
|
cellClickRecords: function(obj) {
|
//1. get stlected
|
if (!obj.column.property){
|
return;
|
}
|
this.selectCellField = this.tableFieldsObj_records[obj.column.property];
|
this.selectCellData = obj.column.property ? obj.row[obj.column.property] : {};
|
|
//2. get config and go
|
var config = new Config(), go = true;
|
|
//2. fire
|
if (this.onCellClick) {
|
go = this.onCellClick.call(this, config, obj);
|
}
|
|
else {
|
if (this.selectCellField.clickContext && this.selectCellField.clickContext.type == "popup") {
|
config.combine({
|
url: this.selectCellField.clickContext.url,
|
sceneCode: this.selectCellField.clickContext.sceneCode,
|
data: obj.row,
|
delta: this.selectCellField.clickContext.delta ? this.selectCellField.clickContext.delta : {},
|
width: this.selectCellField.clickContext.width + "px"
|
})
|
}
|
else go = false;
|
}
|
|
//3. popup
|
if (go) {
|
config.title = clone(config.text);
|
config.operationtype = clone(this.operationtype);
|
if (config.totab) {
|
if (config.url) {
|
if (config.text.length > 4) {
|
config.text = config.text.substr(0, 4) + "...";
|
}
|
}
|
|
var callback_ = config.callback;
|
var parames = {
|
totab: true,
|
url: config.url,
|
title: config.title,
|
sceneCode: config.sceneCode,
|
data: config.data,
|
delta: config.delta,
|
disabled: config.disabled,
|
disabledone: config.disabledone,
|
parentOption: window.top.tab.selected.option,
|
callback: function(obj, callback) {
|
if (callback_) {
|
callback_(obj);
|
}
|
if (callback) {
|
callback();
|
}
|
}
|
};
|
|
Root.popupParames = parames;
|
|
window.top.tab.open(config);
|
}
|
else {
|
this.doPopup(config);
|
}
|
}
|
},
|
|
h_procedure: function(field_, original_val, new_val, confirm_field, confirm_type, success_val, businessType) {
|
let me = this;
|
let row = this.selectedrow;
|
if (!row.id) {
|
Root.message({
|
type: 'warning',
|
message: '请先选择一条数据'
|
})
|
return;
|
}
|
|
if (this.selectedrow[field_] && this.selectedrow[field_] != original_val) {
|
Root.message({
|
type: 'warning',
|
message: this.selectedrow[field_]
|
})
|
return;
|
}
|
|
Root.confirm('确定' + confirm_type + '-' + row[confirm_field] + '-吗?', confirm_type + '提示', {
|
confirmButtonText: confirm_type,
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
var key = "y32P59DT";
|
var param_act = {
|
isClientMode: false,
|
businessId: row.id,
|
businessType: businessType,
|
}
|
|
Server.call("rootact/act/start/"+ key, param_act, function(result1) {
|
console.log(result1);
|
|
let paramObj = {};
|
for (var k in me.selectedrow) {
|
paramObj[k] = me.selectedrow[k];
|
}
|
paramObj[field_] = new_val;
|
|
paramObj.flow_id = result1.data.activitiId;
|
|
let param = paramObj;
|
param.isClientMode = false;
|
param.dataname = me.dataname;
|
|
Server.call("root/data/updateEntity/"+ me.dataname, param, function(result) {
|
console.log(result);
|
me.onQuery();
|
});
|
|
Root.message({
|
type: 'success',
|
message: success_val
|
});
|
|
});
|
|
}).catch(() => {
|
Root.message({
|
type: 'info',
|
message: '已取消'
|
});
|
});
|
},
|
|
//公共的弹窗
|
doPopupByPublic(config) {
|
config.title = clone(config.text);
|
/* if (config.newpage) {
|
let url = config.url;
|
let post_url = window.top.RootSetting.url.slice(0,-8)
|
window.open(url);
|
return;
|
} */
|
|
if (config.totab) {
|
if (config.url) {
|
if (config.text.length > 4) {
|
config.text = config.text.substr(0, 4) + "...";
|
}
|
}
|
var callback_ = config.callback;
|
var parames = {
|
totab: true,
|
url: config.url,
|
title: config.title,
|
sceneCode: config.sceneCode,
|
data: config.data,
|
delta: config.delta,
|
disabled: config.disabled,
|
disabledone: config.disabledone,
|
operationtype: config.operationtype,
|
parentOption: window.top.tab.selected.option,
|
callback: function(obj, callback) {
|
if (callback_) {
|
callback_(obj);
|
}
|
if (callback) {
|
callback();
|
}
|
}
|
};
|
Root.popupParames = parames;
|
|
window.top.tab.open(config);
|
}
|
else {
|
this.doPopup(config);
|
}
|
},
|
|
doPopup: function(popupObj) {
|
var me = this;
|
var callback_ = popupObj.callback;
|
var width_ = popupObj.width ? popupObj.width : "900px";
|
var height_ = popupObj.height ? popupObj.height : "550px";
|
var hide_close_ = popupObj.hide_close ? popupObj.hide_close : false;
|
|
var parames = {
|
width: width_,
|
height: height_,
|
url: popupObj.url,
|
//title: popupObj.title,
|
text: popupObj.text,
|
sceneCode: popupObj.sceneCode,
|
data: popupObj.data,
|
delta: popupObj.delta,
|
disabled: popupObj.disabled,
|
disabledone: popupObj.disabledone,
|
hide_close: hide_close_,
|
callback: function(obj, callback) {
|
if (callback_) {
|
callback_(obj);
|
}
|
if (callback) {
|
callback();
|
}
|
}
|
};
|
|
Root.popupParames = parames;
|
Root.showPopup(parames);
|
},
|
|
saveRowTable_popup: function(obj) {
|
var me = this;
|
var formData_ = obj.row;
|
var operationtype_ = this.operationtype;
|
|
if (operationtype_ == "edit") {//修改
|
var paramObj = {};
|
for (var k in formData_) {
|
paramObj[k] = formData_[k];
|
}
|
var param = paramObj;
|
param.isClientMode = false;
|
|
Server.call("root/data/updateEntity/" + this.dataname, param, function(result) {
|
console.log(result);
|
me.onQuery();
|
});
|
}
|
else if (operationtype_ == "approval") {//审批
|
var paramObj = {};
|
for (var k in formData_) {
|
paramObj[k] = formData_[k];
|
}
|
var param = paramObj;
|
param.isClientMode = false;
|
|
Server.call("root/data/updateEntity/" + this.dataname, param, function(result) {
|
console.log(result);
|
me.onQuery();
|
});
|
//for (var k in formData_) {
|
// this.selectedrow[k] = formData_[k];
|
//}
|
}
|
else {//新增
|
var param = formData_;
|
param.isClientMode = false;
|
|
Server.call("root/data/insertEntity/" + this.dataname, param, function(result) {
|
console.log(result);
|
me.onQuery();
|
});
|
}
|
},
|
|
getDataDifference(dataFields, old_data, new_data, isArray) {
|
var r_list = [];
|
if (dataFields.length == 0) {
|
return r_list;
|
}
|
/*
|
var l_ = {
|
type: 差异类型"add", del, update
|
field: 差异字段
|
fieldname: 差异字段名称
|
currentdata: //现值
|
pre: //原值
|
}
|
*/
|
if (isArray) {//数组
|
|
}
|
else {//对象
|
dataFields.map(f=>{
|
if (old_data[f.field] != new_data[f.field]) {
|
var l_ = {
|
type: "update",
|
field: f.field,
|
fieldname: f.name,
|
currentdata: new_data[f.field],
|
pre: old_data[f.field]
|
}
|
|
r_list.push(l_)
|
}
|
})
|
}
|
|
return r_list;
|
},
|
|
addlog(code, operatelogdataobj, fieldobjlist, callback) {
|
var id_ = uuid_short();
|
var fieldobjlist_ = [];
|
fieldobjlist.map(f=>{
|
var f_ = {
|
id: uuid_short(),
|
parentId: id_,
|
operateType: f.type,
|
field: f.field,
|
fieldName: f.fieldname,
|
pre: f.predata || "",
|
currentData: f.currentdata || ""
|
}
|
fieldobjlist_.push(f_);
|
});
|
|
var param = {
|
isClientMode: false,
|
id: id_,
|
type: code,
|
operateCode: localStorage.getItem("emp_code"),
|
operateName: localStorage.getItem("emp_name"),
|
userId: localStorage.getItem("id"),
|
businessId: operatelogdataobj.businessid,
|
businessName: operatelogdataobj.businessname,
|
dataName: operatelogdataobj.dataname,
|
operateRemark: operatelogdataobj.operateremark,
|
sourceType: "EC",
|
detailList: fieldobjlist_
|
}
|
Server.call("root/api/addCustomerLogs", param, function(result) {
|
if (result.success) {
|
if (callback) {
|
callback();
|
}
|
}
|
});
|
},
|
|
}
|
}
|
|
//
|
config = util.combineObj(config, default_);
|
Object.subClass.call(this);
|
|
//
|
var demand = {
|
dataname: config.data.dataname,
|
//dataRequest: config.data.dataRequest,
|
tabaleFieldsName: config.data.tabaleFieldsName,
|
filterFieldsName: config.data.filterFieldsName,
|
formFieldsName: config.data.formFieldsName,
|
}
|
var result = {};
|
getMeta(demand, result, function(meta) {
|
config.methods.onServerInitData.call(config, meta);
|
config.vue = new Vue(config);
|
|
return config;
|
});
|
|
/*
|
var me = this;
|
Server.call("root/data/getMeta/" + config.dataname, config.dataRequest, function(result) {
|
if (result.success) {
|
|
}
|
|
config.onServerData.call(me, result.data);
|
config.vue = new Vue(config);
|
})
|
*/
|
|
|
},
|
});
|
|
function getMeta(demand, result, callback) {
|
var tableFields_ = [];
|
var filterFields_ = [];
|
var formFields_ = [];
|
|
if(demand.tabaleFieldsName) {
|
tableFields_ = dataRootFields.tableFields[demand.tabaleFieldsName];
|
}
|
if(demand.filterFieldsName) {
|
filterFields_ = dataRootFields.filterFields[demand.filterFieldsName];
|
}
|
if(demand.formFieldsName) {
|
formFields_ = dataRootFields.formFields[demand.formFieldsName];
|
}
|
|
result = {
|
tableFields: tableFields_,
|
filterFields: filterFields_,
|
formFields: formFields_
|
}
|
|
//dogetMeta(demand.dataRequest, result, callback);
|
callback(result);
|
};
|
|
function dogetMeta(dataRequest, result, callback) {
|
if (dataRequest && dataRequest.length) {
|
var item = dataRequest[0];
|
if (typeof(item) == "string") {
|
result[item] = dataRoot.database[item];
|
dataRequest.remove(item);
|
|
dogetMeta(dataRequest, result, callback);
|
}
|
else {
|
if (item.isClientMode) {
|
result[item.name] = dataRoot.database[item.name];
|
dataRequest.remove(item);
|
|
dogetMeta(dataRequest, result, callback);
|
}
|
else {
|
var params = {
|
isClientMode: false,
|
dataname: item.name,
|
}
|
if(item.filter) {
|
params.filter = item.filter
|
}
|
|
Server.call("root/data/getEntitySet", params, function(result_) {
|
console.log(result_);
|
|
if (result_ && result_.data.entityset && result_.data.entityset.length) {
|
result[item.name] = result_.data.entityset;
|
|
//不是不是选项
|
if (!item.isnotoption) {
|
//是选项
|
result_.data.entityset.map(e=>{
|
if (!result.map) {
|
result.map = {};
|
}
|
|
if (!result.map[item.name]) {
|
result.map[item.name] = {};
|
}
|
|
result.map[item.name][e[item.code]] = e[item.label];
|
})
|
}
|
|
}
|
dataRequest.remove(item);
|
|
dogetMeta(dataRequest, result, callback);
|
});
|
}
|
}
|
}
|
else {
|
callback(result);
|
}
|
};
|
|
function hideLoading() {
|
document.getElementById('page_root').style.display = "block";
|
document.getElementById('page_loading').style.display = "none";
|
};
|
|
function getUrl(vue, url, params, callback, error_callback) {
|
url = baseUrl + url;
|
let lastUrl = url.substring(url.lastIndexOf("/") + 1);
|
|
commonAxios.get(url, {
|
params: params
|
}).then(data_ => {
|
if(typeof(data_.data) == "string"){
|
data_.data = JSON.parse(data_.data);
|
}
|
|
if (!data_.data.success) {
|
vue.$message({
|
showClose: true,
|
message: data_.data.errormessage,
|
type: 'error'
|
});
|
return;
|
}
|
var result = data_.data;
|
if (!isEncoded) {
|
var dataStr = JSON.stringify(data_.data);
|
// dataStr = percent2percent25(dataStr);
|
dataStr = decodeURI(dataStr);
|
var result = eval('(' + dataStr + ')');
|
}
|
|
if (callback) {
|
if (lastUrl && lastUrl.startsWith("get")) {
|
lastUrl = lastUrl.substring(3).toLowerCase();
|
if (result[lastUrl]) {
|
callback(result[lastUrl]);
|
} else {
|
callback(result);
|
}
|
} else {
|
callback(result);
|
}
|
}
|
})
|
.catch(error => {
|
vue.$message({
|
showClose: true,
|
message: url + ':请求出现错误:' + error,
|
type: 'error'
|
});
|
console.error(error);
|
if (error_callback) {
|
error_callback(error);
|
}
|
})
|
};
|
|
function uploadFile(vue, formData, callback, error_callback) {
|
uploadAxios.post(baseUrl +'file/exec', formData).then(data_ => {
|
vue.$message({
|
showClose: true,
|
message: '上传成功!',
|
type: 'success'
|
});
|
if (callback) {
|
callback(data_);
|
}
|
}).catch(error => {
|
vue.$message({
|
showClose: true,
|
message: ':请求出现错误:' + error,
|
type: 'error'
|
});
|
console.error(error);
|
if (error_callback) {
|
error_callback(error);
|
}
|
});
|
};
|
//敏感词检测
|
function sensitiveWord(vue, txt, callback) {
|
commonAxios.get(window.top.RootSetting.url_stock + "sensitiveWord/check" , {
|
text:text
|
})
|
.then(data => {
|
console.log(data);
|
if (data.data.check){
|
|
}else{
|
Root.message({
|
type: 'warning',
|
message: data.data.data.msg
|
});
|
return
|
}
|
})
|
.catch( (error) => {
|
console.log(error);
|
});
|
}
|
|
/* function uploadFileAnalysis(vue, formData, callback, error_callback) {
|
uploadAxios.post(baseUrl +'client/parseLicense', formData).then(data_ => {
|
vue.$message({
|
showClose: true,
|
message: '上传成功!',
|
type: 'success'
|
});
|
if (callback) {
|
callback(data_);
|
}
|
}).catch(error => {
|
vue.$message({
|
showClose: true,
|
message: ':请求出现错误:' + error,
|
type: 'error'
|
});
|
console.error(error);
|
if (error_callback) {
|
error_callback(error);
|
}
|
});
|
} */
|
|
|
function getDataList(me, dataName, params, callback, error_callback) {
|
params.dataName = dataName;
|
getUrl(me, "data/getEntitySet", params, callback, error_callback);
|
};
|
|
function getOneData(me, dataName, params, callback, error_callback) {
|
params.dataName = dataName;
|
getUrl(me, "data/getEntity", params, callback, error_callback);
|
};
|
|
function saveData(me, dataName, params, callback, error_callback) {
|
for(let one in params) {
|
let val = params[one];
|
if(val === "") {
|
params[one] = undefined;
|
}
|
}
|
params.dataName = dataName;
|
getUrl(me, "data/saveEntity", params, callback, error_callback);
|
};
|
|
function delData(me, dataName, id, callback, error_callback) {
|
let params = {
|
id:id,
|
dataName: dataName
|
};
|
|
getUrl(me, "data/deleteEntity", params, callback, error_callback);
|
};
|
|
function percent2percent25(URI) {
|
if (URI.indexOf('%') > -1) {
|
return URI.replace(/%/g, '%25')
|
} else {
|
return URI;
|
}
|
}
|
|
function postUrl(vue, url, params, callback, error_callback) {
|
url = baseUrl + url;
|
let lastUrl = url.substring(url.lastIndexOf("/") + 1);
|
let formData = new FormData();
|
for(let name in params) {
|
let val = params[name];
|
formData.append(name, val);
|
}
|
axios.post(url, formData)
|
.then(data_ => {
|
if (!data_.data.success) {
|
vue.$message({
|
showClose: true,
|
message: data_.data.errormessage,
|
type: 'error'
|
});
|
return;
|
}
|
if (callback) {
|
if (lastUrl && lastUrl.startsWith("get")) {
|
lastUrl = lastUrl.substring(3).toLowerCase();
|
if (data_.data[lastUrl]) {
|
callback(data_.data[lastUrl]);
|
} else {
|
callback(data_.data.data);
|
}
|
} else {
|
callback(data_.data.data);
|
}
|
}
|
})
|
.catch(error => {
|
vue.$message({
|
showClose: true,
|
message: url + ':请求出现错误:' + error,
|
type: 'error'
|
});
|
console.info(error);
|
if (error_callback) {
|
error_callback(error);
|
}
|
})
|
};
|
|
|
function postCommonUrl(vue, url, params, callback, error_callback) {
|
url = baseUrl + url;
|
let lastUrl = url.substring(url.lastIndexOf("/") + 1);
|
|
commonAxios.post(url, params)
|
.then(data_ => {
|
if (!data_.data.success) {
|
vue.$message({
|
showClose: true,
|
message: data_.data.errormessage,
|
type: 'error'
|
});
|
return;
|
}
|
if (callback) {
|
if (lastUrl && lastUrl.startsWith("get")) {
|
lastUrl = lastUrl.substring(3).toLowerCase();
|
if (data_.data[lastUrl]) {
|
callback(data_.data[lastUrl]);
|
} else {
|
callback(data_.data.data);
|
}
|
} else {
|
callback(data_.data.data);
|
}
|
}
|
})
|
.catch(error => {
|
vue.$message({
|
showClose: true,
|
message: url + ':请求出现错误:' + error,
|
type: 'error'
|
});
|
console.info(error);
|
if (error_callback) {
|
error_callback(error);
|
}
|
})
|
};
|
|
function objectToURI(object) {
|
if (!object) {
|
return null;
|
}
|
|
if (typeof object == "String") {
|
return encodeURI(object);
|
}
|
|
var param = null;
|
for (var prop in object) {
|
if (object[prop]) {
|
if (param) {
|
param = param + "&" + prop + "=" + encodeURI(object[prop]);
|
} else {
|
param = prop + "=" + encodeURI(object[prop]);
|
}
|
}
|
}
|
|
return param;
|
}
|
|
function getGetParams(url) {
|
// var url = window.location.href;
|
const search = url.split('?')[1]
|
if (!search) {
|
return {}
|
}
|
return JSON.parse(
|
'{"' +
|
decodeURIComponent(search)
|
.replace(/"/g, '\\"')
|
.replace(/&/g, '","')
|
.replace(/=/g, '":"') +
|
'"}'
|
)
|
}
|
|
function getGetParams_(url) {
|
// var url = window.location.href;
|
const search = url.split('?')[1];
|
var obj_ = {};
|
if (!search) {
|
return {}
|
}
|
|
var search_list = search.split("&");
|
|
search_list.map(e=>{
|
var e_list = e.split("=");
|
if (e_list.length == 2) {
|
var e_k = e_list[0].replace(/"/g, '\\"');
|
var e_v = e_list[1].replace(/"/g, '\\"');
|
|
obj_[e_k] = e_v;
|
}
|
})
|
|
return obj_;
|
}
|
|
|
function ArrayToTree(array_, name, parentId, parId, disabled_field, isencode) {
|
if(!parentId) {
|
parentId = "parent_id";
|
}
|
|
if(!name) {
|
name = "label";
|
}
|
|
if(!parId) {
|
parId = "";
|
}
|
|
let obj = {};
|
let result = [];
|
let list = JSON.parse(JSON.stringify(array_));
|
list.map(el => {
|
obj[el.id] = el;
|
})
|
let openId = "";
|
for (let i = 0, len = list.length; i < len; i++) {
|
let parentId_ = list[i][parentId];
|
//如果存在判断只读字段,并且该字段有值则设置该节点为只读
|
if (disabled_field) {
|
if(list[i][disabled_field]) {
|
list[i].disabled = true;
|
}
|
}
|
|
//设置显示字段
|
if (isencode) {
|
list[i].label = decodeURI(encodeURI( list[i][name]));//数据如果带“%”的需要编码再解码,否则会存在格式错误
|
list[i].name = decodeURI(encodeURI( list[i][name]));
|
}
|
else {
|
list[i].label = decodeURI(list[i][name]);
|
list[i].name = decodeURI(list[i][name]);
|
}
|
if (parentId_ == parId || !parentId_ || parentId_ == "null") {
|
if(!obj[list[i].id].children) {
|
obj[list[i].id].children = null;
|
}
|
result.push(list[i]);
|
continue;
|
} else if (obj[parentId_]) {
|
if (!obj[parentId_].children) {
|
obj[parentId_].children = [];
|
}
|
obj[parentId_].children.push(list[i]);
|
}
|
}
|
return result;
|
}
|
|
|
function listTOGroup(array_, id, parentId, label) {
|
let parId = "";
|
let obj = {};
|
let result = [];
|
let list = JSON.parse(JSON.stringify(array_));
|
list.map(el => {
|
obj[el.id] = el;
|
})
|
let openId = "";
|
for (let i = 0, len = list.length; i < len; i++) {
|
let parentId_ = list[i][parentId];
|
//设置显示字段
|
list[i].value = list[i][id];
|
list[i].label = list[i][label];
|
|
if (parentId_ == parId || !parentId_) {
|
obj[list[i].id].children = [];
|
result.push(list[i]);
|
continue;
|
} else if (obj[parentId_]) {
|
if (!obj[parentId_].children) {
|
obj[parentId_].children = [];
|
}
|
obj[parentId_].children.push(list[i]);
|
}
|
}
|
return result;
|
|
}
|
|
|
function list2Options(array_, value, label) {
|
var result = array_.map(function(one) {
|
return {
|
value: one[value],
|
label: one[label]
|
}
|
});
|
return result;
|
}
|
|
function clone(obj) {
|
var result, oClass = isClass(obj);
|
//确定result的类型
|
if (oClass === "Object") {
|
result = {};
|
} else if (oClass === "Array") {
|
result = [];
|
} else {
|
return obj;
|
}
|
for (var key in obj) {
|
var copy = obj[key];
|
if (isClass(copy) == "Object") {
|
result[key] = arguments.callee(copy); //递归调用
|
} else if (key == "contains") {}
|
else if (key == "remove") {}
|
else if (isClass(copy) == "Array") {
|
result[key] = arguments.callee(copy);
|
}
|
else {
|
result[key] = obj[key];
|
}
|
}
|
return result;
|
};
|
|
function isClass(o) {
|
if (o === null) return "Null";
|
if (o === undefined) return "Undefined";
|
return Object.prototype.toString.call(o).slice(8, -1);
|
}
|
|
function formatterRate(rate, fixed) {
|
if (!fixed) {
|
fixed = 1;
|
}
|
if (rate == "") {
|
return "";
|
}
|
|
if (rate == 0) {
|
return 0;
|
}
|
|
if (isNaN(rate)) {
|
return 0;
|
}
|
return (rate * 10000 / 100).toFixed(fixed);
|
}
|
|
function formatters(rate, fixed) {
|
|
if (!fixed) {
|
fixed = 1;
|
}
|
|
|
if (rate == "") {
|
return "";
|
}
|
|
if (isNaN(rate)) {
|
return rate;
|
}
|
if (parseInt(rate) == rate) {
|
return rate;
|
}
|
return (rate * 100 / 100).toFixed(fixed);
|
}
|
|
function sortNumber(a, b) {
|
return a - b
|
}
|
|
function groupArr(list, field) {
|
var obj = {};
|
for (var i = 0; i < list.length; i++) {
|
|
var keys = Object.keys(list[i]);
|
for (var j = 0; j < keys.length; j++) {
|
var item = keys[j]
|
if (item == field) {
|
obj[list[i][item]] = {
|
list: obj[list[i][field]] ? obj[list[i][field]].list : [],
|
type: list[i][field]
|
};
|
}
|
}
|
|
obj[list[i][field]].list.push(list[i])
|
}
|
var att = [];
|
for (item in obj) {
|
att.push({
|
list: obj[item].list,
|
type: obj[item].type,
|
})
|
}
|
return att;
|
}
|
|
function dealExportByBlob(res) {
|
let fileName = decodeURI(res.headers['content-disposition'].split('filename=')[1])
|
// let fileName = decodeURI(res.headers['content-disposition'].match(/filename=(\S*)(?=(.xls|.xlsx))/)[1])
|
let blob = new Blob([res.data], {
|
type: 'application/vnd.ms-excel;charset=UTF-8'
|
})
|
if (window.navigator.msSaveBlob) { // 没有此判断的话,ie11下的导出没有效果
|
window.navigator.msSaveBlob(blob, fileName)
|
} else {
|
let downloadElement = document.createElement('a')
|
let href = window.URL.createObjectURL(blob) // 创建下载的链接
|
downloadElement.href = href
|
downloadElement.download = fileName // 下载后文件名
|
document.body.appendChild(downloadElement)
|
downloadElement.click() // 点击下载
|
document.body.removeChild(downloadElement) // 下载完成移除元素
|
window.URL.revokeObjectURL(href) // 释放掉blob对象
|
}
|
}
|
|
function dealExportByPath(fileurl, fileName) {
|
let downloadElement = document.createElement('a')
|
downloadElement.href = fileurl
|
downloadElement.download = fileName // 下载后文件名
|
document.body.appendChild(downloadElement)
|
downloadElement.click() // 点击下载
|
document.body.removeChild(downloadElement) // 下载完成移除元素
|
}
|
|
function randomData(length, multiple, fixed) {
|
if (!length) {
|
length = 1;
|
}
|
if (!multiple) {
|
multiple = 1;
|
}
|
if (!fixed) {
|
fixed = 0;
|
}
|
if (length == 1) {
|
return getOneRandom(multiple, fixed);
|
}
|
var data = [];
|
for (var i = 0; i < length; i++) {
|
data[i] = getOneRandom(multiple, fixed);
|
}
|
return data;
|
}
|
|
function getOneRandom(multiple, fixed) {
|
return parseFloat((Math.random() * multiple).toFixed(fixed));
|
}
|
|
|
function uuid(len, radix) {
|
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
|
var uuid = [],
|
i;
|
radix = radix || chars.length;
|
|
if (len) {
|
// Compact form
|
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
|
} else {
|
// rfc4122, version 4 form
|
var r;
|
|
// rfc4122 requires these characters
|
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
|
uuid[14] = '4';
|
|
// Fill in random data. At i==19 set the high bits of clock sequence as
|
// per rfc4122, sec. 4.1.5
|
for (i = 0; i < 36; i++) {
|
if (!uuid[i]) {
|
r = 0 | Math.random() * 16;
|
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
|
}
|
}
|
}
|
|
return uuid.join('');
|
}
|
|
function uuid_short() {
|
return uuid(32);
|
}
|
function isObject(obj) {
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
}
|
|
function str2JSON(str) {
|
if(str == ""|| str == undefined) {
|
return null;
|
}
|
return JSON.parse(str);
|
}
|
|
|
function getArrDifference(array1, array2) {
|
|
var result = [];
|
for(var i = 0; i < array2.length; i++){
|
var obj = array2[i];
|
var num = obj.id;
|
var isExist = false;
|
for(var j = 0; j < array1.length; j++){
|
var aj = array1[j];
|
var n = aj.field_id;
|
if(n == num){
|
isExist = true;
|
break;
|
}
|
}
|
if(!isExist){
|
result.push(obj);
|
}
|
}
|
return result;
|
|
}
|
|
|
function groupBy( array , f ) {
|
let groups = {};
|
array.forEach( function( o ) {
|
let group = JSON.stringify( f(o) );
|
groups[group] = groups[group] || [];
|
groups[group].push( o );
|
});
|
return Object.keys(groups).map( function( group ) {
|
return groups[group];
|
});
|
}
|
Array.prototype.contains = function (obj) {
|
var i = this.length;
|
while (i--) {
|
if (this[i] === obj) {
|
return true;
|
}
|
}
|
return false;
|
}
|
|
function dateformatter(date, type){
|
if(!type) {
|
type = 0;
|
}
|
if(0 == type) {
|
return dateFormatCommon(date);
|
}
|
|
if(1 == type) {
|
return dateFormatEn(date);
|
}
|
|
if(2 == type) {
|
return dateFormatCn(date);
|
}
|
if(-1 == type) {
|
return new Date(Date.parse(date.replace(/-/g, "/")));
|
}
|
}
|
|
|
function dateFormatCommon(date) {
|
var nowdate = new Date(date).toLocaleDateString().replace(/\//g, '-')
|
return nowdate
|
}
|
|
function dateFormatEn(date) {
|
var nowdate = new Date(date).toLocaleDateString()
|
return nowdate
|
}
|
|
function dateFormatCn(now) {
|
y = now.getFullYear(),
|
m = ("0" + (now.getMonth() + 1)).slice(-2),
|
d = ("0" + now.getDate()).slice(-2);
|
return y + "-" + m + "-" + d + " " + now.toTimeString().substr(0, 8);
|
}
|
|
function isAssetTypeAnImage(ext) {
|
return [
|
'png', 'jpg', 'jpeg', 'bmp', 'gif', 'webp', 'psd', 'svg', 'tiff'].
|
indexOf(ext.toLowerCase()) !== -1;
|
}
|
|
function logOut() {
|
window.top.location.href = "login.html";
|
localStorage.removeItem('user');
|
localStorage.removeItem('emp');
|
localStorage.removeItem('menu');
|
}
|
function quotedStr(val) {
|
|
return "'" + val + "'";
|
}
|
|
function handleDownload(fileId, isSrc) {
|
var elemIF = document.createElement('iframe')
|
elemIF.src = getDownloadFileUrl(fileId, isSrc);
|
elemIF.style.display = 'none'
|
document.body.appendChild(elemIF)
|
}
|
|
function getDownloadFileUrl(fileId, isSrc, callback) {//&isSrc=true则返回路径否则返回流
|
if(isSrc) {
|
var params = {
|
isClientMode: false,
|
ajaxtype: "get",
|
id: fileId,
|
isSrc: true
|
}
|
Server.call("root/file/download", params, function(result_) {
|
console.log(result_);
|
if (callback) {
|
callback(result_)
|
}
|
})
|
//return baseUrl + 'root/file/download?id=' + fileId + "&isSrc=true";
|
}
|
else {
|
return baseUrl + 'root/file/download?id=' + fileId;
|
}
|
}
|
|
/// 项目使用
|
|
function addNotice(me, to_id, content, callback) {
|
let params = {
|
to_id: to_id,
|
content: content
|
};
|
|
let url = "work/push2Msg";
|
getUrl(me, url, params, result => {
|
if(callback) {
|
callback(result);
|
}
|
})
|
}
|
|
Array.prototype.remove = function(val) {
|
var index = this.indexOf(val);
|
if (index > -1) {
|
this.splice(index, 1);
|
}
|
};
|
|
|
let supplierId = "99008321972863334";
|
let materialCheckList = [
|
// '99008321972863325', //成本单价
|
// '99008321972863326',//成本数量
|
'99008321972863386',//采购填报单价/参数
|
'99008321972863330',//本次到货数量
|
'99008321972863332',//到货单价
|
'99008321972863329',//本次要料数量
|
'99008321972863334',//供应商
|
'99008321972863335',//供应商送货码单号
|
]
|