<!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=20220425"></script>
|
<script src="../../../js/vue/page.js?v=20220425"></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: 550px; overflow-y: auto;">
|
<div class="el-dialog__body" style="height: 500px;">
|
<template slot="title">
|
<i class="header-icon el-icon-info"></i>
|
<span>
|
订单信息
|
</span>
|
</template>
|
<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 style="margin-right: 10px;"@click="showCredit()">资信查询</el-button> -->
|
<el-button @click="addTableData">新增数据</el-button>
|
<input type="file" id="btn_file" ref="btn_file" style="display: none;" @change="getFile($event)"/>
|
<el-button @click="fileUpload()">上传</el-button>
|
<el-button @click="download()">下载模板</el-button>
|
</el-button-group>
|
</div>
|
<h-table
|
v-if="isRefresh"
|
ref="table2"
|
:table-fields="tableFields"
|
:table-data="tableData2"
|
:is-edit-table-data="isEditTableData"
|
:is-within-edit-table-data= "isWithinEditTableData"
|
:show-summary= "true"
|
:table-height="tableHeight2"
|
:is-pagination="false"
|
:is-show-index="true"
|
v-on:visible-change="cellVisibleChange"
|
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-show-popup="cellShowPopup"
|
>
|
</h-table>
|
</div>
|
</div>
|
<div class="el-dialog__footer">
|
<el-button type="default" @click="closeDialog">取 消</el-button>
|
<el-button v-if="notdisabled" type="primary" :loading="isLoading" @click="saveRowTableBefore">批量创建</el-button>
|
</div>
|
</div>
|
</div>
|
|
<div id="page_loading" style="position: absolute; top:0px; width: 100vw; height: 100vh;z-index:9999">
|
<div class="spinner">
|
<div class="cube1"></div>
|
<div class="cube2"></div>
|
</div>
|
</div>
|
</div>
|
|
<script type="text/javascript">
|
new ListVue({
|
el: "#vbody",
|
data: {
|
disabled: false,
|
notdisabled: true,
|
Approval:false,
|
|
form_dataname: "salesOrder",
|
dataname: "salesOrderDetail",
|
isLoading:false,
|
formAttr: {
|
title: "批量创建",
|
istitle: false,
|
columnnumber: 2,
|
labelwidth: "180px",
|
labelposition: "right",
|
size: "medium",
|
border: "0px solid #c6c6c600",
|
},
|
userPhone:{
|
|
},
|
itemOptions:{},
|
formFields: [],
|
formData: {},
|
|
newRowDefault: {
|
id: uuid_short(),
|
code: createCode("S"),
|
status: "input",
|
biz_date: createDate(),
|
create_time: createDatetime(),
|
trans_type:"01",
|
//typecode: "预付款",
|
bussinessman: window.top.userinfo.user.name,
|
sales_business_type: "1",
|
sales_type: "07",
|
creator: window.top.userinfo.employee.name,
|
},
|
|
default_tableFields: [],
|
tableFields: [],
|
tableData2: [],
|
tableDatasave: [],
|
tableDataChange: {},
|
tableHeight2: 300,
|
|
isEditTableData:true,
|
isWithinEditTableData:false,
|
isRefresh: true,
|
selectFormField: {},
|
selectrow: {},
|
dataRequestObj: {},
|
productDetail: [],
|
dataRequest: [{
|
isClientMode: false,
|
code: "code",
|
label: "value",
|
name: "sales_type",
|
dataname: "dictitem",
|
filter: " parent_id='sales_type'"
|
},
|
{
|
isClientMode: false,
|
code: "code",
|
label: "name",
|
name: "trans_type",
|
dataname: "md_trans_type",
|
},
|
],
|
sum_noRate_: 0,
|
updatetime: createDatetime()
|
},
|
|
created() {
|
this.popupParames = clone(Root.popupParames);
|
|
if (this.newRowDefault) {
|
let formData_ = clone(this.formData);
|
|
for (var k in this.newRowDefault) {
|
formData_[k] = this.newRowDefault[k];
|
}
|
this.formData = formData_;
|
}
|
},
|
|
mounted() {
|
let me = this;
|
if (this.dataRequest.length) {
|
var result = {};
|
this.loadRequestData(this.dataRequest, result, function(data) {
|
me.dataRequestObj = data;
|
|
if (me.formFields.length) {
|
var formFields_part_ = clone(me.formFields);
|
formFields_part_.map(e => {
|
if (e.field == "sales_type") {
|
e.options = me.dataRequestObj.sales_type;
|
}else if(e.field == "trans_type") {
|
e.options = me.dataRequestObj.trans_type;
|
}
|
})
|
}
|
me.formFields = formFields_part_
|
})
|
}
|
this.initFields();
|
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 = clone(dataRootFields.tableFields.orderCombineDetail_);
|
me.default_tableFields = clone(dataRootFields.tableFields.orderCombineDetail_);
|
|
me.formFields = dataRootFields.formFields.orderCombine_;
|
},
|
|
closeDialog() {
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, false);
|
},
|
onServerInitData(data) {
|
|
},
|
saveRowTableBefore() {
|
var me = this;
|
let array_ = [];
|
for (var i = 0; i < me.tableData2.length; i++) {
|
|
array_.push(i);
|
}
|
me.isOffline(array_);
|
},
|
saveRowTable() {
|
var me = this;
|
var array_ = [];
|
if(!this.formData.trans_type|| !this.formData.sales_type ||!this.formData.sales_business_type) {
|
Root.message({
|
type: 'warning',
|
message: '请填写必填项'
|
});
|
return
|
}
|
for (var i = 0;i< this.tableData2.length;i++) {
|
var row = this.tableData2[i];
|
if(!row.cnt){
|
Root.message({
|
type: 'warning',
|
message: '请填写数量'
|
});
|
return
|
}
|
var row_ = {};
|
let index = row.customer_consignee_address.indexOf("?:?");
|
if(index > -1)
|
row.customer_consignee_address = row.customer_consignee_address.substring(0,index);
|
row_.id = row.id ? row.id : "";
|
row_.count = row.cnt; //件数
|
row_.rebateAmt = row.rebate_amt?row.rebate_amt: "";
|
row_.salesType = me.formData.sales_type? me.formData.sales_type: ""; //销售类型。。正常销售
|
row_.taxRate = row.tax_rate?row.tax_rate:""; //税率
|
row_.departSalesType = row.depart_sales_type === undefined?"":row.depart_sales_type;
|
row_.departRevoType = row.depart_revo_type === undefined?"":row.depart_revo_type;
|
row_.agreementRecordId = row.agreement_record_id?row.agreement_record_id:""; //协议id row.agreementRecordId
|
row_.remark = row.remark?row.remark:"";
|
row_.customerConsigneeAddress = row.customer_consignee_address?row.customer_consignee_address:"";
|
row_.customerConsigneeUserName = row.customer_consignee_user_name?row.customer_consignee_user_name:"";
|
row_.customerConsigneePhone = row.customer_consignee_phone?row.customer_consignee_phone:"";
|
row_.is_offline = row.is_offline;
|
if(row_.agreementRecordId != ""){
|
array_.push(row_);
|
}
|
}
|
this.isLoading = true;
|
let param =
|
{
|
isClientMode: false,
|
customerId: this.formData.customer_id || "",
|
bizDate: this.formData.biz_date || "",
|
salesBusinessType: this.formData.sales_business_type || "",
|
salesType: this.formData.sales_type || "",
|
transType: this.formData.trans_type || "",
|
//settleType:this.formData.settle_type,
|
agreementRecordId: this.formData.agreementRecordId ? this.formData.agreementRecordId:"",//this.formData.agreementRecordId, //协议id
|
subSalesOrderList: array_,
|
customerConsignee: { //收货信息
|
id: this.formData.addressid?this.formData.addressid:"",//this.formData.addressid,
|
userName: this.formData.customer_consignee_user_name || "",
|
address: this.formData.customer_consignee_address|| "",
|
phone: this.formData.customer_consignee_phone || ""
|
},
|
}
|
Server.call("root/order/batchOrder", param, function(result) {
|
console.log(result);
|
if (result.success){
|
me.tableDatasave = [];
|
me.tableDatasave = clone(result.data.entityset);
|
//me.addCombineData();
|
var list = [];
|
for(var i = 0;i<me.tableDatasave.length;i++){
|
me.tableDatasave[i].isOffline = me.tableData2[i].is_offline;
|
if(!me.tableDatasave[i].bookNo)
|
me.tableDatasave[i].bookNo = me.tableData2[i].book_no || "";
|
//me.tableDatasave[i].customerConsigneeUserName = me.tableData2[i].customer_consignee_user_name
|
//me.tableDatasave[i].customerConsigneeAddress = me.tableData2[i].customer_consignee_address
|
//me.tableDatasave[i].customerConsigneePhone = me.tableData2[i].customer_consignee_phone
|
list.push(me.tableDatasave[i]);
|
}
|
let param = {
|
list
|
};
|
Server.call("root/order/saveBatchSalesOrder", param, function(result) {
|
console.log(result);
|
if (result.success){
|
Root.message({
|
type: 'success',
|
message: '保存成功'
|
});
|
}else{
|
Root.message({
|
type: 'warning',
|
message: result.message
|
});
|
}
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, true);
|
},function(result) {
|
me.isLoading = false;
|
Root.message({
|
type: 'warning',
|
message: result.message
|
});
|
});
|
}
|
else{
|
me.isLoading = false;
|
Root.message({
|
type: 'warning',
|
message: result.message
|
});
|
}
|
},function(result) {
|
me.isLoading = false;
|
Root.message({
|
type: 'warning',
|
message: result.message
|
});
|
});
|
},
|
addCombineData: function() {
|
var me = this;
|
//1.
|
this.operationtype = "add";
|
//this.selectedrow = {};
|
|
//2. get config and go
|
var config = new Config(), go = true;
|
|
if (this.onAddCombineData) {
|
go = this.onAddCombineData.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 = {
|
url: config.url,
|
sceneCode: config.sceneCode,
|
data: config.data,
|
delta: config.delta,
|
disabled: config.disabled,
|
disabledone: config.disabledone,
|
operationtype: "add",
|
};
|
|
Root.popupParames = parames;
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(config,true);
|
}
|
else {
|
this.doPopup(config);
|
}
|
}
|
},
|
onAddCombineData(config) {
|
var me = this;
|
config.combine({
|
totab: true,
|
icon: "icon-product",
|
text: "批量创建",
|
id: "sorder_savecombine",
|
url: "../order/sorder/sorder_savecombine.html",
|
sceneCode: "add",
|
data: this.tableDatasave,
|
});
|
return true;
|
},
|
doSave(array){
|
var me = this;
|
if (array.length) {//存在需处理的明细数据
|
var id = array[0];
|
var row_ = this.tableDataChange[id];
|
var type = row_.type;
|
var row = row_.data;
|
|
var param = {};
|
let event = "";
|
|
if (type == "add") {
|
param = row;
|
param.isClientMode = false;
|
|
event = "insertEntity";
|
}
|
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 + "/" + this.dataname, param, function(result) {
|
array.remove(id);
|
me.doSave(array);
|
});
|
|
}
|
else {
|
//1保存form数据
|
let param = this.formData;
|
param.isClientMode = false;
|
let event = "insertEntity";
|
|
Server.call("root/data/" + event + "/" + this.form_dataname, param, function(result) {
|
//2回调
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, true);
|
});
|
}
|
},
|
|
showCredit(code, row) {
|
let me = this;
|
if (me.formData.customer_name) {
|
Root.popupParames = {
|
url: "../tool/credit_status.html",
|
};
|
Root.showPopup(Root.popupParames);
|
}
|
else {
|
Root.message({
|
type: 'warning',
|
message: '请先选择客户'
|
});
|
}
|
},
|
|
rowChange(row, type) {
|
//tc
|
var id_ = row.id;
|
if (this.tableDataChange[id_]) {
|
this.tableDataChange[id_].data = row;
|
}
|
else {
|
var changeRow_ = {
|
type: type,
|
data: row
|
};
|
this.tableDataChange[id_] = changeRow_;
|
}
|
|
//t2
|
if (type == "add") {
|
this.tableData2.unshift(row);
|
}
|
else if (type == "del") {
|
this.tableData2.remove(row);
|
}
|
|
var sum_noRate_ = 0 ;
|
var available_amt = 0 ;
|
var formData_ = clone(this.formData);
|
this.tableData2.map(e=>{
|
sum_noRate_ += (e.product_amt ? e.product_amt : 0 ) * 1;
|
available_amt += (e.rebate_amt || 0) * 1
|
})
|
formData_.available_amt = available_amt;
|
formData_.amt = sum_noRate_;
|
|
this.formData = formData_;
|
/* this.$refs.form1.refresh();
|
this.isRefresh = false;
|
this.$nextTick(function(){ */
|
this.isRefresh = true;
|
//})
|
},
|
|
addTableData() {
|
if (!this.formData.customer_name) {
|
Root.message({
|
type: 'warning',
|
message: '请选择客户'
|
});
|
return;
|
}
|
if (this.selectrow != {}) {
|
this.selectrow.isWithinEdit = false;
|
}
|
var tax_rate_ = "13";
|
var id_ = uuid_short();
|
var row_ = {
|
isWithinEdit: true,
|
id: id_,
|
tax_rate:tax_rate_,
|
};
|
|
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 if (field_ == "tax_rate") {
|
row_[field_] = "13";
|
}
|
else {
|
row_[field_]="";
|
}
|
}
|
|
this.selectrow = row_;
|
this.rowChange(row_, "add");
|
},
|
|
fileUpload() {
|
let me = this;
|
if (me.formData.customer_name) {
|
document.getElementById("btn_file").click()
|
}
|
else {
|
Root.message({
|
type: 'warning',
|
message: '请先选择客户'
|
});
|
}
|
},
|
download(){
|
var url = window.top.RootSetting.url + "file/downloadTemplate?type=salesUpload&name=批量模板.xlsx";
|
dealExportByPath(url, "批量模板.xlsx");
|
},
|
getFile(event){
|
document.getElementById('page_loading').style.display = "block";
|
let me = this;
|
var file = event.target.files;
|
var forms = new FormData();
|
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]);
|
formData.append("customerId" ,this.formData.customer_id);
|
|
uploadAxios.post(baseUrl +'root/order/uploadSales?userId='+ localStorage.getItem("id"), formData).then(data_ => {
|
/* console.log(data_.data.data.entityset[0].batch_id);
|
var param = {
|
formData: {
|
formData:me.formData,
|
batchId: data_.data.data.entityset[0].batch_id,
|
},
|
tableData: data_.data.data.entityset
|
}
|
Root.showPopup({
|
url: "../order/sorder/sorder_preview.html",
|
width: 1300,
|
height: 550,
|
data: param,
|
callback: function(obj, callback) {
|
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, true);
|
|
if (callback) {
|
callback();
|
}
|
}
|
}); */
|
|
|
if(data_.data.data.matched.length == 0){
|
/* this.$message({
|
showClose: true,
|
message: '全部未匹配' ,
|
type: 'error'
|
}); */
|
this.$alert('全部未匹配', '提示', {
|
confirmButtonText: '确定',
|
|
});
|
document.getElementById('page_loading').style.display = "none";
|
|
}else{
|
if(data_.data.data.unMatched.length == 0){
|
|
this.$message({
|
showClose: true,
|
message: '上传成功!',
|
type: 'success'
|
});
|
document.getElementById('page_loading').style.display = "none";
|
}else{
|
let messageText = "";
|
for(var i = 0; i < data_.data.data.unMatched.length;i++){
|
messageText += data_.data.data.unMatched[i] + ","
|
}
|
this.$alert('以下行未匹配成功' + messageText, '提示', {
|
confirmButtonText: '确定',
|
});
|
document.getElementById('page_loading').style.display = "none";
|
/* this.$message({
|
showClose: true,
|
message: '以下行未匹配成功' + messageText,
|
type: 'error'
|
}); */
|
}
|
var tableDataMatched = [];
|
for(var i = 0; i < data_.data.data.matched.length;i++){
|
tableDataMatched[i] = data_.data.data.matched[i];
|
tableDataMatched[i].manager_part_name = data_.data.data.matched[i].manager_part_code;
|
tableDataMatched[i].cnt = data_.data.data.matched[i].count;
|
tableDataMatched[i].product_amt = (data_.data.data.matched[i].count * data_.data.data.matched[i].supply_price).toFixed(2);
|
tableDataMatched[i].remark = data_.data.data.matched[i].remark_;
|
tableDataMatched[i].trans_rate = data_.data.data.matched[i].product_conversion_rate;
|
tableDataMatched[i].rebate_amt = data_.data.data.matched[i].rebate_amt;
|
tableDataMatched[i].standrad_cnt = data_.data.data.matched[i].count / 1;//data_.data.data.matched[i].product_conversion_rate;
|
tableDataMatched[i].product_spec = data_.data.data.matched[i].pack
|
tableDataMatched[i].delivery_part_code = data_.data.data.matched[i].delivery_part_code
|
tableDataMatched[i].operator_name = data_.data.data.matched[i].operator_name
|
tableDataMatched[i].operator_code = data_.data.data.matched[i].operator_code
|
tableDataMatched[i].depart_sales_type = data_.data.data.matched[i].depart_sales_type
|
tableDataMatched[i].depart_revo_type = data_.data.data.matched[i].depart_revo_type
|
if(data_.data.data.matched[i].control_type == "1"){
|
tableDataMatched[i].control_type = "预付款"
|
}else if (data_.data.data.matched[i].control_type == "2"){
|
tableDataMatched[i].control_type = "账期"
|
}
|
if(data_.data.data.matched[i].manager_part_code == "CFY"){
|
tableDataMatched[i].manager_part_name = "处方药"
|
}else {
|
tableDataMatched[i].manager_part_name = data_.data.data.matched[i].manager_part_code
|
}
|
//let formData_ = clone(me.formData);
|
//formData_.settle_type = data_.data.data.matched[i].settle_type
|
//me.formData = formData_;
|
}
|
me.checkCustomerAndDelivery(tableDataMatched,function(){
|
me.$refs.btn_file.value = null;
|
document.getElementById('page_loading').style.display = "none";
|
})
|
|
return;
|
}
|
this.$refs.btn_file.value = null;
|
document.getElementById('page_loading').style.display = "none";
|
}).catch(error => {
|
|
this.$message({
|
showClose: true,
|
message: ':请求出现错误:' + error,
|
type: 'error'
|
});
|
document.getElementById('page_loading').style.display = "none";
|
});
|
}else{
|
Root.message({
|
type: 'info',
|
message: '格式不正确'
|
});
|
document.getElementById('page_loading').style.display = "none";
|
}
|
}
|
}
|
},
|
|
editData(scope) {
|
if (this.selectrow != {} && this.selectrow.isWithinEdit) {
|
this.$set(this.selectrow,"isWithinEdit",false)
|
let index = this.selectrow.customer_consignee_address.indexOf("?:?");
|
if(index > -1)
|
this.selectrow.customer_consignee_address = this.selectrow.customer_consignee_address.substring(0,index);
|
}
|
if(this.selectrow == scope.row ){
|
scope.row.isWithinEdit = false;
|
this.selectrow = {};
|
}else{
|
this.selectrow = scope.row;
|
scope.row.isWithinEdit = scope.row.isWithinEdit ? false : true;
|
}
|
if(scope.row.product_name != ""){
|
|
this.tableFields.map(e=>{
|
if (e.field == "manager_part_name") {
|
e.disabled = true;
|
}
|
if (e.field == "business_depart_name") {
|
e.type = "";
|
}
|
if (e.field == "province_name") {
|
e.type = "";
|
}
|
|
})
|
|
}
|
this.isRefresh = false;
|
this.$nextTick(function(){
|
this.isRefresh = true;
|
})
|
},
|
|
cellShowPopup(scope){
|
let me = this;
|
let row = scope.row;
|
let field = scope.column.property;
|
if (field == "managesubjectname") {
|
Root.showPopup({
|
url: "../org/company/popup/managesubject_list.html",
|
width: 800,
|
height: 550,
|
callback: function(obj, callback) {
|
row.managesubjectname = obj.row.managesubjectname
|
row.legalpersonsubjectname = obj.row.legalpersonsubjectname
|
if (callback) {
|
callback();
|
}
|
}
|
});
|
}
|
else if (field == "product_name"){
|
this.getFormData(row);
|
}
|
else if (field == "business_depart_name"){
|
let me = this;
|
var filter_ = " 1 = 1 and name is not null ";
|
filter_ = this.Getfilter(filter_,"business_depart_name");
|
Root.showPopup({
|
url: "../org/department/popup/department_list.html",
|
width: 800,
|
height: 550,
|
dataname:"getBusiness_depart_name",
|
filter:filter_,
|
callback: function(obj, callback) {
|
row.business_depart_name = obj.row.name
|
if (callback) {
|
callback();
|
}
|
}
|
});
|
}
|
else if (field == "province_name"){
|
let me = this;
|
var filter_ = " 1 = 1";
|
filter_ = this.Getfilter(filter_,"province_name");
|
Root.showPopup({
|
url: "../org/department/popup/area_list.html",
|
width: 800,
|
height: 550,
|
dataname:"getProvince_name",
|
filter:filter_,
|
callback: function(obj, callback) {
|
row.province_name = obj.row.province_name
|
if (callback) {
|
callback();
|
}
|
}
|
});
|
}
|
},
|
Getfilter(filter_,filter){
|
let me = this;
|
//管理主体名称
|
if (me.tableData2.manager_part_name) {
|
var filter1 = ""
|
if(me.tableData2.manager_part_name == "otc" || me.tableData2.manager_part_name == "OTC"){
|
filter1 = "OTC"
|
}else{
|
filter1 = "处方药"
|
}
|
filter_ += " and agreementRecord.manager_part_name = '"+filter1+"'"
|
}
|
//发货主体
|
if (me.tableData2.delivery_part_name && filter != "delivery_part_name") {
|
filter_ += " and agreementRecord.delivery_part_name = '"+ me.tableData2.delivery_part_name +"'"
|
}
|
//客户名称
|
if (me.formData.customer_id && filter != "customer_name") {
|
filter_ += " and agreementRecord.customer_id = '"+ me.formData.customer_id +"'"
|
}
|
//区域
|
if (me.tableData2.province_name && filter != "province_name") {
|
filter_ += " and agreementRecord.province_name = '"+ me.tableData2.province_name +"'"
|
}
|
//业务部门
|
if (me.tableData2.business_depart_name && filter != "business_depart_name") {
|
filter_ += " and agreementRecord.business_depart_name = '"+ me.tableData2.business_depart_name +"'"
|
}
|
//商业类型
|
if (me.formData.business_type) {
|
filter_ += " and agreementRecord.business_type = '"+ me.formData.business_type +"'"
|
}
|
return filter_
|
},
|
getFormData(row){
|
let me = this;
|
|
let filter_ = "and agreement_record.customer_id is not null ";
|
//管理主体名称
|
if (row.manager_part_name) {
|
filter_ += " and agreement_record.manager_part_code = '"+row.manager_part_code+"'"
|
}
|
//客户名称
|
if (me.formData.customer_id) {
|
filter_ += " and agreement_record.customer_id = '"+ me.formData.customer_id +"'"
|
}
|
|
/* if (me.formData.settle_type) {
|
filter_ += " and agreement_record.settle_type = '"+ me.formData.settle_type +"'"
|
} */
|
//区域
|
/* if (me.tableData2.province_name) {
|
filter_ += " and agreement_record.province_name = '"+ row.province_name +"'"
|
}
|
//业务部门
|
if (me.tableData2.business_depart_name) {
|
filter_ += " and agreementRecord.business_depart_name = '"+ row.business_depart_name +"'"
|
} */
|
|
//已选中的不可再次被选中
|
for(var i = 0; i < this.tableData2.length;i++){
|
if (this.tableData2[i].product_code && this.tableData2[i].delivery_part_code) {
|
filter_ += " and (CASE WHEN agreement_record.product_code = '" + this.tableData2[i].product_code +"'"
|
filter_ += " and agreement_record.delivery_part_code = '" + this.tableData2[i].delivery_part_code +"' THEN 0 ELSE 1 END)"
|
}
|
}
|
//业务类型
|
if (me.formData.sales_business_type) {
|
filter_ += "";
|
}
|
|
/* let param = {
|
isClientMode: false,
|
dataname: "agreementRecord",
|
filter: filter_,
|
} */
|
Root.showPopup({
|
url: "../md/product/popup/product_list.html",
|
width: 1100,
|
height: 550,
|
filter: filter_,
|
dataname: "salesAgreement", //salesAgreement
|
type: "sorder",
|
callback: function(obj, callback) {
|
me.itemOptions[obj.row.delivery_part_code] = [];
|
row.customer_consignee_address = ""
|
row.product_name = obj.row.product_name
|
row.productid = obj.row.product_id
|
row.product_code = obj.row.product_code
|
row.product_spec = obj.row.pack
|
row.supply_price = obj.row.supply_price
|
row.trans_rate = obj.row.product_conversion_rate
|
row.standrad_cnt = obj.row.standrad_cnt
|
row.priceunit = obj.row.priceunit
|
row.settle_type = window.top.formatter_settleType({},0,obj.row.settle_type)
|
row.taxrate = obj.row.taxrate
|
row.conversrate = obj.row.conversrate
|
row.delivery_part_name = obj.row.delivery_part_name
|
row.delivery_part_code = obj.row.delivery_part_code
|
row.book_no = obj.row.book_no
|
row.business_depart_name = obj.row.business_depart_name
|
row.operator_name = obj.row.operator_name
|
row.province_name = obj.row.province_name
|
if(obj.row.control_type == "1"){
|
row.control_type = "预付款"
|
}else if (obj.row.control_type == "2"){
|
row.control_type = "账期"
|
}
|
row.manager_part_code = obj.row.manager_part_code;
|
if(obj.row.manager_part_code == "CFY"){
|
row.manager_part_name = "处方药"
|
}else if(obj.row.manager_part_code == "OTC"){
|
row.manager_part_name = "OTC"
|
}
|
row.depart_sales_type = obj.row.s_depart_sales_type
|
row.depart_revo_type = obj.row.s_depart_revo_type
|
row.agreement_record_id = obj.row.id
|
me.checkCustomerAndDeliveryOne(row)
|
let formData_ = clone(me.formData);
|
//formData_.settle_type = obj.row.settle_type
|
formData_.business_type = obj.row.business_type
|
me.formData = formData_;
|
if (callback) {
|
callback();
|
}
|
}
|
});
|
},
|
|
isOffline(array) {
|
let me = this;
|
if(array.length > 0 ) {
|
let row = me.tableData2[array[0]];
|
let param_ = {
|
isClientMode: false,
|
dataname: "customerSignatureMapping",
|
filter: "1 = 1 and customer_code = '" + me.formData.customer_code + "'",
|
}
|
Server.call("root/data/getEntity", param_, function(result) {
|
if (result && result.data.entity) {
|
if (result.data.entity.has_signature)
|
row.is_offline = false;
|
else
|
row.is_offline = true;
|
|
} else {
|
row.is_offline = true;
|
}
|
array.shift();
|
me.isOffline(array)
|
});
|
}else
|
me.saveRowTable()
|
},
|
|
cellInputChange(scope) {
|
let row = scope.row;
|
let field = scope.column.property;
|
if(field == "cnt") {
|
row.product_amt = ((row.cnt ? row.cnt : 0) * (row.supply_price ? row.supply_price : 0)).toFixed(2);
|
row.standrad_cnt = this.routnFixed(row.cnt / (row.trans_rate || 1), 4);
|
}
|
if(field == "rebate_amt") {
|
if(row.rebate_amt > row.product_amt){
|
row.rebate_amt = "0";
|
Root.message({
|
type: 'warning',
|
message: '返利金额大于金额'
|
});
|
}
|
}
|
this.rowChange(row, "up");
|
},
|
cellSelectChange(obj){
|
let row = clone(obj.row);
|
if(obj.column.property == "customer_consignee_address") {
|
row.customer_consignee_user_name = this.userPhone[row.delivery_part_code][row.customer_consignee_address].user;
|
row.customer_consignee_phone = this.userPhone[row.delivery_part_code][row.customer_consignee_address].phone;
|
let index = row.customer_consignee_address.indexOf("?:?");
|
row.customer_consignee_address = row.customer_consignee_address.substring(0,index);
|
}
|
},
|
cellVisibleChange(obj) {
|
let options_ = [];
|
if (obj.field == "customer_consignee_address") {
|
options_ = this.itemOptions[this.selectrow.delivery_part_code];
|
obj.options = options_;
|
}
|
},
|
checkCustomerAndDeliveryOne(item,callback,type) {
|
if (item.delivery_part_code && this.formData.customer_id) {
|
let me = this;
|
let param_ = {
|
isClientMode: false,
|
dataname: "deliveryType",
|
code: item.delivery_part_code,
|
}
|
Server.call("root/data/getEntity", param_, function(result) {
|
//U8预留接口
|
let url = window.top.RootSetting.url_stock + "order/checkLicence"
|
axios.post(url, {
|
customerId: me.formData.customer_id || "",
|
bookNo: item.book_no ? item.book_no : "",
|
deliveryPartCode:item.delivery_part_code
|
})
|
.then(data => {
|
console.log(data);
|
if (data.data.success) {
|
let addressArr = data.data.data.consigneeList;
|
if (addressArr.length > 0) {
|
let arr = [];
|
var address_ =[];
|
if (addressArr.length == 1) {
|
item.customer_consignee_address = addressArr[0].address;
|
item.customer_consignee_user_name = addressArr[0].empName;
|
item.customer_consignee_phone = addressArr[0].empTel;
|
}
|
me.userPhone[item.delivery_part_code] = {}
|
for (var i = 0; i < addressArr.length; i++) {
|
address_.push({
|
address: addressArr[i].address,
|
address1: addressArr[i].address+"?:?"+i
|
});
|
me.userPhone[item.delivery_part_code][addressArr[i].address+"?:?"+i] = {user:addressArr[i].empName,phone:addressArr[i].empTel}
|
}
|
if(type == "add")
|
me.tableData2.push(item)
|
me.itemOptions[item.delivery_part_code] = address_;
|
}
|
if (callback) {
|
callback();
|
}
|
} else {
|
if (callback) {
|
callback();
|
}
|
Root.message({
|
type: 'warning',
|
message: data.data.message
|
});
|
}
|
})
|
.catch((error) => {
|
if (callback) {
|
callback();
|
}
|
console.log(error);
|
});
|
//}
|
});
|
}
|
},
|
checkCustomerAndDelivery(dataArray,callback) {
|
let me = this;
|
this.tableData2 = [];
|
for (var i = 0; i < dataArray.length; i++) {
|
let item = dataArray[i];
|
if (item.delivery_part_code && this.formData.customer_id) {
|
me.checkCustomerAndDeliveryOne(item,callback,"add");
|
}
|
}
|
},
|
|
delData(scope) {
|
let me = this;
|
let row = scope.row;
|
let index_ = scope.$index;
|
let name_ = "该数据";
|
if(row.product_name) {
|
name_ = row.product_name
|
}
|
Root.confirm('确定删除-' + name_ + '-吗?', '删除提示', {
|
confirmButtonText: '删除',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
me.rowChange(row, "del");
|
|
Root.message({
|
type: 'success',
|
message: '删除成功!'
|
});
|
}).catch(() => {
|
|
Root.message({
|
type: 'info',
|
message: '已取消删除'
|
});
|
});
|
},
|
|
showPopup(obj) {
|
this.selectFormField = obj.obj;
|
if (this.selectFormField.field == "customer_name") {
|
let me = this;
|
|
//var filter_ =" 1 = 1 and sales_agreement.operator_code = '" + localStorage.emp_code + "'"
|
let hierarchy_code = localStorage.hierarchy_code;
|
let isAll = localStorage.roleid.split(";").indexOf("7b84790f8649471c897d369bcde99623") > -1
|
let arr = ["202012210001","202104200018"];
|
var filter_ =" 1 = 1 and sales_agreement.operator_code = '" + localStorage.emp_code + "'"
|
|
let roleids = localStorage.roleid.split(";");
|
let r_id = "";
|
roleids.map(r=>{
|
if (r == "sp023" || r == "sp016") {//OTC招商(sp023)和品控(sp016)
|
r_id = r;
|
}
|
})
|
if (r_id) {
|
filter_ = " 1 = 1 and checked = 1 and vuoc.role_id='" + r_id + "'";
|
}
|
|
else if(arr.indexOf(hierarchy_code) > -1 || isAll)
|
filter_ = " 1 = 1 "
|
filter_ = this.Getfilter(filter_,"customer_name");
|
filter_ += " and "
|
Root.showPopup({
|
url: "../md/customer/popup/customer_list.html",
|
width: 1000,
|
height: 550,
|
filter:filter_,
|
dataname:"getCustomer_name",
|
callback: function(obj, callback) {
|
let formData_ = clone(me.formData);
|
formData_.customer_name = obj.row.md_description;
|
formData_.customer_consignee_address = obj.row.address;
|
formData_.customer_consignee_user_name = obj.row.operator_name;
|
formData_.customer_id = obj.row.customer_id;
|
formData_.customer_code = obj.row.customer_code;
|
//formData_.settle_type = "";
|
|
/* formData_.customername = obj.row.name;
|
formData_.address = obj.row.officeaddress;
|
formData_.customercode = obj.row.code;
|
formData_.contectname = obj.row.businesscontact;
|
formData_.contectphone = obj.row.businessphone;
|
formData_.creditamt = obj.row.creditamt;
|
|
formData_.invoice_title = obj.row.name;
|
formData_.invoice_taxno = obj.row.invoice_taxno;
|
formData_.invoice_address = obj.row.officeaddress;
|
formData_.invoice_phone = obj.row.phone;
|
formData_.invoice_bank = obj.row.invoice_bank;
|
formData_.invoice_bankaccount = obj.row.invoice_bankaccount; */
|
|
me.formData = formData_;
|
me.tableData2 = [];
|
if (callback) {
|
callback();
|
}
|
}
|
});
|
}
|
},
|
|
stopProp: function (e) {
|
e.stopPropagation()
|
},
|
|
handleChange(val){
|
if(val.indexOf("2") > -1) {
|
this.needInvoice = true;
|
}
|
else {
|
this.needInvoice = false;
|
}
|
},
|
|
routnFixed(val, num) {
|
return Math.round(Math.pow(10, num) * val) / Math.pow(10, num);
|
}
|
}
|
});
|
</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;
|
}
|
</style>
|
</body>
|
</html>
|