LookScd.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div>
  3. <el-dialog v-model="dialogVisible" title="选择SCD文件" width="40%" @close="handleClose">
  4. <div class="misBox" v-if="loading" v-loading="loading" element-loading-text="正在比对中,为防止误操作将禁止页面点击"
  5. element-loading-background="rgba(122, 122, 122, 0.8)">
  6. </div>
  7. <el-table ref="multipleTableRef" :data="tableList" style="width: 100%;height: calc(100vh - 520px);" stripe
  8. @selection-change="handleSelectionChange" @select-all="chooseAll">
  9. <el-table-column type="selection" width="55" />
  10. <el-table-column label="比对scd" width="auto" :show-overflow-tooltip="true">
  11. <template #default="scope">{{ scope.row.scd_name }}</template>
  12. </el-table-column>
  13. <el-table-column property="CREATED_TIME" label="时间" width="auto" :show-overflow-tooltip="true" />
  14. <!-- <el-table-column fixed="right" label="操作" width="120">
  15. <template #default>
  16. <el-button link type="primary" size="small"><el-icon>
  17. <View />
  18. </el-icon>查看</el-button>
  19. </template>
  20. </el-table-column> -->
  21. </el-table>
  22. <template #footer>
  23. <span class="dialog-footer">
  24. <el-button @click="cancels">取消</el-button>
  25. <el-button type="primary" @click="sureLook">
  26. 确定
  27. </el-button>
  28. </span>
  29. </template>
  30. </el-dialog>
  31. </div>
  32. </template>
  33. <script>
  34. import { ref, onMounted, toRefs, watch } from 'vue';
  35. import scd from '@/api/scd';
  36. import scdCheck from '@/api/scdCheck/scdCheck'
  37. import { ElMessage } from 'element-plus';
  38. export default {
  39. props: {
  40. lookScdModal: {
  41. type: Boolean,
  42. required: true
  43. },
  44. aktType: {
  45. type: Function,
  46. required: true
  47. },
  48. stations: {//变电站id
  49. type: String,
  50. required: true
  51. }
  52. },
  53. setup(props, { emit }) {
  54. let dialogVisible = ref(false)//模态框开关
  55. let tableList = ref([])//表格数据
  56. let alreadyTriggered = ref(false)//全选开关
  57. let scdid = ref([])//表格选择的scd数组
  58. let multipleTableRef = ref()
  59. let flashId = ref("")//本组件变电站id
  60. let loading = ref(false)//loading动画
  61. watch(() => props.stations, (newVal) => {
  62. flashId.value = newVal
  63. })
  64. function handleClose() {//模态框关闭方法
  65. dialogVisible.value = false
  66. emit("lookScdBack", dialogVisible.value)
  67. }
  68. function lastLook() {//确定
  69. if (scdid.value.length < 2) {
  70. ElMessage({
  71. type: 'warning',
  72. message: "请选择两个scd文件后点击"
  73. })
  74. } else {
  75. loading.value = true
  76. let idArr = scdid.value.map(item => {
  77. return item.id
  78. })
  79. // idArr = idArr.toString(idArr)
  80. scdCheck.scdStart({
  81. type: 'scd',
  82. station_id: flashId.value - 0,
  83. source_scd_id: idArr[0] - 0,
  84. target_scd_id: idArr[1] - 0,
  85. comp_id: 0
  86. }).then(res => {
  87. if (res.code == 0) {
  88. loading.value = false
  89. props.aktType()
  90. dialogVisible.value = false
  91. emit("lookScdBack", dialogVisible.value, scdid.value)
  92. } else {
  93. loading.value = false
  94. ElMessage({
  95. type: "error",
  96. message: "错误"
  97. })
  98. }
  99. })
  100. }
  101. }
  102. function motType() {//初始化数据
  103. dialogVisible.value = props.lookScdModal
  104. flashId.value = props.stations
  105. scd.getAllScd({ stationid: flashId.value - 0, pageno: 1, pagesize: 20 }).then(res => {//获取所有scd文件
  106. tableList.value = res.data
  107. })
  108. }
  109. function handleSelectionChange(e) {//复选
  110. if (e.length > 2 && !alreadyTriggered.value) {
  111. alreadyTriggered.value = true;
  112. let select = e.slice(0, 2);
  113. ElMessage({
  114. type: "warning",
  115. message: "默认只会留存前两个选中的scd",
  116. });
  117. setTimeout(() => {
  118. alreadyTriggered.value = false;
  119. }, 100);
  120. } else {
  121. scdid.value = e
  122. }
  123. }
  124. function chooseAll(e) {//全选
  125. if (e.length > 2) {
  126. ElMessage({
  127. type: "warning",
  128. message: "默认只会选中前两个SCD文件,请手动选择"
  129. })
  130. let select = e.slice(2)
  131. select.forEach((item) => {
  132. //取消选择超出的项
  133. multipleTableRef.value.toggleRowSelection(item, false);
  134. });
  135. scdid.value = e
  136. }
  137. }
  138. onMounted(() => {
  139. motType()
  140. })
  141. return {
  142. dialogVisible,
  143. handleClose,//模态框大关闭
  144. sureLook: lastLook,//确认按钮
  145. cancels: handleClose,//取消
  146. motType,//初始化数据
  147. tableList,//表格数据
  148. handleSelectionChange,
  149. chooseAll,
  150. alreadyTriggered,
  151. scdid,//选择的scd文件数组
  152. multipleTableRef,
  153. loading,
  154. flashId,//本组件变电站id
  155. }
  156. }
  157. }
  158. </script>
  159. <style scoped>
  160. .misBox {
  161. width: 100vw;
  162. height: 100vh;
  163. position: fixed;
  164. top: 0;
  165. right: 0;
  166. /* background-color: rgba(255, 255, 255, 0.5); */
  167. z-index: 200 !important;
  168. }
  169. </style>