salesInvoiceList.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. <template>
  2. <div class="p-2">
  3. <!--查询区域-->
  4. <div class="jeecg-basic-table-form-container">
  5. <a-form ref="formRef" @keyup.enter.native="reload" :model="queryParam" :label-col="{ style: 'width: 240px' }">
  6. <a-row :gutter="24">
  7. <a-col :lg="8">
  8. <a-form-item name="billDate">
  9. <template #label><span title="发票日期(bill date)">发票日期(bill date)</span></template>
  10. <a-range-picker value-format="YYYY-MM-DD" v-model:value="queryParam.billDate" class="query-group-cust" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :lg="8">
  14. <a-form-item name="project">
  15. <template #label><span title="项目(project)">项目(project)</span></template>
  16. <ApiSelect
  17. :api="ProjectOption"
  18. showSearch
  19. v-model:value="queryParam.project"
  20. :filterOption="true"
  21. resultField="records"
  22. labelField="code"
  23. valueField="id"
  24. :params="{ pageSize: -1, status: 1 }"
  25. optionFilterProp="label"
  26. />
  27. </a-form-item>
  28. </a-col>
  29. <template v-if="toggleSearchStatus">
  30. <a-col :lg="8">
  31. <a-form-item name="invoiceCode">
  32. <template #label><span title="发票编号(invoice code)">发票编号(invoice code)</span></template>
  33. <JInput placeholder="请输入发票编号(invoice code)" v-model:value="queryParam.invoiceCode" allow-clear AutoComplete="off" />
  34. </a-form-item>
  35. </a-col>
  36. <a-col :lg="16">
  37. <a-form-item name="customer">
  38. <template #label><span title="购方(buyer)">购方(buyer)</span></template>
  39. <JSelect v-model:value="queryParam.customer" :get-option-url="CustomerOption" :showField="showField" :param="{ status: 1 }" />
  40. </a-form-item>
  41. </a-col>
  42. <a-col :lg="8">
  43. <a-form-item name="sourceCode">
  44. <template #label><span title="来源(sourceCode)">通知单来源(sourceCode)</span></template>
  45. <JInput placeholder="请输入" v-model:value="queryParam.sourceCode" allow-clear AutoComplete="off" />
  46. </a-form-item>
  47. </a-col>
  48. <a-col :lg="8">
  49. <a-form-item name="sourceCode2">
  50. <template #label><span title="来源(sourceCode)">佣金来源(sourceCode)</span></template>
  51. <JInput placeholder="请输入" v-model:value="queryParam.sourceCode2" allow-clear AutoComplete="off" />
  52. </a-form-item>
  53. </a-col>
  54. <a-col :lg="8">
  55. <a-form-item name="orderNumber">
  56. <template #label><span title="客户订单号(customer order number)">客户订单号(customer order number)</span></template>
  57. <JInput placeholder="请输入" v-model:value="queryParam.orderNumber" allow-clear AutoComplete="off" />
  58. </a-form-item>
  59. </a-col>
  60. <a-col :lg="8">
  61. <a-form-item name="organize">
  62. <template #label><span title="组织(organize)">组织(organize)</span></template>
  63. <a-select v-model:value="queryParam.organize">
  64. <a-select-option value="上海">上海</a-select-option>
  65. <a-select-option value="香港">香港</a-select-option>
  66. </a-select>
  67. </a-form-item>
  68. </a-col>
  69. <a-col :lg="8">
  70. <a-form-item name="submit">
  71. <template #label><span title="提交(submit)">提交(submit)</span></template>
  72. <JDictSelectTag v-model:value="queryParam.submit" placeholder="请选择" dictCode="yes_or_no" style="width: 100%" />
  73. </a-form-item>
  74. </a-col>
  75. <a-col :lg="8">
  76. <a-form-item name="close">
  77. <template #label><span title="作废(nullify)">作废(nullify)</span></template>
  78. <JDictSelectTag v-model:value="queryParam.close" placeholder="请选择" dictCode="yes_or_no" style="width: 100%" />
  79. </a-form-item>
  80. </a-col>
  81. </template>
  82. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  83. <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
  84. <a-col :lg="6">
  85. <a-button type="primary" preIcon="ant-design:search-outlined" @click="reload">查询</a-button>
  86. <a-button preIcon="ant-design:reload-outlined" @click="searchReset" style="margin-left: 8px">重置</a-button>
  87. <a @click="toggleSearchStatus = !toggleSearchStatus" style="margin-left: 8px">
  88. {{ toggleSearchStatus ? '收起' : '展开' }}
  89. <Icon :icon="toggleSearchStatus ? 'ant-design:up-outlined' : 'ant-design:down-outlined'" />
  90. </a>
  91. </a-col>
  92. </span>
  93. </a-col>
  94. </a-row>
  95. </a-form>
  96. </div>
  97. <!--引用表格-->
  98. <BasicTable @register="registerTable" :rowSelection="rowSelection" size="small">
  99. <!--插槽:table标题-->
  100. <template #tableTitle>
  101. <a-button type="primary" v-auth="'saleCode:sale_invoice:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增(add)</a-button>
  102. <a-button type="primary" v-auth="'saleCode:sale_invoice:exportXls'" preIcon="ant-design:export-outlined" @click="preProcessingExport">
  103. <!-- <a-button type="primary" v-auth="'saleCode:sale_invoice:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> -->
  104. 导出(export)</a-button
  105. >
  106. <a-button type="primary" @click="submit"> 提交(submit)</a-button>
  107. <a-button type="primary" @click="cancelSubmit"> 取消提交(cancelSubmit)</a-button>
  108. <a-button type="primary" v-auth="'saleCode:sale_invoice:nullify'" @click="handleNullify"> 作废(nullify)</a-button>
  109. <a-dropdown v-if="selectedRowKeys.length > 0">
  110. <template #overlay>
  111. <a-menu>
  112. <a-menu-item key="1" @click="batchHandleDelete" v-auth="'saleCode:sale_invoice:deleteBatch'">
  113. <Icon icon="ant-design:delete-outlined" />
  114. 删除(delete)
  115. </a-menu-item>
  116. </a-menu>
  117. </template>
  118. <a-button v-auth="'saleCode:sale_invoice:deleteBatch'"
  119. >批量操作
  120. <Icon icon="mdi:chevron-down" />
  121. </a-button>
  122. </a-dropdown>
  123. </template>
  124. <!--操作栏-->
  125. <template #action="{ record }">
  126. <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
  127. </template>
  128. <!--字段回显插槽-->
  129. <template #bodyCell="{ column, record, index, text }"> </template>
  130. <template #jumpToAndExport="props">
  131. <a @click="handleView(props)">查看(view)</a>
  132. <a-divider type="vertical" />
  133. <a @click="handleRowExport(props)">导出(export)</a>
  134. </template>
  135. <template #jumpTo="props">
  136. <a @click="handleView(props)">查看(view)</a>
  137. </template>
  138. <template #viewFile="props">
  139. <a @click="handleViewFile(props, '1')">查看</a>
  140. </template>
  141. <template #signFile="props">
  142. <a @click="handleViewFile(props, '2')">查看(view)</a>
  143. </template>
  144. </BasicTable>
  145. <!-- 表单区域 -->
  146. <saleInvoiceFormModal @register="registerModal" @success="handleSuccess" />
  147. <SaleOrderFormList @register="registerModal1" @visible-change="changeVisi" />
  148. <PurchaseOrderFormList @register="registerModal2" @visible-change="changeVisi" />
  149. <ViewFileListModal ref="ViewFileListModalRef" @success="handleSuccess" />
  150. <SaleContractList @register="registerModal3" @visible-change="changeVisi" />
  151. </div>
  152. </template>
  153. <script lang="ts" name="saleCode-saleInquiryForm" setup>
  154. import { ref, reactive, computed, unref, onMounted } from 'vue';
  155. import { BasicTable, useTable, TableAction } from '/@/components/Table';
  156. import { useListPage } from '/@/hooks/system/useListPage';
  157. import { columns } from './salesInvoiceForm.data';
  158. import {
  159. list,
  160. deleteOne,
  161. batchDelete,
  162. getImportUrl,
  163. getExportUrl,
  164. batchSubmit,
  165. cancelBatchSubmit,
  166. batchClose,
  167. editSignSing,
  168. getListDetail,
  169. ProjectOption,
  170. CustomerOption,
  171. getExportUrlRow,
  172. getExportSaleOrderUrl,
  173. getExportPurOrderUrl,
  174. } from './salesInvoiceForm.api';
  175. import { cloneDeep } from 'lodash-es';
  176. import { defHttp } from '/@/utils/http/axios';
  177. import { JDictSelectTag, ApiSelect, JInput, JSelect } from '/@/components/Form';
  178. import saleInvoiceFormModal from './components/saleInvoiceFormModal.vue';
  179. import SaleOrderFormList from '../salesOrder/components/SaleOrderFormModal.vue';
  180. import PurchaseOrderFormList from '../../purchase/purchaseOrder/components/PurchaseOrderFormModal.vue';
  181. import SaleContractList from '../saleContract/components/SaleContractModal.vue';
  182. import ViewFileListModal from './components/ViewFileListModal.vue';
  183. import { useModal } from '/@/components/Modal';
  184. import { message } from 'ant-design-vue';
  185. import { useMethods } from '/@/hooks/system/useMethods';
  186. const { handleExportXlsx } = useMethods();
  187. const formRef = ref();
  188. var queryParam = reactive<any>({});
  189. var viewType = ref('');
  190. //注册model
  191. var [registerModal, { openModal }] = useModal();
  192. var [registerModal1, { openModal: openSaleOrder }] = useModal();
  193. var [registerModal2, { openModal: openPurOrder }] = useModal();
  194. var [registerModal3, { openModal: openSaleContract }] = useModal();
  195. var classOption = ref([]);
  196. var showField = ref('currency_dictText+name');
  197. var ViewFileListModalRef = ref();
  198. //注册table数据
  199. const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
  200. tableProps: {
  201. title: '销售发票',
  202. api: list,
  203. columns,
  204. canResize: false,
  205. useSearchForm: false,
  206. actionColumn: {
  207. width: 300,
  208. fixed: 'right',
  209. },
  210. scroll: {
  211. x: '3500px',
  212. y: 'calc(100vh - 400px)',
  213. },
  214. beforeFetch: async (params) => {
  215. let rangerQuery = await setRangeQuery();
  216. return Object.assign(params, rangerQuery);
  217. },
  218. },
  219. exportConfig: {
  220. name: '销售发票',
  221. url: getExportUrl,
  222. params: queryParam,
  223. },
  224. importConfig: {
  225. url: getImportUrl,
  226. success: handleSuccess,
  227. },
  228. });
  229. const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
  230. // 自动请求并暴露内部方法
  231. onMounted(() => {
  232. getOptiom();
  233. });
  234. /**
  235. * 新增事件
  236. */
  237. function handleAdd() {
  238. openModal(true, {
  239. isUpdate: false,
  240. showFooter: true,
  241. isRevise: false,
  242. });
  243. }
  244. /**
  245. * 编辑事件
  246. */
  247. async function handleEdit(record: Recordable) {
  248. openModal(true, {
  249. record,
  250. isUpdate: true,
  251. showFooter: true,
  252. isRevise: false,
  253. });
  254. }
  255. // 产品分类
  256. function getOptiom() {
  257. defHttp
  258. .get({ url: 'baseCode/baseProductClass/list' }, { isTransformResponse: false })
  259. .then((res) => {
  260. if (res.success) {
  261. classOption.value = [];
  262. res.result.records.forEach((element) => {
  263. var obj = {
  264. label: element.name ? element.name : '无名称请维护',
  265. value: element.id ? element.id : '',
  266. };
  267. classOption.value.push(obj);
  268. });
  269. }
  270. })
  271. .finally(() => {
  272. // loading.value = false;
  273. });
  274. }
  275. /**
  276. * 详情
  277. */
  278. function handleDetail(record: Recordable) {
  279. openModal(true, {
  280. record,
  281. isUpdate: true,
  282. showFooter: false,
  283. });
  284. }
  285. /**
  286. * 删除事件
  287. */
  288. async function handleDelete(record) {
  289. await deleteOne({ id: record.id }, handleSuccess);
  290. }
  291. /**
  292. * 批量删除事件
  293. */
  294. async function batchHandleDelete() {
  295. await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
  296. }
  297. /**
  298. * 成功回调
  299. */
  300. function handleSuccess() {
  301. (selectedRowKeys.value = []) && reload();
  302. }
  303. /**
  304. * 操作栏
  305. */
  306. function getTableAction(record) {
  307. return [
  308. {
  309. label: '导出(export)',
  310. onClick: handleExportRow.bind(null, record),
  311. },
  312. {
  313. label: '编辑(edit)',
  314. onClick: handleEdit.bind(null, record),
  315. auth: 'saleCode:sale_invoice:edit',
  316. ifShow: record.submit == '0' || !record.submit,
  317. },
  318. {
  319. label: '详情(detail)',
  320. onClick: handleDetail.bind(null, record),
  321. ifShow: record.submit == '1',
  322. },
  323. ];
  324. }
  325. /**
  326. * 下拉操作栏
  327. */
  328. function getDropDownAction(record) {
  329. return [
  330. {
  331. label: '详情(detail)',
  332. onClick: handleDetail.bind(null, record),
  333. ifShow: record.submit == '0' || !record.submit,
  334. },
  335. {
  336. label: '下载信用证(Doenload letter of Credit)',
  337. auth: 'saleCode:sale_inquiry_form:delete',
  338. ifShow: record.submit == '1',
  339. },
  340. {
  341. label: '上传盖章发票(upload stamp in invoice)',
  342. auth: 'saleCode:sale_inquiry_form:delete',
  343. ifShow: record.submit == '1',
  344. },
  345. {
  346. label: '删除(delete)',
  347. popConfirm: {
  348. title: '是否确认删除',
  349. confirm: handleDelete.bind(null, record),
  350. placement: 'topLeft',
  351. },
  352. auth: 'saleCode:sale_invoice:delete',
  353. ifShow: record.submit == '0' || !record.submit,
  354. },
  355. ];
  356. }
  357. async function handleExportRow(record) {
  358. var obj = {
  359. id: record.id,
  360. };
  361. handleExportXlsx(record.invoiceCode, getExportUrlRow, obj);
  362. }
  363. function submit() {
  364. if (selectedRowKeys.value.length == 0) {
  365. message.warning('请选择数据');
  366. } else {
  367. var ids = selectedRowKeys.value.join(',');
  368. batchSubmit({ ids: ids }, handleSuccess);
  369. }
  370. }
  371. function cancelSubmit() {
  372. if (selectedRowKeys.value.length == 0) {
  373. message.warning('请选择数据');
  374. } else {
  375. var ids = selectedRowKeys.value.join(',');
  376. cancelBatchSubmit({ ids: ids }, handleSuccess);
  377. }
  378. }
  379. // 作废
  380. function handleNullify() {
  381. if (selectedRowKeys.value.length == 0) {
  382. message.warning('请选择数据');
  383. } else {
  384. var ids = selectedRowKeys.value.join(',');
  385. batchClose({ ids: ids }, handleSuccess);
  386. }
  387. }
  388. async function handleView(prop) {
  389. var param = {
  390. id: '',
  391. type: '',
  392. };
  393. if (prop.column.dataIndex == 'saleOrder') {
  394. viewType.value = 'saleOrder';
  395. param.id = prop.record.id;
  396. param.type = 'saleOrder';
  397. var record = await getListDetail(param);
  398. openSaleOrder(true, {
  399. record,
  400. isUpdate: true,
  401. showFooter: false,
  402. });
  403. } else if (prop.column.dataIndex == 'purchaseOrder') {
  404. viewType.value = 'purchaseOrder';
  405. param.id = prop.record.id;
  406. param.type = 'purchaseOrder';
  407. var record = await getListDetail(param);
  408. openPurOrder(true, {
  409. record,
  410. isUpdate: true,
  411. showFooter: false,
  412. });
  413. } else if (prop.column.dataIndex == 'saleContract') {
  414. viewType.value = 'saleContract';
  415. param.id = prop.record.id;
  416. param.type = 'saleContract';
  417. var record = await getListDetail(param);
  418. openSaleContract(true, {
  419. record,
  420. isUpdate: true,
  421. showFooter: false,
  422. });
  423. }
  424. }
  425. async function handleRowExport(prop) {
  426. let param = {
  427. id: '',
  428. type: '',
  429. };
  430. if (prop.column.dataIndex == 'saleOrder') {
  431. viewType.value = 'saleOrder';
  432. param.id = prop.record.id;
  433. param.type = 'saleOrder';
  434. var record = await getListDetail(param);
  435. let obj = {
  436. id: record.id,
  437. };
  438. handleExportXlsx(record.billCode, getExportSaleOrderUrl, obj);
  439. } else if (prop.column.dataIndex == 'purchaseOrder') {
  440. viewType.value = 'purchaseOrder';
  441. param.id = prop.record.id;
  442. param.type = 'purchaseOrder';
  443. var record = await getListDetail(param);
  444. let obj = {
  445. id: record.id,
  446. };
  447. handleExportXlsx(record.billCode, getExportPurOrderUrl, obj);
  448. }
  449. }
  450. function changeVisi(data) {
  451. if (!data) {
  452. viewType.value = '';
  453. }
  454. }
  455. function handleViewFile(prop, data) {
  456. if (data == '1') {
  457. ViewFileListModalRef.value.getTable(prop.record);
  458. } else {
  459. ViewFileListModalRef.value.viewFile(prop.record);
  460. }
  461. }
  462. async function preProcessingExport() {
  463. if (queryParam.billDate && queryParam.billDate.length !== 0) {
  464. var bv = Object.assign({}, queryParam);
  465. var obj = await setRangeQuery();
  466. Object.assign(queryParam, obj);
  467. delete queryParam.billDate;
  468. await onExportXls();
  469. queryParam.billDate = [bv.billDate[0], bv.billDate[1]];
  470. } else {
  471. await onExportXls();
  472. }
  473. }
  474. /* ----------------------以下为原生查询需要添加的-------------------------- */
  475. const toggleSearchStatus = ref<boolean>(false);
  476. const labelCol = reactive({
  477. xs: 24,
  478. sm: 8,
  479. });
  480. const wrapperCol = reactive({
  481. xs: 24,
  482. sm: 16,
  483. });
  484. const labelCol1 = reactive({
  485. xs: 24,
  486. sm: 11,
  487. });
  488. const wrapperCol1 = reactive({
  489. xs: 24,
  490. sm: 13,
  491. });
  492. /**
  493. * 重置
  494. */
  495. function searchReset() {
  496. formRef.value.resetFields();
  497. selectedRowKeys.value = [];
  498. //刷新数据
  499. reload();
  500. }
  501. let rangeField = 'billDate,';
  502. /**
  503. * 设置范围查询条件
  504. */
  505. async function setRangeQuery() {
  506. let queryParamClone = cloneDeep(queryParam);
  507. if (rangeField) {
  508. let fieldsValue = rangeField.split(',');
  509. fieldsValue.forEach((item) => {
  510. if (queryParamClone[item]) {
  511. let range = queryParamClone[item];
  512. queryParamClone[item + '_begin'] = range[0];
  513. queryParamClone[item + '_end'] = range[1];
  514. delete queryParamClone[item];
  515. } else {
  516. queryParamClone[item + '_begin'] = '';
  517. queryParamClone[item + '_end'] = '';
  518. }
  519. });
  520. }
  521. return queryParamClone;
  522. }
  523. </script>
  524. <style lang="less" scoped>
  525. .jeecg-basic-table-form-container {
  526. padding: 0;
  527. .table-page-search-submitButtons {
  528. display: block;
  529. margin-bottom: 8px;
  530. white-space: nowrap;
  531. }
  532. .query-group-cust {
  533. min-width: 100px !important;
  534. }
  535. .query-group-split-cust {
  536. width: 30px;
  537. display: inline-block;
  538. text-align: center;
  539. }
  540. .ant-form-item:not(.ant-form-item-with-help) {
  541. margin-bottom: 8px;
  542. height: 32px;
  543. }
  544. :deep(.ant-picker),
  545. :deep(.ant-input-number) {
  546. width: 100%;
  547. }
  548. }
  549. </style>