find_keyword.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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. ProjectId: this.projectId,
  213. Ai: this.isSwitch
  214. },
  215. type: this.protocolType
  216. }, res => {
  217. if (!!res.Content.length) {
  218. this.Description = res.Content[0].Description
  219. //默认已经选择的关键字
  220. if(this.type == "type"){
  221. this.closedStr = res.Content[0].KeyEquipmentParameter || ''
  222. this.aiStr = res.Content[0].KeyEquipmentType || ''
  223. }else{
  224. this.closedStr = res.Content[0].KeyEquipmentType || ''
  225. this.aiStr = res.Content[0].KeyEquipmentParameter || ''
  226. }
  227. this.Id = res.Content[0].PointId
  228. //清空已选择的数据
  229. this.$nextTick(_ => {
  230. this.$refs.cutString.clear(this.aiStr)
  231. })
  232. } else {
  233. this.Description = ""
  234. }
  235. })
  236. this.getDataForSource()
  237. this.getbeenFoundList()
  238. },
  239. //查询数据源数据
  240. getDataForSource() {
  241. queryDataSourceCount({
  242. Filters: {
  243. Id: this.datasourceId
  244. }
  245. }, res => {
  246. let data = res.Content[0]
  247. this.dataName = res.Content[0].Name
  248. this.echartsData = [
  249. {
  250. name: "已识别:" + (this.type != 'type' ? data.Equipmentparameterstandard : data.Equipmenttypestandard),
  251. value: (this.type != 'type' ? data.Equipmentparameterstandard : data.Equipmenttypestandard)
  252. },
  253. {
  254. name: "未识别:" + (this.type != 'type' ? data.Equipmentparameternotstandard : data.Equipmenttypenotstandard),
  255. value: (this.type != 'type' ? data.Equipmentparameternotstandard : data.Equipmenttypenotstandard)
  256. },
  257. {
  258. name: "无法识别:" + (this.type != 'type' ? data.Equipmentparameterignorestandard : data.Equipmenttypeignorestandard),
  259. value: (this.type != 'type' ? data.Equipmentparameterignorestandard : data.Equipmenttypeignorestandard)
  260. },
  261. ]
  262. this.sum = data.Used
  263. })
  264. },
  265. //查询标签列表
  266. getbeenFoundList() {
  267. let getListFetch;
  268. if (this.type == "type") {
  269. getListFetch = queryEqTypeList
  270. } else {
  271. getListFetch = queryEqParamList
  272. }
  273. // console.log(getListFetch)
  274. getListFetch({
  275. data: {
  276. ProjectId: this.projectId,
  277. DataSourceId: this.datasourceId
  278. },
  279. type: this.protocolType
  280. }, res => {
  281. // console.log(res, 'getListFetch')
  282. this.tagList = res.Content
  283. })
  284. },
  285. noWatch(){
  286. console.log()
  287. let param = {
  288. data: {
  289. Content: [
  290. {
  291. Id: this.Id,
  292. [this.type == 'type' ? 'IgnoreKeyEquipmentType' : 'IgnoreKeyEquipmentParameter']: true
  293. }
  294. ]
  295. },
  296. type: this.protocolType
  297. }
  298. updatePoint(param,res => {
  299. console.log(res)
  300. this.$message.success("设置无法识别成功")
  301. this.changeType()
  302. })
  303. }
  304. },
  305. watch:{
  306. }
  307. }
  308. </script>
  309. <style lang="scss" scoped>
  310. .view-find-word {
  311. .find-data {
  312. height: 300px;
  313. .left-view {
  314. width: 300px;
  315. height: 300px;
  316. display: inline-block;
  317. }
  318. .right-view {
  319. width: calc(100% - 305px);
  320. padding: 5px;
  321. box-sizing: border-box;
  322. height: 300px;
  323. overflow-y: auto;
  324. float: right;
  325. }
  326. }
  327. .h10 {
  328. height: 10px;
  329. }
  330. .find-tags {
  331. display: inline-block;
  332. margin: 8px;
  333. }
  334. }
  335. </style>