kpi-service.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. import axios from '@/common/services/axios-instance'
  2. import { idText } from 'typescript'
  3. function extendNode(item, options = {}) {
  4. // 按穿梭组件的要求添加属性
  5. const type = item.props?.type?.startsWith('G') ? 'Group' : 'User'
  6. let code = item.id
  7. if (item.props.type === 'U') {
  8. code = item.props.account
  9. }
  10. item.title = item.text
  11. item.isLeaf = item.leaf
  12. item.code = code
  13. item.name = options.levPath && item.props?.levPath ? item.props.levPath : item.text
  14. item.type = type
  15. return item
  16. }
  17. class KpiService {
  18. // 查询是否已存在时间维度
  19. hasJobFrequency(params) {
  20. return axios({
  21. url: 'api/xcoa-mobile/v1/kpijobinfo/hasJobFrequency',
  22. method: 'post',
  23. data: params,
  24. }).then((res) => {
  25. return res.data
  26. })
  27. }
  28. // 获取所有因子指标
  29. getIndisByAttr(params) {
  30. return axios.post('api/xcoa-mobile/v1/kpi-indi-def/getIndisByAttr', params).then(function(res) {
  31. return res.data
  32. })
  33. }
  34. // 手动下发报送任务
  35. sendTask(params) {
  36. return axios({
  37. url: 'api/xcoa-mobile/v1/kpi-indi-task/sendTask',
  38. method: 'post',
  39. data: params,
  40. }).then((res) => {
  41. return res.data
  42. })
  43. }
  44. // 业务类型分类树
  45. getCategoryTree(parentId, treeparams, params) {
  46. return axios({
  47. url: `api/xcoa-mobile/v1/iam-tree/findTreeNodeById/${treeparams.configId}/${parentId}`,
  48. method: 'post',
  49. params,
  50. }).then((res) => {
  51. res.data.forEach((item) => (item.isLeaf = item.leaf))
  52. return res
  53. })
  54. }
  55. // 获取数据字典
  56. getDictionary(id) {
  57. return axios({
  58. url: 'api/xcoa-mobile/v1/iam-law/dictionary?key=' + id,
  59. method: 'get',
  60. }).then((res) => {
  61. return res.data
  62. })
  63. }
  64. // 指标定义-校验SQL
  65. validateSQL(params) {
  66. return axios({
  67. url: 'api/xcoa-mobile/v1/kpi-indi-def/validateSQL',
  68. method: 'post',
  69. data: params,
  70. }).then((res) => {
  71. return res.data
  72. })
  73. }
  74. // 指标定义-校验编号
  75. hasIndiNo(id, indiNo) {
  76. return axios({
  77. url: 'api/xcoa-mobile/v1/kpi-indi-def/hasIndiNo?id=' + id + '&indiNo=' + indiNo,
  78. method: 'get',
  79. }).then((res) => {
  80. return res.data
  81. })
  82. }
  83. // 获取报送人信息
  84. getSubmitterInfo(id, account) {
  85. return axios({
  86. url: 'api/xcoa-mobile/v1/kpi-indi-org/submitter-info?id=' + id + '&account=' + account,
  87. method: 'get',
  88. }).then((res) => {
  89. return res.data
  90. })
  91. }
  92. // 阈值参考单位选择
  93. getOrgsByIndiId(id) {
  94. return axios({
  95. url: 'api/xcoa-mobile/v1/kpi-indi-org/getOrgsByIndiId?id=' + id,
  96. method: 'get',
  97. }).then((res) => {
  98. return res.data
  99. })
  100. }
  101. // 校验监测单位是否本单位
  102. sameCompany(deptId, monitorDeptIds) {
  103. return axios({
  104. url:
  105. 'api/xcoa-mobile/v1/kpi-indi-org/sameCompany?deptId=' +
  106. deptId +
  107. '&monitorDeptIds=' +
  108. monitorDeptIds,
  109. method: 'get',
  110. }).then((res) => {
  111. return res.data
  112. })
  113. }
  114. // 获取指标报送任务明细
  115. findTaskDetailList(taskId) {
  116. return axios({
  117. url: 'api/xcoa-mobile/v1/kpi-inditaskdetail/list?taskId=' + taskId,
  118. method: 'get',
  119. }).then((res) => {
  120. return res.data
  121. })
  122. }
  123. // 指标报送任务-重新计算系统参考值
  124. getResetGuideVal(taskId) {
  125. return axios({
  126. url: 'api/xcoa-mobile/v1/kpi-inditaskdetail/getResetGuideVal?taskId=' + taskId,
  127. method: 'get',
  128. }).then((res) => {
  129. return res.data
  130. })
  131. }
  132. // 指标报送任务-计算指标结果值变更预警状态
  133. getIndiResult(redata) {
  134. return axios({
  135. url: 'api/xcoa-mobile/v1/kpi-inditaskdetail/getResetIndiResult',
  136. data: redata,
  137. method: 'post',
  138. }).then((res) => {
  139. return res.data
  140. })
  141. }
  142. // 指标监测图标数据
  143. getKpiMonitorlist(Id) {
  144. return axios({
  145. url: 'api/xcoa-mobile/v1/kpiindimonitor/getSevenIndiVal?indiId=' + Id,
  146. method: 'post',
  147. }).then((res) => {
  148. return res.data
  149. })
  150. }
  151. // 指标监测表格数据
  152. getKpiMonitortblist(Id) {
  153. return axios({
  154. url: 'api/xcoa-mobile/v1/kpiindimonitor/getIndiVal?indiId=' + Id,
  155. method: 'post',
  156. }).then((res) => {
  157. return res.data
  158. })
  159. }
  160. // 计算更新指标监控数据
  161. getResetIndiResult(indiIds) {
  162. return axios({
  163. url: 'api/xcoa-mobile/v1/kpiindimonitor/getResetIndiResult?indiIds=' + indiIds,
  164. method: 'get',
  165. }).then((res) => {
  166. return res.data
  167. })
  168. }
  169. // 机构选择器相关-增加过滤公司级定制
  170. getRootNode(params) {
  171. return axios // 获取部门下用户
  172. .get(`api/framework/v1/group-manager/group/root-node`, { params })
  173. .then((res) => [extendNode(res.data)])
  174. }
  175. getChildNodes(id, options = {}) {
  176. let type, isContainSub, hierarchical, levPath, secretLevel
  177. // 8.0.16后参数放到object里了,并且兼容之前的方式
  178. if (typeof arguments[1] === 'object') {
  179. ;({ type = 'GU', isContainSub = false, hierarchical, levPath, secretLevel } = options)
  180. } else {
  181. ;[id, type = 'GU', isContainSub = false, hierarchical, levPath] = arguments
  182. }
  183. const paramsU = {}
  184. const paramsD = {}
  185. paramsU.isContainSub = isContainSub
  186. paramsD.parent = id
  187. paramsD.lev = '1' // 过滤机构层级,1:是;0:否
  188. if (hierarchical === undefined) {
  189. hierarchical = ''
  190. } else if (hierarchical) {
  191. hierarchical = '1'
  192. } else {
  193. hierarchical = '0'
  194. }
  195. if (secretLevel) {
  196. paramsU.securityLevel = secretLevel
  197. }
  198. if (type === 'U') {
  199. return axios // 获取部门下用户
  200. .get(
  201. `api/framework/v1/user-manager/users/${id}/users?orderBy=${encodeURIComponent(
  202. 'weight asc,id asc'
  203. )}`,
  204. { params: { ...paramsU, hierarchical } }
  205. )
  206. .then((res) => res.data.map((item) => extendNode(item, { levPath })))
  207. } else {
  208. return axios // 获取部门下的部门
  209. .get(`api/xcoa-mobile/v1/kpi-indi-org/group/getChildren`, {
  210. params: { ...paramsD, hierarchical },
  211. })
  212. .then((res) => res.data.map((item) => extendNode(item, { levPath })))
  213. }
  214. }
  215. getFullPath(id) {
  216. return axios
  217. .get(`api/framework/v1/group-manager/groups/${id}/fullpath`)
  218. .then((res) => res.data.map((item) => extendNode(item)))
  219. }
  220. getGroupTree({ expandedKey, rootNode, hierarchical, levPath }) {
  221. if (rootNode && rootNode.code && rootNode.name) {
  222. rootNode = Promise.resolve([
  223. { text: rootNode.name, checkable: true, type: 'Group', isLeaf: false, ...rootNode },
  224. ])
  225. } else {
  226. rootNode = this.getRootNode({
  227. hierarchical: hierarchical === undefined ? '' : hierarchical ? '1' : '0',
  228. })
  229. }
  230. return rootNode.then((data) => {
  231. let p = Promise.resolve()
  232. if (expandedKey && expandedKey[0]) {
  233. // 设置了默认展开节点,获取每层树节点
  234. p = this.getFullPath(expandedKey[0]).then((items) => {
  235. if (!items.length) return
  236. const index = items.findIndex((item) => item.code === data[0].code)
  237. if (index !== -1) {
  238. // 根节点在fullpath路径里,从fullpath截取
  239. items.splice(index + 1, 99)
  240. } else {
  241. // 如果不是分级授权,路径信息里没有绝对根节点,这种情况下自己拼上根节点
  242. items = [...items, ...data]
  243. }
  244. const pArray = items.map((item) =>
  245. this.getChildNodes(item.code, {
  246. type: 'G',
  247. isContainSub: false,
  248. hierarchical,
  249. levPath,
  250. })
  251. )
  252. return Promise.all(pArray).then((items) => {
  253. const tree = items.reduce((a, b) => {
  254. // 通过fullpathId找到父节点
  255. if (a.length !== 0) {
  256. const node = b.find((item) => a[0].props.fullpathId.endsWith(item.code))
  257. if (node) node.children = a
  258. }
  259. return b
  260. })
  261. return tree
  262. })
  263. })
  264. }
  265. return p.then((tree) => {
  266. data[0].children = tree
  267. return data
  268. })
  269. })
  270. }
  271. // 获取预警指标数据
  272. getIndiMonitorsByIds(id) {
  273. return axios({
  274. url: 'api/xcoa-mobile/v1/kpiindimonitor/getIndiMonitorsByIds?ids=' + id,
  275. method: 'get',
  276. }).then((res) => {
  277. return res.data
  278. })
  279. }
  280. }
  281. export default new KpiService()