SelectStaningStockModal.vue 16 KB

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