wage_settlement.vue 14 KB

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