saleInvoiceForm.vue 26 KB

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