step3.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <div id="handsonStep2">
  3. <div class="btns-view">
  4. <el-button type="primary" @click="dialogShow(1)">根据关键内容批量标准化设备标识</el-button>
  5. <el-button type="primary" @click="dialogShow(2)">根据关键内容批量对应数据字典</el-button>
  6. <el-checkbox style="float:right;" @change="changeChecked" v-model="checked">只显示未标准化得的原始点位</el-checkbox>
  7. </div>
  8. <div id="handsontableSteps1">
  9. <handsontable-component @mouseDown="clickEdit" ref="handsontable"></handsontable-component>
  10. </div>
  11. <!-- <div class="center">
  12. <pagination :page="pages" @change="changePage"></pagination>
  13. </div> -->
  14. <own-dialog :width="'1000px'" :title=" isDataform ? '根据关键内容批量对应数据字典' : '根据关键内容批量标准化设备标识' " :dialogVisible="isDialogShow" @cancel="close">
  15. <dialog-main v-if="!isDataform"></dialog-main>
  16. <steps-main v-if="isDataform"></steps-main>
  17. </own-dialog>
  18. <own-dialog :width="'1000px'" :dialogVisible="isEditDialogShow" @cancel="closeEdit">
  19. <step3-edit v-if="isEditDialogShow" :editData='editData' @refresh='refreshData'></step3-edit>
  20. </own-dialog>
  21. </div>
  22. </template>
  23. <script>
  24. import handsontableComponent from "@/components/common/handsontable"
  25. import headerArr from "@/utils/point_edit/steps3.js"
  26. import {
  27. changeHeader,
  28. showTypes
  29. } from "@/utils/handsontable/delType"
  30. import {
  31. mapGetters,
  32. mapActions
  33. } from "vuex";
  34. import ownDialog from "@/components/el_pack/dialog"
  35. import dialogMain from "@/components/config_point/step3_point/dialog_main"
  36. import stepsMain from "@/components/config_point/step3_point/steps3_main"
  37. import {
  38. queryPointRela,
  39. getNoDealPoint
  40. } from "@/fetch/point_http"
  41. import step3Edit from '@/components/config_point/step3_edit/index'
  42. import pagination from "@/components/common/myPagination"
  43. export default {
  44. data() {
  45. return {
  46. checked: false,
  47. settings: {},
  48. isDialogShow: false,
  49. hot: null,
  50. isDataform: false,
  51. /************point3_step_edit*********************** */
  52. isEditDialogShow: false,
  53. editData:{}, //编辑数据
  54. pages: {
  55. size: 10,
  56. sizes: [10, 30, 50, 100],
  57. total: 0,
  58. currentPage: 0
  59. },
  60. }
  61. },
  62. computed: {
  63. ...mapGetters("project", [
  64. "projectId",
  65. "datasourceId",
  66. "protocolType"
  67. ])
  68. },
  69. created() {
  70. if (!this.protocolType) {
  71. this.$router.push({
  72. path: "/configPoint"
  73. })
  74. }
  75. },
  76. mounted() {
  77. this.getData()
  78. },
  79. methods: {
  80. //页面关闭
  81. close() {
  82. this.isDialogShow = false
  83. },
  84. //只显示为标准化的点位标识
  85. changeChecked(){
  86. if(this.checked){
  87. getNoDealPoint({
  88. type: this.protocolType,
  89. data: {
  90. DataSourceId: this.datasourceId
  91. }
  92. },res => {
  93. let content = res.Content
  94. let settings = {
  95. data: content,
  96. colHeaders: changeHeader(headerArr),
  97. columns: showTypes(headerArr).map(item => {
  98. item.readOnly = true
  99. item.data = item.data
  100. return item
  101. }),
  102. rowHeights: 30,
  103. maxRows: res.Content.length
  104. }
  105. this.hot = this.$refs.handsontable.init(settings)
  106. this.pages.total = res.Total
  107. console.log(this.hot)
  108. })
  109. }else{
  110. this.getData()
  111. }
  112. },
  113. //页面显示num1为标准化设备标识,2为对应数据字典
  114. dialogShow(num) {
  115. if (num == 1) {
  116. this.isDataform = false
  117. } else if (num == 2) {
  118. this.isDataform = true
  119. }
  120. this.isDialogShow = true
  121. },
  122. //页面发生更改
  123. changePage() {
  124. this.getData()
  125. },
  126. /**
  127. * 表格点击事件
  128. * @param {当前条数据} rowData
  129. * @param {当前条} row
  130. *
  131. * down something
  132. */
  133. clickEdit(rowData,row){
  134. console.log(rowData,row)
  135. if(row.row >= 0 && row.col == 7) {
  136. this.isEditDialogShow = true;
  137. this.editData = rowData;
  138. }
  139. },
  140. closeEdit() {
  141. this.isEditDialogShow = false;
  142. },
  143. //初始化表格实例
  144. getData() {
  145. let width, param, settings
  146. param = {
  147. type: this.protocolType,
  148. data: {
  149. DataSourceId: this.datasourceId,
  150. // "PageNumber": this.pages.currentPage || 1,
  151. // "PageSize": this.pages.size,
  152. }
  153. }
  154. queryPointRela(param, res => {
  155. let content = res.Content.map(item => {
  156. if(item.RelationList.length){
  157. item.Point.DataRuleType = item.RelationList[0].DataRuleType
  158. item.Point.PhysicalRelated = item.RelationList[0].EquipmentType + '-' + item.RelationList[0].InfomationPoint
  159. }
  160. return item
  161. })
  162. settings = {
  163. data: content,
  164. colHeaders: changeHeader(headerArr),
  165. columns: showTypes(headerArr).map(item => {
  166. item.readOnly = true
  167. item.data = 'Point.' + item.data
  168. return item
  169. }),
  170. rowHeights: 30,
  171. maxRows: res.Content.length
  172. }
  173. this.hot = this.$refs.handsontable.init(settings)
  174. this.pages.total = res.Total
  175. console.log(this.hot)
  176. })
  177. },
  178. //刷新数据
  179. refreshData() {
  180. this.getData()
  181. this.isEditDialogShow = false;
  182. }
  183. },
  184. components: {
  185. handsontableComponent,
  186. ownDialog,
  187. dialogMain,
  188. step3Edit,
  189. stepsMain,
  190. pagination
  191. }
  192. }
  193. </script>
  194. <style lang="scss" scoped>
  195. #handsonStep2 {
  196. flex: 1;
  197. display: flex;
  198. flex-flow:column;
  199. .btns-view {
  200. height: 40px;
  201. line-height: 40px;
  202. margin-bottom: 10px;
  203. }
  204. #handsontableSteps1 {
  205. flex: 1;
  206. overflow: hidden;
  207. position: relative;
  208. }
  209. }
  210. </style>