wage_settlement.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  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. hrefFix = this.$store.state.domainConfig.siteUrl + `${hrefFix}`;
  181. return hrefFix;
  182. },
  183. /**
  184. * 开发者服务费率
  185. */
  186. devServiceRate() {
  187. let rate = this.rate;
  188. let result =
  189. +rate.origin_person_service_fee_rate -
  190. +rate.person_service_fee_rate_reduce;
  191. return result < 0 ? 0 : result;
  192. },
  193. /**
  194. * 开发者税率
  195. */
  196. devRate() {
  197. let rate = this.rate;
  198. return +rate.person_tax_rate + +rate.person_tax_service_fee_rate;
  199. },
  200. /**
  201. * 薪资
  202. */
  203. salary() {
  204. return this.detail.salary;
  205. },
  206. /**
  207. * 会员减免
  208. */
  209. vipMinus() {
  210. let salary = this.salary;
  211. let rate = this.rate;
  212. return this.keepDecimal(
  213. ((salary.normal_salary * 1 + salary.probation_salary * 1) *
  214. (this.detail.work_hour.work_rate / 100) -
  215. salary.deduction_fee * 1) *
  216. ((rate.origin_person_service_fee_rate -
  217. rate.person_service_fee_rate_reduce) /
  218. 100)
  219. );
  220. },
  221. /**
  222. * 税率
  223. */
  224. rate() {
  225. return this.detail.rate;
  226. },
  227. /**
  228. * 应缴税费
  229. */
  230. shouldRate() {
  231. let rate = this.rate;
  232. return this.keepDecimal(
  233. (+this.baseSalary *
  234. (1 -
  235. +rate.origin_person_service_fee_rate / 100 +
  236. +rate.person_service_fee_rate_reduce / 100) *
  237. this.devRate) /
  238. 100
  239. );
  240. },
  241. /**
  242. * 本月工资
  243. */
  244. baseSalary() {
  245. let salary = this.salary;
  246. return this.keepDecimal(
  247. ((+salary.normal_salary + +salary.probation_salary) *
  248. +this.detail.work_hour.work_rate) /
  249. 100 -
  250. +salary.deduction_fee
  251. );
  252. },
  253. /**
  254. * 退还金额
  255. */
  256. returnMoney() {
  257. if (this.is_use_deposit) return 0;
  258. let salary = this.salary;
  259. let isPay = +this.detail.company.company_pay > 0 ? 1 : 0;
  260. let hasTax =
  261. this.detail.is_invoice == "1"
  262. ? 1 + +this.detail.rate.company_tax_rate / 100
  263. : 1;
  264. return (
  265. this.keepDecimal(
  266. (+salary.normal_salary +
  267. +salary.probation_salary -
  268. +this.baseSalary) *
  269. (1 + +this.detail.rate.company_service_fee_rate / 100) *
  270. hasTax
  271. ) * isPay
  272. );
  273. },
  274. /**
  275. * 实际工资
  276. */
  277. personPrice() {
  278. let salary = this.salary;
  279. let rate = this.detail.rate;
  280. let work_hour = this.detail.work_hour;
  281. let isPayable = this.dev_is_invoice
  282. ? 1 -
  283. rate.person_tax_rate / 100 -
  284. rate.person_tax_service_fee_rate / 100
  285. : 1;
  286. let personPrice =
  287. (((salary.normal_salary - 0 + (salary.probation_salary - 0)) *
  288. work_hour.work_rate) /
  289. 100 -
  290. +salary.deduction_fee) *
  291. (1 - rate.person_service_fee_rate / 100) *
  292. isPayable;
  293. return this.keepDecimal(personPrice);
  294. },
  295. /**
  296. * 企业方费用
  297. */
  298. companyPrice() {
  299. let salary = this.salary;
  300. let rate = this.detail.rate;
  301. let work_hour = this.detail.work_hour;
  302. let isPayable = this.is_invoice ? 1 + rate.company_tax_rate / 100 : 1;
  303. let companyPrice =
  304. (((salary.normal_salary - 0 + (salary.probation_salary - 0)) *
  305. work_hour.work_rate) /
  306. 100 -
  307. +salary.deduction_fee) *
  308. (1 + rate.company_service_fee_rate / 100) *
  309. isPayable;
  310. return this.keepDecimal(companyPrice);
  311. },
  312. /**
  313. * is_invoice根据身份取值
  314. */
  315. isInvoice() {
  316. return this.detail[this.isDev ? "dev_is_invoice" : "is_invoice"];
  317. }
  318. },
  319. filters: {
  320. /**
  321. * 格式化日期
  322. */
  323. dateFormat(val) {
  324. return new Date(+val * 1000).toLocaleDateString();
  325. }
  326. },
  327. mounted() {
  328. this.job_id = this.$route.query.job_id;
  329. this.period_id = this.$route.query.period_id;
  330. this.getClients();
  331. this.getData();
  332. this.getReminds();
  333. },
  334. methods: {
  335. /**
  336. * 备注页码变化
  337. */
  338. changePagination(page) {
  339. this.getReminds(page);
  340. },
  341. async getReminds(page = currentPage) {
  342. this.reminds = [];
  343. let { status, data } = await this.$post("/api/admin/job/getPeriodNote", {
  344. period_id: this.period_id,
  345. page
  346. });
  347. currentPage = page;
  348. console.log(data);
  349. if (status) {
  350. this.total = data.total;
  351. this.reminds = data.list;
  352. }
  353. },
  354. /**
  355. * 点击提交备注
  356. */
  357. async clickRemindSave() {
  358. console.log(this.remind);
  359. if (!this.remind.length) {
  360. this.$message({
  361. message: "请输入备注",
  362. type: "warning"
  363. });
  364. return;
  365. }
  366. let content = `${this.remind} -账单ID${this.period_id}`;
  367. let res = await this.$post("/api/admin/job/note", {
  368. id: this.job_id,
  369. period_id: this.period_id,
  370. content
  371. });
  372. console.log(res);
  373. if (res.status) {
  374. this.$message({
  375. message: "保存成功",
  376. type: "success"
  377. });
  378. setTimeout(() => {
  379. location.reload();
  380. }, 1500);
  381. } else {
  382. this.$message({
  383. message: "保存失败",
  384. type: "error"
  385. });
  386. }
  387. },
  388. /**
  389. * 有效数字控制
  390. */
  391. keepDecimal(num) {
  392. return num.toFixed(2);
  393. },
  394. /**
  395. * 点击保存或支付
  396. */
  397. async jobPeriodSettle(action) {
  398. if (this.returnMoney < 0 || this.detail.work_hour.work_rate > 100) {
  399. this.$message({
  400. message: "退还金额不能小于0 且 结算比例不能大于100",
  401. type: "error"
  402. });
  403. return;
  404. }
  405. let body = {
  406. // 云端工作周期id(int)
  407. period_id: this.period_id,
  408. // 云端工作id(int)
  409. job_id: this.job_id,
  410. // 操作名称 save-保存结算信息 confirm-确认支付工资
  411. action,
  412. // 结算比例(百分比)
  413. work_rate: this.detail.work_hour.work_rate,
  414. // 扣减工资(数值,两位小数)
  415. deduction_fee: this.salary.deduction_fee,
  416. // 退还金额(数值,两位小数)
  417. return_money: this.returnMoney,
  418. // 结算工资时的备注(可选)
  419. remark: this.detail.remark,
  420. // 结算时是否使用押金
  421. is_use_deposit: this.is_use_deposit ? 1 : 0,
  422. person_service_fee_rate: this.detail.rate.origin_person_service_fee_rate
  423. };
  424. body.dev_is_invoice = this.dev_is_invoice ? 1 : 0;
  425. let res = await this.$post("/api/admin/job/job_period_settle", body);
  426. if (!res) return;
  427. if (res.status > 0) {
  428. this.$message({
  429. message: res.info,
  430. type: "success"
  431. });
  432. setTimeout(() => {
  433. location.reload();
  434. }, 1000);
  435. } else {
  436. if (!res.info) {
  437. console.log(res);
  438. }
  439. this.$message({
  440. message: res.info ? res.info : "接口返回数据异常",
  441. type: "error"
  442. });
  443. }
  444. },
  445. /**
  446. * 获取数据
  447. */
  448. async getData(i) {
  449. let res = await this.$post("/api/admin/job/get_job_period_detail", {
  450. job_id: this.job_id,
  451. period_id: this.period_id,
  452. is_cal_workrate: 1
  453. });
  454. if (!res.data) return;
  455. let data = res.data;
  456. env = data.current_env;
  457. this.detail = data;
  458. this.isDev = data.is_dev;
  459. this.is_invoice = this.detail.is_invoice === "1";
  460. this.dev_is_invoice = this.detail.dev_is_invoice == "1";
  461. this.is_use_deposit = data.can_use_deposit === "1";
  462. this.clientSelected = this.detail.user_manager
  463. ? this.detail.user_manager.uid
  464. : "";
  465. },
  466. /**
  467. * 获取客户经理
  468. */
  469. async getClients() {
  470. let res = await this.$post("/api/admin/user_manager/get_manager", {});
  471. if (!res.data) return;
  472. let data = res.data;
  473. console.log(data);
  474. this.clients = data.managers;
  475. },
  476. /**
  477. * 更换客户经理
  478. */
  479. async handleClientChange() {
  480. if (!this.clientSelected) {
  481. this.$message.error("请选择客户经理");
  482. }
  483. let res = await this.$post(
  484. "/api/admin/user_manager/change_manager_record",
  485. {
  486. manager_id: this.clientSelected,
  487. period_id: this.period_id
  488. }
  489. );
  490. if (res.status === 1) {
  491. this.$message({
  492. message: "修改成功",
  493. type: "success"
  494. });
  495. this.getData();
  496. this.clientSelected = "";
  497. this.clientChangeDialog = false;
  498. } else {
  499. this.$message.error("修改失败!" + res.info);
  500. }
  501. }
  502. }
  503. };
  504. </script>
  505. <style scoped>
  506. #wage-settlement {
  507. display: flex;
  508. padding: 20px;
  509. }
  510. .left,
  511. .right {
  512. flex: 1;
  513. }
  514. .left {
  515. border-right: 1px solid #ccc;
  516. padding-right: 20px;
  517. }
  518. .right {
  519. padding: 20px;
  520. }
  521. .container {
  522. display: flex;
  523. align-items: center;
  524. height: 44px;
  525. }
  526. .salary-container {
  527. height: 80px;
  528. background: #f0f0f0;
  529. }
  530. .salary-result {
  531. font-size: 28px;
  532. font-weight: 800;
  533. }
  534. .salary-calc {
  535. color: #666;
  536. margin-left: 40px;
  537. }
  538. .title {
  539. width: 120px;
  540. }
  541. .el-input {
  542. width: 180px;
  543. }
  544. textarea {
  545. resize: none;
  546. width: 100%;
  547. height: 120px;
  548. padding: 12px;
  549. }
  550. .reminds {
  551. margin-top: 40px;
  552. height: 600px;
  553. overflow-y: scroll;
  554. }
  555. .remind {
  556. display: flex;
  557. margin-bottom: 40px;
  558. }
  559. .remind-head {
  560. --width: 40px;
  561. width: var(--width);
  562. height: var(--width);
  563. border-radius: 50%;
  564. margin-right: 10px;
  565. }
  566. .remind-right {
  567. display: flex;
  568. flex-direction: column;
  569. }
  570. .remind-nickname {
  571. font-weight: 800;
  572. }
  573. .remind-date {
  574. color: #999;
  575. }
  576. .remind-content {
  577. border-left: 4px solid #d8d8d8;
  578. padding-left: 10px;
  579. margin-top: 10px;
  580. }
  581. </style>