8
0

adjust-excel.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <hc-drawer v-model="isShow" ui="hc-project-list-adjust-excel-drawer" to-id="hc-layout-box" is-close @close="drawerClose">
  3. <hc-page-split :fold="false" :options="splitOptions">
  4. <template #left>
  5. <hc-card :title="`【调整表单】${dataInfo.tableName}`">
  6. <hc-table-form ref="excelRef" :html="excelHtml" @tap="excelClick" />
  7. </hc-card>
  8. </template>
  9. <hc-card scrollbar>
  10. <template #header>
  11. <el-segmented v-model="tabsKey" :options="tabsProps" @change="tabsChange" />
  12. </template>
  13. <HcSetInput v-if="tabsKey === 'tab1'" ref="setInputRef" :info="dataInfo" @finish="getDataApi" />
  14. <HcSetEVisa v-if="tabsKey === 'tab2'" ref="setEVisaRef" :info="dataInfo" @finish="getDataApi" />
  15. </hc-card>
  16. </hc-page-split>
  17. </hc-drawer>
  18. </template>
  19. <script setup>
  20. import { ref, watch } from 'vue'
  21. import { getObjValue, isNullES } from 'js-fast-way'
  22. import HcSetInput from './adjust-excel/set-input.vue'
  23. import HcSetEVisa from './adjust-excel/set-e-visa.vue'
  24. import excelApi from '~api/exctab/exceltab'
  25. const props = defineProps({
  26. info: {
  27. type: Object,
  28. default: () => ({}),
  29. },
  30. })
  31. //事件
  32. const emit = defineEmits(['close'])
  33. //双向绑定
  34. const isShow = defineModel('modelValue', {
  35. default: false,
  36. })
  37. //监听数据
  38. const dataInfo = ref(props.info)
  39. watch(() => props.info, (data) => {
  40. dataInfo.value = getObjValue(data)
  41. }, { immediate: true, deep: true })
  42. //监听显示
  43. watch(isShow, (val) => {
  44. if (val) getDataApi()
  45. })
  46. //页面分割
  47. const splitOptions = {
  48. sizes: [70, 30],
  49. snapOffset: 0,
  50. minSize: [300, 300],
  51. }
  52. //选项卡
  53. const tabsKey = ref('tab1')
  54. const tabsProps = [
  55. { label: '输入框', value: 'tab1' },
  56. { label: '电签位置', value: 'tab2' },
  57. { label: '公式条件', value: 'tab3' },
  58. { label: '默认信息', value: 'tab4' },
  59. { label: '提示信息', value: 'tab5' },
  60. ]
  61. const tabsChange = (val) => {
  62. console.log(val)
  63. }
  64. //处理相关数据
  65. const excelRef = ref(null)
  66. const excelHtml = ref('')
  67. const getDataApi = async () => {
  68. const { pkeyId, excelId } = getObjValue(dataInfo.value)
  69. if (isNullES(pkeyId) || isNullES(excelId)) {
  70. window?.$message.warning('表单值异常,请联系管理员')
  71. return
  72. }
  73. const { data } = await excelApi.getExcelHtml({ pkeyId })
  74. excelHtml.value = data || ''
  75. }
  76. //ref
  77. const setInputRef = ref(null)
  78. const setEVisaRef = ref(null)
  79. //框框被点击
  80. const keys = [
  81. 'type', 'key', 'tr', 'td', 'index', 'x1', 'y1', 'x2', 'y2', 'name', 'text', 'rows', 'format',
  82. 'weighing', 'label', 'value', 'src', 'val', 'contractid', 'pkeyid', 'objs', 'range',
  83. ]
  84. const excelClick = async (item) => {
  85. const dom = item?.target
  86. let obj = { zdom: item }
  87. for (let i = 0; i < keys.length; i++) {
  88. obj[keys[i]] = await getAttribute(dom, keys[i])
  89. }
  90. //设置输入框
  91. if (tabsKey.value === 'tab1') {
  92. setInputRef.value?.setDomData(obj)
  93. }
  94. }
  95. //获取属性
  96. const getAttribute = async (dom, key) => {
  97. try {
  98. return dom?.getAttribute(`data-${key}`)
  99. } catch (e) {
  100. return null
  101. }
  102. }
  103. //关闭抽屉
  104. const drawerClose = () => {
  105. isShow.value = false
  106. emit('close')
  107. }
  108. </script>
  109. <style scoped lang="scss">
  110. </style>
  111. <style lang="scss">
  112. .el-overlay .el-drawer.hc-project-list-adjust-excel-drawer {
  113. background-color: #F1F5F8;
  114. .hc-table-form-data-item {
  115. padding: 0;
  116. }
  117. .hc-table-form-data-item .hc-excel-table-form {
  118. background: #e4e7eb;
  119. }
  120. }
  121. </style>