云枢例子

<style>
</style>

<section id="toolbar"></section>

<section type="template" id="template">
<a-row>
<a-col>
<a-title key="title1582969388001" data-name="导购人事维护" data-name_i18n='{"en":"导购人事维护"}'></a-title>
</a-col>
</a-row>
<a-row>
<a-col>
<a-create-by key="creater" data-name="创建人"></a-create-by>
</a-col>
<a-col>
<a-created-time key="createdTime" data-name="创建时间"></a-created-time>
</a-col>
<a-col>
<a-sequence-no key="sequenceNo" data-name="单据号"></a-sequence-no>
</a-col>
</a-row>
<a-row>
<a-col>
<a-group-title key="group1582969388001" data-name="申请人信息"></a-group-title>
</a-col>
</a-row>
<a-row>
<a-col>
<a-text key="apply_user" data-name="申请人姓名" data-name_i18n='{"en":"申请人姓名"}' data-readonly-formula="true" data-default-value=""></a-text>
</a-col>
<a-col>
<a-text key="job_number" data-name="申请人工号" data-readonly-formula="true"></a-text>
</a-col>
</a-row>
<a-row>
<a-col>
<a-text key="apply_post" data-name="申请人职位" data-readonly-formula="true"></a-text>
</a-col>
</a-row>
<a-row>
<a-col>
<a-group-title key="group1582969520959" data-name="导购信息"></a-group-title>
</a-col>
</a-row>
<a-row>
<a-col>
<a-association-form key="choose_guide_type" data-name="选择导购类型" data-schema-code="sales_type" data-display-field="guide_type_name" data-mappings="guide_type_name:{classification};sales_type:{guide_type};code:{guide_type_code}"></a-association-form>
</a-col>
<a-col>
<a-text key="classification" data-name="导购类型" data-required-formula="true" data-readonly-formula="true"></a-text>
</a-col>
</a-row>
<a-row>
<a-col>
<a-text key="guide_type_code" data-name="导购员编码" data-required-formula="true"></a-text>
</a-col>
<a-col>
<a-text key="guide_type" data-name="导购员类型" data-required-formula="true"></a-text>
</a-col>
</a-row>
<a-row>
<a-col>
<a-association-form key="choose_bianzhi" data-name="请选择编制" data-display-formula="{classification} == '长促' || {classification} == '冲锋队'" data-required-formula="{classification} == '临促' || {classification} == '冲锋队'" data-schema-code="plans_info" data-conditions="status:空编" data-mappings="plans:{bianzhi_code};shopping_guide_type:{guide_nature};store_code:{store_code};store_name:{store_name};customer_group:{system_name};stroe_in_provincial_area:{city};large_area:{org_bigarea_name};provincial_area:{province_name}"></a-association-form>
</a-col>
</a-row>
<a-row>
<a-col>
<a-text key="bianzhi_code" data-name="编制编码" data-display-formula="{classification} == '长促' && {classification} == '冲锋队'" data-required-formula="{classification} == '长促' || {classification} == '冲锋队'" data-readonly-formula="true"></a-text>
</a-col>
<a-col>
<a-text key="system_name" data-name="系统名称" data-display-formula="{classification} == '长促' || {classification} == '冲锋队'" data-readonly-formula="true"></a-text>
</a-col>
</a-row>
<a-row>
<a-col>
<a-text key="store_code" data-name="门店编码" data-display-formula="{classification} == '长促' || {classification} == '冲锋队'" data-required-formula="{classification} != '临促'" data-readonly-formula="true"></a-text>
</a-col>
<a-col>
<a-text key="store_name" data-name="门店名称" data-display-formula="{classification} == '长促' || {classification} == '冲锋队'" data-required-formula="{classification} != '临促'"></a-text>
</a-col>
</a-row>
<a-row>
<a-col>
<a-dropdown key="is_direct" data-name="是否有督导" data-default-value="有督导" data-options="有督导;无督导" data-empty-value=""></a-dropdown>
</a-col>
</a-row>
<a-row>
<a-col>
<a-text key="supervisor_pernr" data-name="管辖督导工号" data-readonly-formula="true"></a-text>
</a-col>
<a-col>
<a-dropdown key="supervisor" data-name="管辖督导" data-readonly-formula="true" data-options="选项1;选项2;选项3"></a-dropdown>
</a-col>
</a-row>
<a-row>
<a-col>
<a-dropdown key="org_bigarea_name" data-name="大区名称" data-options="选项1;选项2;选项3"></a-dropdown>
</a-col>
<a-col>
<a-dropdown key="province_name" data-name="省区名称" data-options="选项1;选项2;选项3"></a-dropdown>
</a-col>
</a-row>
<a-row>
<a-col>
<a-text key="city" data-name="城市" data-display-formula="{classification} == '长促' || {classification} == '冲锋队'"></a-text>
</a-col>
<a-col>
<a-text key="guide_nature" data-name="导购性质" data-display-formula="{classification} == '长促' || {classification} == '冲锋队'" data-required-formula="{classification} == '长促' || {classification} == '冲锋队'"></a-text>
</a-col>
</a-row>
<a-row>
<a-col>
<a-dropdown key="grade" data-name="星级" data-required-formula="{classification} != '临促'" data-default-value="一星" data-options="一星;二星;三星;四星;五星"></a-dropdown>
</a-col>
<a-col>
<a-radio key="sex" data-name="性别" data-options="男;女"></a-radio>
</a-col>
</a-row>
<a-row>
<a-col>
<a-text key="guide_name" data-name="入职人员姓名" data-required-formula="true"></a-text>
</a-col>
<a-col>
<a-text key="mobile" data-name="联络电话" data-required-formula="true" data-regexp="/^1[3|4|5|6|7|8|9][0-9]{9}$/" data-regexp-text='{"en":"Please enter a valid mobile phone number","zh":"请输入一个有效手机号码"}'></a-text>
</a-col>
</a-row>
<a-row>
<a-col>
<a-text key="icnum" data-name="身份证" data-regexp="/^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/" data-regexp-text='{"en":"Please enter a valid ID card","zh":"请输入一个有效的身份证"}'></a-text>
</a-col>
<a-col>
<a-number key="age" data-name="年龄"></a-number>
</a-col>
</a-row>
<a-row>
<a-col>
<a-dropdown key="education" data-name="学历" data-required-formula="true" data-default-value="小学" data-options="小学;初中;高中;中专;大专;本科;硕士;博士"></a-dropdown>
</a-col>
<a-col>
<a-dropdown key="is_full_time_staff" data-name="是否全日制工" data-default-value="是" data-options="是;否"></a-dropdown>
</a-col>
</a-row>
<a-row>
<a-col>
<a-text key="work_city" data-name="工作城市" data-required-formula="true"></a-text>
</a-col>
</a-row>
<a-row>
<a-col>
<a-text key="household_address" data-name="户口地址" data-required-formula="true"></a-text>
</a-col>
</a-row>
<a-row>
<a-col>
<a-text key="live_address" data-name="现居住地" data-required-formula="true"></a-text>
</a-col>
</a-row>
<a-row>
<a-col>
<a-text key="urgent_contacts" data-name="紧急联系人姓名" data-required-formula="true"></a-text>
</a-col>
<a-col>
<a-text key="contacts_relation" data-name="与联系人关系" data-required-formula="true"></a-text>
</a-col>
</a-row>
<a-row>
<a-col>
<a-text key="urgent_mobile" data-name="紧急联系人电话" data-required-formula="true"></a-text>
</a-col>
<a-col>
<a-text key="urgent_address" data-name="紧急联系人地址" data-required-formula="true"></a-text>
</a-col>
</a-row>
<a-row>
<a-col>
<a-text key="bankcard_num" data-name="银行卡号" data-required-formula="true" data-regexp="/^[\+\-]?\d*?\.?\d*?$/" data-regexp-text='{"en":"Please enter a number","zh":"请输入正确的银行卡号"}'></a-text>
</a-col>
<a-col>
<a-text key="bank_card_name" data-name="银行名称" data-required-formula="true"></a-text>
</a-col>
</a-row>
<a-row>
<a-col>
<a-text key="sub_branch_name" data-name="支行名称" data-required-formula="true"></a-text>
</a-col>
<a-col>
<a-checkbox key="before_resume" data-name="过往日化行业工作经历" data-options="纳爱斯;蓝月亮;保洁;联合利华;其他"></a-checkbox>
</a-col>
</a-row>
<a-row>
<a-col>
<a-date key="join_company_date" data-name="入职日期" data-required-formula="true" data-verify-formula='{"type":2,"rule":"~","dialogBox":1,"day":1,"lInput":-10,"rInput":10,"prompt":"%E5%85%A5%E8%81%8C%E6%97%A5%E6%9C%9F%E4%B8%BA%E5%BD%93%E5%89%8D%E6%97%A5%E6%9C%9F%E5%89%8D%E5%90%8E10%E5%A4%A9"}'></a-date>
</a-col>
<a-col>
<a-text key="remarks" data-name="备注"></a-text>
</a-col>
</a-row>
<a-row>
<a-col>
<a-image key="bank_card_enclosure" data-name="银行卡附件" data-required-formula="true" data-number="unique"></a-image>
</a-col>
</a-row>
<a-row>
<a-col>
<a-image key="id_card_enclosure" data-name="身份证附件" data-required-formula="true" data-number="batch_min:2_max:2"></a-image>
</a-col>
</a-row>
<a-row>
<a-col>
<a-attachment key="enclosure" data-name="附件"></a-attachment>
</a-col>
</a-row>
</section>

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment-with-locales.min.js"></script>

