|
@@ -8,21 +8,22 @@
|
|
<view>
|
|
<view>
|
|
<uni-forms :rules="rules" :value="formData" ref="form" validate-trigger="bind" err-show-type="undertext" class="uniForm">
|
|
<uni-forms :rules="rules" :value="formData" ref="form" validate-trigger="bind" err-show-type="undertext" class="uniForm">
|
|
<uni-group title="基本信息" top="0">
|
|
<uni-group title="基本信息" top="0">
|
|
- <uni-forms-item name="name" required label="事项标题">
|
|
|
|
- <uni-easyinput type="text" :inputBorder="true" v-model="formData.titleName" placeholder="请输入事项标题"></uni-easyinput>
|
|
|
|
|
|
+ <uni-forms-item name="title" required label="事项标题">
|
|
|
|
+ <uni-easyinput type="text" :inputBorder="true" v-model="formData.title" placeholder="请输入事项标题"></uni-easyinput>
|
|
</uni-forms-item>
|
|
</uni-forms-item>
|
|
<!-- 使用原生input,需要绑定binddata -->
|
|
<!-- 使用原生input,需要绑定binddata -->
|
|
- <uni-forms-item name="textDetails" required label="正文">
|
|
|
|
- <uni-easyinput type="textarea" v-model="formData.textDetails" :maxlength="50" @blur="binddata('textDetails', $event.detail.value)" placeholder="请输入正文"></uni-easyinput>
|
|
|
|
|
|
+ <uni-forms-item name="content" required label="正文">
|
|
|
|
+ <uni-easyinput type="textarea" v-model="formData.content" :maxlength="50" @blur="binddata('textDetails', $event.detail.value)" placeholder="请输入正文"></uni-easyinput>
|
|
</uni-forms-item>
|
|
</uni-forms-item>
|
|
- <uni-forms-item label="电话" required name="phone">
|
|
|
|
|
|
+ <uni-forms-item label="电话" name="phone">
|
|
<uni-easyinput v-model="formData.phone" placeholder="请输入电话" />
|
|
<uni-easyinput v-model="formData.phone" placeholder="请输入电话" />
|
|
</uni-forms-item>
|
|
</uni-forms-item>
|
|
- <uni-forms-item name="address" required label="地址">
|
|
|
|
|
|
+ <uni-forms-item name="address" label="地址">
|
|
<uni-easyinput type="text" :inputBorder="true" v-model="formData.address" placeholder="请输入地址"></uni-easyinput>
|
|
<uni-easyinput type="text" :inputBorder="true" v-model="formData.address" placeholder="请输入地址"></uni-easyinput>
|
|
</uni-forms-item>
|
|
</uni-forms-item>
|
|
- <uni-forms-item name="checked" label="主题类型" label-width="30%">
|
|
|
|
|
|
+ <uni-forms-item name="type" label="主题类型" required label-width="30%">
|
|
<uni-data-select
|
|
<uni-data-select
|
|
|
|
+
|
|
style="width: 30%;margin: auto;"
|
|
style="width: 30%;margin: auto;"
|
|
v-model="formData.type"
|
|
v-model="formData.type"
|
|
placeholder="请选择主题类型"
|
|
placeholder="请选择主题类型"
|
|
@@ -30,8 +31,9 @@
|
|
:localdata="topicTypeList"
|
|
:localdata="topicTypeList"
|
|
></uni-data-select>
|
|
></uni-data-select>
|
|
</uni-forms-item>
|
|
</uni-forms-item>
|
|
- <uni-forms-item name="checked" label="所属部门" label-width="30%">
|
|
|
|
|
|
+ <uni-forms-item name="department" label="所属部门" required label-width="30%">
|
|
<uni-data-select
|
|
<uni-data-select
|
|
|
|
+
|
|
style="width: 30%;margin: auto;"
|
|
style="width: 30%;margin: auto;"
|
|
v-model="formData.department"
|
|
v-model="formData.department"
|
|
placeholder="请选择所属部门"
|
|
placeholder="请选择所属部门"
|
|
@@ -39,11 +41,9 @@
|
|
:localdata="departmentList"
|
|
:localdata="departmentList"
|
|
></uni-data-select>
|
|
></uni-data-select>
|
|
</uni-forms-item>
|
|
</uni-forms-item>
|
|
- <uni-forms-item name="checked" label="是否常办" label-width="30%">
|
|
|
|
- <switch :checked="formData.isTop" @change="change(' isTop', $event.detail.value)" style="margin-top: 2%;"/>
|
|
|
|
- </uni-forms-item>
|
|
|
|
- <uni-forms-item name="urlList" required label="图片">
|
|
|
|
- <upload :imgArr="imageList" :fileSize="1" :limit="3" @updateImg="updateImg"></upload>
|
|
|
|
|
|
+
|
|
|
|
+ <uni-forms-item name="picture" label="图片">
|
|
|
|
+ <upload :imgArr="imageList" :fileSize="1" :limit="3" @updateImg="updateImg"></upload>
|
|
</uni-forms-item>
|
|
</uni-forms-item>
|
|
</uni-group>
|
|
</uni-group>
|
|
<view>
|
|
<view>
|
|
@@ -64,6 +64,8 @@
|
|
getListDepts ,
|
|
getListDepts ,
|
|
} from '@/api/me/matters/matters.js'
|
|
} from '@/api/me/matters/matters.js'
|
|
import upload from '@/components/upload/index.vue'
|
|
import upload from '@/components/upload/index.vue'
|
|
|
|
+ import {addsc} from '@/api/handleAffairs/matter.js'
|
|
|
|
+
|
|
export default {
|
|
export default {
|
|
components: {
|
|
components: {
|
|
upload
|
|
upload
|
|
@@ -73,7 +75,7 @@
|
|
e.rows.forEach(v => {
|
|
e.rows.forEach(v => {
|
|
this.topicTypeList.push({
|
|
this.topicTypeList.push({
|
|
text:v.deptName,
|
|
text:v.deptName,
|
|
- value:v.id
|
|
|
|
|
|
+ value:v.deptName
|
|
})
|
|
})
|
|
})
|
|
})
|
|
})
|
|
})
|
|
@@ -89,14 +91,12 @@
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
formData: {
|
|
formData: {
|
|
- titleName: '',
|
|
|
|
|
|
+ title: '',
|
|
textDetails: '',
|
|
textDetails: '',
|
|
address:'',
|
|
address:'',
|
|
phone:'',
|
|
phone:'',
|
|
- email: '',
|
|
|
|
- sex: '0',
|
|
|
|
- hobby: [0, 2],
|
|
|
|
- remarks: '热爱学习,热爱生活',
|
|
|
|
|
|
+ content:'',
|
|
|
|
+ picture:'',
|
|
isGovernment: false,
|
|
isGovernment: false,
|
|
isTop: false,
|
|
isTop: false,
|
|
country: 2,
|
|
country: 2,
|
|
@@ -108,36 +108,10 @@
|
|
imageList:[],
|
|
imageList:[],
|
|
topicTypeList:[],
|
|
topicTypeList:[],
|
|
departmentList:[],
|
|
departmentList:[],
|
|
- sex: [{
|
|
|
|
- text: '男',
|
|
|
|
- value: '0'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- text: '女',
|
|
|
|
- value: '1'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- text: '未知',
|
|
|
|
- value: '2'
|
|
|
|
- }
|
|
|
|
- ],
|
|
|
|
- hobby: [{
|
|
|
|
- text: '足球',
|
|
|
|
- value: 0
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- text: '篮球',
|
|
|
|
- value: 1
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- text: '游泳',
|
|
|
|
- value: 2
|
|
|
|
- }
|
|
|
|
- ],
|
|
|
|
- range: ['中国', '美国', '澳大利亚'],
|
|
|
|
|
|
+
|
|
show: false,
|
|
show: false,
|
|
rules: {
|
|
rules: {
|
|
- titleName: {
|
|
|
|
|
|
+ title: {
|
|
rules: [{
|
|
rules: [{
|
|
required: true,
|
|
required: true,
|
|
errorMessage: '请输入标题'
|
|
errorMessage: '请输入标题'
|
|
@@ -148,123 +122,140 @@
|
|
}
|
|
}
|
|
]
|
|
]
|
|
},
|
|
},
|
|
- textDetails: {
|
|
|
|
|
|
+ content: {
|
|
rules: [{
|
|
rules: [{
|
|
required: true,
|
|
required: true,
|
|
errorMessage: '请输入正文'
|
|
errorMessage: '请输入正文'
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- minLength: 10,
|
|
|
|
- errorMessage: '正文不得少于 {minLength} 字'
|
|
|
|
|
|
+ minLength: 1,
|
|
|
|
+ errorMessage: '正文不得为空'
|
|
}
|
|
}
|
|
]
|
|
]
|
|
},
|
|
},
|
|
- weight: {
|
|
|
|
|
|
+ type: {
|
|
rules: [{
|
|
rules: [{
|
|
- format: 'number',
|
|
|
|
- errorMessage: '体重必须是数字'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- minimum: 100,
|
|
|
|
- maximum: 200,
|
|
|
|
- errorMessage: '体重应该大于 {minimum} 斤,小于 {maximum} 斤'
|
|
|
|
- }
|
|
|
|
- ]
|
|
|
|
- },
|
|
|
|
- birth: {
|
|
|
|
- rules: [
|
|
|
|
- {
|
|
|
|
required: true,
|
|
required: true,
|
|
- errorMessage: '请选择时间'
|
|
|
|
|
|
+ errorMessage: '请选择主题类型'
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- format: 'timestamp',
|
|
|
|
- errorMessage: '必须是时间戳'
|
|
|
|
|
|
+ minLength: 1,
|
|
|
|
+ errorMessage: '主题类型不得为空'
|
|
}
|
|
}
|
|
]
|
|
]
|
|
},
|
|
},
|
|
- email: {
|
|
|
|
- rules: [{
|
|
|
|
- format: 'email',
|
|
|
|
- errorMessage: '请输入正确的邮箱地址'
|
|
|
|
- }]
|
|
|
|
- },
|
|
|
|
- isGovernment: {
|
|
|
|
- rules: [{
|
|
|
|
- format: 'bool'
|
|
|
|
- }]
|
|
|
|
- },
|
|
|
|
- isTop: {
|
|
|
|
|
|
+ department: {
|
|
rules: [{
|
|
rules: [{
|
|
- format: 'bool'
|
|
|
|
- }]
|
|
|
|
- },
|
|
|
|
- sex: {
|
|
|
|
- rules: [{
|
|
|
|
- format: 'string'
|
|
|
|
- }]
|
|
|
|
- },
|
|
|
|
- hobby: {
|
|
|
|
- rules: [{
|
|
|
|
- format: 'array'
|
|
|
|
|
|
+ required: true,
|
|
|
|
+ errorMessage: '请选择所属部门'
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- validateFunction: function(rule, value, data, callback) {
|
|
|
|
- if (value.length < 2) {
|
|
|
|
- callback('请至少勾选两个兴趣爱好')
|
|
|
|
- }
|
|
|
|
- return true
|
|
|
|
- }
|
|
|
|
|
|
+ minLength: 1,
|
|
|
|
+ errorMessage: '所属部门不得为空'
|
|
}
|
|
}
|
|
]
|
|
]
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ // textDetails: {
|
|
|
|
+ // rules: [{
|
|
|
|
+ // required: true,
|
|
|
|
+ // errorMessage: '请输入正文'
|
|
|
|
+ // },
|
|
|
|
+ // {
|
|
|
|
+ // minLength: 10,
|
|
|
|
+ // errorMessage: '正文不得少于 {minLength} 字'
|
|
|
|
+ // }
|
|
|
|
+ // ]
|
|
|
|
+ // },
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- change(name, value) {
|
|
|
|
- this.formData.checked = value
|
|
|
|
- this.$refs.form.setValue(name, value)
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
|
|
+
|
|
submitForm(form) {
|
|
submitForm(form) {
|
|
- this.$refs[form]
|
|
|
|
- .submit()
|
|
|
|
- .then(res => {
|
|
|
|
- console.log('表单的值:', res)
|
|
|
|
- uni.showToast({
|
|
|
|
- title: '验证成功'
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
- .catch(errors => {
|
|
|
|
- console.error('验证失败:', errors)
|
|
|
|
- })
|
|
|
|
|
|
+ this.$refs[form]
|
|
|
|
+ .submit()
|
|
|
|
+ .then(res => {
|
|
|
|
+ console.log("222222222222222222", res);
|
|
|
|
+ uni.showModal({
|
|
|
|
+ title: '确认',
|
|
|
|
+ content: '是否添加该事项?',
|
|
|
|
+ success: (res) => {
|
|
|
|
+ console.log("1111111111111", res);
|
|
|
|
+ if (res.confirm) {
|
|
|
|
+ // 用户点击确定按钮
|
|
|
|
+
|
|
|
|
+ addsc(this.formData).then(response => {
|
|
|
|
+ console.log("7777777", this.formData);
|
|
|
|
+ this.$modal.msgSuccess("新增成功");
|
|
|
|
+ uni.navigateBack();
|
|
|
|
+
|
|
|
|
+ }).catch(error => {
|
|
|
|
+ console.error("新增方法出错:", error);
|
|
|
|
+ });
|
|
|
|
+ } else if (res.cancel) {
|
|
|
|
+ // 用户点击取消按钮
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '已取消',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ })
|
|
|
|
+ .catch(error => {
|
|
|
|
+ console.error("表单提交出错:", error);
|
|
|
|
+ });
|
|
},
|
|
},
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // submitForm(form) {
|
|
|
|
+ // this.$refs[form]
|
|
|
|
+ // .submit()
|
|
|
|
+ // .then(res => {
|
|
|
|
+ // console.log('表单的值:', res)
|
|
|
|
+ // uni.showToast({
|
|
|
|
+ // title: '验证成功'
|
|
|
|
+ // })
|
|
|
|
+ // })
|
|
|
|
+ // .catch(errors => {
|
|
|
|
+ // console.error('验证失败:', errors)
|
|
|
|
+ // })
|
|
|
|
+ // },
|
|
|
|
|
|
- //重置表单 。原生的组件input组件不能重置表单
|
|
|
|
|
|
+
|
|
resetForm() {
|
|
resetForm() {
|
|
this.$refs.form.resetFields()
|
|
this.$refs.form.resetFields()
|
|
},
|
|
},
|
|
- validateField(form) {
|
|
|
|
- this.$refs[form]
|
|
|
|
- .validateField(['name', 'email'])
|
|
|
|
- .then(res => {
|
|
|
|
- uni.showToast({
|
|
|
|
- title: '验证成功'
|
|
|
|
- })
|
|
|
|
- console.log('表单的值:', res)
|
|
|
|
- })
|
|
|
|
- .catch(errors => {
|
|
|
|
- console.error('验证失败:', errors)
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
|
|
+ // validateField(form) {
|
|
|
|
+ // this.$refs[form]
|
|
|
|
+ // .validateField(['name', 'email'])
|
|
|
|
+ // .then(res => {
|
|
|
|
+ // uni.showToast({
|
|
|
|
+ // title: '验证成功'
|
|
|
|
+ // })
|
|
|
|
+ // console.log('表单的值:', res)
|
|
|
|
+ // })
|
|
|
|
+ // .catch(errors => {
|
|
|
|
+ // console.error('验证失败:', errors)
|
|
|
|
+ // })
|
|
|
|
+ // },
|
|
updateImg(imgList){
|
|
updateImg(imgList){
|
|
this.imageList = imgList;
|
|
this.imageList = imgList;
|
|
|
|
+ // this.formData.picture =this.imageList
|
|
|
|
+ // this.formData.picture = JSON.stringify(this.imageList);
|
|
|
|
+ const pictureString = '"' + this.imageList.join('","') + '"';
|
|
|
|
+
|
|
|
|
+ // 将转换后的字符串赋值给 this.formData.picture
|
|
|
|
+ this.formData.picture = pictureString;
|
|
|
|
+ // console.log("1111111111111",)
|
|
},
|
|
},
|
|
- clearValidate(form, name) {
|
|
|
|
- if (!name) name = []
|
|
|
|
- this.$refs[form].clearValidate(name)
|
|
|
|
- }
|
|
|
|
|
|
+ // clearValidate(form, name) {
|
|
|
|
+ // if (!name) name = []
|
|
|
|
+ // this.$refs[form].clearValidate(name)
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|