<!doctype html>
|
<html>
|
<head>
|
<meta charset="utf-8"><meta http-equiv="Expires" content="0"><meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-control" content="no-cache"><meta http-equiv="Cache" content="no-cache">
|
<title>纯销计划详情</title>
|
<script src="../../../js/vue/vue.js"></script>
|
<script src="../../../js/vue/element-ui/lib/index.js"></script>
|
<script src="../../../js/vue/axios/dist/axios.min.js"></script>
|
<script src="../../../js/myelement.js?v=20220615"></script>
|
<script src="../../../js/vue/page.js?v=20220615"></script>
|
<script src="../../../js/common.js"></script>
|
|
<link href="../../../js/vue/element-ui/lib/theme-chalk/index.css" rel="stylesheet">
|
<link href="../../../css/myelement.css?v=20220425" rel="stylesheet">
|
<link href="../../../css/iconfont.css" rel="stylesheet">
|
<link href="../../../css/page.css?v=20220425" rel="stylesheet">
|
<link href="//at.alicdn.com/t/font_2374495_mkoo966o0uo.css" rel="stylesheet">
|
</head>
|
|
<body>
|
<div id="vbody">
|
<div id="page_root">
|
<div ref="popup_body" style="padding-right: 20px;">
|
<div class="el-dialog_header">
|
<div class="dialog-title">
|
<i class="iconfont icon-customermanagement"></i>
|
<span> {{formAttr.title}} </span>
|
</div>
|
</div>
|
<div style="height: 530px;overflow-y: auto">
|
<div class="el-dialog_body" style="height': 500px">
|
<h-form ref="form1"
|
:form-attr="formAttr"
|
:table-fields="formFields"
|
:form-data="formData"
|
:is-end-colspan="false"
|
v-on:show-popup="showPopup"
|
>
|
</h-form>
|
<div v-if="notdisabled" style="text-align: right;">
|
<el-button-group>
|
<el-button @click="addTableData">新增数据</el-button>
|
<input type="file" id="btn_file" style="display: none;" @change="getFile($event)" />
|
<el-button @click="fileUpload()">导入</el-button>
|
<el-button @click="downloadTemplate()">下载模板</el-button>
|
<!-- <el-button @click="download()">导出</el-button> -->
|
</el-button-group>
|
</div>
|
<h-table v-if="isRefresh"
|
ref="table2"
|
v-loading.fullscreen.lock="fullscreenLoading"
|
element-loading-background="rgba(0, 0, 0, 0.4)"
|
:table-fields="tableFields"
|
:table-data="tableData2"
|
:is-edit-table-data="isEditTableData"
|
:is-within-edit-table-data="isWithinEditTableData"
|
:table-height="tableHeight2"
|
:is-pagination="false"
|
:is-show-index="true"
|
|
v-on:edit-data="editData"
|
v-on:del-data="delData"
|
v-on:cell-input-change="cellInputChange"
|
v-on:cell-select-change="cellSelectChange"
|
v-on:cell-click="cellClick"
|
v-on:visible-change="cellVisibleChange"
|
v-on:cell-show-popup="cellShowPopup">
|
</h-table>
|
<div v-if="acctObj.flow_id && popupParames.sceneCode == 'approval'" style="height: 350px; border-top: 1px solid #ccc;">
|
<iframe :src="'../../approval/ApprovalList_page.html?flow_id=' + acctObj.flow_id" style="width: 100%; height: 100%; border: 0px;"></iframe>
|
</div>
|
</div>
|
</div>
|
<el-dialog title="填写原因" :visible.sync="reasonvisible" v-loading="reasonLoading" height="50%">
|
<el-input type="textarea" :autosize="{ minRows: 2, maxRows: 10}" placeholder="请输入原因"
|
v-model="textarea2">
|
</el-input>
|
|
<div class="dialog-footer" style="float: right;margin-top: 30px;">
|
<el-button type="default" @click="reasonvisible = false">取 消</el-button>
|
<el-button type="primary" @click="saveReason">确 定</el-button>
|
</div>
|
</el-dialog>
|
<div class="el-dialog_footer">
|
|
<el-button v-if="Approval" type="success" @click="onpassApproval">通过</el-button>
|
<el-button v-if="Approval" type="danger" @click="onrefuseApproval">拒绝</el-button>
|
<el-button v-if="notdisabled" type="primary" @click="saveRowTable">保 存</el-button>
|
<el-button v-if="notdisabled" type="primary" @click="submitRowTable">提 交</el-button>
|
<el-button v-if="browse || Approval" @click="download()">导出</el-button>
|
<el-button v-if="!fromDing" type="default" @click="closeDialog">关闭</el-button>
|
</div>
|
</div>
|
</div>
|
<div id="page_loading" style="position: absolute; top:0px; width: 100vw; height: 100vh;">
|
<div class="spinner">
|
<div class="cube1"></div>
|
<div class="cube2"></div>
|
</div>
|
</div>
|
|
<el-dialog :visible.sync="dingResult" width="40vw" height="50vh" :show-close="false" :close-on-click-modal="false" :close-on-press-escape="false">
|
<span>{{dingResultTxt}}</span>
|
<div style="min-height: 150px;"></div>
|
</el-dialog>
|
</div>
|
|
<script type="text/javascript">
|
new Vue({
|
el: "#vbody",
|
data: {
|
disabled: false,
|
notdisabled: true,
|
Approval: false,
|
browse: false,
|
|
form_dataname: "puresalePlan",
|
dataname: "puresalePlanDetail",
|
uploadDataname: "tempPuresaleDetail",
|
|
acctObj:{
|
flow_id:""
|
},
|
|
formAttr: {
|
title: "纯销计划信息",
|
istitle: false,
|
columnnumber: 2,
|
labelwidth: "130px",
|
labelposition: "right",
|
size: "medium",
|
border: "0px solid #c6c6c600",
|
},
|
formFields: [],
|
formData: {},
|
customer_products:{},
|
newRowDefault: {
|
id: uuid_short(),
|
status: "input",
|
create_time: createDatetime(),
|
create_operate_name: window.top.userinfo.employee.name,
|
create_operate_id: window.top.userinfo.employee.id,
|
create_operate_code: window.top.userinfo.employee.code,
|
year: createYearByYear() + "",
|
month: createMonth()
|
},
|
info:{},
|
tableFields: [],
|
tableData2: [],
|
tableDataChange: {},
|
tableHeight2: 350,
|
|
isEditTableData: true,
|
isWithinEditTableData: false,
|
isRefresh: true,
|
selectFormField: {},
|
selectedrow: {},
|
isUpload: false,
|
uploadType: "purSale",
|
batch_id: "",
|
productDetail: [],
|
textarea2: "",
|
optionsObj: {},
|
reasonvisible: false,
|
reasonLoading: false,
|
fullscreenLoading: false,
|
fromDing: false,
|
dingResult: false,
|
dingResultTxt: ""
|
},
|
|
created() {
|
var me = this;
|
this.popupParames = clone(Root.popupParames);
|
|
if (this.popupParames.data) {
|
this.formData = clone(this.popupParames.data);
|
this.formData.year = this.formData.year + "";
|
this.acctObj.flow_id = this.formData.flow_id;
|
}
|
|
if (this.popupParames.sceneCode) {
|
if (this.popupParames.sceneCode == "browse") {
|
this.formAttr.disabled = true;
|
this.isWithinEditTableData = false;
|
this.isEditTableData = false;
|
this.notdisabled = false;
|
this.Approval = false;
|
this.browse = true;
|
} else if (this.popupParames.sceneCode == "approval") {
|
this.formAttr.disabled = true;
|
this.isWithinEditTableData = false;
|
this.isEditTableData = false;
|
this.notdisabled = false;
|
this.Approval = true;
|
} else if (this.popupParames.sceneCode == "add") {
|
if (this.newRowDefault) {
|
let formData_ = clone(this.formData);
|
|
for (var k in this.newRowDefault) {
|
formData_[k] = this.newRowDefault[k];
|
}
|
|
this.formData = formData_;
|
}
|
}
|
}
|
},
|
|
mounted() {
|
this.initFields();
|
|
if (this.popupParames.sceneCode != "add") {
|
this.initData();
|
}
|
|
var urlParam = getGetParams(this.popupParames.url);
|
|
for(let key in urlParam) {
|
if(key == "fromDing") {
|
this.fromDing = urlParam[key];
|
}
|
}
|
|
this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
|
document.getElementById('page_root').style.display = "block";
|
document.getElementById('page_loading').style.display = "none";
|
|
//重新设置弹窗宽高
|
this.$nextTick(function() {
|
let w_ = this.$refs.popup_body.offsetWidth + "px";
|
let h_ = this.$refs.popup_body.offsetHeight + "px";
|
Root.setPopupWH(w_, h_);
|
})
|
});
|
},
|
|
methods: {
|
initFields() {
|
let me = this;
|
me.tableFields = dataRootFields.tableFields.puresalePlanDetail_;
|
me.formFields = dataRootFields.formFields.puresalePlan_;
|
},
|
|
initData() {
|
let me = this;
|
|
let filter_table = "1<>1";
|
|
if (this.formData.id) {
|
filter_table = "plan_puresale_detail.parent_id = '" + this.formData.id + "'";
|
}
|
|
let param_table = {
|
isClientMode: false,
|
dataname: this.dataname,
|
filter: filter_table,
|
}
|
console.log(param_table);
|
Server.call("root/data/getEntitySet", param_table, function(result) {
|
console.log(result);
|
if (result && result.data) {
|
me.tableData2 = result.data.entityset;
|
}
|
});
|
},
|
|
closeDialog() {
|
if(this.popupParames.totab) {
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(this.popupParames.parentOption, false);
|
}else {
|
Root.hidePopup();
|
}
|
},
|
|
createCode(array_) {
|
var me = this;
|
Server.call("root/code/nextval", {
|
ruleCode: "Code-Puresale"
|
}, function(result) {
|
if (result && result.data) {
|
me.formData.code = result.data.value;
|
me.doSave(array_);
|
}
|
})
|
},
|
|
dataIntegrityValidation() {
|
var tableData = this.tableData2;
|
|
for (var i = 0; i < tableData.length; i++) {
|
let tempObj = tableData[i];
|
|
for(const key in tempObj) {
|
if(key == "customer_code"||key == "sub_customer_name"||key == "marketing_company_name"||key == "sales_company_name"||key == "product_code") {
|
if(tempObj[key] == "" || tempObj[key] == null) {
|
Root.message({
|
type: 'warning',
|
message: '数据不完整,请完善数据'
|
});
|
return;
|
}
|
}
|
}
|
}
|
|
this.dodataExistValidation();
|
// this.dataExistValidation();
|
},
|
dodataExistValidation() {
|
var me = this;
|
var array_ = [];
|
var tableData = this.tableData2;
|
|
if(tableData.length == 0) {
|
Root.message({
|
type: 'warning',
|
message: '明细数据为空'
|
});
|
return;
|
}
|
if(this.popupParames.sceneCode == "edit") {
|
for (var id in me.tableDataChange) {
|
array_.push(id);
|
}
|
me.doSave(array_);
|
}
|
else {
|
for (var id in me.tableDataChange) {
|
array_.push(id);
|
}
|
me.createCode(array_);
|
}
|
|
},
|
|
dataExistValidation() {
|
var me = this;
|
var array_ = [];
|
var tableData = this.tableData2;
|
|
if(tableData.length == 0) {
|
Root.message({
|
type: 'warning',
|
message: '明细数据为空'
|
});
|
return;
|
}
|
|
for (var i = 0; i < tableData.length; i++) {
|
let idx = i;
|
let tempObj = tableData[idx]
|
|
let shop_code = tempObj.shop_code ? "= '" + tempObj.shop_code + "'" : "is null";
|
let shop_name = tempObj.shop_name ? "= '" + tempObj.shop_name + "'" : "is null";
|
|
let filterParam = {
|
isClientMode: false,
|
dataname: "puresaleplansummary",
|
filter: "year = " + '\'' + this.formData.year + '\''
|
+ ' and month = ' + '\'' + this.formData.month + '\''
|
+ ' and province_code = ' + '\'' + this.formData.province_code + '\''
|
+ ' and sub_company_name = ' + '\'' + tempObj.sub_company_name + '\''
|
+ ' and sales_company_code = ' + '\'' + tempObj.sales_company_code + '\''
|
+ ' and marketing_company_code = ' + '\'' + tempObj.marketing_company_code + '\''
|
+ ' and customer_code = ' + '\'' + tempObj.customer_code + '\''
|
+ ' and product_code = ' + '\'' + tempObj.product_code + '\''
|
+ ' and shop_code ' + shop_code
|
+ ' and shop_name ' + shop_name
|
|
}
|
/* if(tempObj.business_type) {
|
filterParam.filter += ' and business_type =' + '\'' + tempObj.business_type + '\''
|
} */
|
if(tempObj.business_operate_code) {
|
filterParam.filter += ' and business_operate_code =' + '\'' + tempObj.business_operate_code + '\''
|
}
|
if(this.popupParames.sceneCode == "edit") {
|
Server.call("root/data/getEntitySet/", filterParam, function(result) {
|
if (result.data.entityset.length > 0) {
|
for (var i = 0; i < result.data.entityset.length; i++) {
|
let tempObj = result.data.entityset[i];
|
|
if(tempObj.parent_id != me.formData.id) {
|
Root.message({
|
type: 'warning',
|
message: '当前月份已经创建了相同的纯销计划'
|
});
|
return;
|
}
|
}
|
}
|
if(idx == tableData.length - 1) {
|
for (var id in me.tableDataChange) {
|
array_.push(id);
|
}
|
me.doSave(array_);
|
}
|
});
|
}else {
|
Server.call("root/data/getEntitySet/", filterParam, function(result) {
|
if (result.data.entityset.length > 0) {
|
Root.message({
|
type: 'warning',
|
message: '当前月份已经创建了相同的纯销计划'
|
});
|
return;
|
}
|
if(idx == tableData.length - 1) {
|
for (var id in me.tableDataChange) {
|
array_.push(id);
|
}
|
me.createCode(array_);
|
}
|
});
|
}
|
}
|
},
|
|
checkData(callback) {
|
var me = this;
|
this.formData.id;
|
|
var param = {
|
dataname: "planPuresaleDetailIsNull",
|
plan_puresale_id: "'" + this.formData.id + "'"
|
}
|
Server.call("root/data/getEntitySet/", param, function(result) {
|
console.log(result);
|
|
if (result.data.entityset.length > 0) {
|
var warning_table_ids_ = [];
|
|
result.data.entityset.map(e=>{
|
warning_table_ids_.push(e.id);
|
})
|
Root.message({
|
type: 'warning',
|
message: '存在共' + result.data.entityset.length + '条空数据的纯销计划'
|
});
|
|
me.$refs.table2.toggleSelection(warning_table_ids_, null, null, true);
|
|
if (callback) {
|
me.formData.continueCommit = false;
|
me.fullscreenLoading = false;
|
}
|
|
}
|
else {
|
me.checkRepeatData(callback);
|
}
|
})
|
|
},
|
|
|
checkRepeatData(callback) {
|
var me = this;
|
this.formData.id;
|
|
var param = {
|
dataname: "planPuresaleDetailExist",
|
plan_puresale_id: "'" + this.formData.id + "'"
|
}
|
Server.call("root/data/getEntitySet/", param, function(result) {
|
console.log(result);
|
|
/* result.data.entityset.push(
|
{id: "92d5a74b284849b6869247efc2169afb"}
|
) */
|
if (result.data.entityset.length > 0) {
|
var warning_table_ids_ = [];
|
|
result.data.entityset.map(e=>{
|
warning_table_ids_.push(e.id);
|
})
|
Root.message({
|
type: 'warning',
|
message: '共' + result.data.entityset.length + '已存在相同的纯销计划'
|
});
|
|
me.$refs.table2.toggleSelection(warning_table_ids_, null, null, true);
|
|
if (callback) {
|
me.formData.continueCommit = false;
|
me.fullscreenLoading = false;
|
}
|
|
}
|
else {
|
Root.message({
|
type: 'success',
|
message: '检查完成'
|
});
|
|
if (callback) {
|
callback()
|
}
|
}
|
})
|
|
},
|
|
submitRowTable() {
|
this.formData.continueCommit = true;
|
this.saveRowTable();
|
},
|
|
saveRowTable() {
|
if(!this.formData.year) {
|
Root.message({
|
type: 'warning',
|
message: '请选择年份'
|
});
|
return;
|
}else if(!this.formData.province_code) {
|
Root.message({
|
type: 'warning',
|
message: '请选择省份'
|
});
|
return;
|
}
|
else if(!this.formData.type) {
|
Root.message({
|
type: 'warning',
|
message: '请选择类型'
|
});
|
return;
|
}
|
|
this.dataIntegrityValidation();
|
},
|
|
doSave(array) {
|
var me = this;
|
this.fullscreenLoading = true;
|
|
if (this.isUpload) {
|
let param = {
|
dataname: this.uploadDataname,
|
parentId: this.formData.id,
|
type: this.uploadType,
|
batchId: this.batch_id
|
};
|
|
//新建
|
if(this.popupParames.sceneCode == "add") {
|
if (me.formData.newfile_id) {
|
me.formData.file_id = me.formData.newfile_id;
|
}
|
|
Server.call("root/data/saveEntity/" + me.form_dataname, this.formData, function(result) {
|
if(result.success) {
|
me.popupParames.sceneCode = "edit";
|
me.isUpload = false
|
Server.call("root/plan/transDataByTemp/", param, function(result) {
|
me.fullscreenLoading = false;
|
if(result.success) {
|
if (me.formData.continueCommit) {
|
me.checkData(function() {
|
Server.call("root/plan/spiltPlanPurse", {id: me.formData.id}, function(result0) {
|
if (result0.success) {
|
if (result0.data && result0.data.ids) {
|
let count = 0
|
result0.data.ids.map(x => {
|
let param = {
|
businessId: x,
|
businessType: "puresale_plan",
|
variableMap: {
|
province: me.formData.province_code
|
},
|
}
|
Server.call("root/api/startAct", param, function(result1) {
|
if (result1.success) {
|
Server.call("root/data/updateEntity/" +
|
"puresalePlan", {
|
id: x,
|
flow_id: result1.data.data.activitiId
|
},
|
function(result2) {
|
count += 1
|
if (result2.success) {
|
if (count == result0.data.ids.length) {
|
Root.message({
|
type: 'success',
|
message: '提交成功'
|
});
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, true);
|
me.fullscreenLoading = false;
|
}
|
} else {
|
Root.message({
|
type: 'warning',
|
message: result2.message
|
});
|
if (count == result0.data.ids.length) me.fullscreenLoading = false;
|
return;
|
}
|
});
|
} else {
|
Root.message({
|
type: 'warning',
|
message: result1.message
|
});
|
me.fullscreenLoading = false;
|
return;
|
}
|
});
|
})
|
}
|
} else {
|
|
}
|
})
|
})
|
}else {
|
Root.message({
|
type: 'success',
|
message: '保存成功'
|
});
|
me.fullscreenLoading = false;
|
|
//2回调
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, true);
|
return;
|
}
|
// Root.hidePopup();
|
}else {
|
Root.message({
|
type: 'warning',
|
message: result.message
|
});
|
me.fullscreenLoading = false;
|
return;
|
}
|
|
}, function(err) {
|
let str = "";
|
if(err.data && err.data.data && err.data.data.length > 0) {
|
for (var i = 0; i < err.data.data.length - 1; i++) {
|
str += "line:" + err.data.data[i].line + ","
|
}
|
str += "line:" + err.data.data[err.data.data.length-1].line
|
}
|
Root.message({
|
type: 'warning',
|
message: err.message + str
|
});
|
me.fullscreenLoading = false;
|
})
|
}
|
})
|
}else {
|
if (me.formData.newfile_id) {
|
Server.call("root/data/updateEntity/" + "puresalePlan", {
|
id: me.formData.id,
|
file_id: me.formData.newfile_id
|
},
|
function(r) {
|
|
});
|
}
|
|
|
let param = {
|
dataname: this.uploadDataname,
|
parentId: this.formData.id,
|
type: this.uploadType,
|
batchId: this.batch_id
|
};
|
//编辑
|
Server.call("root/plan/transDataByTemp/", param, function(result) {
|
me.fullscreenLoading = false;
|
if(result.success) {
|
if (me.formData.continueCommit) {
|
me.checkData(function() {
|
if(me.formData.status == "refuse") {
|
let param = {
|
flowId: me.formData.flow_id,
|
businessType: "puresale_plan",
|
pass: true,
|
variableMap: {
|
reason: ""
|
}
|
}
|
Server.call("root/api/dealAct", param, function(result) {
|
if (result.success) {
|
Root.message({
|
type: 'success',
|
message: '提交成功'
|
});
|
me.fullscreenLoading = false;
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, true);
|
} else {
|
Root.message({
|
type: 'warning',
|
message: result.message
|
});
|
me.fullscreenLoading = false;
|
return;
|
}
|
})
|
}else {
|
let param = {
|
businessId: me.formData.id,
|
businessType: "puresale_plan",
|
variableMap: {
|
province: me.formData.province_code
|
},
|
}
|
Server.call("root/api/startAct", param, function(result1) {
|
if (result1.success) {
|
Server.call("root/data/updateEntity/" +
|
"puresalePlan", {
|
id: me.formData.id,
|
flow_id: result1.data.data.activitiId
|
},
|
function(result2) {
|
if (result2.success) {
|
Root.message({
|
type: 'success',
|
message: '提交成功'
|
});
|
me.fullscreenLoading = false;
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, true);
|
} else {
|
Root.message({
|
type: 'warning',
|
message: result2.message
|
});
|
me.fullscreenLoading = false;
|
return;
|
}
|
});
|
} else {
|
Root.message({
|
type: 'warning',
|
message: result1.message
|
});
|
me.fullscreenLoading = false;
|
return;
|
}
|
});
|
}
|
})
|
}else {
|
Root.message({
|
type: 'success',
|
message: '保存成功'
|
});
|
me.fullscreenLoading = false;
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, true);
|
}
|
// Root.hidePopup();
|
}else {
|
Root.message({
|
type: 'warning',
|
message: result.message
|
});
|
me.fullscreenLoading = false;
|
return
|
}
|
//2回调
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, true);
|
}, function(err) {
|
let str = "";
|
if(err.data && err.data.data && err.data.data.length > 0) {
|
for (var i = 0; i < err.data.data.length - 1; i++) {
|
str += "line:" + err.data.data[i].line + ","
|
}
|
str += "line:" + err.data.data[err.data.data.length-1].line
|
}
|
Root.message({
|
type: 'warning',
|
message: err.message + str
|
});
|
me.fullscreenLoading = false;
|
return;
|
})
|
}
|
} else{
|
if (array.length) { //存在需处理的明细数据
|
var id = array[0];
|
var row_ = me.tableDataChange[id];
|
var type = row_.type;
|
var row = row_.data;
|
|
let param = {};
|
let event = "";
|
|
if (type == "add") {
|
param = row;
|
param.parent_id = this.formData.id;
|
param.isClientMode = false;
|
|
event = "saveEntity";
|
} else if (type == "up") {
|
param = row;
|
param.isClientMode = false;
|
|
event = "updateEntity";
|
} else if (type == "del") {
|
param = {
|
id: row.id,
|
isClientMode: false
|
}
|
event = "deleteEntity";
|
}
|
|
Server.call("root/data/" + event + "/" + me.dataname, param, function(result) {
|
array.remove(id);
|
me.doSave(array);
|
});
|
} else {
|
if(this.popupParames.sceneCode != "edit") {
|
if (Object.keys(me.tableDataChange).length == undefined || Object.keys(me.tableDataChange).length == 0) {
|
Root.message({
|
type: 'warning',
|
message: '请添加数据'
|
});
|
me.fullscreenLoading = false;
|
return;
|
}
|
}
|
//1保存form数据
|
let param = me.formData;
|
param.isClientMode = false;
|
let event = "updateEntity";
|
|
if (me.popupParames.sceneCode == "add") {
|
event = "saveEntity"
|
}
|
|
Server.call("root/data/" + event + "/" + me.form_dataname, param, function(result) {
|
console.log(result);
|
if (me.formData.continueCommit) {
|
me.checkData(function() {
|
if(me.formData.status == "refuse") {
|
let param = {
|
flowId: me.formData.flow_id,
|
businessType: "puresale_plan",
|
pass: true,
|
variableMap: {
|
reason: ""
|
}
|
}
|
Server.call("root/api/dealAct", param, function(result) {
|
if (result.success) {
|
Root.message({
|
type: 'success',
|
message: '提交成功'
|
});
|
me.fullscreenLoading = false;
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, true);
|
} else {
|
Root.message({
|
type: 'warning',
|
message: result.message
|
});
|
me.fullscreenLoading = false;
|
return;
|
}
|
})
|
}else {
|
Server.call("root/plan/spiltPlanPurse", {id: result.data.entity.id}, function(result0) {
|
if (result0.success) {
|
if (result0.data && result0.data.ids) {
|
let count = 0
|
result0.data.ids.map(x => {
|
let param = {
|
businessId: x,
|
businessType: "puresale_plan",
|
variableMap: {
|
province: result.data.entity.province_code
|
},
|
}
|
Server.call("root/api/startAct", param, function(result1) {
|
if (result1.success) {
|
Server.call("root/data/updateEntity/" +
|
"puresalePlan", {
|
id: x,
|
flow_id: result1.data.data.activitiId
|
},
|
function(result2) {
|
count += 1
|
if (result2.success) {
|
if (count == result0.data.ids.length) {
|
Root.message({
|
type: 'success',
|
message: '提交成功'
|
});
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, true);
|
me.fullscreenLoading = false;
|
}
|
} else {
|
Root.message({
|
type: 'warning',
|
message: result2.message
|
});
|
if (count == result0.data.ids.length) me.fullscreenLoading = false;
|
return;
|
}
|
});
|
} else {
|
Root.message({
|
type: 'warning',
|
message: result1.message
|
});
|
me.fullscreenLoading = false;
|
return;
|
}
|
});
|
})
|
}
|
} else {
|
|
}
|
})
|
}
|
});
|
}else {
|
Root.message({
|
type: 'success',
|
message: '保存成功'
|
});
|
me.fullscreenLoading = false;
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, true);
|
}
|
// this.fullscreenLoading = false;
|
});
|
}
|
}
|
},
|
|
rowChange(row, type) {
|
//tc
|
if(!this.isUpload) {
|
if(row.add_id) {
|
var id_ = row.add_id;
|
}else {
|
var id_ = row.id;
|
}
|
if(type != "del") {
|
if (this.tableDataChange[id_]) {
|
this.tableDataChange[id_].data = row;
|
} else {
|
var changeRow_ = {
|
type: type,
|
data: row
|
};
|
if (id_ == undefined || id_ == "") {
|
this.tableDataChange[row.add_id] = changeRow_;
|
} else{
|
this.tableDataChange[id_] = changeRow_;
|
}
|
}
|
}
|
}
|
|
//t2
|
if (type == "add") {
|
this.tableData2.unshift(row);
|
} else if (type == "del") {
|
this.tableData2.remove(row);
|
if(row.add_id) {
|
this.$delete(this.tableDataChange, row.add_id)
|
}
|
}else{
|
if (this.tableDataChange[id_]) {
|
this.tableDataChange[id_].data = row;
|
} else {
|
var changeRow_ = {
|
type: type,
|
data: row
|
};
|
if (id_ == undefined || id_ == "") {
|
this.tableDataChange[row.add_id] = changeRow_;
|
} else{
|
this.tableDataChange[id_] = changeRow_;
|
}
|
}
|
}
|
this.$refs.form1.refresh();
|
},
|
|
fileUpload() {
|
var me = this;
|
document.getElementById("btn_file").click();
|
// if (this.popupParames.sceneCode == "edit") {
|
// } else {
|
// let filterParam = {
|
// isClientMode: false,
|
// dataname: this.form_dataname,
|
// filter: "year = " + '\'' + this.formData.year + '\' and month = ' + '\'' + this.formData.month + '\''
|
// }
|
// Server.call("root/data/getEntitySet/", filterParam, function(result) {
|
// if (result.data.entityset.length > 0) {
|
// Root.message({
|
// type: 'warning',
|
// message: '当前月份已经创建了纯销计划'
|
// });
|
// return;
|
// } else {
|
// document.getElementById("btn_file").click();
|
// }
|
// });
|
// }
|
},
|
|
getFile(event) {
|
let me = this
|
this.fullscreenLoading = true;
|
var file = event.target.files;
|
var forms = new FormData();
|
if(file.length <= 0) {
|
this.fullscreenLoading = false;
|
}
|
for (var i = 0; i < file.length; i++) {
|
// 上传类型判断
|
var FileName = file[i].name;
|
var idx = FileName.lastIndexOf(".");
|
if (idx != -1) {
|
var ext = FileName.substr(idx + 1).toUpperCase();
|
ext = ext.toLowerCase();
|
if (ext == 'xlsx') {
|
let formData = new FormData()
|
formData.append("file", file[i]);
|
|
uploadAxios.post(baseUrl + 'root/plan/uploadPurse?userId=' + window.top.userinfo.user.id, formData).then(data_ => {
|
// console.log(data_.data.data.entityset);
|
this.isUpload = true;
|
let not_Batch = "第 ";
|
this.tableData2 = clone(data_.data.data.entityset) ;
|
let tableData = data_.data.data.entityset;
|
let file_id_ = data_.data.data.file_id;
|
me.formData.newfile_id = file_id_;
|
for (var i = 0; i < tableData.length; i++) {
|
if(tableData[i].customer_code && tableData[i].product_code && tableData[i].business_operate_code) {
|
if(!this.customer_products[tableData[i].customer_code]) {
|
this.customer_products[tableData[i].customer_code] = {}
|
}
|
if(!this.customer_products[tableData[i].customer_code][tableData[i].business_operate_code]) {
|
this.customer_products[tableData[i].customer_code][tableData[i].business_operate_code] = [];
|
}
|
if(this.customer_products[tableData[i].customer_code][tableData[i].business_operate_code].indexOf(tableData[i].product_code) > -1) {
|
not_Batch += (i+1) + ","
|
}else {
|
this.customer_products[tableData[i].customer_code][tableData[i].business_operate_code].push(tableData[i].product_code)
|
}
|
|
}
|
}
|
not_Batch = not_Batch.substring(0,not_Batch.length -1)
|
if(me.tableData2.length > 0 && me.tableData2[0].batch_id)
|
this.batch_id = me.tableData2[0].batch_id;
|
// if(not_Batch.length > 2) {
|
// Root.message({
|
// type:"warning",
|
// message:not_Batch + "条数据已存在"
|
// })
|
// }
|
|
/*
|
var param = {
|
formData: this.formData,
|
type: "purSale",
|
batchId: data_.data.data.batch_id,
|
tableData: data_.data.data.entityset
|
}
|
Root.showPopup({
|
url: "../order/plan/puresaleplan_preview.html",
|
width: 1200,
|
height: 550,
|
data: param,
|
sceneCode: this.popupParames.sceneCode,
|
callback: function(obj, callback) {
|
|
if (callback) {
|
callback();
|
}
|
}
|
}); */
|
|
|
// this.tableData2 = tableData ;
|
|
// this.$refs.btn_file.value = null;
|
this.fullscreenLoading = false;
|
}).catch(error => {
|
this.$message({
|
showClose: true,
|
message: ':请求出现错误:' + error,
|
type: 'error'
|
});
|
this.fullscreenLoading = false;
|
});
|
} else {
|
Root.message({
|
type: 'info',
|
message: '格式不正确'
|
});
|
this.fullscreenLoading = false;
|
}
|
}
|
}
|
},
|
|
download() {
|
/* var id = "'" + this.formData.id + "'";
|
var filter_ = "plan_puresale_detail.parent_id = '" + this.formData.id + "'"
|
var name = "纯销计划-" + createDate()+".xlsx";
|
var url = baseUrl + "plan/downloadByType?type=Puresale&&userId=" + window.top.userinfo.user.id + "&&id=" + id;
|
dealExportByPath(url, "纯销计划信息.xlsx"); */
|
var filter_ = "plan_puresale_detail.parent_id = '" + this.formData.id + "'"
|
var url = baseUrl + "file/downloadDataWithExcel?userId=" + window.top.userinfo.user.id + "&filter=" +filter_ + "&type=puresaleDetailInfo&dataName=puresaleDetailInfo" + "&name=" + "纯销计划明细导出.xlsx"
|
dealExportByPath(url, "纯销计划明细导出.xlsx");
|
},
|
|
downloadTemplate() {
|
var name = "纯销计划模板.xlsx"
|
var url = baseUrl + "file/downloadTemplate?type=puresale_upload&&userId=" + window.top.userinfo.user.id + "&&name=" + name;
|
dealExportByPath(url, "纯销计划模板.xlsx");
|
// dealExportByPath("../../../template/plan.xlsx","计划模板");
|
},
|
|
addTableData() {
|
var me = this;
|
if (this.selectedrow != {}) {
|
this.selectedrow.isWithinEdit = false;
|
}
|
|
var id_ = uuid_short();
|
var row_ = {
|
id: uuid_short(),
|
isWithinEdit: true,
|
add_id: id_
|
};
|
for (var i = 0; i < this.tableData2.length; i++) {
|
if(this.tableData2[i].customer_code) {
|
if(!this.customer_products[this.tableData2[i].customer_code]) {
|
this.customer_products[this.tableData2[i].customer_code] = {};
|
}
|
}
|
if(this.tableData2[i].business_operate_code) {
|
if(!this.customer_products[this.tableData2[i].customer_code][this.tableData2[i].business_operate_code]) {
|
this.customer_products[this.tableData2[i].customer_code][this.tableData2[i].business_operate_code] = [];
|
}
|
}
|
if(this.tableData2[i].product_code) {
|
this.customer_products[this.tableData2[i].customer_code][this.tableData2[i].business_operate_code].push(this.tableData2[i].product_code);
|
}
|
|
}
|
for (var i = 0; i < this.tableFields.length; i++) {
|
let field_ = this.tableFields[i].field;
|
|
if (field_ == "parent_id") {
|
row_[field_] = this.formData.id;
|
} else {
|
row_[field_] = "";
|
}
|
}
|
|
this.selectedrow = row_;
|
|
if(this.isUpload) {
|
row_.batch_id = this.batch_id,
|
row_.line = this.tableData2.length+1,
|
Server.call("root/data/saveEntity/" + this.uploadDataname, row_, function(result) {
|
console.info(result);
|
result.data.entity.isWithinEdit = true
|
me.tableData2.unshift(result.data.entity);
|
});
|
}else {
|
this.rowChange(row_, "add");
|
}
|
},
|
|
editData(scope) {
|
if (scope.row.isWithinEdit) {
|
scope.row.isWithinEdit = false;
|
} else {
|
if (this.selectedrow != {}) {
|
this.selectedrow.isWithinEdit = false;
|
}
|
this.selectedrow = scope.row;
|
scope.row.isWithinEdit = scope.row.isWithinEdit ? false : true;
|
}
|
|
this.isRefresh = false;
|
this.$nextTick(function() {
|
this.isRefresh = true;
|
})
|
},
|
|
cellVisibleChange(obj) {
|
var me = this;
|
// if(obj.options.length > 0 ) {
|
// return;
|
// }
|
if (obj.field == "marketing_company_name") {
|
var param = {
|
dataname: "dictitem",
|
filter: " parent_id = 'marketing_company'"
|
}
|
|
Server.call("root/data/getEntitySet", param, function(result) {
|
if (result && result.data.entityset ) {
|
obj.options = result.data.entityset;
|
var obj_ = {};
|
result.data.entityset.map(e => {
|
obj_[e.value]=e.code;
|
});
|
me.optionsObj[obj.field] = obj_;
|
}
|
});
|
} else if (obj.field == "sales_company_name") {
|
var param = {
|
dataname: "dictitem",
|
filter: " parent_id = 'sales_company'"
|
}
|
|
Server.call("root/data/getEntitySet", param, function(result) {
|
if (result && result.data.entityset ) {
|
obj.options = result.data.entityset;
|
var obj_ = {};
|
result.data.entityset.map(e => {
|
obj_[e.value]=e.code;
|
});
|
me.optionsObj[obj.field] = obj_;
|
}
|
});
|
}
|
},
|
|
cellShowPopup(scope) {
|
let me = this;
|
let row = scope.row;
|
let field = scope.column.property;
|
if (field == "product_name") {
|
if(!row.customer_code) {
|
Root.message({
|
type:"warning",
|
message:"请先选择商业"
|
})
|
return;
|
}
|
if(!row.business_operate_code) {
|
Root.message({
|
type:"warning",
|
message:"请先选择商业操作人"
|
})
|
return;
|
}
|
let filter = "";
|
if(this.customer_products[row.customer_code][row.business_operate_code] && this.customer_products[row.customer_code][row.business_operate_code].length > 0) {
|
let products = this.customer_products[row.customer_code][row.business_operate_code];
|
let productStr = "";
|
for (var i = 0; i < products.length; i++) {
|
productStr += "'" + products[i] + "',"
|
}
|
productStr = productStr.substring(0,productStr.length-1)
|
filter += " and md_code not in (" + productStr + ") "
|
}
|
Root.showPopup({
|
url: "../md/product/popup/product_list.html",
|
width: 800,
|
height: 550,
|
dataname: "md_product_act",
|
type: "onlySimple",
|
filter: filter,
|
callback: function(obj, callback) {
|
row.product_name = obj.row.product_name
|
row.product_id = obj.row.id
|
row.product_code = obj.row.product_code
|
row.product_spec = obj.row.product_spec
|
row.unit = obj.row.product_pack
|
if(row.product_code) {
|
me.customer_products[row.customer_code][row.business_operate_code].push(row.product_code);
|
}
|
// row.price = obj.row.priceunit
|
// row.tax_rate = obj.row.taxrate
|
// row.conversrate = obj.row.conversrate
|
if(me.isUpload) {
|
let param = row;
|
Server.call("root/data/updateEntity/" + me.uploadDataname, param, function(result) {
|
console.info(result);
|
});
|
}else {
|
me.rowChange(row, "up");
|
}
|
if (callback) {
|
callback();
|
}
|
}
|
});
|
} else if (field == "customer_name") {
|
Root.showPopup({
|
url: "../md/customer/popup/customer_list.html",
|
width: 800,
|
height: 550,
|
callback: function(obj, callback) {
|
row.customer_name = obj.row.md_description;
|
row.customer_code = obj.row.md_code;
|
row.customer_id = obj.row.id;
|
if(row.customer_code) {
|
if(!me.customer_products[row.customer_code]) {
|
me.customer_products[row.customer_code] = {};
|
}
|
}
|
if(me.isUpload) {
|
let param = row;
|
Server.call("root/data/updateEntity/" + me.uploadDataname, param, function(result) {
|
console.info(result);
|
});
|
}else {
|
me.rowChange(row, "up");
|
}
|
if (callback) {
|
callback();
|
}
|
}
|
});
|
} else if (field == "shop_name") {
|
Root.showPopup({
|
url: "../agreement/popup/popup_network_list.html",
|
width: 800,
|
height: 550,
|
text: "网点信息",
|
sceneCode: "add",
|
callback: function(obj, callback) {
|
row.shop_name = obj.row.md_description;
|
row.shop_code = obj.row.pos_code;
|
|
if (callback) {
|
callback();
|
}
|
}
|
});
|
} else if (field == "province_name"){
|
Root.showPopup({
|
url: "../org/department/popup/area_list.html",
|
width: 800,
|
height: 550,
|
callback: function(obj, callback) {
|
row.province_name = obj.row.province_name
|
row.province_code = obj.row.province_code
|
row.days_trans = obj.row.days
|
if(me.isUpload) {
|
let param = row;
|
Server.call("root/data/updateEntity/" + me.uploadDataname, param, function(result) {
|
console.info(result);
|
});
|
}else {
|
me.rowChange(row, "up");
|
}
|
if (callback) {
|
callback();
|
}
|
}
|
});
|
}
|
if (field == "business_operate_name") {
|
if(!row.customer_code) {
|
Root.message({
|
type:"warning",
|
message:"请先选择商业"
|
})
|
return;
|
}
|
Root.showPopup({
|
url: "../md/customer/popup/employee_list.html",
|
width: 800,
|
height: 550,
|
callback: function(obj, callback) {
|
row.business_operate_name = obj.row.md_description
|
row.business_operate_code = obj.row.md_code
|
if(row.business_operate_code) {
|
if(!me.customer_products[row.customer_code][row.business_operate_code]) {
|
me.customer_products[row.customer_code][row.business_operate_code] = [];
|
}
|
}
|
if (callback) {
|
callback();
|
}
|
}
|
});
|
|
}
|
},
|
|
cellSelectChange(scope) {
|
let me = this;
|
let row = scope.row;
|
let field = scope.column.property;
|
|
if (field == "marketing_company_name") {
|
// let val = row[field];
|
row.marketing_company_code = this.optionsObj.marketing_company_name[row[field]];
|
if(me.isUpload) {
|
let param = row;
|
Server.call("root/data/updateEntity/" + me.uploadDataname, param, function(result) {
|
console.info(result);
|
});
|
}else {
|
me.rowChange(row, "up");
|
}
|
}else if (field == "sales_company_name") {
|
// let val = row[field];
|
// row.sales_company_code = val;
|
row.sales_company_code = this.optionsObj.sales_company_name[row[field]];
|
if(me.isUpload) {
|
let param = row;
|
Server.call("root/data/updateEntity/" + me.uploadDataname, param, function(result) {
|
console.info(result);
|
});
|
}else {
|
me.rowChange(row, "up");
|
}
|
}
|
|
|
this.$refs.form1.refresh();
|
},
|
|
cellInputChange(scope) {
|
let row = scope.row;
|
let field = scope.column.property;
|
// if(field == "qty_order") {
|
// row.price_final = (row.qty_order ? row.qty_order : 0) * (row.price_unit ? row.price_unit : 0);
|
// }
|
if(this.isUpload) {
|
let param = row;
|
Server.call("root/data/updateEntity/" + this.uploadDataname, param, function(result) {
|
console.info(result);
|
});
|
}else {
|
this.rowChange(row, "up");
|
}
|
},
|
|
cellClick(obj) {
|
// if(obj.column.property == "productname") {
|
// this.selectedrow = obj.row;
|
// this.showPic("showPic", obj.row);
|
// }
|
},
|
|
showPopup(obj) {
|
var me = this;
|
this.selectFormField = obj.obj;
|
if (this.selectFormField.field == "province_name") {
|
Root.showPopup({
|
url: "../org/department/popup/area_list.html",
|
width: 800,
|
height: 550,
|
callback: function(obj, callback) {
|
let formData_ = clone(me.formData);
|
formData_.province_name = obj.row.province_name
|
formData_.province_code = obj.row.province_code
|
formData_.days_trans = obj.row.days
|
me.formData = formData_;
|
if (callback) {
|
callback();
|
}
|
}
|
});
|
}
|
},
|
|
onpassApproval() {
|
this.textarea2 = "";
|
this.reasonvisible = true;
|
this.passOrRefuse = true;
|
},
|
onrefuseApproval() {
|
this.textarea2 = "";
|
this.reasonvisible = true;
|
this.passOrRefuse = false;
|
},
|
saveReason() {
|
let me = this;
|
this.reasonLoading = true;
|
if (this.passOrRefuse) {
|
let param = {
|
flowId: this.formData.flow_id,
|
businessType: "puresale_plan",
|
pass: true,
|
variableMap: {
|
reason: this.textarea2
|
}
|
}
|
Server.call("root/api/dealAct", param, function(result) {
|
if (result.success) {
|
Root.message({
|
type: 'success',
|
message: '审批成功'
|
});
|
|
if(me.fromDing) {
|
me.dingResult = true;
|
me.dingResultTxt = "审批成功"
|
return;
|
}
|
me.reasonLoading = false;
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, true);
|
} else {
|
Root.message({
|
type: 'warning',
|
message: result.message
|
});
|
me.reasonLoading = false;
|
}
|
})
|
} else {
|
if (this.textarea2 != "") {
|
let param = {
|
flowId: this.formData.flow_id,
|
businessType: "puresale_plan",
|
pass: false,
|
variableMap: {
|
reason: this.textarea2
|
}
|
}
|
Server.call("root/api/dealAct", param, function(result) {
|
if (result.success) {
|
Root.message({
|
type: 'success',
|
message: '拒绝审批成功'
|
});
|
if(me.fromDing) {
|
me.dingResult = true;
|
me.dingResultTxt = "拒绝审批成功"
|
return;
|
}
|
me.reasonLoading = false;
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, true);
|
} else {
|
Root.message({
|
type: 'warning',
|
message: result.message
|
});
|
me.reasonLoading = false;
|
}
|
})
|
} else {
|
Root.message({
|
type: 'warning',
|
message: '请填写原因'
|
});
|
me.reasonLoading = false;
|
}
|
}
|
},
|
delData(scope) {
|
let me = this;
|
let row = scope.row;
|
let index_ = scope.$index;
|
|
Root.confirm('确定删除-' + row.product_name + '-吗?', '删除提示', {
|
confirmButtonText: '删除',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
if (row.id == undefined || row.id == '') {
|
me.rowChange(row, "del");
|
} else {
|
let param = {
|
id: row.id
|
}
|
if(me.isUpload) {
|
Server.call("root/data/deleteEntity" + "/" + me.uploadDataname, param, function(result) {
|
me.rowChange(row, "del");
|
});
|
}else {
|
Server.call("root/data/deleteEntity" + "/" + me.dataname, param, function(result) {
|
me.rowChange(row, "del");
|
});
|
}
|
}
|
Root.message({
|
type: 'success',
|
message: '删除成功!'
|
});
|
}).catch(() => {
|
Root.message({
|
type: 'info',
|
message: '已取消删除'
|
});
|
});
|
},
|
|
showPic(code, row) {
|
Root.popupParames = {
|
url: "../md/product/sku/pic_list.html",
|
};
|
Root.showPopup(Root.popupParames);
|
},
|
}
|
});
|
</script>
|
|
<style>
|
.el-collapse {
|
border: 0;
|
}
|
|
.el-collapse-item__content {
|
padding-bottom: 5px;
|
}
|
|
.el-collapse-item__header {
|
height: 30px;
|
line-height: 30px;
|
}
|
|
.el-collapse-item__header.is-active {
|
border-bottom-color: #e9f5f2;
|
}
|
|
.el-collapse-item__wrap {
|
border: 0;
|
}
|
|
.el-input__inner {
|
padding: 0 2px;
|
}
|
.header {
|
height: 21px;
|
}
|
.el-dialog__header {
|
border-bottom: 0;
|
}
|
.el-dialog__body {
|
text-align: center;
|
/* height: 200px; */
|
}
|
.warning-row {
|
color: red;
|
}
|
</style>
|
</body>
|
</html>
|