step3.vue 8.4 KB

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