wage_settlement.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <div v-if="detail" id="wage-settlement">
  3. <h3>工资结算</h3>
  4. <h4>
  5. <a :href="orderHref">{{detail.job.title_count}}</a>
  6. 】{{detail.time.month}}工资账单
  7. </h4>
  8. <section class="container">
  9. <span class="title">每月薪资:</span>
  10. ¥{{salary.job_salary}}/月
  11. </section>
  12. <section class="container">
  13. <span class="title">工作周期:</span>
  14. {{detail.time.start_time | dateFormat}} 至 {{detail.time.end_time | dateFormat}} ({{detail.days}}天)
  15. </section>
  16. <section class="container">
  17. <span class="title">托管金额:</span>
  18. ¥{{detail.company.company_pay}}
  19. </section>
  20. <section v-if="detail.normal_days > 0" class="container">
  21. <span class="title">正式工资:</span>
  22. ¥{{salary.normal_salary}}({{detail.normal_days}}天)
  23. </section>
  24. <section v-if="detail.probation_days > 0" class="container">
  25. <span class="title">试用工资:</span>
  26. ¥{{salary.probation_salary}}({{detail.probation_days}}天,按月工资{{rate.probation_rate}}%结算)
  27. </section>
  28. <section class="container">
  29. <span class="title">结算比例:</span>
  30. <el-input type="number" v-model="detail.work_hour.work_rate"></el-input>
  31. % (工作工时:{{detail.work_hour.worked_hours}}/{{detail.work_hour.should_work_hours}})
  32. </section>
  33. <section class="container">
  34. <span class="title">扣减工资:</span>
  35. <el-input type="number" v-model="salary.deduction_fee"></el-input>元
  36. </section>
  37. <section class="container salary-container">
  38. <span class="title">本月工资:</span>
  39. <section>
  40. <div class="salary-result">¥{{baseSalary}}</div>
  41. <div
  42. class="salary-calc"
  43. >=({{salary.normal_salary}}+{{salary.probation_salary}})*{{detail.work_hour.work_rate}}%-{{salary.deduction_fee}}</div>
  44. </section>
  45. </section>
  46. <section class="container">
  47. <span class="title">平台服务费:</span>
  48. <el-input type="number" v-model="rate.origin_person_service_fee_rate"></el-input>
  49. VIP会员减免{{rate.person_service_fee_rate_reduce}}% ¥{{vipMinus}} (开发者服务费率{{devServiceRate}}%)
  50. </section>
  51. <section class="container">
  52. <span class="title">应缴税费:</span>
  53. <el-checkbox type="checkbox" v-model="payable"></el-checkbox>
  54. ¥{{shouldRate}} (开发者税率{{devRate}}%)
  55. </section>
  56. <section class="container salary-container">
  57. <span class="title">实际工资:</span>
  58. <section>
  59. <div class="salary-result">¥{{personPrice}}</div>
  60. <div class="salary-calc">
  61. <span>=(({{salary.normal_salary}}+{{salary.probation_salary}})*{{detail.work_hour.work_rate}}%-{{salary.deduction_fee * 1}})*(1-{{rate.person_service_fee_rate}}%)</span>
  62. <span v-if="payable">*(1-{{rate.person_tax_rate}}%-{{rate.person_tax_service_fee_rate}}%)</span>
  63. </div>
  64. </section>
  65. </section>
  66. <!-- 本月结束合作,下月未托管费用 -->
  67. <section v-if="detail.can_use_deposit" class="container">
  68. <el-checkbox v-model="is_use_deposit" style="margin: 0 4px 0 0;"></el-checkbox>
  69. 使用押金结算(¥{{detail.company.company_left_deposit}})(企业方费用:¥{{companyPrice}})
  70. </section>
  71. <section class="container">
  72. <span class="title">退还金额:</span>
  73. <el-input type="text" :value="returnMoney"></el-input>
  74. =(({{salary.normal_salary}}+{{salary.probation_salary}})-{{baseSalary}})*(1+{{rate.company_service_fee_rate}}%)
  75. <span
  76. v-if="payable"
  77. >*(1+{{detail.is_invoice ? rate.company_tax_rate : 0}}%)</span>元
  78. </section>
  79. <section class="container">
  80. <span class="title">备注说明:</span>
  81. <el-input v-model="detail.remark"></el-input>
  82. </section>
  83. <el-button v-show="detail.status == 2 || detail.status == 3" @click="jobPeriodSettle('save')">保存</el-button>
  84. <section v-if="detail.can_send_salary" class="container" style="margin-top: 20px;">
  85. <el-button
  86. type="primary"
  87. v-show="detail.status == 3"
  88. @click="jobPeriodSettle('confirm')"
  89. >确定支付工资</el-button>
  90. </section>
  91. </div>
  92. </template>
  93. <script>
  94. // 现在环境是线上还是测试, 默认线上
  95. let env = ''
  96. export default {
  97. data() {
  98. return {
  99. job_id: '',
  100. period_id: '',
  101. payable: false,
  102. is_use_deposit: false,
  103. detail: null,
  104. }
  105. },
  106. computed: {
  107. /**
  108. * 详情链接地址
  109. */
  110. orderHref() {
  111. let detail = this.detail
  112. , hrefFix = `/rooter/cloudjobitem/${detail.job_id}`
  113. if(env === 'test') hrefFix = `https://dev.test.proginn.com${hrefFix}`
  114. else hrefFix = `https://www.proginn.com${hrefFix}`
  115. return hrefFix
  116. },
  117. /**
  118. * 开发者服务费率
  119. */
  120. devServiceRate() {
  121. let rate = this.rate
  122. let result = Number(rate.origin_person_service_fee_rate) - Number(rate.person_service_fee_rate_reduce)
  123. return result < 0 ? 0 : result
  124. },
  125. /**
  126. * 开发者税率
  127. */
  128. devRate() {
  129. let rate = this.rate
  130. return Number(rate.person_tax_rate) + Number(rate.person_tax_service_fee_rate)
  131. },
  132. /**
  133. * 薪资
  134. */
  135. salary() {
  136. return this.detail.salary
  137. },
  138. /**
  139. * 会员减免
  140. */
  141. vipMinus() {
  142. let salary = this.salary
  143. let rate = this.rate
  144. return this.keepDecimal(((salary.normal_salary * 1 + salary.probation_salary * 1) * (this.detail.work_hour.work_rate / 100) - salary.deduction_fee * 1) * ((rate.origin_person_service_fee_rate - rate.person_service_fee_rate_reduce) / 100))
  145. },
  146. /**
  147. * 税率
  148. */
  149. rate() {
  150. return this.detail.rate
  151. },
  152. /**
  153. * 应缴税费
  154. */
  155. shouldRate() {
  156. let rate = this.rate
  157. return this.keepDecimal(Number(this.baseSalary) * (1 - Number(rate.origin_person_service_fee_rate) / 100 + Number(rate.person_service_fee_rate_reduce) / 100) * this.devRate / 100)
  158. },
  159. /**
  160. * 本月工资
  161. */
  162. baseSalary() {
  163. let salary = this.salary
  164. return this.keepDecimal((Number(salary.normal_salary) + Number(salary.probation_salary)) * Number(this.detail.work_hour.work_rate) / 100 - Number(salary.deduction_fee))
  165. },
  166. /**
  167. * 退还金额
  168. */
  169. returnMoney() {
  170. if(this.is_use_deposit) return 0
  171. let salary = this.salary
  172. let isPay = Number(this.detail.company.company_pay) > 0 ? 1 : 0
  173. let hasTax = this.payable ? (1 + Number(this.detail.rate.company_tax_rate) / 100) : 1
  174. return this.keepDecimal((Number(salary.normal_salary) + Number(salary.probation_salary) - Number(this.baseSalary)) * (1 + Number(this.detail.rate.company_service_fee_rate) / 100) * hasTax) * isPay
  175. },
  176. /**
  177. * 实际工资
  178. */
  179. personPrice() {
  180. let salary = this.salary
  181. let rate = this.detail.rate
  182. let work_hour = this.detail.work_hour
  183. let isPayable = this.payable ? (1 - rate.person_tax_rate / 100 - rate.person_tax_service_fee_rate / 100) : 1
  184. let personPrice = (((salary.normal_salary - 0) + (salary.probation_salary - 0)) * work_hour.work_rate / 100 - Number(salary.deduction_fee)) * (1 - rate.person_service_fee_rate / 100) * isPayable
  185. return this.keepDecimal(personPrice)
  186. },
  187. /**
  188. * 企业方费用
  189. */
  190. companyPrice() {
  191. let salary = this.salary
  192. let rate = this.detail.rate
  193. let work_hour = this.detail.work_hour
  194. let isPayable = this.payable ? (1 + rate.company_tax_rate / 100) : 1
  195. let companyPrice = (((salary.normal_salary - 0) + (salary.probation_salary - 0)) * work_hour.work_rate / 100 - Number(salary.deduction_fee)) * (1 + rate.company_service_fee_rate / 100) * isPayable
  196. return this.keepDecimal(companyPrice)
  197. },
  198. },
  199. filters: {
  200. /**
  201. * 格式化日期
  202. */
  203. dateFormat(val) {
  204. return new Date(Number(val) * 1000).toLocaleDateString()
  205. }
  206. },
  207. mounted() {
  208. this.job_id = this.$route.query.job_id
  209. this.period_id = this.$route.query.period_id
  210. this.getData()
  211. },
  212. methods: {
  213. /**
  214. * 有效数字控制
  215. */
  216. keepDecimal(num) {
  217. return num.toFixed(2)
  218. },
  219. /**
  220. * 点击保存或支付
  221. */
  222. jobPeriodSettle(action) {
  223. let res = this.$post('/api/admin/job/job_period_settle', {
  224. // 云端工作周期id(int)
  225. period_id: this.period_id,
  226. // 云端工作id(int)
  227. job_id: this.job_id,
  228. // 操作名称 save-保存结算信息 confirm-确认支付工资
  229. action,
  230. // 结算比例(百分比)
  231. work_rate: this.detail.work_hour.work_rate,
  232. // 扣减工资(数值,两位小数)
  233. deduction_fee: this.salary.deduction_fee,
  234. // 是否要发票(0-不需要 1-需要)
  235. is_invoice: this.payable ? 1 : 0,
  236. // 退还金额(数值,两位小数)
  237. return_money: this.returnMoney,
  238. // 结算工资时的备注(可选)
  239. remark: this.detail.remark,
  240. // 结算时是否使用押金
  241. is_use_deposit: this.is_use_deposit ? 1 : 0,
  242. person_service_fee_rate: this.detail.rate.origin_person_service_fee_rate,
  243. })
  244. // console.log(res)
  245. if(!res) return
  246. this.$message({
  247. message: '成功',
  248. type: 'success'
  249. })
  250. setTimeout(() => {
  251. location.reload()
  252. }, 1000)
  253. },
  254. /**
  255. * 获取数据
  256. */
  257. async getData(i) {
  258. let res = await this.$post('/api/admin/job/get_job_period_detail', {
  259. job_id: this.job_id,
  260. period_id: this.period_id,
  261. is_cal_workrate: 1
  262. })
  263. if(!res.data) return
  264. let data = res.data
  265. env = data.current_env
  266. this.detail = data
  267. this.payable = data.is_invoice === '1'
  268. this.is_use_deposit = data.can_use_deposit === '1'
  269. },
  270. }
  271. }
  272. </script>
  273. <style scoped>
  274. #wage-settlement {
  275. padding: 20px;
  276. }
  277. .container {
  278. display: flex;
  279. align-items: center;
  280. height: 44px;
  281. }
  282. .salary-container {
  283. height: 80px;
  284. background: #f0f0f0;
  285. }
  286. .salary-result {
  287. font-size: 28px;
  288. font-weight: 800;
  289. }
  290. .salary-calc {
  291. color: #666;
  292. margin-left: 40px;
  293. }
  294. .title {
  295. width: 92px;
  296. }
  297. .el-input {
  298. width: 180px;
  299. }
  300. </style>