view.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <template>
  2. <el-dialog title="公积金申报信息" v-model="visible" :width="width" append-to-body draggable @close="close"
  3. :close-on-click-modal="false">
  4. <!-- <div slot="title" class="dialog-title-container">
  5. <span class="title-label"><i class="el-icon-document" /> 工资信息</span>
  6. <i class="el-icon-close" @click="close" />
  7. </div> -->
  8. <!-- 功能按钮 -->
  9. <div v-loading="loading">
  10. <div style="padding: 8px 24px 16px 24px">
  11. <el-form size="small" label-width="120px" v-model="form">
  12. <el-row :gutter="30">
  13. <el-col :span="24" style="text-align: right; margin-bottom: 10px;">
  14. <el-button size="small" type="success" @click="getHistory">历史记录</el-button>
  15. </el-col>
  16. <el-col :span="12">
  17. <el-form-item label="客户名称">
  18. <div>{{ form.companyName }}</div>
  19. </el-form-item>
  20. </el-col>
  21. <el-col :span="12">
  22. <el-form-item label="所属月份">
  23. <!-- <div>{{ form.year }}-{{ form.month }}</div> -->
  24. <el-date-picker v-model="currentMonth" type="month" placeholder="请选择时间" format="YYYY-MM"
  25. @change="changeMonthHandle" />
  26. </el-form-item>
  27. </el-col>
  28. <el-col :span="12">
  29. <el-form-item label="窗口缴纳:" required class="edit-label">
  30. <template #label>
  31. <div>窗口缴纳</div>
  32. </template>
  33. <div>{{ form.isPayOnWindow === 1 ? "是" : "否" }}</div>
  34. </el-form-item>
  35. </el-col>
  36. <el-col :span="12">
  37. <el-form-item label="公积金单位账号" required class="edit-label">
  38. <template #label>
  39. <div>公积金单位账号</div>
  40. </template>
  41. <div>{{ form.housingFundUnitAccount }}</div>
  42. </el-form-item>
  43. </el-col>
  44. <el-col :span="12">
  45. <el-form-item label="公积金秘钥密码" required class="edit-label">
  46. <template #label>
  47. <div>公积金秘钥密码</div>
  48. </template>
  49. <div>{{ form.housingFundPassword }}</div>
  50. </el-form-item>
  51. </el-col>
  52. <el-col :span="12">
  53. <el-form-item label="公积金划款密码" required class="edit-label">
  54. <template #label>
  55. <div>公积金划款密码</div>
  56. </template>
  57. <div>{{ form.housingFundDeductionPassword }}</div>
  58. </el-form-item>
  59. </el-col>
  60. <el-col :span="24">
  61. <div style="display: flex; justify-content: flex-end;margin-bottom: 10px;margin-top: 10px;"
  62. v-hasPermi="['business:housingFundDeclare:exportDetail']">
  63. <el-button type="primary" @click="exportExcel"
  64. v-if="housingFundPersonList != null && housingFundPersonList.length>0">导出明细表</el-button>
  65. </div>
  66. </el-col>
  67. <el-table :data="housingFundPersonList" border style="width: 100%" show-summary
  68. :summary-method="getSummaries">
  69. <el-table-column label="序号" align="center" type="index" />
  70. <el-table-column prop="employeeName" label="人员" />
  71. <el-table-column prop="cardinalNumber" label="基数" />
  72. <el-table-column prop="ratio" label="比例">
  73. <template #default="scope">
  74. {{scope.row.ratio/100}}
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="公司" prop="companyAmount">
  78. </el-table-column>
  79. <el-table-column label="个人" prop="oneSelfAmount">
  80. </el-table-column>
  81. <el-table-column label="缴费金额" prop="totalAmount">
  82. </el-table-column>
  83. </el-table>
  84. <el-col :span="24">
  85. <el-divider />
  86. </el-col>
  87. <el-col :span="12">
  88. <el-form-item label="单位缴纳:">
  89. <el-input-number v-model="form.unitAmount" size="small" v-if="form.status !==3" placeholder="单位缴纳"
  90. :precision="2" :controls="false" style="width: 100%" @change="amountChangeHandler" />
  91. <div v-else>{{ rowNum(form.unitAmount) }}</div>
  92. </el-form-item>
  93. </el-col>
  94. <el-col :span="12">
  95. <el-form-item label="个人缴纳:">
  96. <el-input-number v-model="form.individualAmount" v-if="form.status !==3" size="small" placeholder="个人缴纳"
  97. :precision="2" :controls="false" style="width: 100%" @change="amountChangeHandler" />
  98. <div v-else>{{ rowNum(form.individualAmount) }}</div>
  99. </el-form-item>
  100. </el-col>
  101. <el-col :span="24">
  102. <el-divider />
  103. </el-col>
  104. <el-col :span="24">
  105. <el-form-item label="备注">
  106. <el-input v-model.trim="form.content" v-if="form.status !==3" type="textarea" rows="2" />
  107. <div v-else>{{form.content}}</div>
  108. </el-form-item>
  109. </el-col>
  110. <el-col :span="24">
  111. <el-form-item label="凭证" required>
  112. <img style="height: 148px; width: 148px" :src="`${baseUrl}/${form.evidenceFile}`" class="avatar"
  113. @click="openEvidience()" />
  114. <!-- <el-upload action="#" :http-request="upload" :with-credentials="true" :show-file-list="false" multiple>
  115. <el-button size="small" type="primary" icon="Upload" v-if="form.status !==3">点击上传</el-button>
  116. </el-upload>
  117. <el-table style="margin-top: 15px;" ref="dbTable" :data="form.evidenceFiles" size="small" border
  118. header-row-class-name="list-header-row" row-class-name="list-row">
  119. <el-table-column label="文件名" prop="originalFileName" align="center" show-overflow-tooltip>
  120. <template #default="scope">
  121. <el-button size="small" type="text" @click="openFile(scope.row)">{{
  122. scope.row.originalFileName == ""
  123. ? "打开文件"
  124. : scope.row.originalFileName
  125. }}</el-button>
  126. </template>
  127. </el-table-column>
  128. <el-table-column label="操作" width="80" prop="fileType" align="center">
  129. <template #default="scope">
  130. <el-button size="small" link type="danger" @click="handleDel(scope.row, scope.$index)"
  131. v-if="form.status !==3">删除</el-button>
  132. </template>
  133. </el-table-column>
  134. </el-table> -->
  135. </el-form-item>
  136. </el-col>
  137. </el-row>
  138. </el-form>
  139. </div>
  140. <div class="form-btns-container" style="height: 40px">
  141. <el-button size="small" icon="close" v-if="form.status !== 3"
  142. style="float: right; margin-left: 12px; margin-right: 12px" @click="close">取消</el-button>
  143. <el-button type="primary" style="float: right" size="small" v-if="form.status !== 3" icon="Finished"
  144. @click="handleSave">
  145. 保存</el-button>
  146. <el-button v-show="(toTenantId == form?.entrust?.toTenantId || tenantMyself.tenantId == 0)" v-hasPermi="['business:housingFundDeclare:return']" style="float: right;" icon="back" size="small"
  147. type="warning" :disabled="
  148. form == null || form.status !== 3
  149. " @click="turnBack(form)">退回</el-button>
  150. </div>
  151. </div>
  152. <!-- <feedback-dialog ref="feedbackDialogView" :parent="this" />
  153. <print-dialog ref="printDialog" :parent="this" /> -->
  154. <history ref="fromDialog" :currentMember="form.companyName"></history>
  155. <el-dialog title="退回" v-model="returnFlag" width="720px" append-to-body size="small" draggable
  156. :close-on-click-modal="false">
  157. <el-form-item label="退回理由" prop="refuseReason" style="margin-top: 10px">
  158. <el-input v-model="form.refuseReason" type="textarea" placeholder="请输入取消理由" />
  159. </el-form-item>
  160. <template #footer>
  161. <div class="dialog-footer">
  162. <el-button type="primary" icon="Finished" size="small" @click="submitForm">确 定</el-button>
  163. <el-button icon="close" size="small" @click="returnFlag = false">取 消</el-button>
  164. </div>
  165. </template>
  166. </el-dialog>
  167. </el-dialog>
  168. </template>
  169. <script setup>
  170. import {
  171. getDetail,
  172. saveDetail, turnBackDetail, exportDetail
  173. } from "@/api/business/production/housingFundDeclare";
  174. import { getMembers, getMembersNoDelete } from "@/api/business/production/housingFundDeclare";
  175. import { uploadFile } from "@/api/tool/file";
  176. import { ref } from "vue";
  177. import { rowNum } from "@/utils/index";
  178. import { getTenant } from "@/utils/auth";
  179. import useUserStore from "@/store/modules/user";
  180. import history from "./history";
  181. const { proxy } = getCurrentInstance();
  182. const visible = ref(false);
  183. const width = ref(800);
  184. const selections = ref([]);
  185. const currentSource = ref(null);
  186. const editStatus = ref(false);
  187. const returnFlag = ref(false);
  188. const canSave = ref(false);
  189. const loading = ref(false);
  190. const tenantMyself = useUserStore().user;
  191. const stopUseBack = ref(false)
  192. const currentMonth = ref(
  193. // proxy.moment().format("YYYY-MM-01")
  194. );
  195. const toTenantId = ref([])
  196. const baseUrl = ref(import.meta.env.VITE_APP_BASE_API);
  197. const props = defineProps({
  198. getList: {
  199. type: Function,
  200. default: () => { },
  201. },
  202. });
  203. const housingFundPersonList = ref([])
  204. const { getList } = toRefs(props);
  205. const total = ref(0);
  206. const employeeEmptyData = {
  207. id: null,
  208. title: "",
  209. remark: "",
  210. employeeName: "",
  211. departmentName: "",
  212. idCardImage: "",
  213. idCardImageBack: "",
  214. idiograph: "",
  215. details: [],
  216. editStatus: true,
  217. };
  218. const form = ref({});
  219. const emptyForm = {
  220. details: [],
  221. };
  222. function open(detail) {
  223. console.log(2332,detail);
  224. visible.value = true;
  225. currentMonth.value = detail.year + "-" + detail.month + "-01"
  226. // currentMonth.value = proxy.moment().format("YYYY-MM-01")
  227. form.value = detail;
  228. toTenantId.value = getTenant()
  229. loadData();
  230. }
  231. function openEvidience() {
  232. window.open(`${baseUrl.value}${form.value.evidenceFile}`);
  233. }
  234. function loadData() {
  235. loading.value = true
  236. form.value.year = proxy.moment(currentMonth.value).format("YYYY");
  237. form.value.month = proxy.moment(currentMonth.value).format("MM");
  238. const { year, month, housingFundDeclareId, companyId } = form.value
  239. const clearForm = { year, month, housingFundDeclareId, companyId }
  240. console.log("form.value",form.value);
  241. getDetail(clearForm).then((res) => {
  242. form.value = { ...proxy.deepClone(emptyForm), ...res.data };
  243. form.value.evidenceFile = form.value.evidenceFiles[0].fileUrl;
  244. amountChangeHandler();
  245. let query = { "companyId": companyId, "year": form.value.year, "month": form.value.month }
  246. getMembersNoDelete(query)
  247. .then((res) => {
  248. housingFundPersonList.value = res.data
  249. })
  250. .catch((err) => {
  251. console.log(err);
  252. });
  253. }).finally(() => {
  254. loading.value = false
  255. });
  256. }
  257. const getSummaries = (param) => {
  258. const { columns, data } = param;
  259. const sums = [];
  260. columns.forEach((column, index) => {
  261. if (index === 0) {
  262. sums[index] = '合计';
  263. return;
  264. }
  265. if (index === 1 || index === 2 || index === 3) {
  266. return;
  267. }
  268. const values = data.map(item => Number(item[column.property]));
  269. // if (column.property === 'companyAmount') {
  270. // if (form.value.unitAmount) {
  271. // sums[index] = form.value.unitAmount
  272. // return
  273. // }
  274. // } else if (column.property === 'oneSelfAmount') {
  275. // if (form.value.unitAmount) {
  276. // sums[index] = form.value.individualAmount
  277. // return
  278. // }
  279. // }
  280. // else if (column.property === 'totalAmount') {
  281. // if (form.value.unitAmount && form.value.individualAmount) {
  282. // sums[index] = form.value.individualAmount + form.value.unitAmount
  283. // return
  284. // }
  285. // }
  286. sums[index] = values.reduce((prev, curr) => {
  287. const value = Number(curr);
  288. if (!isNaN(value)) {
  289. return prev + curr;
  290. } else {
  291. return prev;
  292. }
  293. }, 0);
  294. });
  295. return sums
  296. }
  297. function changeMonthHandle() {
  298. // isView.value = true
  299. const nowDate = ref(
  300. proxy.moment().format("YYYY-MM-01")
  301. );
  302. let nowyear = proxy.moment(nowDate.value).format("YYYY");
  303. let nowmonth = proxy.moment(nowDate.value).format("MM");
  304. const year = proxy.moment(currentMonth.value).format("YYYY");
  305. const month = proxy.moment(currentMonth.value).format("MM");
  306. if (nowyear + nowmonth == year + month) {
  307. // isView.value = false
  308. stopUseBack.value = false
  309. } else {
  310. stopUseBack.value = true
  311. }
  312. loadData()
  313. }
  314. function close() {
  315. visible.value = false;
  316. reset();
  317. }
  318. function turnBack(detail) {
  319. returnFlag.value = true;
  320. }
  321. function submitForm(){
  322. loading.value = true
  323. form.value.status = 1;
  324. form.value.year = proxy.moment(currentMonth.value).format("YYYY");
  325. form.value.month = proxy.moment(currentMonth.value).format("MM");
  326. turnBackDetail(form.value)
  327. .then((res) => {
  328. getList.value();
  329. })
  330. .catch((err) => {
  331. proxy.$modal.msgError(err.message);
  332. }).finally(() => {
  333. loading.value = false
  334. visible.value = false;
  335. returnFlag.value = false;
  336. });
  337. }
  338. function reset() {
  339. form.value = proxy.deepClone(emptyForm);
  340. canSave.value = false;
  341. }
  342. function handleCurrentChange(row) {
  343. currentSource.value = row;
  344. }
  345. function handleCheckChange(selection) {
  346. selections.value = selection.map((item) => item);
  347. }
  348. function handleSave() {
  349. if (form.value.isFirstSocialSecurity === 0) {
  350. if (!form.value.governmentAccountNo) {
  351. proxy.$modal.msgError("请输入政务网账号");
  352. return;
  353. }
  354. if (!form.value.governmentPassword) {
  355. proxy.$modal.msgError("请输入政务网密码");
  356. return;
  357. }
  358. if (!passwordCheck(form.value.governmentPassword)) {
  359. proxy.$modal.msgError("请输入正确的政务网密码");
  360. return;
  361. }
  362. if (!form.value.socialSecurityAccountNo) {
  363. proxy.$modal.msgError("请输入社保账号");
  364. return;
  365. }
  366. if (!form.value.socialSecurityPassword) {
  367. proxy.$modal.msgError("请输入社保密码");
  368. return;
  369. }
  370. if (!passwordCheck(form.value.socialSecurityPassword)) {
  371. proxy.$modal.msgError("请输入正确的社保密码");
  372. return;
  373. }
  374. if (!form.value.employeePassword) {
  375. proxy.$modal.msgError("请输入用工密码");
  376. return;
  377. }
  378. if (!passwordCheck(form.value.employeePassword)) {
  379. proxy.$modal.msgError("请输入正确的用工密码");
  380. return;
  381. }
  382. }
  383. if (
  384. form.value.evidenceFiles == null ||
  385. form.value.evidenceFiles.length === 0
  386. ) {
  387. proxy.$modal.msgError("请上传凭证");
  388. return;
  389. }
  390. // if (form.value.reportFiles == null || form.value.reportFiles.length === 0) {
  391. // proxy.$modal.msgError("请上传报表");
  392. // return;
  393. // }
  394. proxy.$modal
  395. .confirm("确认保存么?")
  396. .then(() => {
  397. const saveValue = proxy.deepClone(form.value);
  398. saveValue.status = 3;
  399. saveValue.year = proxy.moment(currentMonth.value).format("YYYY");
  400. saveValue.month = proxy.moment(currentMonth.value).format("MM");
  401. saveDetail(saveValue).then((res) => {
  402. proxy.$modal.msgSuccess("保存成功");
  403. reset();
  404. close();
  405. getList.value();
  406. });
  407. })
  408. .catch((err) => {
  409. proxy.$modal.msg("取消保存");
  410. });
  411. }
  412. function getHistory() {
  413. proxy.$refs.fromDialog.open(form.value.companyId);
  414. }
  415. function passwordCheckHandler(value, field) {
  416. // console.log(value)
  417. if (!passwordCheck(form.value[field])) {
  418. proxy.$modal.msgError("请输入正确密码");
  419. }
  420. }
  421. function passwordCheck(value) {
  422. const pattern = /^[A-Za-z0-9~!@#$%^&*()_+-=]*$/;
  423. if (!pattern.test(value)) {
  424. return false;
  425. }
  426. return true;
  427. }
  428. function upload(param) {
  429. const formData = new FormData();
  430. formData.append("file", param.file);
  431. uploadFile(formData).then((res) => {
  432. if (res.code === 200) {
  433. const file = {};
  434. file.fileName = res.originalFilename;
  435. file.url = res.url;
  436. file.originalFileName = res.originalFilename;
  437. file.fileUrl = res.fileName;
  438. form.value.evidenceFiles.push(file);
  439. }
  440. });
  441. }
  442. function openFile(row) {
  443. window.open(`${baseUrl.value}${row.fileUrl}`);
  444. }
  445. function changeEdit() {
  446. editStatus.value = !editStatus.value;
  447. }
  448. function amountChangeHandler() {
  449. let amount = 0;
  450. amount += form.value.unitAmount == null ? 0 : form.value.unitAmount;
  451. amount +=
  452. form.value.individualAmount == null ? 0 : form.value.individualAmount;
  453. form.value.amount = amount;
  454. }
  455. function exportExcel() {
  456. let data = {
  457. "companyId": form.value.companyId,
  458. "year": form.value.year,
  459. "month": form.value.month
  460. }
  461. exportDetail(data)
  462. }
  463. function handleDel(row, index) {
  464. proxy.$modal
  465. .confirm("确定删除吗?")
  466. .then((_) => {
  467. form.value.evidenceFiles.splice(index, 1);
  468. })
  469. .catch((_) => {
  470. proxy.$modal.msg("已取消删除");
  471. });
  472. }
  473. // 暴露给父组件的方法
  474. defineExpose({
  475. open,
  476. });
  477. </script>
  478. <style scoped>
  479. .img {
  480. width: 23px;
  481. height: 23px;
  482. display: flex;
  483. justify-content: center;
  484. align-items: center;
  485. }
  486. ::v-deep(.el-upload) {
  487. display: flex;
  488. text-align: center;
  489. justify-content: center;
  490. cursor: pointer;
  491. outline: 0;
  492. }
  493. .required::after {
  494. content: "*";
  495. color: red;
  496. }
  497. </style>