index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <div>
  3. <m-search :items="searchItems" v-model="searchValues" class="mb-3" @search="onSearch">
  4. <template #button>
  5. <el-upload class="el-button pa-0" action="#" :show-file-list="false" :http-request="onImport">
  6. <m-button type="primary" icon="el-icon-upload2" :loading="importLoading">导入手工数据</m-button>
  7. </el-upload>
  8. <m-button type="primary" icon="el-icon-download" :loading="downloadLoading" @click="onExport">导出手工数据模板</m-button>
  9. </template>
  10. </m-search>
  11. <m-table
  12. :items="items"
  13. :headers="headers"
  14. :loading="loading"
  15. :total="total"
  16. :page-size="pageInfo.size"
  17. :page-current="pageInfo.current"
  18. :row-class-name="rowClassName"
  19. @page-change="onPageChange"
  20. @expand-change="onExpandChange"
  21. >
  22. <template #expand="{ row }">
  23. <el-form label-position="left" inline class="demo-table-expand">
  24. <m-card shadow="nerve">
  25. <el-timeline>
  26. <el-timeline-item
  27. :hide-timestamp="true">
  28. <el-row>
  29. <el-col :span="4">月份</el-col>
  30. <el-col :span="4">绩效薪资</el-col>
  31. <el-col :span="4">数据来源</el-col>
  32. <el-col :span="4">写入时间</el-col>
  33. <el-col :span="4">操作</el-col>
  34. </el-row>
  35. </el-timeline-item>
  36. <el-timeline-item
  37. v-for="(list, index) in row.childrenList"
  38. :key="index"
  39. :hide-timestamp="true">
  40. <el-row>
  41. <el-col class="col" :span="4">{{ list.month }}</el-col>
  42. <el-col class="col" :span="4">{{ list.performanceSalary || '暂无' }}</el-col>
  43. <el-col class="col" :span="4">{{ list.dataType === 1 ? '手工录入' : '系统数据'}}</el-col>
  44. <el-col class="col" :span="4">{{ list.createDate }}</el-col>
  45. <el-col class="col" :span="4">
  46. <m-button v-if="checked" type="text" size="small" icon="el-icon-check" disabled>已使用当前版本</m-button>
  47. <m-button
  48. v-else
  49. type="primary"
  50. size="small"
  51. @click="onConfirm(list)"
  52. >确认使用该版本</m-button>
  53. </el-col>
  54. </el-row>
  55. </el-timeline-item>
  56. </el-timeline>
  57. </m-card>
  58. </el-form>
  59. </template>
  60. </m-table>
  61. </div>
  62. </template>
  63. <script>
  64. import {
  65. getComparisonPage,
  66. uploadComparisonTemplate,
  67. downloadComparisonTemplate,
  68. getComparisonByEmployee,
  69. getComparisonConfirm,
  70. confirmComparisonVersion
  71. } from '@/api/salary'
  72. import { dateFormat } from '@/utils/date'
  73. import { downloadFile } from '@/utils'
  74. export default {
  75. name: 'salary-employee-comparison',
  76. data () {
  77. return {
  78. expandRow: [],
  79. importLoading: false,
  80. downloadLoading: false,
  81. submitLoading: false,
  82. searchItems: [
  83. {
  84. label: '月份',
  85. prop: 'month',
  86. type: 'datePicker',
  87. option: {
  88. editable: false,
  89. clearable: false,
  90. placeholder: '请选择月份',
  91. type: 'month',
  92. valueFormat: 'yyyy-MM',
  93. format: 'yyyy 年 MM 月'
  94. }
  95. },
  96. { label: '部门', prop: 'organizationName', type: 'input', option: { placeholder: '请输入部门' } },
  97. { label: '姓名', prop: 'employeeName', type: 'input', option: { placeholder: '请输入姓名' } }
  98. ],
  99. searchValues: {
  100. month: dateFormat('YYYY-mm', new Date()),
  101. organizationName: null,
  102. employeeName: null
  103. },
  104. headers: [
  105. { type: 'expand', prop: 'expand' },
  106. { label: '机构', prop: 'organizationName' },
  107. { label: '姓名', prop: 'employeeName' },
  108. { label: '统一认证号', prop: 'unifiedCertificationNumber' },
  109. { label: '月份', prop: 'month' }
  110. // { label: '操作', prop: 'action', align: 'center', width: 100 }
  111. ],
  112. items: [
  113. ],
  114. loading: false,
  115. total: 0,
  116. pageInfo: {
  117. current: 1,
  118. size: 10
  119. },
  120. checked: false
  121. }
  122. },
  123. methods: {
  124. async onInit () {
  125. try {
  126. const { data } = await getComparisonPage({
  127. page: this.pageInfo,
  128. ...this.searchValues
  129. })
  130. // 确认是否已经确认方案
  131. const { data: _data } = await getComparisonConfirm({
  132. page: {
  133. size: 10,
  134. current: 1
  135. },
  136. month: this.searchValues.month
  137. })
  138. this.checked = _data.records[0]?.version ?? false
  139. this.items = data.records.map(e => {
  140. return {
  141. ...e,
  142. childrenList: []
  143. }
  144. })
  145. this.total = data.total
  146. } catch (error) {
  147. this.$message.error(error)
  148. }
  149. },
  150. rowClassName ({ row, rowIndex }) {
  151. return this.expandRow.includes(row.unifiedCertificationNumber) ? 'grey' : null
  152. },
  153. onSearch () {
  154. this.pageInfo.current = 1
  155. this.onInit()
  156. },
  157. async onImport (response) {
  158. this.importLoading = true
  159. const formData = new FormData()
  160. formData.append('file', response.file)
  161. try {
  162. await uploadComparisonTemplate(formData)
  163. this.$message.success('导入成功')
  164. this.onInit()
  165. } catch (error) {
  166. this.$message.error(error)
  167. } finally {
  168. this.importLoading = false
  169. }
  170. },
  171. async onExport () {
  172. this.downloadLoading = true
  173. try {
  174. const { data, name } = await downloadComparisonTemplate()
  175. downloadFile(data, name)
  176. } catch (error) {
  177. this.$message.error(error)
  178. } finally {
  179. this.downloadLoading = false
  180. }
  181. },
  182. async onExpandChange (row, expandedRows) {
  183. this.expandRow = expandedRows.map(e => e.unifiedCertificationNumber)
  184. if (row.childrenList.length) {
  185. return
  186. }
  187. try {
  188. const { data } = await getComparisonByEmployee({
  189. page: {
  190. size: 999,
  191. current: 1
  192. },
  193. entity: {
  194. unifiedCertificationNumber: row.unifiedCertificationNumber,
  195. month: row.month
  196. }
  197. })
  198. row.childrenList = data.records
  199. } catch (error) {
  200. this.$message.error(error)
  201. }
  202. },
  203. onConfirm (item) {
  204. const h = this.$createElement
  205. this.$confirm(h('div', null, [
  206. h('p', undefined, '确认后将无法修改,是否确认?'),
  207. h('p', { style: 'color: #ff5555' }, '注:版本确认之后所有人将同步使用当前选择的版本')
  208. ]), '提示', {
  209. confirmButtonText: '确定',
  210. cancelButtonText: '取消',
  211. type: 'warning'
  212. }).then(async () => {
  213. try {
  214. await confirmComparisonVersion({
  215. employeePerformanceConfirmation: {
  216. month: item.month,
  217. version: item.version
  218. }
  219. })
  220. this.$message.success('确认成功')
  221. this.checked = true
  222. } catch (error) {
  223. this.$message.error(error)
  224. }
  225. }).catch(_ => {})
  226. },
  227. onSubmit () {
  228. this.submitLoading = true
  229. },
  230. onPageChange (page) {
  231. this.pageInfo.current = page
  232. this.onInit()
  233. }
  234. }
  235. }
  236. </script>
  237. <style lang="scss" scoped>
  238. .col {
  239. height: 32px;
  240. line-height: 30px;
  241. }
  242. ::v-deep .grey {
  243. background-color: #f0f0f0;
  244. }
  245. </style>