form.vue 29 KB

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