step2.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <div id="handsonStep2">
  3. <div class="btns-view">
  4. <el-button>AI自动识别</el-button>
  5. <el-button @click="discern(1)">批量识别设备类型关键字</el-button>
  6. <el-button @click="discern(2)">批量识别设备参数关键字</el-button>
  7. <el-button @click="examine">检查&微调</el-button>
  8. <el-button>刷新</el-button>
  9. <el-button @click="saveData">保存</el-button>
  10. </div>
  11. <div id="handsontableSteps1">
  12. <handsontable-component ref="handsontable"></handsontable-component>
  13. </div>
  14. <own-dialog :width="'60%'" :title="title" :dialogVisible="isDialogShow" @cancel="close">
  15. <find-keyword ref="findKeyword" :type="type" @change="changeHand"></find-keyword>
  16. </own-dialog>
  17. <own-dialog :width="'1000px'" :index="true" title="关键内容设别——检查&微调" :dialogVisible="examineDialog" @cancel="close">
  18. <!-- <find-keyword ref="findKeyword" :type="type"></find-keyword> -->
  19. <examine-main></examine-main>
  20. </own-dialog>
  21. </div>
  22. </template>
  23. <script>
  24. import handsontableComponent from "components/common/handsontable"
  25. import examineMain from "components/config_point/examine_main"
  26. import headerArr from "utils/point_edit/steps2.js"
  27. import {
  28. changeHeader,
  29. showTypes
  30. } from "utils/handsontable/delType"
  31. import ownDialog from "components/el_pack/dialog"
  32. import {
  33. mapGetters,
  34. mapActions
  35. } from "vuex";
  36. import {
  37. queryPoint,
  38. updatePoint
  39. } from "fetch/point_http"
  40. import findKeyword from "components/config_point/find_keyword"
  41. export default {
  42. data() {
  43. return {
  44. checked: false,
  45. settings: {},
  46. isDialogShow: false,
  47. msg: "",
  48. hot: null,
  49. title: "",
  50. type: "",
  51. examineDialog: false,
  52. changeFlag: true,
  53. }
  54. },
  55. created() {
  56. if (!this.protocolType) {
  57. this.$router.push({
  58. path: "/configPoint"
  59. })
  60. }
  61. },
  62. mounted() {
  63. this.getData()
  64. },
  65. computed: {
  66. ...mapGetters("project", [
  67. "projectId",
  68. "datasourceId",
  69. "protocolType"
  70. ])
  71. },
  72. methods: {
  73. /**
  74. * @param num 代表着1类型2参数
  75. *
  76. */
  77. discern(num) {
  78. if (num == 1) {
  79. this.title = "关键内同识别——批量识别设备类型关键字"
  80. this.type = "type"
  81. } else if (num == 2) {
  82. this.title = "关键内同识别——批量识别设备参数关键字"
  83. this.type = "arguments"
  84. }
  85. this.isChangeData()
  86. this.isDialogShow = true
  87. this.$nextTick(() => {
  88. this.$refs.findKeyword.changeType()
  89. })
  90. },
  91. close() {
  92. this.isDialogShow = false
  93. this.examineDialog = false
  94. this.isChangeData()
  95. },
  96. //判断是否修改,修改调用修改接口,否则调用获取最新数据
  97. isChangeData(){
  98. if (!this.changeFlag) {
  99. this.saveData(false)
  100. } else {
  101. this.getData()
  102. }
  103. },
  104. //点击检查按钮
  105. examine() {
  106. this.isChangeData()
  107. this.examineDialog = true
  108. },
  109. //保存
  110. saveData(falg) {
  111. if (!!this.hot) {
  112. console.log(this.hot.getSourceData())
  113. let data = this.hot.getSourceData(),
  114. changeData;
  115. changeData = data.map(item => {
  116. return {
  117. Id: item.Id,
  118. DatasourceId: item.DatasourceId,
  119. ProjectId: item.ProjectId,
  120. Description: item.Description || null,
  121. KeyEquipmentParameter: item.KeyEquipmentParameter || null,
  122. Remarks: item.Remarks || null,
  123. LocationFlag: item.LocationFlag || null,
  124. KeyEquipmentType: item.KeyEquipmentType || null
  125. }
  126. })
  127. console.log(changeData)
  128. updatePoint({
  129. data: {
  130. Content: changeData
  131. },
  132. type: this.protocolType
  133. }, res => {
  134. console.log(res)
  135. if (!falg) {
  136. this.$message.success("保存成功")
  137. }
  138. this.getData()
  139. })
  140. } else {
  141. this.$message.error("请确保存在数据")
  142. }
  143. },
  144. //发生更改
  145. changeHand(changeData, source) {
  146. if (!!changeData) {
  147. this.changeFlag = false
  148. }
  149. return false
  150. },
  151. //获取初始数据
  152. getData() {
  153. let width, param, settings
  154. width = (document.getElementById("app").clientWidth - 50) / headerArr.length
  155. param = {
  156. type: this.protocolType,
  157. data: {
  158. Filters: {
  159. DatasourceId: this.datasourceId,
  160. },
  161. "PageNumber": 1,
  162. "PageSize": 50,
  163. }
  164. }
  165. queryPoint(param, res => {
  166. console.log(res)
  167. settings = {
  168. data: res.Content,
  169. colHeaders: changeHeader(headerArr),
  170. columns: showTypes(headerArr),
  171. colWidths: width,
  172. rowHeights: 30,
  173. maxRows: res.Content.length
  174. }
  175. this.hot = this.$refs.handsontable.init(settings)
  176. console.log(this.hot)
  177. })
  178. },
  179. noSaveData() {
  180. return this.changeFlag
  181. }
  182. },
  183. components: {
  184. handsontableComponent,
  185. ownDialog,
  186. findKeyword,
  187. examineMain
  188. }
  189. }
  190. </script>
  191. <style lang="scss" scoped>
  192. #handsonStep2 {
  193. height: 100%;
  194. .btns-view {
  195. height: 50px;
  196. vertical-align: middle;
  197. }
  198. #handsontableSteps1 {
  199. height: calc(100% - 50px);
  200. overflow: hidden;
  201. position: relative;
  202. }
  203. }
  204. </style>