form.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. <template>
  2. <el-dialog title="社保人员信息" v-model="visible" width="80%" append-to-body draggable @close="close"
  3. :close-on-click-modal="false">
  4. <div v-loading="loading">
  5. <!-- <div slot="title" class="dialog-title-container">
  6. <span class="title-label"><i class="el-icon-document" /> 工资信息</span>
  7. <i class="el-icon-close" @click="close" />
  8. </div> -->
  9. <!-- 功能按钮 -->
  10. <div style="padding: 8px 24px 16px 24px">
  11. <el-form size="small" label-width="100px" 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-form-item>
  22. </el-col>
  23. <el-col v-if="form.status === 4" :span="12">
  24. <el-form-item label="驳回原因">
  25. <div>{{ form.feedbackContent }}</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>
  32. 政务网账号<el-button v-if="form.isFirstSocialSecurity === 1" type="primary" link icon="Edit"
  33. @click="changeEdit" />
  34. </div>
  35. </template>
  36. <el-input v-if="form.isFirstSocialSecurity === 0 || editStatus" v-model="form.governmentAccountNo"
  37. placeholder="请输入政务网账号" />
  38. <div v-else>{{ form.governmentAccountNo }}</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>
  45. 政务网密码<el-button v-if="form.isFirstSocialSecurity === 1" type="primary" link icon="Edit"
  46. @click="changeEdit" />
  47. </div>
  48. </template>
  49. <el-input v-if="form.isFirstSocialSecurity === 0 || editStatus" v-model="form.governmentPassword"
  50. placeholder="请输入政务网密码" @blur="
  51. (value) => passwordCheckHandler(value, 'governmentPassword')
  52. " />
  53. <div v-else>{{ form.governmentPassword }}</div>
  54. </el-form-item>
  55. </el-col>
  56. <el-col :span="12">
  57. <el-form-item label="社保账号" required class="edit-label">
  58. <template #label>
  59. <div>
  60. 社保账号<el-button v-if="form.isFirstSocialSecurity === 1" type="primary" link icon="Edit"
  61. @click="changeEdit" />
  62. </div>
  63. </template>
  64. <el-input v-if="form.isFirstSocialSecurity === 0 || editStatus" v-model="form.socialSecurityAccountNo"
  65. placeholder="请输入社保账号" />
  66. <div v-else>{{ form.socialSecurityAccountNo }}</div>
  67. </el-form-item>
  68. </el-col>
  69. <el-col :span="12">
  70. <el-form-item label="社保密码" required class="edit-label">
  71. <template #label>
  72. <div>
  73. 社保密码<el-button v-if="form.isFirstSocialSecurity === 1" type="primary" link icon="Edit"
  74. @click="changeEdit" />
  75. </div>
  76. </template>
  77. <el-input v-if="form.isFirstSocialSecurity === 0 || editStatus" v-model="form.socialSecurityPassword"
  78. placeholder="请输入社保密码" @blur="
  79. (value) =>
  80. passwordCheckHandler(value, 'socialSecurityPassword')
  81. " />
  82. <div v-else>{{ form.socialSecurityPassword }}</div>
  83. </el-form-item>
  84. </el-col>
  85. <el-col :span="12">
  86. <el-form-item label="用工密码" required class="edit-label">
  87. <template #label>
  88. <div>
  89. 用工密码<el-button v-if="form.isFirstSocialSecurity === 1" type="primary" link icon="Edit"
  90. @click="changeEdit" />
  91. </div>
  92. </template>
  93. <el-input v-if="form.isFirstSocialSecurity === 0 || editStatus" v-model="form.employeePassword"
  94. placeholder="请输入用工密码" @blur="
  95. (value) => passwordCheckHandler(value, 'employeePassword')
  96. " />
  97. <div v-else>{{ form.employeePassword }}</div>
  98. </el-form-item>
  99. </el-col>
  100. <el-col :span="24" class="details-container">
  101. <!--操作按钮 开始-->
  102. <div class="details-head">
  103. <div class="title">
  104. <i class="fa fa-th-list" aria-hidden="true" /> 人员信息
  105. </div>
  106. <el-button class="button-class" type="primary" icon="plus" size="small" @click="handleEmployeeCreate">
  107. 新增</el-button>
  108. <el-button class="button-class" v-if="selections.length > 0" type="danger" size="small" icon="delete"
  109. @click="handleEmployeeBatchDelete">删除</el-button>
  110. <el-button type="danger" v-if="selections.length > 0" size="small" icon="delete" class="button-class"
  111. @click="handleEmployeeNotBatchDelete">取消删除
  112. </el-button>
  113. </div>
  114. <div class="details-body">
  115. <div>
  116. <el-table ref="sourceTable" :data="form.details" size="small" max-height="490px" border show-summary
  117. :summary-method="getSummaries" highlight-current-row header-row-class-name="list-header-row"
  118. :row-class-name="tableRowClassName" class="salary-table" @selection-change="handleCheckChange"
  119. @current-change="handleCurrentChange">
  120. <el-table-column type="selection" width="50" align="center" />
  121. <el-table-column type="index" label="序号" width="50" align="center" />
  122. <el-table-column label="姓名" width="80" align="center">
  123. <template #default="scope">
  124. <div>
  125. <el-input v-model="scope.row.employeeName" size="small" placeholder="姓名"
  126. style="width: 100%" />
  127. </div>
  128. <span style="
  129. color: red;
  130. position: absolute;
  131. z-index: 10;
  132. top: 4px;
  133. right: 12px;
  134. ">*</span>
  135. </template>
  136. </el-table-column>
  137. <el-table-column label="电话号码" width="130" align="center">
  138. <template #default="scope">
  139. <div>
  140. <el-input v-model="scope.row.phone" size="small" minlength="1" maxlength="11"
  141. placeholder="电话号码" style="width: 100%" oninput="value=value.replace(/[^\d]/g, '')" />
  142. </div>
  143. <span style="
  144. color: red;
  145. position: absolute;
  146. z-index: 10;
  147. top: 4px;
  148. right: 12px;
  149. ">*</span>
  150. </template>
  151. </el-table-column>
  152. <el-table-column label="身份证正面" width="120" align="center">
  153. <template #default="scope">
  154. <div>
  155. <!-- <el-upload
  156. action="#"
  157. :http-request="
  158. (params) => upload(params, scope.row, 'idCardImage')
  159. "
  160. :with-credentials="true"
  161. :show-file-list="false"
  162. >
  163. <template v-if="scope.row.idCardImage === ''">
  164. <div class="el-upload__text" style="color: blue">
  165. 点击上传
  166. </div>
  167. </template>
  168. <img
  169. v-else
  170. class="img"
  171. :src="baseUrl + '/' + scope.row.idCardImage"
  172. alt=""
  173. />
  174. </el-upload> -->
  175. <div>
  176. <div id="preview" v-on:paste="handlePaste($event,scope.row,'idCardImage')"
  177. v-if="scope.row.idCardImage === ''">
  178. <span>将图片粘贴至此</span>
  179. </div>
  180. <div class="image-container" v-else>
  181. <el-image class="img" :src="baseUrl + scope.row.idCardImage" alt=""
  182. preview-teleported="true" fit="contain" :preview-src-list="srcList"
  183. @click="vbs(baseUrl + scope.row.idCardImage)" />
  184. <!-- 删除按钮 -->
  185. <el-icon v-if="scope.row.idCardImage !== ''" @click="scope.row.idCardImage = ''"
  186. class="delete-button">
  187. <Delete />
  188. </el-icon>
  189. </div>
  190. </div>
  191. </div>
  192. <span style="
  193. color: red;
  194. position: absolute;
  195. z-index: 10;
  196. top: 4px;
  197. right: 12px;
  198. ">*</span>
  199. </template>
  200. </el-table-column>
  201. <el-table-column label="身份证反面" width="120" align="center">
  202. <template #default="scope">
  203. <div>
  204. <!-- <el-upload
  205. action="#"
  206. :http-request="
  207. (params) =>
  208. upload(params, scope.row, 'idCardImageBack')
  209. "
  210. :with-credentials="true"
  211. :show-file-list="false"
  212. >
  213. <template v-if="scope.row.idCardImageBack === ''">
  214. <div class="el-upload__text" style="color: blue">
  215. 点击上传
  216. </div>
  217. </template>
  218. <img
  219. v-else
  220. class="img"
  221. :src="baseUrl + '/' + scope.row.idCardImageBack"
  222. alt=""
  223. />
  224. </el-upload> -->
  225. <div>
  226. <div id="preview2" v-on:paste="handlePaste($event,scope.row,'idCardImageBack')"
  227. v-if="scope.row.idCardImageBack === ''">
  228. <span>将图片粘贴至此</span>
  229. </div>
  230. <div class="image-container" v-else>
  231. <el-image class="img" :src="baseUrl + scope.row.idCardImageBack" alt=""
  232. preview-teleported="true" fit="contain" :preview-src-list="srcListback"
  233. @click="vbsBack(baseUrl + scope.row.idCardImageBack)" />
  234. <!-- 删除按钮 -->
  235. <el-icon v-if="scope.row.idCardImageBack !== ''" @click="scope.row.idCardImageBack = ''"
  236. class="delete-button">
  237. <Delete />
  238. </el-icon>
  239. </div>
  240. </div>
  241. </div>
  242. <span style="
  243. color: red;
  244. position: absolute;
  245. z-index: 10;
  246. top: 4px;
  247. right: 12px;
  248. ">*</span>
  249. </template>
  250. </el-table-column>
  251. <el-table-column label="采暖费" width="100" align="center">
  252. <template #default="scope">
  253. <div>
  254. <el-input-number v-model="scope.row.heatingFee" :precision="2" :controls="false"
  255. style="width: 100%; align: left" size="small" placeholder="采暖费" />
  256. </div>
  257. <!-- <span
  258. style="
  259. color: red;
  260. position: absolute;
  261. z-index: 10;
  262. top: 4px;
  263. right: 12px;
  264. "
  265. >*</span
  266. > -->
  267. </template>
  268. </el-table-column>
  269. <el-table-column label="基数" width="100" align="center">
  270. <template #default="scope">
  271. <div>
  272. <el-input-number v-model="scope.row.cardinalNumber" :precision="2" :controls="false"
  273. style="width: 100%; align: left" size="small" placeholder="基数" />
  274. </div>
  275. <span style="
  276. color: red;
  277. position: absolute;
  278. z-index: 10;
  279. top: 4px;
  280. right: 12px;
  281. ">*</span>
  282. </template>
  283. </el-table-column>
  284. <el-table-column label="医疗基数" width="100" align="center">
  285. <template #default="scope">
  286. <div>
  287. <el-input-number v-model="scope.row.medicalCardinalNumber" :precision="2" :controls="false"
  288. style="width: 100%" size="small" placeholder="基数" />
  289. </div>
  290. <span style="
  291. color: red;
  292. position: absolute;
  293. z-index: 10;
  294. top: 4px;
  295. right: 12px;
  296. ">*</span>
  297. </template>
  298. </el-table-column>
  299. <!-- <el-table-column label="签名" width="100" header-align="center" required>
  300. </el-table-column> -->
  301. <el-table-column label="备注" header-align="center">
  302. <template #default="scope">
  303. <div>
  304. <el-input v-model="scope.row.remark" size="small" placeholder="备注" />
  305. </div>
  306. </template>
  307. </el-table-column>
  308. </el-table>
  309. </div>
  310. </div>
  311. </el-col>
  312. <el-col :span="24">
  313. <el-divider />
  314. </el-col>
  315. <el-col :span="24">
  316. <el-form-item label="社保人员变更">
  317. <el-select v-model="form.isChanged" placeholder="请选择" style="width: 100%">
  318. <el-option v-for="item in yesOrNo" :key="item.label" :label="item.label" :value="item.value" />
  319. </el-select>
  320. </el-form-item>
  321. </el-col>
  322. <el-col :span="24">
  323. <el-form-item label="备注">
  324. <el-input v-model.trim="form.content" maxlength="200" show-word-limit type="textarea" rows="2" />
  325. </el-form-item>
  326. </el-col>
  327. </el-row>
  328. </el-form>
  329. </div>
  330. <div class="form-btns-container" style="height: 40px">
  331. <el-button size="small" style="float: right; margin-left: 12px; margin-right: 12px" icon="close"
  332. @click="close">取消
  333. </el-button>
  334. <el-button size="small" type="primary" icon="Finished" style="float: right"
  335. @click="handleSave(2)">保存</el-button>
  336. <el-button type="warning" size="small" icon="Edit" style="float: right" @click="handleSave(1)">
  337. 待确认</el-button>
  338. </div>
  339. </div>
  340. <!-- <feedback-dialog ref="feedbackDialogView" :parent="this" />
  341. <print-dialog ref="printDialog" :parent="this" /> -->
  342. </el-dialog>
  343. </template>
  344. <script setup>
  345. import {
  346. getDetail,
  347. saveDetail,
  348. updateDetail,
  349. checkEmployees,
  350. } from "@/api/business/production/socialSecurityConfirm";
  351. import { uploadFile } from "@/api/tool/file";
  352. import zTool from '@/utils/zTool'
  353. import { ref } from "vue";
  354. import { yesOrNo } from "@/utils/default";
  355. const { proxy } = getCurrentInstance();
  356. const visible = ref(false);
  357. const width = ref(800);
  358. const selections = ref([]);
  359. const currentSource = ref(null);
  360. const editStatus = ref(false);
  361. const baseUrl = ref(import.meta.env.VITE_APP_BASE_API);
  362. const props = defineProps({
  363. getList: {
  364. type: Function,
  365. default: () => { },
  366. },
  367. });
  368. const tempFile = ref(null)
  369. const srcList = ref([
  370. "https://elevator4s-oss.oss-cn-hangzhou.aliyuncs.com/2021/05/07/b632db6a837f46e0950670277fa9e5e5multipartFile.png"
  371. ]);
  372. const srcListback = ref([
  373. "https://elevator4s-oss.oss-cn-hangzhou.aliyuncs.com/2021/05/07/b632db6a837f46e0950670277fa9e5e5multipartFile.png"
  374. ]);
  375. const { getList } = toRefs(props);
  376. const total = ref(0);
  377. const loading = ref(false)
  378. const employeeEmptyData = {
  379. id: null,
  380. title: "",
  381. remark: "",
  382. employeeName: "",
  383. departmentName: "",
  384. idCardImage: "",
  385. idCardImageBack: "",
  386. idiograph: "",
  387. details: [],
  388. editStatus: true,
  389. };
  390. const form = ref({});
  391. const emptyForm = {
  392. details: [],
  393. };
  394. function open(detail) {
  395. visible.value = true;
  396. form.value = detail;
  397. loadData();
  398. }
  399. function loadData() {
  400. loading.value = true
  401. getDetail(form.value).then((res) => {
  402. form.value = { ...proxy.deepClone(emptyForm), ...res.data };
  403. if (form.value.status === 2 || form.value.status === 3) {
  404. proxy.$modal.msgError("该信息已提交待审核");
  405. close();
  406. }
  407. computeTotal();
  408. }).finally(() => {
  409. loading.value = false
  410. });
  411. }
  412. function close() {
  413. visible.value = false;
  414. reset();
  415. }
  416. function reset() {
  417. form.value = proxy.deepClone(emptyForm);
  418. }
  419. function printSalary() { }
  420. function exportSalary() { }
  421. function handleCurrentChange(row) {
  422. currentSource.value = row;
  423. }
  424. function handleCheckChange(selection) {
  425. selections.value = selection.map((item) => item);
  426. }
  427. function handleEmployeeCreate() {
  428. // 此处必须进行深拷贝,否则添加的明细,将都指向了一个对象
  429. employeeEmptyData.add = 1
  430. employeeEmptyData.changeStatus = 1
  431. const _newSource = JSON.parse(JSON.stringify(employeeEmptyData));
  432. form.value.details.push(_newSource);
  433. handleCurrentChange(_newSource);
  434. }
  435. function handleEmployeeBatchDelete() {
  436. proxy.$modal
  437. .confirm("确定删除?")
  438. .then(() => {
  439. // form.value.details = form.value.details.filter(
  440. // (item) => selections.value.indexOf(item) === -1
  441. // );
  442. for (let index = 0; index < form.value.details.length; index++) {
  443. let x = form.value.details[index];
  444. for (let index2 = 0; index2 < selections.value.length; index2++) {
  445. let y = selections.value[index2];
  446. if(x.changeStatus == 1){
  447. x.isnew = true;
  448. }
  449. if (x.phone + x.employeeName === y.phone + y.employeeName && y.add !== 1) {
  450. x.changeStatus = 2;
  451. }
  452. else {
  453. let selectionsFilter = selections.value.filter((item) => item.add == 1);
  454. form.value.details = form.value.details.filter(
  455. (item) => selectionsFilter.indexOf(item) === -1
  456. );
  457. }
  458. }
  459. }
  460. })
  461. .catch(() => {
  462. proxy.$modal.msg("已取消删除");
  463. });
  464. }
  465. function tableRowClassName({ row, index }) {
  466. if (row.changeStatus === 1) {
  467. return "list-row add-row";
  468. } else if(row.isnew && row.changeStatus === 2) {
  469. return "list-row new-delete-row";
  470. } else if (row.changeStatus === 2) {
  471. return "list-row delete-row";
  472. }else {
  473. return "list-row";
  474. }
  475. }
  476. function rowChangeSum(row) {
  477. let actuallySalary = 0;
  478. actuallySalary += row.planSalary == null ? 0 : row.planSalary;
  479. actuallySalary += row.bonusAmount == null ? 0 : row.bonusAmount;
  480. actuallySalary -= row.endowmentInsurance == null ? 0 : row.endowmentInsurance;
  481. actuallySalary -= row.medicalInsurance == null ? 0 : row.medicalInsurance;
  482. actuallySalary -=
  483. row.unemploymentBenefit == null ? 0 : row.unemploymentBenefit;
  484. actuallySalary -=
  485. row.seriousIllnessInsurance == null ? 0 : row.seriousIllnessInsurance;
  486. actuallySalary -= row.housingFund == null ? 0 : row.housingFund;
  487. actuallySalary -=
  488. row.currentIndividualIncomeTax == null ? 0 : row.currentIndividualIncomeTax;
  489. actuallySalary -= row.otherCut == null ? 0 : row.otherCut;
  490. row.actuallySalary = actuallySalary;
  491. computeTotal();
  492. }
  493. function computeTotal() {
  494. let totalSalay = 0;
  495. form.value.details.forEach((l) => {
  496. totalSalay += l.actuallySalary == null ? 0 : l.actuallySalary;
  497. });
  498. form.value.amount = totalSalay.toFixed(2);
  499. }
  500. function vbs(val) {
  501. srcList.value = []
  502. srcList.value.push(val)
  503. }
  504. function vbsBack(val) {
  505. srcListback.value = []
  506. srcListback.value.push(val)
  507. }
  508. function getSummaries(param) {
  509. const { columns, data } = param;
  510. const sums = [];
  511. columns.forEach((column, index) => {
  512. if (index === 0) {
  513. sums[index] = "合计";
  514. return;
  515. } else if (index === 1) {
  516. sums[index] = "";
  517. return;
  518. }
  519. const values = data.map((item) => Number(item[column.property]));
  520. if (!values.every((value) => isNaN(value))) {
  521. sums[index] = values.reduce((prev, curr) => {
  522. const value = Number(curr);
  523. if (!isNaN(value)) {
  524. return (Number(prev) + Number(curr)).toFixed(2);
  525. } else {
  526. return Number(prev).toFixed(2);
  527. }
  528. }, 0);
  529. } else {
  530. sums[index] = "";
  531. }
  532. });
  533. return sums;
  534. }
  535. async function handleSave(status) {
  536. for (let i = 0; i < form.value.details.length; i++) {
  537. const l = form.value.details[i];
  538. // 数据校验
  539. if (l.employeeName == null || l.employeeName === "") {
  540. proxy.$modal.msgError(`第${i + 1}行姓名不能为空`);
  541. return;
  542. }
  543. if (l.phone == null || l.phone === "") {
  544. proxy.$modal.msgError(`第${i + 1}行电话不能为空`);
  545. return;
  546. }
  547. // 正则表达式匹配身份证号的格式
  548. const regExp = /1[3-9]\d{9}/;
  549. if (!regExp.test(l.phone)) {
  550. proxy.$modal.msgError(`第${i + 1}行请输入正确的电话号码!`);
  551. return;
  552. }
  553. if (!l.idCardImage) {
  554. proxy.$modal.msgError(`第${i + 1}行身份证正面照不能为空`);
  555. return;
  556. }
  557. if (!l.idCardImageBack) {
  558. proxy.$modal.msgError(`第${i + 1}行身份证反面照不能为空`);
  559. return;
  560. }
  561. if (!l.cardinalNumber) {
  562. proxy.$modal.msgError(`第${i + 1}行基数不能为空`);
  563. return;
  564. }
  565. // if (!l.medicalCardinalNumber) {
  566. // proxy.$modal.msgError(`第${i + 1}行医疗基数不能为空`);
  567. // return;
  568. // }
  569. }
  570. if (form.value.isFirstSocialSecurity === 0) {
  571. if (!form.value.governmentAccountNo) {
  572. proxy.$modal.msgError("请输入政务网账号");
  573. return;
  574. }
  575. if (!form.value.governmentPassword) {
  576. proxy.$modal.msgError("请输入政务网密码");
  577. return;
  578. }
  579. if (!passwordCheck(form.value.governmentPassword)) {
  580. proxy.$modal.msgError("请输入正确的政务网密码");
  581. return;
  582. }
  583. if (!form.value.socialSecurityAccountNo) {
  584. proxy.$modal.msgError("请输入社保账号");
  585. return;
  586. }
  587. if (!form.value.socialSecurityPassword) {
  588. proxy.$modal.msgError("请输入社保密码");
  589. return;
  590. }
  591. if (!passwordCheck(form.value.socialSecurityPassword)) {
  592. proxy.$modal.msgError("请输入正确的社保密码");
  593. return;
  594. }
  595. if (!form.value.employeePassword) {
  596. proxy.$modal.msgError("请输入用工密码");
  597. return;
  598. }
  599. if (!passwordCheck(form.value.employeePassword)) {
  600. proxy.$modal.msgError("请输入正确的用工密码");
  601. return;
  602. }
  603. }
  604. const res = await checkEmployees(form.value);
  605. if (!res.data) {
  606. proxy.$modal.confirm("该月社保人员出现变更确定保存么?").then(() => {
  607. const saveValue = proxy.deepClone(form.value);
  608. saveValue.isChanged = 1;
  609. // saveValue.status = 2;
  610. saveValue.status = status;
  611. if (saveValue.id == null) {
  612. saveDetail(saveValue).then((res) => {
  613. proxy.$modal.msgSuccess("保存成功");
  614. reset();
  615. close();
  616. getList.value();
  617. });
  618. } else {
  619. updateDetail(saveValue).then((res) => {
  620. proxy.$modal.msgSuccess("保存成功");
  621. reset();
  622. close();
  623. getList.value();
  624. });
  625. }
  626. });
  627. } else {
  628. proxy.$modal
  629. .confirm("确认保存么?")
  630. .then(() => {
  631. const saveValue = proxy.deepClone(form.value);
  632. //saveValue.status = 2;
  633. saveValue.status = status
  634. loading.value = true
  635. if (saveValue.id == null) {
  636. saveDetail(saveValue).then((res) => {
  637. proxy.$modal.msgSuccess("保存成功");
  638. reset();
  639. close();
  640. getList.value();
  641. }).finally(() => {
  642. loading.value = false
  643. });;
  644. } else {
  645. updateDetail(saveValue).then((res) => {
  646. proxy.$modal.msgSuccess("保存成功");
  647. reset();
  648. close();
  649. getList.value();
  650. });
  651. }
  652. })
  653. .catch((err) => {
  654. proxy.$modal.msg("取消保存");
  655. }).finally(() => {
  656. loading.value = false
  657. });;
  658. }
  659. }
  660. // 监听粘贴操作
  661. function handlePaste(event, row, field) {
  662. const items = (event.clipboardData || window.clipboardData).items;
  663. let file = null;
  664. if (!items || items.length === 0) {
  665. this.$message.error("当前浏览器不支持本地");
  666. return;
  667. }
  668. // 搜索剪切板items
  669. for (let i = 0; i < items.length; i++) {
  670. if (items[i].type.indexOf("image") !== -1) {
  671. file = items[i].getAsFile();
  672. break;
  673. }
  674. }
  675. if (!file) {
  676. this.$message.error("粘贴内容非图片");
  677. return;
  678. }
  679. zTool.addWatermark(file, "仅供社保使用").then(watermarkedFile => {
  680. tempFile.value = watermarkedFile
  681. uploadIdImage2(tempFile, row, field)
  682. })
  683. // tempFile.value = file;
  684. // uploadIdImage2(tempFile, row, field)
  685. }
  686. function uploadIdImage2(tempFile, row, field) {
  687. const formData = new FormData();
  688. formData.append("file", tempFile.value);
  689. uploadFile(formData).then((res) => {
  690. if (res.code === 200) {
  691. const file = {};
  692. file.fileType =
  693. res.newFileName.split(".")[res.newFileName.split(".").length - 1];
  694. if (file.fileType !== "png" && file.fileType !== "jpg") {
  695. proxy.$modal.msgError("文件类型错误,只能上传png,jpg格式");
  696. return;
  697. }
  698. file.fileName = res.originalFilename;
  699. file.url = res.url;
  700. file.originalFileName = res.originalFilename;
  701. file.fileUrl = res.fileName;
  702. row[field] = file.fileUrl;
  703. }
  704. });
  705. }
  706. function passwordCheckHandler(value, field) {
  707. // console.log(value)
  708. if (!passwordCheck(form.value[field])) {
  709. proxy.$modal.msgError("请输入正确密码");
  710. }
  711. }
  712. function handleEmployeeNotBatchDelete() {
  713. let cancelDelete = selections.value.filter((item) => {
  714. return item.changeStatus == 2;
  715. })
  716. if (cancelDelete == null || cancelDelete.length <= 0) {
  717. proxy.$modal.msgError("请选择并只能选择被删除的数据");
  718. } else {
  719. for (let index = 0; index < form.value.details.length; index++) {
  720. let x = form.value.details[index];
  721. for (let index2 = 0; index2 < selections.value.length; index2++) {
  722. let y = selections.value[index2];
  723. if (x.phone + x.employeeName === y.phone + y.employeeName && y.add !== 1) {
  724. x.changeStatus = 0;
  725. }
  726. }
  727. }
  728. }
  729. }
  730. function passwordCheck(value) {
  731. const pattern = /^[A-Za-z0-9~!@#$%^&*()_+-=]*$/;
  732. if (!pattern.test(value)) {
  733. return false;
  734. }
  735. return true;
  736. }
  737. function upload(param, row, field) {
  738. const formData = new FormData();
  739. formData.append("file", param.file);
  740. uploadFile(formData).then((res) => {
  741. if (res.code === 200) {
  742. const file = {};
  743. file.fileType =
  744. res.newFileName.split(".")[res.newFileName.split(".").length - 1];
  745. if (file.fileType !== "png" && file.fileType !== "jpg") {
  746. proxy.$modal.msgError("文件类型错误,只能上传png,jpg格式");
  747. return;
  748. }
  749. file.fileName = res.originalFilename;
  750. file.url = res.url;
  751. file.originalFileName = res.originalFilename;
  752. file.fileUrl = res.fileName;
  753. row[field] = file.fileUrl;
  754. }
  755. });
  756. }
  757. function changeEdit() {
  758. editStatus.value = !editStatus.value;
  759. }
  760. // 暴露给父组件的方法
  761. defineExpose({
  762. open,
  763. });
  764. </script>
  765. <style scoped>
  766. .image-container {
  767. display: flex;
  768. /* 使用Flex布局 */
  769. align-items: center;
  770. /* 垂直居中 */
  771. }
  772. .delete-button {
  773. margin-left: 20px;
  774. cursor: pointer;
  775. }
  776. .img {
  777. width: 23px;
  778. height: 23px;
  779. display: flex;
  780. justify-content: center;
  781. align-items: center;
  782. margin-left: 20px;
  783. }
  784. .button-class {
  785. margin-top: 10px;
  786. margin-bottom: 10px;
  787. }
  788. ::v-deep(.el-upload) {
  789. display: flex;
  790. text-align: center;
  791. justify-content: center;
  792. cursor: pointer;
  793. outline: 0;
  794. }
  795. .required::after {
  796. content: "*";
  797. color: red;
  798. }
  799. </style>
  800. <style>
  801. .el-table .delete-row {
  802. background-color: rgb(251, 159, 173);
  803. }
  804. .new-delete-row {
  805. display: none;
  806. }
  807. .el-table .add-row {
  808. background-color: rgb(184, 234, 147);
  809. }
  810. </style>