selectArrivalList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. <template>
  2. <a-modal
  3. title="选择到货单(Select arrival 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="{ style: 'width: 200px' }" @keyup.enter.native="searchQuery">
  14. <a-row :gutter="24">
  15. <a-col :md="6" :sm="8">
  16. <a-form-item label="到货单号(bill code)">
  17. <j-input placeholder="请输入" v-model:value="queryParams.billCode"></j-input>
  18. </a-form-item>
  19. </a-col>
  20. <a-col :md="6" :sm="8">
  21. <a-form-item label="到货日期(arrival date)">
  22. <a-range-picker value-format="YYYY-MM-DD" v-model:value="arrivalDate" @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="code"
  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)">
  43. <ApiSelect
  44. :api="ClassList"
  45. showSearch
  46. v-model:value="queryParams.productionClass"
  47. optionFilterProp="label"
  48. resultField="records"
  49. labelField="name"
  50. valueField="id"
  51. :params='{pageSize:-1}'
  52. />
  53. </a-form-item>
  54. </a-col>
  55. <a-col :md="12" :sm="16">
  56. <a-form-item label="供应商(supplier)">
  57. <JSelect v-model:value="queryParams.supplier" :get-option-url="supplierOption" :showField="showField"></JSelect>
  58. </a-form-item>
  59. </a-col>
  60. <a-col :md="6" :sm="8">
  61. <a-form-item label="优先级(priority)" >
  62. <JDictSelectTag v-model:value="queryParams.priority" placeholder="请选择" dictCode="priority" style="width: 100%;"/>
  63. </a-form-item>
  64. </a-col>
  65. <a-col :md="6" :sm="8">
  66. <a-form-item label="机型(model)">
  67. <JDictSelectTag v-model:value="queryParams.model" placeholder="请选择" dictCode="model_typer"/>
  68. </a-form-item>
  69. </a-col>
  70. <a-col :md="6" :sm="8">
  71. <a-form-item label="产品编码(product code)">
  72. <j-input placeholder="请输入" v-model:value="queryParams.productCode"></j-input>
  73. </a-form-item>
  74. </a-col>
  75. </template>
  76. <a-col :md="6" :sm="8">
  77. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  78. <a-button type="primary" @click="searchQuery" >查询(search)</a-button>
  79. <a-button type="primary" @click="searchReset" style="margin-left: 8px">重置(reset)</a-button>
  80. <a @click="handleToggleSearch" style="margin-left: 8px">
  81. {{ toggleSearchStatus ? '收起' : '展开' }}
  82. <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
  83. </a>
  84. </span>
  85. </a-col>
  86. </a-row>
  87. </a-form>
  88. </div>
  89. </a-card>
  90. <a-card :body-style="{ padding: '10px' }" :bordered="false" style="margin: 10px;">
  91. <a-alert type="info" show-icon class="alert" style="margin-bottom: 8px">
  92. <template #message>
  93. <template v-if="selectedRowKeys.length > 0">
  94. <span>已选中 {{ selectedRowKeys.length }} 条记录</span>
  95. <a-divider type="vertical" />
  96. <a @click="selectedRowKeys = []">清空</a>
  97. </template>
  98. <template v-else>
  99. <span>未选中任何数据</span>
  100. </template>
  101. </template>
  102. </a-alert>
  103. <a-table
  104. :columns="columns"
  105. :row-key="record => record.childId"
  106. :data-source="dataSource"
  107. bordered
  108. size="small"
  109. @change="handleTableChange"
  110. :pagination="pagination"
  111. :scroll="{ x: 3200, y: 400 }"
  112. :rowSelection="{onSelect: onSelect, onSelectAll: onSelectAll, selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
  113. >
  114. </a-table>
  115. </a-card>
  116. </div>
  117. </a-modal>
  118. </template>
  119. <script lang="ts" setup>
  120. import {ref, reactive } from 'vue';
  121. import { defHttp} from '/@/utils/http/axios';
  122. import { message } from 'ant-design-vue';
  123. import { filterObj} from '/@/utils/common/compUtils';
  124. import { JDictSelectTag,ApiSelect,JInput,JSelect} from '/@/components/Form';
  125. const emit = defineEmits([ 'selectArrrivalOrder']); //定义emit
  126. import {supplierOption,ProjectOption,ClassList} from '../inventiry/purchaseIn/purchaseInForm.api';
  127. var visible = ref(false)
  128. var fatherProject = ref('')
  129. var fatherSourceCode = ref('')
  130. var showField = ref('currency_dictText+name');
  131. const columns = [
  132. {
  133. type: 'selection',
  134. fixed: 'left',
  135. width:0
  136. },
  137. {
  138. title: '到货单号(bill code)',
  139. dataIndex: 'billCode',
  140. key: 'billCode',
  141. align:"center",
  142. width:250,
  143. },
  144. {
  145. title: '到货日期(arrival date)',
  146. dataIndex: 'arrivalDate',
  147. key: 'arrivalDate',
  148. align:"center"
  149. },
  150. {
  151. title: '项目(project)',
  152. dataIndex: 'projectName',
  153. key: 'projectName',
  154. align:"center",
  155. width:250,
  156. },
  157. {
  158. title: '供应商(supplier)',
  159. dataIndex: 'supplierName',
  160. key: 'supplierName',
  161. align:"center"
  162. },
  163. {
  164. title: '优先级(priority)',
  165. dataIndex: 'priority_dictText',
  166. key: 'priority_dictText',
  167. align:"center"
  168. },
  169. {
  170. title: '产品分类(production class)',
  171. dataIndex: 'productionClass_dictText',
  172. key: 'productionClass_dictText',
  173. align:"center",
  174. width:250,
  175. },
  176. {
  177. title: '机型(model)',
  178. dataIndex: 'model',
  179. key: 'model',
  180. align:"center"
  181. },
  182. {
  183. title: '采购部门(puechase department)',
  184. dataIndex: 'purchaseDepartment',
  185. key: 'purchaseDepartment',
  186. align:"center"
  187. },
  188. {
  189. title: '采购员(puechaseman)',
  190. dataIndex: 'purchaseman',
  191. key: 'purchaseman',
  192. align:"center"
  193. },
  194. {
  195. title: '产品英文名(English name)',
  196. key: 'englishName',
  197. dataIndex: 'englishName',
  198. align:"center",
  199. width:250,
  200. },
  201. {
  202. title: '型号(childModel)',
  203. key: 'childModel',
  204. dataIndex: 'childModel',
  205. align:"center"
  206. },
  207. {
  208. title: '厂家(factory)',
  209. key: 'factory',
  210. dataIndex: 'factory',
  211. align:"center",
  212. width:250
  213. },
  214. {
  215. title: '质量等级(quantity grade)',
  216. key: 'qualityGrade',
  217. dataIndex: 'qualityGrade',
  218. align:"center",
  219. width:250,
  220. },
  221. ];
  222. const labelCol = ref({
  223. xs: { span: 24 },
  224. sm: { span: 9 },
  225. });
  226. const wrapperCol = ref({
  227. xs: { span: 24 },
  228. sm: { span: 15 },
  229. });
  230. const labelCol1 = ref({
  231. xs: { span: 24 },
  232. sm: { span: 10 },
  233. });
  234. const wrapperCol1 = ref({
  235. xs: { span: 24 },
  236. sm: { span: 14 },
  237. });
  238. const dataSource =ref([]);
  239. let selectedRowKeys = ref([]);
  240. let selectionRows = ref([]);
  241. const toggleSearchStatus = ref(false);
  242. var arrivalDate = ref([])
  243. const queryParams = ref({
  244. billCode:'',
  245. project:'',
  246. projectName:'',
  247. productionClass:'',
  248. priority:'',
  249. supplier:'',
  250. supplierName:'',
  251. model:'',
  252. productCode:'',
  253. arrivalDate_begin:'',
  254. arrivalDate_end:'',
  255. });
  256. let pagination = ref({
  257. current: 1,
  258. pageSize: 10,
  259. total: '', // 假设总共有100条数据
  260. showSizeChanger: true,
  261. showQuickJumper: true,
  262. showTotal: (total, range) => {
  263. return range[0] + "-" + range[1] + " 共" + total + "条"
  264. },
  265. size:'small'
  266. });
  267. function loadData(){
  268. let params = getQueryParams();
  269. defHttp.get({ url: '/purCode/purDeliveryNote/purDeliveryNoteArrivalAlert',params}, { isTransformResponse: false })
  270. .then((res) => {
  271. if (res.success) {
  272. dataSource.value = res.result.records;
  273. pagination.value.total = res.result.total;
  274. pagination.value.current = res.result.current;
  275. pagination.value.pageSize = res.result.size;
  276. } else {
  277. message.error(res.message);
  278. }
  279. })
  280. .finally(() => {
  281. // loading.value = false;
  282. });
  283. }
  284. function getQueryParams(){
  285. let params = Object.assign(queryParams.value);
  286. params.pageNo = pagination.value.current;
  287. params.pageSize = pagination.value.pageSize;
  288. if(fatherProject.value&&fatherProject.value!==''){
  289. queryParams.value.project = fatherProject.value
  290. }else {
  291. queryParams.value.project = params.project
  292. }
  293. return filterObj(params);
  294. }
  295. function handleTableChange(paginations, filters, sorter){
  296. pagination.value.total = paginations.total;
  297. pagination.value.current = paginations.current;
  298. pagination.value.pageSize = paginations.pageSize;
  299. loadData()
  300. };
  301. function searchQuery(){
  302. pagination.value.current =1;
  303. selectedRowKeys.value = []
  304. selectionRows.value=[]
  305. loadData();
  306. }
  307. function searchReset(){
  308. arrivalDate.value = []
  309. queryParams.value = {
  310. billCode:'',
  311. project:'',
  312. projectName:'',
  313. productionClass:'',
  314. priority:'',
  315. supplier:'',
  316. supplierName:'',
  317. model:'',
  318. productCode:'',
  319. arrivalDate_begin:'',
  320. arrivalDate_end:'',
  321. }
  322. pagination.value.current =1;
  323. pagination.value.pageSize = 10;
  324. selectedRowKeys.value = []
  325. selectionRows.value=[]
  326. loadData();
  327. }
  328. function handleToggleSearch(){
  329. toggleSearchStatus.value = !toggleSearchStatus.value;
  330. }
  331. function onSelectChange(selectedRowKeys1, selectionRows1) {
  332. var arr = []
  333. selectionRows.value.map(item=>{
  334. arr.push(item.childId)
  335. })
  336. selectedRowKeys.value = arr
  337. }
  338. function onSelect(record, selected, selectionRows1, nativeEvent) {
  339. if (selected) {
  340. selectionRows.value.push(record)
  341. console.log( selectionRows.value);
  342. }else{
  343. const delIndex = selectionRows.value.findIndex((val) => {
  344. return val.childId === record.childId
  345. })
  346. selectionRows.value.splice(delIndex, 1)
  347. }
  348. }
  349. function onSelectAll(selected, selectionRows1, changeRows) {
  350. if (selected) {
  351. selectionRows.value = selectionRows.value.concat(changeRows)
  352. }
  353. if (!selected) {
  354. let selectionRows2 = JSON.parse(JSON.stringify(selectionRows.value))
  355. const delIndex = []
  356. selectionRows2.forEach((item, index) => {
  357. changeRows.forEach((val, itemIndex) => {
  358. if (item.childId === val.childId) {
  359. delIndex.push(index)
  360. }
  361. })
  362. })
  363. delIndex.forEach((item) => {
  364. delete selectionRows2[item]
  365. })
  366. selectionRows2 = selectionRows2.filter((item) => {
  367. return item !== undefined
  368. })
  369. selectionRows.value = selectionRows2
  370. }
  371. }
  372. function handleOk(){
  373. var arr = []
  374. selectionRows.value.map(item=>arr.push(item.billCode))
  375. if(fatherSourceCode.value&&fatherSourceCode.value!==''){
  376. arr.push(fatherSourceCode.value)
  377. }
  378. if(selectedRowKeys.value.length==0){
  379. message.error('请勾选数据');
  380. }else if(new Set(arr).size!==1){
  381. message.error('请勾选到货单号相同的数据');
  382. }else{
  383. emit('selectArrrivalOrder', selectionRows.value)
  384. handleCancel()
  385. }
  386. }
  387. function handleCancel(){
  388. visible.value = false
  389. selectedRowKeys.value = []
  390. selectionRows.value=[]
  391. queryParams.value = {
  392. billCode:'',
  393. project:'',
  394. projectName:'',
  395. productionClass:'',
  396. priority:'',
  397. supplier:'',
  398. supplierName:'',
  399. model:'',
  400. productCode:'',
  401. arrivalDate_begin:'',
  402. arrivalDate_end:'',
  403. }
  404. pagination.value.current =1;
  405. pagination.value.pageSize = 10;
  406. }
  407. function getTable(formData){
  408. visible.value = true
  409. if(formData.projectName&&formData.projectName!==''){
  410. fatherProject.value = formData.project
  411. }else{
  412. fatherProject.value = ''
  413. }
  414. if(formData.sourceCode&&formData.sourceCode!==''){
  415. fatherSourceCode.value = formData.sourceCode
  416. }else{
  417. fatherSourceCode.value = ''
  418. }
  419. loadData()
  420. }
  421. function changeBillDate(prop){
  422. if(prop){
  423. arrivalDate.value = prop
  424. queryParams.value.arrivalDate_begin = prop[0]
  425. queryParams.value.arrivalDate_end = prop[1]
  426. }else{
  427. arrivalDate.value = []
  428. queryParams.value.arrivalDate_begin = ''
  429. queryParams.value.arrivalDate_end = ''
  430. }
  431. }
  432. defineExpose({
  433. getTable
  434. });
  435. </script>
  436. <style scoped lang="less">
  437. /deep/.ant-form-item{
  438. margin-bottom: 8px !important;
  439. }
  440. // /deep/.ant-table-wrapper .ant-table-thead > tr > th, .ant-table-wrapper .ant-table-thead > tr > td{
  441. // padding: 8px !important;
  442. // }
  443. </style>