DomainDialog.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <SubDialog
  3. :modelValue="modelValue"
  4. @update:modelValue="$emit('update:modelValue', $event)"
  5. title="域"
  6. width="600"
  7. height="500px"
  8. @confirm="handleConfirm"
  9. @cancel="handleCancel"
  10. >
  11. <div>
  12. <el-row style="margin-bottom: 10px;" :gutter="20">
  13. <el-col :key="showAll" :span="8">
  14. <el-button @click="showAll" style="width: 100%;">显示全部</el-button>
  15. </el-col>
  16. <el-col :key="hideAll" :span="8">
  17. <el-button @click="hideAll" style="width: 100%;">隐藏全部</el-button>
  18. </el-col>
  19. <el-col :key="reverseAll" :span="8">
  20. <el-button @click="reverseAll" style="width: 100%;">倒转互换</el-button>
  21. </el-col>
  22. </el-row>
  23. <el-row style="margin-bottom: 10px;" :gutter="20">
  24. <el-col :span="8">
  25. <el-button @click="showSelected" style="width: 100%;">显示</el-button>
  26. </el-col>
  27. <el-col :span="8">
  28. <el-button @click="hideSelected" style="width: 100%;">隐藏</el-button>
  29. </el-col>
  30. <el-col :span="8">
  31. <el-button @click="surfaceRendering" style="width: 100%;">表面绘制</el-button>
  32. </el-col>
  33. </el-row>
  34. </div>
  35. <div class="classtable tabledomain">
  36. <el-table
  37. :data="tableData"
  38. style="width: 100%; height: 230px"
  39. border="true"
  40. :header-cell-class-name="headerCellClassName"
  41. @selection-change="handleSelectionChange"
  42. >
  43. <el-table-column type="selection" width="55" />
  44. <el-table-column prop="domain" label="域名称" />
  45. <el-table-column prop="status" label="状态" /> <!-- 直接显示原始值 -->
  46. <el-table-column prop="drawType" label="绘制类型" />
  47. <el-table-column prop="planeRange" label="平面范围" />
  48. </el-table>
  49. </div>
  50. </SubDialog>
  51. <!-- 表面绘制弹窗 -->
  52. <SurfaceDialog
  53. v-model="showSurfaceDialog"
  54. :initial-data="surfaceFormData"
  55. @surfaceConfirm="handleSurfaceConfirm"
  56. />
  57. </template>
  58. <script setup>
  59. import { ref, defineProps, defineEmits } from 'vue'
  60. import SubDialog from './SubDialog.vue'
  61. import SurfaceDialog from './SurfaceDialog.vue'
  62. const props = defineProps({
  63. modelValue: Boolean,
  64. initialData: {
  65. type: Array,
  66. default: () => []
  67. }
  68. })
  69. const emit = defineEmits(['update:modelValue', 'confirm', 'cancel'])
  70. const selectedRows = ref([]); // 存储选中的行
  71. // 表面绘制弹窗状态
  72. const showSurfaceDialog = ref(false)
  73. const surfaceFormData = ref({
  74. slotType: '0',
  75. start: '1',
  76. end: '1',
  77. skip: '1'
  78. })
  79. const selectedDomains = computed(() => {
  80. return selectedRows.value.map(row => row.domain)
  81. })
  82. // 监听选中行变化
  83. const handleSelectionChange = (rows) => {
  84. selectedRows.value = rows;
  85. };
  86. // 显示全部
  87. const showAll = () => {
  88. tableData.value.forEach(item => {
  89. item.status = 'show'
  90. })
  91. }
  92. // 隐藏全部
  93. const hideAll = () => {
  94. tableData.value.forEach(item => {
  95. item.status = 'hide'
  96. })
  97. }
  98. // 显示选中行
  99. const showSelected = () => {
  100. selectedRows.value.forEach(row => {
  101. row.status = 'show'
  102. })
  103. }
  104. // 隐藏选中行
  105. const hideSelected = () => {
  106. selectedRows.value.forEach(row => {
  107. row.status = 'hide'
  108. })
  109. }
  110. // 倒转互换所有行状态
  111. const reverseAll = () => {
  112. tableData.value.forEach(item => {
  113. item.status = item.status === 'show' ? 'hide' : 'show'
  114. })
  115. }
  116. // 按钮数据
  117. let domainbtnbox1 = ref(['显示全部','隐藏全部','倒转互换'])
  118. let domainbtnbox2 = ref(['显示','隐藏','表面绘制'])
  119. // 表格数据
  120. let tableData = ref([
  121. {domain:"Z1", status:'show', drawType:'Exposed', planeRange:'(1,1,1)'},
  122. {domain:"Z2", status:'show', drawType:'Exposed', planeRange:'(1,1,1)'},
  123. {domain:"Z3", status:'show', drawType:'Exposed', planeRange:'(1,1,1)'},
  124. {domain:"Z4", status:'show', drawType:'Exposed', planeRange:'(1,1,1)'},
  125. {domain:"Z1", status:'show', drawType:'Exposed', planeRange:'(1,1,1)'},
  126. {domain:"Z2", status:'show', drawType:'Exposed', planeRange:'(1,1,1)'},
  127. {domain:"Z3", status:'show', drawType:'Exposed', planeRange:'(1,1,1)'},
  128. {domain:"Z4", status:'show', drawType:'Exposed', planeRange:'(1,1,1)'},
  129. ])
  130. // 表格列配置
  131. let tabledomainColumns = ref([
  132. {label:"状态", prop:'state'},
  133. {label:"绘制类型", prop:'type'},
  134. {label:"平面范围", prop:'area'},
  135. ])
  136. const slotTypeOptions = ref([
  137. { value: "0", label: "Exposed" },
  138. { value: "1", label: "I-plans" },
  139. { value: "2", label: "J-plans" },
  140. { value: "3", label: "K-plans" }
  141. ])
  142. // 表头样式
  143. const headerCellClassName = ({ column }) => {
  144. // console.log('列:',column.property)
  145. if (column.property === 'state') {
  146. console.log('yanse',column.property)
  147. return 'header-blue';
  148. } else if (column.property === 'type') {
  149. return 'header-green';
  150. } else if (column.property === 'area') {
  151. return 'header-yellow';
  152. }
  153. return '';
  154. };
  155. // 表面绘制按钮点击
  156. const surfaceRendering = () => {
  157. if (selectedRows.value.length === 0) {
  158. return
  159. }
  160. // 初始化表面绘制表单数据
  161. surfaceFormData.value = {
  162. slotType: '0',
  163. start: '1',
  164. end: '1',
  165. skip: '1',
  166. domains: selectedDomains.value // 传递选中的域
  167. }
  168. showSurfaceDialog.value = true
  169. }
  170. // 表面绘制确认
  171. const handleSurfaceConfirm = (surfaceData) => {
  172. console.log('表面绘制数据:', surfaceData)
  173. // 找到对应的label
  174. const selectedOption = slotTypeOptions.value.find(option => option.value === surfaceData.slotType);
  175. const drawTypeLabel = selectedOption ? selectedOption.label : surfaceData.slotType;
  176. // 更新选中行的绘制类型和平面范围
  177. selectedRows.value.forEach(row => {
  178. row.drawType = drawTypeLabel; // 使用label而不是value
  179. row.planeRange = `(${surfaceData.start},${surfaceData.end},${surfaceData.skip})`
  180. })
  181. showSurfaceDialog.value = false
  182. }
  183. // 确认操作
  184. const handleConfirm = () => {
  185. emit('confirm', tableData.value)
  186. emit('update:modelValue', false)
  187. }
  188. // 取消操作
  189. const handleCancel = () => {
  190. emit('cancel')
  191. emit('update:modelValue', false)
  192. }
  193. </script>
  194. <style scoped>
  195. .classtable.tabledomain {
  196. margin-top: 20px;
  197. }
  198. /* 表头样式 */
  199. :deep(.header-cell) {
  200. background-color: #f5f7fa;
  201. font-weight: bold;
  202. }
  203. </style>