You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
173 lines
7.6 KiB
173 lines
7.6 KiB
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
{include file="public/head"}
|
|
<title>{$title|default=''}</title>
|
|
<script src="{__PLUG_PATH}jquery-1.10.2.min.js"></script>
|
|
<script src="{__PLUG_PATH}reg-verify.js"></script>
|
|
<script src="{__PLUG_PATH}city.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="form-add" class="mp-form" v-cloak>
|
|
<i-Form :model="formData" :rules="ruleValidate" :label-width="80">
|
|
<Form-Item label="代理名称">
|
|
<i-input v-model="formData.lecturer_name" placeholder="请输入代理名称"></i-input>
|
|
</Form-Item>
|
|
<Form-Item label="负责人" prop="username">
|
|
<i-input v-model="formData.username" placeholder="请输入负责人"></i-input>
|
|
</Form-Item>
|
|
<Form-Item label="联系电话" prop="phone">
|
|
<i-input v-model="formData.phone" placeholder="请输入联系电话"></i-input>
|
|
</Form-Item>
|
|
<Form-Item label="专题分成[5=5%]">
|
|
<i-input v-model="formData.mer_special_divide" placeholder="请输入专题分成[5=5%]"></i-input>
|
|
</Form-Item>
|
|
<Form-Item label="商品分成[5=5%]">
|
|
<i-input v-model="formData.mer_store_divide" placeholder="请输入商品分成[5=5%]"></i-input>
|
|
</Form-Item>
|
|
<Form-Item label="活动分成[5=5%]">
|
|
<i-input v-model="formData.mer_event_divide" placeholder="请输入活动分成[5=5%]"></i-input>
|
|
</Form-Item>
|
|
<Form-Item label="资料分成[5=5%]">
|
|
<i-input v-model="formData.mer_data_divide" placeholder="请输入资料分成[5=5%]"></i-input>
|
|
</Form-Item>
|
|
<Form-Item label="试卷分成[5=5%]">
|
|
<i-input v-model="formData.mer_test_divide" placeholder="请输入试卷分成[5=5%]"></i-input>
|
|
</Form-Item>
|
|
<Form-Item label="直播收益分成[5=5%]">
|
|
<i-input v-model="formData.gold_divide" placeholder="请输入直播收益分成[5=5%]"></i-input>
|
|
</Form-Item>
|
|
<Form-Item label="联系地址">
|
|
<i-input v-model="formData.mer_address" placeholder="请输入联系地址"></i-input>
|
|
</Form-Item>
|
|
<Form-Item label="备注">
|
|
<i-input type="textarea" v-model="formData.mark" placeholder="请输入备注"></i-input>
|
|
</Form-Item>
|
|
|
|
<Form-Item label="状态">
|
|
<Radio-Group v-model="formData.status">
|
|
<Radio :label="1">开启</Radio>
|
|
<Radio :label="0">关闭</Radio>
|
|
</Radio-Group>
|
|
</Form-Item>
|
|
<Form-Item label="可用权限" prop="checked_menus">
|
|
<Tree :data="menus" show-checkbox ref="tree"></Tree>
|
|
</Form-Item>
|
|
<Form-Item :class="'add-submit-item'">
|
|
<i-Button :type="'primary'" :html-type="'submit'" :size="'large'" :long="true" :loading="loading" @click.prevent="submit">提交</i-Button>
|
|
</Form-Item>
|
|
</i-Form>
|
|
</div>
|
|
<script>
|
|
$eb = parent._mpApi;
|
|
var role = <?php echo $roles; ?> || {};
|
|
var menus = <?php echo $menus; ?> || [];
|
|
mpFrame.start(function(Vue){
|
|
new Vue({
|
|
el:'#form-add',
|
|
data:{
|
|
formData:{
|
|
mer_special_divide:role.mer_special_divide || 0,
|
|
mer_store_divide:role.mer_store_divide,
|
|
mer_event_divide:role.mer_event_divide,
|
|
mer_data_divide:role.mer_data_divide,
|
|
mer_test_divide:role.mer_test_divide,
|
|
gold_divide:role.gold_divide,
|
|
username:role.username || '',
|
|
lecturer_name:role.lecturer_name,
|
|
phone:role.phone,
|
|
real_name:role.real_name || '',
|
|
mer_address:role.mer_address || '',
|
|
mark:role.mark || '',
|
|
status:role.status || 0,
|
|
checked_menus:role.rules,
|
|
id:role.id
|
|
},
|
|
menus:[],
|
|
loading:false,
|
|
ruleValidate: {
|
|
username: [
|
|
{ required: true, message: '请输入负责人', trigger: 'blur' }
|
|
],
|
|
phone: [
|
|
{ required: true, message: '请输入联系电话', trigger: 'blur' }
|
|
],
|
|
checked_menus: [
|
|
{ required: true, message: '至少选择一项权限', trigger: 'blur' }
|
|
]
|
|
}
|
|
},
|
|
methods:{
|
|
selectEnd:function (value,selectedData) {
|
|
var t= this;
|
|
t.formData.cityName = '';
|
|
$.each(selectedData,function (index,item) {
|
|
if(!t.formData.cityName)
|
|
t.formData.cityName = item.label;
|
|
else
|
|
t.formData.cityName = t.formData.cityName +","+item.label;
|
|
})
|
|
},
|
|
tidyRes:function(){
|
|
var data = [];
|
|
menus.map((menu)=>{
|
|
data.push(this.initMenu(menu));
|
|
});
|
|
this.$set(this,'menus',data);
|
|
},
|
|
initMenu:function(menu){
|
|
var data = {},checkMenus = ','+this.formData.checked_menus+',';
|
|
data.title = menu.menu_name;
|
|
data.id = menu.id;
|
|
if(menu.child && menu.child.length >0){
|
|
data.children = [];
|
|
menu.child.map((child)=>{
|
|
data.children.push(this.initMenu(child));
|
|
})
|
|
}else{
|
|
data.checked = checkMenus.indexOf(String(','+data.id+',')) !== -1;
|
|
data.expand = !data.checked;
|
|
}
|
|
return data;
|
|
},
|
|
submit:function(){
|
|
this.formData.checked_menus = [];
|
|
this.$refs.tree.getCheckedNodes().map((node)=>{
|
|
this.formData.checked_menus.push(node.id);
|
|
});
|
|
if(!this.formData.username){
|
|
return layer.msg('请输入负责人');
|
|
}
|
|
if(this.formData.phone){
|
|
if(!$reg.isPhone(this.formData.phone)){
|
|
return $eb.message('error','请输入正确的手机号');
|
|
}
|
|
}else{
|
|
return $eb.message('error','请输入手机号');
|
|
}
|
|
if(!this.formData.checked_menus.length){
|
|
return $eb.message('error','请至少选择一项权限');
|
|
}
|
|
this.loading = true;
|
|
$eb.axios.post("{$action}",this.formData).then((res)=>{
|
|
if(res.status && res.data.code == 200)
|
|
return Promise.resolve(res.data);
|
|
else
|
|
return Promise.reject(res.data.msg || '添加失败,请稍候再试!');
|
|
}).then((res)=>{
|
|
$eb.message('success',res.msg || '操作成功!');
|
|
$eb.closeModalFrame(window.name);
|
|
}).catch((err)=>{
|
|
this.loading=false;
|
|
$eb.message('error',err);
|
|
});
|
|
}
|
|
},
|
|
mounted:function(){
|
|
t = this;
|
|
this.tidyRes();
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
|