Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
data-table
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2023-01-30 11:09:54 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8ad836f665e7bc4adc62a4a23522fbe459ac71e9
8ad836f6
1 parent
b68c3702
测试新增单选其他提交新内容功能
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
9 deletions
src/components/RadioField/index.vue
src/views/index.vue
src/components/RadioField/index.vue
View file @
8ad836f
<!--
* @Date: 2022-08-30 11:34:19
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-01-
18 16:14:00
* @LastEditTime: 2023-01-
30 11:09:03
* @FilePath: /data-table/src/components/RadioField/index.vue
* @Description: 单项选择控件
-->
...
...
@@ -29,7 +29,7 @@
style="margin-bottom: 0.25rem"
>{{ x.title }}</van-radio
>
<van-field v-
model="value" label="" placeholder="请输入用户名
" />
<van-field v-
if="has_add_info" :name="item.key + '#other_add_info'" v-model="add_info" label="" placeholder="请输入补充信息
" />
</van-radio-group>
</template>
</van-field>
...
...
@@ -53,13 +53,14 @@ const HideShow = computed(() => {
})
// TEST: 测试新功能:选择其他选项时,下方出现输入框,如果其他项被选中,输入框值为最终录入值。
// 绑定值发生变化时回调,处理选项为其他时的输入项录入
const value = ref('');
const has_add_info = ref(false); // 文字不一定是其他,后续可能需要字段绑定一个值,标识是否有其他输入框进行判断
const add_info = ref('');
const onChange = (item) => {
console.warn(item);
}
//
onMounted(() => {
//
props.item.value = '120'
//
})
onMounted(() => {
//
props.item.value = '120'
})
</script>
<style lang="less" scoped>
...
...
src/views/index.vue
View file @
8ad836f
<!--
* @Date: 2022-07-18 10:22:22
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-01-
18 16:12
:51
* @LastEditTime: 2023-01-
30 11:07
:51
* @FilePath: /data-table/src/views/index.vue
* @Description: 首页
-->
...
...
@@ -358,11 +358,25 @@ const validOther = () => {
return valid;
};
const onSubmit = async (values) => {
// 预处理表单数据
const preValidData = (values) => {
// 过滤掉标识为 ignore,undefined 的字段数据
let { ignore, undefined, ...rest_data } = values;
// TAG: 处理其他补充消息
for (const key in rest_data) {
if (key.includes('other_add_info')) {
const name = key.split('#')[0];
rest_data[name] = rest_data[key]
}
}
// console.warn(postData.value);
// 合并自定义字段到提交表单字段
postData.value = _.assign(postData.value, rest_data);
return _.assign(postData.value, rest_data);
}
const onSubmit = async (values) => {
// 表单数据处理
postData.value = preValidData(values)
// 检查非表单输入项
if (validOther().status) {
// 编辑模式不能提交数据
...
...
Please
register
or
login
to post a comment