Showing
6 changed files
with
202 additions
and
25 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-07-12 13:28:27 | 2 | * @Date: 2024-07-12 13:28:27 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-07-12 17:58:57 | 4 | + * @LastEditTime: 2024-08-01 12:00:57 |
| 5 | * @FilePath: /data-table/src/components/TEditor/index.vue | 5 | * @FilePath: /data-table/src/components/TEditor/index.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -18,7 +18,7 @@ | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | ||
| 19 | <script setup> | 19 | <script setup> |
| 20 | import {computed, reactive, watch, ref, nextTick, onMounted} from "vue"; //全屏 | 20 | import {computed, reactive, watch, ref, nextTick, onMounted} from "vue"; //全屏 |
| 21 | - | 21 | +import $ from "jquery"; |
| 22 | // import tinymce from "tinymce/tinymce"; | 22 | // import tinymce from "tinymce/tinymce"; |
| 23 | // import "tinymce/skins/content/default/content.css"; | 23 | // import "tinymce/skins/content/default/content.css"; |
| 24 | import Editor from "@tinymce/tinymce-vue"; | 24 | import Editor from "@tinymce/tinymce-vue"; |
| ... | @@ -204,8 +204,8 @@ const tinymceOptions = { | ... | @@ -204,8 +204,8 @@ const tinymceOptions = { |
| 204 | image_title: true, | 204 | image_title: true, |
| 205 | menubar: 'edit view insert format tools', | 205 | menubar: 'edit view insert format tools', |
| 206 | // fontselect fontsizeselect | 206 | // fontselect fontsizeselect |
| 207 | - toolbar: 'bold italic table', | 207 | + toolbar: 'table', // 工具栏显示 |
| 208 | - width: '100vw', | 208 | + width: $('.table-field-page').width() + 'px', |
| 209 | paste_data_images: false, //允许粘贴图像 | 209 | paste_data_images: false, //允许粘贴图像 |
| 210 | min_height: 300, | 210 | min_height: 300, |
| 211 | // file_picker_callback: function (cb, value, meta) { | 211 | // file_picker_callback: function (cb, value, meta) { | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-08-29 14:31:20 | 2 | * @Date: 2022-08-29 14:31:20 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-08-29 16:44:53 | 4 | + * @LastEditTime: 2024-08-01 13:17:05 |
| 5 | * @FilePath: /data-table/src/components/TableField/index.vue | 5 | * @FilePath: /data-table/src/components/TableField/index.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| 8 | <template> | 8 | <template> |
| 9 | - <van-field v-if="item.component_type === 'radio'" :name="item.key" :label="item.label"> | 9 | + <div v-if="HideShow" class="table-field-page"> |
| 10 | - <template #input> | 10 | + <div class="label"> |
| 11 | - <van-radio-group v-model="item.value" direction="horizontal"> | 11 | + <span v-if="item.component_props.required" style="color: red"> *</span> |
| 12 | - <van-radio v-for="x in item.sub" :key="index" :name="x.key">{{ x.value }}</van-radio> | 12 | + <span :class="[ReadonlyShow ? 'readonly-show' : '']">{{ item.component_props.label }}</span> |
| 13 | - </van-radio-group> | 13 | + </div> |
| 14 | - </template> | 14 | + <div class="tinymce-box"> |
| 15 | - </van-field> | 15 | + <TEditor ref="refEdit" ></TEditor> |
| 16 | - <van-field v-else v-model="item.value" :name="item.name" :label="item.label" :type="item.type" | 16 | + <div @click="getValue">获取内容</div> |
| 17 | - :placeholder="item.placeholder" :rules="item.rules" :required="item.required" :autosize="item.autosize" | 17 | + <div @click="setValue">设置内容</div> |
| 18 | - :row="item.row" /> | 18 | + </div> |
| 19 | + <div> | ||
| 20 | + <div v-html="table_html" class="table-wrapper"></div> | ||
| 21 | + <div @click="setHtml">设置内容</div> | ||
| 22 | + </div> | ||
| 23 | + </div> | ||
| 19 | </template> | 24 | </template> |
| 20 | 25 | ||
| 21 | <script setup> | 26 | <script setup> |
| 27 | +import { useRoute } from "vue-router"; | ||
| 28 | +import { showSuccessToast, showFailToast } from 'vant'; | ||
| 29 | +// 初始化WX环境 | ||
| 30 | +import wx from 'weixin-js-sdk' | ||
| 31 | +import TEditor from "@/components/TEditor/index.vue"; | ||
| 32 | + | ||
| 33 | +const $route = useRoute(); | ||
| 22 | const props = defineProps({ | 34 | const props = defineProps({ |
| 23 | - item: Object | 35 | + item: Object, |
| 24 | -}) | 36 | +}); |
| 37 | + | ||
| 38 | +// 隐藏显示 | ||
| 39 | +const HideShow = computed(() => { | ||
| 40 | + return !props.item.component_props.disabled | ||
| 41 | +}); | ||
| 42 | + | ||
| 43 | +// 只读显示-流程模式 | ||
| 44 | +const ReadonlyShow = computed(() => { | ||
| 45 | + return $route.query.page_type === 'flow' && !props.item.component_props.readonly; | ||
| 46 | +}); | ||
| 47 | + | ||
| 48 | +onMounted(() => { | ||
| 49 | + props.item.value = props.item.component_props.default; | ||
| 50 | +}); | ||
| 51 | + | ||
| 52 | +const refEdit = ref(null); | ||
| 53 | + | ||
| 54 | +// refEdit.value.handleGetContent() | ||
| 55 | +const getValue = () => { | ||
| 56 | + console.warn(refEdit.value.handleGetContent()); | ||
| 57 | +} | ||
| 58 | + | ||
| 59 | +const setValue = () => { | ||
| 60 | + refEdit.value.handleSetContent(table) | ||
| 61 | +} | ||
| 62 | + | ||
| 63 | +const table_html = ref(''); | ||
| 64 | +const setHtml = () => { | ||
| 65 | + table_html.value = table | ||
| 66 | +} | ||
| 67 | + | ||
| 68 | +const table = ` | ||
| 69 | +<table> | ||
| 70 | + <thead> | ||
| 71 | + <tr> | ||
| 72 | + <th>姓名</th> | ||
| 73 | + <th>年龄</th> | ||
| 74 | + <th>城市</th> | ||
| 75 | + <th>姓名</th> | ||
| 76 | + <th>年龄</th> | ||
| 77 | + <th>城市</th> | ||
| 78 | + <th>姓名</th> | ||
| 79 | + <th>年龄</th> | ||
| 80 | + <th>城市</th> | ||
| 81 | + <th>姓名</th> | ||
| 82 | + <th>年龄</th> | ||
| 83 | + <th>城市</th> | ||
| 84 | + </tr> | ||
| 85 | + </thead> | ||
| 86 | + <tbody> | ||
| 87 | + <tr> | ||
| 88 | + <td>张三</td> | ||
| 89 | + <td>28</td> | ||
| 90 | + <td>北京</td> | ||
| 91 | + <td>张三</td> | ||
| 92 | + <td>28</td> | ||
| 93 | + <td>北京</td> | ||
| 94 | + <td>张三</td> | ||
| 95 | + <td>28</td> | ||
| 96 | + <td>北京</td> | ||
| 97 | + <td>张三</td> | ||
| 98 | + <td>28</td> | ||
| 99 | + <td>北京</td> | ||
| 100 | + </tr> | ||
| 101 | + <tr> | ||
| 102 | + <td>李四</td> | ||
| 103 | + <td>34</td> | ||
| 104 | + <td>上海</td> | ||
| 105 | + <td>李四</td> | ||
| 106 | + <td>34</td> | ||
| 107 | + <td>上海</td> | ||
| 108 | + <td>李四</td> | ||
| 109 | + <td>34</td> | ||
| 110 | + <td>上海</td> | ||
| 111 | + <td>李四</td> | ||
| 112 | + <td>34</td> | ||
| 113 | + <td>上海</td> | ||
| 114 | + </tr> | ||
| 115 | + <tr> | ||
| 116 | + <td>王五</td> | ||
| 117 | + <td>22</td> | ||
| 118 | + <td>广州</td> | ||
| 119 | + <td>王五</td> | ||
| 120 | + <td>22</td> | ||
| 121 | + <td>广州</td> | ||
| 122 | + <td>王五</td> | ||
| 123 | + <td>22</td> | ||
| 124 | + <td>广州</td> | ||
| 125 | + <td>王五</td> | ||
| 126 | + <td>22</td> | ||
| 127 | + <td>广州</td> | ||
| 128 | + </tr> | ||
| 129 | + </tbody> | ||
| 130 | +</table> | ||
| 131 | +` | ||
| 25 | </script> | 132 | </script> |
| 26 | 133 | ||
| 27 | <style lang="less" scoped> | 134 | <style lang="less" scoped> |
| 135 | +.table-field-page { | ||
| 136 | + .label { | ||
| 137 | + padding: 1rem 1rem 0 1rem; | ||
| 138 | + font-size: 0.9rem; | ||
| 139 | + font-weight: bold; | ||
| 140 | + } | ||
| 141 | +} | ||
| 142 | + | ||
| 143 | +.tinymce-box { | ||
| 144 | + // width: 100%; | ||
| 145 | +} | ||
| 146 | + | ||
| 147 | +:deep(.table-wrapper) { | ||
| 148 | + overflow: auto; | ||
| 149 | + table { | ||
| 150 | + width: 100%; | ||
| 151 | + border-collapse: collapse; | ||
| 152 | + } | ||
| 153 | + th, td { | ||
| 154 | + border: 1px solid #ddd; | ||
| 155 | + padding: 8px; | ||
| 156 | + text-align: left; | ||
| 157 | + } | ||
| 158 | + th { | ||
| 159 | + background-color: #f4f4f4; | ||
| 160 | + } | ||
| 161 | + tr:nth-child(even) { | ||
| 162 | + background-color: #f9f9f9; | ||
| 163 | + } | ||
| 164 | + tr:hover { | ||
| 165 | + background-color: #f1f1f1; | ||
| 166 | + } | ||
| 167 | +} | ||
| 28 | </style> | 168 | </style> | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-08-29 14:31:20 | 2 | * @Date: 2022-08-29 14:31:20 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-07-26 22:37:33 | 4 | + * @LastEditTime: 2024-08-01 11:50:02 |
| 5 | * @FilePath: /data-table/src/components/TextField/index.vue | 5 | * @FilePath: /data-table/src/components/TextField/index.vue |
| 6 | * @Description: 单行文本输入框(微信扫描功能) | 6 | * @Description: 单行文本输入框(微信扫描功能) |
| 7 | --> | 7 | --> |
| ... | @@ -113,10 +113,6 @@ const clickRightIcon = async () => { | ... | @@ -113,10 +113,6 @@ const clickRightIcon = async () => { |
| 113 | color: #666; | 113 | color: #666; |
| 114 | border-top: 1px solid #eee; | 114 | border-top: 1px solid #eee; |
| 115 | border-bottom: 1px solid #eee; | 115 | border-bottom: 1px solid #eee; |
| 116 | - | ||
| 117 | - span { | ||
| 118 | - color: red; | ||
| 119 | - } | ||
| 120 | } | 116 | } |
| 121 | 117 | ||
| 122 | .note-wrapper { | 118 | .note-wrapper { | ... | ... |
| ... | @@ -67,6 +67,7 @@ import VolunteerGroupField from '@/components/VolunteerGroupField/index.vue'; | ... | @@ -67,6 +67,7 @@ import VolunteerGroupField from '@/components/VolunteerGroupField/index.vue'; |
| 67 | * @type group 组集合输入控件 GroupField | 67 | * @type group 组集合输入控件 GroupField |
| 68 | * @type org_picker 树形选择控件 OrgPickerField | 68 | * @type org_picker 树形选择控件 OrgPickerField |
| 69 | * @type volunteer_group 义工组别选择控件 VolunteerGroupField | 69 | * @type volunteer_group 义工组别选择控件 VolunteerGroupField |
| 70 | + * @type table 表格控件 TableField | ||
| 70 | */ | 71 | */ |
| 71 | export function createComponentType(data) { | 72 | export function createComponentType(data) { |
| 72 | // 判断类型和使用组件 | 73 | // 判断类型和使用组件 |
| ... | @@ -206,5 +207,8 @@ export function createComponentType(data) { | ... | @@ -206,5 +207,8 @@ export function createComponentType(data) { |
| 206 | if (item.component_props.tag === 'volunteer_group') { | 207 | if (item.component_props.tag === 'volunteer_group') { |
| 207 | item.component = VolunteerGroupField; | 208 | item.component = VolunteerGroupField; |
| 208 | } | 209 | } |
| 210 | + if (item.component_props.tag === 'table') { | ||
| 211 | + item.component = TableField; | ||
| 212 | + } | ||
| 209 | }) | 213 | }) |
| 210 | } | 214 | } | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-07-18 10:22:22 | 2 | * @Date: 2022-07-18 10:22:22 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-07-31 10:53:58 | 4 | + * @LastEditTime: 2024-08-01 14:33:36 |
| 5 | * @FilePath: /data-table/src/views/index.vue | 5 | * @FilePath: /data-table/src/views/index.vue |
| 6 | * @Description: 首页 | 6 | * @Description: 首页 |
| 7 | --> | 7 | --> |
| ... | @@ -580,8 +580,9 @@ onMounted(async () => { | ... | @@ -580,8 +580,9 @@ onMounted(async () => { |
| 580 | // },] | 580 | // },] |
| 581 | // }); | 581 | // }); |
| 582 | 582 | ||
| 583 | + // TEST 新组件 | ||
| 583 | // page_form.push({ | 584 | // page_form.push({ |
| 584 | - // "tag": "name", | 585 | + // "tag": "table", |
| 585 | // "name": "name_2", | 586 | // "name": "name_2", |
| 586 | // "index": 2, | 587 | // "index": 2, |
| 587 | // "label": "姓名", | 588 | // "label": "姓名", | ... | ... |
| 1 | +<!-- | ||
| 2 | + * @Date: 2024-07-12 13:20:15 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2024-08-01 11:51:07 | ||
| 5 | + * @FilePath: /data-table/src/views/test.vue | ||
| 6 | + * @Description: 文件描述 | ||
| 7 | +--> | ||
| 1 | <template> | 8 | <template> |
| 2 | <div class="tinymce-box"> | 9 | <div class="tinymce-box"> |
| 3 | <TEditor ref="refEdit" ></TEditor> | 10 | <TEditor ref="refEdit" ></TEditor> |
| ... | @@ -17,8 +24,37 @@ | ... | @@ -17,8 +24,37 @@ |
| 17 | } | 24 | } |
| 18 | 25 | ||
| 19 | const setValue = () => { | 26 | const setValue = () => { |
| 20 | - refEdit.value.handleSetContent('<p>test</p>') | 27 | + refEdit.value.handleSetContent(table) |
| 21 | } | 28 | } |
| 29 | + | ||
| 30 | + const table = ` | ||
| 31 | + <table> | ||
| 32 | + <thead> | ||
| 33 | + <tr> | ||
| 34 | + <th>姓名</th> | ||
| 35 | + <th>年龄</th> | ||
| 36 | + <th>城市</th> | ||
| 37 | + </tr> | ||
| 38 | + </thead> | ||
| 39 | + <tbody> | ||
| 40 | + <tr> | ||
| 41 | + <td>张三</td> | ||
| 42 | + <td>28</td> | ||
| 43 | + <td>北京</td> | ||
| 44 | + </tr> | ||
| 45 | + <tr> | ||
| 46 | + <td>李四</td> | ||
| 47 | + <td>34</td> | ||
| 48 | + <td>上海</td> | ||
| 49 | + </tr> | ||
| 50 | + <tr> | ||
| 51 | + <td>王五</td> | ||
| 52 | + <td>22</td> | ||
| 53 | + <td>广州</td> | ||
| 54 | + </tr> | ||
| 55 | + </tbody> | ||
| 56 | + </table> | ||
| 57 | + ` | ||
| 22 | </script> | 58 | </script> |
| 23 | 59 | ||
| 24 | <style> | 60 | <style> | ... | ... |
-
Please register or login to post a comment