SelectStaningStockModal.vue 17 KB

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