SelectSaleOrderModal.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. <template>
  2. <a-modal
  3. title="选择销售订单(Select Sale Order)"
  4. width="95%"
  5. :visible="visible"
  6. :maskClosable="false"
  7. switchFullscreen
  8. @ok = "handleOk"
  9. @cancel="handleCancel">
  10. <div>
  11. <a-card :body-style="{ padding: '10px' }" :bordered="false" style="margin: 10px;">
  12. <div class="table-page-search-wrapper">
  13. <a-form :model="queryParams" :label-col="labelCol" :wrapper-col="wrapperCol" @keyup.enter.native="searchQuery">
  14. <a-row :gutter="24">
  15. <a-col :md="6" :sm="8">
  16. <a-form-item label="订单编号(bill code)">
  17. <a-input placeholder="请输入" v-model:value="queryParams.billCode"></a-input>
  18. </a-form-item>
  19. </a-col>
  20. <a-col :md="6" :sm="8">
  21. <a-form-item label="单据日期(bill date)">
  22. <a-range-picker value-format="YYYY-MM-DD" v-model:value="billDate" @change="changeBillDate" class="query-group-cust"/>
  23. </a-form-item>
  24. </a-col>
  25. <template v-if="toggleSearchStatus">
  26. <a-col :md="6" :sm="8">
  27. <a-form-item label="项目(project)">
  28. <ApiSelect
  29. :api="ProjectOption"
  30. showSearch
  31. v-model:value="queryParams.project"
  32. optionFilterProp="label"
  33. resultField="records"
  34. labelField="name"
  35. valueField="id"
  36. :params='{pageSize:-1}'
  37. :disabled="fatherProject!==''"
  38. />
  39. </a-form-item>
  40. </a-col>
  41. <a-col :md="6" :sm="8">
  42. <a-form-item label="产品分类(production class)" :label-col="labelCol1" :wrapper-col="wrapperCol1">
  43. <!-- <a-input placeholder="请输入" v-model:value="queryParams.classId"></a-input> -->
  44. <ApiSelect
  45. :api="ClassList"
  46. showSearch
  47. v-model:value="queryParams.productionClass"
  48. optionFilterProp="label"
  49. resultField="records"
  50. labelField="name"
  51. valueField="id"
  52. :params='{pageSize:-1}'
  53. />
  54. </a-form-item>
  55. </a-col>
  56. <a-col :md="6" :sm="8">
  57. <a-form-item label="优先级(priority)" >
  58. <JDictSelectTag v-model:value="queryParams.priority" placeholder="请选择" dictCode="priority"/>
  59. </a-form-item>
  60. </a-col>
  61. <a-col :md="6" :sm="8" v-if="showCustomer=='no'">
  62. <a-form-item label="供应商(supplier)" >
  63. <ApiSelect
  64. :api="supplierOption"
  65. showSearch
  66. v-model:value="queryParams.supplierName"
  67. optionFilterProp="label"
  68. resultField="records"
  69. labelField="name"
  70. valueField="name"
  71. :params='{pageSize:-1}'
  72. />
  73. </a-form-item>
  74. </a-col>
  75. <a-col :md="6" :sm="8" v-if="showCustomer=='yes'">
  76. <a-form-item label="客户(supplier)">
  77. <ApiSelect
  78. :api="CustomerOption"
  79. showSearch
  80. v-model:value="queryParams.customerName"
  81. optionFilterProp="label"
  82. resultField="records"
  83. labelField="abbreviation"
  84. valueField="name"
  85. />
  86. </a-form-item>
  87. </a-col>
  88. <a-col :md="6" :sm="8">
  89. <a-form-item label="机型(model)">
  90. <JDictSelectTag v-model:value="queryParams.headModel" placeholder="请选择" dictCode="model_typer" style="width: 100%;"/>
  91. </a-form-item>
  92. </a-col>
  93. <a-col :md="6" :sm="8">
  94. <a-form-item label="产品英文名(English name)" :label-col="labelCol1" :wrapper-col="wrapperCol1">
  95. <a-input placeholder="请输入" v-model:value="queryParams.englishName"></a-input>
  96. </a-form-item>
  97. </a-col>
  98. <a-col :md="6" :sm="8">
  99. <a-form-item label="产品编码(product code)">
  100. <a-input placeholder="请输入" v-model:value="queryParams.productCode"></a-input>
  101. </a-form-item>
  102. </a-col>
  103. <a-col :md="6" :sm="8">
  104. <a-form-item label="型号(model)">
  105. <a-input placeholder="请输入" v-model:value="queryParams.childModel"></a-input>
  106. </a-form-item>
  107. </a-col>
  108. <a-col :md="6" :sm="8">
  109. <a-form-item label="业务员(salesman)">
  110. <a-input placeholder="请输入" v-model:value="queryParams.salesman"></a-input>
  111. </a-form-item>
  112. </a-col>
  113. <a-col :md="6" :sm="8">
  114. <a-form-item label="销售部门(sale department)" :label-col="labelCol1" :wrapper-col="wrapperCol1">
  115. <a-input placeholder="请输入" v-model:value="queryParams.saleDepartment"></a-input>
  116. </a-form-item>
  117. </a-col>
  118. </template>
  119. <a-col :md="6" :sm="8">
  120. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  121. <a-button type="primary" @click="searchQuery" >查询(search)</a-button>
  122. <a-button type="primary" @click="searchReset" style="margin-left: 8px">重置(reset)</a-button>
  123. <a @click="handleToggleSearch" style="margin-left: 8px">
  124. {{ toggleSearchStatus ? '收起' : '展开' }}
  125. <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
  126. </a>
  127. </span>
  128. </a-col>
  129. </a-row>
  130. </a-form>
  131. </div>
  132. </a-card>
  133. <a-card :body-style="{ padding: '10px' }" :bordered="false" style="margin: 10px;">
  134. <a-alert type="info" show-icon class="alert" style="margin-bottom: 8px">
  135. <template #message>
  136. <template v-if="selectedRowKeys.length > 0">
  137. <span>已选中 {{ selectedRowKeys.length }} 条记录</span>
  138. <a-divider type="vertical" />
  139. <a @click="selectedRowKeys = []">清空</a>
  140. </template>
  141. <template v-else>
  142. <span>未选中任何数据</span>
  143. </template>
  144. </template>
  145. </a-alert>
  146. <a-table
  147. :columns="columns"
  148. :row-key="record => record.childId"
  149. :data-source="dataSource"
  150. bordered
  151. size="small"
  152. @change="handleTableChange"
  153. :pagination="pagination"
  154. :scroll="{ x: 4000, y: 300 }"
  155. :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
  156. >
  157. </a-table>
  158. </a-card>
  159. </div>
  160. </a-modal>
  161. </template>
  162. <script lang="ts" setup>
  163. import {ref, reactive } from 'vue';
  164. import { defHttp} from '/@/utils/http/axios';
  165. import { message } from 'ant-design-vue';
  166. import { filterObj, getFileAccessHttpUrl } from '/@/utils/common/compUtils';
  167. import { JDictSelectTag,ApiSelect} from '/@/components/Form';
  168. import {ProjectOption,ClassList,supplierOption} from '../saleCode/deliveryNotice/delivertNoticeForm.api';
  169. import {CustomerOption} from '../saleCode/saleContract/SaleContract.api';
  170. const emit = defineEmits([ 'selectSaleOrder']); //定义emit
  171. var visible = ref(false)
  172. var fatherProject = ref('')
  173. var fatherSourceCode = ref('')
  174. var fatherSupplierName =ref('')
  175. var fatherType = ref('')
  176. var fatherCustomerName=ref('')
  177. var showCustomer = ref('no')
  178. var columns=[]
  179. var columns1 = [
  180. {
  181. title: '订单编号号(bill code)',
  182. dataIndex: 'billCode',
  183. key: 'billCode',
  184. align:"center",
  185. width:250,
  186. },
  187. {
  188. title: '单据日期(bill date)',
  189. dataIndex: 'billDate',
  190. key: 'billDate',
  191. align:"center"
  192. },
  193. {
  194. title: '项目(project)',
  195. dataIndex: 'projectName',
  196. key: 'projectName',
  197. align:"center",
  198. width:250,
  199. ellipsis: true,
  200. },
  201. {
  202. title: '供应商(supplier)',
  203. dataIndex: 'supplierName',
  204. key: 'supplierName',
  205. align:"center",
  206. ellipsis: true,
  207. ifShow:showCustomer.value=='no'?true:false,
  208. // className:showCustomer.value=='no'?'tableShow':'tableHiddle'
  209. },
  210. {
  211. title: '客户(customer)',
  212. dataIndex: 'customerName',
  213. key: 'customerName',
  214. align:"center",
  215. ellipsis: true,
  216. // className:showCustomer.value=='yes'?'tableShow':'tableHiddl
  217. },
  218. {
  219. title: '优先级(priority)',
  220. dataIndex: 'priority_dictText',
  221. key: 'priority_dictText',
  222. align:"center"
  223. },
  224. {
  225. title: '产品分类(production class)',
  226. dataIndex: 'productClass',
  227. key: 'productClass',
  228. align:"center",
  229. width:250,
  230. },
  231. {
  232. title: '机型(model)',
  233. dataIndex: 'headModel',
  234. key: 'headModel',
  235. align:"center"
  236. },
  237. {
  238. title: '销售部门(sale department)',
  239. dataIndex: 'saleDepartment',
  240. key: 'saleDepartment',
  241. align:"center"
  242. },
  243. {
  244. title: '业务员(salesman)',
  245. dataIndex: 'salesman',
  246. key: 'salesman',
  247. align:"center"
  248. },
  249. {
  250. title: '产品编码(product code)',
  251. dataIndex: 'productCode',
  252. key: 'productCode',
  253. align:"center",
  254. width:250,
  255. },
  256. {
  257. title: '产品英文名(English name)',
  258. key: 'englishName',
  259. dataIndex: 'englishName',
  260. align:"center",
  261. width:250,
  262. },
  263. {
  264. title: '型号(childModel)',
  265. key: 'childModel',
  266. dataIndex: 'childModel',
  267. align:"center"
  268. },
  269. {
  270. title: '厂家(factory)',
  271. key: 'factory',
  272. dataIndex: 'factory',
  273. align:"center",
  274. width:250
  275. },
  276. {
  277. title: '质量等级(quantity grade)',
  278. key: 'quantityGrade',
  279. dataIndex: 'quantityGrade',
  280. align:"center",
  281. width:250,
  282. },
  283. {
  284. title: '数量(quantity)',
  285. key: 'quantity',
  286. dataIndex: 'quantity',
  287. align:"center",
  288. width:250,
  289. },
  290. // {
  291. // title: '单价(price)',
  292. // key: 'taxPrice',
  293. // dataIndex: 'taxPrice',
  294. // align:"center",
  295. // width:250,
  296. // },
  297. // {
  298. // title: '金额(tax money)',
  299. // key: 'taxAmount',
  300. // dataIndex: 'taxAmount',
  301. // align:"center",
  302. // width:250,
  303. // },
  304. ];
  305. const labelCol = ref({
  306. xs: { span: 24 },
  307. sm: { span: 9 },
  308. });
  309. const wrapperCol = ref({
  310. xs: { span: 24 },
  311. sm: { span: 15 },
  312. });
  313. const labelCol1 = ref({
  314. xs: { span: 24 },
  315. sm: { span: 12 },
  316. });
  317. const wrapperCol1 = ref({
  318. xs: { span: 24 },
  319. sm: { span: 12 },
  320. });
  321. const dataSource =ref([]);
  322. let selectedRowKeys = ref([]);
  323. let selectedRows = ref([]);
  324. const toggleSearchStatus = ref(false);
  325. var billDate = ref([])
  326. const queryParams = ref({
  327. billCode:'',
  328. project:'',
  329. projectName:'',
  330. productionClass:'',
  331. priority:'',
  332. supplierId:'',
  333. supplierName:'',
  334. headModel:'',
  335. englishName:'',
  336. productCode:'',
  337. childModel:'',
  338. billDate_begin:'',
  339. billDate_end:'',
  340. saleDepartment:'',
  341. salesman:'',
  342. customer:'',
  343. customerName:''
  344. });
  345. let pagination = ref({
  346. current: 1,
  347. pageSize: 10,
  348. total: '', // 假设总共有100条数据
  349. showSizeChanger: true,
  350. showQuickJumper: true,
  351. showTotal: (total, range) => {
  352. return range[0] + "-" + range[1] + " 共" + total + "条"
  353. },
  354. size:'small'
  355. });
  356. function loadData(){
  357. let params = getQueryParams();
  358. defHttp.get({ url: '/saleCode/saleOrder/selectSaleOrderDetailAlert',params}, { isTransformResponse: false })
  359. .then((res) => {
  360. if (res.success) {
  361. dataSource.value = res.result.records;
  362. pagination.value.total = res.result.total;
  363. pagination.value.current = res.result.current;
  364. pagination.value.pageSize = res.result.size;
  365. } else {
  366. message.error(res.message);
  367. }
  368. })
  369. .finally(() => {
  370. // loading.value = false;
  371. });
  372. }
  373. function getQueryParams(){
  374. let params = Object.assign(queryParams.value);
  375. params.pageNo = pagination.value.current;
  376. params.pageSize = pagination.value.pageSize;
  377. if(fatherProject.value&&fatherProject.value!==''){
  378. queryParams.value.project = fatherProject.value
  379. }else {
  380. queryParams.value.project = params.project
  381. }
  382. if(fatherSupplierName.value&&fatherSupplierName.value!==''){
  383. queryParams.value.supplierName = fatherSupplierName.value
  384. }else {
  385. queryParams.value.supplierName = params.supplierName
  386. }
  387. if(fatherCustomerName.value&&fatherCustomerName.value!==''){
  388. queryParams.value.customerName = fatherCustomerName.value
  389. }else {
  390. queryParams.value.customerName = params.customerName
  391. }
  392. return filterObj(params);
  393. }
  394. function handleTableChange(paginations, filters, sorter){
  395. pagination.value.total = paginations.total;
  396. pagination.value.current = paginations.current;
  397. pagination.value.pageSize = paginations.pageSize;
  398. loadData()
  399. }
  400. function searchQuery(){
  401. pagination.value.current = 1
  402. loadData();
  403. }
  404. function searchReset(){
  405. billDate.value = []
  406. queryParams.value = {
  407. billCode:'',
  408. project:'',
  409. projectName:'',
  410. productionClass:'',
  411. priority:'',
  412. supplierId:'',
  413. supplierName:'',
  414. headModel:'',
  415. englishName:'',
  416. productCode:'',
  417. childModel:'',
  418. billDate_begin:'',
  419. billDate_end:'',
  420. saleDepartment:'',
  421. salesman:'',
  422. customer:'',
  423. customerName:''
  424. }
  425. pagination.value.current =1;
  426. pagination.value.pageSize = 10;
  427. loadData();
  428. }
  429. function handleToggleSearch(){
  430. toggleSearchStatus.value = !toggleSearchStatus.value;
  431. }
  432. function onSelectChange(keys,rows){
  433. selectedRowKeys.value = keys
  434. selectedRows.value = rows
  435. }
  436. function handleOk(){
  437. if(fatherType.value=='payRequest'){
  438. emit('selectSaleOrder', selectedRows.value)
  439. handleCancel()
  440. }else{
  441. var arr = [],
  442. arrSupplierName=[]
  443. selectedRows.value.map(item=>{
  444. arr.push(item.billCode)
  445. arrSupplierName.push(item.supplierName)
  446. })
  447. if(fatherSourceCode.value&&fatherSourceCode.value!==''){
  448. arr.push(fatherSourceCode.value)
  449. }
  450. if(fatherSupplierName.value&&fatherSupplierName.value!==''){
  451. arrSupplierName.push(fatherSupplierName.value)
  452. }
  453. if(selectedRowKeys.value.length==0){
  454. message.error('请勾选数据');
  455. }else if(new Set(arr).size!==1){
  456. message.error('请勾选订单编号相同的数据');
  457. }else if(new Set(arrSupplierName).size!==1){
  458. message.error('请勾选供应商相同的数据');
  459. }else{
  460. emit('selectSaleOrder', selectedRows.value)
  461. handleCancel()
  462. }
  463. }
  464. }
  465. function handleCancel(){
  466. visible.value = false
  467. selectedRowKeys.value = []
  468. selectedRows.value=[]
  469. billDate.value = []
  470. queryParams.value = {
  471. billCode:'',
  472. project:'',
  473. projectName:'',
  474. productionClass:'',
  475. priority:'',
  476. supplierId:'',
  477. supplierName:'',
  478. headModel:'',
  479. englishName:'',
  480. productCode:'',
  481. childModel:'',
  482. billDate_begin:'',
  483. billDate_end:'',
  484. saleDepartment:'',
  485. salesman:'',
  486. customer:'',
  487. customerName:''
  488. }
  489. pagination.value.current =1;
  490. pagination.value.pageSize = 10;
  491. }
  492. function getTable(formData,data){
  493. visible.value = true
  494. if(formData.projectName&&formData.projectName!==''){
  495. fatherProject.value = formData.project
  496. }else{
  497. fatherProject.value = ''
  498. }
  499. if(formData.sourceCode&&formData.sourceCode!==''){
  500. fatherSourceCode.value = formData.sourceCode2
  501. }else{
  502. fatherSourceCode.value = ''
  503. }
  504. if(formData.sourceCode&&formData.sourceCode!==''){
  505. fatherSourceCode.value = formData.sourceCode2
  506. }else{
  507. fatherSourceCode.value = ''
  508. }
  509. fatherType.value='other'
  510. if(data=='delivery'){
  511. showCustomer.value = 'yes'
  512. columns= columns1.filter(function(value, i) {
  513. return i !== 3;
  514. });
  515. if(formData.supplierName&&formData.supplierName!==''){
  516. fatherCustomerName.value = formData.supplierName
  517. }else{
  518. fatherCustomerName.value = ''
  519. }
  520. }else{
  521. showCustomer.value = 'no'
  522. columns= columns1.filter(function(value, i) {
  523. return i !== 4;
  524. });
  525. if(formData.supplierName&&formData.supplierName!==''){
  526. fatherSupplierName.value = formData.supplierName
  527. }else{
  528. fatherSupplierName.value = ''
  529. }
  530. }
  531. loadData()
  532. }
  533. function getTableFromSalePayRequestForm(){
  534. visible.value = true
  535. fatherProject.value = ''
  536. fatherSourceCode.value = ''
  537. fatherType.value='payRequest'
  538. showCustomer.value = 'no'
  539. columns= columns1.filter(function(value, i) {
  540. return i !== 4;
  541. });
  542. loadData()
  543. }
  544. function changeBillDate(prop){
  545. if(prop){
  546. billDate.value = prop
  547. queryParams.value.billDate_begin = prop[0]
  548. queryParams.value.billDate_end = prop[1]
  549. }else{
  550. billDate.value = []
  551. queryParams.value.billDate_begin = ''
  552. queryParams.value.billDate_end = ''
  553. }
  554. }
  555. defineExpose({
  556. getTable,
  557. getTableFromSalePayRequestForm
  558. });
  559. </script>
  560. <style scoped lang="less">
  561. /deep/.ant-form-item{
  562. margin-bottom: 8px !important;
  563. }
  564. // /deep/.ant-table-wrapper .ant-table-thead > tr > th, .ant-table-wrapper .ant-table-thead > tr > td{
  565. // padding: 8px !important;
  566. // }
  567. /deep/.tableHiddle {
  568. display: none;
  569. }
  570. /deep/.tableShow{
  571. display: revert;
  572. }
  573. </style>