detailSelect.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  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. // console.log(111);
  309. // const { data } = await getWarehouseList();
  310. // this.warehouseList = data;
  311. },
  312. handleCurrentChange(val) {
  313. this.formData.pageNum = val;
  314. this.handleList();
  315. },
  316. handleSizeChange(val) {
  317. // this.formData.pageNum = 1;
  318. this.formData.size = val;
  319. this.handleList();
  320. },
  321. selecctedRow(val) {
  322. console.log(val);
  323. this.$emit('mxArgs', val);
  324. this.memo = val;
  325. },
  326. open(infoData, memo = []) {
  327. this.visible = true;
  328. this.batchVisible = false;
  329. this.infoData = infoData;
  330. this.tableData = [];
  331. // console.log('wqwq', this.infoData.assetCode);
  332. this.formData = { pageNum: 1, size: 10, type: infoData.type };
  333. if (this.infoData.bizTypes == 3) {
  334. // this.formData.code = this.infoData.assetCode;
  335. this.$set(this.formData, 'code', this.infoData.assetCode);
  336. }
  337. this.formData.dateType = 2;
  338. this.memo1 = memo || [];
  339. this.multipleNum = this.memo.length;
  340. this.handleList(true);
  341. return new Promise((res) => (this.confirmResolve = res));
  342. },
  343. cancel() {
  344. this.tableData = [];
  345. this.memo = [];
  346. this.memo1 = [];
  347. this.visible = false;
  348. },
  349. confirm() {
  350. if (!this.selectedNum) {
  351. return this.$message.error('请勾选数据');
  352. }
  353. this.confirmResolve && this.confirmResolve(this.memo);
  354. this.cancel();
  355. },
  356. openBatch() {
  357. this.multipleNum = 0;
  358. this.batchVisible = true;
  359. },
  360. multiConfirm() {
  361. if (!this.multipleNum) {
  362. return this.$message.error('请输入大于0的数量');
  363. }
  364. this.batchVisible = false;
  365. const selectedList = this.tableData.filter((i) => i.checked);
  366. if (selectedList.length === this.multipleNum) return;
  367. if (selectedList.length >= this.multipleNum) {
  368. for (
  369. let index = this.multipleNum;
  370. index < selectedList.length;
  371. index++
  372. ) {
  373. selectedList[index].checked = false;
  374. this.singleSelect(false, selectedList[index]);
  375. }
  376. } else {
  377. let rest = this.multipleNum - selectedList.length;
  378. for (const p of this.tableData) {
  379. if (!p.checked) {
  380. p.checked = true;
  381. this.memo.push(p);
  382. rest--;
  383. }
  384. if (!rest) break;
  385. }
  386. }
  387. // this.tableData.forEach((item, index) => {
  388. // item.checked = index < this.multipleNum
  389. // if (item.checked) {
  390. // this.memo.push(item)
  391. // }
  392. // })
  393. },
  394. reset() {
  395. this.formData = {};
  396. this.handleList();
  397. },
  398. singleSelect(checked, row) {
  399. // 取消选中
  400. if (!checked) {
  401. let index = this.memo.findIndex(
  402. (item) => item.onlyCode === row.onlyCode
  403. );
  404. if (index > -1) {
  405. this.memo.splice(index, 1);
  406. }
  407. } else {
  408. this.memo.push(row);
  409. }
  410. },
  411. // 表格数据
  412. async handleList(val) {
  413. console.log(this.infoData);
  414. console.log('sasa', this.formData);
  415. if (this.formData.dateType == 1) {
  416. this.formData.manufactureTime = this.formData.productTime;
  417. } else {
  418. this.formData.procurementTime = this.formData.productTime;
  419. }
  420. // if (!this.infoData.id) {
  421. // this.$message.warning('数据异常,当前物品id为空!');
  422. // return;
  423. // }
  424. const res = await outin.getoutDetail({
  425. ...this.formData,
  426. categoryId: this.infoData.id
  427. });
  428. console.log('11', res);
  429. this.tableData = res.data.list;
  430. this.total = res.data.count;
  431. if (res.data.list.length > 0 && res.data.list[0].brandNum) {
  432. this.infoData.brandNum = res.data.list[0].brandNum;
  433. }
  434. if (val) {
  435. this.changeSelect();
  436. }
  437. },
  438. changeSelect() {
  439. this.$nextTick(() => {
  440. this.tableData.forEach((item) => {
  441. const index = this.memo1.findIndex(
  442. (i) => item.sourceBizNo == i.sourceBizNo
  443. );
  444. if (index > -1) {
  445. this.$refs.tableRef.toggleRowSelection(item, true);
  446. }
  447. });
  448. });
  449. }
  450. }
  451. };
  452. </script>
  453. <style lang="scss" scoped>
  454. .info-box {
  455. display: flex;
  456. justify-content: space-between;
  457. align-items: center;
  458. font-size: 14px;
  459. padding: 20px 0 5px;
  460. ul {
  461. list-style: none;
  462. display: flex;
  463. justify-content: space-between;
  464. align-items: center;
  465. li {
  466. margin-right: 40px;
  467. }
  468. span {
  469. font-weight: bold;
  470. margin-right: 10px;
  471. }
  472. }
  473. .result-box {
  474. margin: 0 20px;
  475. display: flex;
  476. justify-content: space-between;
  477. align-items: center;
  478. white-space: nowrap;
  479. .el-input {
  480. width: 100px;
  481. margin: 0 10px;
  482. }
  483. .select-box {
  484. margin-left: 20px;
  485. .el-input-number {
  486. width: 80px;
  487. }
  488. }
  489. .el-button {
  490. font-size: 16px;
  491. }
  492. }
  493. }
  494. .footer {
  495. display: flex;
  496. justify-content: space-between;
  497. .info {
  498. display: flex;
  499. span {
  500. font-weight: bold;
  501. margin-right: 10px;
  502. }
  503. > div {
  504. margin-right: 20px;
  505. }
  506. }
  507. }
  508. </style>