riskPeopleTable.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <div class="paper-table">
  3. <el-table
  4. ref="elTable"
  5. :data="tableList"
  6. border
  7. stripe
  8. highlight-current-row
  9. header-row-class-name="exam-table-header"
  10. style="width: 100%"
  11. class="exam-table"
  12. >
  13. <el-table-column label="序号" type="index" width="80" />
  14. <el-table-column prop="bian_zhi_ren_" label="评估人" width="100">
  15. <template slot-scope="{ row }">
  16. <ibps-user-selector
  17. type="user"
  18. :value="row.bian_zhi_ren_"
  19. readonly-text="text"
  20. :disabled="true"
  21. :multiple="false"
  22. />
  23. </template>
  24. </el-table-column>
  25. <el-table-column prop="bian_zhi_bu_men_" label="部门" width="140">
  26. <template slot-scope="{ row }">
  27. <ibps-user-selector
  28. type="position"
  29. :value="row.bian_zhi_bu_men_"
  30. readonly-text="text"
  31. :disabled="true"
  32. :multiple="false"
  33. />
  34. </template>
  35. </el-table-column>
  36. <el-table-column prop="feng_xian_shu_" label="风险数" width="80" />
  37. <el-table-column prop="feng_xian_c_" label="风险等级分布情况" />
  38. <el-table-column prop="shi_fou_guo_shen_" label="识别状态" width="140">
  39. <template slot-scope="{ row }">
  40. <el-tag
  41. :type="row.shi_fou_guo_shen_ === '已完成' ? 'success' : 'danger'"
  42. >{{ row.shi_fou_guo_shen_ }}</el-tag
  43. >
  44. </template>
  45. </el-table-column>
  46. <el-table-column prop="" label="操作" width="200">
  47. <template slot-scope="{ row }">
  48. <el-button
  49. v-if="isZuZhang"
  50. type="primary"
  51. size="mini"
  52. :disabled="
  53. row.shi_fou_guo_shen_ !== '已完成' ||
  54. (params && params.shi_fou_guo_shen_ === '已完成')
  55. "
  56. @click="goBack(row)"
  57. >退回</el-button
  58. >
  59. <el-button type="primary" size="mini" @click="goDetail(row)"
  60. >详情</el-button
  61. >
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. <RiskDetail ref="RiskDetailRef" :cul-ways="culWays" />
  66. </div>
  67. </template>
  68. <script>
  69. import ibpsUserSelector from '@/business/platform/org/selector'
  70. import RiskDetail from './riskDetail.vue'
  71. import sortableJs from '@/mixins/sortable'
  72. export default {
  73. components: {
  74. ibpsUserSelector,
  75. RiskDetail
  76. },
  77. mixins: [sortableJs],
  78. props: {
  79. params: {
  80. type: Object,
  81. default: () => ({})
  82. },
  83. peopleIds: {
  84. type: String,
  85. default: ''
  86. },
  87. culWays: {
  88. type: Object,
  89. default: () => ({})
  90. }
  91. },
  92. data() {
  93. const { userId } = this.$store.getters
  94. return {
  95. tableList: [],
  96. detail: [],
  97. isZuZhang: false,
  98. userId: userId,
  99. sortable: null
  100. }
  101. },
  102. watch: {
  103. peopleIds: {
  104. handler(val) {
  105. this.getPeopleList()
  106. }
  107. // immediate: true
  108. }
  109. },
  110. mounted() {
  111. this.getPeopleList()
  112. // this.initSortable()
  113. },
  114. methods: {
  115. sortableEnd(evt) {
  116. const { oldIndex, newIndex } = evt
  117. // 处理数据交换
  118. const currRow = this.tableList.splice(oldIndex, 1)[0]
  119. this.tableList.splice(newIndex, 0, currRow)
  120. console.log('排序已变更', this.tableList)
  121. },
  122. // 获取人员部门
  123. getPersonPosition(id) {
  124. const userList = this.$store.getters.userList
  125. const bianzhiUserid = userList.find((i) => i.userId === id)
  126. if (bianzhiUserid) {
  127. return bianzhiUserid.positionId
  128. }
  129. },
  130. getPersonStatus(id) {
  131. const tempList = this.detail.filter((i) => i.bian_zhi_ren_ === id)
  132. if (tempList.length) {
  133. return tempList.every((i) => i.shi_fou_guo_shen_ === '已完成')
  134. ? '已完成'
  135. : '未完成'
  136. } else {
  137. return '未完成'
  138. }
  139. },
  140. getRiskCount(id) {
  141. const tempList = this.detail.filter((i) => i.bian_zhi_ren_ === id)
  142. if (tempList.length) return tempList.length
  143. },
  144. getRiskCategory(id) {
  145. const tempList = this.detail.filter((i) => i.bian_zhi_ren_ === id)
  146. if (tempList.length) {
  147. const myMap = new Map()
  148. tempList.forEach((item) => {
  149. const category = item.feng_xian_deng_ji
  150. if (!myMap.has(category)) {
  151. myMap.set(category, 0)
  152. }
  153. myMap.set(category, myMap.get(category) + 1)
  154. })
  155. let result = ''
  156. myMap.forEach((value, key) => {
  157. result += `${key}:${value || 0};`
  158. })
  159. return result
  160. }
  161. },
  162. async getPeopleList() {
  163. // console.log('zi', data)
  164. // this.tableList = data
  165. this.isZuZhang = this.userId === this.params.zu_chang_id_
  166. if (this.peopleIds) {
  167. // const sql = `select * from t_fxsbpgb2 where parent_id_='${this.params.id_}'`
  168. const {
  169. variables: { data }
  170. } = await this.$common.request('query', {
  171. key: 'getFxsbpgb2ByPid',
  172. params: [this.params.id_]
  173. })
  174. this.detail = data
  175. // console.log(data)
  176. const people = this.peopleIds.split(',')
  177. if (people.length > 0) {
  178. this.tableList = people.map((item) => {
  179. return {
  180. bian_zhi_ren_: item,
  181. bian_zhi_bu_men_:
  182. this.detail.find((i) => i.bian_zhi_ren_ === item)
  183. ?.bian_zhi_bu_men_ || this.getPersonPosition(item),
  184. shi_fou_guo_shen_: this.getPersonStatus(item),
  185. feng_xian_shu_: this.getRiskCount(item),
  186. feng_xian_c_: this.getRiskCategory(item)
  187. }
  188. })
  189. }
  190. }
  191. },
  192. goDetail(row) {
  193. this.$refs.RiskDetailRef.open(this.params, row)
  194. },
  195. goBack(row) {
  196. this.$confirm('退回操作后评估人可再次修改识别项,是否继续?', '提示', {
  197. confirmButtonText: '继续',
  198. cancelButtonText: '取消',
  199. type: 'warning'
  200. })
  201. .then(async () => {
  202. const params = {
  203. tableName: 't_fxsbpgb2',
  204. updList: [
  205. {
  206. where: {
  207. bian_zhi_ren_: row.bian_zhi_ren_,
  208. parent_id_: this.params.id_
  209. },
  210. param: {
  211. shi_fou_guo_shen_: '编制中'
  212. }
  213. }
  214. ]
  215. }
  216. console.log(params)
  217. await this.$common.request('update', params)
  218. // 发消息给评估人退回消息
  219. await this.$common.sendMsg({
  220. subject: '风险评估与措施表单退回提醒',
  221. content: `您有一份评估与措施表单已退回,请前往-风险控制-风险评估与措施页面重新提交,计划编号:${this.params.ji_hua_bian_hao_},组长:${this.params.zu_chang_}。`,
  222. receiverId: row.bian_zhi_ren_,
  223. canreplay: '0',
  224. skipTypeMsg: JSON.stringify({
  225. skipType: 3,
  226. pathInfo: '/tygl/fxkzV2/fxpgycslb' // 路由
  227. })
  228. })
  229. console.log('退回提醒成功')
  230. console.log('退回成功')
  231. this.$message({
  232. type: 'success',
  233. message: '退回成功!'
  234. })
  235. this.$emit('goBack')
  236. })
  237. .catch(() => {})
  238. }
  239. }
  240. }
  241. </script>
  242. <style lang="scss" scoped></style>