find_keyword.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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. aiStr: "",//ai推荐
  103. Id: "",
  104. dataName: "",
  105. isSwitch: false,//是否开启开关
  106. closedStr: "",//已被选择的数据
  107. }
  108. },
  109. created() {},
  110. mounted() {},
  111. methods: {
  112. //继续发现关键字
  113. getCutString() {
  114. // console.log(this.$refs.cutString.getData())
  115. if (!this.$refs.cutString.getData()) {
  116. this.$message.error("请确定当前有选择关键字")
  117. return false
  118. }
  119. let setNameFun;
  120. if (this.type == "type") {
  121. setNameFun = setTypeTer
  122. } else {
  123. setNameFun = setParamTer
  124. }
  125. setNameFun({
  126. data: {
  127. DataSourceId: this.datasourceId,
  128. Key: this.$refs.cutString.getData()
  129. },
  130. type: this.protocolType
  131. }, res => {
  132. this.$message.success("添加成功")
  133. this.changeType()
  134. })
  135. },
  136. //取消
  137. cancel() {
  138. this.reNameDialog = false
  139. },
  140. //关闭标签(删除)
  141. closeTag(tag) {
  142. // console.log(tag)
  143. let delFun;
  144. if (this.type == "type") {
  145. delFun = delTypeTer
  146. } else {
  147. delFun = delParamTer
  148. }
  149. let param = {
  150. data: {
  151. DataSourceId: this.datasourceId,
  152. Key: this.type == "type" ? tag : tag
  153. },
  154. type: this.protocolType
  155. }
  156. this.$confirm("你确定删除该标签?").then(_ => {
  157. this.delAjax(param, delFun)
  158. }).catch(_ => {
  159. })
  160. },
  161. delAjax(param, fun) {
  162. fun(param, res => {
  163. this.$message.success("删除标签成功")
  164. this.changeType()
  165. })
  166. },
  167. //点击事件,重命名
  168. changeName(tag) {
  169. this.reNameDialog = true
  170. this.newName = ""
  171. if (this.type == "type") {
  172. this.name = tag
  173. } else {
  174. this.name = tag
  175. }
  176. },
  177. //确定修改名字
  178. reNameConfirm() {
  179. let reNameFun;
  180. if (this.type == "type") {
  181. reNameFun = renameType
  182. } else {
  183. reNameFun = renameParam
  184. }
  185. reNameFun({
  186. data: {
  187. DataSourceId: this.datasourceId,
  188. KeyNew: this.newName,
  189. KeyOld: this.name
  190. },
  191. type: this.protocolType
  192. }, res => {
  193. this.$message.success("修改成功")
  194. this.changeType()
  195. this.cancel()
  196. })
  197. },
  198. //获取文字
  199. changeType(type) {
  200. let queryFun
  201. this.type = !!type ? type : this.type
  202. if (this.type == "type") {
  203. queryFun = findKeysWordType
  204. } else {
  205. queryFun = findKeysWord
  206. }
  207. queryFun({
  208. data: {
  209. DataSourceId: this.datasourceId,
  210. ProjectId: this.projectId,
  211. Ai: this.isSwitch
  212. },
  213. type: this.protocolType
  214. }, res => {
  215. if (!!res.Content.length) {
  216. this.Description = res.Content[0].Description
  217. //默认已经选择的关键字
  218. if(this.type == "type"){
  219. this.closedStr = res.Content[0].KeyEquipmentParameter || ''
  220. this.aiStr = res.Content[0].KeyEquipmentType || ''
  221. }else{
  222. this.closedStr = res.Content[0].KeyEquipmentType || ''
  223. this.aiStr = res.Content[0].KeyEquipmentParameter || ''
  224. }
  225. this.Id = res.Content[0].PointId
  226. //清空已选择的数据
  227. this.$nextTick(_ => {
  228. this.$refs.cutString.clear(this.aiStr)
  229. })
  230. } else {
  231. this.Description = ""
  232. }
  233. })
  234. this.getDataForSource()
  235. this.getbeenFoundList()
  236. },
  237. //查询数据源数据
  238. getDataForSource() {
  239. queryDataSourceCount({
  240. Filters: {
  241. Id: this.datasourceId
  242. }
  243. }, res => {
  244. let data = res.Content[0]
  245. this.dataName = res.Content[0].Name
  246. this.echartsData = [{
  247. name: "无法识别:" + (this.type != 'type' ? data.Equipmentparameterignorestandard : data.Equipmenttypeignorestandard),
  248. value: (this.type != 'type' ? data.Equipmentparameterignorestandard : data.Equipmenttypeignorestandard)
  249. },
  250. {
  251. name: "未识别:" + (this.type != 'type' ? data.Equipmentparameternotstandard : data.Equipmenttypenotstandard),
  252. value: (this.type != 'type' ? data.Equipmentparameternotstandard : data.Equipmenttypenotstandard)
  253. },
  254. {
  255. name: "已识别:" + (this.type != 'type' ? data.Equipmentparameterstandard : data.Equipmenttypestandard),
  256. value: (this.type != 'type' ? data.Equipmentparameterstandard : data.Equipmenttypestandard)
  257. }
  258. ]
  259. this.sum = data.Used
  260. })
  261. },
  262. //查询标签列表
  263. getbeenFoundList() {
  264. let getListFetch;
  265. if (this.type == "type") {
  266. getListFetch = queryEqTypeList
  267. } else {
  268. getListFetch = queryEqParamList
  269. }
  270. // console.log(getListFetch)
  271. getListFetch({
  272. data: {
  273. ProjectId: this.projectId,
  274. DataSourceId: this.datasourceId
  275. },
  276. type: this.protocolType
  277. }, res => {
  278. // console.log(res, 'getListFetch')
  279. this.tagList = res.Content
  280. })
  281. },
  282. noWatch(){
  283. console.log()
  284. let param = {
  285. data: {
  286. Content: [
  287. {
  288. Id: this.Id,
  289. [this.type == 'type' ? 'IgnoreKeyEquipmentType' : 'IgnoreKeyEquipmentParameter']: true
  290. }
  291. ]
  292. },
  293. type: this.protocolType
  294. }
  295. updatePoint(param,res => {
  296. console.log(res)
  297. this.$message.success("设置无法识别成功")
  298. this.changeType()
  299. })
  300. }
  301. },
  302. watch:{
  303. }
  304. }
  305. </script>
  306. <style lang="scss" scoped>
  307. .view-find-word {
  308. .find-data {
  309. height: 300px;
  310. .left-view {
  311. width: 300px;
  312. height: 300px;
  313. display: inline-block;
  314. }
  315. .right-view {
  316. width: calc(100% - 305px);
  317. padding: 5px;
  318. box-sizing: border-box;
  319. height: 300px;
  320. overflow-y: auto;
  321. float: right;
  322. }
  323. }
  324. .h10 {
  325. height: 10px;
  326. }
  327. .find-tags {
  328. display: inline-block;
  329. margin: 8px;
  330. }
  331. }
  332. </style>