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
2024-07-28 19:01:05 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2b93616498804f88da725d81180eeef45bd64115
2b936164
1 parent
80043d23
fix page_type默认add,预览模式下不设置minWidth
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
14 deletions
src/views/index.vue
src/views/index.vue
View file @
2b93616
<!--
* @Date: 2022-07-18 10:22:22
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-07-2
7 16:09:5
1
* @LastEditTime: 2024-07-2
8 18:58:3
1
* @FilePath: /data-table/src/views/index.vue
* @Description: 首页
-->
<template>
<van-notice-bar v-if="formSetting.sjsj_is_count_down" left-icon="volume-o" :text="notice_text" scrollable
mode="closeable" />
<div class="table-box" :style="{ margin: is_pc ? '1rem 0' : '1rem', overflow: 'auto', minWidth:
is_pc
? '40rem' : '' }">
<div class="table-box" :style="{ margin: is_pc ? '1rem 0' : '1rem', overflow: 'auto', minWidth:
(is_pc && model !== 'preview')
? '40rem' : '' }">
<template v-if="PHeader.visible && page_type === 'add'">
<van-image v-if="PHeader.type === 'image' && PHeader.cover" width="100%" :src="PHeader.cover + '?imageView2/0/w/2000'" fit="cover" />
<template v-if="PHeader.type === 'carousel'">
...
...
@@ -219,7 +219,7 @@ const model = $route.query.model;
* edit 编辑页
* flow 流程页
*/
const page_type = $route.query.page_type ? $route.query.page_type :
null
;
const page_type = $route.query.page_type ? $route.query.page_type :
'add'
;
//
const data_id = $route.query.data_id ? $route.query.data_id : null;
// 模仿金数据的扩展参数
...
...
@@ -596,17 +596,31 @@ onMounted(async () => {
if (data_id) { // 如果有data_id,则获取历史数据 否则获取表单默认值
const history_data = await queryFormDataAPI({ form_code: $route.query.code, data_id, openid: iframe_openid });
if (history_data.code) {
let object = history_data.data; // 表单数据
formData.value.forEach((item) => { // 把对应数据赋值到表单
for (const key in object) {
const element = object[key];
if (item.key === key) {
item.component_props.default = element;
// 设置读写权限 read_only read_write
if (page_type === 'info') {
item.component_props.readonly = true;
PCommit.value.visible = false; // 只读模式下,提交按钮隐藏
}
// let object = history_data.data; // 表单数据
// formData.value.forEach((item) => { // 把对应数据赋值到表单
// for (const key in object) {
// const element = object[key];
// if (item.key === key) {
// item.component_props.default = element;
// // 设置读写权限 read_only read_write
// if (page_type === 'info') {
// item.component_props.readonly = true;
// PCommit.value.visible = false; // 只读模式下,提交按钮隐藏
// }
// }
// }
// });
// 结构优化一下
let object = history_data.data;
const isInfoPage = page_type === 'info';
const objectMap = new Map(Object.entries(object)); // 将 object 转换为 Map
formData.value.forEach((item) => {
if (objectMap.has(item.key)) {
item.component_props.default = objectMap.get(item.key);
// 设置读写权限 read_only read_write
if (isInfoPage) {
item.component_props.readonly = true;
PCommit.value.visible = false; // 只读模式下,提交按钮隐藏
}
}
});
...
...
Please
register
or
login
to post a comment