asideData.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <el-container style="height: 100%">
  3. <el-header class="panel-header">
  4. <p>管网预览</p>
  5. <el-button style="border: none" @click="closePanel">
  6. <el-icon><Close /></el-icon>
  7. </el-button>
  8. </el-header>
  9. <el-main>
  10. <el-tabs v-model="activename" style="height: 100%">
  11. <el-tab-pane label="数据" name="data" style="height: 100%">
  12. <Splitpanes horizontal>
  13. <Pane min-size="20" size="50" max-size="80">
  14. <!-- <div>shang</div> -->
  15. <el-table :data="comdata" border class="datatable">
  16. <el-table-column type="index" width="40" label="" />
  17. <el-table-column prop="name" label="属性"> </el-table-column>
  18. <el-table-column prop="val" label="值">
  19. <template #default="{ row }">
  20. <el-select
  21. v-if="row.valueType === 1"
  22. v-model="row.val"
  23. placeholder="请选择"
  24. class="full-width-select"
  25. >
  26. <el-option
  27. v-for="option in row.options"
  28. :key="option.val"
  29. :label="option.tag"
  30. :value="option.val"
  31. >
  32. </el-option>
  33. </el-select>
  34. <el-input
  35. v-else-if="row.valueType === 2"
  36. v-model="row.val"
  37. class="full-width-input"
  38. />
  39. <el-button
  40. v-else-if="row.valueType === 3"
  41. @click="handleClick(row)"
  42. ></el-button>
  43. </template>
  44. </el-table-column>
  45. <el-table-column prop="unit" label="单位" width="100">
  46. <template #default="{ row }">
  47. <el-select
  48. v-if="row.unitType !== '无'"
  49. v-model="row.unit"
  50. placeholder="请选择"
  51. class="full-width-select"
  52. >
  53. <el-option
  54. v-for="option in row.unitoptions"
  55. :key="option.val"
  56. :label="option.tag"
  57. :value="option.val"
  58. >
  59. </el-option>
  60. </el-select>
  61. <div v-else>{{ row.unitType }}</div>
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. </Pane>
  66. <Pane min-size="20" size="50" max-size="80">
  67. <!-- <div>xia</div> -->
  68. </Pane>
  69. </Splitpanes>
  70. </el-tab-pane>
  71. <el-tab-pane label="模拟数据" name="simulatedata" style="height: 100%">
  72. <Splitpanes horizontal>
  73. <Pane min-size="20" size="50" max-size="80">
  74. <div>shang</div>
  75. </Pane>
  76. <Pane min-size="20" size="50" max-size="80">
  77. <div>xia</div>
  78. </Pane>
  79. </Splitpanes>
  80. </el-tab-pane>
  81. </el-tabs>
  82. </el-main>
  83. <!-- 用于数据按钮table -->
  84. <el-dialog
  85. v-model="paneTabledialog"
  86. align-center
  87. :append-to-body="true"
  88. width="500"
  89. class="dialog_class"
  90. draggable
  91. >
  92. <template #header="{ titleId, titleClass }">
  93. <div class="my-header">
  94. <!-- <el-image :src="icon" fit="contain"></el-image> -->
  95. <h4 :id="titleId" :class="titleClass">{{ $t("dialog.new") }}</h4>
  96. </div>
  97. </template>
  98. <el-table :data="tableData" border style="width: 100%">
  99. <el-table-colum prop="name" label="属性"></el-table-colum>
  100. <el-table-colum prop="" label="值"></el-table-colum>
  101. </el-table>
  102. <template #footer>
  103. <span class="lastbtn">
  104. <el-button @click="paneTabledialog = false">{{
  105. $t("dialog.cancel")
  106. }}</el-button>
  107. <el-button type="primary" >
  108. {{ $t("dialog.ok") }}
  109. </el-button>
  110. </span>
  111. </template>
  112. </el-dialog>
  113. <!-- 用于数据按钮键值对 -->
  114. <el-dialog
  115. v-model="paneKVdialog"
  116. align-center
  117. :append-to-body="true"
  118. width="500"
  119. class="dialog_class"
  120. draggable
  121. >
  122. <template #header="{ titleId, titleClass }">
  123. <div class="my-header">
  124. <!-- <el-image :src="icon" fit="contain"></el-image> -->
  125. <h4 :id="titleId" :class="titleClass">{{ $t("dialog.new") }}</h4>
  126. </div>
  127. </template>
  128. <el-table :data="tableData" border style="width: 100%">
  129. <!-- 动态列 -->
  130. <el-table-column
  131. v-for="col in tableColumns"
  132. :key="col.code"
  133. :prop="col.code"
  134. :label="col.name"
  135. :min-width="100"
  136. />
  137. </el-table>
  138. <template #footer>
  139. <span class="lastbtn">
  140. <el-button @click="paneKVdialog = false">{{
  141. $t("dialog.cancel")
  142. }}</el-button>
  143. <el-button type="primary" >
  144. {{ $t("dialog.ok") }}
  145. </el-button>
  146. </span>
  147. </template>
  148. </el-dialog>
  149. </el-container>
  150. </template>
  151. <script setup>
  152. import { Splitpanes, Pane } from "splitpanes"
  153. import "splitpanes/dist/splitpanes.css"
  154. import { Close } from "@element-plus/icons-vue"
  155. import { request } from "@/utils/request"
  156. import {
  157. ElMessage,
  158. ElButton,
  159. ElDialog,
  160. ElSelect,
  161. ElMessageBox
  162. } from "element-plus"
  163. const activename = ref("data")
  164. const emit = defineEmits(["close"])
  165. const comdata = ref()
  166. const paneTabledialog = ref(false)
  167. const paneKVdialog = ref(false)
  168. // data表格按钮点击弹窗表格
  169. const tableColumns = ref([]);
  170. const tableData = ref([]);
  171. const closePanel = () => {
  172. emit("close")
  173. }
  174. const getcomdata = (pcId) => {
  175. const params = {
  176. transCode: "ES0009",
  177. pcId: pcId
  178. }
  179. request(params)
  180. .then((res) => {
  181. comdata.value = res.rows
  182. console.log("comdata.value", comdata.value)
  183. comdata.value.forEach((item) => {
  184. if (item.pcaId) {
  185. // 若为下拉类型,则获取选项
  186. if (item.valueType === 1) {
  187. getlistopt(item, "value")
  188. } else {
  189. }
  190. if (item.unitType !== "无") {
  191. getlistopt(item, "unit")
  192. }
  193. }
  194. })
  195. })
  196. .catch((err) => {
  197. console.error(err)
  198. ElMessage.error("初始化失败")
  199. })
  200. }
  201. const getbtnvalue = (pcaId,dataType) => {
  202. const params = {
  203. transCode: "ES0010",
  204. pcaId: pcaId
  205. }
  206. request(params)
  207. .then((res) => {
  208. console.log(`值获取成功 [${pcaId}]:`, res)
  209. if(dataType === 1){
  210. tableColumns.value = res.headers || [];
  211. tableData.value = res.datas || [];
  212. }
  213. else {
  214. }
  215. })
  216. .catch((err) => {
  217. ElMessage.error("值初始化失败")
  218. })
  219. }
  220. const getlistopt = (item, gettype) => {
  221. let params = {}
  222. if (gettype === "value") {
  223. params = {
  224. transCode: "BES001",
  225. type: item.valueDef
  226. }
  227. } else {
  228. params = {
  229. transCode: "BES001",
  230. type: item.unitType
  231. }
  232. }
  233. request(params)
  234. .then((res) => {
  235. console.log("选项获取成功", res)
  236. if (gettype === "value") {
  237. item.val = res.rows[0].val
  238. item.options = res.rows || []
  239. } else {
  240. item.unit = res.rows[0].val
  241. item.unitoptions = res.rows || []
  242. }
  243. })
  244. .catch((err) => {
  245. console.error("err", err)
  246. ElMessage.error("选项初始化失败")
  247. })
  248. }
  249. const handleClick = (row) => {
  250. paneTabledialog.value = true;
  251. const pcaId = row.pcaId;
  252. const dataType = row.dataType;
  253. getbtnvalue(pcaId,dataType)
  254. }
  255. defineExpose({
  256. getcomdata
  257. })
  258. </script>
  259. <style scoped>
  260. .panel-header {
  261. display: flex;
  262. justify-content: space-between;
  263. align-items: center;
  264. }
  265. .datatable {
  266. width: 100%;
  267. max-height: 300px;
  268. overflow: auto;
  269. }
  270. </style>