registerInfoDialog.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="签到信息"
  5. center
  6. :visible.sync="dialogVisible"
  7. width="70%"
  8. append-to-body
  9. top
  10. style="margin-top:100px"
  11. :close-on-click-modal="false"
  12. :show-close="true"
  13. :close-on-press-escape="false"
  14. >
  15. <div class="contain">
  16. <div class="selector">
  17. 签到状态:
  18. <el-select v-model="selectItem" placeholder="请选择" @change="onSelectorChange">
  19. <el-option
  20. v-for="item in ['全部','已签到','未签到','已补签']"
  21. :key="item"
  22. :label="item"
  23. :value="item"
  24. />
  25. </el-select>
  26. </div>
  27. <div class="table">
  28. <el-table :data="showPaperList">
  29. <el-table-column
  30. prop=""
  31. label="序号"
  32. type="index"
  33. width="100"
  34. :index="showIndex"
  35. />
  36. <el-table-column
  37. prop="ren_yuan_id_"
  38. label="应参训人员"
  39. width="150"
  40. >
  41. <template slot-scope="{row}">
  42. <ibps-user-selector
  43. type="user"
  44. :value="row.ren_yuan_id_"
  45. readonly-text="text"
  46. :disabled="true"
  47. :multiple="true"
  48. />
  49. </template>
  50. </el-table-column>
  51. <el-table-column
  52. prop="status"
  53. label="签到状态"
  54. width="150"
  55. >
  56. <template slot-scope="{row}">
  57. <el-tag :type="showType(row)">{{ row.status }}</el-tag>
  58. </template>
  59. </el-table-column>
  60. <el-table-column
  61. prop="qian_dao_shi_jian"
  62. label="签到时间"
  63. align="center"
  64. />
  65. </el-table>
  66. </div>
  67. <el-pagination
  68. style="margin-top: 5px; padding-bottom: 10px"
  69. :current-page="pagination.currentPage"
  70. :page-sizes="[10, 20,30, 50]"
  71. :page-size="pagination.pageSize"
  72. layout="prev,pager,next,jumper,sizes,->,total"
  73. :total="categoryList.length"
  74. @size-change="handleSizeChange"
  75. @current-change="handleCurrentChange"
  76. />
  77. </div>
  78. <span slot="footer" class="dialog-footer">
  79. <el-button @click="close">关 闭</el-button>
  80. </span>
  81. </el-dialog>
  82. </div>
  83. </template>
  84. <script>
  85. import ibpsUserSelector from '@/business/platform/org/selector'
  86. export default {
  87. components: {
  88. ibpsUserSelector
  89. },
  90. props: {
  91. visible: {
  92. type: Boolean,
  93. default: false
  94. },
  95. params: {
  96. type: Object,
  97. default: () => {
  98. return {}
  99. }
  100. }
  101. },
  102. data () {
  103. return {
  104. pagination: {
  105. pageSize: 10,
  106. currentPage: 1
  107. },
  108. dialogVisible: true,
  109. tableList: [],
  110. selectItem: '全部'
  111. }
  112. },
  113. computed: {
  114. categoryList () {
  115. const tempList = this.selectItem === '全部' ? this.tableList : this.tableList.filter(item => item.status === this.selectItem)
  116. return tempList
  117. },
  118. showPaperList () {
  119. const start = (this.pagination.currentPage - 1) * this.pagination.pageSize
  120. const end = start + this.pagination.pageSize
  121. return this.categoryList.slice(start, end)
  122. }
  123. },
  124. async mounted () {
  125. // console.log(this.params)
  126. await this.getAllPeople()
  127. },
  128. methods: {
  129. // 选择器切换
  130. onSelectorChange () {
  131. this.pagination = {
  132. pageSize: 10,
  133. currentPage: 1
  134. }
  135. },
  136. // tag 类型
  137. showType (row) {
  138. let type = ''
  139. switch (row.status) {
  140. case '已签到':
  141. type = 'success'
  142. break
  143. case '未签到':
  144. type = 'danger'
  145. break
  146. case '已补签':
  147. type = 'warning'
  148. break
  149. default:
  150. break
  151. }
  152. return type
  153. },
  154. // 手动签到的
  155. addPeople () {
  156. if (!this.params.addPeople) return
  157. this.params.addPeople.split(',').forEach(person => {
  158. const p = this.tableList.find(item => item.ren_yuan_id_ === person)
  159. if (!p) {
  160. this.tableList.push({
  161. ren_yuan_id_: person,
  162. status: '已签到'
  163. })
  164. } else {
  165. p.status = '已签到'
  166. }
  167. })
  168. },
  169. // 获取全部培训人员
  170. async getAllPeople () {
  171. const sql = `select * from t_rypxcjb where id_='${this.params.guan_lian_id_}'`
  172. const { variables: { data }} = await this.$common.request('sql', sql)
  173. if (data.length <= 0) {
  174. return this.$message.warning('数据异常!')
  175. }
  176. // console.log('全部人员', data)
  177. const peopleList = data[0].pei_xun_ren_yuan_?.split(',')
  178. peopleList.forEach(person => {
  179. if (person) {
  180. this.tableList.push({
  181. ren_yuan_id_: person,
  182. status: '未签到',
  183. qian_dao_shi_jian: ''
  184. })
  185. }
  186. })
  187. await this.getRegisterPeople()
  188. if (data[0].shi_fou_guo_shen_ === '进行中') {
  189. this.addPeople()
  190. }
  191. if (data[0].shi_fou_guo_shen_ === '已结束' && data[0].bu_qian_ren_yuan_) {
  192. data[0].bu_qian_ren_yuan_.split(',').forEach(person => {
  193. const p = this.tableList.find(item => item.ren_yuan_id_ === person)
  194. if (p) {
  195. p.status = '已补签'
  196. } else {
  197. this.tableList.push({
  198. ren_yuan_id_: person,
  199. status: '已补签',
  200. qian_dao_shi_jian: ''
  201. })
  202. }
  203. })
  204. }
  205. },
  206. // 获取已签到人员
  207. async getRegisterPeople () {
  208. const sql = `select * from t_qdxxb where guan_lian_id_='${this.params.guan_lian_id_}'`
  209. const { variables: { data }} = await this.$common.request('sql', sql)
  210. // console.log('已签到', data)
  211. data.forEach(person => {
  212. const p = this.tableList.find(item => item.ren_yuan_id_ === person.ren_yuan_id_)
  213. if (!p) {
  214. this.tableList.push({
  215. ren_yuan_id_: person.ren_yuan_id_,
  216. status: '已签到',
  217. qian_dao_shi_jian: person.qian_dao_shi_jian
  218. })
  219. } else {
  220. p.status = '已签到'
  221. p.qian_dao_shi_jian = person.qian_dao_shi_jian
  222. }
  223. })
  224. },
  225. // 当前页码改变
  226. handleCurrentChange (val) {
  227. this.pagination.currentPage = val
  228. },
  229. // 页码选择器改变
  230. handleSizeChange (val) {
  231. this.pagination.pageSize = val
  232. this.pagination.currentPage = 1
  233. },
  234. // 分页连续序号
  235. showIndex (index) {
  236. return index + 1 + (this.pagination.currentPage - 1) * this.pagination.pageSize
  237. },
  238. close () {
  239. this.dialogVisible = false
  240. }
  241. }
  242. }
  243. </script>
  244. <style lang="scss" scoped>
  245. .contain{
  246. padding: 20px;
  247. .table{
  248. height:440px;
  249. overflow: auto;
  250. margin-top: 20px;
  251. }
  252. }
  253. </style>