view.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <template>
  2. <el-dialog
  3. title="公积金申报信息"
  4. v-model="visible"
  5. :width="width"
  6. append-to-body
  7. draggable
  8. @close="close"
  9. >
  10. <!-- <div slot="title" class="dialog-title-container">
  11. <span class="title-label"><i class="el-icon-document" /> 工资信息</span>
  12. <i class="el-icon-close" @click="close" />
  13. </div> -->
  14. <!-- 功能按钮 -->
  15. <div style="padding: 8px 24px 16px 24px">
  16. <el-form size="small" label-width="120px" v-model="form">
  17. <el-row :gutter="30">
  18. <el-col :span="12">
  19. <el-form-item label="客户名称">
  20. <div>{{ form.companyName }}</div>
  21. </el-form-item>
  22. </el-col>
  23. <el-col :span="12">
  24. <el-form-item label="所属月份">
  25. <div>{{ form.year }}-{{ form.month }}</div>
  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. <el-divider />
  62. </el-col>
  63. <el-col :span="12">
  64. <el-form-item label="单位缴纳:">
  65. <div>{{ rowNum(form.unitAmount) }}</div>
  66. </el-form-item>
  67. </el-col>
  68. <el-col :span="12">
  69. <el-form-item label="个人缴纳:">
  70. <div>{{ rowNum(form.individualAmount) }}</div>
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="24">
  74. <el-divider />
  75. </el-col>
  76. <el-col :span="24">
  77. <el-form-item label="备注">
  78. <div>{{ form.content }}</div>
  79. </el-form-item>
  80. </el-col>
  81. <el-col :span="24">
  82. <el-form-item label="凭证" required>
  83. <el-table
  84. ref="dbTable"
  85. :data="form.evidenceFiles"
  86. size="small"
  87. border
  88. header-row-class-name="list-header-row"
  89. row-class-name="list-row"
  90. >
  91. <el-table-column
  92. label="文件名"
  93. prop="originalFileName"
  94. align="center"
  95. show-overflow-tooltip
  96. >
  97. <template #default="scope">
  98. <el-button
  99. size="small"
  100. type="text"
  101. @click="openFile(scope.row)"
  102. >{{
  103. scope.row.originalFileName == ""
  104. ? "打开文件"
  105. : scope.row.originalFileName
  106. }}</el-button
  107. >
  108. </template>
  109. </el-table-column>
  110. </el-table>
  111. </el-form-item>
  112. </el-col>
  113. </el-row>
  114. </el-form>
  115. </div>
  116. <div class="form-btns-container" style="height: 40px">
  117. <el-button size="small" icon="Close" style="float: right" @click="close">
  118. 取消</el-button
  119. >
  120. </div>
  121. <!-- <feedback-dialog ref="feedbackDialogView" :parent="this" />
  122. <print-dialog ref="printDialog" :parent="this" /> -->
  123. </el-dialog>
  124. </template>
  125. <script setup>
  126. import {
  127. getDetail,
  128. saveDetail,
  129. } from "@/api/business/production/housingFundDeclare";
  130. import { uploadFile } from "@/api/tool/file";
  131. import { ref } from "vue";
  132. import { rowNum } from "@/utils/index";
  133. const { proxy } = getCurrentInstance();
  134. const visible = ref(false);
  135. const width = ref(800);
  136. const selections = ref([]);
  137. const currentSource = ref(null);
  138. const editStatus = ref(false);
  139. const canSave = ref(false);
  140. const baseUrl = ref(import.meta.env.VITE_APP_BASE_API);
  141. const props = defineProps({
  142. getList: {
  143. type: Function,
  144. default: () => {},
  145. },
  146. });
  147. const { getList } = toRefs(props);
  148. const total = ref(0);
  149. const employeeEmptyData = {
  150. id: null,
  151. title: "",
  152. remark: "",
  153. employeeName: "",
  154. departmentName: "",
  155. idCardImage: "",
  156. idCardImageBack: "",
  157. idiograph: "",
  158. details: [],
  159. editStatus: true,
  160. };
  161. const form = ref({});
  162. const emptyForm = {
  163. details: [],
  164. };
  165. function open(detail) {
  166. visible.value = true;
  167. form.value = detail;
  168. loadData();
  169. }
  170. function loadData() {
  171. getDetail(form.value).then((res) => {
  172. form.value = { ...proxy.deepClone(emptyForm), ...res.data };
  173. amountChangeHandler();
  174. });
  175. }
  176. function close() {
  177. visible.value = false;
  178. reset();
  179. }
  180. function reset() {
  181. form.value = proxy.deepClone(emptyForm);
  182. canSave.value = false;
  183. }
  184. function handleCurrentChange(row) {
  185. currentSource.value = row;
  186. }
  187. function handleCheckChange(selection) {
  188. selections.value = selection.map((item) => item);
  189. }
  190. function handleSave() {
  191. for (let i = 0; i < form.value.details.length; i++) {
  192. const l = form.value.details[i];
  193. // 数据校验
  194. if (l.employeeName == null || l.employeeName === "") {
  195. proxy.$modal.msgError(`第${i + 1}行姓名不能为空`);
  196. return;
  197. }
  198. if (l.phone == null || l.phone === "") {
  199. proxy.$modal.msgError(`第${i + 1}行电话不能为空`);
  200. return;
  201. }
  202. // 正则表达式匹配身份证号的格式
  203. const regExp = /1[3-9]\d{9}/;
  204. if (!regExp.test(l.phone)) {
  205. proxy.$modal.msgError(`第${i + 1}行请输入正确的电话号码!`);
  206. return;
  207. }
  208. if (!l.idCardImage) {
  209. proxy.$modal.msgError(`第${i + 1}行身份证正面照不能为空`);
  210. return;
  211. }
  212. if (!l.idCardImageBack) {
  213. proxy.$modal.msgError(`第${i + 1}行身份证反面照不能为空`);
  214. return;
  215. }
  216. if (!l.cardinalNumber) {
  217. proxy.$modal.msgError(`第${i + 1}行基数不能为空`);
  218. return;
  219. }
  220. // if (!l.medicalCardinalNumber) {
  221. // proxy.$modal.msgError(`第${i + 1}行医疗基数不能为空`);
  222. //return;
  223. //}
  224. }
  225. if (form.value.isFirstSocialSecurity === 0) {
  226. if (!form.value.governmentAccountNo) {
  227. proxy.$modal.msgError("请输入政务网账号");
  228. return;
  229. }
  230. if (!form.value.governmentPassword) {
  231. proxy.$modal.msgError("请输入政务网密码");
  232. return;
  233. }
  234. if (!passwordCheck(form.value.governmentPassword)) {
  235. proxy.$modal.msgError("请输入正确的政务网密码");
  236. return;
  237. }
  238. if (!form.value.socialSecurityAccountNo) {
  239. proxy.$modal.msgError("请输入社保账号");
  240. return;
  241. }
  242. if (!form.value.socialSecurityPassword) {
  243. proxy.$modal.msgError("请输入社保密码");
  244. return;
  245. }
  246. if (!passwordCheck(form.value.socialSecurityPassword)) {
  247. proxy.$modal.msgError("请输入正确的社保密码");
  248. return;
  249. }
  250. if (!form.value.employeePassword) {
  251. proxy.$modal.msgError("请输入用工密码");
  252. return;
  253. }
  254. if (!passwordCheck(form.value.employeePassword)) {
  255. proxy.$modal.msgError("请输入正确的用工密码");
  256. return;
  257. }
  258. }
  259. proxy.$modal
  260. .confirm("确认保存么?")
  261. .then(() => {
  262. const saveValue = proxy.deepClone(form.value);
  263. saveValue.status = 3;
  264. saveDetail(saveValue).then((res) => {
  265. proxy.$modal.msgSuccess("保存成功");
  266. reset();
  267. close();
  268. getList.value();
  269. });
  270. })
  271. .catch((err) => {
  272. proxy.$modal.msg("取消保存");
  273. });
  274. }
  275. function passwordCheckHandler(value, field) {
  276. // console.log(value)
  277. if (!passwordCheck(form.value[field])) {
  278. proxy.$modal.msgError("请输入正确密码");
  279. }
  280. }
  281. function passwordCheck(value) {
  282. const pattern = /^[A-Za-z0-9~!@#$%^&*()_+-=]*$/;
  283. if (!pattern.test(value)) {
  284. return false;
  285. }
  286. return true;
  287. }
  288. function upload(param) {
  289. const formData = new FormData();
  290. formData.append("file", param.file);
  291. uploadFile(formData).then((res) => {
  292. if (res.code === 200) {
  293. const file = {};
  294. file.fileName = res.newFileName;
  295. file.url = res.url;
  296. file.originalFileName = res.originalFilename;
  297. file.fileUrl = res.fileName;
  298. form.value.evidenceFiles.push(file);
  299. }
  300. });
  301. }
  302. function openFile(row) {
  303. window.open(`${baseUrl.value}${row.fileUrl}`);
  304. }
  305. function changeEdit() {
  306. editStatus.value = !editStatus.value;
  307. }
  308. function amountChangeHandler() {
  309. let amount = 0;
  310. amount += form.value.unitAmount == null ? 0 : form.value.unitAmount;
  311. amount +=
  312. form.value.individualAmount == null ? 0 : form.value.individualAmount;
  313. form.value.amount = amount;
  314. }
  315. function handleDel(row, index) {
  316. proxy.$modal
  317. .confirm("确定删除吗?")
  318. .then((_) => {
  319. form.value.evidenceFiles.splice(index, 1);
  320. })
  321. .catch((_) => {
  322. proxy.$modal.msg("已取消删除");
  323. });
  324. }
  325. // 暴露给父组件的方法
  326. defineExpose({
  327. open,
  328. });
  329. </script>
  330. <style scoped>
  331. .img {
  332. width: 23px;
  333. height: 23px;
  334. display: flex;
  335. justify-content: center;
  336. align-items: center;
  337. }
  338. ::v-deep(.el-upload) {
  339. display: flex;
  340. text-align: center;
  341. justify-content: center;
  342. cursor: pointer;
  343. outline: 0;
  344. }
  345. .required::after {
  346. content: "*";
  347. color: red;
  348. }
  349. </style>