master
lion 1 year ago
parent a14f0a1a88
commit dd523602ea

@ -2,5 +2,5 @@
ENV = 'production'
# base api
VUE_APP_BASE_API = https://suzhoukeji-test.ali251.langye.net
VUE_APP_UPLOAD_API = https://suzhoukeji-test.ali251.langye.net/api/admin/upload-file
VUE_APP_BASE_API = https://wx.sstbc.com
VUE_APP_UPLOAD_API = https://wx.sstbc.com/api/admin/upload-file

@ -55,8 +55,8 @@ export default {
Watermark.set(this.username, this.$refs.containerS);
}
}
}
, created() {
},
created() {
this.$nextTick(function () {
this.loadUser()

@ -1,4 +1,6 @@
import {getparameter} from "@/api/system/dictionary.js"
import {
getparameter
} from "@/api/system/dictionary.js"
export default {
data() {
return {
@ -8,65 +10,132 @@ export default {
field: 'username',
rule: 'required',
edit_input: "text",
help: '请输入姓名'
help: '请输入姓名',
need_fill: 0,
belong_user: 1,
belong_user_table: 'username'
}, {
name: '性别',
field: 'sex',
rule: 'required',
edit_input: "text",
help: '请选择性别'
},{
edit_input: "radio",
help: '请选择性别',
select_item: [{
key: '男',
value: '男'
}, {
key: '女',
value: '女'
}],
need_fill: 0,
belong_user: 1,
belong_user_table: 'sex'
}, {
name: '出生日期',
field: 'birthday',
rule: '',
edit_input: "date",
help: '请选择出生日期',
need_fill: 0,
belong_user: 1,
belong_user_table: 'birthday'
}, {
name: '联系方式',
field: 'mobile',
rule: 'required',
edit_input: "text",
help: '请输入联系方式'
help: '请输入联系方式',
need_fill: 0,
belong_user: 1,
belong_user_table: 'mobile'
}, {
name: '出生日期',
field: 'birthday',
rule: '',
name: '身份证号',
field: 'idcard',
rule: 'idcard',
edit_input: "text",
help: '请选择出生日期'
help: '请输入身份证号',
need_fill: 0,
belong_user: 1,
select_item: [],
is_open: false,
belong_user_table: 'idcard'
}, {
name: '邮箱',
field: 'email',
name: '学历',
field: 'education',
rule: '',
edit_input: "text",
help: '请输入邮箱'
edit_input: "radio",
help: '请选择学历',
need_fill: 0,
belong_user: 1,
select_item: [],
is_open: false,
belong_user_table: 'education'
}, {
name: '公司名称',
field: 'company_name',
rule: '',
edit_input: "text",
help: '请输入公司名称'
help: '请输入公司名称',
need_fill: 0,
belong_user: 1,
belong_user_table: 'company_name'
}, {
name: '职务',
field: 'company_position',
rule: '',
edit_input: "text",
help: '请选择职务'
}],
// 自定义表单的 扩展字段 可填可不填
selectFormList: [ {
name: '身份证号',
field: 'idcard',
rule: 'idcard',
edit_input: "text",
help: '请输入身份证号',
need_fill: 0,
belong_user: 1,
select_item: [],
help: '请输入职务',
need_fill: 0,
belong_user: 1,
belong_user_table: 'company_position'
}, {
name: '有无股份',
field: 'company_has_share',
rule: '',
edit_input: "radio",
help: '请选择有无股份',
need_fill: 0,
belong_user: 1,
select_item: [{
key: '有',
value: '有'
}, {
key: '无',
value: '无'
}],
is_open: false,
belong_user_table: 'company_has_share'
}, {
name: '人才类型',
field: 'type',
rule: '',
edit_input: "radio",
help: '请选择人才类型',
need_fill: 0,
belong_user: 1,
select_item: [],
is_open: false,
belong_user_table: 'type'
}, {
name: '企业性质',
field: 'company_type',
rule: '',
edit_input: "radio",
edit_input: "checkbox",
help: '请选择企业性质',
need_fill: 0,
belong_user: 1,
select_item: [],
is_open: false, // 控制开启关闭的 参数不做保存
belong_user_table: 'company_type'
}, {
name: '融资情况',
field: 'company_fund',
rule: '',
edit_input: "text",
help: '请输入融资情况',
need_fill: 0,
belong_user: 1,
belong_user_table: 'company_fund'
}, {
name: '所在区域',
field: 'company_area',
@ -76,7 +145,19 @@ export default {
need_fill: 0,
belong_user: 1,
select_item: [],
is_open: false
is_open: false,
belong_user_table: 'company_area'
}, {
name: '公司地址',
field: 'company_address',
rule: '',
edit_input: "text",
help: '请填写公司地址',
need_fill: 0,
belong_user: 1,
select_item: [],
is_open: false,
belong_user_table: 'company_address'
}, {
name: '所属行业',
field: 'company_industry',
@ -86,17 +167,123 @@ export default {
need_fill: 0,
belong_user: 1,
select_item: [],
is_open: false
is_open: false,
belong_user_table: 'company_industry'
}, {
name: '人才类型',
field: 'type',
name: '产品',
field: 'company_product',
rule: '',
edit_input: "text",
help: '请输入产品',
need_fill: 0,
belong_user: 1,
belong_user_table: 'company_product'
}, {
name: '毕业院校',
field: 'school',
rule: '',
edit_input: "text",
help: '请输入产品',
need_fill: 0,
belong_user: 1,
belong_user_table: 'school'
}, {
name: '专业',
field: 'speciality',
rule: '',
edit_input: "text",
help: '请输入专业',
need_fill: 0,
belong_user: 1,
belong_user_table: 'speciality'
}, {
name: '海外经验',
field: 'overseas_experience',
rule: '',
edit_input: "text",
help: '请输入海外经验',
need_fill: 0,
belong_user: 1,
belong_user_table: 'overseas_experience'
}, {
name: '报名渠道',
field: 'sign_from',
rule: '',
edit_input: "radio",
help: '请选择人才类型',
help: '请选择报名渠道',
need_fill: 0,
belong_user: 1,
belong_user_table: 'sign_from'
}, {
name: '邮箱',
field: 'email',
rule: '',
edit_input: "text",
help: '请输入邮箱',
need_fill: 0,
belong_user: 1,
belong_user_table: 'email'
}],
// 自定义表单的 扩展字段 可填可不填
selectFormList: [{
name: '姓名',
field: 'username',
rule: 'required',
edit_input: "text",
help: '请输入姓名',
need_fill: 0,
belong_user: 1,
belong_user_table: 'username',
sort: 0,
}, {
name: '性别',
field: 'sex',
rule: 'required',
edit_input: "radio",
help: '请选择性别',
select_item: [{
key: '男',
value: '男'
}, {
key: '女',
value: '女'
}],
need_fill: 0,
belong_user: 1,
belong_user_table: 'sex',
sort: 0,
}, {
name: '出生日期',
field: 'birthday',
rule: '',
edit_input: "date",
help: '请选择出生日期',
need_fill: 0,
belong_user: 1,
belong_user_table: 'birthday',
sort: 0,
}, {
name: '联系方式',
field: 'mobile',
rule: 'required',
edit_input: "text",
help: '请输入联系方式',
need_fill: 0,
belong_user: 1,
belong_user_table: 'mobile',
sort: 0,
}, {
name: '身份证号',
field: 'idcard',
rule: 'idcard',
edit_input: "text",
help: '请输入身份证号',
need_fill: 0,
belong_user: 1,
select_item: [],
is_open: false
is_open: false,
belong_user_table: 'idcard',
sort: 0,
}, {
name: '学历',
field: 'education',
@ -106,53 +293,226 @@ export default {
need_fill: 0,
belong_user: 1,
select_item: [],
is_open: false
}],
formSelect:{
company_position:[],
company_type:[],
company_area:[],
company_industry:[],
type:[],
education:[]
},
is_open: false,
belong_user_table: 'education',
sort: 0,
}, {
name: '公司名称',
field: 'company_name',
rule: '',
edit_input: "text",
help: '请输入公司名称',
need_fill: 0,
belong_user: 1,
belong_user_table: 'company_name',
sort: 0,
}, {
name: '职务',
field: 'company_position',
rule: '',
edit_input: "text",
help: '请输入职务',
need_fill: 0,
belong_user: 1,
belong_user_table: 'company_position',
sort: 0,
}, {
name: '有无股份',
field: 'company_has_share',
rule: '',
edit_input: "radio",
help: '请选择有无股份',
need_fill: 0,
belong_user: 1,
select_item: [{
key: '有',
value: '有'
}, {
key: '无',
value: '无'
}],
is_open: false,
belong_user_table: 'company_has_share',
sort: 0,
}, {
name: '人才类型',
field: 'type',
rule: '',
edit_input: "radio",
help: '请选择人才类型',
need_fill: 0,
belong_user: 1,
select_item: [],
is_open: false,
belong_user_table: 'type',
sort: 0,
}, {
name: '企业性质',
field: 'company_type',
rule: '',
edit_input: "checkbox",
help: '请选择企业性质',
need_fill: 0,
belong_user: 1,
select_item: [],
is_open: false, // 控制开启关闭的 参数不做保存
belong_user_table: 'company_type',
sort: 0,
}, {
name: '融资情况',
field: 'company_fund',
rule: '',
edit_input: "text",
help: '请输入融资情况',
need_fill: 0,
belong_user: 1,
belong_user_table: 'company_fund',
sort: 0,
}, {
name: '所在区域',
field: 'company_area',
rule: '',
edit_input: "radio",
help: '请选择所在区域',
need_fill: 0,
belong_user: 1,
select_item: [],
is_open: false,
belong_user_table: 'company_area',
sort: 0,
}, {
name: '公司地址',
field: 'company_address',
rule: '',
edit_input: "text",
help: '请填写公司地址',
need_fill: 0,
belong_user: 1,
is_open: false,
belong_user_table: 'company_address',
sort: 0,
}, {
name: '所属行业',
field: 'company_industry',
rule: '',
edit_input: "radio",
help: '请选择所属行业',
need_fill: 0,
belong_user: 1,
select_item: [],
is_open: false,
belong_user_table: 'company_industry',
sort: 0,
}, {
name: '产品',
field: 'company_product',
rule: '',
edit_input: "text",
help: '请输入产品',
need_fill: 0,
belong_user: 1,
belong_user_table: 'company_product',
sort: 0,
}, {
name: '毕业院校',
field: 'school',
rule: '',
edit_input: "text",
help: '请输入产品',
need_fill: 0,
belong_user: 1,
belong_user_table: 'school',
sort: 0,
}, {
name: '专业',
field: 'speciality',
rule: '',
edit_input: "text",
help: '请输入专业',
need_fill: 0,
belong_user: 1,
belong_user_table: 'speciality',
sort: 0,
}, {
name: '海外经验',
field: 'overseas_experience',
rule: '',
edit_input: "text",
help: '请输入海外经验',
need_fill: 0,
belong_user: 1,
belong_user_table: 'overseas_experience',
sort: 0,
}, {
name: '报名渠道',
field: 'sign_from',
rule: '',
edit_input: "radio",
help: '请选择报名渠道',
need_fill: 0,
select_item: [],
belong_user: 1,
belong_user_table: 'sign_from',
sort: 0,
}, {
name: '邮箱',
field: 'email',
rule: '',
edit_input: "text",
help: '请输入邮箱',
need_fill: 0,
belong_user: 1,
belong_user_table: 'email',
sort: 0,
}],
formSelect: {
// company_position: [],
company_type: [],
company_area: [],
company_industry: [],
type: [],
education: [],
sign_from: []
},
}
},
computed: {},
created() {
this.getAllPara()
created() {
this.getAllPara()
},
mounted() {},
methods: {
getAllPara(){
let number = ['company_position','company_type','company_area','company_industry','type','education']
getparameter({
number:number
}).then(res=>{
// 获取数据字典插入到 select中
res.map(item=>{
for(var k in this.formSelect){
if(item.number===k){
this.formSelect[k] = item.detail
}
}
})
// 数据插入到 selectFormList 的select_item中{key:'',value:''}
this.selectFormList.map(sform=>{
for(var k in this.formSelect){
if(sform.field===k){
this.formSelect[k].map(kf=>{
sform.select_item.push({
key:kf.value,
value:kf.value
})
})
}
}
})
console.log("this.selectFormList123",this.selectFormList)
})
getAllPara() {
let number = ['company_type', 'company_area', 'company_industry', 'type', 'education',
'sign_from'
]
getparameter({
number: number
}).then(res => {
// 获取数据字典插入到 select中
res.map(item => {
for (var k in this.formSelect) {
if (item.number === k) {
this.formSelect[k] = item.detail
}
}
})
// 数据插入到 selectFormList 的select_item中{key:'',value:''}
this.selectFormList.map(sform => {
for (var k in this.formSelect) {
if (sform.field === k) {
this.formSelect[k].map(kf => {
sform.select_item.push({
key: kf.value,
value: kf.value
})
})
}
}
})
console.log("this.selectFormList123", this.selectFormList)
})
}
},
};

@ -126,6 +126,32 @@
</el-radio-group>
</div>
</div>
</template>
<template v-slot:show_txl v-if="active===0">
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>是否显示通讯录
</div>
<div class="xy-table-item-content">
<el-radio-group style="width:100%" v-model="form.show_txl">
<el-radio :label="1"></el-radio>
<el-radio :label="0"></el-radio>
</el-radio-group>
</div>
</div>
</template>
<template v-slot:show_mobile v-if="active===0">
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>是否显示联系方式
</div>
<div class="xy-table-item-content">
<el-radio-group style="width:100%" v-model="form.show_mobile">
<el-radio :label="1"></el-radio>
<el-radio :label="0"></el-radio>
</el-radio-group>
</div>
</div>
</template>
<template v-slot:qun_image_id v-if="active===0 && form.is_fee===0">
<div class="xy-table-item">
@ -279,7 +305,9 @@
status: 0,
is_arrange: 1,
is_fee: 1,
is_fee: 1,
show_txl:1,
show_mobile:0,
qun_image_id: '',
image_id: '',
publicize_ids: [],
@ -436,7 +464,8 @@
}).then(res => {
this.$message({
type: 'success',
message: '保存课程成功'
message: '保存课程成功',
duration:2000
})
this.id = res.id
this.$emit('refresh')
@ -466,7 +495,9 @@
this.form.dateRange = res.start_date ? [res.start_date, res.end_date] : ''
this.form.status = res.status ? res.status : 0
this.form.is_arrange = res.is_arrange ? res.is_arrange : 0
this.form.is_fee = res.is_fee ? res.is_fee : 0
this.form.is_fee = res.is_fee ? res.is_fee : 0
this.form.show_txl = res.show_txl===0 ? 0 : 1
this.form.show_mobile = res.show_mobile ? res.show_mobile : 0
this.showTinymce = true
})
},
@ -526,7 +557,9 @@
sign_end_date: '',
status: 0,
is_arrange: 1,
is_fee: 1,
is_fee: 1,
show_txl:1,
show_mobile:1,
qun_image_id: '',
image_id: '',
publicize_ids: [],
@ -552,7 +585,9 @@
::v-deep .status,
::v-deep .is_arrange,
::v-deep .is_fee,
::v-deep .is_fee,
::v-deep .show_txl,
::v-deep .show_mobile,
{
flex-basis: 33%;
}

@ -1,15 +1,15 @@
<template>
<div>
<el-dialog title="创建报名表单" :show-close="false" :visible.sync="dialogVisible" :fullscreen="true" :modal='false'>
<template v-slot:title>
<div style="display: flex;align-items: center;justify-content: space-between;font-size: 26px;">
<div>创建报名表单</div>
<div style="cursor: pointer;">
<Button type="primary" @click="dialogVisible = false">完成并关闭</Button>
</div>
</div>
</template>
<template v-slot:title>
<div style="display: flex;align-items: center;justify-content: space-between;font-size: 26px;">
<div>创建报名表单</div>
<div style="cursor: pointer;">
<Button type="primary" @click="dialogVisible = false">完成并关闭</Button>
</div>
</div>
</template>
<div style="height: 100%">
<Split v-model="splitL" :min="0.05">
<template #left>
@ -23,40 +23,39 @@
<Split v-model="splitR" :min="0.2">
<template #left>
<div style="height: 100%">
<el-dialog id="template-dialog" :title="'模板表单'"
:show-close="false"
<el-dialog id="template-dialog" :title="'模板表单'" :show-close="false"
style="position: relative; inset: 0 0 0 0; height: 100%" width="80%" top="40px" :visible="true"
:modal="false" :append-to-body="false" :modal-append-to-body="false">
:modal="false" :append-to-body="false" :modal-append-to-body="false">
<el-form style="min-height: 200px;display: flex;flex-wrap: wrap;" label-width="80px"
label-position="right" size="small">
<el-divider>基础字段</el-divider>
<el-form-item :label="i.name" :required="
<el-divider>表单字段</el-divider>
<!-- <el-form-item :label="i.name" :required="
i.rule ? !!i.rule.includes('required') : false
" v-for="(i, index) in defaultFormList">
<el-input :placeholder="i.help?i.help:'基础字段'" :disabled="true"></el-input>
</el-form-item>
<el-divider>选填字段</el-divider>
<el-form-item :label="i.name" :required="
<el-input :placeholder="i.help?i.help:'表单字段'" :disabled="true"></el-input>
</el-form-item> -->
<draggable :value="formList" group="items" @change="changeHandler"
style="display: flex;flex-wrap: wrap;width:100%">
<el-form-item style="flex-basis: 100%;" :label="i.name || '字段名称'" :required="
i.rule ? !!i.rule.includes('required') : false
" v-for="(i, index) in formList" @click.native="selectPick(i, index)">
<formSlotRender :config="i" :index="index"></formSlotRender>
</el-form-item>
</draggable>
<!-- <el-divider>选填字段</el-divider> -->
<!-- <el-form-item style="flex-basis: 100%;" :label="i.name" :required="
i.rule ? !!i.rule.includes('required') : false
" v-for="(i, index) in selectFormList">
<el-input style="width:60%;margin-right:10px" :placeholder="i.help?i.help:'选填字段'" :disabled="true"></el-input>
" v-for="(i, index) in selectFormList"
@click.native="selectPick(i, index)">
<el-input style="width:100%;" :placeholder="i.help?i.help:'表单字段'"></el-input>
<el-switch @change="(e)=>{changeSelect(e,i)}" v-model="i.is_open" active-color="#0077CC"
inactive-color="#ccc">
</el-switch>
</el-form-item>
</el-form-item> -->
<!-- <el-divider>自定义字段</el-divider> -->
<el-divider>自定义字段</el-divider>
<draggable :value="formList" group="items" @change="changeHandler"
style="display: flex;flex-wrap: wrap;width:100%">
<el-form-item style="flex-basis: 100%;" :label="i.name || '字段名称'" :required="
i.rule ? !!i.rule.includes('required') : false
" v-for="(i, index) in formList" @click.native="selectPick(i, index)">
<formSlotRender :config="i" :index="index"></formSlotRender>
</el-form-item>
</draggable>
</el-form>
<div slot="footer">
@ -136,6 +135,7 @@
this.types = edit_to_migration.filter(item => item.edit_input !== 'textarea' && item.edit_input !==
"richtext" &&
item.edit_input !== "file" && item.edit_input !== "map");
},
//
async getFormList() {
@ -147,9 +147,12 @@
}],
...this.select
})
this.formList = res.data
this.updateObjects(this.selectFormList, this.formList)
this.formList = res.data
// this.updateObjects(this.selectFormList, this.formList)
// let _arr = this.removeMatchingItems(this.selectFormList, this.formList)
// this.formList.push(..._arr)
// this.selectFormList = _arr
console.log("_arr",_arr)
console.log("this.selectFormList", this.selectFormList, this.formList)
},
@ -161,7 +164,7 @@
if (match) {
// a
Object.assign(match, objB);
Object.assign(match, objB);
match.is_open = true
return false; //
} else {
@ -173,6 +176,13 @@
b.length = 0; //
b.push(...updatedB); //
},
removeMatchingItems(a, b) {
// Set b filed
const bFiledValues = new Set(b.map(item => item.field));
// 使 filter a
return a.filter(item => !bFiledValues.has(item.field));
},
//
changeHandler(e) {
if (e.added) {
@ -201,11 +211,17 @@
newIndex,
oldIndex
} = e.moved;
element.sort = newIndex;
if (element) {
this.formList.splice(oldIndex, 1);
this.formList.splice(newIndex, 0, element);
element.sort = newIndex;
console.log(element)
if(element.id){
this.saveSelect(element)
}else{
this.formList.splice(oldIndex, 1);
this.formList.splice(newIndex, 0, element);
}
// if (element) {
// }
}
},
@ -261,15 +277,15 @@
if (newval) {
this.getFormList()
} else {
this.course_id = ''
this.selectFormList.map(item=>{
item.is_open = false
if(item.id){
item.id = ''
}
if(item.course_id){
item.course_id = ''
}
this.course_id = ''
this.selectFormList.map(item => {
item.is_open = false
if (item.id) {
item.id = ''
}
if (item.course_id) {
item.course_id = ''
}
})
this.$emit("refresh")
}

@ -1,278 +1,250 @@
<template>
<div style="padding: 0 10px; height: 100%; overflow: scroll">
<template v-if="showForm">
<el-form
:rules="formRule"
ref="form"
:model="selectedForm"
label-width="80px"
>
<el-form-item prop="name" label="字段名称">
<el-input
v-model="selectedForm.name"
placeholder="请输入字段名称"
@input="inputHandler"
></el-input>
</el-form-item>
<el-form-item required prop="field" label="字段标识">
<el-input v-model="selectedForm.field"></el-input>
</el-form-item>
<el-form-item prop="help" label="帮助文字">
<el-input
v-model="selectedForm.help"
placeholder="请输入帮助文字"
></el-input>
</el-form-item>
<el-form-item prop="sort" label="排序">
<el-input
v-model="selectedForm.sort"
placeholder="请输入排序"
></el-input>
</el-form-item>
<el-form-item prop="select_item" label="下拉框选项"
v-if="selectedForm.edit_input==='radio' || selectedForm.edit_input==='checkbox'">
<div class="select-item">
<div class="select-item__header">
<span></span>
<span></span>
</div>
<div class="select-item__body" v-for="(i, index) in selectItem">
<div><el-input v-model="i.key" size="mini"></el-input></div>
<div><el-input v-model="i.value" size="mini"></el-input></div>
<div>
<el-button
type="danger"
size="mini"
circle
icon="el-icon-delete"
@click="selectItem.splice(index, 1)"
></el-button>
</div>
</div>
<el-button
type="primary"
size="mini"
circle
icon="el-icon-plus"
@click="selectItem.push({ key: '', value: '' })"
></el-button>
</div>
</el-form-item>
<el-form-item prop="validation" label="校验规则">
<el-select
v-model="validation"
clearable
multiple
collapse-tags
:popper-append-to-body="false"
placeholder="请选择校验规则"
style="width: 100%"
>
<el-option
v-for="(value, key) in rules"
:key="key"
:label="value"
:value="key"
></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="saveField"></el-button>
<el-popover
trigger="hover"
ref="el-popover"
placement="top"
width="160"
>
<p>确定删除字段吗</p>
<div style="text-align: right; margin: 0">
<el-button
size="mini"
type="text"
@click="$refs['el-popover'].doClose()"
>取消</el-button
>
<el-button
type="primary"
size="mini"
@click="destroyField"
>确定</el-button
>
</div>
<el-button
type="danger"
slot="reference"
@click="$refs['el-popover'].doShow()"
style="margin-left: 10px"
>删除</el-button
>
</el-popover>
</el-form-item>
</el-form>
</template>
<template v-else>
<el-empty
style="position: relative; top: 50%; transform: translateY(-50%)"
description="暂无选择"
></el-empty>
</template>
</div>
</template>
<script>
import { save,destroy } from "@/api/course/form";
import { translate } from "@/api/system/customFormField";
import { debounce } from "@/utils";
export default {
props: {
rules: Object,
types: Array,
},
data() {
return {
showForm:false,
debouncedInputHandler: null,
formRule: {
name: [
{ required: true, message: "请输入字段名称" }
],
field: [
{ required: true, message: "请输入字段标识" }
],
},
selectedForm:{}, // item
selectedIndex:0, // item index
selectItem: [], //
validation:[], //
parameters: [], //
forms: [], //
};
},
methods: {
checkChinese(rule, value, callback) {
const reg = /^[\u4e00-\u9fa5]+$/;
if (reg.test(value)) {
callback();
} else {
callback(new Error("请输入中文姓名"));
}
},
inputHandler(e) {
this.debouncedInputHandler(e);
},
saveField() {
this.selectedForm.select_item = []
this.selectedForm.select_item = this.selectItem
this.selectedForm.rule = this.validation.join(",")
if(this.selectedForm.edit_input==='radio' || this.selectedForm.edit_input==='checkbox'){
if(this.selectedForm.select_item.length===0){
this.$Message.warning("请输入下拉框选项")
return
}
}
// return
save(this.selectedForm).then(res=>{
console.log("res",res)
this.$Message.success('保存成功')
this.$emit("refreshFormItem",'save')
this.showForm = false
})
},
destroyField () {
if(this.selectedForm.id){
destroy({
id:this.selectedForm.id
}).then(res=>{
this.$Message.success('删除成功')
this.showForm = false
this.$emit("refreshFormItem",'DelId',this.selectedIndex)
})
}else{
this.$Message.success('删除成功')
this.showForm = false
this.$emit("refreshFormItem",'Del',this.selectedIndex)
}
}
},
watch: {
selectedForm(newVal) {
console.log("newval",newVal)
if(newVal) {
if(newVal.select_item) {
this.selectItem = [];
this.selectItem = newVal.select_item
// for(let key in newVal.select_item) {
// this.selectItem.push({
// key,
// value: newVal.select_item[key]
// })
// }
}
this.validation = []
if(newVal.rule){
this.validation = newVal.rule.split(',')
}
}
}
},
created() {
this.debouncedInputHandler = debounce((e) => {
if (e) {
this.checkChinese("", e, (err) => {
if (!err) {
translate({
str: e,
}).then((en) => {
this.selectedForm.field = en.pinyin;
});
}
});
}
}, 1000);
},
};
</script>
<style scoped lang="scss">
::v-deep .el-input-number.is-without-controls .el-input__inner {
text-align: left;
}
.select-item {
text-align: center;
&__header {
font-weight: 600;
display: flex;
& > span {
flex-basis: 30%;
& + span {
margin-left: 10px;
}
}
}
&__body {
display: flex;
& > div {
flex-basis: 30%;
& + div {
margin-left: 10px;
}
}
}
}
<template>
<div style="padding: 0 10px; height: 100%; overflow: scroll">
<template v-if="showForm">
<el-form :rules="formRule" ref="form" :model="selectedForm" label-width="80px">
<el-form-item prop="belong_user_table" label="更新学员字段">
<el-select v-model="selectedForm.belong_user_table" clearable @change="changeIsUser"
:popper-append-to-body="false" placeholder="请选择学员字段" style="width: 100%">
<el-option v-for="(value, key) in selectFormList" :key="key" :label="value.name"
:value="value.belong_user_table"></el-option>
</el-select>
</el-form-item>
<el-form-item prop="name" label="字段名称">
<el-input v-model="selectedForm.name" placeholder="请输入字段名称" @input="inputHandler"></el-input>
</el-form-item>
<el-form-item required prop="field" label="字段标识">
<el-input :disabled="selectedForm.belong_user?true:false" v-model="selectedForm.field"></el-input>
</el-form-item>
<el-form-item prop="help" label="帮助文字">
<el-input v-model="selectedForm.help" placeholder="请输入帮助文字"></el-input>
</el-form-item>
<el-form-item prop="sort" label="排序">
<el-input v-model="selectedForm.sort" placeholder="请输入排序"></el-input>
</el-form-item>
<el-form-item prop="select_item" label="下拉框选项"
v-if="selectedForm.edit_input==='radio' || selectedForm.edit_input==='checkbox'">
<div class="select-item">
<div class="select-item__header">
<span></span>
<span></span>
</div>
<div class="select-item__body" v-for="(i, index) in selectItem">
<div><el-input v-model="i.key" size="mini"></el-input></div>
<div><el-input v-model="i.value" size="mini"></el-input></div>
<div>
<el-button type="danger" size="mini" circle icon="el-icon-delete"
@click="selectItem.splice(index, 1)"></el-button>
</div>
</div>
<el-button type="primary" size="mini" circle icon="el-icon-plus"
@click="selectItem.push({ key: '', value: '' })"></el-button>
</div>
</el-form-item>
<el-form-item prop="validation" label="校验规则">
<el-select v-model="validation" clearable multiple collapse-tags :popper-append-to-body="false"
placeholder="请选择校验规则" style="width: 100%">
<el-option v-for="(value, key) in rules" :key="key" :label="value" :value="key"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="saveField"></el-button>
<el-popover trigger="hover" ref="el-popover" placement="top" width="160">
<p>确定删除字段吗</p>
<div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="$refs['el-popover'].doClose()"></el-button>
<el-button type="primary" size="mini" @click="destroyField"></el-button>
</div>
<el-button type="danger" slot="reference" @click="$refs['el-popover'].doShow()"
style="margin-left: 10px">删除</el-button>
</el-popover>
</el-form-item>
</el-form>
</template>
<template v-else>
<el-empty style="position: relative; top: 50%; transform: translateY(-50%)" description="暂无选择"></el-empty>
</template>
</div>
</template>
<script>
import {
save,
destroy
} from "@/api/course/form";
import {
translate
} from "@/api/system/customFormField";
import {
debounce,
deepCopy
} from "@/utils";
import formMixins from "@/mixin/formMixin.js";
export default {
mixins: [formMixins],
props: {
rules: Object,
types: Array,
},
data() {
return {
showForm: false,
debouncedInputHandler: null,
formRule: {
name: [{
required: true,
message: "请输入字段名称"
}],
field: [{
required: true,
message: "请输入字段标识"
}],
},
selectedForm: {}, // item
selectedIndex: 0, // item index
selectItem: [], //
validation: [], //
parameters: [], //
forms: [], //
};
},
methods: {
checkChinese(rule, value, callback) {
const reg = /^[\u4e00-\u9fa5]+$/;
if (reg.test(value)) {
callback();
} else {
callback(new Error("请输入中文姓名"));
}
},
inputHandler(e) {
if (this.selectedForm.belong_user) {
} else {
this.debouncedInputHandler(e);
}
},
changeIsUser(e) {
console.log("e", e)
console.log(this.selectedForm)
this.selectFormList.map(item => {
if (e === item.belong_user_table) {
this.selectedForm = this.base.requestToForm(item,this.selectedForm)
console.log(this.selectedForm)
}
})
},
saveField() {
this.selectedForm.select_item = []
this.selectedForm.select_item = this.selectItem
this.selectedForm.rule = this.validation.join(",")
if (this.selectedForm.edit_input === 'radio' || this.selectedForm.edit_input === 'checkbox') {
if (this.selectedForm.select_item.length === 0) {
this.$Message.warning("请输入下拉框选项")
return
}
}
// return
save(this.selectedForm).then(res => {
console.log("res", res)
this.$Message.success('保存成功')
this.$emit("refreshFormItem", 'save')
this.showForm = false
})
},
destroyField() {
if (this.selectedForm.id) {
destroy({
id: this.selectedForm.id
}).then(res => {
this.$Message.success('删除成功')
this.showForm = false
this.$emit("refreshFormItem", 'DelId', this.selectedIndex)
})
} else {
this.$Message.success('删除成功')
this.showForm = false
this.$emit("refreshFormItem", 'Del', this.selectedIndex)
}
}
},
watch: {
selectedForm(newVal) {
console.log("newval", newVal)
if (newVal) {
if (newVal.select_item) {
this.selectItem = [];
this.selectItem = newVal.select_item
// for(let key in newVal.select_item) {
// this.selectItem.push({
// key,
// value: newVal.select_item[key]
// })
// }
}
this.validation = []
if (newVal.rule) {
this.validation = newVal.rule.split(',')
}
}
}
},
created() {
this.debouncedInputHandler = debounce((e) => {
if (e) {
this.checkChinese("", e, (err) => {
if (!err) {
translate({
str: e,
}).then((en) => {
this.selectedForm.field = en.pinyin;
});
}
});
}
}, 1000);
},
};
</script>
<style scoped lang="scss">
::v-deep .el-input-number.is-without-controls .el-input__inner {
text-align: left;
}
.select-item {
text-align: center;
&__header {
font-weight: 600;
display: flex;
&>span {
flex-basis: 30%;
&+span {
margin-left: 10px;
}
}
}
&__body {
display: flex;
&>div {
flex-basis: 30%;
&+div {
margin-left: 10px;
}
}
}
}
</style>

@ -52,8 +52,7 @@
<template v-slot:signDate>
<el-table-column align='center' label="报名日期" width="200" header-align="center">
<template slot-scope="scope">
{{scope.row.sign_start_date?scope.row.sign_start_date:''}}
{{scope.row.sign_end_date?"至"+scope.row.sign_end_date:'起'}}
{{scope.row.sign_start_date?scope.row.sign_start_date:''}}{{scope.row.sign_end_date?"至"+scope.row.sign_end_date:'起'}}
</template>
</el-table-column>
</template>

Loading…
Cancel
Save