saleInvoiceForm.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. <template>
  2. <a-spin :spinning="loading">
  3. <JFormContainer :disabled="disabled">
  4. <template #detail>
  5. <a-form v-bind="formItemLayout" name="saleInvoiceForm" ref="formRef">
  6. <a-row>
  7. <a-col :span="12">
  8. <a-form-item
  9. label="发票编号(invoice code)"
  10. v-bind="validateInfos.invoiceCode"
  11. id="saleInvoiceForm-invoiceCode"
  12. name="invoiceCode"
  13. :labelCol="formItemLayout.labelCol1"
  14. :wrapperCol="formItemLayout.wrapperCol1"
  15. >
  16. <a-input v-model:value="formData.invoiceCode" placeholder="自动生成" disabled />
  17. </a-form-item>
  18. </a-col>
  19. <a-col :span="12">
  20. <a-form-item label="发票日期(bill date)" v-bind="validateInfos.billDate" id="saleInvoiceForm-billDate" name="billDate">
  21. <a-date-picker
  22. placeholder="请选择发票日期(bill date)"
  23. v-model:value="formData.billDate"
  24. value-format="YYYY-MM-DD"
  25. style="width: 100%"
  26. allow-clear
  27. />
  28. </a-form-item>
  29. </a-col>
  30. <a-col :span="12">
  31. <a-form-item label="项目(project)" v-bind="validateInfos.projectName" id="saleInvoiceForm-projectName" name="projectName">
  32. <a-input-search
  33. v-model:value="formData.projectName"
  34. placeholder="请输入项目(project)"
  35. readonly
  36. allow-clear
  37. enter-button="Search"
  38. :disabled="notAllowEdit"
  39. @search="onSearchProject"
  40. />
  41. </a-form-item>
  42. </a-col>
  43. <a-col :span="12">
  44. <a-form-item label="业务类型(busymess type)" v-bind="validateInfos.busynessType" id="saleInvoiceForm-busynessType" name="busynessType">
  45. <JDictSelectTag
  46. v-model:value="formData.busynessType"
  47. placeholder="请选择"
  48. dictCode=" busyness_type"
  49. style="width: 100%"
  50. :disabled="notAllowEdit"
  51. />
  52. </a-form-item>
  53. </a-col>
  54. <a-col :span="12">
  55. <a-form-item
  56. label="购方(buyer)"
  57. v-bind="validateInfos.customer"
  58. id="saleInvoiceForm-customer"
  59. name="customer"
  60. :labelCol="formItemLayout.labelCol1"
  61. :wrapperCol="formItemLayout.wrapperCol1"
  62. >
  63. <ApiSelect
  64. :api="getCustomerOptions"
  65. showSearch
  66. v-model:value="formData.customer"
  67. optionFilterProp="label"
  68. resultField="records"
  69. labelField="name"
  70. valueField="id"
  71. :params="{ pageSize: -1,status:1}"
  72. disabled
  73. />
  74. </a-form-item>
  75. </a-col>
  76. <a-col :span="12">
  77. <a-form-item
  78. label="购方税号(buyer's tax number)"
  79. v-bind="validateInfos.buyerTaxNumber"
  80. id="saleInvoiceForm-buyerTaxNumber"
  81. name="buyerTaxNumber"
  82. >
  83. <a-input v-model:value="formData.buyerTaxNumber" placeholder="请输入" allow-clear AutoComplete="off" />
  84. </a-form-item>
  85. </a-col>
  86. <a-col :span="12">
  87. <a-form-item
  88. label="购方电话(buyer's telphone)"
  89. v-bind="validateInfos.buyerTelphone"
  90. id="saleInvoiceForm-buyerTelphone"
  91. name="buyerTelphone"
  92. >
  93. <a-input v-model:value="formData.buyerTelphone" placeholder="请输入" allow-clear AutoComplete="off" />
  94. </a-form-item>
  95. </a-col>
  96. <a-col :span="12">
  97. <a-form-item
  98. label="购方地址(buyer's address)"
  99. v-bind="validateInfos.buyerAddress"
  100. id="saleInvoiceForm-buyerAddress"
  101. name="buyerAddress"
  102. >
  103. <a-input v-model:value="formData.buyerAddress" placeholder="请输入" allow-clear AutoComplete="off" />
  104. </a-form-item>
  105. </a-col>
  106. <a-col :span="12">
  107. <a-form-item label="购方银行(buyer's bank)" v-bind="validateInfos.buyerBank" id="saleInvoiceForm-buyerBank" name="buyerBank">
  108. <a-input v-model:value="formData.buyerBank" placeholder="请输入" allow-clear AutoComplete="off" />
  109. </a-form-item>
  110. </a-col>
  111. <a-col :span="12">
  112. <a-form-item
  113. label="购方银行账户(buyer's bank account)"
  114. v-bind="validateInfos.buyerAccount"
  115. id="saleInvoiceForm-buyerAccount"
  116. name="buyerAccount"
  117. >
  118. <a-input v-model:value="formData.buyerAccount" placeholder="请输入" allow-clear AutoComplete="off" />
  119. </a-form-item>
  120. </a-col>
  121. <a-col :span="12">
  122. <a-form-item
  123. label="开票抬头(invoice header)"
  124. v-bind="validateInfos.invoiceHeader"
  125. id="saleInvoiceForm-invoiceHeader"
  126. name="invoiceHeader"
  127. >
  128. <a-input v-model:value="formData.invoiceHeader" placeholder="请输入" allow-clear disabled />
  129. </a-form-item>
  130. </a-col>
  131. <a-col :span="12">
  132. <a-form-item
  133. label="开票地址(invoice address)"
  134. v-bind="validateInfos.invoiceAddress"
  135. id="saleInvoiceForm-invoiceAddress"
  136. name="invoiceAddress"
  137. >
  138. <a-input v-model:value="formData.invoiceAddress" placeholder="请输入" allow-clear disabled />
  139. </a-form-item>
  140. </a-col>
  141. <a-col :span="12">
  142. <a-form-item
  143. label="销方(seller)"
  144. v-bind="validateInfos.seller"
  145. id="saleInvoiceForm-seller"
  146. name="saller"
  147. :labelCol="formItemLayout.labelCol1"
  148. :wrapperCol="formItemLayout.wrapperCol1"
  149. >
  150. <ApiSelect
  151. :api="listHeard"
  152. showSearch
  153. :filterOption="true"
  154. v-model:value="formData.seller"
  155. optionFilterProp="label"
  156. resultField="records"
  157. labelField="name"
  158. valueField="id"
  159. :params="{ pageSize: -1 }"
  160. @change="changeSeller"
  161. />
  162. </a-form-item>
  163. </a-col>
  164. <a-col :span="12">
  165. <a-form-item
  166. label="销方税号(seller's tax number)"
  167. v-bind="validateInfos.sellerTaxNumber"
  168. id="saleInvoiceForm-sellerTaxNumber"
  169. name="sellerTaxNumber"
  170. >
  171. <a-input v-model:value="formData.sellerTaxNumber" placeholder="请输入" allow-clear />
  172. </a-form-item>
  173. </a-col>
  174. <a-col :span="12">
  175. <a-form-item
  176. label="销方电话(seller's telphone)"
  177. v-bind="validateInfos.sellerTelphone"
  178. id="saleInvoiceForm-sellerTelphone"
  179. name="sellerTelphone"
  180. >
  181. <a-input v-model:value="formData.sellerTelphone" placeholder="请输入" allow-clear />
  182. </a-form-item>
  183. </a-col>
  184. <a-col :span="12">
  185. <a-form-item
  186. label="销方地址(seller's address)"
  187. v-bind="validateInfos.sellerAddress"
  188. id="saleInvoiceForm-sellerAddress"
  189. name="sellerAddress"
  190. >
  191. <a-input v-model:value="formData.sellerAddress" placeholder="请输入" allow-clear />
  192. </a-form-item>
  193. </a-col>
  194. <a-col :span="12">
  195. <a-form-item label="销方银行(seller's bank)" v-bind="validateInfos.sellerBank" id="saleInvoiceForm-sellerBank" name="sellerBank">
  196. <a-input v-model:value="formData.sellerBank" placeholder="请输入" allow-clear />
  197. </a-form-item>
  198. </a-col>
  199. <a-col :span="12">
  200. <a-form-item
  201. label="销方银行账户(seller's bank account)"
  202. v-bind="validateInfos.sellerBankAccount"
  203. id="saleInvoiceForm-sellerBankAccount"
  204. name="sellerBankAccount"
  205. >
  206. <a-input v-model:value="formData.sellerBankAccount" placeholder="请输入" allow-clear />
  207. </a-form-item>
  208. </a-col>
  209. <a-col :span="12">
  210. <a-form-item label="F号(F number)" v-bind="validateInfos.fnumber" id="saleInvoiceForm-fnumber" name="fnumber">
  211. <a-input v-model:value="formData.fnumber" placeholder="请输入" allow-clear AutoComplete="off" />
  212. </a-form-item>
  213. </a-col>
  214. <a-col :span="12">
  215. <a-form-item
  216. label="备注(notes)"
  217. v-bind="validateInfos.notes"
  218. id="saleInvoiceForm-notes"
  219. name="notes"
  220. :labelCol="formItemLayout.labelCol1"
  221. :wrapperCol="formItemLayout.wrapperCol1"
  222. >
  223. <a-input v-model:value="formData.notes" placeholder="请输入备注(notes)" allow-clear AutoComplete="off" />
  224. </a-form-item>
  225. </a-col>
  226. </a-row>
  227. </a-form>
  228. </template>
  229. </JFormContainer>
  230. <!-- 子表单区域 -->
  231. <a-tabs v-model:activeKey="activeKey" animated style="padding: 24px; padding-top: 0px">
  232. <a-tab-pane tab="销售发票 - 发票明细(invoice details)" key="saleInvoiceDetails" :forceRender="true">
  233. <a-button type="primary" style="margin-right: 1%; margin-bottom: 1%" @click="selectDeliveryList">
  234. 选择发货通知单(select delevery notice)</a-button
  235. >
  236. <a-button type="primary" @click="selectCommissionList"> 选择佣金订单(selete commission order)</a-button>
  237. <j-vxe-table
  238. :keep-source="true"
  239. resizable
  240. ref="saleInvoiceDetailsTableRef"
  241. :loading="saleInvoiceDetailsTable.loading"
  242. :columns="saleInvoiceDetailsTable.columns"
  243. :dataSource="saleInvoiceDetailsTable.dataSource"
  244. :maxHeight="340"
  245. :disabled="disabled"
  246. :rowNumber="true"
  247. :rowSelection="true"
  248. asyncRemove
  249. @value-change="changeValues"
  250. >
  251. <template #action="props">
  252. <a-popconfirm title="确定删除吗?" @confirm="handleDelete1(props)">
  253. <a>删除(delete)</a>
  254. </a-popconfirm>
  255. </template>
  256. </j-vxe-table>
  257. </a-tab-pane>
  258. <a-tab-pane tab="销售发票 - 船明细(ship details)" key="saleInvoiceFormShip" :forceRender="true">
  259. <j-vxe-table
  260. :keep-source="true"
  261. resizable
  262. ref="saleInvoiceFormShipTableRef"
  263. :loading="saleInvoiceFormShipTable.loading"
  264. :columns="saleInvoiceFormShipTable.columns"
  265. :dataSource="saleInvoiceFormShipTable.dataSource"
  266. :maxHeight="340"
  267. :disabled="disabled"
  268. :rowNumber="true"
  269. :rowSelection="true"
  270. >
  271. <template #action="props">
  272. <a @click="viewAccessory(props)">查看配件信息(view accessory information)</a>
  273. </template>
  274. </j-vxe-table>
  275. </a-tab-pane>
  276. </a-tabs>
  277. <SelectDeliveryNoticeModal ref="SelectDeliveryNoticeModalRef" @add-delivery="addSonList" />
  278. <BaseShipArchiveAccessoriesModal ref="BaseShipArchiveAccessoriesListRef" />
  279. <SelectCommissionOrderModal ref="SelectCommissionOrderModalRef" />
  280. <SelectProjectModal ref="SelectProjectModalRef" @select-project="addProject" />
  281. </a-spin>
  282. </template>
  283. <script lang="ts">
  284. import { defineComponent, ref, reactive, computed, toRaw, onMounted } from 'vue';
  285. import { defHttp } from '/@/utils/http/axios';
  286. import { useValidateAntFormAndTable } from '/@/hooks/system/useJvxeMethods';
  287. import {
  288. querysaleInvoiceFormShipListByMainId,
  289. querySaleInvoiceDetailListByMainId,
  290. queryDataById,
  291. saveOrUpdate,
  292. listHeard,
  293. queryDeliverDataById
  294. } from '../salesInvoiceForm.api';
  295. import { JVxeTable } from '/@/components/jeecg/JVxeTable';
  296. import { saleInvoiceShipColumns, saleInvoiceDetailColumns } from '../salesInvoiceForm.data';
  297. import BaseShipArchiveAccessoriesModal from '../../../publicComponents/BaseShipArchiveAccessoriesModal.vue';
  298. import SelectProjectModal from '../../../publicComponents/SelectProjectModal.vue';
  299. import SelectDeliveryNoticeModal from './SelectDeliveryNoticeModal.vue';
  300. import SelectCommissionOrderModal from './SelectCommissionOrderModal.vue';
  301. import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
  302. import JUpload from '/@/components/Form/src/jeecg/components/JUpload/JUpload.vue';
  303. import { JDictSelectTag, JSelectMultiple } from '/@/components/Form';
  304. import { ApiSelect } from '/@/components/Form/index';
  305. import { Form, message } from 'ant-design-vue';
  306. import { useUserStore } from '/@/store/modules/user';
  307. import moment from 'moment';
  308. const userStore = useUserStore();
  309. const useForm = Form.useForm;
  310. export default defineComponent({
  311. name: 'SaleInvoiceForm',
  312. components: {
  313. JVxeTable,
  314. JFormContainer,
  315. BaseShipArchiveAccessoriesModal,
  316. JUpload,
  317. SelectProjectModal,
  318. JDictSelectTag,
  319. JSelectMultiple,
  320. SelectDeliveryNoticeModal,
  321. SelectCommissionOrderModal,
  322. ApiSelect,
  323. },
  324. props: {
  325. formDisabled: {
  326. type: Boolean,
  327. default: false,
  328. },
  329. formData: { type: Object, default: () => {} },
  330. formBpm: { type: Boolean, default: true },
  331. },
  332. emits: ['success'],
  333. setup(props, { emit }) {
  334. const loading = ref(false);
  335. const formRef = ref();
  336. const SelectDeliveryNoticeModalRef = ref();
  337. const SelectCommissionOrderModalRef = ref();
  338. var SelectProjectModalRef = ref();
  339. const saleInvoiceFormShipTableRef = ref();
  340. const saleInvoiceFormShipTable = reactive<Record<string, any>>({
  341. loading: false,
  342. columns: saleInvoiceShipColumns,
  343. dataSource: [],
  344. });
  345. const saleInvoiceDetailsTableRef = ref();
  346. const saleInvoiceDetailsTable = reactive<Record<string, any>>({
  347. loading: false,
  348. columns: saleInvoiceDetailColumns,
  349. dataSource: [],
  350. });
  351. var BaseShipArchiveAccessoriesListRef = ref();
  352. const activeKey = ref('saleInvoiceDetails');
  353. var notAllowEdit = ref(false);
  354. var customerOption = ref([]);
  355. const formData = reactive<Record<string, any>>({
  356. id: '',
  357. status: undefined,
  358. delFlag: undefined,
  359. sourceCode: '',
  360. billDate: moment(new Date()).format('YYYY-MM-DD'),
  361. invoiceCode: '',
  362. project: '',
  363. projectName: '',
  364. customer: '',
  365. customerName: '',
  366. buyerTaxNumber: '',
  367. buyerTelphone: '',
  368. buyerAddress: '',
  369. buyerBank: '',
  370. buyerAccount: '',
  371. invoiceHeader: '',
  372. invoiceAddress: '',
  373. seller: '',
  374. sellerName: '',
  375. sellerTaxNumber: '',
  376. sellerTelphone: '',
  377. sellerAddress: '',
  378. sellerBank: '',
  379. sellerBankAccount: '',
  380. fnumber: '',
  381. notes: '',
  382. busynessType: '',
  383. });
  384. //表单验证
  385. const validatorRules = reactive({
  386. projectName: [{ required: true, message: '请选择项目(select project)' }],
  387. });
  388. const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });
  389. const dbData = {};
  390. const formItemLayout = {
  391. labelCol: { xs: { span: 24 }, sm: { span: 8 } },
  392. wrapperCol: { xs: { span: 24 }, sm: { span: 13 } },
  393. labelCol1: { xs: { span: 24 }, sm: { span: 8 } },
  394. wrapperCol1: { xs: { span: 24 }, sm: { span: 13 } },
  395. };
  396. // 表单禁用
  397. const disabled = computed(() => {
  398. if (props.formBpm === true) {
  399. if (props.formData.disabled === false) {
  400. return false;
  401. } else {
  402. return true;
  403. }
  404. }
  405. return props.formDisabled;
  406. });
  407. //新增方法
  408. function add() {
  409. resetFields();
  410. saleInvoiceFormShipTable.dataSource = [];
  411. saleInvoiceDetailsTable.dataSource = [];
  412. activeKey.value = 'saleInvoiceDetails';
  413. notAllowEdit.value = false;
  414. }
  415. //编辑方法
  416. async function edit(row) {
  417. //主表数据
  418. await queryMainData(row.id);
  419. //子表数据
  420. const saleInvoiceFormShipDataList = await querysaleInvoiceFormShipListByMainId(row['id']);
  421. saleInvoiceFormShipTable.dataSource = [...saleInvoiceFormShipDataList];
  422. const saleInvoiceDetailsDataList = await querySaleInvoiceDetailListByMainId(row['id']);
  423. saleInvoiceDetailsTable.dataSource = [...saleInvoiceDetailsDataList];
  424. notAllowEdit.value = true;
  425. }
  426. //获取主表
  427. async function queryMainData(id) {
  428. const row = await queryDataById(id);
  429. resetFields();
  430. const tmpData = {};
  431. Object.keys(formData).forEach((key) => {
  432. if (row.hasOwnProperty(key)) {
  433. tmpData[key] = row[key];
  434. }
  435. });
  436. //赋值
  437. Object.assign(formData, tmpData);
  438. }
  439. const { getSubFormAndTableData, transformData } = useValidateAntFormAndTable(activeKey, {
  440. saleInvoiceShip: saleInvoiceFormShipTableRef,
  441. saleInvoiceProduct: saleInvoiceDetailsTableRef,
  442. });
  443. //获取表单信息
  444. async function getFormData() {
  445. try {
  446. // 触发表单验证
  447. await validate();
  448. } catch ({ errorFields }) {
  449. if (errorFields) {
  450. const firstField = errorFields[0];
  451. if (firstField) {
  452. formRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
  453. }
  454. }
  455. return Promise.reject(errorFields);
  456. }
  457. return transformData(toRaw(formData));
  458. }
  459. //保存
  460. async function submitForm() {
  461. var xTable = saleInvoiceDetailsTableRef.value!.getXTable();
  462. if (xTable.data.length == 0) {
  463. message.warning('请添加发票明细');
  464. } else {
  465. saleInvoiceDetailsTableRef.value!.validateTable().then(async (errMap) => {
  466. if (errMap) {
  467. console.log('表单验证未通过:', { errMap });
  468. } else {
  469. const mainData = await getFormData();
  470. const subData = await getSubFormAndTableData();
  471. const values = Object.assign({}, dbData, mainData, subData);
  472. console.log('表单提交数据', values);
  473. const isUpdate = values.id ? true : false;
  474. await saveOrUpdate(values, isUpdate);
  475. //关闭弹窗
  476. emit('success');
  477. }
  478. });
  479. }
  480. }
  481. function setFieldsValue(values) {
  482. if (values) {
  483. Object.keys(values).map((k) => {
  484. formData[k] = values[k];
  485. });
  486. }
  487. }
  488. /**
  489. * 值改变事件触发-树控件回调
  490. * @param key
  491. * @param value
  492. */
  493. function handleFormChange(key, value) {
  494. formData[key] = value;
  495. }
  496. //产品明细-删除行
  497. async function handleDelete1(prop) {
  498. var xTable = saleInvoiceDetailsTableRef.value!.getXTable();
  499. var newArray = [...xTable.data];
  500. newArray.splice(prop.rowIndex, 1);
  501. saleInvoiceDetailsTable.dataSource = newArray;
  502. if (saleInvoiceDetailsTable.dataSource.length !== 0) {
  503. notAllowEdit.value = true;
  504. } else {
  505. notAllowEdit.value = false;
  506. add();
  507. }
  508. }
  509. //选择项目
  510. function addProject(data) {
  511. if (data.length == 0) {
  512. formData.project = formData.projectName = '';
  513. } else {
  514. formData.project = data[0].id;
  515. formData.projectName = data[0].code;
  516. formData.customer = data[0].customerId;
  517. formData.customerName = data[0].customerId_dictText;
  518. }
  519. }
  520. //获取客户列表
  521. function getCustomerOptions(params) {
  522. return defHttp.get({ url: '/cuspCode/cuspCustomerProfile/list', params });
  523. }
  524. //查看配件信息
  525. function viewAccessory(prop) {
  526. BaseShipArchiveAccessoriesListRef.value.getTable(prop.row);
  527. }
  528. //选择项目
  529. function onSearchProject() {
  530. SelectProjectModalRef.value.getTable();
  531. }
  532. function changeValues(prop) {
  533. if (prop.col.key == 'taxPrice' || prop.col.key == 'quantity') {
  534. prop.row.taxPrice = prop.row.taxPrice && prop.row.taxPrice !== '' ? prop.row.taxPrice : 0;
  535. prop.row.quantity = prop.row.quantity && prop.row.quantity !== '' ? prop.row.quantity : 0;
  536. var num = Number(prop.row.taxPrice) * Number(prop.row.quantity);
  537. prop.row.taxMoney = num.toFixed(2);
  538. prop.row.taxRate = prop.row.taxRate ? prop.row.taxRate : 0;
  539. prop.row.taxAmount = (Number(prop.row.taxMoney) * Number(prop.row.taxRate)) / 100;
  540. }
  541. }
  542. function selectDeliveryList() {
  543. if (formData.busynessType == '佣金业务') {
  544. message.warning('佣金业务不能选择发货通知单');
  545. } else if (saleInvoiceDetailsTable.dataSource == 0 || saleInvoiceDetailsTable.dataSource == undefined) {
  546. SelectDeliveryNoticeModalRef.value.getTable(formData);
  547. } else {
  548. message.warning('发票明细只可有一条数据');
  549. }
  550. }
  551. function selectCommissionList() {
  552. if (formData.busynessType == '普通业务') {
  553. message.warning('普通业务不能选择佣金订单');
  554. } else if (saleInvoiceDetailsTable.dataSource == 0 || saleInvoiceDetailsTable.dataSource == undefined) {
  555. SelectCommissionOrderModalRef.value.getTable();
  556. } else {
  557. message.warning('发票明细只可有一条数据');
  558. }
  559. }
  560. async function addSonList(data) {
  561. var arrDeliverSon = await queryDeliverDataById(data[0].id)
  562. arrDeliverSon.map((item) => {
  563. item.sourceId = item.id;
  564. item.quantity = item.quantity && item.quantity !== '' ? item.quantity : 0;
  565. item.taxPrice = item.taxPrice && item.taxPrice !== '' ? item.taxPrice : 0;
  566. item.taxMoney = item.money && item.money !== '' ? item.money : 0;
  567. //暂无税率字段,设置默认为1
  568. item.taxRate = item.taxRate ? item.taxRate : 0;
  569. item.taxAmount = (item.taxMoney * item.taxRate) / 100;
  570. item.sourceType='普通业务'
  571. });
  572. notAllowEdit.value = true;
  573. var xTable = saleInvoiceDetailsTableRef.value!.getXTable();
  574. var arrSonFormDelivery = xTable.data.concat(arrDeliverSon);
  575. saleInvoiceDetailsTable.dataSource = arrSonFormDelivery;
  576. formData.project = data[0].project;
  577. formData.projectName = data[0].projectName;
  578. formData.customer = data[0].customer;
  579. formData.customerName = data[0].customerName;
  580. formData.sourceCode = data[0].billCode;
  581. formData.invoiceHeader = data[0].invoiceHeader;
  582. formData.invoiceAddress = data[0].invoiceAddress;
  583. formData.busynessType = '普通业务';
  584. getCustomerOptions({ pageSize: -1, id: data[0].customer }).then((res) => {
  585. formData.buyerTaxNumber = res.records[0].dutyParagraph;
  586. formData.buyerTelphone = res.records[0].phone;
  587. formData.buyerAddress = res.records[0].invoiceAddress;
  588. });
  589. getShipDetail(data[0].id, 'delivery');
  590. }
  591. function getShipDetail(id, status) {
  592. let params = { id: id };
  593. let url =
  594. status == 'delivery' ? '/saleCode/saleDelivery/querySaleDeliveryShipByMainId' : '/saleCode/saleDelivery/querySaleContractShipByMainId';
  595. defHttp.get({ url: url, params }, { isTransformResponse: false }).then((res) => {
  596. if (res) {
  597. saleInvoiceFormShipTable.dataSource = res.result;
  598. }
  599. });
  600. }
  601. async function changeSeller(value) {
  602. var param = { id: value };
  603. var result = await listHeard(param);
  604. formData.sellerName = result.records[0].name;
  605. formData.sellerTaxNumber = result.records[0].taxcode;
  606. formData.sellerTelphone = result.records[0].telphone;
  607. formData.sellerAddress = result.records[0].address;
  608. formData.sellerBank = result.records[0].bank;
  609. formData.sellerBankAccount = result.records[0].bankAccount;
  610. }
  611. return {
  612. saleInvoiceFormShipTableRef,
  613. saleInvoiceFormShipTable,
  614. saleInvoiceDetailsTableRef,
  615. saleInvoiceDetailsTable,
  616. validatorRules,
  617. validateInfos,
  618. activeKey,
  619. loading,
  620. formData,
  621. setFieldsValue,
  622. handleFormChange,
  623. formItemLayout,
  624. disabled,
  625. getFormData,
  626. submitForm,
  627. add,
  628. edit,
  629. formRef,
  630. BaseShipArchiveAccessoriesListRef,
  631. viewAccessory,
  632. handleDelete1,
  633. SelectProjectModalRef,
  634. onSearchProject,
  635. addProject,
  636. getCustomerOptions,
  637. customerOption,
  638. notAllowEdit,
  639. changeValues,
  640. SelectDeliveryNoticeModalRef,
  641. selectDeliveryList,
  642. SelectCommissionOrderModalRef,
  643. selectCommissionList,
  644. addSonList,
  645. listHeard,
  646. changeSeller,
  647. };
  648. },
  649. });
  650. </script>
  651. <style lang="less" scoped>
  652. /** 时间和数字输入框样式 */
  653. :deep(.ant-input-number) {
  654. width: 100%;
  655. }
  656. :deep(.ant-calendar-picker) {
  657. width: 100%;
  658. }
  659. /deep/.vxe-table--body-wrapper {
  660. height: 100% !important;
  661. }
  662. /deep/.ant-modal-body {
  663. padding: 24px !important;
  664. }
  665. /deep/.ant-form-item {
  666. margin-bottom: 8px !important;
  667. }
  668. </style>