addInventory.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. <template>
  2. <div class="bg-in-stock">
  3. <el-form ref="goodsExchangeAddFormRef" :model="goodsExchangeAddForm" :rules="goodsExchangeAddFormRule" label-width="160px" inline class="change-form">
  4. <el-form-item
  5. label="订单编号:"
  6. prop="order_id"
  7. class="change-form-item"
  8. v-if="goodsExchangeAddForm.sn && (goodsExchangeAddForm.type == 'SALE_AFTER' || goodsExchangeAddForm.type == 'HAIL_ENTRY')"
  9. >
  10. {{ goodsExchangeAddForm.sn }}
  11. </el-form-item>
  12. <el-form-item prop="warehouse_id" label="入库仓库:" class="change-form-item">
  13. <el-select v-model="goodsExchangeAddForm.warehouse_id" clearable :disabled="type === 'view'">
  14. <el-option v-for="item in warehouseList" :key="item.id" :label="item.name" :value="item.id" />
  15. </el-select>
  16. </el-form-item>
  17. <el-form-item label="类型:" prop="type" class="change-form-item">
  18. <el-select
  19. v-model="goodsExchangeAddForm.type"
  20. filterable
  21. allow-create
  22. clearable
  23. default-first-option
  24. :disabled="type === 'view' || orderType || goodsExchangeAddForm.type == 'SALE_AFTER' || goodsExchangeAddForm.type == 'HAIL_ENTRY'"
  25. >
  26. <el-option
  27. v-for="item in typeList"
  28. :key="item.id"
  29. :label="item.label"
  30. :value="item.value"
  31. :disabled="item.value == 'TRANSFER_ENTRY' || item.value == 'HAIL_ENTRY' || item.value == 'SALE_AFTER'"
  32. />
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item label="备注:" prop="change_desc" class="change-form-item" style="width: 61%">
  36. <el-input
  37. style="flex: 1"
  38. v-model="goodsExchangeAddForm.memo"
  39. type="textarea"
  40. :disabled="type === 'view' || type === 'audit'"
  41. :autosize="{ minRows: 3, maxRows: 4 }"
  42. placeholder="请输入"
  43. ></el-input>
  44. </el-form-item>
  45. <div class="mx">
  46. <h3>商品明细:</h3>
  47. <el-button class="button" size="mini" type="primary" v-if="type !== 'view' && type !== 'audit'" @click="scanCode">扫码入库</el-button>
  48. <el-button
  49. class="button"
  50. size="mini"
  51. type="primary"
  52. v-if="
  53. type !== 'view' &&
  54. type !== 'audit' &&
  55. goodsExchangeAddForm.type !== 'TRANSFER_ENTRY' &&
  56. goodsExchangeAddForm.type !== 'HAIL_ENTRY' &&
  57. goodsExchangeAddForm.type !== 'SALE_AFTER'
  58. "
  59. @click="handleSelectWarehouseEntryBatch"
  60. >选择</el-button
  61. >
  62. </div>
  63. <div style="width: 100%; display: block">
  64. <el-form-item style="width: 100%">
  65. <el-table
  66. :data="goodsExchangeAddForm.product_list"
  67. border
  68. :cell-style="{ textAlign: 'center' }"
  69. :header-cell-style="{ textAlign: 'center' }"
  70. style="width: 100%; margin-top: 20px"
  71. >
  72. <el-table-column label="库位号">
  73. <template #default="scope">
  74. <el-popover placement="right" trigger="click" v-if="scope.row.area_stock_list">
  75. <div>
  76. <p v-for="item in scope.row.area_stock_list" :key="item.id">{{ item.warehouse_area_name }}</p>
  77. </div>
  78. <span slot="reference" v-if="scope.row.area_stock_list.length !== 0">{{ scope.row.area_stock_list[0].warehouse_area_name }}</span>
  79. </el-popover>
  80. </template>
  81. </el-table-column>
  82. <!-- <el-table-column label="商品编号">
  83. <template #default="scope">
  84. {{ scope.row.goods_vo.sn }}
  85. </template>
  86. </el-table-column> -->
  87. <el-table-column label="商品名称">
  88. <template #default="scope">
  89. {{ scope.row.product_vo.name }}
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="sku">
  93. <template #default="scope">
  94. {{ scope.row.product_vo.sku }}
  95. <!-- <span v-if="id">{{ scope.row.product_vo.sku }}</span>
  96. <span v-else>{{ scope.row.product_vo.sku }}</span> -->
  97. </template>
  98. </el-table-column>
  99. <!-- <el-table-column label="序列号">
  100. <template #default="scope">
  101. <div class="sn-code-container">
  102. <span v-for="item in scope.row.sn_code_list" :key="item.id">
  103. <p>{{ item.sn_code }}</p>
  104. </span>
  105. </div>
  106. </template>
  107. </el-table-column> -->
  108. <!-- <el-table-column prop="product_vo.spec_name" label="规格型号" v-if="id"> </el-table-column>
  109. <el-table-column prop="product_vo.spec_name" label="规格型号" v-else> </el-table-column> -->
  110. <el-table-column label="单位">
  111. <template #default="scope">
  112. {{ scope.row.product_vo.unit }}
  113. <!-- <span v-if="id">{{ scope.row.product_vo.unit }}</span>
  114. <span v-else>{{ scope.row.product_vo.unit }}</span> -->
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="入库数量">
  118. <template #default="scope">
  119. <el-input-number
  120. v-model="scope.row.num"
  121. type="number"
  122. :min="0"
  123. :maxlength="20"
  124. :disabled="
  125. type === 'view' ||
  126. type === 'audit' ||
  127. goodsExchangeAddForm.type == 'TRANSFER_ENTRY' ||
  128. goodsExchangeAddForm.type == 'HAIL_ENTRY' ||
  129. goodsExchangeAddForm.type == 'SALE_AFTER'
  130. "
  131. ></el-input-number>
  132. </template>
  133. </el-table-column>
  134. <el-table-column
  135. prop="entry_num"
  136. label="已入库数量"
  137. v-if="goodsExchangeAddForm.type == 'TRANSFER_ENTRY' || goodsExchangeAddForm.type == 'HAIL_ENTRY' || goodsExchangeAddForm.type == 'SALE_AFTER'"
  138. >
  139. <template #default="scope">
  140. {{ scope.row.entry_num }}
  141. </template>
  142. </el-table-column>
  143. <el-table-column
  144. prop="not_entry_num"
  145. label="未入库数量"
  146. v-if="goodsExchangeAddForm.type == 'TRANSFER_ENTRY' || goodsExchangeAddForm.type == 'HAIL_ENTRY' || goodsExchangeAddForm.type == 'SALE_AFTER'"
  147. >
  148. <template #default="scope">
  149. {{ scope.row.not_entry_num }}
  150. </template>
  151. </el-table-column>
  152. <el-table-column
  153. label="订单数量"
  154. v-if="goodsExchangeAddForm.type == 'HAIL_ENTRY' || goodsExchangeAddForm.type == 'SALE_AFTER' || goodsExchangeAddForm.type == 'TRANSFER_ENTRY'"
  155. >
  156. <template #default="scope">
  157. {{ scope.row.order_num }}
  158. </template>
  159. </el-table-column>
  160. <el-table-column label="退货数量" v-if="goodsExchangeAddForm.type == 'SALE_AFTER'">
  161. <template #default="scope">
  162. {{ scope.row.return_num }}
  163. </template>
  164. </el-table-column>
  165. <el-table-column label="在途库存" v-if="TO_BE_RETURN == 'TO_BE_RETURN'">
  166. <template #default="scope">
  167. {{ scope.row.stock_num }}
  168. </template>
  169. </el-table-column>
  170. <el-table-column label="差异" v-if="id">
  171. <template #default="scope">
  172. <span v-if="scope.row.order_num">{{ scope.row.num - scope.row.order_num || 0 }}</span>
  173. </template>
  174. </el-table-column>
  175. <el-table-column
  176. label="操作"
  177. v-if="
  178. type !== 'view' &&
  179. type !== 'audit' &&
  180. goodsExchangeAddForm.type !== 'TRANSFER_ENTRY' &&
  181. goodsExchangeAddForm.type !== 'HAIL_ENTRY' &&
  182. goodsExchangeAddForm.type !== 'SALE_AFTER'
  183. "
  184. >
  185. <template #default="scope">
  186. <el-button size="mini" type="danger" @click="goodsExchangeAddForm.product_list.splice(scope.$index, 1)">删除</el-button>
  187. </template>
  188. </el-table-column>
  189. </el-table>
  190. </el-form-item>
  191. </div>
  192. </el-form>
  193. <div class="footer">
  194. <el-button
  195. v-if="
  196. type !== 'view' &&
  197. type !== 'detail' &&
  198. checkPermission(['warehouseEntry2:add']) &&
  199. goodsExchangeAddForm.type !== 'TRANSFER_ENTRY' &&
  200. goodsExchangeAddForm.type !== 'HAIL_ENTRY' &&
  201. goodsExchangeAddForm.type !== 'SALE_AFTER'
  202. "
  203. type="primary"
  204. @click="savegoodsExchangeAddForm"
  205. >保存
  206. </el-button>
  207. <el-button v-if="type !== 'view' && type !== 'detail' && checkPermission(['warehouseEntry:update'])" type="primary" @click="submitgoodsExchangeAddForm"
  208. >入库
  209. </el-button>
  210. <el-button @click="printIng" v-if="type == 'audit'">打印</el-button>
  211. <el-button @click="toBack()">返回</el-button>
  212. </div>
  213. <el-dialog title="提示" v-model="dialogVisible" width="30%">
  214. <el-form :model="goodsExchangeAddForm" label-width="120px" inline style="width: 900px">
  215. <el-form-item label="驳回原因" prop="reject_reason">
  216. <el-input v-model="goodsExchangeAddForm.reject_reason" type="textarea" :minlength="0" :maxlength="100"></el-input>
  217. </el-form-item>
  218. </el-form>
  219. <template #footer>
  220. <el-button @click="dialogVisible = false">取 消</el-button>
  221. <el-button type="primary" @click="handleRejectGoodsExchange()">确 定</el-button>
  222. </template>
  223. </el-dialog>
  224. <el-dialog title="扫码入库" v-model="scanDialogVisible" width="30%" :close-on-click-modal="false">
  225. <el-form ref="scanGoodsFormRef" :model="scanGoodsForm" label-width="120px" inline>
  226. <el-form-item label="sku" prop="bar_code">
  227. <el-input v-model="scanGoodsForm.bar_code" ref="inputRef" @keyup.enter="toSearch()" :minlength="0" :maxlength="100"></el-input>
  228. </el-form-item>
  229. <el-form-item label="序列号" prop="sn_code">
  230. <el-input ref="sn_input" v-model="sn_code" @keyup.enter="toSnCode()" :minlength="0" :maxlength="100"></el-input>
  231. </el-form-item>
  232. </el-form>
  233. </el-dialog>
  234. <el-dialog title="入库商品" v-model="goodsVisible" width="1000px" @close="closeGoosData">
  235. <div style="display: flex; align-items: center; justify-content: flex-end; padding: 10px 0">
  236. <span>搜索商品:</span><el-input v-model="params.keyWord" style="width: 200px; margin-right: 5px"></el-input>
  237. <el-button @click="searchGoodEvent"> 搜索 </el-button>
  238. </div>
  239. <el-table :data="goodsData.records" border style="width: 100%" @selection-change="handleSelectionChange">
  240. <el-table-column type="selection" width="55" />
  241. <el-table-column prop="product_vo.name" label="商品名称"></el-table-column>
  242. <el-table-column prop="product_vo.sku" label="sku"> </el-table-column>
  243. <el-table-column prop="" label="品牌">
  244. <template #default="scope">
  245. {{ scope.row.product_vo.brand }}
  246. </template>
  247. </el-table-column>
  248. <el-table-column prop="product_vo.weight" label="重量"> </el-table-column>
  249. <el-table-column prop="product_vo.unit" label="单位"> </el-table-column>
  250. </el-table>
  251. <el-pagination
  252. @size-change="goodsPageSizeChange"
  253. @current-change="goodsPageCurrentChange"
  254. :current-page="goodsData.current"
  255. :page-sizes="[10, 20, 50, 100]"
  256. :page-size="goodsData.size"
  257. layout="total, sizes, prev, pager, next, jumper"
  258. :total="goodsData.total"
  259. >
  260. </el-pagination>
  261. <template #footer>
  262. <el-button @click="closeGoosData">取 消</el-button>
  263. <el-button type="primary" @click="submitGoosData()">确 定</el-button>
  264. </template>
  265. </el-dialog>
  266. <el-dialog title="订单列表" v-model="orderVisible" width="1000px" @close="closeGoosData">
  267. <el-table :data="orderList.data" border style="width: 100%" ref="tables" @selection-change="handleSelOrderChange">
  268. <el-table-column type="selection" width="55" />
  269. <el-table-column prop="" label="订单编号">
  270. <template #default="scope">
  271. {{ scope.row.sn }}
  272. </template>
  273. </el-table-column>
  274. <el-table-column prop="order_time" label="下单时间">
  275. <template #default="scope">{{ scope.row.order_time }}</template>
  276. </el-table-column>
  277. <el-table-column prop="" label="仓库名称">
  278. <template #default="scope">
  279. {{ warehouseName(scope.row.warehouse_id) }}
  280. </template>
  281. </el-table-column>
  282. <el-table-column prop="" label="配送方式">
  283. <template #default="scope">{{ deliveryType(scope.row.send_type) }}</template>
  284. </el-table-column>
  285. <el-table-column prop="" label="实付金额">
  286. <template #default="scope">{{ '¥' + scope.row.pay_price }}</template>
  287. </el-table-column>
  288. </el-table>
  289. <el-pagination
  290. @size-change="handlePageSizeChange"
  291. @current-change="handlePageCurrentChange"
  292. :current-page="orderList.page_no"
  293. :page-sizes="[10, 20, 50, 100]"
  294. :page-size="orderList.page_size"
  295. layout="total, sizes, prev, pager, next, jumper"
  296. :total="orderList.data_total"
  297. >
  298. </el-pagination>
  299. <template #footer>
  300. <el-button @click="closeOrder">取 消</el-button>
  301. <el-button @click="searchOrderAdd" type="primary">确 定</el-button>
  302. </template>
  303. </el-dialog>
  304. </div>
  305. </template>
  306. <script setup>
  307. import { ref, reactive, computed, onMounted, watch, nextTick } from 'vue';
  308. import { useStore } from 'vuex';
  309. import { useRoute, useRouter } from 'vue-router';
  310. import { ElMessageBox, ElMessage } from 'element-plus';
  311. import * as API_GoodsExchange from '@/api/goodsExchange';
  312. import * as API_Setting from '@/api/setting';
  313. import * as API_BasicSetting from '@/api/basicSetting';
  314. /* import * as API_Erp from '@/api/erp';
  315. import * as API_Auth from '@/api/auth';
  316. import * as API_order from '@/api/order';
  317. import * as API_Goods from '@/api/goods';
  318. import * as API_CollectingAccount from '@/api/collectingAccount'; */
  319. const store = useStore();
  320. const route = useRoute();
  321. const router = useRouter();
  322. const dialogVisible = ref(false);
  323. const scanDialogVisible = ref(false);
  324. const goodsVisible = ref(false);
  325. const orderVisible = ref(false);
  326. const snCodeVisible = ref(false);
  327. const goodsExchangeAddFormRef = ref();
  328. let goodsExchangeAddForm = reactive({
  329. contract_product_list: [],
  330. product_list: [],
  331. warehouse_id: '',
  332. type: '',
  333. memo: '',
  334. sn: '',
  335. reject_reason: '',
  336. order_id: '',
  337. });
  338. const goodsExchangeAddFormRule = {
  339. warehouse_id: [{ required: true, message: '请选择入库仓库', trigger: 'change' }],
  340. type: [{ required: true, message: '请选择入库类型', trigger: 'change' }],
  341. };
  342. const params = reactive({
  343. page_no: 1,
  344. page_size: 10,
  345. keyWord: '',
  346. });
  347. const warehouseList = ref([]);
  348. const typeList = ref([]);
  349. const goodsData = ref([]);
  350. const orderList = ref([]);
  351. const sn_code = ref('');
  352. const scanGoodsForm = reactive({
  353. bar_code: '',
  354. });
  355. const scanGoodsFormRef = ref();
  356. const type = ref('');
  357. const id = ref('');
  358. const orderType = ref(false);
  359. const TO_BE_RETURN = ref('');
  360. const checkPermission = (permissions) => {
  361. // Implement your permission check logic here
  362. return true;
  363. };
  364. const searchGoodEvent = () => {
  365. API_GoodsExchange.getGoodsInfo(params, goodsExchangeAddForm.warehouse_id).then((res) => {
  366. goodsData.value = res;
  367. });
  368. };
  369. const handleSelOrderChange = (val) => {
  370. if (val.length > 1) {
  371. const lastSelected = val[val.length - 1];
  372. orderList.value = [lastSelected];
  373. }
  374. };
  375. const toBack = () => {
  376. router.push({ name: 'goodsExchange', params: { type: 'second' } });
  377. };
  378. const toSnCode = async () => {
  379. if (scanGoodsForm.bar_code === '') return;
  380. const res = await API_GoodsExchange.getSnCode('in', scanGoodsForm.bar_code, sn_code.value.replace(/\s+/g, ''));
  381. sn_code.value = '';
  382. const exists = goodsExchangeAddForm.product_list.find((item) => item.sn_code === res.sn_code && item.sku === res.sku);
  383. if (!exists) {
  384. goodsExchangeAddForm.product_list.push(res);
  385. }
  386. if (TO_BE_RETURN.value === 'TO_BE_RETURN') {
  387. if (goodsExchangeAddForm.product_list.length >= goodsExchangeAddForm.stock_num) {
  388. return;
  389. }
  390. }
  391. if (goodsExchangeAddForm.type === 'TRANSFER_ENTRY' || goodsExchangeAddForm.type === 'HAIL_ENTRY' || goodsExchangeAddForm.type === 'SALE_AFTER') {
  392. if (goodsExchangeAddForm.product_list.length >= goodsExchangeAddForm.not_entry_num) {
  393. return;
  394. }
  395. }
  396. goodsExchangeAddForm.product_list.length = goodsExchangeAddForm.product_list.length;
  397. scanGoodsForm.bar_code = '';
  398. };
  399. const addSnCode = (row, index) => {
  400. scanGoodsForm.bar_code = row.product_vo.sku;
  401. snCodeVisible.value = true;
  402. };
  403. const orderBtn = () => {
  404. params.status = 'TO_BE_RETURN';
  405. API_order.getOrderList(params).then((res) => {
  406. orderList.value = res;
  407. orderVisible.value = true;
  408. });
  409. };
  410. const closeOrder = () => {
  411. orderVisible.value = false;
  412. };
  413. const goodsPageSizeChange = (size) => {
  414. params.page_size = size;
  415. searchGoodEvent();
  416. };
  417. const goodsPageCurrentChange = (page) => {
  418. params.page_no = page;
  419. searchGoodEvent();
  420. };
  421. const handlePageSizeChange = (size) => {
  422. params.page_size = size;
  423. API_order.getOrderList(params).then((res) => {
  424. orderList.value = res;
  425. });
  426. };
  427. const handlePageCurrentChange = (page) => {
  428. params.page_no = page;
  429. API_order.getOrderList(params).then((res) => {
  430. orderList.value = res;
  431. });
  432. };
  433. const searchOrderAdd = () => {
  434. if (orderList.value.length >= 1) {
  435. API_GoodsExchange.getOneBySn(orderList.value[0].sn).then((res) => {
  436. orderType.value = true;
  437. goodsExchangeAddForm.type = res.scan_order_type === 'saleAfter' ? 'SALE_AFTER' : 'HAIL_ENTRY';
  438. TO_BE_RETURN.value = res.status;
  439. goodsExchangeAddForm.warehouse_id = res.return_warehouse_id;
  440. goodsExchangeAddForm.scan_order_sn = orderList.value[0].sn;
  441. goodsExchangeAddForm.scan_order_type = res.type;
  442. goodsExchangeAddForm.order_id = res.id;
  443. goodsExchangeAddForm.product_list = res.item_list
  444. .filter((el) => el.stock_num > 0)
  445. .map((el) => {
  446. el.scan_order_item_id = el.id;
  447. el.scan_order_id = res.id;
  448. el.num = res.scan_order_type === 'saleAfter' ? el.return_num : 0;
  449. el.order_num = res.scan_order_type === 'saleAfter' ? el.order_item_num : el.num;
  450. el.sn_code_list = [];
  451. return el;
  452. });
  453. orderVisible.value = false;
  454. });
  455. } else {
  456. ElMessage.error('请选择订单');
  457. }
  458. };
  459. const blurUsername = () => {
  460. if (goodsExchangeAddForm.sn !== undefined) {
  461. API_GoodsExchange.getOneBySn(goodsExchangeAddForm.sn).then((res) => {
  462. orderType.value = true;
  463. goodsExchangeAddForm.type = res.scan_order_type === 'saleAfter' ? 'SALE_AFTER' : 'HAIL_ENTRY';
  464. goodsExchangeAddForm.warehouse_id = res.return_warehouse_id;
  465. goodsExchangeAddForm.scan_order_sn = goodsExchangeAddForm.sn;
  466. goodsExchangeAddForm.scan_order_type = res.type;
  467. goodsExchangeAddForm.order_id = res.id;
  468. res.item_list.forEach((el) => {
  469. el.scan_order_item_id = el.id;
  470. el.scan_order_id = res.id;
  471. el.num = res.scan_order_type === 'saleAfter' ? el.return_num : 0;
  472. el.order_num = res.scan_order_type === 'saleAfter' ? el.num : el.num;
  473. el.sn_code_list = [];
  474. });
  475. goodsExchangeAddForm.product_list = res.item_list;
  476. });
  477. } else {
  478. ElMessage.error('请填写订单编号');
  479. }
  480. };
  481. /* 选中的商品列表 */
  482. const goodsList = ref([]);
  483. const handleSelectionChange = (val) => {
  484. goodsList.value = val.map((el) => {
  485. /* el.product_id = el.id;
  486. el.goods_id = el.id;
  487. el.sn_code_list = []; */
  488. return el;
  489. });
  490. };
  491. const submitGoosData = () => {
  492. if (goodsList.value.length >= 1) {
  493. goodsExchangeAddForm.product_list = goodsList.value.map((el) => {
  494. /* el.sn_code_list = []; */
  495. return el;
  496. });
  497. goodsVisible.value = false;
  498. } else {
  499. ElMessage.error('请选择商品信息');
  500. }
  501. };
  502. const closeGoosData = () => {
  503. goodsVisible.value = false;
  504. };
  505. const inputRef = ref();
  506. const scanCode = () => {
  507. if (!goodsExchangeAddForm.warehouse_id) {
  508. ElMessage.error('请先选择仓库!');
  509. return;
  510. }
  511. scanDialogVisible.value = true;
  512. nextTick(() => {
  513. inputRef.value.focus();
  514. });
  515. };
  516. const handleSelectWarehouseEntryBatch = () => {
  517. if (!goodsExchangeAddForm.warehouse_id) {
  518. ElMessage.error('请先选择仓库!');
  519. return;
  520. }
  521. API_GoodsExchange.getGoodsInfo(params, goodsExchangeAddForm.warehouse_id, 'le').then((res) => {
  522. goodsData.value = res;
  523. goodsVisible.value = true;
  524. });
  525. };
  526. const savegoodsExchangeAddForm = () => {
  527. goodsExchangeAddFormRef.value.validate((valid) => {
  528. if (valid) {
  529. const params = { ...goodsExchangeAddForm };
  530. params.save_or_submit = 'save';
  531. if (!params.product_list.length) {
  532. ElMessage.error('请选择商品!');
  533. return;
  534. }
  535. params.product_list.forEach((el) => {
  536. el.product_stock_id = el.id;
  537. el.product_id = el.product_vo.id;
  538. el.id = '';
  539. });
  540. if (type.value == 'edit') {
  541. API_GoodsExchange.editWarehouseEntry(route.query.id, params).then((response) => {
  542. ElMessage.success('修改成功!');
  543. router.push({ name: 'goodsExchange' });
  544. });
  545. } else {
  546. API_GoodsExchange.warehouseEntry(params).then(() => {
  547. ElMessage.success('保存成功!');
  548. router.push({ name: 'goodsExchange' });
  549. });
  550. }
  551. }
  552. });
  553. };
  554. const submitgoodsExchangeAddForm = () => {
  555. goodsExchangeAddFormRef.value.validate((valid) => {
  556. if (valid) {
  557. const params = { ...goodsExchangeAddForm };
  558. params.save_or_submit = 'submit';
  559. if (!params.product_list.length) {
  560. ElMessage.error('请选择商品!');
  561. return;
  562. }
  563. params.product_list.forEach((el) => {
  564. el.product_stock_id = el.id;
  565. el.product_id = el.product_vo.id;
  566. el.id = '';
  567. });
  568. if (type.value == 'edit') {
  569. API_GoodsExchange.editWarehouseEntry(route.query.id, params).then((response) => {
  570. ElMessage.success('修改成功!');
  571. router.push({ name: 'goodsExchange' });
  572. });
  573. } else {
  574. API_GoodsExchange.warehouseEntry(params).then(() => {
  575. ElMessage.success('保存成功!');
  576. router.push({ name: 'goodsExchange' });
  577. });
  578. }
  579. }
  580. });
  581. };
  582. /* 获取当前入库单详情 */
  583. const GET_WarehousInfo = () => {
  584. API_GoodsExchange.getGoodsExchangeInfo(route.query.id).then((response) => {
  585. API_Setting.getPage({ dictType: 'warehouse_entry_type' }).then((res) => {
  586. Object.assign(typeList, res.data);
  587. });
  588. Object.assign(goodsExchangeAddForm, response);
  589. });
  590. };
  591. onMounted(() => {
  592. if (route.query.type == 'view') {
  593. type.value = 'view';
  594. GET_WarehousInfo();
  595. } else if (route.query.type == 'edit') {
  596. type.value = 'edit';
  597. GET_WarehousInfo();
  598. }
  599. API_BasicSetting.getWarehouseListAll().then((response) => {
  600. warehouseList.value = response;
  601. });
  602. API_Setting.getPage({ dictType: 'warehouse_entry_type' }).then((res) => {
  603. typeList.value = res.data;
  604. });
  605. });
  606. </script>
  607. <style scoped>
  608. /* 底部步骤 */
  609. .footer {
  610. width: 100%;
  611. padding: 10px;
  612. bottom: 0px;
  613. text-align: center;
  614. z-index: 999;
  615. }
  616. .mx {
  617. display: flex;
  618. align-items: center;
  619. width: 100%;
  620. }
  621. .mx .button {
  622. margin-left: 10px;
  623. }
  624. .change-form {
  625. display: flex;
  626. justify-content: flex-start;
  627. align-items: flex-start;
  628. flex-wrap: wrap;
  629. min-width: 900px;
  630. }
  631. .change-form .change-form-item {
  632. width: 30%;
  633. margin: 0 10px 20px 0;
  634. display: flex;
  635. flex-direction: row;
  636. flex-wrap: nowrap;
  637. }
  638. .change-form .el-form-item__content {
  639. flex: 1;
  640. width: 100%;
  641. }
  642. .change-form .el-date-editor,
  643. .change-form .el-cascader,
  644. .change-form .el-select {
  645. width: 100%;
  646. }
  647. .bg-in-stock {
  648. background-color: #fff;
  649. margin: 10px;
  650. padding: 25px;
  651. }
  652. .goods-info {
  653. display: flex;
  654. }
  655. .goods-info .goods-name-box {
  656. text-align: left;
  657. }
  658. .goods-info .goods-name-box .goods-name {
  659. text-overflow: ellipsis;
  660. display: -webkit-box;
  661. -webkit-line-clamp: 2;
  662. -webkit-box-orient: vertical;
  663. overflow: hidden;
  664. line-height: 16px;
  665. }
  666. .goods-info .goods-name-box .specs {
  667. color: #999999;
  668. }
  669. .sn-code-container {
  670. max-height: 100px;
  671. overflow-y: auto;
  672. }
  673. .el-input--suffix .el-input__inner {
  674. padding-right: 10px;
  675. }
  676. .error-input .el-input__inner {
  677. border: 1px solid red;
  678. }
  679. </style>