find_keyword.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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 :disabled="!Description" @click="getCutString">此条无法识别</el-button>
  13. <el-button :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" 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 in tagList">
  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. }
  92. },
  93. created() {},
  94. mounted() {},
  95. methods: {
  96. //继续发现关键字
  97. getCutString() {
  98. // console.log(this.$refs.cutString.getData())
  99. if (!this.$refs.cutString.getData()) {
  100. this.$message.error("请确定当前有选择关键字")
  101. return false
  102. }
  103. let setNameFun;
  104. if (this.type == "type") {
  105. setNameFun = setTypeTer
  106. } else {
  107. setNameFun = setParamTer
  108. }
  109. setNameFun({
  110. data: {
  111. DataSourceId: this.datasourceId,
  112. Key: this.$refs.cutString.getData()
  113. },
  114. type: this.protocolType
  115. }, res => {
  116. this.$message.success("添加成功")
  117. this.changeType()
  118. })
  119. },
  120. //取消
  121. cancel() {
  122. this.reNameDialog = false
  123. },
  124. //关闭标签(删除)
  125. closeTag(tag) {
  126. // console.log(tag)
  127. let delFun;
  128. if (this.type == "type") {
  129. delFun = delTypeTer
  130. } else {
  131. delFun = delParamTer
  132. }
  133. let param = {
  134. data: {
  135. DataSourceId: this.datasourceId,
  136. Key: this.type == "type" ? tag : tag
  137. },
  138. type: this.protocolType
  139. }
  140. this.$confirm("你确定删除该标签?").then(_ => {
  141. this.delAjax(param, delFun)
  142. }).catch(_ => {
  143. })
  144. },
  145. delAjax(param, fun) {
  146. fun(param, res => {
  147. this.$message.success("删除标签成功")
  148. this.changeType()
  149. })
  150. },
  151. //点击事件,重命名
  152. changeName(tag) {
  153. this.reNameDialog = true
  154. this.newName = ""
  155. if (this.type == "type") {
  156. this.name = tag
  157. } else {
  158. this.name = tag
  159. }
  160. },
  161. //确定修改名字
  162. reNameConfirm() {
  163. let reNameFun;
  164. if (this.type == "type") {
  165. reNameFun = renameType
  166. } else {
  167. reNameFun = renameParam
  168. }
  169. reNameFun({
  170. data: {
  171. DataSourceId: this.datasourceId,
  172. KeyNew: this.newName,
  173. KeyOld: this.name
  174. },
  175. type: this.protocolType
  176. }, res => {
  177. this.$message.success("修改成功")
  178. this.changeType()
  179. this.cancel()
  180. })
  181. },
  182. //获取文字
  183. changeType(type) {
  184. let queryFun
  185. this.type = !!type ? type : this.type
  186. console.log(this.type)
  187. if (this.type == "type") {
  188. queryFun = findKeysWordType
  189. } else {
  190. queryFun = findKeysWord
  191. }
  192. queryFun({
  193. data: {
  194. DataSourceId: this.datasourceId,
  195. ProjectId: this.projectId
  196. },
  197. type: this.protocolType
  198. }, res => {
  199. if (!!res.Content) {
  200. this.Description = res.Content.Description
  201. } else {
  202. this.Description = ""
  203. }
  204. // console.log(res)
  205. })
  206. this.getDataForSource()
  207. this.getbeenFoundList()
  208. },
  209. //查询数据源数据
  210. getDataForSource() {
  211. queryDataSourceCount({
  212. Filters: {
  213. Id: this.datasourceId
  214. }
  215. }, res => {
  216. let data = res.Content[0]
  217. this.echartsData = [{
  218. name: "无法识别-" + data.Ignorestandard,
  219. value: data.Ignorestandard
  220. },
  221. {
  222. name: "未识别-" + data.Notstandard,
  223. value: data.Notstandard
  224. },
  225. {
  226. name: "已识别-" + data.Notrelated,
  227. value: data.Notrelated
  228. }
  229. ]
  230. this.sum = data.Sum
  231. })
  232. },
  233. //查询标签列表
  234. getbeenFoundList() {
  235. let getListFetch;
  236. if (this.type == "type") {
  237. getListFetch = queryEqTypeList
  238. } else {
  239. getListFetch = queryEqParamList
  240. }
  241. // console.log(getListFetch)
  242. getListFetch({
  243. data: {
  244. ProjectId: this.projectId,
  245. DataSourceId: this.datasourceId
  246. },
  247. type: this.protocolType
  248. }, res => {
  249. // console.log(res, 'getListFetch')
  250. this.tagList = res.Content
  251. })
  252. }
  253. },
  254. watch:{
  255. }
  256. }
  257. </script>
  258. <style lang="scss" scoped>
  259. .view-find-word {
  260. .find-data {
  261. height: 300px;
  262. .left-view {
  263. width: 300px;
  264. height: 300px;
  265. display: inline-block;
  266. }
  267. .right-view {
  268. width: calc(100% - 305px);
  269. padding: 5px;
  270. box-sizing: border-box;
  271. height: 300px;
  272. overflow-y: auto;
  273. float: right;
  274. }
  275. }
  276. .h10 {
  277. height: 10px;
  278. }
  279. .find-tags {
  280. display: inline-block;
  281. margin: 8px;
  282. }
  283. }
  284. </style>