salesInvoiceList.vue 17 KB

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