addInventory.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  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="$t('warehousing')+$t('warechouse')+':'" 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="$t('type')+':'" 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="$t('notes')+':'" 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="$t('place')"
  43. ></el-input>
  44. </el-form-item>
  45. <div class="mx">
  46. <h3>{{$t('goods_inventory')}}:</h3>
  47. <el-button class="button" size="mini" type="primary" v-if="type !== 'view' && type !== 'audit'" @click="scanCode">{{$t('scan_code')}}</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. >{{$t('select')}}</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="$t('warechouse_code')">
  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="$t('goods_name')">
  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="$t('goods_unit')">
  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="$t('warehousing_num')">
  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="$t('warehousing_in_num')"
  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="$t('not_entry_num')"
  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="$t('order_num')"
  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="$t('return_num')" 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="$t('transit_stock')" 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="$t('diff')" 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="$t('operate')"
  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)">{{$t('delete')}}</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. >{{$t('save')}}
  206. </el-button>
  207. <el-button v-if="type !== 'view' && type !== 'detail' && checkPermission(['warehouseEntry:update'])" type="primary" @click="submitgoodsExchangeAddForm"
  208. >{{$t('warehousing')}}
  209. </el-button>
  210. <el-button @click="printIng" v-if="type == 'audit'">{{$t('print')}}</el-button>
  211. <el-button @click="toBack()">{{$t('return')}}</el-button>
  212. </div>
  213. <el-dialog :title="$t('prompt')" v-model="dialogVisible" width="30%">
  214. <el-form :model="goodsExchangeAddForm" label-width="120px" inline style="width: 900px">
  215. <el-form-item :label="$t('reject')" 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">{{$t('cancel')}}</el-button>
  221. <el-button type="primary" @click="handleRejectGoodsExchange()">{{$t('submit')}}</el-button>
  222. </template>
  223. </el-dialog>
  224. <el-dialog :title="$t('scan_code')" 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="$t('warehousing')+$t('goods_info')" v-model="goodsVisible" width="1000px" @close="closeGoosData">
  235. <div style="display: flex; align-items: center; justify-content: flex-end; padding: 10px 0">
  236. <span>{{$t('search')+$t('goods_info')}}:</span><el-input v-model="params.keyWord" style="width: 200px; margin-right: 5px"></el-input>
  237. <el-button @click="searchGoodEvent"> {{$t('search')}} </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="$t('goods_name')"></el-table-column>
  242. <el-table-column prop="product_vo.sku" label="sku"> </el-table-column>
  243. <el-table-column prop="" :label="$t('brand')">
  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="$t('weight')"> </el-table-column>
  249. <el-table-column prop="product_vo.unit" :label="$t('goods_unit')"> </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">{{$t('cancel')}}</el-button>
  263. <el-button type="primary" @click="submitGoosData()">{{$t('submit')}}</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. import { useI18n } from 'vue-i18n';
  320. const { t } = useI18n();
  321. const store = useStore();
  322. const route = useRoute();
  323. const router = useRouter();
  324. const dialogVisible = ref(false);
  325. const scanDialogVisible = ref(false);
  326. const goodsVisible = ref(false);
  327. const orderVisible = ref(false);
  328. const snCodeVisible = ref(false);
  329. const goodsExchangeAddFormRef = ref();
  330. let goodsExchangeAddForm = reactive({
  331. contract_product_list: [],
  332. product_list: [],
  333. warehouse_id: '',
  334. type: '',
  335. memo: '',
  336. sn: '',
  337. reject_reason: '',
  338. order_id: '',
  339. });
  340. const goodsExchangeAddFormRule = {
  341. warehouse_id: [{ required: true, message: t('change')+t('warehousing')+t('warechouse'), trigger: 'change' }],
  342. type: [{ required: true, message: t('change')+t('warehousing')+t('type'), trigger: 'change' }],
  343. };
  344. const params = reactive({
  345. page_no: 1,
  346. page_size: 10,
  347. keyWord: '',
  348. });
  349. const warehouseList = ref([]);
  350. const typeList = ref([]);
  351. const goodsData = ref([]);
  352. const orderList = ref([]);
  353. const sn_code = ref('');
  354. const scanGoodsForm = reactive({
  355. bar_code: '',
  356. });
  357. const scanGoodsFormRef = ref();
  358. const type = ref('');
  359. const id = ref('');
  360. const orderType = ref(false);
  361. const TO_BE_RETURN = ref('');
  362. const checkPermission = (permissions) => {
  363. // Implement your permission check logic here
  364. return true;
  365. };
  366. const searchGoodEvent = () => {
  367. API_GoodsExchange.getGoodsInfo(params, goodsExchangeAddForm.warehouse_id).then((res) => {
  368. goodsData.value = res;
  369. });
  370. };
  371. const handleSelOrderChange = (val) => {
  372. if (val.length > 1) {
  373. const lastSelected = val[val.length - 1];
  374. orderList.value = [lastSelected];
  375. }
  376. };
  377. const toBack = () => {
  378. router.push({ name: 'goodsExchange', params: { type: 'second' } });
  379. };
  380. const toSnCode = async () => {
  381. if (scanGoodsForm.bar_code === '') return;
  382. const res = await API_GoodsExchange.getSnCode('in', scanGoodsForm.bar_code, sn_code.value.replace(/\s+/g, ''));
  383. sn_code.value = '';
  384. const exists = goodsExchangeAddForm.product_list.find((item) => item.sn_code === res.sn_code && item.sku === res.sku);
  385. if (!exists) {
  386. goodsExchangeAddForm.product_list.push(res);
  387. }
  388. if (TO_BE_RETURN.value === 'TO_BE_RETURN') {
  389. if (goodsExchangeAddForm.product_list.length >= goodsExchangeAddForm.stock_num) {
  390. return;
  391. }
  392. }
  393. if (goodsExchangeAddForm.type === 'TRANSFER_ENTRY' || goodsExchangeAddForm.type === 'HAIL_ENTRY' || goodsExchangeAddForm.type === 'SALE_AFTER') {
  394. if (goodsExchangeAddForm.product_list.length >= goodsExchangeAddForm.not_entry_num) {
  395. return;
  396. }
  397. }
  398. goodsExchangeAddForm.product_list.length = goodsExchangeAddForm.product_list.length;
  399. scanGoodsForm.bar_code = '';
  400. };
  401. const addSnCode = (row, index) => {
  402. scanGoodsForm.bar_code = row.product_vo.sku;
  403. snCodeVisible.value = true;
  404. };
  405. const orderBtn = () => {
  406. params.status = 'TO_BE_RETURN';
  407. API_order.getOrderList(params).then((res) => {
  408. orderList.value = res;
  409. orderVisible.value = true;
  410. });
  411. };
  412. const closeOrder = () => {
  413. orderVisible.value = false;
  414. };
  415. const goodsPageSizeChange = (size) => {
  416. params.page_size = size;
  417. searchGoodEvent();
  418. };
  419. const goodsPageCurrentChange = (page) => {
  420. params.page_no = page;
  421. searchGoodEvent();
  422. };
  423. const handlePageSizeChange = (size) => {
  424. params.page_size = size;
  425. API_order.getOrderList(params).then((res) => {
  426. orderList.value = res;
  427. });
  428. };
  429. const handlePageCurrentChange = (page) => {
  430. params.page_no = page;
  431. API_order.getOrderList(params).then((res) => {
  432. orderList.value = res;
  433. });
  434. };
  435. const searchOrderAdd = () => {
  436. if (orderList.value.length >= 1) {
  437. API_GoodsExchange.getOneBySn(orderList.value[0].sn).then((res) => {
  438. orderType.value = true;
  439. goodsExchangeAddForm.type = res.scan_order_type === 'saleAfter' ? 'SALE_AFTER' : 'HAIL_ENTRY';
  440. TO_BE_RETURN.value = res.status;
  441. goodsExchangeAddForm.warehouse_id = res.return_warehouse_id;
  442. goodsExchangeAddForm.scan_order_sn = orderList.value[0].sn;
  443. goodsExchangeAddForm.scan_order_type = res.type;
  444. goodsExchangeAddForm.order_id = res.id;
  445. goodsExchangeAddForm.product_list = res.item_list
  446. .filter((el) => el.stock_num > 0)
  447. .map((el) => {
  448. el.scan_order_item_id = el.id;
  449. el.scan_order_id = res.id;
  450. el.num = res.scan_order_type === 'saleAfter' ? el.return_num : 0;
  451. el.order_num = res.scan_order_type === 'saleAfter' ? el.order_item_num : el.num;
  452. el.sn_code_list = [];
  453. return el;
  454. });
  455. orderVisible.value = false;
  456. });
  457. } else {
  458. ElMessage.error('请选择订单');
  459. }
  460. };
  461. const blurUsername = () => {
  462. if (goodsExchangeAddForm.sn !== undefined) {
  463. API_GoodsExchange.getOneBySn(goodsExchangeAddForm.sn).then((res) => {
  464. orderType.value = true;
  465. goodsExchangeAddForm.type = res.scan_order_type === 'saleAfter' ? 'SALE_AFTER' : 'HAIL_ENTRY';
  466. goodsExchangeAddForm.warehouse_id = res.return_warehouse_id;
  467. goodsExchangeAddForm.scan_order_sn = goodsExchangeAddForm.sn;
  468. goodsExchangeAddForm.scan_order_type = res.type;
  469. goodsExchangeAddForm.order_id = res.id;
  470. res.item_list.forEach((el) => {
  471. el.scan_order_item_id = el.id;
  472. el.scan_order_id = res.id;
  473. el.num = res.scan_order_type === 'saleAfter' ? el.return_num : 0;
  474. el.order_num = res.scan_order_type === 'saleAfter' ? el.num : el.num;
  475. el.sn_code_list = [];
  476. });
  477. goodsExchangeAddForm.product_list = res.item_list;
  478. });
  479. } else {
  480. ElMessage.error('请填写订单编号');
  481. }
  482. };
  483. /* 选中的商品列表 */
  484. const goodsList = ref([]);
  485. const handleSelectionChange = (val) => {
  486. goodsList.value = val.map((el) => {
  487. /* el.product_id = el.id;
  488. el.goods_id = el.id;
  489. el.sn_code_list = []; */
  490. return el;
  491. });
  492. };
  493. const submitGoosData = () => {
  494. if (goodsList.value.length >= 1) {
  495. goodsExchangeAddForm.product_list = goodsList.value.map((el) => {
  496. /* el.sn_code_list = []; */
  497. return el;
  498. });
  499. goodsVisible.value = false;
  500. } else {
  501. ElMessage.error(t('change')+t('goods_info')+'!');
  502. }
  503. };
  504. const closeGoosData = () => {
  505. goodsVisible.value = false;
  506. };
  507. const inputRef = ref();
  508. const scanCode = () => {
  509. if (!goodsExchangeAddForm.warehouse_id) {
  510. ElMessage.error(t('change')+t('warechouse')+'!');
  511. return;
  512. }
  513. scanDialogVisible.value = true;
  514. nextTick(() => {
  515. inputRef.value.focus();
  516. });
  517. };
  518. const handleSelectWarehouseEntryBatch = () => {
  519. if (!goodsExchangeAddForm.warehouse_id) {
  520. ElMessage.error(t('change')+t('warechouse')+'!');
  521. return;
  522. }
  523. API_GoodsExchange.getGoodsInfo(params, goodsExchangeAddForm.warehouse_id, 'le').then((res) => {
  524. goodsData.value = res;
  525. goodsVisible.value = true;
  526. });
  527. };
  528. const savegoodsExchangeAddForm = () => {
  529. goodsExchangeAddFormRef.value.validate((valid) => {
  530. if (valid) {
  531. const params = { ...goodsExchangeAddForm };
  532. params.save_or_submit = 'save';
  533. if (!params.product_list.length) {
  534. ElMessage.error(t('change')+t('goods_info')+'!');
  535. return;
  536. }
  537. params.product_list.forEach((el) => {
  538. el.product_stock_id = el.id;
  539. el.product_id = el.product_vo.id;
  540. el.id = '';
  541. });
  542. if (type.value == 'edit') {
  543. API_GoodsExchange.editWarehouseEntry(route.query.id, params).then((response) => {
  544. ElMessage.success(t('edit_success')+'!');
  545. router.push({ name: 'goodsExchange' });
  546. });
  547. } else {
  548. API_GoodsExchange.warehouseEntry(params).then(() => {
  549. ElMessage.success(t('sub_success')+'!');
  550. router.push({ name: 'goodsExchange' });
  551. });
  552. }
  553. }
  554. });
  555. };
  556. const submitgoodsExchangeAddForm = () => {
  557. goodsExchangeAddFormRef.value.validate((valid) => {
  558. if (valid) {
  559. const params = { ...goodsExchangeAddForm };
  560. params.save_or_submit = 'submit';
  561. if (!params.product_list.length) {
  562. ElMessage.error(t('change')+t('goods_info')+'!');
  563. return;
  564. }
  565. params.product_list.forEach((el) => {
  566. el.product_stock_id = el.id;
  567. el.product_id = el.product_vo.id;
  568. el.id = '';
  569. });
  570. if (type.value == 'edit') {
  571. API_GoodsExchange.editWarehouseEntry(route.query.id, params).then((response) => {
  572. ElMessage.success(t('edit_success')+'!');
  573. router.push({ name: 'goodsExchange' });
  574. });
  575. } else {
  576. API_GoodsExchange.warehouseEntry(params).then(() => {
  577. ElMessage.success(t('sub_success')+'!');
  578. router.push({ name: 'goodsExchange' });
  579. });
  580. }
  581. }
  582. });
  583. };
  584. /* 获取当前入库单详情 */
  585. const GET_WarehousInfo = () => {
  586. API_GoodsExchange.getGoodsExchangeInfo(route.query.id).then((response) => {
  587. API_Setting.getPage({ dictType: 'warehouse_entry_type' }).then((res) => {
  588. Object.assign(typeList, res.data);
  589. });
  590. Object.assign(goodsExchangeAddForm, response);
  591. });
  592. };
  593. onMounted(() => {
  594. if (route.query.type == 'view') {
  595. type.value = 'view';
  596. GET_WarehousInfo();
  597. } else if (route.query.type == 'edit') {
  598. type.value = 'edit';
  599. GET_WarehousInfo();
  600. }
  601. API_BasicSetting.getWarehouseListAll().then((response) => {
  602. warehouseList.value = response;
  603. });
  604. API_Setting.getPage({ dictType: 'warehouse_entry_type' }).then((res) => {
  605. typeList.value = res.data;
  606. });
  607. });
  608. </script>
  609. <style scoped>
  610. /* 底部步骤 */
  611. .footer {
  612. width: 100%;
  613. padding: 10px;
  614. bottom: 0px;
  615. text-align: center;
  616. z-index: 999;
  617. }
  618. .mx {
  619. display: flex;
  620. align-items: center;
  621. width: 100%;
  622. }
  623. .mx .button {
  624. margin-left: 10px;
  625. }
  626. .change-form {
  627. display: flex;
  628. justify-content: flex-start;
  629. align-items: flex-start;
  630. flex-wrap: wrap;
  631. min-width: 900px;
  632. }
  633. .change-form .change-form-item {
  634. width: 30%;
  635. margin: 0 10px 20px 0;
  636. display: flex;
  637. flex-direction: row;
  638. flex-wrap: nowrap;
  639. }
  640. .change-form .el-form-item__content {
  641. flex: 1;
  642. width: 100%;
  643. }
  644. .change-form .el-date-editor,
  645. .change-form .el-cascader,
  646. .change-form .el-select {
  647. width: 100%;
  648. }
  649. .bg-in-stock {
  650. background-color: #fff;
  651. margin: 10px;
  652. padding: 25px;
  653. }
  654. .goods-info {
  655. display: flex;
  656. }
  657. .goods-info .goods-name-box {
  658. text-align: left;
  659. }
  660. .goods-info .goods-name-box .goods-name {
  661. text-overflow: ellipsis;
  662. display: -webkit-box;
  663. -webkit-line-clamp: 2;
  664. -webkit-box-orient: vertical;
  665. overflow: hidden;
  666. line-height: 16px;
  667. }
  668. .goods-info .goods-name-box .specs {
  669. color: #999999;
  670. }
  671. .sn-code-container {
  672. max-height: 100px;
  673. overflow-y: auto;
  674. }
  675. .el-input--suffix .el-input__inner {
  676. padding-right: 10px;
  677. }
  678. .error-input .el-input__inner {
  679. border: 1px solid red;
  680. }
  681. </style>