find_keyword.vue 12 KB

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