ffds.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. <template>
  2. <div class="XFpdding" style="height: 400px;overflow: auto;">
  3. <div>
  4. <el-form-item label="FFD包围盒:" :label-width="formLabelWidth1">
  5. <el-input
  6. v-model="ffdvalue.fname"
  7. :max="20"
  8. controls-position="right"
  9. >
  10. <template #append>
  11. <fileUploads
  12. :projectId="123"
  13. solverType="exampleSolver"
  14. accept=".xyz"
  15. upId="ffds"
  16. name="点击选择文件"
  17. :imgSrc="imageSrc"
  18. @upload-success="handleFileUploadSuccess"
  19. />
  20. </template>
  21. </el-input>
  22. </el-form-item>
  23. <el-form-item label="参考坐标系:" :label-width="formLabelWidth1">
  24. <el-radio-group v-model="order">
  25. <el-radio :value="0" :label="0">x-y-z</el-radio>
  26. <el-radio :value="1" :label="1">x-z-y</el-radio>
  27. <el-radio :value="2" :label="2">y-x-z</el-radio>
  28. <el-radio :value="3" :label="3">y-z-x</el-radio>
  29. <el-radio :value="4" :label="4">z-x-y</el-radio>
  30. <el-radio :value="5" :label="5">z-y-x</el-radio>
  31. </el-radio-group>
  32. </el-form-item>
  33. </div>
  34. <el-form-item label="控制点数(X,Y,Z):" :label-width="formLabelWidth1">
  35. <el-row style="width: 100%" :gutter="5">
  36. <el-col :span="6">
  37. <el-input-number
  38. style="width: 120px"
  39. v-model="ffdvalue.nx"
  40. controls-position="right"
  41. />
  42. </el-col>
  43. <el-col :span="6">
  44. <el-input-number
  45. style="width: 120px"
  46. v-model="ffdvalue.ny"
  47. controls-position="right"
  48. />
  49. </el-col>
  50. <el-col :span="6">
  51. <el-input-number
  52. style="width: 120px"
  53. v-model="ffdvalue.nz"
  54. controls-position="right"
  55. />
  56. </el-col>
  57. <el-col :span="6">
  58. <el-button @click="generateTable" style="width: 100%">应用</el-button>
  59. </el-col>
  60. </el-row>
  61. </el-form-item>
  62. <div class="classtable" style="margin-top: 20px;">
  63. <el-table
  64. :data="tableDatacst1"
  65. style="width: 100%;margin-bottom: 20px;"
  66. border
  67. :header-cell-class-name="headerCellClassName"
  68. >
  69. <el-table-column prop="rowname" label="" width="100" />
  70. <el-table-column
  71. v-for="(item,index) in tablecstHeaders" :key="index"
  72. :prop="item.prop"
  73. :label="item.label">
  74. <template #default="{ row }">
  75. <el-input v-model="row[item.prop]" @change="handleEdit(row)"/>
  76. </template>
  77. </el-table-column>
  78. </el-table>
  79. </div>
  80. <div style="height: 260px; overflow: hidden;">
  81. <cloudChart :data="xyzData" />
  82. </div>
  83. </div>
  84. </template>
  85. <script setup>
  86. import { ref, onMounted, reactive, provide, nextTick } from "vue"
  87. import { RouterView, RouterLink, useRouter, useRoute } from "vue-router"
  88. import myheader from "@/components/header.vue"
  89. import fileUploads from "../components/fileuploads.vue"
  90. import { request, uploadFile } from "@/utils/request"
  91. import { ElMessage, ElButton, ElDialog, ElSelect } from "element-plus"
  92. import { Edit, CaretBottom } from "@element-plus/icons-vue"
  93. import cloudChart from "../threejsView/index.vue" // 云图
  94. let formLabelWidth1 = ref("200")
  95. let xyzData = ref()
  96. let pid = ref()
  97. let wid = ref()
  98. let fid = ref()
  99. let ffdid = ref()
  100. let ffdvalue = ref({
  101. fname: "204",
  102. nx: 10,
  103. ny: 2,
  104. nz: 2
  105. })
  106. let order = ref(1)
  107. let vars = ref()
  108. let tableDatacst1 = ref([
  109. { rowname: 'Y1Z1', X1: null, X2: null, X3: null, X4: null, X5: null, X6: null, X7: null, X8: null, X9: null },
  110. { rowname: 'Y1Z2', X1: null, X2: null, X3: null, X4: null, X5: null, X6: null, X7: null, X8: null, X9: null },
  111. { rowname: 'Y2Z1', X1: null, X2: null, X3: null, X4: null, X5: null, X6: null, X7: null, X8: null, X9: null },
  112. { rowname: 'Y2Z2', X1: null, X2: null, X3: null, X4: null, X5: null, X6: null, X7: null, X8: null, X9: null }
  113. ])
  114. let tablecstHeaders = ref([
  115. { prop: "X1", label: "X1" },
  116. { prop: "X2", label: "X2" },
  117. { prop: "X3", label: "X3" },
  118. { prop: "X4", label: "X4" },
  119. { prop: "X5", label: "X5" },
  120. { prop: "X6", label: "X6" },
  121. { prop: "X7", label: "X7" },
  122. { prop: "X8", label: "X8" },
  123. { prop: "X9", label: "X9" }
  124. ])
  125. const imageSrc = new URL("@/assets/flowimg/ffdFileSave.png", import.meta.url)
  126. .href
  127. const headerCellClassName = ({ columnIndex }) => {
  128. if (columnIndex !== 0) {
  129. return "header-blue"
  130. }
  131. return ""
  132. }
  133. // for (let i = 0; i < yCount; i++) {
  134. // for(let j = 0; j< zCount; j++) {
  135. // rows.push({
  136. // label: `Y${i + 1}Z${j + 1}`,
  137. // prop: `Y${i + 1}Z${j + 1}`
  138. // })
  139. // }
  140. // }
  141. const generateTable = () => {
  142. console.log("generateTable")
  143. // 获取 X, Y, Z 方向的数值
  144. const xCount = Number(ffdvalue.value.nx)
  145. const yCount = Number(ffdvalue.value.ny)
  146. const zCount = Number(ffdvalue.value.nz)
  147. console.log("xCount", xCount, "yCount", yCount, "zCount", zCount)
  148. // 定义表格的列和行
  149. let columns = []
  150. let rows = []
  151. switch (order.value) {
  152. case 0: // x-y-z
  153. columns = Array.from({ length: xCount }, (_, i) => ({
  154. label: `X${i + 1}`,
  155. prop: `X${i + 1}`
  156. }))
  157. rows = Array.from({ length: yCount * zCount }, (_, index) => {
  158. const yIndex = Math.floor(index / zCount)
  159. const zIndex = index % zCount
  160. return {
  161. label: `Y${yIndex + 1}Z${zIndex + 1}`,
  162. prop: `Y${yIndex + 1}Z${zIndex + 1}`
  163. }
  164. })
  165. break
  166. case 1: // x-z-y
  167. columns = Array.from({ length: xCount }, (_, i) => ({
  168. label: `X${i + 1}`,
  169. prop: `X${i + 1}`
  170. }))
  171. rows = Array.from({ length: zCount * yCount }, (_, index) => {
  172. const zIndex = Math.floor(index / yCount)
  173. const yIndex = index % yCount
  174. return {
  175. label: `Z${zIndex + 1}Y${yIndex + 1}`,
  176. prop: `Z${zIndex + 1}Y${yIndex + 1}`
  177. }
  178. })
  179. break
  180. case 2: // y-x-z
  181. columns = Array.from({ length: yCount }, (_, i) => ({
  182. label: `Y${i + 1}`,
  183. prop: `Y${i + 1}`
  184. }))
  185. rows = Array.from({ length: xCount * zCount }, (_, index) => {
  186. const xIndex = Math.floor(index / zCount)
  187. const zIndex = index % zCount
  188. return {
  189. label: `X${xIndex + 1}Z${zIndex + 1}`,
  190. prop: `X${xIndex + 1}Z${zIndex + 1}`
  191. }
  192. })
  193. break
  194. case 3: // y-z-x
  195. columns = Array.from({ length: yCount }, (_, i) => ({
  196. label: `Y${i + 1}`,
  197. prop: `Y${i + 1}`
  198. }))
  199. rows = Array.from({ length: zCount * xCount }, (_, index) => {
  200. const zIndex = Math.floor(index / xCount)
  201. const xIndex = index % xCount
  202. return {
  203. label: `Z${zIndex + 1}X${xIndex + 1}`,
  204. prop: `Z${zIndex + 1}X${xIndex + 1}`
  205. }
  206. })
  207. break
  208. case 4: // z-x-y
  209. columns = Array.from({ length: zCount }, (_, i) => ({
  210. label: `Z${i + 1}`,
  211. prop: `Z${i + 1}`
  212. }))
  213. rows = Array.from({ length: xCount * yCount }, (_, index) => {
  214. const xIndex = Math.floor(index / yCount)
  215. const yIndex = index % yCount
  216. return {
  217. label: `X${xIndex + 1}Y${yIndex + 1}`,
  218. prop: `X${xIndex + 1}Y${yIndex + 1}`
  219. }
  220. })
  221. break
  222. case 5: // z-y-x
  223. columns = Array.from({ length: zCount }, (_, i) => ({
  224. label: `Z${i + 1}`,
  225. prop: `Z${i + 1}`
  226. }))
  227. rows = Array.from({ length: yCount * xCount }, (_, index) => {
  228. const yIndex = Math.floor(index / xCount)
  229. const xIndex = index % xCount
  230. return {
  231. label: `Y${yIndex + 1}X${xIndex + 1}`,
  232. prop: `Y${yIndex + 1}X${xIndex + 1}`
  233. }
  234. })
  235. break
  236. default:
  237. console.error('无效的 order 值:', order.value)
  238. break
  239. }
  240. // 更新表格列头
  241. tablecstHeaders.value = columns
  242. // 生成表格的数据行
  243. tableDatacst1.value = []
  244. for (let i = 1; i <= rows.length; i++) {
  245. let row = { rowname: rows[i - 1].label }
  246. columns.forEach((column) => {
  247. row[column.prop] = null // 每个单元格初始化为空
  248. })
  249. tableDatacst1.value.push(row)
  250. }
  251. }
  252. // const generateTable = () => {
  253. // // 获取 X, Y, Z 方向的数值
  254. // const xCount = Number(ffdvalue.value.nx);
  255. // const yCount = Number(ffdvalue.value.ny);
  256. // const zCount = Number(ffdvalue.value.nz);
  257. // // 计算总行数
  258. // const rowCount = xCount * yCount * zCount;
  259. // // 确定最大维度
  260. // const maxCount = Math.max(xCount, yCount, zCount);
  261. // let maxAxis = "x";
  262. // if (yCount === maxCount) maxAxis = "y";
  263. // if (zCount === maxCount) maxAxis = "z";
  264. // // 清空表格数据
  265. // tableDatacst1.value = [];
  266. // // 循环填充数据
  267. // for (let i = 0; i < rowCount; i++) {
  268. // // 计算 x, y, z 的索引
  269. // const xIndex = i + 1;
  270. // const yIndex = i + 1;
  271. // const zIndex = i + 1;
  272. // // 构造 row 数据
  273. // const row = {
  274. // x: maxAxis === "x" ? xIndex : i < xCount ? xIndex : "/",
  275. // y: maxAxis === "y" ? yIndex : i < yCount ? yIndex : "/",
  276. // z: maxAxis === "z" ? zIndex : i < zCount ? zIndex : "/",
  277. // };
  278. // // 追加到 table 数据中
  279. // tableDatacst1.value.push(row);
  280. // }
  281. // };
  282. const handleFileUploadSuccess = (data) => {
  283. ffdvalue.value.fname = data.fname
  284. fid.value = data.bfid
  285. console.log("文件上传成功,bfid:", data.bfid, "fname:", data.fname)
  286. //bwb
  287. xyzData.value = {
  288. "data": {
  289. "uvw": [4, 2, 4],
  290. "datasetType": "xyz",
  291. "points": [0, -3.1, -23.5, 10.00333333, -3.1, -23.5, 20.00666667, -3.1, -23.5, 30.01, -3.1, -23.5, 0, 3, -23.5, 10.00333333, 3, -23.5, 20.00666667, 3, -23.5, 30.01, 3, -23.5, 0, -3.1, -3.98354861, 10.00333333, -3.1, -3.98354861, 20.00666667, -3.1, -3.98354861, 30.01, -3.1, -3.98354861, 0, 3, -3.98354861, 10.00333333, 3, -3.98354861, 20.00666667, 3, -3.98354861, 30.01, 3, -3.98354861, 0, -3.1, 10.4801155, 10.00333333, -3.1, 10.4801155, 20.00666667, -3.1, 10.4801155, 30.01, -3.1, 10.4801155, 0, 3, 10.4801155, 10.00333333, 3, 10.4801155, 20.00666667, 3, 10.4801155, 30.01, 3, 10.4801155, 0, -3.1, 23.5, 10.00333333, -3.1, 23.5, 20.00666667, -3.1, 23.5, 30.01, -3.1, 23.5, 0, 3, 23.5, 10.00333333, 3, 23.5, 20.00666667, 3, 23.5, 30.01, 3, 23.5]
  292. }
  293. }
  294. // ffd
  295. // xyzData.value = {
  296. // data: {
  297. // uvw: [10, 2, 2],
  298. // datasetType: "xyz",
  299. // points: [
  300. // -0.001, -0.02221365166194, 0, 0.110333333333333, -0.0666100429735, 0,
  301. // 0.221666666666667, -0.0746911997999, 0, 0.333, -0.0742001960868, 0,
  302. // 0.444333333333333, -0.0687689907986, 0, 0.555666666666667,
  303. // -0.059906331372, 0, 0.667, -0.0489160613387, 0, 0.778333333333333,
  304. // -0.0359079976976, 0, 0.889666666666667, -0.0213458626849, 0, 1.001,
  305. // -0.005339065876895, 0, -0.001, 0.020015, 0, 0.110333333333333,
  306. // 0.0666100429762, 0, 0.221666666666667, 0.0746911998011, 0, 0.333,
  307. // 0.0742001960863, 0, 0.444333333333333, 0.0687689907954, 0,
  308. // 0.555666666666667, 0.059906331369, 0, 0.667, 0.0489160613418, 0,
  309. // 0.778333333333333, 0.0359079976956, 0, 0.889666666666667,
  310. // 0.0213458626807, 0, 1.001, 0.004985000012241, 0, -0.001,
  311. // -0.02221365166194, 1, 0.110333333333333, -0.0666100429735, 1,
  312. // 0.221666666666667, -0.0746911997999, 1, 0.333, -0.0742001960868, 1,
  313. // 0.444333333333333, -0.0687689907986, 1, 0.555666666666667,
  314. // -0.059906331372, 1, 0.667, -0.0489160613387, 1, 0.778333333333333,
  315. // -0.0359079976976, 1, 0.889666666666667, -0.0213458626849, 1, 1.001,
  316. // -0.005339065876895, 1, -0.001, 0.020015, 1, 0.110333333333333,
  317. // 0.0666100429762, 1, 0.221666666666667, 0.0746911998011, 1, 0.333,
  318. // 0.0742001960863, 1, 0.444333333333333, 0.0687689907954, 1,
  319. // 0.555666666666667, 0.059906331369, 1, 0.667, 0.0489160613418, 1,
  320. // 0.778333333333333, 0.0359079976956, 1, 0.889666666666667,
  321. // 0.0213458626807, 1, 1.001, 0.004985000012241, 1
  322. // ]
  323. // }
  324. // }
  325. // xyzData.value = {"0":{"x":0,"y":-3.1,"z":-23.5},"1":{"x":10.00333333,"y":-3.1,"z":-23.5},"2":{"x":20.00666667,"y":-3.1,"z":-23.5},"3":{"x":30.01,"y":-3.1,"z":-23.5},"4":{"x":0,"y":3,"z":-23.5},"5":{"x":10.00333333,"y":3,"z":-23.5},"6":{"x":20.00666667,"y":3,"z":-23.5},"7":{"x":30.01,"y":3,"z":-23.5},"8":{"x":0,"y":-3.1,"z":-3.98354861},"9":{"x":10.00333333,"y":-3.1,"z":-3.98354861},"10":{"x":20.00666667,"y":-3.1,"z":-3.98354861},"11":{"x":30.01,"y":-3.1,"z":-3.98354861},"12":{"x":0,"y":3,"z":-3.98354861},"13":{"x":10.00333333,"y":3,"z":-3.98354861},"14":{"x":20.00666667,"y":3,"z":-3.98354861},"15":{"x":30.01,"y":3,"z":-3.98354861},"16":{"x":0,"y":-3.1,"z":10.4801155},"17":{"x":10.00333333,"y":-3.1,"z":10.4801155},"18":{"x":20.00666667,"y":-3.1,"z":10.4801155},"19":{"x":30.01,"y":-3.1,"z":10.4801155},"20":{"x":0,"y":3,"z":10.4801155},"21":{"x":10.00333333,"y":3,"z":10.4801155},"22":{"x":20.00666667,"y":3,"z":10.4801155},"23":{"x":30.01,"y":3,"z":10.4801155},"24":{"x":0,"y":-3.1,"z":23.5},"25":{"x":10.00333333,"y":-3.1,"z":23.5},"26":{"x":20.00666667,"y":-3.1,"z":23.5},"27":{"x":30.01,"y":-3.1,"z":23.5},"28":{"x":0,"y":3,"z":23.5},"29":{"x":10.00333333,"y":3,"z":23.5},"30":{"x":20.00666667,"y":3,"z":23.5},"31":{"x":30.01,"y":3,"z":23.5}}
  326. // xyzData.value = {"0":{"x":-0.05,"y":-0.25,"z":-0.01},"1":{"x":0.53333333,"y":-0.25,"z":-0.01},"2":{"x":1.11666667,"y":-0.25,"z":-0.01},"3":{"x":1.7,"y":-0.25,"z":-0.01},"4":{"x":-0.05,"y":0.25,"z":-0.01},"5":{"x":0.53333333,"y":0.25,"z":-0.01},"6":{"x":1.11666667,"y":0.25,"z":-0.01},"7":{"x":1.7,"y":0.25,"z":-0.01},"8":{"x":-0.05,"y":-0.25,"z":2.27799249},"9":{"x":0.53333333,"y":-0.25,"z":2.27799249},"10":{"x":1.11666667,"y":-0.25,"z":2.27799249},"11":{"x":1.7,"y":-0.25,"z":2.27799249},"12":{"x":-0.05,"y":0.25,"z":2.27799249},"13":{"x":0.53333333,"y":0.25,"z":2.27799249},"14":{"x":1.11666667,"y":0.25,"z":2.27799249},"15":{"x":1.7,"y":0.25,"z":2.27799249},"16":{"x":-0.05,"y":-0.25,"z":3.97362631},"17":{"x":0.53333333,"y":-0.25,"z":3.97362631},"18":{"x":1.11666667,"y":-0.25,"z":3.97362631},"19":{"x":1.7,"y":-0.25,"z":3.97362631},"20":{"x":-0.05,"y":0.25,"z":3.97362631},"21":{"x":0.53333333,"y":0.25,"z":3.97362631},"22":{"x":1.11666667,"y":0.25,"z":3.97362631},"23":{"x":1.7,"y":0.25,"z":3.97362631},"24":{"x":-0.05,"y":-0.25,"z":5.5},"25":{"x":0.53333333,"y":-0.25,"z":5.5},"26":{"x":1.11666667,"y":-0.25,"z":5.5},"27":{"x":1.7,"y":-0.25,"z":5.5},"28":{"x":-0.05,"y":0.25,"z":5.5},"29":{"x":0.53333333,"y":0.25,"z":5.5},"30":{"x":1.11666667,"y":0.25,"z":5.5},"31":{"x":1.7,"y":0.25,"z":5.5}}
  327. }
  328. // 用来生成 vars,存储表格中除了行名与列名的所有值
  329. const generateVars = () => {
  330. let values = []
  331. tableDatacst1.value.forEach((row) => {
  332. tablecstHeaders.value.forEach((col) => {
  333. let value = row[col.prop]
  334. if (value === null || value === undefined || value === "") {
  335. value = " "
  336. }
  337. values.push(value)
  338. })
  339. })
  340. // 将值拼接成用逗号分隔的字符串
  341. vars.value = values.join(",")
  342. }
  343. // 用来初始化表格,将 vars 中的值填充到表格中
  344. const initializeTableFromVars = () => {
  345. if (!vars.value) return
  346. const values = vars.value.split(",")
  347. console.log("ffdchaxun", values)
  348. let index = 0
  349. // 遍历 tableDatacst1 中的每一行
  350. tableDatacst1.value.forEach((row) => {
  351. tablecstHeaders.value.forEach((col) => {
  352. if (index < values.length) {
  353. // 将解析后的值赋给相应的单元格
  354. row[col.prop] = values[index] === " " ? "" : values[index] // 空格用空字符串代替
  355. index++
  356. }
  357. })
  358. })
  359. }
  360. // ffd查询
  361. const getffds = (id,nowid) => {
  362. pid.value = id;
  363. wid.value = nowid;
  364. const params = {
  365. transCode: "MDO0043",
  366. pid: pid.value,
  367. wid: wid.value
  368. }
  369. request(params)
  370. .then((res) => {
  371. if (res.hasOwnProperty("ffdid")) {
  372. // ffdid.value = res.ffdid;
  373. // ffdvalue.value.fname = res.fname;
  374. // ffdvalue.value.nx = res.nx;
  375. // ffdvalue.value.ny = res.ny;
  376. // ffdvalue.value.nz = res.nz;
  377. // order.value = Number(res.order);
  378. // vars.value = res.vars;
  379. // generateTable();
  380. // initializeTableFromVars();
  381. getffdsAssign(res)
  382. }
  383. })
  384. .catch((err) => {
  385. ElMessage.error(err.returnMsg)
  386. })
  387. }
  388. const getffdsAssign = (data) => {
  389. pid.value = data.pid
  390. ffdid.value = data.ffdid
  391. ffdvalue.value.fname = data.fname
  392. ffdvalue.value.nx = data.nx
  393. ffdvalue.value.ny = data.ny
  394. ffdvalue.value.nz = data.nz
  395. order.value = Number(data.order)
  396. vars.value = data.vars
  397. generateTable()
  398. // initializeTableFromVars()
  399. }
  400. // ffd保存
  401. const getffdsave = (id,nowid) => {
  402. if(nowid){
  403. wid.value = nowid
  404. }
  405. pid.value = id;
  406. // generateVars()
  407. const params = {
  408. transCode: "MDO0044",
  409. pid: pid.value,
  410. wid: wid.value,
  411. fid: fid.value,
  412. fname: ffdvalue.value.fname,
  413. nx: ffdvalue.value.nx,
  414. ny: ffdvalue.value.ny,
  415. nz: ffdvalue.value.nz,
  416. order: order.value,
  417. vars: vars.value,
  418. checked: 1
  419. }
  420. request(params)
  421. .then((res) => {
  422. ElMessage({
  423. message: '保存成功',
  424. type: "success"
  425. })
  426. })
  427. .catch((err) => {
  428. ElMessage.error('保存失败')
  429. })
  430. }
  431. defineExpose({ getffds, getffdsAssign, getffdsave })
  432. </script>