step2.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <template>
  2. <div id="handsonStep2">
  3. <div class="btns-view">
  4. <el-button style="width:164px" @click="aiDiscern">AI自动识别</el-button>
  5. <el-button @click="discern(1)">批量识别设备类型关键字</el-button>
  6. <el-button @click="discern(2)">批量识别设备参数关键字</el-button>
  7. <el-button style="width:164px" @click="examine">检查&微调</el-button>
  8. <div style="float:right;">
  9. <el-button @click="reset">刷新</el-button>
  10. <el-button @click="saveData">保存</el-button>
  11. </div>
  12. </div>
  13. <div id="handsontableSteps1" class="middle_sty" v-loading="isLoading">
  14. <handsontable-component v-if="!!pages.total" @delete="delePoint" @mouseDown="clickTable" @change="changeHand" ref="handsontable"></handsontable-component>
  15. <div v-else class="center">
  16. <i class="iconwushuju iconfont"></i> 暂无数据
  17. </div>
  18. </div>
  19. <div class="right">
  20. <pagination :page="pages" @change="changePage"></pagination>
  21. </div>
  22. <own-dialog :width="'60%'" :title="title" :dialogVisible="isDialogShow" @cancel="close">
  23. <find-keyword ref="findKeyword" :type="type" @change="changeHand"></find-keyword>
  24. </own-dialog>
  25. <own-dialog :width="'1200px'" :index="true" title="关键内容设别——检查&微调" :dialogVisible="examineDialog" @cancel="close">
  26. <!-- <find-keyword ref="findKeyword" :type="type"></find-keyword> -->
  27. <examine-main></examine-main>
  28. </own-dialog>
  29. <!-- <own-dialog :width="'1000px'" :index="true" title="关键内容设别——检查&微调" :dialogVisible="examineDialog" @cancel="close"> -->
  30. <!-- <find-keyword ref="findKeyword" :type="type"></find-keyword> -->
  31. <!-- <examine-main></examine-main>
  32. </own-dialog> -->
  33. <own-dialog :width="'500px'" :index="true" title="位置标签" :dialogVisible="localtionDialog" @cancel="localFalgChange">
  34. <localtion-falg :renderData="renderData" @changeTag="changeLoc"></localtion-falg>
  35. </own-dialog>
  36. <own-dialog :width="'500px'" :footer="footer" :index="true" :escape="false" :isModel="false" title="AI自动识别" :dialogVisible="aiDialog" @confirm="isTrue" @cancel="aiClose">
  37. <!-- <localtion-falg :renderData="renderData" @changeTag="changeLoc"></localtion-falg> -->
  38. <el-progress v-if="hadTrue" :text-inside="true" :stroke-width="18" :percentage="usedNum"></el-progress>
  39. <div v-else>
  40. <p>确认要人工智能识别么?</p>
  41. </div>
  42. </own-dialog>
  43. </div>
  44. </template>
  45. <script>
  46. import handsontableComponent from "@/components/common/handsontable"
  47. import examineMain from "@/components/config_point/examine_main"
  48. import headerArr from "@/utils/point_edit/steps2.js"
  49. import localtionFalg from "@/components/config_point/location_flag"
  50. import {
  51. changeHeader,
  52. showTypes
  53. } from "@/utils/handsontable/delType"
  54. import ownDialog from "@/components/el_pack/dialog"
  55. import {
  56. mapGetters,
  57. mapActions
  58. } from "vuex";
  59. import {
  60. queryPoint,
  61. updatePoint,
  62. deletePoint,
  63. AIFindPoint,
  64. AIPlan
  65. } from "@/fetch/point_http"
  66. import findKeyword from "@/components/config_point/find_keyword"
  67. import pagination from "@/components/common/myPagination"
  68. export default {
  69. data() {
  70. return {
  71. checked: false,
  72. settings: {},
  73. isDialogShow: false,
  74. msg: "",
  75. hot: null,
  76. title: "",
  77. type: "",
  78. examineDialog: false,
  79. changeFlag: true,
  80. pages: {
  81. size: 50,
  82. sizes: [10, 30, 50, 100, 150, 200],
  83. total: 0,
  84. currentPage: 0
  85. },
  86. oldPage: {
  87. currentPage: 0,
  88. size: 10
  89. },
  90. localtionDialog: false,
  91. renderData: {},
  92. isLoading: false,
  93. aiDialog: false,
  94. hadTrue: false,//是否确定人工智能升级
  95. usedNum: 0,//识别百分比
  96. footer:{}
  97. }
  98. },
  99. created() {
  100. if (!this.protocolType) {
  101. this.$router.push({
  102. path: "/configPoint"
  103. })
  104. }
  105. },
  106. mounted() {
  107. this.getData()
  108. },
  109. computed: {
  110. ...mapGetters("project", [
  111. "projectId",
  112. "datasourceId",
  113. "protocolType"
  114. ])
  115. },
  116. methods: {
  117. clickTable(info, row) {
  118. // let activeCell = this.hot.getActiveEditor()
  119. // this.renderData = info
  120. // console.log(activeCell, 'activeCell')
  121. // if (activeCell.prop == "LocationFlag") {
  122. // this.localtionDialog = true
  123. // }
  124. },
  125. //人工智能识别
  126. aiDiscern(){
  127. // this.hadTrue = false
  128. // this.footer = {}
  129. // this.aiDialog = true
  130. },
  131. //确认人工识别
  132. isTrue(){
  133. console.log("222")
  134. AIFindPoint({
  135. data: {
  136. DataSourceId: this.datasourceId
  137. },
  138. type: this.protocolType
  139. },res => {
  140. this.timer = setInterval(() => {
  141. this.getSchedule()
  142. }, 1000)
  143. this.hadTrue = true
  144. this.footer = null
  145. })
  146. },
  147. async getSchedule(){
  148. await AIPlan({
  149. type: this.protocolType,
  150. data: {
  151. DataSourceId: this.datasourceId
  152. }
  153. },res => {
  154. console.log(res)
  155. })
  156. },
  157. changeLoc(val) {
  158. this.renderData.LocationFlag = val
  159. this.changeFlag = false
  160. },
  161. //修改提示
  162. changeHand(changeData, source) {
  163. if (!!changeData) {
  164. this.changeFlag = false
  165. }
  166. return false
  167. },
  168. //关闭人工智能弹窗
  169. aiClose(){
  170. this.aiDialog = false
  171. },
  172. //刷新
  173. reset() {
  174. if (!this.changeFlag) {
  175. this.$confirm("表格数据尚未保存,确定刷新吗?").then(_ => {
  176. this.saveData()
  177. }).catch(_ => {
  178. this.pages.currentPage = this.oldPage.currentPage
  179. this.pages.size = this.oldPage.size
  180. this.getData()
  181. })
  182. } else {}
  183. },
  184. //删除点位
  185. delePoint(delData) {
  186. let param = {
  187. data: delData.map(item => {
  188. return item.Id
  189. }),
  190. type: this.protocolType
  191. }
  192. console.log(param, 'param')
  193. this.$confirm('你确定要删除点位吗?').then(_ => {
  194. console.log(param, 'param')
  195. deletePoint(param, res => {
  196. this.$message.success("删除成功")
  197. this.getData()
  198. })
  199. }).catch(_ => {
  200. this.$message("取消删除")
  201. this.getData()
  202. })
  203. },
  204. //页面发生更改
  205. changePage() {
  206. if (!this.changeFlag) {
  207. //发生更改,提示是否保存
  208. this.$confirm('存在数据未保存, 是否继续?', '提示', {
  209. confirmButtonText: '确定',
  210. cancelButtonText: '取消',
  211. type: 'warning'
  212. }).then(() => {
  213. this.getData()
  214. }).catch(() => {
  215. this.pages.currentPage = this.oldPage.currentPage
  216. this.pages.size = this.oldPage.size
  217. return false
  218. });
  219. } else {
  220. this.getData()
  221. }
  222. },
  223. /**
  224. * @param num 代表着1类型2参数
  225. *
  226. */
  227. discern(num) {
  228. if (num == 1) {
  229. this.title = "关键内容识别——批量识别设备类型关键字"
  230. this.type = "type"
  231. } else if (num == 2) {
  232. this.title = "关键内容识别——批量识别设备参数关键字"
  233. this.type = "arguments"
  234. }
  235. this.isChangeDo(this.dialogDo,this.elseDo,true)
  236. },
  237. isChangeDo(func,elseDo,falg = false){
  238. if (!this.changeFlag) {
  239. //发生更改,提示是否保存
  240. this.$confirm('存在数据未保存, 是否继续?', '提示', {
  241. confirmButtonText: '确定',
  242. cancelButtonText: '取消',
  243. type: 'warning'
  244. }).then(() => {
  245. func(falg)
  246. }).catch(() => {
  247. elseDo()
  248. });
  249. } else {
  250. func(falg)
  251. }
  252. },
  253. //否则
  254. elseDo(){
  255. this.pages.currentPage = this.oldPage.currentPage
  256. this.pages.size = this.oldPage.size
  257. return false
  258. },
  259. //处理弹窗
  260. dialogDo(flag){
  261. if(!!flag && !this.changeFlag){
  262. this.changeFlag = !this.changeFlag
  263. }
  264. this.isDialogShow = true
  265. this.$nextTick(() => {
  266. this.$refs.findKeyword.changeType(this.type)
  267. })
  268. },
  269. close() {
  270. this.isDialogShow = false
  271. this.examineDialog = false
  272. this.isChangeData()
  273. },
  274. localFalgChange() {
  275. this.localtionDialog = false
  276. },
  277. //判断是否修改,修改调用修改接口,否则调用获取最新数据
  278. isChangeData() {
  279. if (!this.changeFlag) {
  280. this.saveData(false)
  281. } else {
  282. this.getData()
  283. }
  284. },
  285. //点击检查按钮
  286. examine() {
  287. this.isChangeDo(this.examineTrue,this.elseDo,true)
  288. },
  289. examineTrue(flag){
  290. if(!!flag && !this.changeFlag){
  291. this.changeFlag = !this.changeFlag
  292. }
  293. this.examineDialog = true
  294. },
  295. //保存
  296. saveData(falg) {
  297. if (!!this.hot) {
  298. let data = this.hot.getSourceData(),
  299. changeData;
  300. changeData = data.map(item => {
  301. return {
  302. Id: item.Id,
  303. DatasourceId: item.DatasourceId,
  304. ProjectId: item.ProjectId,
  305. Description: item.Description || null,
  306. KeyEquipmentParameter: item.KeyEquipmentParameter || null,
  307. Remarks: item.Remarks || null,
  308. LocationFlag: item.LocationFlag || null,
  309. KeyEquipmentType: item.KeyEquipmentType || null
  310. }
  311. })
  312. updatePoint({
  313. data: {
  314. Content: changeData
  315. },
  316. type: this.protocolType
  317. }, res => {
  318. console.log(res)
  319. if (!falg) {
  320. this.$message.success("保存成功")
  321. }
  322. this.getData()
  323. })
  324. } else {
  325. this.$message.error("请确保存在数据")
  326. }
  327. },
  328. //发生更改
  329. changeHand(changeData, source) {
  330. console.log(changeData, source)
  331. if (!!changeData) {
  332. this.changeFlag = false
  333. }
  334. return false
  335. },
  336. //获取初始数据
  337. getData() {
  338. this.isLoading = true
  339. let width, param, settings
  340. // width = (document.getElementById("app").clientWidth - 50) / headerArr.length
  341. param = {
  342. type: this.protocolType,
  343. data: {
  344. Filters: {
  345. DatasourceId: this.datasourceId,
  346. Used: true
  347. },
  348. "PageNumber": this.pages.currentPage || 1,
  349. "PageSize": this.pages.size,
  350. }
  351. }
  352. this.oldPage = {
  353. size: this.pages.size,
  354. currentPage: this.pages.currentPage
  355. }
  356. queryPoint(param, res => {
  357. console.log(res)
  358. settings = {
  359. data: res.Content,
  360. colHeaders: changeHeader(headerArr),
  361. columns: showTypes(headerArr),
  362. // colWidths: width,
  363. rowHeights: 30,
  364. maxRows: res.Content.length,
  365. contextMenu: {
  366. items: {
  367. remove_row: {
  368. name: "删除点位"
  369. }
  370. }
  371. }
  372. }
  373. this.pages.total = res.Total
  374. this.isLoading = false
  375. if (!this.pages.total) {
  376. return false
  377. }
  378. this.$nextTick(_ => {
  379. this.hot = this.$refs.handsontable.init(settings)
  380. })
  381. console.log(this.hot)
  382. })
  383. },
  384. noSaveData() {
  385. return this.changeFlag
  386. }
  387. },
  388. components: {
  389. handsontableComponent,
  390. ownDialog,
  391. findKeyword,
  392. examineMain,
  393. pagination,
  394. localtionFalg
  395. }
  396. }
  397. </script>
  398. <style lang="scss" scoped>
  399. #handsonStep2 {
  400. flex: 1;
  401. display: flex;
  402. flex-flow: column;
  403. .btns-view {
  404. height: 40px;
  405. line-height: 40px;
  406. margin-bottom: 10px;
  407. padding: 0 10px;
  408. }
  409. #handsontableSteps1 {
  410. flex: 1;
  411. overflow: hidden;
  412. position: relative;
  413. margin: 0 10px;
  414. }
  415. }
  416. </style>