find_keyword.vue 10 KB

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