view.vue 16 KB

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