period.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. <template>
  2. <div v-loading="loading">
  3. <div class="white-box">
  4. <div class="filter-box">
  5. <filter-user :filter-types.sync="filterTypes" :filter-btn-name="$t('common.screen')"
  6. @select-value="handleFilterUser"></filter-user><!-- Select -->
  7. </div>
  8. <el-table :data="tableData" stripe style="width: 100%;" @selection-change="handleSelectionChange"
  9. :height="tool.getTableHeight()">
  10. <el-table-column prop="PERIOD_NUM" :label="$t('bonus.periodNo')" width="100"><!-- 期数 -->
  11. <template slot-scope="scope">
  12. <el-tag type="" size="small" class="no-border">{{scope.row.PERIOD_NUM}}</el-tag>
  13. </template>
  14. </el-table-column>
  15. <el-table-column :label="$t('bonus.bonusMonth')" width="110"><!-- 结算月 -->
  16. <template slot-scope="scope">
  17. <el-tag type="warning" size="small" class="no-border">{{ scope.row.CALC_YEAR_MONTH }}
  18. </el-tag>
  19. </template>
  20. </el-table-column>
  21. <el-table-column :label="$t('bonus.settlementDate')" width="230"><!-- 结算时间 -->
  22. <template slot-scope="scope">
  23. {{ getWatTime(scope.row.CALCULATED_AT) }}
  24. </template>
  25. </el-table-column>
  26. <el-table-column :label="$t('bonus.networkConnectionTime')" width="230"><!-- 挂网时间 -->
  27. <template slot-scope="scope">
  28. {{getWatTime(scope.row.SENT_AT)}}
  29. </template>
  30. </el-table-column>
  31. <el-table-column :fixed="fixed" :label="$t('common.action')" width=""><!-- 操作 -->
  32. <template slot-scope="scope">
  33. <!-- 计算 -->
  34. <el-button v-if="scope.row.IS_CAN_CALC" class="button" type="primary" size="small" @click.native="calcHandle(scope.row.PERIOD_NUM)">{{ $t('bonus.calculationOfBonus') }}</el-button>
  35. <!-- 挂网 -->
  36. <el-button @click.native="sentHandle(scope.row)" type="danger" class="button" size="small" v-if="scope.row.IS_CAN_SENT && permission.hasPermission(`bonus/send-period`)">
  37. {{ $t('bonus.spreadNet') }}
  38. </el-button>
  39. <!-- 日志 -->
  40. <el-button v-if="scope.row.IS_SHOW_LOG" class="button" type="info" size="small" @click.native="getDialogData(scope.row.PERIOD_NUM);dialogLoading=true;" >{{$t('bonus.logRefresh')}}</el-button>
  41. <!-- <el-row><el-button class="button" type="primary" @click.native="autoPerfHandle(currentPeriod)" >计算和拉取期业绩</el-button></el-row>-->
  42. <!-- <div>-->
  43. <!-- <el-table :data="dialogData" height="550" v-loading="dialogLoading" style="width: 100%">-->
  44. <!-- <el-table-column prop="CREATED_AT" :label="$t('bonus.actionTime')" width="180">-->
  45. <!-- <template slot-scope="scope">-->
  46. <!-- {{getWatTime(scope.row.CREATED_AT)}}-->
  47. <!-- </template>-->
  48. <!-- </el-table-column>-->
  49. <!-- <el-table-column prop="TEXT" :label="$t('bonus.logContent')" width="650"></el-table-column>-->
  50. <!-- </el-table>-->
  51. <!-- </div>-->
  52. <!-- </el-dialog>-->
  53. </template>
  54. </el-table-column>
  55. </el-table>
  56. <div class="white-box-footer">
  57. <el-button type="primary" size="small" @click="doAutoWithdraw()">
  58. {{$t('bonus.bulkWithdrawal')}}
  59. </el-button>
  60. <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange"></pagination>
  61. </div>
  62. </div>
  63. </div>
  64. </template>
  65. <script>
  66. import Vue from 'vue'
  67. import tool from './../../utils/tool'
  68. import store from '@/utils/vuexStore'
  69. import FilterUser from '@/components/FilterUser'
  70. import permission from '@/utils/permission'
  71. import Pagination from '@/components/Pagination'
  72. import filterHelper from '../../utils/filterHelper'
  73. import { fetchPeriod,fetchAutoWithdraw,fetchRecordList,fetchAutoCalc,fetchPerfOrderList,fetchInitData,fetchCalcPerfPeriod,fetchPullPerfPeriod,fetchCalcBonus,fetchSyncCalcRecord,fetchPullBonus,fetchClosePeriod,fetchCalcPeriod,fetchPerfPeriod,fetchSendPeriod } from '@/api/bonus'
  74. import ElementUI from 'element-ui'
  75. import {getScreenWidth} from "@/utils";
  76. export default {
  77. name: 'bonus-period',
  78. components: {FilterUser, Pagination},
  79. created () {
  80. const wsServer = 'ws://127.0.0.1:9513'
  81. console.log(wsServer)
  82. let webSocket = new WebSocket(wsServer)
  83. webSocket.onopen = function (evt) {
  84. let userId = userInfo.userId()
  85. let sendData = {app: 'admin', userId: userId}
  86. webSocket.send(JSON.stringify(sendData))
  87. }
  88. webSocket.onmessage = (env) => {
  89. let data = JSON.parse(env.data)
  90. if (data.handle === 'adminAsyncPercent') {
  91. this.onMessageCallback(data)
  92. }
  93. }
  94. },
  95. mounted () {
  96. this.getData(this.currentPage, this.pageSize)
  97. // store.state.socket.onMessageCallback = this.onMessageCallback
  98. },
  99. data () {
  100. return {
  101. currentPeriod: 0,
  102. tableData: null,
  103. loading: true,
  104. multipleSelection: [],
  105. currentPage: 1,
  106. totalPages: 1,
  107. totalCount: 1,
  108. pageSize: 10,
  109. tool: tool,
  110. permission: permission,
  111. filterTypes: {
  112. 'periodNum': {isUserTable: false, name: this.$t('bonus.periodNum')}, // 期数
  113. 'year': {isUserTable: false, name: this.$t('bonus.year')}, // 所在结算年
  114. 'month': {isUserTable: false, name: this.$t('bonus.month')}, // 所在结算月
  115. 'startTime': {isUserTable: false, name: this.$t('bonus.startTime'), other: 'date'}, // 期数开始时间
  116. 'endTime': {isUserTable: false, name: this.$t('bonus.endTime'), other: 'date'}, // 期数结束时间
  117. 'closedAt': {isUserTable: false, name: this.$t('bonus.closedAt'), other: 'date'}, // 封期时间
  118. 'perfStartedAt': {isUserTable: false, name: this.$t('bonus.perfStartedAt'), other: 'date'}, // 生成业绩单开始时间
  119. 'perfedAt': {isUserTable: false, name: this.$t('bonus.perfedAt'), other: 'date'}, // 生成业绩单结束时间
  120. 'calStartedAt': {isUserTable: false, name: this.$t('bonus.calStartedAt'), other: 'date'}, // 结算开始时间
  121. 'calculatedAt': {isUserTable: false, name: this.$t('bonus.calculatedAt'), other: 'date'}, // 结算结束时间
  122. 'sendStartedAt': {isUserTable: false, name: this.$t('bonus.sendStartedAt'), other: 'date'}, // 挂网开始时间
  123. 'sentAt': {isUserTable: false, name: this.$t('bonus.sentAt'), other: 'date'} // 挂网结束时间
  124. },
  125. filterModel: {},
  126. percentList: {
  127. 'PERF_PERCENT': {},
  128. 'CALC_PERCENT': {},
  129. 'SENT_PERCENT': {}
  130. },
  131. dialogTableVisible: false,
  132. dialogData: null,
  133. currentDialogPage: 1,
  134. dialogPageSize: 100,
  135. dialogLoading: true,
  136. form: {
  137. name: '',
  138. region: '',
  139. date1: '',
  140. date2: '',
  141. delivery: false,
  142. type: [],
  143. resource: '',
  144. desc: ''
  145. },
  146. formLabelWidth: '120px',
  147. fixed: getScreenWidth() < 500 ? false : 'right',
  148. screenWidth: getScreenWidth() > 600 ? '600px' : getScreenWidth() + 'px',
  149. labelPosition: getScreenWidth() >= 600 ? 'right' : 'top',
  150. };
  151. },
  152. methods: {
  153. autoCalcHandle(currentPeriod) {
  154. this.$confirm(this.$t('bonus.autoSettlementHint'), this.$t('common.hint'), { // '确定对当前期进行结算操作?', '提示'
  155. confirmButtonText: this.$t('common.confirm'), // 确定
  156. cancelButtonText: this.$t('common.cancel'), // 取消
  157. type: 'warning'
  158. }).then(() => {
  159. // return network.getData(`calc/auto-calc/${currentPeriod}`)
  160. return fetchAutoCalc(currentPeriod)
  161. }).then(response => {
  162. this.$message({
  163. message: response.data,
  164. type: 'success'
  165. })
  166. this.getDialogData(this.currentPage, this.pageSize)
  167. }).catch((error) => {
  168. if(error !== 'cancel'){
  169. ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
  170. }
  171. })
  172. },
  173. perfOrderHandle(currentPeriod) {
  174. this.$confirm(this.$t('bonus.generatePerformanceOrderHint'), this.$t('common.hint'), { // '确定对当前期进行生成业绩单操作?', '提示'
  175. confirmButtonText: this.$t('common.confirm'), // 确定
  176. cancelButtonText: this.$t('common.cancel'), // 取消
  177. type: 'warning'
  178. }).then(() => {
  179. return fetchPerfOrderList(currentPeriod)
  180. }).then(response => {
  181. this.$message({
  182. message: response.data,
  183. type: 'success'
  184. })
  185. this.getDialogData(this.currentPage, this.pageSize)
  186. }).catch((error) => {
  187. if(error !== 'cancel'){
  188. ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
  189. }
  190. })
  191. },
  192. initDataHandle(currentPeriod) {
  193. this.$confirm(this.$t('bonus.generatePerformanceSheetHint'), this.$t('common.hint'), { // '确定对当前期进行生成业绩单操作?', '提示'
  194. confirmButtonText: this.$t('common.confirm'), // 确定
  195. cancelButtonText: this.$t('common.cancel'), // 取消
  196. type: 'warning'
  197. }).then(() => {
  198. return fetchInitData(currentPeriod)
  199. }).then(response => {
  200. this.$message({
  201. message: response.data,
  202. type: 'success'
  203. })
  204. this.getDialogData(this.currentPage, this.pageSize)
  205. }).catch((error) => {
  206. if(error !== 'cancel'){
  207. ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
  208. }
  209. })
  210. },
  211. perfPeriodHandle(currentPeriod) {
  212. this.$confirm(this.$t('bonus.generatePerformanceSheetHint'), this.$t('common.hint'), { // '确定对当前期进行生成业绩单操作?', '提示'
  213. confirmButtonText: this.$t('common.confirm'), // 确定
  214. cancelButtonText: this.$t('common.cancel'), // 取消
  215. type: 'warning'
  216. }).then(() => {
  217. return fetchCalcPerfPeriod(currentPeriod)
  218. }).then(response => {
  219. this.$message({
  220. message: response.data,
  221. type: 'success'
  222. })
  223. this.getDialogData(this.currentPage, this.pageSize)
  224. }).catch((error) => {
  225. if(error !== 'cancel'){
  226. ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
  227. }
  228. })
  229. },
  230. pullPerfPeriodHandle(currentPeriod) {
  231. this.$confirm(this.$t('bonus.pullPerformanceSheetHint'), this.$t('common.hint'), { // '确定对当前期进行生成业绩单操作?', '提示'
  232. confirmButtonText: this.$t('common.confirm'), // 确定
  233. cancelButtonText: this.$t('common.cancel'), // 取消
  234. type: 'warning'
  235. }).then(() => {
  236. return fetchPullPerfPeriod(currentPeriod)
  237. }).then(response => {
  238. this.$message({
  239. message: response.data,
  240. type: 'success'
  241. })
  242. this.getDialogData(this.currentPage, this.pageSize)
  243. }).catch((error) => {
  244. if(error !== 'cancel'){
  245. ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
  246. }
  247. })
  248. },
  249. calcBonusHandle(currentPeriod) {
  250. this.$confirm(this.$t('bonus.calculateBonusDataHint'), this.$t('common.hint'), { // '确定对当前期进行生成业绩单操作?', '提示'
  251. confirmButtonText: this.$t('common.confirm'), // 确定
  252. cancelButtonText: this.$t('common.cancel'), // 取消
  253. type: 'warning'
  254. }).then(() => {
  255. return fetchCalcBonus(currentPeriod)
  256. }).then(response => {
  257. this.$message({
  258. message: response.data,
  259. type: 'success'
  260. })
  261. this.getDialogData(this.currentPage, this.pageSize)
  262. }).catch((error) => {
  263. if(error !== 'cancel'){
  264. ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
  265. }
  266. })
  267. },
  268. calcBonusRecordHandle(currentPeriod) {
  269. this.$confirm(this.$t('bonus.syncCalculateBonusRecordHint'), this.$t('common.hint'), { // '确定对当前期进行生成业绩单操作?', '提示'
  270. confirmButtonText: this.$t('common.confirm'), // 确定
  271. cancelButtonText: this.$t('common.cancel'), // 取消
  272. type: 'warning'
  273. }).then(() => {
  274. return fetchSyncCalcRecord(currentPeriod)
  275. }).then(response => {
  276. this.$message({
  277. message: response.data,
  278. type: 'success'
  279. })
  280. this.getDialogData(this.currentPage, this.pageSize)
  281. }).catch((error) => {
  282. if(error !== 'cancel'){
  283. ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
  284. }
  285. })
  286. },
  287. pullBonusHandle(currentPeriod) {
  288. this.$confirm(this.$t('bonus.calculateBonusDataHint'), this.$t('common.hint'), { // '确定对当前期进行生成业绩单操作?', '提示'
  289. confirmButtonText: this.$t('common.confirm'), // 确定
  290. cancelButtonText: this.$t('common.cancel'), // 取消
  291. type: 'warning'
  292. }).then(() => {
  293. return fetchPullBonus(currentPeriod)
  294. }).then(response => {
  295. this.$message({
  296. message: response.data,
  297. type: 'success'
  298. })
  299. this.getDialogData(this.currentPage, this.pageSize)
  300. }).catch((error) => {
  301. if(error !== 'cancel'){
  302. ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
  303. }
  304. })
  305. },
  306. // trialCalcHandle (currentPeriod) {
  307. // this.$confirm('Confirm to calculate bonus data for the current period?', this.$t('common.hint'), { // '确定对当前期进行生成业绩单操作?', '提示'
  308. // confirmButtonText: this.$t('common.confirm'), // 确定
  309. // cancelButtonText: this.$t('common.cancel'), // 取消
  310. // type: 'warning'
  311. // }).then(() => {
  312. // return network.getData(`calc/trial-calc/${currentPeriod}`)
  313. // }).then(response => {
  314. // this.$message({
  315. // message: response,
  316. // type: 'success'
  317. // })
  318. // this.getDialogData(this.currentPage, this.pageSize)
  319. // }).catch(response => {
  320. // })
  321. // },
  322. getDialogData (period) {
  323. let paramsData = {
  324. page: this.currentDialogPage,
  325. pageSize: this.dialogPageSize,
  326. }
  327. fetchRecordList(period, paramsData).then(response => {
  328. this.dialogData = response.data.list
  329. this.dialogLoading = false;
  330. })
  331. },
  332. closeHandle (row) {
  333. this.$confirm(this.$t('bonus.manuallySealHint'), this.$t('common.hint'), { // '确定对当前期进行手动封期操作?', '提示'
  334. confirmButtonText: this.$t('common.confirm'), // 确定
  335. cancelButtonText: this.$t('common.cancel'), // 取消
  336. type: 'warning'
  337. }).then(() => {
  338. return fetchClosePeriod(row.PERIOD_NUM)
  339. }).then(response => {
  340. this.$message({
  341. message: response.data,
  342. type: 'success'
  343. })
  344. this.getData(this.currentPage, this.pageSize)
  345. }).catch((error) => {
  346. if(error !== 'cancel'){
  347. ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
  348. }
  349. })
  350. },
  351. calcHandle (period) {
  352. this.$confirm(this.$t('bonus.performSettlementOperationHint'), this.$t('common.hint'), { // '确定对当前期进行结算操作?', '提示'
  353. confirmButtonText: this.$t('common.confirm'), // 确定
  354. cancelButtonText: this.$t('common.cancel'), // 取消
  355. type: 'warning'
  356. }).then(() => {
  357. return fetchCalcPeriod(period)
  358. }).then(response => {
  359. this.$message({
  360. message: response.data,
  361. type: 'success'
  362. })
  363. this.getData(this.currentPage, this.pageSize)
  364. }).catch((error) => {
  365. if(error !== 'cancel'){
  366. ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
  367. }
  368. })
  369. },
  370. perfHandle (row) {
  371. this.$confirm(this.$t('bonus.generatePerformanceSheetHint'), this.$t('common.hint'), { // '确定对当前期进行生成业绩单操作?', '提示'
  372. confirmButtonText: this.$t('common.confirm'), // 确定
  373. cancelButtonText: this.$t('common.cancel'), // 取消
  374. type: 'warning'
  375. }).then(() => {
  376. return fetchPerfPeriod(row.PERIOD_NUM)
  377. }).then(response => {
  378. this.$message({
  379. message: response.data,
  380. type: 'success'
  381. })
  382. this.getData(this.currentPage, this.pageSize)
  383. }).catch((error) => {
  384. if(error !== 'cancel'){
  385. ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
  386. }
  387. })
  388. },
  389. sentHandle (row) {
  390. this.$confirm(this.$t('bonus.spreadNetHint'), this.$t('common.hint'), { // '确定对当前期进行挂网操作?挂网后无法生成业绩单和结算', '提示'
  391. confirmButtonText: this.$t('common.confirm'), // 确定
  392. cancelButtonText: this.$t('common.cancel'), // 取消
  393. type: 'warning'
  394. }).then(() => {
  395. return fetchSendPeriod(row.PERIOD_NUM)
  396. }).then(response => {
  397. this.$message({
  398. message: response.data,
  399. type: 'success'
  400. })
  401. this.getData(this.currentPage, this.pageSize)
  402. }).catch((error) => {
  403. if(error !== 'cancel'){
  404. ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
  405. }
  406. })
  407. },
  408. doAutoWithdraw () {
  409. this.$confirm(this.$t('bonus.allWithdrawalHint'), this.$t('common.hint'), {
  410. confirmButtonText: this.$t('common.confirm'), // 确定
  411. cancelButtonText: this.$t('common.cancel'), // 取消
  412. type: 'warning'
  413. }).then(() => {
  414. //return network.getData(`bonus/auto-withdraw`)
  415. return fetchAutoWithdraw()
  416. }).then(response => {
  417. this.$message({
  418. message: response.data,
  419. type: 'success'
  420. })
  421. this.getData(this.currentPage, this.pageSize)
  422. }).catch(err => {
  423. this.$message({
  424. message: err,
  425. type: 'error'
  426. })
  427. })
  428. },
  429. viewHandle (row) {
  430. this.$router.push({path: `/bonus/period-detail/${row.PERIOD_NUM}`})
  431. },
  432. handleSelectionChange (val) {
  433. this.multipleSelection = val
  434. },
  435. handleCurrentChange (page) {
  436. this.getData(page, this.pageSize)
  437. },
  438. handleSizeChange (pageSize) {
  439. this.getData(this.currentPage, pageSize)
  440. },
  441. handleFilterUser (filterData) {
  442. filterHelper.handleFilterUser(this, filterData)
  443. },
  444. handleFilter () {
  445. this.getData()
  446. },
  447. getData (page, pageSize) {
  448. let filterData = this.filterModel
  449. const paramsData = Object.assign({
  450. page: (page === null || page === undefined) ? 1 : page,
  451. pageSize: (pageSize === null || pageSize === undefined) ? this.pageSize : pageSize
  452. }, filterData)
  453. // fetchPeriod(this, 'bonus/period', page, pageSize, filterData, function (response) {
  454. // vueObj.allData = response
  455. // }, null, ['PERF_PERCENT', 'CALC_PERCENT', 'SENT_PERCENT'])
  456. fetchPeriod(paramsData).then(response => {
  457. this.tableData = response.data.list
  458. this.tableHeaders = response.data.columnsShow ? response.data.columnsShow : []
  459. this.loading = false
  460. this.currentPage = page
  461. this.totalPages = parseInt(response.data.totalPages)
  462. this.totalCount = parseInt(response.data.totalCount)
  463. this.pageSize = pageSize
  464. this.allData = response
  465. },null, ['PERF_PERCENT', 'CALC_PERCENT', 'SENT_PERCENT'])
  466. },
  467. onMessageCallback (data) {
  468. if (data) {
  469. if (data.other && data.other.MODEL === 'PERIOD' && data.other.ID) {
  470. this.$set(this.percentList[data.other.FIELD], data.other.ID, data.percent)
  471. }
  472. if (data.other && data.other.MODEL === 'PERIOD' && data.percent === 100) {
  473. this.getData(this.currentPage, this.pageSize)
  474. }
  475. }
  476. },
  477. getWatTime (ts) {
  478. ts = parseInt(ts)
  479. if (ts) {
  480. return this.$moment(ts * 1000).utcOffset('+0100' ).format('YYYY-MM-DD HH:mm:ss')
  481. } else {
  482. return ''
  483. }
  484. }
  485. }
  486. }
  487. </script>
  488. <style>
  489. .button{
  490. margin-bottom: 10px;
  491. }
  492. .el-table__body {
  493. -webkit-border-horizontal-spacing: -30px;
  494. -webkit-border-vertical-spacing: -30px;
  495. }
  496. </style>
  497. <style scoped>
  498. .el-divider--horizontal {
  499. margin: 12px 0 !important;
  500. }
  501. @media (max-width:740px) {
  502. /deep/ .el-dialog__body {
  503. }
  504. }
  505. </style>>