wage_settlement.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  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. <section class="container">
  90. <span class="title">提成客户经理</span>
  91. {{detail.user_manager ? `${detail.user_manager.nickname}(${detail.user_manager.uid})` : ''}}
  92. <el-button @click="clientChangeDialog = true" type="text">更换</el-button>
  93. <el-dialog title="更换提成客户经理" :visible.sync="clientChangeDialog" width="30%">
  94. <div>客户昵称:{{detail.company_info ?`${detail.company_info.nickname}(${detail.company_info.uid})` : ''}}</div>
  95. <div>
  96. 客户经理:
  97. <el-select v-model="clientSelected" placeholder="请选择">
  98. <el-option
  99. v-for="item in clients"
  100. :key="item.uid"
  101. :label="`${item.nickname}(${item.uid})`"
  102. :value="item.uid"
  103. ></el-option>
  104. </el-select>
  105. </div>
  106. <span slot="footer" class="dialog-footer">
  107. <el-button @click="clientChangeDialog = false">取 消</el-button>
  108. <el-button type="primary" @click="handleClientChange">确 定</el-button>
  109. </span>
  110. </el-dialog>
  111. </section>
  112. <el-button
  113. v-show="detail.status == 2 || detail.status == 3"
  114. @click="jobPeriodSettle('save')"
  115. >保存</el-button>
  116. <section v-if="detail.can_send_salary" class="container" style="margin-top: 20px;">
  117. <el-button
  118. type="primary"
  119. v-show="detail.status == 3"
  120. @click="jobPeriodSettle('confirm')"
  121. >确定支付工资</el-button>
  122. </section>
  123. </section>
  124. <section class="right">
  125. <textarea v-model="remind" placeholder="请输入备注" maxlength="200"></textarea>
  126. <el-button style="width: 100px;" @click="clickRemindSave" type="primary">保存</el-button>
  127. <section class="reminds">
  128. <section class="remind" v-for="remind of reminds" :key="remind.id">
  129. <img class="remind-head" :src="remind.icon_url" alt="icon" />
  130. <section class="remind-right">
  131. <section class="remind-top">
  132. <span class="remind-nickname">{{remind.nickname}}</span>
  133. <span class="remind-date">{{remind.create_date}}</span>
  134. </section>
  135. <p class="remind-content">{{remind.content}}</p>
  136. </section>
  137. </section>
  138. </section>
  139. <el-pagination
  140. layout="prev, pager, next"
  141. :total="total"
  142. :page-size="20"
  143. @current-change="changePagination"
  144. ></el-pagination>
  145. </section>
  146. </section>
  147. </template>
  148. <script>
  149. // 现在环境是线上还是测试, 默认线上
  150. let env = ''
  151. // 备注页码
  152. let currentPage = 1
  153. export default {
  154. data() {
  155. return {
  156. // 全部备注数量
  157. total: 0,
  158. // 历史备注
  159. reminds: [],
  160. // 备注信息
  161. remind: '',
  162. job_id: '',
  163. period_id: '',
  164. is_invoice: false,
  165. dev_is_invoice: false,
  166. is_use_deposit: false,
  167. detail: null,
  168. clientChangeDialog: false,
  169. clients: [],
  170. clientSelected: ''
  171. }
  172. },
  173. computed: {
  174. /**
  175. * 详情链接地址
  176. */
  177. orderHref() {
  178. let detail = this.detail
  179. , hrefFix = `/rooter/cloudjobitem/${detail.job_id}`
  180. if (env === 'test') hrefFix = `https://dev.test.proginn.com${hrefFix}`
  181. else hrefFix = `https://www.proginn.com${hrefFix}`
  182. return hrefFix
  183. },
  184. /**
  185. * 开发者服务费率
  186. */
  187. devServiceRate() {
  188. let rate = this.rate
  189. let result = +rate.origin_person_service_fee_rate - +rate.person_service_fee_rate_reduce
  190. return result < 0 ? 0 : result
  191. },
  192. /**
  193. * 开发者税率
  194. */
  195. devRate() {
  196. let rate = this.rate
  197. return +rate.person_tax_rate + +rate.person_tax_service_fee_rate
  198. },
  199. /**
  200. * 薪资
  201. */
  202. salary() {
  203. return this.detail.salary
  204. },
  205. /**
  206. * 会员减免
  207. */
  208. vipMinus() {
  209. let salary = this.salary
  210. let rate = this.rate
  211. 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))
  212. },
  213. /**
  214. * 税率
  215. */
  216. rate() {
  217. return this.detail.rate
  218. },
  219. /**
  220. * 应缴税费
  221. */
  222. shouldRate() {
  223. let rate = this.rate
  224. return this.keepDecimal(+this.baseSalary * (1 - +rate.origin_person_service_fee_rate / 100 + +rate.person_service_fee_rate_reduce / 100) * this.devRate / 100)
  225. },
  226. /**
  227. * 本月工资
  228. */
  229. baseSalary() {
  230. let salary = this.salary
  231. return this.keepDecimal((+salary.normal_salary + +salary.probation_salary) * +this.detail.work_hour.work_rate / 100 - +salary.deduction_fee)
  232. },
  233. /**
  234. * 退还金额
  235. */
  236. returnMoney() {
  237. if (this.is_use_deposit) return 0
  238. let salary = this.salary
  239. let isPay = +this.detail.company.company_pay > 0 ? 1 : 0
  240. let hasTax = this.detail.is_invoice == '1' ? (1 + +this.detail.rate.company_tax_rate / 100) : 1
  241. return this.keepDecimal((+salary.normal_salary + +salary.probation_salary - +this.baseSalary) * (1 + +this.detail.rate.company_service_fee_rate / 100) * hasTax) * isPay
  242. },
  243. /**
  244. * 实际工资
  245. */
  246. personPrice() {
  247. let salary = this.salary
  248. let rate = this.detail.rate
  249. let work_hour = this.detail.work_hour
  250. let isPayable = this.dev_is_invoice ? (1 - rate.person_tax_rate / 100 - rate.person_tax_service_fee_rate / 100) : 1
  251. 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
  252. return this.keepDecimal(personPrice)
  253. },
  254. /**
  255. * 企业方费用
  256. */
  257. companyPrice() {
  258. let salary = this.salary
  259. let rate = this.detail.rate
  260. let work_hour = this.detail.work_hour
  261. let isPayable = this.is_invoice ? (1 + rate.company_tax_rate / 100) : 1
  262. 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
  263. return this.keepDecimal(companyPrice)
  264. },
  265. /**
  266. * is_invoice根据身份取值
  267. */
  268. isInvoice() {
  269. return this.detail[this.isDev ? 'dev_is_invoice' : 'is_invoice']
  270. }
  271. },
  272. filters: {
  273. /**
  274. * 格式化日期
  275. */
  276. dateFormat(val) {
  277. return new Date(+val * 1000).toLocaleDateString()
  278. }
  279. },
  280. mounted() {
  281. this.job_id = this.$route.query.job_id
  282. this.period_id = this.$route.query.period_id
  283. this.getClients();
  284. this.getData()
  285. this.getReminds()
  286. },
  287. methods: {
  288. /**
  289. * 备注页码变化
  290. */
  291. changePagination(page) {
  292. this.getReminds(page)
  293. },
  294. async getReminds(page = currentPage) {
  295. this.reminds = []
  296. let { status, data } = await this.$post('/api/admin/job/getPeriodNote', { period_id: this.period_id, page })
  297. currentPage = page
  298. console.log(data)
  299. if (status) {
  300. this.total = data.total
  301. this.reminds = data.list
  302. }
  303. },
  304. /**
  305. * 点击提交备注
  306. */
  307. async clickRemindSave() {
  308. console.log(this.remind)
  309. if (!this.remind.length) {
  310. this.$message({
  311. message: '请输入备注',
  312. type: 'warning'
  313. })
  314. return
  315. }
  316. let content = `${this.remind} -账单ID${this.period_id}`
  317. let res = await this.$post('/api/admin/job/note', { id: this.job_id, period_id: this.period_id, content })
  318. console.log(res)
  319. if (res.status) {
  320. this.$message({
  321. message: '保存成功',
  322. type: 'success'
  323. })
  324. setTimeout(() => {
  325. location.reload()
  326. }, 1500);
  327. } else {
  328. this.$message({
  329. message: '保存失败',
  330. type: 'error'
  331. })
  332. }
  333. },
  334. /**
  335. * 有效数字控制
  336. */
  337. keepDecimal(num) {
  338. return num.toFixed(2)
  339. },
  340. /**
  341. * 点击保存或支付
  342. */
  343. async jobPeriodSettle(action) {
  344. if (this.returnMoney < 0 || this.detail.work_hour.work_rate > 100) {
  345. this.$message({
  346. message: '退还金额不能小于0 且 结算比例不能大于100',
  347. type: 'error'
  348. })
  349. return;
  350. }
  351. let body = {
  352. // 云端工作周期id(int)
  353. period_id: this.period_id,
  354. // 云端工作id(int)
  355. job_id: this.job_id,
  356. // 操作名称 save-保存结算信息 confirm-确认支付工资
  357. action,
  358. // 结算比例(百分比)
  359. work_rate: this.detail.work_hour.work_rate,
  360. // 扣减工资(数值,两位小数)
  361. deduction_fee: this.salary.deduction_fee,
  362. // 退还金额(数值,两位小数)
  363. return_money: this.returnMoney,
  364. // 结算工资时的备注(可选)
  365. remark: this.detail.remark,
  366. // 结算时是否使用押金
  367. is_use_deposit: this.is_use_deposit ? 1 : 0,
  368. person_service_fee_rate: this.detail.rate.origin_person_service_fee_rate,
  369. }
  370. body.dev_is_invoice = this.dev_is_invoice ? 1 : 0
  371. let res = await this.$post('/api/admin/job/job_period_settle', body)
  372. if (!res) return
  373. if (res.status > 0) {
  374. this.$message({
  375. message: res.info,
  376. type: 'success'
  377. });
  378. setTimeout(() => {
  379. location.reload()
  380. }, 1000)
  381. } else {
  382. if (!res.info) {
  383. console.log(res)
  384. }
  385. this.$message({
  386. message: res.info ? res.info : '接口返回数据异常',
  387. type: 'error'
  388. })
  389. }
  390. },
  391. /**
  392. * 获取数据
  393. */
  394. async getData(i) {
  395. let res = await this.$post('/api/admin/job/get_job_period_detail', {
  396. job_id: this.job_id,
  397. period_id: this.period_id,
  398. is_cal_workrate: 1
  399. })
  400. if (!res.data) return
  401. let data = res.data
  402. env = data.current_env
  403. this.detail = data
  404. this.isDev = data.is_dev
  405. this.is_invoice = this.detail.is_invoice === '1'
  406. this.dev_is_invoice = this.detail.dev_is_invoice == '1'
  407. this.is_use_deposit = data.can_use_deposit === '1'
  408. this.clientSelected = this.detail.user_manager ? this.detail.user_manager.uid : '';
  409. },
  410. /**
  411. * 获取客户经理
  412. */
  413. async getClients() {
  414. let res = await this.$post('/api/admin/user_manager/get_manager', {
  415. })
  416. if (!res.data) return
  417. let data = res.data
  418. console.log(data)
  419. this.clients = data.managers
  420. },
  421. /**
  422. * 更换客户经理
  423. */
  424. async handleClientChange() {
  425. if (!this.clientSelected) {
  426. this.$message.error('请选择客户经理');
  427. }
  428. let res = await this.$post('/api/admin/user_manager/change_manager_record', {
  429. manager_id: this.clientSelected,
  430. period_id: this.period_id,
  431. })
  432. if (res.status === 1) {
  433. this.$message({
  434. message: '修改成功',
  435. type: 'success'
  436. })
  437. this.getData();
  438. this.clientSelected = '';
  439. this.clientChangeDialog = false;
  440. } else {
  441. this.$message.error('修改失败!' + res.info)
  442. }
  443. }
  444. }
  445. }
  446. </script>
  447. <style scoped>
  448. #wage-settlement {
  449. display: flex;
  450. padding: 20px;
  451. }
  452. .left,
  453. .right {
  454. flex: 1;
  455. }
  456. .left {
  457. border-right: 1px solid #ccc;
  458. padding-right: 20px;
  459. }
  460. .right {
  461. padding: 20px;
  462. }
  463. .container {
  464. display: flex;
  465. align-items: center;
  466. height: 44px;
  467. }
  468. .salary-container {
  469. height: 80px;
  470. background: #f0f0f0;
  471. }
  472. .salary-result {
  473. font-size: 28px;
  474. font-weight: 800;
  475. }
  476. .salary-calc {
  477. color: #666;
  478. margin-left: 40px;
  479. }
  480. .title {
  481. width: 120px;
  482. }
  483. .el-input {
  484. width: 180px;
  485. }
  486. textarea {
  487. resize: none;
  488. width: 100%;
  489. height: 120px;
  490. padding: 12px;
  491. }
  492. .reminds {
  493. margin-top: 40px;
  494. height: 600px;
  495. overflow-y: scroll;
  496. }
  497. .remind {
  498. display: flex;
  499. margin-bottom: 40px;
  500. }
  501. .remind-head {
  502. --width: 40px;
  503. width: var(--width);
  504. height: var(--width);
  505. border-radius: 50%;
  506. margin-right: 10px;
  507. }
  508. .remind-right {
  509. display: flex;
  510. flex-direction: column;
  511. }
  512. .remind-nickname {
  513. font-weight: 800;
  514. }
  515. .remind-date {
  516. color: #999;
  517. }
  518. .remind-content {
  519. border-left: 4px solid #d8d8d8;
  520. padding-left: 10px;
  521. margin-top: 10px;
  522. }
  523. </style>