<script id="customScript">
    (function(form){
/**
* 用户自定义JS区域
*/
function isOnBlackList (params) {
return axios.post('/api/hr/batchSearchLibyUserIsBlack', { params: params })
}
// 用户信息
function getLibyUserInfo (params) {
return axios.post('/api/hr/getLibyUserInfo', params)
}
function getOrgBigareaAndProvince (params) {
return axios.post('/api/hr/getOrgBigareaAndProvince', { params: params })
}
// 省区 入职时间校验
function checkRemainDays (params) {
return axios.get('/api/hr/check_remain_days', {params})
}
// 督导列表
function getListDirect (params) {
return axios.get('/api/hr/list_direct', {params})
}
// 根据身份证获取年龄
function getAge(id_card){
var date = new Date()
var now = {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate()
}
var year = id_card.substring(6,10) * 1
var month = id_card.substring(10,12) * 1
var day = id_card.substring(12,14) * 1
var age = now.year - year
if (now.month > month) {
return age
} else if (now.month < month) {
return age - 1
} else if (now.month === month && now.day >= day) {
return age
} else {
return age - 1
}
}
// 用户信息
function getUserInfo () {
var strUser = sessionStorage.getItem('user')
if(!strUser) {
return false
}
var jsonUser = JSON.parse(strUser)
return jsonUser
}
// 获取性别
function getSexByIdNO(IdNO){
if (IdNO.length==18) {
return IdNO.charAt(16)%2==0?"女":"男";
}else if(IdNO.length==15){
return IdNO.charAt(14)%2==0?"女":"男";
}else{
return "";
}
}
/**
* 事件绑定,form.on
* @param eventType 事件类型
* @params function 事件
* @param cover true, false 是否覆盖root的生命周期 默认不覆盖
*/
//数据加载后,渲染之前,this为window
form.on('onLoad',function(data, dataPermission){
if(data.apply_user) {
return false
}
var jsonUser = getUserInfo()
data.apply_user = jsonUser.name
data.job_number = jsonUser.employeeNo
data.apply_post = jsonUser.dingtalkId
data.supervisor=jsonUser.name
data.supervisor_pernr= jsonUser.employeeNo
},'cover');
//渲染完成后
form.on('onRendered',function(data){
var that = this
// 根据身份证带出年龄
if (this.icnum.value) {
var oldYear = moment(this.icnum.value.substr(6,8)).get('year')
var nowYear = moment(new Date()).format("YYYY")
this.age.value = nowYear - oldYear
console.log( this.age.value, ' this.age.value ')
var sex = getSexByIdNO(this.icnum.value)
console.log(sex, 'sex')
this.sex.value = sex
}
// 身份证带出用户信息
this.icnum.valueChange.subscribe((change)=>{
if (/^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/.test(change.value)) {
var params = {
type: 'icnum',
value: change.value
};
getLibyUserInfo({
type: 'icnum',
value: change.value
})
.then(res => {
if(res.errcode === 0 && res.data.code === '200') {
var jsonData = res.data.data
if(jsonData) {
// 性别
switch(jsonData.sex) {
case 1:
this.sex.value='男'
break;
case 2:
this.sex.value='女'
break;
default:
this.sex.value=''
break;
}
// 年龄
this.age.value = jsonData.age
// 入职人员姓名
this.guide_name.value = jsonData.guideName
this.system_name.value = jsonData.systemName
// 教育程度
this.education.value = jsonData.education
// 工作城市
this.work_city.value = jsonData.workCity
// 现居住地
this.live_address.value = jsonData.liveAddress
// 户口
this.household_address.value = jsonData.householdAddress
// 与联系人关系
this.contacts_relation.value= jsonData.contactsRelation
 
// 城市
this.city.value=jsonData.city
// 星级
switch(jsonData.grade) {
case "1":
this.grade.value='一星'
break;
case "2":
this.grade.value='二星'
break;
case "3":
this.grade.value='三星'
break;
case "4":
this.grade.value='四星'
break;
case "5":
this.grade.value='五星'
break;
default:
this.grade.value='一星'
break;
}
// 导购性质
switch(jsonData.guideNature) {
case "01":
this.guide_nature.value='直营导购员'
break;
case "02":
this.guide_nature.value='经销商导购员'
break;
default:
this.guide_nature.value = ''
break;
}
// 导购类型
that.guide_nature.value = jsonData.guideType
// 紧急联系人
that.urgent_contacts.value = jsonData.urgentMobile
// 紧急联系人地址
that.urgent_address.value= jsonData.urgentAddress
// 手机号
that.mobile.value = jsonData.mobile
// 银行卡号
that.bankcard_num.value = jsonData.bankcardNum
// 银行名
that.bank_card_name.value = jsonData.bankCardName
// 支行名称
that.sub_branch_name.value = jsonData.subBranchName
// 省区名称
that.province_name.value = jsonData.provinceName
// 大区名称
that.org_bigarea_name.value = jsonData.orgBigareaName
// 备注
that.remarks.value = jsonData.remarks
// 入职日期
// that.join_company_date.value = moment(jsonData.joinCompanyDate).format("YYYY-MM-DD");
// 全日制
switch(jsonData.isFullTimeStaff) {
case "1":
that.is_full_time_staff.value = "是"
break;
case "2":
that.is_full_time_staff.value = "否"
break;
default:
that.is_full_time_staff.value = "是"
break;
}
 
}
}else {
// console.log(res, 'res')
that.$message.error(res.data.msg || res.errmsg);
}
})
} else {
this.age.value = null
this.sex.value=null
this.guide_nature.value=null
this.grade.value=null
this.contacts_relation.value=null
this.city.value=null
this.live_address.value=null
this.system_name.value=null
this.education.value=null
}
});
var directList = [] // 督导数据 用于列表切换关联
this.choose_guide_type.valueChange.subscribe((change)=>{
//最新值
var type = change.value.guide_type_name;
var currentUserInfo = getUserInfo();
if(type === '长促') {
that.is_direct.value = '有督导'
that.is_direct.options.readonlyFormula = true // 督导禁用
that.supervisor.options.readonlyFormula = true // 管辖督导不可选
that.supervisor_pernr.value = currentUserInfo.employeeNo //管辖督导为当前用户
that.supervisor.value = currentUserInfo.name // 管辖督导为当前用户
}
if(type === '临促' || type === '冲锋队') {
that.is_direct.options.readonlyFormula = false // 督导不禁用
// 获取省区
var params = [{
userName: currentUserInfo.username
}];
getOrgBigareaAndProvince(params)
.then(res => {
if(res.errcode === 0) {
var dataResults = res.data[0];
this.province_name.items = dataResults.orgProvinceNameList;
this.province_name.value = dataResults.orgProvinceNameList[0];
this.org_bigarea_name.items = dataResults.orgBigareaNameList;
this.org_bigarea_name.value = dataResults.orgBigareaNameList[0];
var param = {
regionName: this.org_bigarea_name.value,
provinceName: this.province_name.value
}
var datas = []
var supervisor = []
// 获取管辖督导
getListDirect(param)
.then(res => {
if (res.errcode === 0) {
datas = res.data
datas.forEach(item => {
supervisor.push(item.name)
})
console.log(that.supervisor, ' that.supervisor')
that.supervisor.value = supervisor[0] // 默认选第一个
that.supervisor.options.readonlyFormula = false // 管辖督导可选
that.supervisor.edit = true
that.supervisor.items = supervisor
directList = datas
}
})
} else {
this.$message.error('获取省区失败');
}
})
.catch(err => {
this.$message.error('获取省区失败');
})
} else {
this.province_name.items = [];
this.org_bigarea_name.items = [];
this.province_name.value = '';
this.org_bigarea_name.value = '';
}
});
// 区切换
that.supervisor.valueChange.subscribe((change)=>{
// console.log(change, 'change')
directList.forEach(item => {
if (change.value === item.name) {
that.supervisor_pernr.value = item.code
}
})
});
// 手机号查询校验
that.mobile.valueChange.subscribe((change)=>{
if (/^1[3|4|5|6|7|8|9][0-9]{9}$/.test(change.value)) {
var params = {
type: 'mobile',
value: change.value
}
getLibyUserInfo(params)
.then(res => {
if (res.errcode !== 0) {
that.$message.error(res.errmsg)
} else {
that.$message.success(res.errmsg)
}
})
.catch(err => {
that.$message.error(err.errmsg)
})
}
});
// 大区 省区 入职校验
function checkRemain (params) {
checkRemainDays(params)
.then(res => {
if (res.errcode !== 0) {
that.$message.error(res.errmsg)
}else {
that.$message.success(res.errmsg)
}
})
.catch(err => {
that.$message.error(err.errmsg)
})
};
// 大区切换
this.org_bigarea_name.valueChange.subscribe((change)=>{
if(change.value && that.join_company_date.value && that.province_name.value ) {
var date = moment(that.join_company_date.value).startOf("month").format("YYYY-MM-DD");
var params = {
regionName: change.value,
provinceName: that.province_name.value,
entryDate: date
};
checkRemain(params)
}
});
// 入职日期
this.join_company_date.valueChange.subscribe((change)=>{
if(change.value && that.org_bigarea_name.value && that.province_name.value ) {
var date = moment(change.value).startOf("month").format("YYYY-MM-DD");
var params = {
regionName: that.org_bigarea_name.value,
provinceName: that.province_name.value,
entryDate: date
}
checkRemain(params)
}
});
// 省区
this.province_name.valueChange.subscribe((change)=>{
if(change.value && that.org_bigarea_name.value && that.join_company_date.value ) {
var date = moment(that.join_company_date.value).startOf("month").format("YYYY-MM-DD");
var params = {
regionName: that.org_bigarea_name.value,
provinceName: change.value,
entryDate: date
}
checkRemain(params)
}
});
});
//内置校验完成后,返回false阻止提交
form.on('onValidate',function(action,data){});
//操作前(包含自定义按钮)执行,返回false阻止按钮操作
form.on('onPreAction',function(action,data){
if(action.code === 'submit') {
var params = [{
mobile: data.mobile,
icnum: data.icnum
}]
var _this = this
return isOnBlackList(params).then(function(res){
if(res.errcode === 0 && res.data && res.data.length === 0){
 
} else if(res.errcode === 0 && res.data && res.data.length > 0) {
_this.$message.error(res.data[0].msg)
return false
} else {
_this.$message.error(res.errmsg)
return false
}
})
}
});
//自定义按钮执行
form.on('onCustomAction',function(action,data){});
//操作完成后执行
form.on('onActionDone',function(action,data,httpRes){});
})
</script>
posted @ 2020-04-29 18:03  菜鸟木易  阅读(704)  评论(0编辑  收藏  举报