detailSelect.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. <template>
  2. <el-dialog :visible.sync="visible" title="选择出库明细" width="90vw">
  3. <el-form :model="formData" label-width="120px">
  4. <el-row>
  5. <!-- <el-col :span="6">
  6. <el-form-item label="仓库:" prop="warehouseId">
  7. <el-select
  8. style="width: 100%"
  9. clearable
  10. v-model="formData.warehouseId"
  11. placeholder="请选择"
  12. >
  13. <el-option
  14. v-for="item in warehouseList"
  15. :label="item.name"
  16. :value="item.id"
  17. :key="item.id"
  18. >
  19. </el-option>
  20. </el-select>
  21. </el-form-item>
  22. </el-col> -->
  23. <el-col :span="6">
  24. <el-form-item label="物品编码" prop="code">
  25. <el-input
  26. v-model.trim="formData.code"
  27. placeholder="请输入"
  28. ></el-input>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :span="6">
  32. <el-form-item label="物品名称" prop="name">
  33. <el-input
  34. v-model.trim="formData.name"
  35. placeholder="请输入"
  36. ></el-input>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="6">
  40. <el-form-item label="货位" prop="goodsAllocation">
  41. <el-input
  42. v-model.trim="formData.goodsAllocation"
  43. placeholder="请输入"
  44. ></el-input>
  45. </el-form-item>
  46. </el-col>
  47. <el-col :span="6">
  48. <el-form-item :label="`${title}编码`" prop="sourceBizNo">
  49. <el-input
  50. v-model.trim="formData.sourceBizNo"
  51. placeholder="请输入"
  52. ></el-input>
  53. </el-form-item>
  54. </el-col>
  55. <el-col :span="6">
  56. <el-form-item label="批次号" prop="batchNo">
  57. <el-input
  58. v-model.trim="formData.batchNo"
  59. placeholder="请输入"
  60. ></el-input>
  61. </el-form-item>
  62. </el-col>
  63. <el-col :span="6">
  64. <el-form-item label="包装编码" prop="packageNo">
  65. <el-input
  66. v-model.trim="formData.packageNo"
  67. placeholder="请输入"
  68. ></el-input>
  69. </el-form-item>
  70. </el-col>
  71. <el-col :span="6">
  72. <el-form-item label="时间类型">
  73. <el-select
  74. style="width: 100%"
  75. v-model="formData.dateType"
  76. placeholder=""
  77. @change="$forceUpdate()"
  78. >
  79. <el-option label="生产日期" :value="2"> </el-option>
  80. <el-option label="采购日期" :value="1"> </el-option>
  81. </el-select>
  82. </el-form-item>
  83. </el-col>
  84. <el-col :span="6">
  85. <el-form-item label="时间" prop="productTime">
  86. <el-date-picker
  87. v-model="formData.productTime"
  88. type="daterange"
  89. style="width: 100%"
  90. value-format="yyyy-MM-dd"
  91. range-separator="至"
  92. start-placeholder="开始日期"
  93. end-placeholder="结束日期"
  94. placeholder="选择日期"
  95. >
  96. </el-date-picker>
  97. </el-form-item>
  98. </el-col>
  99. <el-col style="text-align: right">
  100. <el-button @click="reset" icon="el-icon-refresh-left" size="small"
  101. >重置</el-button
  102. >
  103. <el-button
  104. type="primary"
  105. @click="handleList"
  106. icon="el-icon-search"
  107. size="small"
  108. >搜索</el-button
  109. >
  110. </el-col>
  111. </el-row>
  112. </el-form>
  113. <div class="info-box">
  114. <ul>
  115. <li><span>物品编码</span>{{ infoData.code }}</li>
  116. <li><span>物品名称</span>{{ infoData.name }}</li>
  117. <li v-for="(item, index) in tableHeader" :key="index">
  118. <span>{{ item.label }}</span>
  119. <template v-if="item.formatter">{{
  120. item.formatter(infoData)
  121. }}</template>
  122. <template v-else>{{ infoData[item.prop] }}</template>
  123. </li>
  124. <li v-if="infoData.sparePartsNum">
  125. <span>申领数量</span>{{ infoData.sparePartsNum }}
  126. </li>
  127. </ul>
  128. <div class="result-box">
  129. <!-- takeStockPattern0,逐个出库,1,批量出库 -->
  130. <div class="select-box"><span>已选数量</span> {{ selectedNum }}条</div>
  131. <div v-if="infoData.takeStockPattern === 1" class="select-box">
  132. <!-- 选择数量<el-input-number
  133. size="mini"
  134. :controls="false"
  135. v-model="multipleNum"
  136. :max="tableData.length"
  137. >
  138. </el-input-number
  139. >条 -->
  140. <el-button type="text" @click="openBatch">批量出库</el-button>
  141. </div>
  142. </div>
  143. </div>
  144. <el-table
  145. height="60vh"
  146. ref="tableRef"
  147. :data="tableData"
  148. @selection-change="selecctedRow"
  149. style="width: 100%"
  150. :header-cell-style="{ background: '#EEEEEE', border: 'none' }"
  151. >
  152. <el-table-column label="序号" type="index"></el-table-column>
  153. <el-table-column
  154. label="货位"
  155. prop="pathName"
  156. show-overflow-tooltip
  157. width="270"
  158. >
  159. </el-table-column>
  160. <el-table-column
  161. :label="`${title}编码`"
  162. prop="sourceBizNo"
  163. ></el-table-column>
  164. <el-table-column label="物品编码" prop="code"> </el-table-column>
  165. <el-table-column label="物品名称" prop="name"> </el-table-column>
  166. <el-table-column label="批次号" prop="batchNum"> </el-table-column>
  167. <el-table-column
  168. label="生产日期"
  169. width="180"
  170. v-if="formData.dateType == 2"
  171. >
  172. <template slot-scope="{ row }">
  173. <span>
  174. {{ row.produceTime }}
  175. </span>
  176. </template>
  177. </el-table-column>
  178. <el-table-column
  179. label="采购日期"
  180. width="180"
  181. v-if="formData.dateType == 1"
  182. >
  183. <template slot-scope="{ row }">
  184. <span>
  185. {{ row.procureTime }}
  186. </span>
  187. </template>
  188. </el-table-column>
  189. <el-table-column
  190. label="最小包装单元"
  191. prop=""
  192. align="center"
  193. v-if="!infoData.isUnpack"
  194. >
  195. <template slot-scope="{ row }">
  196. {{ row.measurementUnit }}{{ row.unit }}/{{ row.minUnit }}
  197. </template>
  198. </el-table-column>
  199. <el-table-column label="包装编码" prop="packageNo"></el-table-column>
  200. <el-table-column label="入库时间" prop="createTime"></el-table-column>
  201. <el-table-column width="50" type="selection"></el-table-column>
  202. </el-table>
  203. <div style="text-align: right; padding: 10px">
  204. <el-pagination
  205. background
  206. layout="total, sizes, prev, pager, next, jumper"
  207. :total="total"
  208. :page-sizes="[5, 10, 20, 50]"
  209. :page-size.sync="formData.size"
  210. :current-page.sync="formData.pageNum"
  211. @current-change="handleCurrentChange"
  212. @size-change="handleSizeChange"
  213. >
  214. </el-pagination>
  215. </div>
  216. <div slot="footer" class="footer">
  217. <div class="info">
  218. <div><span>总库存量</span>{{ infoData.availableCountBase }}</div>
  219. <!-- <div><span>总包装数量</span>{{ infoData.realPacketNum }}</div> -->
  220. </div>
  221. <div>
  222. <el-button @click="cancel">取消</el-button>
  223. <el-button type="primary" @click="confirm">确定</el-button>
  224. </div>
  225. </div>
  226. <el-dialog
  227. :visible.sync="batchVisible"
  228. title="批量选择"
  229. width="300px"
  230. append-to-body
  231. >
  232. <div style="text-align: center">
  233. <el-input-number
  234. size="small"
  235. v-model="multipleNum"
  236. :max="tableData.length"
  237. >
  238. </el-input-number>
  239. </div>
  240. <div slot="footer">
  241. <el-button size="small" @click="batchVisible = false">取消</el-button>
  242. <el-button size="small" type="primary" @click="multiConfirm"
  243. >确认</el-button
  244. >
  245. </div>
  246. </el-dialog>
  247. </el-dialog>
  248. </template>
  249. <script>
  250. // import { getWarehouseActualDetail } from '@/api/stockManagement/stockLedger.js'
  251. import outin from '@/api/warehouseManagement/outin';
  252. import { getWarehouseList } from '@/api/classifyManage/itemInformation';
  253. export default {
  254. props: {
  255. tableHeader: {
  256. type: Array,
  257. default: () => []
  258. },
  259. title: {
  260. type: String,
  261. default: ''
  262. }
  263. },
  264. data() {
  265. return {
  266. visible: false,
  267. batchVisible: false,
  268. multipleNum: '',
  269. confirmResolve: null,
  270. tableData: [],
  271. selectList: [],
  272. formData: {
  273. cargoSpaceCode: '',
  274. time: '',
  275. dateType: 2,
  276. batchNo: '',
  277. packageNo: '',
  278. onlyCode: '',
  279. pageNum: 1,
  280. size: 10
  281. },
  282. infoData: {},
  283. memo: [],
  284. memo1: [],
  285. total: 0,
  286. warehouseList: []
  287. };
  288. },
  289. computed: {
  290. selectedNum() {
  291. return this.memo.length;
  292. },
  293. checkedAll: {
  294. get() {
  295. return this.tableData.every((item) => item.checked);
  296. },
  297. set(val) {
  298. this.tableData.forEach((item) => (item.checked = val));
  299. }
  300. }
  301. },
  302. created() {
  303. this.getArguInfo();
  304. },
  305. methods: {
  306. //搜索数据源
  307. async getArguInfo() {
  308. const { data } = await getWarehouseList();
  309. this.warehouseList = data;
  310. },
  311. handleCurrentChange() {
  312. this.handleList();
  313. },
  314. handleSizeChange() {
  315. this.formData.pageNum = 1;
  316. this.handleList();
  317. },
  318. selecctedRow(val) {
  319. console.log(val);
  320. this.$emit('mxArgs', val);
  321. this.memo = val;
  322. },
  323. open(infoData, memo = []) {
  324. this.visible = true;
  325. this.batchVisible = false;
  326. this.infoData = infoData;
  327. this.tableData = [];
  328. this.formData = {};
  329. this.formData.dateType = 2;
  330. this.memo1 = memo || [];
  331. this.multipleNum = this.memo.length;
  332. this.handleList(true);
  333. return new Promise((res) => (this.confirmResolve = res));
  334. },
  335. cancel() {
  336. this.tableData = [];
  337. this.memo = [];
  338. this.memo1 = [];
  339. this.visible = false;
  340. },
  341. confirm() {
  342. if (!this.selectedNum) {
  343. return this.$message.error('请勾选数据');
  344. }
  345. this.confirmResolve && this.confirmResolve(this.memo);
  346. this.cancel();
  347. },
  348. openBatch() {
  349. this.multipleNum = 0;
  350. this.batchVisible = true;
  351. },
  352. multiConfirm() {
  353. if (!this.multipleNum) {
  354. return this.$message.error('请输入大于0的数量');
  355. }
  356. this.batchVisible = false;
  357. const selectedList = this.tableData.filter((i) => i.checked);
  358. if (selectedList.length === this.multipleNum) return;
  359. if (selectedList.length >= this.multipleNum) {
  360. for (
  361. let index = this.multipleNum;
  362. index < selectedList.length;
  363. index++
  364. ) {
  365. selectedList[index].checked = false;
  366. this.singleSelect(false, selectedList[index]);
  367. }
  368. } else {
  369. let rest = this.multipleNum - selectedList.length;
  370. for (const p of this.tableData) {
  371. if (!p.checked) {
  372. p.checked = true;
  373. this.memo.push(p);
  374. rest--;
  375. }
  376. if (!rest) break;
  377. }
  378. }
  379. // this.tableData.forEach((item, index) => {
  380. // item.checked = index < this.multipleNum
  381. // if (item.checked) {
  382. // this.memo.push(item)
  383. // }
  384. // })
  385. },
  386. reset() {
  387. this.formData = {};
  388. this.handleList();
  389. },
  390. singleSelect(checked, row) {
  391. // 取消选中
  392. if (!checked) {
  393. let index = this.memo.findIndex(
  394. (item) => item.onlyCode === row.onlyCode
  395. );
  396. if (index > -1) {
  397. this.memo.splice(index, 1);
  398. }
  399. } else {
  400. this.memo.push(row);
  401. }
  402. },
  403. // 表格数据
  404. async handleList(val) {
  405. console.log(this.infoData);
  406. console.log('sasa', this.formData);
  407. if (this.formData.dateType == 1) {
  408. this.formData.manufactureTime = this.formData.productTime;
  409. } else {
  410. this.formData.procurementTime = this.formData.productTime;
  411. }
  412. const res = await outin.getoutDetail({
  413. ...this.formData,
  414. categoryId: this.infoData.id
  415. });
  416. console.log('11', res);
  417. this.tableData = res.data.list;
  418. this.total = res.data.count;
  419. if (res.data.list.length > 0 && res.data.list[0].brandNum) {
  420. this.infoData.brandNum = res.data.list[0].brandNum;
  421. }
  422. if (val) {
  423. this.changeSelect();
  424. }
  425. },
  426. changeSelect() {
  427. this.$nextTick(() => {
  428. this.tableData.forEach((item) => {
  429. const index = this.memo1.findIndex(
  430. (i) => item.sourceBizNo == i.sourceBizNo
  431. );
  432. if (index > -1) {
  433. this.$refs.tableRef.toggleRowSelection(item, true);
  434. }
  435. });
  436. });
  437. }
  438. }
  439. };
  440. </script>
  441. <style lang="scss" scoped>
  442. .info-box {
  443. display: flex;
  444. justify-content: space-between;
  445. align-items: center;
  446. font-size: 14px;
  447. padding: 20px 0 5px;
  448. ul {
  449. list-style: none;
  450. display: flex;
  451. justify-content: space-between;
  452. align-items: center;
  453. li {
  454. margin-right: 40px;
  455. }
  456. span {
  457. font-weight: bold;
  458. margin-right: 10px;
  459. }
  460. }
  461. .result-box {
  462. margin: 0 20px;
  463. display: flex;
  464. justify-content: space-between;
  465. align-items: center;
  466. white-space: nowrap;
  467. .el-input {
  468. width: 100px;
  469. margin: 0 10px;
  470. }
  471. .select-box {
  472. margin-left: 20px;
  473. .el-input-number {
  474. width: 80px;
  475. }
  476. }
  477. .el-button {
  478. font-size: 16px;
  479. }
  480. }
  481. }
  482. .footer {
  483. display: flex;
  484. justify-content: space-between;
  485. .info {
  486. display: flex;
  487. span {
  488. font-weight: bold;
  489. margin-right: 10px;
  490. }
  491. > div {
  492. margin-right: 20px;
  493. }
  494. }
  495. }
  496. </style>