wage_settlement.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <template>
  2. <section v-if="detail" id="wage-settlement">
  3. <section class="left">
  4. <h3>工资结算</h3>
  5. <h4>
  6. <a :href="orderHref">{{detail.job.title_count}}</a>
  7. 】{{detail.time.month}}工资账单
  8. <el-tag size="small">{{detail.statusName}}</el-tag>
  9. <el-tag size="small" v-if="detail.is_use_deposit=='1'">使用押金结算</el-tag>
  10. </h4>
  11. <section class="container">
  12. <span class="title">每月薪资:</span>
  13. ¥{{salary.job_salary}}/月
  14. </section>
  15. <section class="container">
  16. <span class="title">工作周期:</span>
  17. {{detail.time.start_time | dateFormat}} 至 {{detail.time.end_time | dateFormat}} ({{detail.days}}天)
  18. </section>
  19. <section class="container">
  20. <span class="title">托管金额:</span>
  21. ¥{{detail.company.company_pay}}
  22. </section>
  23. <section v-if="detail.normal_days > 0" class="container">
  24. <span class="title">正式工资:</span>
  25. ¥{{salary.normal_salary}}({{detail.normal_days}}天)
  26. </section>
  27. <section v-if="detail.probation_days > 0" class="container">
  28. <span class="title">试用工资:</span>
  29. ¥{{salary.probation_salary}}({{detail.probation_days}}天,按月工资{{rate.probation_rate}}%结算)
  30. </section>
  31. <section class="container">
  32. <span class="title">结算比例:</span>
  33. <el-input type="number" v-model="detail.work_hour.work_rate"></el-input>
  34. % (工作工时:{{detail.work_hour.worked_hours}}/{{detail.work_hour.should_work_hours}})
  35. </section>
  36. <section class="container">
  37. <span class="title">扣减工资:</span>
  38. <el-input type="number" v-model="salary.deduction_fee"></el-input>元
  39. </section>
  40. <section class="container salary-container">
  41. <span class="title">本月工资:</span>
  42. <section>
  43. <div class="salary-result">¥{{baseSalary}}</div>
  44. <div
  45. class="salary-calc"
  46. >=({{salary.normal_salary}}+{{salary.probation_salary}})*{{detail.work_hour.work_rate}}%-{{salary.deduction_fee}}</div>
  47. </section>
  48. </section>
  49. <section class="container">
  50. <span class="title">平台服务费:</span>
  51. <el-input type="number" v-model="rate.origin_person_service_fee_rate"></el-input>
  52. VIP会员减免{{rate.person_service_fee_rate_reduce}}% ¥{{vipMinus}} (开发者服务费率{{devServiceRate}}%)
  53. </section>
  54. <section class="container">
  55. <span class="title">应缴税费:</span>
  56. <el-checkbox type="checkbox" v-model="payable"></el-checkbox>
  57. ¥{{shouldRate}} (开发者税率{{devRate}}%)
  58. </section>
  59. <section class="container salary-container">
  60. <span class="title">实际工资:</span>
  61. <section>
  62. <div class="salary-result">¥{{personPrice}}</div>
  63. <div class="salary-calc">
  64. <span>=(({{salary.normal_salary}}+{{salary.probation_salary}})*{{detail.work_hour.work_rate}}%-{{salary.deduction_fee * 1}})*(1-{{rate.person_service_fee_rate}}%)</span>
  65. <span
  66. v-if="payable"
  67. >*(1-{{rate.person_tax_rate}}%-{{rate.person_tax_service_fee_rate}}%)</span>
  68. </div>
  69. </section>
  70. </section>
  71. <!-- 本月结束合作,下月未托管费用 -->
  72. <section v-if="detail.can_use_deposit" class="container">
  73. <el-checkbox v-model="is_use_deposit" style="margin: 0 4px 0 0;" disabled checked></el-checkbox>
  74. 使用押金结算(¥{{detail.company.company_left_deposit}})(企业方费用:¥{{companyPrice}})
  75. </section>
  76. <section class="container">
  77. <span class="title">退还金额:</span>
  78. <el-input type="text" :value="returnMoney" disabled></el-input>
  79. =(({{salary.normal_salary}}+{{salary.probation_salary}})-{{baseSalary}})*(1+{{rate.company_service_fee_rate}}%)
  80. <span
  81. v-if="payable"
  82. >*(1+{{detail.dev_is_invoice ? rate.person_total_tax_rate : 0}}%)</span>元
  83. </section>
  84. <section class="container">
  85. <span class="title">备注说明:</span>
  86. <el-input v-model="detail.remark"></el-input>
  87. </section>
  88. <el-button
  89. v-show="detail.status == 2 || detail.status == 3"
  90. @click="jobPeriodSettle('save')"
  91. >保存</el-button>
  92. <section v-if="detail.can_send_salary" class="container" style="margin-top: 20px;">
  93. <el-button
  94. type="primary"
  95. v-show="detail.status == 3"
  96. @click="jobPeriodSettle('confirm')"
  97. >确定支付工资</el-button>
  98. </section>
  99. </section>
  100. <section class="right">
  101. <textarea v-model="remind" placeholder="请输入备注" maxlength="200"></textarea>
  102. <el-button style="width: 100px;" @click="clickRemindSave" type="primary">保存</el-button>
  103. <section class="reminds">
  104. <section class="remind" v-for="remind of reminds" :key="remind.id">
  105. <img class="remind-head" :src="remind.icon_url" alt="icon">
  106. <section class="remind-right">
  107. <section class="remind-top">
  108. <span class="remind-nickname">{{remind.nickname}}</span>
  109. <span class="remind-date">{{remind.create_date}}</span>
  110. </section>
  111. <p class="remind-content">{{remind.content}}</p>
  112. </section>
  113. </section>
  114. </section>
  115. <el-pagination layout="prev, pager, next" :total="total" :page-size="20" @current-change="changePagination"></el-pagination>
  116. </section>
  117. </section>
  118. </template>
  119. <script>
  120. // 现在环境是线上还是测试, 默认线上
  121. let env = ''
  122. // 备注页码
  123. let currentPage = 1
  124. export default {
  125. data() {
  126. return {
  127. // 全部备注数量
  128. total: 0,
  129. // 历史备注
  130. reminds: [],
  131. // 备注信息
  132. remind: '',
  133. job_id: '',
  134. period_id: '',
  135. payable: false,
  136. is_use_deposit: false,
  137. detail: null,
  138. }
  139. },
  140. computed: {
  141. /**
  142. * 详情链接地址
  143. */
  144. orderHref() {
  145. let detail = this.detail
  146. , hrefFix = `/rooter/cloudjobitem/${detail.job_id}`
  147. if(env === 'test') hrefFix = `https://dev.test.proginn.com${hrefFix}`
  148. else hrefFix = `https://www.proginn.com${hrefFix}`
  149. return hrefFix
  150. },
  151. /**
  152. * 开发者服务费率
  153. */
  154. devServiceRate() {
  155. let rate = this.rate
  156. let result = Number(rate.origin_person_service_fee_rate) - Number(rate.person_service_fee_rate_reduce)
  157. return result < 0 ? 0 : result
  158. },
  159. /**
  160. * 开发者税率
  161. */
  162. devRate() {
  163. let rate = this.rate
  164. return Number(rate.person_tax_rate) + Number(rate.person_tax_service_fee_rate)
  165. },
  166. /**
  167. * 薪资
  168. */
  169. salary() {
  170. return this.detail.salary
  171. },
  172. /**
  173. * 会员减免
  174. */
  175. vipMinus() {
  176. let salary = this.salary
  177. let rate = this.rate
  178. 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))
  179. },
  180. /**
  181. * 税率
  182. */
  183. rate() {
  184. return this.detail.rate
  185. },
  186. /**
  187. * 应缴税费
  188. */
  189. shouldRate() {
  190. let rate = this.rate
  191. 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)
  192. },
  193. /**
  194. * 本月工资
  195. */
  196. baseSalary() {
  197. let salary = this.salary
  198. return this.keepDecimal((Number(salary.normal_salary) + Number(salary.probation_salary)) * Number(this.detail.work_hour.work_rate) / 100 - Number(salary.deduction_fee))
  199. },
  200. /**
  201. * 退还金额
  202. */
  203. returnMoney() {
  204. if(this.is_use_deposit) return 0
  205. let salary = this.salary
  206. let isPay = Number(this.detail.company.company_pay) > 0 ? 1 : 0
  207. let hasTax = this.payable ? (1 + Number(this.detail.rate.company_tax_rate) / 100) : 1
  208. 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
  209. },
  210. /**
  211. * 实际工资
  212. */
  213. personPrice() {
  214. let salary = this.salary
  215. let rate = this.detail.rate
  216. let work_hour = this.detail.work_hour
  217. let isPayable = this.payable ? (1 - rate.person_tax_rate / 100 - rate.person_tax_service_fee_rate / 100) : 1
  218. 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
  219. return this.keepDecimal(personPrice)
  220. },
  221. /**
  222. * 企业方费用
  223. */
  224. companyPrice() {
  225. let salary = this.salary
  226. let rate = this.detail.rate
  227. let work_hour = this.detail.work_hour
  228. let isPayable = this.payable ? (1 + rate.company_tax_rate / 100) : 1
  229. 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
  230. return this.keepDecimal(companyPrice)
  231. },
  232. },
  233. filters: {
  234. /**
  235. * 格式化日期
  236. */
  237. dateFormat(val) {
  238. return new Date(Number(val) * 1000).toLocaleDateString()
  239. }
  240. },
  241. mounted() {
  242. this.job_id = this.$route.query.job_id
  243. this.period_id = this.$route.query.period_id
  244. this.getData()
  245. this.getReminds()
  246. },
  247. methods: {
  248. /**
  249. * 备注页码变化
  250. */
  251. changePagination(page) {
  252. this.getReminds(page)
  253. },
  254. async getReminds(page = currentPage) {
  255. this.reminds = []
  256. let {status, data} = await this.$post('/api/admin/job/getPeriodNote', { period_id: this.period_id, page })
  257. currentPage = page
  258. console.log(data)
  259. if(status) {
  260. this.total = data.total
  261. this.reminds = data.list
  262. }
  263. },
  264. /**
  265. * 点击提交备注
  266. */
  267. async clickRemindSave() {
  268. console.log(this.remind)
  269. if(!this.remind.length) {
  270. this.$message({
  271. message: '请输入备注',
  272. type: 'warning'
  273. })
  274. return
  275. }
  276. let content = `${this.remind} -账单ID${this.period_id}`
  277. let res = await this.$post('/api/admin/job/note', { id: this.job_id, period_id: this.period_id, content })
  278. console.log(res)
  279. if(res.status) {
  280. this.$message({
  281. message: '保存成功',
  282. type: 'success'
  283. })
  284. setTimeout(() => {
  285. location.reload()
  286. }, 1500);
  287. } else {
  288. this.$message({
  289. message: '保存失败',
  290. type: 'error'
  291. })
  292. }
  293. },
  294. /**
  295. * 有效数字控制
  296. */
  297. keepDecimal(num) {
  298. return num.toFixed(2)
  299. },
  300. /**
  301. * 点击保存或支付
  302. */
  303. async jobPeriodSettle(action) {
  304. if (this.returnMoney < 0 || this.detail.work_hour.work_rate > 100) {
  305. this.$message({
  306. message: '退还金额不能小于0 且 结算比例不能大于100',
  307. type: 'error'
  308. })
  309. return;
  310. }
  311. let res = await this.$post('/api/admin/job/job_period_settle', {
  312. // 云端工作周期id(int)
  313. period_id: this.period_id,
  314. // 云端工作id(int)
  315. job_id: this.job_id,
  316. // 操作名称 save-保存结算信息 confirm-确认支付工资
  317. action,
  318. // 结算比例(百分比)
  319. work_rate: this.detail.work_hour.work_rate,
  320. // 扣减工资(数值,两位小数)
  321. deduction_fee: this.salary.deduction_fee,
  322. // 是否要纳税(0-不需要 1-需要)
  323. is_invoice: this.payable ? 1 : 0,
  324. // 退还金额(数值,两位小数)
  325. return_money: this.returnMoney,
  326. // 结算工资时的备注(可选)
  327. remark: this.detail.remark,
  328. // 结算时是否使用押金
  329. is_use_deposit: this.is_use_deposit ? 1 : 0,
  330. person_service_fee_rate: this.detail.rate.origin_person_service_fee_rate,
  331. })
  332. if(!res) return
  333. if (res.status > 0) {
  334. this.$message({
  335. message: res.info,
  336. type: 'success'
  337. });
  338. setTimeout(() => {
  339. location.reload()
  340. }, 1000)
  341. } else {
  342. if (!res.info) {
  343. console.log(res)
  344. }
  345. this.$message({
  346. message: res.info ? res.info : '接口返回数据异常',
  347. type: 'error'
  348. })
  349. }
  350. },
  351. /**
  352. * 获取数据
  353. */
  354. async getData(i) {
  355. let res = await this.$post('/api/admin/job/get_job_period_detail', {
  356. job_id: this.job_id,
  357. period_id: this.period_id,
  358. is_cal_workrate: 1
  359. })
  360. if(!res.data) return
  361. let data = res.data
  362. env = data.current_env
  363. this.detail = data
  364. this.payable = data.is_invoice === '1'
  365. this.is_use_deposit = data.can_use_deposit === '1'
  366. },
  367. }
  368. }
  369. </script>
  370. <style scoped>
  371. #wage-settlement {
  372. display: flex;
  373. padding: 20px;
  374. }
  375. .left,
  376. .right {
  377. flex: 1;
  378. }
  379. .left {
  380. border-right: 1px solid #ccc;
  381. padding-right: 20px;
  382. }
  383. .right {
  384. padding: 20px;
  385. }
  386. .container {
  387. display: flex;
  388. align-items: center;
  389. height: 44px;
  390. }
  391. .salary-container {
  392. height: 80px;
  393. background: #f0f0f0;
  394. }
  395. .salary-result {
  396. font-size: 28px;
  397. font-weight: 800;
  398. }
  399. .salary-calc {
  400. color: #666;
  401. margin-left: 40px;
  402. }
  403. .title {
  404. width: 92px;
  405. }
  406. .el-input {
  407. width: 180px;
  408. }
  409. textarea {
  410. resize: none;
  411. width: 100%;
  412. height: 120px;
  413. padding: 12px;
  414. }
  415. .reminds {
  416. margin-top: 40px;
  417. height: 600px;
  418. overflow-y: scroll;
  419. }
  420. .remind {
  421. display: flex;
  422. margin-bottom: 40px;
  423. }
  424. .remind-head {
  425. --width: 40px;
  426. width: var(--width);
  427. height: var(--width);
  428. border-radius: 50%;
  429. margin-right: 10px;;
  430. }
  431. .remind-right {
  432. display: flex;
  433. flex-direction: column;
  434. }
  435. .remind-nickname {
  436. font-weight: 800;
  437. }
  438. .remind-date {
  439. color: #999;
  440. }
  441. .remind-content {
  442. border-left: 4px solid #d8d8d8;
  443. padding-left: 10px;
  444. margin-top: 10px;
  445. }
  446. </style>