form.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. <template>
  2. <!-- 添加或修改项目信息对话框 -->
  3. <div class="el-drawer__wrapper company-list">
  4. <el-drawer :title="title" v-model="visible" direction="rtl" size="100%">
  5. <div class="page-container form-container">
  6. <!-- 功能按钮区域 -->
  7. <div class="form-btns-container">
  8. <span class="title-label"><el-icon>
  9. <Document />
  10. </el-icon>
  11. 对账单表单</span>
  12. <el-button v-if="editStatus" type="primary" size="small" icon="Finished" @click="submitForm">保存</el-button>
  13. <el-button v-else-if="form.entrustOrderStatus !== 2 && form.status !== 2" type="warning" size="small"
  14. icon="Edit" @click="editStatus = true"
  15. v-hasPermi="['business:statement:update']"
  16. >修改</el-button>
  17. <el-button v-if="form.id && editStatus" type="info" v-hasPermi="['business:statement:update']" size="small" icon="Close"
  18. @click="editStatus = false">取消修改</el-button>
  19. <el-button type="warning" size="small" icon="Download" @click="exportExcel" v-hasPermi="['business:statement:export']">导出</el-button>
  20. <el-button v-if="form.id" type="success" icon="refresh" size="small" @click="getForm">
  21. 刷新</el-button>
  22. <div class="screen-btn" @click="handleScreen">
  23. <template v-if="!isFullscreen">
  24. <i class="fa fa-window-maximize" aria-hidden="true" />
  25. <!-- <span>全屏</span> -->
  26. </template>
  27. <template v-else>
  28. <i class="fa fa-window-restore" aria-hidden="true" />
  29. <!-- <span>还原</span> -->
  30. </template>
  31. </div>
  32. <div class="close-btn" @click="cancel">
  33. <i class="fa fa-times" aria-hidden="true" />
  34. <!-- <span>关闭</span> -->
  35. </div>
  36. </div>
  37. <el-form ref="companyRef" class="master-container" size="small" :model="form" :rules="rules"
  38. label-width="120px">
  39. <el-row :gutter="30">
  40. <el-col :span="6"> 结算单位:{{ form.contactCompany }} </el-col>
  41. <el-col :span="6"> 结算订单编号:{{ form.formNo }} </el-col>
  42. <el-col :span="4">
  43. 上期余额:{{ rowNum(form.prevRemainAmount) }}
  44. </el-col>
  45. <el-col :span="4"> 本期消耗:{{ rowNum(form.amount) }} </el-col>
  46. <el-col :span="4">
  47. 本期余额:{{ rowNum(form.remainAmount) }}
  48. </el-col>
  49. <el-col :span="24">
  50. <el-tabs v-model="activeName">
  51. <el-tab-pane label="汇总" name="base" class="baseTable">
  52. <table class="header" cellspacing="0" cellpadding="0" style="table-layout: fixed"
  53. v-loading="loading">
  54. <tbody>
  55. <tr class=" bg-white-color">
  56. <td :colspan="1" style="width: 100px">自然月</td>
  57. <td :colspan="2" style="width: 200px">项目分类</td>
  58. <td :colspan="1" style="width: 100px">
  59. 客户数量(单位:户)
  60. </td>
  61. <td :colspan="1" style="width: 100px">
  62. 单价(单位:元)
  63. </td>
  64. <td :colspan="1" style="width: 100px">
  65. 小计(单位:元)
  66. </td>
  67. <td :colspan="1" style="width: 100px">优惠后单价</td>
  68. <td :colspan="1" style="width: 100px">优惠后金额</td>
  69. <td :colspan="1" style="width: 100px">减免金额</td>
  70. <td :colspan="1" style="width: 100px">实际支付</td>
  71. <td :colspan="2" class="tdLast" style="width: 300px">
  72. 说明
  73. </td>
  74. </tr>
  75. <tr class="bg-white-color" v-for="(item, index) in form.collect" :key="index">
  76. <td :colspan="1" v-if="index === 0" :rowspan="form.collect.length">
  77. <!-- {{ item.year }}年{{ item.month}}月 -->
  78. {{ form.startMonth }} - {{ form.endMonth }}
  79. </td>
  80. <td :colspan="1">{{ item.taskType }}</td>
  81. <td :colspan="1">
  82. {{
  83. item.taskType === "代理记账"
  84. ? item.annualIncome
  85. : item.taskType === "社保代缴" ||
  86. item.taskType === "公积金代缴"
  87. ? item.haveChanged === 1
  88. ? "有变化"
  89. : "无变化"
  90. : ""
  91. }}
  92. </td>
  93. <td :colspan="1">{{ item.companyNum }}</td>
  94. <td :colspan="1">
  95. <template v-if="item.taskType === '工商代办'">-</template>
  96. <template v-else-if="editStatus">
  97. <el-input-number v-model="item.price" size="small" placeholder="" :precision="2"
  98. :controls="false" style="width: 100%"
  99. @change="(arg) => itemChangeHandle(item, 'price')" />
  100. </template>
  101. <template v-else>{{ rowNum(item.price) }}</template>
  102. </td>
  103. <td :colspan="1">{{ rowNum(item.amount) }}</td>
  104. <td :colspan="1">
  105. <template v-if="item.taskType === '工商代办'">-</template>
  106. <template v-else-if="editStatus">
  107. <el-input-number v-model="item.discountPrice" size="small" placeholder="" :precision="2"
  108. :controls="false" style="width: 100%" @change="
  109. (arg) => itemChangeHandle(item, 'discountPrice')
  110. " />
  111. </template>
  112. <template v-else>{{
  113. rowNum(item.discountPrice)
  114. }}</template>
  115. </td>
  116. <td :colspan="1">{{ rowNum(item.discountAmount) }}</td>
  117. <td :colspan="1">
  118. <template v-if="editStatus">
  119. <el-input-number v-model="item.freeAmount" size="small" placeholder="" :precision="2"
  120. :controls="false" style="width: 100%" :max="
  121. item.discountPrice == null
  122. ? item.amount
  123. : item.discountAmount
  124. " @change="
  125. (arg) =>
  126. itemChangeHandle(item, 'freeAmount', arg)
  127. " />
  128. </template>
  129. <template v-else>{{
  130. rowNum(item.discountPrice)
  131. }}</template>
  132. </td>
  133. <td :colspan="1">{{ rowNum(item.actuallyAmount) }}</td>
  134. <td :colspan="2" class="tdLast" v-if="index === 0" :rowspan="form.collect.length"
  135. style="width: 300px">
  136. <template v-if="editStatus">
  137. <el-input v-model="form.description" type="textarea" style="width: 100%" autosize
  138. maxlength="200" show-word-limit />
  139. </template>
  140. <template v-else>{{ form.description }}</template>
  141. <!-- <template>{{ form.descrpition }}</template> -->
  142. </td>
  143. </tr>
  144. </tbody>
  145. </table>
  146. <table class="header" cellspacing="0" cellpadding="0">
  147. <tbody></tbody>
  148. </table>
  149. </el-tab-pane>
  150. <el-tab-pane label="循环任务" name="loop">
  151. <el-table v-loading="loading" :data="form.loopList" size="small" border height="100%">
  152. <!-- <el-table-column label="工单号" align="center" prop="workOrderNo" width="200" /> -->
  153. <el-table-column label="工作月" align="center" prop="workMonth">
  154. <template #default="scope">
  155. {{ scope.row.workMonth.substring(0, 7)}}
  156. </template>
  157. </el-table-column>
  158. <el-table-column label="客户名称" align="center" width="150" prop="companyName" />
  159. <el-table-column label="税号" align="center" prop="socialCreditCode" width="150" />
  160. <el-table-column label="注册地址" align="center" prop="formNo" width="120">
  161. <template #default="scope">
  162. {{ scope.row.province }}-{{ scope.row.city }}-{{
  163. scope.row.district
  164. }}
  165. </template>
  166. </el-table-column>
  167. <el-table-column label="年收入" align="center" prop="annualIncome" width="100">
  168. </el-table-column>
  169. <el-table-column label="税务申报" align="center" width="80">
  170. <template #default="scope">
  171. {{ scope.row.isTax === 1 ? "是" : "否" }}
  172. </template>
  173. </el-table-column>
  174. <el-table-column label="社保" prop="remainAmount" align="center" width="80">
  175. <template #default="scope">
  176. {{ scope.row.isSocialSecurity === 1 ? "是" : "否" }}
  177. </template>
  178. </el-table-column>
  179. <el-table-column label="公积金" prop="status" align="center" width="80">
  180. <template #default="scope">
  181. {{ scope.row.isHousingFund === 1 ? "是" : "否" }}
  182. </template>
  183. </el-table-column>
  184. <el-table-column label="纳税性质" align="center" prop="taxType" width="100" />
  185. <el-table-column label="征收方式" align="center" prop="collectionMethod" width="100" />
  186. <!-- <el-table-column
  187. label="定额金额"
  188. align="center"
  189. prop="quotaAmount"
  190. width="80"
  191. /> -->
  192. <el-table-column label="是否零申报" align="center" prop="isZero" width="80">
  193. <template #default="scope">
  194. {{ scope.row.isZero === 1 ? "是" : "否" }}
  195. </template>
  196. </el-table-column>
  197. <el-table-column label="实际年收入" align="center" prop="actuallyAnnualIncome" width="100" />
  198. <el-table-column label="社保有无变化" prop="status" align="center" width="100">
  199. <template #default="scope">
  200. {{
  201. scope.row.changedSocialSecurity === 1 ? "是" : "否"
  202. }}
  203. </template>
  204. </el-table-column>
  205. <el-table-column label="公积金有无变化" prop="status" align="center" width="100">
  206. <template #default="scope">
  207. {{ scope.row.changedHousingFund === 1 ? "是" : "否" }}
  208. </template>
  209. </el-table-column>
  210. <el-table-column label="累计年收入" prop="status" align="center" width="100">
  211. <template #default="scope">
  212. {{ scope.row.cumulativeIncome }}
  213. </template>
  214. </el-table-column>
  215. <el-table-column label="负责人" prop="leaderName" align="center" width="100">
  216. </el-table-column>
  217. </el-table>
  218. </el-tab-pane>
  219. <el-tab-pane label="工商任务" name="once">
  220. <el-table v-loading="loading" :data="form.onceList" size="small" border height="100%">
  221. <!-- <el-table-column label="工单号" align="center" prop="workOrderNo" width="200" /> -->
  222. <el-table-column label="客户名称" align="center" width="200" prop="companyName" />
  223. <el-table-column label="税号" align="center" prop="socialCreditCode" width="150" />
  224. <el-table-column label="所在区" align="center" prop="formNo" width="150">
  225. <template #default="scope">
  226. {{ scope.row.province }}-{{ scope.row.city }}-{{
  227. scope.row.district
  228. }}
  229. </template>
  230. </el-table-column>
  231. <el-table-column label="办理事项" align="center" prop="annualIncome" width="120">
  232. <template #default="scope">
  233. {{ scope.row.taskTypeName }}-{{
  234. scope.row.taskTypeDetailName
  235. }}
  236. </template>
  237. </el-table-column>
  238. <el-table-column label="下单时间" prop="entrustDate" align="center" width="100">
  239. </el-table-column>
  240. <el-table-column label="完成时间" prop="finishedDate" align="center" width="100">
  241. </el-table-column>
  242. <el-table-column label="收费" prop="amount" align="center" width="100">
  243. <template #default="scope">
  244. <template v-if="editStatus">
  245. <el-input-number v-model="scope.row.amount" size="small" placeholder="" :precision="2"
  246. :controls="false" style="width: 100%" @change="onceChangeHandle(scope.row, 'amount')" />
  247. </template>
  248. <template v-else>{{ scope.row.amount }}</template>
  249. </template>
  250. </el-table-column>
  251. <el-table-column label="说明" align="center" prop="description" />
  252. </el-table>
  253. </el-tab-pane>
  254. </el-tabs>
  255. </el-col>
  256. </el-row>
  257. </el-form>
  258. </div>
  259. </el-drawer>
  260. <!-- 图片预览 -->
  261. <el-image-viewer v-if="showViewer" :url-list="currentFileList" @close="closeImages" :initial-index="showIndex" />
  262. </div>
  263. </template>
  264. <script setup>
  265. import { getToken } from "@/utils/auth";
  266. import { rowNum } from "@/utils/index";
  267. import {
  268. addFollow,
  269. listFollow,
  270. delFollow,
  271. } from "@/api/business/crm/companyFollowDetail";
  272. import {
  273. getDeduct,
  274. genDeduct,
  275. addDeduct,
  276. updateDeduct,
  277. exportAccountStatement
  278. } from "@/api/business/entrust/deduct";
  279. import useUserStore from "@/store/modules/user";
  280. import { deepClone } from "@/utils";
  281. import {
  282. incomeDefault,
  283. taxTypes,
  284. confirmDefault,
  285. collectionMethods,
  286. yesOrNo,
  287. } from "@/utils/default";
  288. const { proxy } = getCurrentInstance();
  289. /** 父组件传参 */
  290. const props = defineProps({
  291. getList: {
  292. type: Function,
  293. default: () => { },
  294. },
  295. });
  296. const { getList } = toRefs(props);
  297. /** 字典数组区 */
  298. import { uploadFile } from "@/api/tool/file";
  299. const CustomerFormComRef = ref(null);
  300. /** 表单抽屉 页变量 */
  301. const title = ref("");
  302. const loading = ref(false);
  303. const multiple = ref(true);
  304. const visible = ref(false);
  305. const editStatus = ref(false);
  306. const isFullscreen = ref(false);
  307. const addDetailNum = ref(1);
  308. const currentMember = {};
  309. const activeName = ref("base");
  310. const provinces = ref(proxy.region.getProvinces());
  311. provinces.value.unshift({ code: "", name: "全部" });
  312. const cities = ref([]);
  313. const districts = ref([]);
  314. const sourceCategories = ref([]);
  315. const area = ref([]);
  316. const fileList = ref([]);
  317. const condition = ref({});
  318. const showViewer = ref(false);
  319. const currentFileList = ref([]);
  320. const showIndex = ref(0);
  321. const types = ref([]);
  322. const taxDeclarationCategories = ref([]);
  323. const baseUrl = ref(import.meta.env.VITE_APP_BASE_API);
  324. const webHost = import.meta.env.VITE_APP_BASE_API;
  325. const setHeaders = {
  326. Authorization: getToken(),
  327. };
  328. const data = reactive({
  329. form: {},
  330. });
  331. const { form, rules } = toRefs(data);
  332. const contactorEmptyData = {
  333. id: null,
  334. name: "",
  335. position: "",
  336. gender: "男",
  337. phone: "",
  338. email: "",
  339. isMain: "是",
  340. remark: "",
  341. };
  342. const deductEmptyData = {
  343. id: null,
  344. collect: [],
  345. loopList: [],
  346. onceList: [],
  347. creatorId: useUserStore().user.id,
  348. };
  349. const queryRadio = ref("base-form");
  350. const defaultIsZero = ref(0);
  351. /*********************** 表单页方法 ****************************/
  352. function sourceValidator(rule, value, callback) {
  353. // console.log(form.value)
  354. if (form.value.sourceCategoryName === "") {
  355. callback(new Error("来源类型不能为空"));
  356. return;
  357. }
  358. // console.log(`referrerDataSource: ${form.value.referrerDataSource}`)
  359. // console.log(`sourceName: ${form.value.sourceName}`)
  360. if (
  361. form.value.referrerDataSource !== "" &&
  362. form.value.referrerDataSource != null &&
  363. (form.value.sourceName === "" || form.value.sourceName == null)
  364. ) {
  365. callback(new Error("来源不能为空"));
  366. return;
  367. }
  368. return callback();
  369. }
  370. /** 抽屉打开 */
  371. function open(id) {
  372. reset();
  373. visible.value = true;
  374. if (id) {
  375. loading.value = true;
  376. getDeduct(id).then((response) => {
  377. form.value = response.data;
  378. editStatus.value = false;
  379. title.value = "修改客户";
  380. condition.value.entrustOrderId = form.value.entrustOrderId;
  381. condition.value.startMonth = form.value.startMonth;
  382. condition.value.endMonth = form.value.endMonth;
  383. }).finally
  384. (() => {
  385. loading.value = false;
  386. });
  387. }
  388. }
  389. function add(options) {
  390. reset();
  391. visible.value = true;
  392. loading.value = true;
  393. condition.value = options
  394. genDeduct(options).then((res) => {
  395. form.value = res.data;
  396. editStatus.value = true;
  397. }).finally
  398. (() => {
  399. loading.value = false;
  400. });
  401. }
  402. /** 取消按钮 */
  403. function cancel() {
  404. visible.value = false;
  405. reset();
  406. }
  407. /** 表单重置 */
  408. function reset() {
  409. form.value = deepClone(deductEmptyData);
  410. if (CustomerFormComRef.value) CustomerFormComRef.value.reset();
  411. proxy.resetForm("companyRef");
  412. }
  413. /** 上传后方法处理 */
  414. function uploadSuccess(res) {
  415. if (res.code == 200) {
  416. const newAttach = {
  417. name: res.data.name,
  418. url: res.data.url,
  419. };
  420. form.value.attaches.push(newAttach);
  421. } else {
  422. proxy.$modal.msgError("上传失败" + res.msg);
  423. }
  424. }
  425. function handleDownLoad(url) {
  426. window.open(webHost + url);
  427. }
  428. // 全屏缩放
  429. function handleScreen() {
  430. const dom = document.querySelector(
  431. ".list-container > .el-drawer__wrapper > .el-overlay"
  432. );
  433. isFullscreen.value = !isFullscreen.value;
  434. dom.style.position = isFullscreen.value ? "fixed" : "absolute";
  435. }
  436. function getForm() {
  437. loading.value = true;
  438. getCompany(form.value.id).then((response) => {
  439. loading.value = false;
  440. form.value = response.data;
  441. CustomerFormCom.value.setForm(form.value);
  442. });
  443. }
  444. function checkZero() {
  445. if (defaultIsZero.value === 1) {
  446. return true;
  447. } else if (
  448. defaultIsZero.value != form.value.isZero &&
  449. form.value.isZero === 1
  450. ) {
  451. proxy.$modal.msgError("不可将非零申报客户改为零申报");
  452. return false;
  453. } else {
  454. return true;
  455. }
  456. }
  457. function exportExcel() {
  458. condition.value.title = "(" + form.value.contactCompany + "-" + form.value.formNo+")";
  459. exportAccountStatement(condition.value)
  460. }
  461. /** 提交保存 */
  462. function submitForm() {
  463. if (form.value.amount < 0) {
  464. proxy.$modal.msgError("本期消耗不能小于0");
  465. return;
  466. }
  467. proxy.$modal.confirm("确认保存么").then((res) => {
  468. form.value.status = 0;
  469. if (form.value.id == null) {
  470. addDeduct(form.value).then((res) => {
  471. cancel();
  472. getList.value();
  473. });
  474. } else {
  475. updateDeduct(form.value).then((res) => {
  476. cancel();
  477. getList.value();
  478. });
  479. }
  480. });
  481. }
  482. /** 添加从表 */
  483. function handleAdd() {
  484. for (var i = 0; i < addDetailNum.value; i++) {
  485. form.value.members.push({});
  486. }
  487. }
  488. /** 删除从表 */
  489. function handleDel(index) {
  490. proxy.$modal
  491. .confirm("确定删除?")
  492. .then(() => {
  493. form.value.members.splice(index, 1);
  494. })
  495. .catch(() => {
  496. proxy.$modal.msg("已取消删除");
  497. });
  498. }
  499. function handleDelAttach(index) {
  500. proxy.$modal
  501. .confirm("确定删除?")
  502. .then(() => {
  503. form.value.attaches.splice(index, 1);
  504. })
  505. .catch(() => {
  506. proxy.$modal.msg("已取消删除");
  507. });
  508. }
  509. /** 单选添加 */
  510. function handleDialogOpen(person) {
  511. multiple.value = false;
  512. currentMember.value = person;
  513. proxy.$refs.personRef.open();
  514. }
  515. /** 多选添加 */
  516. function handleAddBatch() {
  517. multiple.value = true;
  518. proxy.$refs.personRef.open();
  519. }
  520. function handleSingleSelected(person) {
  521. // console.log('单选带回', person)
  522. if (
  523. form.value.members.findIndex((item) => item.personId === person.id) === -1
  524. ) {
  525. currentMember.value.personId = person.id;
  526. currentMember.value.name = person.name;
  527. currentMember.value.code = person.code;
  528. currentMember.value.gender = person.gender;
  529. currentMember.value.age = person.age;
  530. currentMember.value.phone = person.phone;
  531. } else {
  532. proxy.$modal.msgError(person.name + "已存在,请勿重复添加!");
  533. }
  534. }
  535. function handleMultipleSelected(selection) {
  536. // console.log('多选回带', selection)
  537. for (var i = 0; i < selection.length; ++i) {
  538. const newPerson = {};
  539. if (
  540. form.value.members.findIndex(
  541. (item) => item.personId === selection[i].id
  542. ) === -1
  543. ) {
  544. newPerson.personId = selection[i].id;
  545. newPerson.name = selection[i].name;
  546. newPerson.code = selection[i].code;
  547. newPerson.gender = selection[i].gender;
  548. newPerson.age = selection[i].age;
  549. newPerson.phone = selection[i].phone;
  550. form.value.members.push(newPerson);
  551. } else {
  552. proxy.$modal.msgError(selection[i].name + "已存在,请勿重复添加!");
  553. }
  554. }
  555. }
  556. function scrollTargetTo(target) {
  557. const targetElement = document.getElementById(target);
  558. if (targetElement) {
  559. targetElement.scrollIntoView();
  560. }
  561. }
  562. function validDetails() {
  563. const contactors = form.value.contactors;
  564. if (contactors.length === 0) {
  565. return true;
  566. }
  567. form.value.contactors.forEach(function (val, index) {
  568. if (val.name === "") {
  569. proxy.$modal.msgError(`第 ${index + 1} 行联系人的姓名不能为空`);
  570. _isNull = true;
  571. return false;
  572. } else if (val.position === "") {
  573. proxy.$modal.msgError(`第 ${index + 1} 行联系人的角色不能为空`);
  574. _isNull = true;
  575. return false;
  576. }
  577. });
  578. return true;
  579. }
  580. function itemChangeHandle(item, field) {
  581. const price = item.price == null ? 0 : item.price;
  582. const num = item.companyNum == null ? 0 : item.companyNum;
  583. const discountPrice = item.discountPrice == null ? 0 : item.discountPrice;
  584. const amount = price * num;
  585. const freeAmount = item.freeAmount == null ? 0 : item.freeAmount;
  586. item.amount = amount;
  587. item.discountAmount = discountPrice * num;
  588. item.actuallyAmount =
  589. (item.discountPrice == null ? item.amount : item.discountAmount) -
  590. freeAmount;
  591. computedTotal();
  592. }
  593. function itemChangeHandleEnd(item, field, arg) {
  594. let freeAmount = item.freeAmount;
  595. let discountPrice = item.discountPrice;
  596. let discountAmount = item.discountAmount;
  597. let num = item.companyNum == null ? 0 : item.companyNum;
  598. let amount = item.amount;
  599. let actuallyAmount = item.actuallyAmount;
  600. if (item.taskType === "工商代办") {
  601. switch (field) {
  602. case "freeAmount":
  603. freeAmount = arg == null ? 0 : arg;
  604. const actuallyAmount =
  605. freeAmount > item.amount ? 0 : item.amount - freeAmount;
  606. item.freeAmount = freeAmount > item.amount ? item.amount : freeAmount;
  607. item.actuallyAmount = actuallyAmount;
  608. break;
  609. }
  610. } else {
  611. switch (field) {
  612. case "discountPrice":
  613. discountPrice = arg;
  614. discountAmount = discountPrice * item.companyNum;
  615. item.discountAmount = discountAmount;
  616. actuallyAmount =
  617. freeAmount > discountAmount ? 0 : discountAmount - freeAmount;
  618. item.actuallyAmount = actuallyAmount;
  619. item.freeAmount =
  620. freeAmount > discountAmount ? discountAmount : freeAmount;
  621. break;
  622. case "price":
  623. price = arg;
  624. amount = price * num;
  625. item.amount = amount;
  626. break;
  627. case "freeAmount":
  628. actuallyAmount =
  629. freeAmount > discountAmount ? 0 : discountAmount - freeAmount;
  630. item.actuallyAmount = actuallyAmount;
  631. item.freeAmount =
  632. freeAmount > discountAmount ? discountAmount : freeAmount;
  633. break;
  634. }
  635. }
  636. computedTotal();
  637. }
  638. function computedTotal() {
  639. let totalAmount = 0;
  640. form.value.collect.forEach((item) => {
  641. totalAmount += item.actuallyAmount;
  642. });
  643. form.value.amount = totalAmount;
  644. form.value.remainAmount = form.value.prevRemainAmount - form.value.amount;
  645. }
  646. function onceChangeHandle() {
  647. let totalAmount = 0;
  648. form.value.onceList.forEach((item) => {
  649. totalAmount += item.amount == null ? 0 : item.amount;
  650. });
  651. const collect = form.value.collect.find((v) => v.taskType === "工商代办");
  652. collect.amount = totalAmount;
  653. collect.actuallyAmount = totalAmount;
  654. computedTotal();
  655. }
  656. function closeImages() {
  657. reset();
  658. showViewer.value = false;
  659. }
  660. // 暴露给父组件的方法
  661. defineExpose({
  662. open,
  663. add,
  664. });
  665. </script>
  666. <style>
  667. .header {
  668. text-align: center;
  669. line-height: 30px;
  670. }
  671. .baseTable table tbody tr td {
  672. border-left: 1px solid #dadada;
  673. border-top: 1px solid #dadada;
  674. border-bottom: 1px solid #dadada;
  675. padding: 0;
  676. border-spacing: 0;
  677. }
  678. .tdLast {
  679. border-right: 1px solid #dadada;
  680. }
  681. </style>