find_keyword.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <div class="view-find-word">
  3. <div class="saga-border" style="position:relative;">
  4. <p class="center">请从下面的原始点位描述中选择"{{type == 'type' ? "设备类型" : "设备参数"}}"关键字</p>
  5. <div style="position:absolute;top: 0;right: 20px;">
  6. <el-switch
  7. @change="changeType(type)"
  8. v-model="isSwitch">
  9. </el-switch>
  10. AI辅助
  11. </div>
  12. <div class="h10"></div>
  13. <div>
  14. <cut-string v-if="!!Description" :string="Description" :closedStr="closedStr" ref="cutString"></cut-string>
  15. <p v-else class="center">已处理到最后一条</p>
  16. </div>
  17. <div class="h10"></div>
  18. <div class="center">
  19. <el-button type="primary" :disabled="!Description" @click="noWatch">此条无法识别</el-button>
  20. <el-button type="primary" :disabled="!Description" @click="getCutString">继续发现关键字</el-button>
  21. </div>
  22. <div class="h10"></div>
  23. </div>
  24. <div class="h10"></div>
  25. <div class="find-data">
  26. <div class="left-view saga-border">
  27. <doughnut v-if="!!sum" :sum="sum" type="left" :name="dataName" width="200" height="200" :renderData="echartsData"></doughnut>
  28. <div v-else class="center">
  29. <i class="iconwushuju iconfont"></i>
  30. 暂无数据
  31. </div>
  32. </div>
  33. <div class="right-view saga-border">
  34. <div class="find-tags" v-for="(tag,index) in tagList" :key="index">
  35. <el-tag :key="type == 'type' ? tag.EquipmentType : tag.EquipmentParameter" @click="changeName(type == 'type' ? tag.EquipmentType : tag.EquipmentParameter)" @close="closeTag(type == 'type' ? tag.EquipmentType : tag.EquipmentParameter)" closable>
  36. {{type == 'type' ? (tag.EquipmentType + "(" + tag.PointCount + ")") : (tag.EquipmentParameter + "(" + tag.PointCount + ")")}}
  37. </el-tag>
  38. </div>
  39. </div>
  40. </div>
  41. <my-dialog :dialogVisible="reNameDialog" @confirm="reNameConfirm" :footer="footer" @cancel="cancel" title="重命名" :isAppendBody="true">
  42. <h3 class="center">{{name}}</h3>
  43. <el-input v-model="newName" placeholder="请输入新名称"></el-input>
  44. </my-dialog>
  45. </div>
  46. </template>
  47. <script>
  48. import cutString from "@/components/config_point/cut_string"
  49. import doughnut from "@/components/echarts/doughnut"
  50. import myDialog from "@/components/el_pack/dialog"
  51. import {
  52. findKeysWord,
  53. findKeysWordType,
  54. queryDataSourceCount,
  55. queryEqTypeList,
  56. queryEqParamList,
  57. renameType,
  58. renameParam,
  59. setParamTer,
  60. setTypeTer,
  61. delParamTer,
  62. delTypeTer,
  63. updatePoint
  64. } from "@/fetch/point_http"
  65. import {
  66. mapGetters,
  67. mapActions
  68. } from "vuex";
  69. export default {
  70. props: {
  71. type: {
  72. type: String,
  73. default: "type", //arguments or type
  74. }
  75. },
  76. computed: {
  77. ...mapGetters("project", [
  78. "projectId",
  79. "datasourceId",
  80. "protocolType"
  81. ])
  82. },
  83. components: {
  84. cutString,
  85. doughnut,
  86. myDialog
  87. },
  88. data() {
  89. return {
  90. title: "",
  91. Description: "",
  92. echartsData: [],
  93. sum: 0,
  94. tagList: [],
  95. reNameDialog: false,
  96. name: "",
  97. newName: "",
  98. footer: {
  99. cancel: "取消",
  100. confirm: "确定"
  101. },
  102. Id: "",
  103. dataName: "",
  104. isSwitch: false,//是否开启开关
  105. closedStr: "",//已被选择的数据
  106. }
  107. },
  108. created() {},
  109. mounted() {},
  110. methods: {
  111. //继续发现关键字
  112. getCutString() {
  113. // console.log(this.$refs.cutString.getData())
  114. if (!this.$refs.cutString.getData()) {
  115. this.$message.error("请确定当前有选择关键字")
  116. return false
  117. }
  118. let setNameFun;
  119. if (this.type == "type") {
  120. setNameFun = setTypeTer
  121. } else {
  122. setNameFun = setParamTer
  123. }
  124. setNameFun({
  125. data: {
  126. DataSourceId: this.datasourceId,
  127. Key: this.$refs.cutString.getData()
  128. },
  129. type: this.protocolType
  130. }, res => {
  131. this.$message.success("添加成功")
  132. this.changeType()
  133. })
  134. },
  135. //取消
  136. cancel() {
  137. this.reNameDialog = false
  138. },
  139. //关闭标签(删除)
  140. closeTag(tag) {
  141. // console.log(tag)
  142. let delFun;
  143. if (this.type == "type") {
  144. delFun = delTypeTer
  145. } else {
  146. delFun = delParamTer
  147. }
  148. let param = {
  149. data: {
  150. DataSourceId: this.datasourceId,
  151. Key: this.type == "type" ? tag : tag
  152. },
  153. type: this.protocolType
  154. }
  155. this.$confirm("你确定删除该标签?").then(_ => {
  156. this.delAjax(param, delFun)
  157. }).catch(_ => {
  158. })
  159. },
  160. delAjax(param, fun) {
  161. fun(param, res => {
  162. this.$message.success("删除标签成功")
  163. this.changeType()
  164. })
  165. },
  166. //点击事件,重命名
  167. changeName(tag) {
  168. this.reNameDialog = true
  169. this.newName = ""
  170. if (this.type == "type") {
  171. this.name = tag
  172. } else {
  173. this.name = tag
  174. }
  175. },
  176. //确定修改名字
  177. reNameConfirm() {
  178. let reNameFun;
  179. if (this.type == "type") {
  180. reNameFun = renameType
  181. } else {
  182. reNameFun = renameParam
  183. }
  184. reNameFun({
  185. data: {
  186. DataSourceId: this.datasourceId,
  187. KeyNew: this.newName,
  188. KeyOld: this.name
  189. },
  190. type: this.protocolType
  191. }, res => {
  192. this.$message.success("修改成功")
  193. this.changeType()
  194. this.cancel()
  195. })
  196. },
  197. //获取文字
  198. changeType(type) {
  199. let queryFun
  200. this.type = !!type ? type : this.type
  201. if (this.type == "type") {
  202. queryFun = findKeysWordType
  203. } else {
  204. queryFun = findKeysWord
  205. }
  206. queryFun({
  207. data: {
  208. DataSourceId: this.datasourceId,
  209. ProjectId: this.projectId,
  210. Ai: this.isSwitch
  211. },
  212. type: this.protocolType
  213. }, res => {
  214. if (!!res.Content.length) {
  215. this.Description = res.Content[0].Description
  216. //默认已经选择的关键字
  217. if(this.type == "type"){
  218. this.closedStr = res.Content[0].KeyEquipmentParameter || ''
  219. }else{
  220. this.closedStr = res.Content[0].KeyEquipmentType || ''
  221. }
  222. this.Id = res.Content[0].PointId
  223. //清空已选择的数据
  224. this.$nextTick(_ => {
  225. this.$refs.cutString.clear()
  226. })
  227. } else {
  228. this.Description = ""
  229. }
  230. })
  231. this.getDataForSource()
  232. this.getbeenFoundList()
  233. },
  234. //查询数据源数据
  235. getDataForSource() {
  236. queryDataSourceCount({
  237. Filters: {
  238. Id: this.datasourceId
  239. }
  240. }, res => {
  241. let data = res.Content[0]
  242. this.dataName = res.Content[0].Name
  243. this.echartsData = [{
  244. name: "无法识别:" + (this.type != 'type' ? data.Equipmentparameterignorestandard : data.Equipmenttypeignorestandard),
  245. value: (this.type != 'type' ? data.Equipmentparameterignorestandard : data.Equipmenttypeignorestandard)
  246. },
  247. {
  248. name: "未识别:" + (this.type != 'type' ? data.Equipmentparameternotstandard : data.Equipmenttypenotstandard),
  249. value: (this.type != 'type' ? data.Equipmentparameternotstandard : data.Equipmenttypenotstandard)
  250. },
  251. {
  252. name: "已识别:" + (this.type != 'type' ? data.Equipmentparameterstandard : data.Equipmenttypestandard),
  253. value: (this.type != 'type' ? data.Equipmentparameterstandard : data.Equipmenttypestandard)
  254. }
  255. ]
  256. this.sum = data.Used
  257. })
  258. },
  259. //查询标签列表
  260. getbeenFoundList() {
  261. let getListFetch;
  262. if (this.type == "type") {
  263. getListFetch = queryEqTypeList
  264. } else {
  265. getListFetch = queryEqParamList
  266. }
  267. // console.log(getListFetch)
  268. getListFetch({
  269. data: {
  270. ProjectId: this.projectId,
  271. DataSourceId: this.datasourceId
  272. },
  273. type: this.protocolType
  274. }, res => {
  275. // console.log(res, 'getListFetch')
  276. this.tagList = res.Content
  277. })
  278. },
  279. noWatch(){
  280. console.log()
  281. let param = {
  282. data: {
  283. Content: [
  284. {
  285. Id: this.Id,
  286. [this.type == 'type' ? 'IgnoreKeyEquipmentType' : 'IgnoreKeyEquipmentParameter']: true
  287. }
  288. ]
  289. },
  290. type: this.protocolType
  291. }
  292. updatePoint(param,res => {
  293. console.log(res)
  294. this.$message.success("设置无法识别成功")
  295. this.changeType()
  296. })
  297. }
  298. },
  299. watch:{
  300. }
  301. }
  302. </script>
  303. <style lang="scss" scoped>
  304. .view-find-word {
  305. .find-data {
  306. height: 300px;
  307. .left-view {
  308. width: 300px;
  309. height: 300px;
  310. display: inline-block;
  311. }
  312. .right-view {
  313. width: calc(100% - 305px);
  314. padding: 5px;
  315. box-sizing: border-box;
  316. height: 300px;
  317. overflow-y: auto;
  318. float: right;
  319. }
  320. }
  321. .h10 {
  322. height: 10px;
  323. }
  324. .find-tags {
  325. display: inline-block;
  326. margin: 8px;
  327. }
  328. }
  329. </style>