ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<script setup lang="ts">
import { reactive, watch } from 'vue';
 
import { getAlphabetFromIndexRule } from '../helper';
 
const props = defineProps([
  'text',
  'getCustomRowNameList',
  'getMaxRows',
  'jnpfUniverRef',
  'cellFromDialogValue',
  'startColumn',
  'startRow',
  'dataSetList',
  'queryList',
]);
 
const emits = defineEmits(['clearCellRelevanceValue']);
 
interface State {
  type: string;
}
 
const state = reactive<State>({
  type: '',
});
const cellTypeOptions = [
  { id: 'none', fullName: '无' },
  { id: 'default', fullName: '默认' },
  { id: 'custom', fullName: '自定义' },
];
 
watch(
  () => props.cellFromDialogValue,
  (value) => {
    if (!value) return;
    const str = value.match(/[a-z]+/i)[0];
    const str1 = value.split(str);
    props.text[`${state.type}ParentCellCustomRowName`] = str;
    props.text[`${state.type}ParentCellCustomColName`] = str1[1];
  },
);
 
function openCellByDialogSelect(type?) {
  state.type = type || '';
  const focusedCell = {
    startColumn: props.startColumn,
    startRow: props.startRow,
  };
  props.jnpfUniverRef.value?.getCellFromDialogSelect(focusedCell);
  emits('clearCellRelevanceValue');
}
function onParentCellType(type) {
  const customRowName = `${type}ParentCellCustomRowName`;
  const customColName = `${type}ParentCellCustomColName`;
  if (props.text[`${type}ParentCellType`] == 'custom') {
    const startColumn = type == 'top' ? (props.startRow === 0 ? 0 : props.startColumn) : props.startColumn === 0 ? 0 : props.startColumn - 1;
    const startRow = type == 'top' ? (props.startRow === 0 ? 1 : props.startRow) : props.startColumn == 0 ? 1 : props.startRow + 1;
    props.text[customRowName] = props.text[customRowName] || getAlphabetFromIndexRule(startColumn);
    props.text[customColName] = props.text[customColName] || startRow;
  }
}
</script>
 
<template>
  <a-form-item label="左父格">
    <a-radio-group v-model:value="text.leftParentCellType" class="right-radio" @change="onParentCellType('left')">
      <a-radio :key="option.id" v-for="option in cellTypeOptions" :value="option.id">
        {{ option.fullName }}<BasicHelp v-if="option.id === 'custom'" text="目标单元格被删除、清除、撤销、重做和合并后,需要重新设置" />
      </a-radio>
    </a-radio-group>
  </a-form-item>
  <a-form-item v-if="text.leftParentCellType === 'custom'" class="-mt-[14px]">
    <a-input-group compact>
      <a-select class="!w-1/3" v-model:value="text.leftParentCellCustomRowName">
        <a-select-option v-for="item in getCustomRowNameList" :key="item" :value="item">{{ item }}</a-select-option>
      </a-select>
      <a-input-number class="!w-1/2" :min="1" :max="getMaxRows" v-model:value="text.leftParentCellCustomColName" />
      <a-button class="!w-1/6" pre-icon="icon-ym icon-ym-select-cell" @click="openCellByDialogSelect('left')" />
    </a-input-group>
  </a-form-item>
  <a-form-item label="上父格">
    <a-radio-group v-model:value="text.topParentCellType" class="right-radio" @change="onParentCellType('top')">
      <a-radio :key="option.id" v-for="option in cellTypeOptions" :value="option.id">
        {{ option.fullName }}<BasicHelp v-if="option.id === 'custom'" text="目标单元格被删除、清除、撤销、重做和合并后,需要重新设置" />
      </a-radio>
    </a-radio-group>
  </a-form-item>
  <a-form-item v-if="text.topParentCellType === 'custom'" class="-mt-[14px]">
    <a-input-group compact>
      <a-select class="!w-1/3" v-model:value="text.topParentCellCustomRowName">
        <a-select-option v-for="item in getCustomRowNameList" :key="item" :value="item">{{ item }}</a-select-option>
      </a-select>
      <a-input-number class="!w-1/2" :min="1" :max="getMaxRows" v-model:value="text.topParentCellCustomColName" />
      <a-button class="!w-1/6" pre-icon="icon-ym icon-ym-select-cell" @click="openCellByDialogSelect('top')" />
    </a-input-group>
  </a-form-item>
</template>