opProblem.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <!-- 优化问题 -->
  3. <div style="height: 100%;">
  4. <el-card class="custom-card">
  5. <template #header>
  6. <span>{{ opDataObj.header?.name }}</span>
  7. </template>
  8. <div class="opProblem-container" :class="currentClass">
  9. <div class="first-container">
  10. <div class="content-container">
  11. <div class="content-aside">
  12. <el-row justify="center">
  13. <img src="@/assets/img/yhwt.png" class="content-aside-img" alt="Experiment Icon" />
  14. </el-row>
  15. <el-row justify="center" align="middle">
  16. <span style="font-size: 10px;line-height: 32px;">{{ opDataObj1.header?.name }}</span>
  17. <el-switch v-if="opDataObj1.switch" v-model="opDataObj1.switch.val" active-value="1" inactive-value="0" class="custom-switch custom-switch-colors" />
  18. </el-row>
  19. </div>
  20. <div class="content-form content-form-right">
  21. <el-form class="custom-form" :label-width="Labelwidth" label-position="left">
  22. <template v-for="(item, index) in opDataObj1.body" :key="index">
  23. <!-- 下拉框和输入框(带 label) -->
  24. <el-form-item
  25. v-if="item.vo.valCodeType !== 'swithType'"
  26. :label="item.vo.name"
  27. >
  28. <el-select
  29. v-if="item.vo.valType === 1"
  30. v-model="item.vo.val"
  31. size="small"
  32. >
  33. <el-option
  34. v-for="option in valoption[item.vo.valCodeType]"
  35. :key="option.val"
  36. :label="option.tag"
  37. :value="option.val"
  38. />
  39. </el-select>
  40. <el-input
  41. v-else-if="item.vo.valType === 2"
  42. v-model="item.vo.val"
  43. size="small"
  44. />
  45. </el-form-item>
  46. <!-- 复选框(无 label、不占位) -->
  47. <el-checkbox
  48. v-else-if="item.vo.valType === 1 && item.vo.valCodeType === 'swithType'"
  49. v-model="item.vo.val"
  50. class="custom-checkbox"
  51. >
  52. {{ item.vo.name }}
  53. </el-checkbox>
  54. </template>
  55. </el-form>
  56. <!-- <div class="content-form-bottom">
  57. <el-form class="custom-form" :label-width="Labelwidth" label-position="left">
  58. <el-form-item label="厚度分布">
  59. <el-input v-model="qitanOPData1.thickness" size="small"></el-input>
  60. </el-form-item>
  61. <el-form-item label="上限">
  62. <el-input-number v-model="qitanOPData1.upperLimit" size="small" controls-position="right"></el-input-number>
  63. </el-form-item>
  64. <el-form-item label="下限">
  65. <el-input-number v-model="qitanOPData1.lowerLimit" size="small" controls-position="right"></el-input-number>
  66. </el-form-item>
  67. </el-form>
  68. </div> -->
  69. </div>
  70. </div>
  71. </div>
  72. <el-divider />
  73. <div class="second-container">
  74. <div class="content-container">
  75. <div class="content-aside">
  76. <el-row justify="center">
  77. <img src="@/assets/img/yhwt.png" class="content-aside-img" alt="Experiment Icon" />
  78. </el-row>
  79. <el-row justify="center" align="middle" >
  80. <span style="font-size: 10px;line-height: 32px;">{{ opDataObj2.header?.name }}</span>
  81. <el-switch v-if="opDataObj2.switch" v-model="opDataObj2.switch.val" active-value="1" inactive-value="0" class="custom-switch custom-switch-colors" />
  82. </el-row>
  83. </div>
  84. <div class="content-form content-form-right">
  85. <el-form class="custom-form" :label-width="Labelwidth" label-position="left">
  86. <template v-for="(item, index) in opDataObj2.body" :key="index">
  87. <!-- 下拉框和输入框(带 label) -->
  88. <el-form-item
  89. v-if="item.vo.valCodeType !== 'swithType'"
  90. :label="item.vo.name"
  91. >
  92. <el-select
  93. v-if="item.vo.valType === 1"
  94. v-model="item.vo.val"
  95. size="small"
  96. >
  97. <el-option
  98. v-for="option in valoption[item.vo.valCodeType]"
  99. :key="option.val"
  100. :label="option.tag"
  101. :value="option.val"
  102. />
  103. </el-select>
  104. <el-input
  105. v-else-if="item.vo.valType === 2"
  106. v-model="item.vo.val"
  107. size="small"
  108. />
  109. </el-form-item>
  110. <!-- 复选框(无 label、不占位) -->
  111. <el-checkbox
  112. v-else-if="item.vo.valType === 1 && item.vo.valCodeType === 'swithType'"
  113. v-model="item.vo.val"
  114. class="custom-checkbox"
  115. >
  116. {{ item.vo.name }}
  117. </el-checkbox>
  118. </template>
  119. </el-form>
  120. </div>
  121. </div>
  122. </div>
  123. <el-divider />
  124. <div class="third-container">
  125. <div class="content-container">
  126. <div class="content-aside">
  127. <el-row justify="center">
  128. <img src="@/assets/img/yhwt.png" class="content-aside-img" alt="Experiment Icon" />
  129. </el-row>
  130. <el-row justify="center" align="middle">
  131. <span style="font-size: 10px;line-height: 32px;">{{ opDataObj3.header?.name }}</span>
  132. <el-switch v-if="opDataObj3.switch" v-model="opDataObj3.switch.val" active-value="1" inactive-value="0" class="custom-switch custom-switch-colors" />
  133. </el-row>
  134. </div>
  135. <div class="content-form content-form-right">
  136. <el-form class="custom-form" :label-width="Labelwidth" label-position="left">
  137. <template v-for="(item, index) in opDataObj3.body" :key="index">
  138. <!-- 下拉框和输入框(带 label) -->
  139. <el-form-item
  140. v-if="item.vo.valCodeType !== 'swithType'"
  141. :label="item.vo.name"
  142. >
  143. <el-select
  144. v-if="item.vo.valType === 1"
  145. v-model="item.vo.val"
  146. size="small"
  147. >
  148. <el-option
  149. v-for="option in valoption[item.vo.valCodeType]"
  150. :key="option.val"
  151. :label="option.tag"
  152. :value="option.val"
  153. />
  154. </el-select>
  155. <el-input
  156. v-else-if="item.vo.valType === 2"
  157. v-model="item.vo.val"
  158. size="small"
  159. />
  160. </el-form-item>
  161. <!-- 复选框(无 label、不占位) -->
  162. <el-checkbox
  163. v-else-if="item.vo.valType === 1 && item.vo.valCodeType === 'swithType'"
  164. v-model="item.vo.val"
  165. class="custom-checkbox"
  166. >
  167. {{ item.vo.name }}
  168. </el-checkbox>
  169. </template>
  170. </el-form>
  171. </div>
  172. </div>
  173. </div>
  174. </div>
  175. </el-card>
  176. </div>
  177. </template>
  178. <script setup>
  179. import { analysisJson } from '../js/analysisData.js'
  180. import { useValOptionsStore } from '@/store/valoptions'
  181. const valOptionsStore = useValOptionsStore()
  182. const props = defineProps({
  183. opDatajson: {
  184. type: Object
  185. },
  186. runtype: {
  187. type: Number,
  188. default: 0
  189. }
  190. })
  191. const currentClass = computed(() => {
  192. if (props.runtype === 0) return 'class-qidong'
  193. if (props.runtype === 1) return 'class-jiegou'
  194. return 'class-qitan'
  195. })
  196. const Labelwidth = '70px';
  197. const valoption = computed(() => valOptionsStore.valOptionsMap)
  198. const opDataObj = ref({})
  199. const opDataObj1 = ref({})
  200. const opDataObj2 = ref({})
  201. const opDataObj3 = ref({})
  202. // 监听 opDatajson 变化
  203. watch(
  204. () => props.opDatajson,
  205. (newVal) => {
  206. getdatainit()
  207. },
  208. { deep: true } // 深度监听
  209. );
  210. const getdatainit = () => {
  211. opDataObj.value = analysisJson(props.opDatajson);
  212. opDataObj1.value = analysisJson(props.opDatajson.svo[0]);
  213. opDataObj2.value = analysisJson(props.opDatajson.svo[1]);
  214. opDataObj3.value = analysisJson(props.opDatajson.svo[2]);
  215. // console.log('opDataObj',opDataObj.value);
  216. console.log('opDataObj1',opDataObj1.value);
  217. }
  218. const gatherData = () => {
  219. let opdata1 = saveData(opDataObj1)
  220. let opdata2 = saveData(opDataObj2)
  221. let opdata3 = saveData(opDataObj3)
  222. let opdata = [...opdata1,...opdata2,...opdata3]
  223. console.log("op保存数据:", opdata)
  224. return opdata
  225. }
  226. // 保存前过滤
  227. const saveData = (obj) => {
  228. // 获取当前选中的 选项value
  229. const selectValue = obj.value.body
  230. .find(item => item?.vo?.valCodeType === 'samplingMethod')?.vo?.val;
  231. // 过滤 body
  232. const filteredBody = obj.value.body
  233. .map(item => item.vo);
  234. const switchObj = obj.value.switch
  235. const saveArr = switchObj ? [...filteredBody, switchObj] : filteredBody;
  236. // 这里执行你的上传或保存逻辑
  237. return saveArr;
  238. };
  239. defineExpose({gatherData})
  240. </script>
  241. <style scoped>
  242. .opProblem-container {
  243. width: 100%;
  244. height: 100%;
  245. display: flex;
  246. flex-direction: column;
  247. }
  248. .class-qidong {
  249. .first-container {
  250. width: 100%;
  251. height: 33%;
  252. }
  253. .second-container {
  254. width: 100%;
  255. height: 33%;
  256. }
  257. .third-container {
  258. width: 100%;
  259. height: 33%;
  260. }
  261. }
  262. .class-jiegou {
  263. .first-container {
  264. width: 100%;
  265. height: 48%;
  266. }
  267. .second-container {
  268. width: 100%;
  269. height: 25%;
  270. }
  271. .third-container {
  272. width: 100%;
  273. height: 25%;
  274. }
  275. }
  276. .class-qitan {
  277. .first-container {
  278. width: 100%;
  279. height: 48%;
  280. }
  281. .second-container {
  282. width: 100%;
  283. height: 25%;
  284. }
  285. .third-container {
  286. width: 100%;
  287. height: 25%;
  288. }
  289. }
  290. .content-form-top {
  291. width: 100%;
  292. height: 45%;
  293. }
  294. .content-form-bottom {
  295. width: 100%;
  296. height: 45%;
  297. }
  298. </style>