(function (vc) {
|
vc.extends({
|
data: {
|
addContractInfo: {
|
communityId: vc.getCurrentCommunity().communityId,
|
communities: [],
|
contractId: '',
|
contractName: '',
|
contractCode: '',
|
contractType: '',
|
aPartyaId: '',
|
bPartyaId: '',
|
cPartyaId: '',
|
partyA: '',
|
partyB: '',
|
partyC: '',
|
aContacts: '',
|
bContacts: '',
|
cContacts: '',
|
aLink: '',
|
bLink: '',
|
cLink: '',
|
operator: '',
|
operatorLink: '',
|
allNum: '',
|
amount: '',
|
startTime: '',
|
endTime: '',
|
signingTime: '',
|
contractTypes: [],
|
contractTypeSpecs: [],
|
roomId: '',
|
ownerName: '',
|
link: '',
|
objType: '1111',
|
objId: '-1',
|
contractParentId: '',
|
parentContractCode: '',
|
parentContractName: '',
|
parentStateName: '',
|
objName: '',
|
objPersonName: '',
|
objPersonId: '',
|
rooms: [],
|
contractFilePo: [],
|
tempfile: '',
|
contractPartyAs: [],
|
contractPartyBs: [],
|
contractPartyCs: [],
|
audit: '',
|
staffName: '',
|
nextUserId: ''
|
}
|
},
|
_initMethod: function () {
|
vc.component._initAddContractInfo();
|
$that._loadCommunities();
|
$that._loadAddContractType();
|
$that._loadAddContractParkA();
|
$that._loadAddContractParkB();
|
$that._loadAddContractParkC();
|
if (vc.getParam("contractId")) {
|
$that.addContractInfo.contractParentId = vc.getParam("contractId");
|
$that.addContractInfo.parentContractCode = vc.getParam("contractCode");
|
$that.addContractInfo.parentContractName = vc.getParam("contractName");
|
$that.addContractInfo.parentStateName = vc.getParam("stateName");
|
$that.addContractInfo.contractId = '';
|
$that.addContractInfo.contractCode = '';
|
$that.addContractInfo.contractName = '';
|
$that.addContractInfo.allNum = vc.getParam("objId");
|
$that._queryRoom();
|
$that._listContracts();
|
}
|
/*vc.initDateTime('addStartTime', function (_value) {
|
$that.addContractInfo.startTime = _value;
|
});
|
vc.initDateTime('addEndTime', function (_value) {
|
$that.addContractInfo.endTime = _value;
|
});
|
vc.initDateTime('addSigningTime', function (_value) {
|
$that.addContractInfo.signingTime = _value;
|
});
|
$that.addContractInfo.signingTime = vc.dateTimeFormat(new Date().getTime());*/
|
},
|
_initEvent: function () {
|
vc.on('addContract', 'chooseRoom', function (param) {
|
$that.addContractInfo.rooms.push(param);
|
})
|
vc.on('addContract', 'chooseOwner', function (param) {
|
$that.addContractInfo.partyB = param.name;
|
$that.addContractInfo.bContacts = param.name;
|
$that.addContractInfo.bLink = param.link;
|
$that.addContractInfo.objId = param.ownerId;
|
})
|
vc.on("addContract", "notify3", function (info) {
|
$that.addContractInfo.nextUserId = info.staffId;
|
$that.addContractInfo.staffName = info.staffName;
|
});
|
},
|
methods: {
|
formatAmount(event) {
|
let value = event.target.value;
|
// 移除非数字和小数点字符
|
let number = value.replace(/[^0-9.]/g, '');
|
|
// 限制小数点后两位并合并输入
|
const parts = number.split('.');
|
if (parts.length > 2) {
|
number = parts[0] + '.' + parts.slice(1).join('').substring(0, 2);
|
} else if (parts.length === 2) {
|
number = parts[0] + '.' + parts[1].substring(0, 2);
|
}
|
// 如果不是有效数字则返回
|
if (isNaN(number) || number === '') {
|
$that.addContractInfo.amount = '';
|
return;
|
}
|
// 更新原始金额
|
$that.addContractInfo.amount = number;
|
// 格式化为千分位
|
let formattedAmount = parseFloat(number).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 2 });
|
|
// 设置显示值
|
event.target.value = formattedAmount;
|
},
|
_initAddContractInfo: function () {
|
// $that.addContractInfo.signingTime = vc.dateTimeFormat(new Date().getTime());
|
$that.addContractInfo.signingTime = vc.dateFormat(new Date(), "yyyy-MM-dd");
|
$('.addStartTime').datetimepicker({
|
language: 'zh-CN',
|
fontAwesome: 'fa',
|
format: 'yyyy-mm-dd',
|
minView: "month",
|
initTime: true,
|
initialDate: new Date(),
|
autoClose: 1,
|
todayBtn: true
|
});
|
$('.addStartTime').datetimepicker()
|
.on('changeDate', function (ev) {
|
var value = $(".addStartTime").val();
|
vc.component.addContractInfo.startTime = value;
|
});
|
$('.addEndTime').datetimepicker({
|
language: 'zh-CN',
|
fontAwesome: 'fa',
|
format: 'yyyy-mm-dd',
|
minView: "month",
|
initTime: true,
|
initialDate: new Date(),
|
autoClose: 1,
|
todayBtn: true
|
});
|
$('.addEndTime').datetimepicker()
|
.on('changeDate', function (ev) {
|
var value = $(".addEndTime").val();
|
var start = Date.parse(new Date(vc.component.addContractInfo.startTime))
|
var end = Date.parse(new Date(value))
|
if (start - end >= 0) {
|
vc.toast("结束时间必须大于开始时间")
|
$(".addEndTime").val('')
|
} else {
|
vc.component.addContractInfo.endTime = value;
|
}
|
});
|
$('.addSigningTime').datetimepicker({
|
language: 'zh-CN',
|
fontAwesome: 'fa',
|
format: 'yyyy-mm-dd',
|
minView: "month",
|
startView: "month",
|
initTime: true,
|
initialDate: new Date(),
|
autoClose: 1,
|
todayBtn: true
|
});
|
$('.addSigningTime').datetimepicker()
|
.on('changeDate', function (ev) {
|
var value = $(".addSigningTime").val();
|
vc.component.addContractInfo.signingTime = value.split(' ')[0];
|
});
|
//防止多次点击时间插件失去焦点
|
document.getElementsByClassName('form-control addStartTime')[0].addEventListener('click', myfunc)
|
|
function myfunc(e) {
|
e.currentTarget.blur();
|
}
|
|
document.getElementsByClassName("form-control addEndTime")[0].addEventListener('click', myfunc)
|
|
function myfunc(e) {
|
e.currentTarget.blur();
|
}
|
|
document.getElementsByClassName("form-control addSigningTime")[0].addEventListener('click', myfunc)
|
|
function myfunc(e) {
|
e.currentTarget.blur();
|
}
|
},
|
addContractValidate() {
|
return vc.validate.validate({
|
addContractInfo: $that.addContractInfo
|
}, {
|
'addContractInfo.contractName': [
|
{
|
limit: "required",
|
param: "",
|
errInfo: "合同名称不能为空"
|
},
|
{
|
limit: "maxLength",
|
param: "200",
|
errInfo: "合同名称不能超过64位"
|
},
|
],
|
'addContractInfo.contractCode': [
|
{
|
limit: "required",
|
param: "",
|
errInfo: "合同编号不能为空"
|
},
|
{
|
limit: "maxLength",
|
param: "30",
|
errInfo: "合同编号错误"
|
},
|
],
|
'addContractInfo.contractType': [
|
{
|
limit: "required",
|
param: "",
|
errInfo: "合同类型不能为空"
|
},
|
{
|
limit: "num",
|
param: "",
|
errInfo: "合同类型格式错误"
|
},
|
],
|
'addContractInfo.partyA': [
|
{
|
limit: "required",
|
param: "",
|
errInfo: "甲方不能为空"
|
},
|
{
|
limit: "maxLength",
|
param: "200",
|
errInfo: "甲方名称太长"
|
},
|
],
|
'addContractInfo.partyB': [
|
{
|
limit: "required",
|
param: "",
|
errInfo: "乙方不能为空"
|
},
|
{
|
limit: "maxLength",
|
param: "200",
|
errInfo: "乙方名称太长"
|
},
|
],
|
// 'addContractInfo.aContacts': [
|
// {
|
// limit: "required",
|
// param: "",
|
// errInfo: "甲方联系人不能为空"
|
// },
|
// {
|
// limit: "maxLength",
|
// param: "64",
|
// errInfo: "甲方联系人长度超过64位"
|
// },
|
// ],
|
// 'addContractInfo.bContacts': [
|
// {
|
// limit: "required",
|
// param: "",
|
// errInfo: "乙方联系人不能为空"
|
// },
|
// {
|
// limit: "maxLength",
|
// param: "64",
|
// errInfo: "乙方联系人长度超过64位"
|
// },
|
// ],
|
// 'addContractInfo.aLink': [
|
// {
|
// limit: "required",
|
// param: "",
|
// errInfo: "甲方联系电话不能为空"
|
// }
|
// ],
|
// 'addContractInfo.bLink': [
|
// {
|
// limit: "required",
|
// param: "",
|
// errInfo: "乙方联系电话不能为空"
|
// }
|
// ],
|
'addContractInfo.operator': [
|
{
|
limit: "required",
|
param: "",
|
errInfo: "经办人不能为空"
|
},
|
{
|
limit: "maxLength",
|
param: "64",
|
errInfo: "经办人超过64位"
|
},
|
],
|
'addContractInfo.operatorLink': [
|
{
|
limit: "required",
|
param: "",
|
errInfo: "联系电话不能为空"
|
}
|
],
|
'addContractInfo.amount': [
|
{
|
limit: "money",
|
param: "",
|
errInfo: "合同金额格式错误,如1.50"
|
}
|
],
|
'addContractInfo.startTime': [
|
{
|
limit: "required",
|
param: "",
|
errInfo: "开始时间不能为空"
|
}
|
],
|
'addContractInfo.endTime': [
|
{
|
limit: "required",
|
param: "",
|
errInfo: "结束时间不能为空"
|
}
|
],
|
'addContractInfo.signingTime': [
|
{
|
limit: "required",
|
param: "",
|
errInfo: "合同签订时间不能为空"
|
}
|
],
|
'addContractInfo.communityId': [
|
{
|
limit: "required",
|
param: "",
|
errInfo: "请选择所属小区"
|
}
|
]
|
});
|
},
|
_queryRoom: function () {
|
let param = {
|
params: {
|
contractId: vc.getParam("contractId"),
|
page: 1,
|
row: 100
|
}
|
}
|
//发送get请求
|
vc.http.apiGet('/contract/queryContractRoom',
|
param,
|
function (json, res) {
|
var _contractTFile = JSON.parse(json);
|
$that.addContractInfo.rooms = _contractTFile.data;
|
},
|
function (errInfo, error) {
|
console.log('请求失败处理');
|
}
|
);
|
},
|
saveContractInfo: function () {
|
if (!$that.addContractValidate()) {
|
vc.toast(vc.validate.errInfo);
|
return;
|
}
|
// 使用下拉框选中的communityId传递给接口
|
// addContractInfo.communityId 已通过 v-model 绑定,包含用户选择的值
|
|
vc.http.apiPost(
|
'/contract/saveContract',
|
JSON.stringify($that.addContractInfo), {
|
emulateJSON: true
|
},
|
function (json, res) {
|
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
|
let _json = JSON.parse(json);
|
if (_json.code == 0) {
|
//关闭model
|
vc.toast('提交成功');
|
$that._goBack();
|
return;
|
} else {
|
vc.toast(_json.msg);
|
}
|
},
|
function (errInfo, error) {
|
console.log('请求失败处理');
|
vc.toast(errInfo);
|
});
|
},
|
clearAddContractInfo: function () {
|
let _contractTypes = $that.addContractInfo.contractTypes;
|
$that.addContractInfo = {
|
communityId: vc.getCurrentCommunity().communityId,
|
contractName: '',
|
contractCode: '',
|
contractType: '',
|
aPartyaId: '',
|
bPartyaId: '',
|
cPartyaId: '',
|
partyA: '',
|
partyB: '',
|
partyC: '',
|
aContacts: '',
|
bContacts: '',
|
cContacts: '',
|
aLink: '',
|
bLink: '',
|
cLink: '',
|
operator: '',
|
operatorLink: '',
|
amount: '',
|
startTime: '',
|
endTime: '',
|
signingTime: vc.dateFormat(new Date(), "yyyy-MM-dd"),
|
propertyCompany: '', // 物业公司名称(新增)
|
contractTerm: '', // 合同年限(新增)
|
isArchived: '', // 是否存档(新增)
|
contractReminderDate: '', // 合同提醒日期(新增)
|
signatoryAddress: '', // 签约方详细地址(新增)
|
contactEmail: '', // 签约方联系邮箱(新增)
|
contactWechat: '', // 签约方联系微信(新增)
|
remarks: '', // 合同备注信息(新增)
|
contractTypes: _contractTypes,
|
contractTypeSpecs: [],
|
allNum: '',
|
roomId: '',
|
ownerName: '',
|
link: '',
|
objId: '-1',
|
objType: '1111',
|
contractParentId: '',
|
parentContractCode: '',
|
parentContractName: '',
|
parentStateName: '',
|
objName: '',
|
objPersonName: '',
|
objPersonId: '',
|
rooms: [],
|
contractFilePo: [],
|
tempfile: '',
|
contractPartyAs: [],
|
contractPartyBs: [],
|
contractPartyCs: [],
|
audit: '',
|
staffName: '',
|
nextUserId: ''
|
};
|
},
|
_loadCommunities: function () {
|
let param = {
|
params: {
|
page: 1,
|
row: 100
|
}
|
};
|
//发送get请求
|
vc.http.apiGet('/community.listCommunitys',
|
param,
|
function (json, res) {
|
let _communityInfo = JSON.parse(json);
|
if (_communityInfo.code == 0) {
|
$that.addContractInfo.communities = _communityInfo.communitys || [];
|
}
|
},
|
function (errInfo, error) {
|
console.log('请求失败处理');
|
}
|
);
|
},
|
_loadAddContractType: function () {
|
let param = {
|
params: {
|
page: 1,
|
row: 100,
|
communityId: vc.getCurrentCommunity().communityId,
|
|
}
|
}
|
//发送get请求
|
vc.http.apiGet('/contract/queryContractType',
|
param,
|
function (json, res) {
|
var _contractTypeManageInfo = JSON.parse(json);
|
$that.addContractInfo.contractTypes = _contractTypeManageInfo.data;
|
},
|
function (errInfo, error) {
|
console.log('请求失败处理');
|
}
|
);
|
},
|
_loadAddContractParkA: function () {
|
let param = {
|
params: {
|
page: 1,
|
row: 100,
|
typeId: 1,
|
communityId: vc.getCurrentCommunity().communityId,
|
|
}
|
}
|
//发送get请求
|
vc.http.apiGet('/contractPartya/queryContractPartya',
|
param,
|
function (json, res) {
|
var _contractTypeManageInfo = JSON.parse(json);
|
$that.addContractInfo.contractPartyAs = _contractTypeManageInfo.data;
|
},
|
function (errInfo, error) {
|
console.log('请求失败处理');
|
}
|
);
|
},
|
_loadAddContractParkB: function () {
|
let param = {
|
params: {
|
page: 1,
|
row: 100,
|
typeId: 2,
|
communityId: vc.getCurrentCommunity().communityId,
|
|
|
}
|
}
|
//发送get请求
|
vc.http.apiGet('/contractPartya/queryContractPartya',
|
param,
|
function (json, res) {
|
var _contractTypeManageInfo = JSON.parse(json);
|
$that.addContractInfo.contractPartyBs = _contractTypeManageInfo.data;
|
},
|
function (errInfo, error) {
|
console.log('请求失败处理');
|
}
|
);
|
},
|
_loadAddContractParkC: function () {
|
let param = {
|
params: {
|
page: 1,
|
row: 100,
|
typeId: 3,
|
communityId: vc.getCurrentCommunity().communityId,
|
|
|
}
|
}
|
//发送get请求
|
vc.http.apiGet('/contractPartya/queryContractPartya',
|
param,
|
function (json, res) {
|
var _contractTypeManageInfo = JSON.parse(json);
|
$that.addContractInfo.contractPartyCs = _contractTypeManageInfo.data;
|
},
|
function (errInfo, error) {
|
console.log('请求失败处理');
|
}
|
);
|
},
|
_changeContractType: function () {
|
$that.addContractInfo.contractTypes.forEach(item => {
|
if ($that.addContractInfo.contractType == item.contractTypeId) {
|
$that.addContractInfo.audit = item.audit;
|
}
|
})
|
let param = {
|
params: {
|
page: 1,
|
row: 100,
|
contractTypeId: $that.addContractInfo.contractType,
|
communityId: vc.getCurrentCommunity().communityId,
|
|
}
|
}
|
$that.addContractInfo.contractTypeSpecs = [];
|
vc.http.apiGet('/contract/queryContractTypeSpec',
|
param,
|
function (json, res) {
|
let _contractTypeSpecManageInfo = JSON.parse(json);
|
_contractTypeSpecManageInfo.data.forEach(item => {
|
item.value = '';
|
if (item.specShow == 'Y') {
|
item.values = [];
|
//$that._loadAttrValue(item.specCd, item.values);
|
$that.addContractInfo.contractTypeSpecs.push(item);
|
}
|
});
|
},
|
function (errInfo, error) {
|
console.log('请求失败处理');
|
}
|
);
|
},
|
_changeCommunity: function () {
|
// 小区变更时的处理逻辑
|
},
|
_goBack: function () {
|
vc.goBack();
|
},
|
_selectRoom: function () {
|
vc.emit('searchRoom', 'openSearchRoomModel', {})
|
},
|
_openDelRoomModel: function (_room) {
|
let _tmpRooms = [];
|
$that.addContractInfo.rooms.forEach(item => {
|
if (item.roomId != _room.roomId) {
|
_tmpRooms.push(item);
|
}
|
});
|
$that.addContractInfo.rooms = _tmpRooms;
|
},
|
addFileStep: function () {
|
let _file = {
|
seq: $that.addContractInfo.contractFilePo.length,
|
fileSaveName: '',
|
fileRealName: ''
|
}
|
$that.addContractInfo.contractFilePo.push(_file);
|
},
|
deleteStep: function (_step) {
|
for (var i = 0; i < $that.addContractInfo.contractFilePo.length; i++) {
|
if ($that.addContractInfo.contractFilePo[i].seq == _step.seq) {
|
$that.addContractInfo.contractFilePo.splice(i, 1);
|
}
|
}
|
},
|
getFile: function (e, index) {
|
$that.addContractInfo.tempfile = e.target.files[0];
|
$that.addContractInfo.contractFilePo[index].fileRealName = $that.addContractInfo.tempfile.name;
|
$that._importData(index);
|
},
|
_importData: function (index) {
|
// 导入数据
|
let _fileName = $that.addContractInfo.tempfile.name;
|
let _suffix = _fileName.substring(_fileName.lastIndexOf('.') + 1);
|
if (!$that.checkFileType(_suffix.toLowerCase())) {
|
vc.toast('操作失败,请上传图片、PDF或Word格式的文件');
|
return;
|
}
|
let param = new FormData();
|
param.append("uploadFile", $that.addContractInfo.tempfile);
|
vc.http.upload(
|
'importRoomFee',
|
'uploadContactFile',
|
param, {
|
emulateJSON: true,
|
//添加请求头
|
headers: {
|
"Content-Type": "multipart/form-data"
|
}
|
},
|
function (json, res) {
|
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
|
if (res.status == 200) {
|
$that.addContractInfo.contractFilePo[index].fileSaveName = json;
|
vc.toast("上传成功");
|
return;
|
}
|
vc.toast(json, 10000);
|
},
|
function (errInfo, error) {
|
console.log('请求失败处理');
|
vc.toast(errInfo, 10000);
|
});
|
},
|
checkFileType: function (fileType) {
|
const acceptTypes = ['png', 'pdf', 'jpg', 'doc', 'docx'];
|
return acceptTypes.includes(fileType);
|
// for (var i = 0; i < acceptTypes.length; i++) {
|
// if (fileType === acceptTypes[i]) {
|
// return true;
|
// }
|
// }
|
// return false;
|
},
|
_changeContractPartyA: function () {
|
let _partyA = $that.addContractInfo.partyA;
|
$that.addContractInfo.contractPartyAs.forEach(item => {
|
if (_partyA == item.partyA) {
|
$that.addContractInfo.aLink = item.aLink;
|
$that.addContractInfo.aPartyaId = item.partyaId;
|
$that.addContractInfo.aContacts = item.aContacts;
|
}
|
})
|
},
|
_changeContractPartyB: function () {
|
let _partyB = $that.addContractInfo.partyB;
|
$that.addContractInfo.contractPartyBs.forEach(item => {
|
if (_partyB == item.partyA) {
|
$that.addContractInfo.bLink = item.aLink;
|
$that.addContractInfo.bPartyaId = item.partyaId;
|
$that.addContractInfo.bContacts = item.aContacts;
|
}
|
})
|
},
|
_changeContractPartyC: function() {
|
let _partyC = $that.addContractInfo.partyC;
|
$that.addContractInfo.contractPartyCs.forEach(item => {
|
if (_partyC == item.partyA) {
|
$that.addContractInfo.cLink = item.aLink;
|
$that.addContractInfo.cPartyaId = item.partyaId;
|
$that.addContractInfo.cContacts = item.aContacts;
|
}
|
});
|
},
|
_searchOwner: function () {
|
vc.emit('searchOwner', 'openSearchOwnerModel', {});
|
},
|
_listContracts: function () {
|
let param = {
|
params: {
|
page: 1,
|
row: 1,
|
contractId: vc.getParam('contractId')
|
}
|
};
|
//发送get请求
|
vc.http.apiGet('/contract/queryContract',
|
param,
|
function (json, res) {
|
let _expirationContractInfo = JSON.parse(json);
|
vc.copyObject(_expirationContractInfo.data[0], $that.addContractInfo);
|
$that.addContractInfo.contractId = '';
|
$that.addContractInfo.contractCode = '';
|
$that.addContractInfo.contractName = '';
|
$that.addContractInfo.startTime = $that.addContractInfo.endTime;
|
$that.addContractInfo.endTime = '';
|
$that.addContractInfo.signingTime = '';
|
},
|
function (errInfo, error) {
|
console.log('请求失败处理');
|
}
|
);
|
},
|
},
|
});
|
|
})(window.vc);
|