paylist.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <view class="pay">
  3. <view class="paybox">
  4. <!-- 历史工资 -->
  5. <view class="hisbox flexc mb15">
  6. <view class="line"></view>
  7. <view class="tit">工资条记录</view>
  8. <view class="hisbtn">
  9. <picker mode="date" fields ="month" :value="dateyear" @change="bindDateChangea">
  10. <view class="flexcc pl8">
  11. <view class=" f15 co6 f500" :style="'text-align:'+textAlign" v-if="dateyear">{{year}}年{{month}}月</view>
  12. <view class=" f15 co6 f500" :style="'text-align:'+textAlign" v-else>请选择日期</view>
  13. <image :src="aup"></image>
  14. </view>
  15. </picker>
  16. </view>
  17. </view>
  18. <view class="paybg payb flex1" style="overflow: hidden;">
  19. <zb-table
  20. ref="zbTable"
  21. :show-header="true"
  22. :columns="columns"
  23. :stripe="true"
  24. :pullUpLoading="pullUpLoading"
  25. :isShowLoadMore="reachflag"
  26. :fit="true"
  27. @rowClick="rowClick"
  28. @toggleRowSelection="toggleRowSelection"
  29. @toggleAllSelection="toggleAllSelection"
  30. :border="border"
  31. @edit="buttonEdit"
  32. @dele="dele"
  33. :data="list"></zb-table>
  34. </view>
  35. <view style="height: 80rpx;" v-if="checkPermi(['xiaoYuan:data:importData'])"></view>
  36. <view class="addbtn" @click="getAdd" v-if="checkPermi(['xiaoYuan:data:importData'])">导入工资</view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  42. import {getDictionaryFn} from '@/api/mine/register.js'
  43. import {getpayListFn,getpayDelFn} from '@/api/mine/payslip.js'
  44. import zbTable from "@/mine/components/zb-table/zb-tables.vue"
  45. export default {
  46. components:{
  47. zbTable
  48. },
  49. data(){
  50. return{
  51. pbg:require("@/work/static/pay/pbg.png"),
  52. aup:require("@/work/static/pay/aup.png"),
  53. pup:require("@/work/static/pay/pup.png"),
  54. noicon:require("@/work/static/pay/noicon.png"),
  55. columns:[],
  56. list: [],
  57. paymonth:{},//当月工资条
  58. nodataflag:false,//当月是否有工资
  59. pageSize: 20,
  60. pageNum: 1,
  61. reachflag: true,
  62. joinflag:false,
  63. wtdt: '',
  64. wagesList:[],//字典值
  65. date:'',
  66. textAlign:'center',
  67. border:false,
  68. year:'',//年
  69. month:'',//月
  70. dateyear:'',
  71. datemonth:'',
  72. flag1:true,
  73. }
  74. },
  75. onUnload(){
  76. uni.$off('refreshpayfile')
  77. },
  78. onLoad: function() {
  79. this.init()
  80. // this.time()
  81. this.getDataFn()
  82. uni.$on('refreshpayfile', (e) => {
  83. var that=this;
  84. that.reachflag=true;
  85. this.flag1=true;
  86. that.pageNum=1;
  87. that.list=[];
  88. that.getDataFn()
  89. })
  90. },
  91. methods:{
  92. checkPermi,checkRole,
  93. init(){
  94. // 工资条
  95. getDictionaryFn('wages').then(res=>{
  96. if(res.code==200){
  97. this.wagesList = res.data.map(v => {
  98. return {
  99. dictLabel: v.dictLabel,
  100. dictValue: v.dictValue
  101. }
  102. })
  103. this.getColumns(this.wagesList)
  104. }
  105. })
  106. },
  107. bindDateChangea(e){
  108. var val=e.detail.value.split('-')
  109. this.dateyear=e.detail.value;
  110. this.year=val[0];
  111. this.month=val[1];
  112. this.reachflag=true;
  113. this.pageNum=1;
  114. this.list=[];
  115. this.getDataFn()
  116. },
  117. bindDateChangeb(e){
  118. var val=e.detail.value
  119. this.reachflag=true;
  120. this.pageNum=1;
  121. this.list=[];
  122. this.getDataFn()
  123. },
  124. time() {
  125. var date = new Date();
  126. var y = date.getFullYear();
  127. var m = date.getMonth() + 1;
  128. this.year = y;
  129. this.month = m < 10 ? "0" + m : m;
  130. this.dateyear=y;
  131. this.getDataFn()
  132. },
  133. getColumns(info){
  134. var newArr=info;
  135. var narr=[];
  136. var column1=[];
  137. var s={ name: 'operation', type:'operation',label: '操作',
  138. renders:[
  139. // {name:'编辑',func:'edit'}, // func 代表子元素点击的事件 父元素接收的事件 父元素 @edit
  140. {name:'删除',type:'warn',func:"dele"},
  141. ]}
  142. Object.keys(newArr).some((key) => {
  143. var obj={};
  144. obj.name=newArr[key].dictLabel;
  145. obj.label=newArr[key].dictLabel;
  146. // obj.sorter=true
  147. obj.align='center'
  148. obj.width='70'
  149. obj.paddingRight=12;
  150. column1.push(obj)
  151. })
  152. if(checkPermi(['xiaoYuan:pay:remove'])){
  153. column1=column1.concat(s)
  154. }
  155. this.columns=JSON.parse(JSON.stringify(column1))
  156. },
  157. getAdd(){
  158. this.$tab.navigateTo('/mine/pages/payslip/format?type=add');
  159. },
  160. dele(e){
  161. var id=e.payId
  162. var idx=e.key;
  163. this.$modal.confirm('确定删除该条信息?').then(() => {
  164. getpayDelFn(id).then(res=>{
  165. if(res.code==200){
  166. this.$toast('删除成功')
  167. this.list.splice(idx,1)
  168. }else{
  169. this.$toast(res.msg)
  170. }
  171. })
  172. })
  173. },
  174. // 年
  175. getDataFn(a) {
  176. var params = {
  177. pageSize: this.pageSize,
  178. pageNum: this.pageNum,
  179. year:this.year,
  180. month:this.month,
  181. }
  182. // params['params[role]']=this.$store.state.user.choseroles
  183. getpayListFn(params).then(res => {
  184. this.flag1=true;
  185. if (res.code == 200) {
  186. if (res.data.size < this.pageSize) {
  187. this.reachflag = false
  188. this.wtdt = '到底了~';
  189. this.$refs.zbTable.pullUpCompleteLoading('ok')
  190. } else {
  191. var num = parseInt(res.data.size) + parseInt(this.pageSize) * parseInt(this.pageNum -1)
  192. if (num < res.data.total) {
  193. this.reachflag = true
  194. this.wtdt = '上拉加载更多'
  195. this.$refs.zbTable.pullUpCompleteLoading('')
  196. } else {
  197. this.reachflag = false
  198. this.wtdt = '到底了~';
  199. this.$refs.zbTable.pullUpCompleteLoading('ok')
  200. }
  201. }
  202. var data=res.data;
  203. if(data.records&&data.records.length){
  204. var paylist=data.records[0].tableDataJO
  205. if(paylist&&paylist.length){
  206. // 处理数据
  207. if (this.pageNum == 1) {
  208. this.list = paylist;
  209. } else {
  210. this.list = this.list.concat(paylist)
  211. }
  212. }
  213. }
  214. } else {
  215. this.$toast(res.msg)
  216. }
  217. })
  218. },
  219. pullUpLoading(done){
  220. if(!this.flag1){
  221. return
  222. }
  223. var that=this;
  224. this.flag1=false;
  225. setTimeout(()=>{
  226. that.pageNum++
  227. that.getDataFn()
  228. },100)
  229. },
  230. },
  231. }
  232. </script>
  233. <style lang="scss" scoped>
  234. .pay{
  235. .paytop{width: 100%;height: 300rpx;}
  236. .paybox{
  237. padding:30rpx 32rpx 0;position: relative;display: flex;flex-direction: column;height: 100vh;box-sizing: border-box;
  238. .pay_btn{width: 240rpx;height: 66rpx;background: rgba(0, 0, 0, 0.4);border-radius: 32rpx;
  239. font-size: 30rpx;font-weight: 500;color: #ECECEC;
  240. image{width: 18rpx;height: 10rpx;margin-left: 20rpx;}
  241. }
  242. .paybg{
  243. background: #FFFFFF;width: 100%;border-radius: 20rpx;
  244. &.paya{display: flex;align-items: center;flex-wrap: wrap;padding:16rpx 0 ;}
  245. &.payb{padding: 30rpx 24rpx 20rpx;min-height: 300rpx;box-sizing: border-box;}
  246. .paylist{width: 25%;display: flex;flex-direction: column;align-items: center;padding: 16rpx 0;
  247. .tit{font-size: 38rpx;color: #161616;font-weight: bold;margin-bottom: 6rpx;}
  248. .txt{font-size: 26rpx;color: #666666;}
  249. }
  250. &.payc{height: 388rpx;display: flex;flex-direction: column;align-items: center;justify-content: center;font-size: 26rpx;font-weight: 500;
  251. color: #AAAAAA;
  252. image{width: 232rpx;height: 168rpx;margin-bottom: 40rpx;}
  253. }
  254. }
  255. .hisbox{
  256. .line{width: 10rpx;height: 40rpx;background: #1F57E6;border-radius: 6rpx;flex: 0 0 auto;margin-right: 26rpx;}
  257. .tit{font-size: 32rpx;font-weight: bold;color: #161616;flex: 1;}
  258. .hisbtn{
  259. image{width: 18rpx;height: 10rpx;margin-left: 14rpx;}
  260. }
  261. }
  262. }
  263. }
  264. .pay /deep/ .zb-table .zb-table-header{background-color: #F2F5FB;}
  265. .pay /deep/ .zb-table .odd{background-color: #F2F5FB;}
  266. .pay /deep/ .item-td{border-bottom: none;font-weight: bold;font-size: 26rpx;}
  267. .pay /deep/ .item-th{border-bottom: none;font-weight: bold;font-size: 26rpx;}
  268. .pay /deep/ .zb-table-tbody{padding-bottom: 20rpx;}
  269. .addbtn{width:100%;
  270. height: 100rpx;
  271. background: #1f57e6;position: fixed;left: 0;right: 0;bottom: 0;z-index: 1;font-size: 34rpx;font-weight: 500;
  272. color: #FFFFFF;display: flex;align-items: center;justify-content: center;}
  273. </style>