addInventory.vue 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260
  1. <template>
  2. <div class="bg-in-stock">
  3. <el-form
  4. ref="goodsExchangeAddForm"
  5. :model="goodsExchangeAddForm"
  6. :rules="goodsExchangeAddFormRule"
  7. label-width="160px"
  8. inline
  9. class="change-form"
  10. >
  11. <el-form-item label="订单" prop="order_id" class="change-form-item">
  12. <span>
  13. <el-input
  14. v-model="goodsExchangeAddForm.order_id"
  15. :disabled="type === 'detail' || type === 'audit'"
  16. ref="order"
  17. >
  18. </el-input>
  19. <el-button @click="blurUsername()">搜索</el-button>
  20. <el-button @click="orderBtn">订单列表</el-button>
  21. </span>
  22. </el-form-item>
  23. <el-form-item
  24. prop="warehouse_id"
  25. label="入库仓库"
  26. class="change-form-item"
  27. >
  28. <el-select
  29. v-model="goodsExchangeAddForm.warehouse_id"
  30. clearable
  31. :disabled="type === 'detail' || type === 'audit'"
  32. >
  33. <!--@blur="" @change="handleChangeWareHouse" -->
  34. <el-option
  35. v-for="item in warehouseList"
  36. :key="item.id"
  37. :label="item.name"
  38. :value="item.id"
  39. />
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item label="类型" prop="type" class="change-form-item">
  43. <el-select
  44. v-model="goodsExchangeAddForm.type"
  45. filterable
  46. allow-create
  47. clearable
  48. default-first-option
  49. :disabled="type === 'detail' || type === 'audit'"
  50. >
  51. <el-option
  52. v-for="item in typeList"
  53. :key="item.id"
  54. :label="item.label"
  55. :value="item.value"
  56. />
  57. </el-select>
  58. </el-form-item>
  59. <el-form-item
  60. label="备注"
  61. prop="change_desc"
  62. class="change-form-item"
  63. style="width: 61%"
  64. >
  65. <el-input
  66. style="flex: 1"
  67. v-model="goodsExchangeAddForm.memo"
  68. type="textarea"
  69. :disabled="type === 'detail' || type === 'audit'"
  70. :autosize="{ minRows: 3, maxRows: 4 }"
  71. placeholder="请输入"
  72. ></el-input>
  73. </el-form-item>
  74. <div class="mx">
  75. <h3>商品明细</h3>
  76. <el-button
  77. class="button"
  78. size="mini"
  79. type="primary"
  80. v-if="type !== 'detail' && type !== 'audit'"
  81. @click="scanCode"
  82. >扫码入库</el-button
  83. >
  84. <el-button
  85. class="button"
  86. size="mini"
  87. type="primary"
  88. v-if="type !== 'detail' && type !== 'audit'"
  89. @click="handleSelectWarehouseEntryBatch"
  90. >选择</el-button
  91. >
  92. </div>
  93. <div style="width: 100%; display: block">
  94. <el-form-item style="width: 100%">
  95. <el-table
  96. :data="goodsExchangeAddForm.product_list"
  97. border
  98. :cell-style="{ textAlign: 'center' }"
  99. :header-cell-style="{ textAlign: 'center' }"
  100. style="width: 100%; margin-top: 20px"
  101. >
  102. <el-table-column label="商品编号">
  103. <template slot-scope="scope">
  104. {{ scope.row.goods_vo.sn }}
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="商品名称">
  108. <template slot-scope="scope">
  109. {{ scope.row.goods_vo.name }}
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="条码">
  113. <template slot-scope="scope">
  114. <span v-if="id">{{ scope.row.product_vo.bar_code }}</span>
  115. <span v-else>{{ scope.row.bar_code }}</span>
  116. </template>
  117. </el-table-column>
  118. <el-table-column label="序列号">
  119. <template slot-scope="scope">
  120. <span v-if="id">{{ scope.row.product_vo.sn_code }}</span>
  121. <span v-else>{{ scope.row.sn_code }}</span>
  122. </template>
  123. </el-table-column>
  124. <el-table-column label="规格型号" v-if="id">
  125. <template slot-scope="scope">
  126. {{ scope.row.product_vo.spec_name.join("/") }}
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="规格型号" v-else>
  130. <template slot-scope="scope">
  131. {{ scope.row.spec_name.join("/") }}
  132. </template>
  133. </el-table-column>
  134. <el-table-column label="单位">
  135. <template slot-scope="scope">
  136. <span v-if="id">{{ scope.row.product_vo.unit }}</span>
  137. <span v-else>{{ scope.row.unit }}</span>
  138. </template>
  139. </el-table-column>
  140. <!-- <el-table-column label="订单数量">
  141. </el-table-column> -->
  142. <el-table-column label="入库数量">
  143. <template slot-scope="scope">
  144. <el-input-number
  145. v-model="scope.row.num"
  146. type="number"
  147. :min="0"
  148. :maxlength="20"
  149. :disabled="type === 'detail' || type === 'audit'"
  150. ></el-input-number>
  151. </template>
  152. </el-table-column>
  153. <!-- <el-table-column label="库存数量">
  154. <template slot-scope="scope">
  155. {{ scope.row.usable_stock }}
  156. </template>
  157. </el-table-column>
  158. <el-table-column label="差异">
  159. <template slot-scope="scope">
  160. {{ scope.row.num - scope.row.usable_stock || 0 }}
  161. </template>
  162. </el-table-column> -->
  163. <el-table-column
  164. label="操作"
  165. v-if="type !== 'detail' && type !== 'audit'"
  166. >
  167. <template slot-scope="scope">
  168. <el-button
  169. size="mini"
  170. type="danger"
  171. @click="
  172. goodsExchangeAddForm.product_list.splice(scope.$index, 1)
  173. "
  174. >删除</el-button
  175. >
  176. </template>
  177. </el-table-column>
  178. </el-table>
  179. </el-form-item>
  180. </div>
  181. </el-form>
  182. <div class="footer">
  183. <!-- <el-button v-if="type === 'audit'" type="primary" @click="handlePassGoodsExchange()">审核通过
  184. </el-button>
  185. <el-button v-if="type === 'audit'" type="danger" @click="dialogVisible = true">审核驳回
  186. </el-button> -->
  187. <el-button
  188. v-if="type !== 'audit' && type !== 'detail'"
  189. type="primary"
  190. @click="savegoodsExchangeAddForm"
  191. >保存
  192. </el-button>
  193. <el-button
  194. v-if="type !== 'audit' && type !== 'detail'"
  195. type="primary"
  196. @click="submitgoodsExchangeAddForm"
  197. >入库
  198. </el-button>
  199. <el-button @click="printIng" v-if="type == 'audit'">打印</el-button>
  200. <el-button @click="$router.back()">返回</el-button>
  201. </div>
  202. <el-dialog title="提示" :visible.sync="dialogVisible" width="30%">
  203. <el-form
  204. ref="goodsExchangeAddForm"
  205. :model="goodsExchangeAddForm"
  206. label-width="120px"
  207. inline
  208. style="width: 900px"
  209. >
  210. <el-form-item label="驳回原因" prop="reject_reason">
  211. <el-input
  212. v-model="goodsExchangeAddForm.reject_reason"
  213. type="textarea"
  214. :minlength="0"
  215. :maxlength="100"
  216. ></el-input>
  217. </el-form-item>
  218. </el-form>
  219. <span slot="footer" class="dialog-footer">
  220. <el-button @click="dialogVisible = false">取 消</el-button>
  221. <el-button type="primary" @click="handleRejectGoodsExchange()"
  222. >确 定</el-button
  223. >
  224. </span>
  225. </el-dialog>
  226. <el-dialog title="扫码入库" :visible.sync="scanDialogVisible" width="30%">
  227. <el-form
  228. ref="scanGoodsForm"
  229. :model="scanGoodsForm"
  230. label-width="120px"
  231. inline
  232. >
  233. <el-form-item label="条码" prop="bar_code">
  234. <el-input
  235. v-model="scanGoodsForm.bar_code"
  236. ref="input"
  237. @keyup.enter.native="toSearch()"
  238. @blur="blurCode()"
  239. :minlength="0"
  240. :maxlength="100"
  241. ></el-input>
  242. </el-form-item>
  243. <el-form-item label="序列号" prop="sn_code">
  244. <el-input
  245. v-model="scanGoodsForm.sn_code"
  246. :minlength="0"
  247. :maxlength="100"
  248. ></el-input>
  249. </el-form-item>
  250. </el-form>
  251. <span slot="footer" class="dialog-footer">
  252. <!-- <el-button @click="dialogVisible = false">取 消</el-button>
  253. <el-button type="primary" @click="handleRejectGoodsExchange()">确 定</el-button> -->
  254. </span>
  255. </el-dialog>
  256. <el-dialog
  257. title="入库商品"
  258. :visible.sync="goodsVisible"
  259. width="1000px"
  260. @close="closeGoosData"
  261. >
  262. <el-table
  263. :data="goodsData"
  264. border
  265. style="width: 100%"
  266. @selection-change="handleSelectionChange"
  267. >
  268. <el-table-column type="selection" width="55" />
  269. <el-table-column prop="" label="商品编号">
  270. <template slot-scope="scope">
  271. {{ scope.row.goods_vo.sn }}
  272. </template>
  273. </el-table-column>
  274. <el-table-column prop="bar_code" label="商品条码"> </el-table-column>
  275. <el-table-column prop="bar_code" label="序列号"></el-table-column>
  276. <el-table-column prop="" label="商品名称">
  277. <template slot-scope="scope">
  278. {{ scope.row.goods_vo.name }}
  279. </template>
  280. </el-table-column>
  281. <el-table-column prop="goods_style" label="规格型号">
  282. <template slot-scope="scope">
  283. {{ scope.row.spec_name.join("/") }}
  284. </template>
  285. </el-table-column>
  286. <el-table-column prop="unit" label="单位"> </el-table-column>
  287. <!-- <el-table-column prop="product_list.stock_num" label="库存数量"> </el-table-column> -->
  288. </el-table>
  289. <!-- <el-pagination
  290. slot="pagination"
  291. @size-change="handlePageSizeChange"
  292. @current-change="handlePageCurrentChange"
  293. :current-page="goodsData.page_no"
  294. :page-sizes="[10, 20, 50, 100]"
  295. :page-size="goodsData.page_size"
  296. layout="total, sizes, prev, pager, next, jumper"
  297. :total="goodsData.data_total"
  298. >
  299. </el-pagination> -->
  300. <span slot="footer" class="dialog-footer">
  301. <el-button @click="closeGoosData">取 消</el-button>
  302. <el-button type="primary" @click="submitGoosData()">确 定</el-button>
  303. </span>
  304. </el-dialog>
  305. <el-dialog
  306. title="订单列表"
  307. :visible.sync="orderVisible"
  308. width="1000px"
  309. @close="closeGoosData"
  310. >
  311. <el-table
  312. :data="orderList.data"
  313. border
  314. style="width: 100%"
  315. @selection-change="handleSelectionChange"
  316. >
  317. <el-table-column type="selection" width="55" />
  318. <el-table-column prop="" label="订单编号">
  319. <template slot-scope="scope">
  320. {{ scope.row.sn }}
  321. </template>
  322. </el-table-column>
  323. <!-- <el-table-column prop="member_id" label="客户">
  324. <template slot-scope="scope">{{
  325. memberType(scope.row.member_id)
  326. }}</template>
  327. </el-table-column>
  328. --> <el-table-column prop="order_time" label="下单时间">
  329. <template slot-scope="scope">{{
  330. scope.row.order_time | unixToDate
  331. }}</template>
  332. </el-table-column>
  333. <el-table-column prop="" label="仓库名称">
  334. <template slot-scope="scope">
  335. {{ warehouseName(scope.row.warehouse_id) }}
  336. </template>
  337. </el-table-column>
  338. <el-table-column prop="" label="配送方式">
  339. <template slot-scope="scope">{{
  340. deliveryType(scope.row.send_type)
  341. }}</template>
  342. </el-table-column>
  343. <!-- <el-table-column prop="pay_type" label="付款方式">
  344. <template slot-scope="scope">{{
  345. payType(scope.row.pay_type)
  346. }}</template>
  347. </el-table-column> -->
  348. <el-table-column prop="" label="实付金额">
  349. <template slot-scope="scope">{{
  350. "¥" + scope.row.pay_price
  351. }}</template>
  352. </el-table-column>
  353. <!-- <el-table-column prop="" label="订单状态">
  354. <template slot-scope="scope">
  355. {{ typeName(scope.row.status) }}
  356. </template>
  357. </el-table-column> -->
  358. </el-table>
  359. <el-pagination
  360. @size-change="handlePageSizeChange"
  361. @current-change="handlePageCurrentChange"
  362. :current-page="orderList.page_no"
  363. :page-sizes="[10, 20, 50, 100]"
  364. :page-size="orderList.page_size"
  365. layout="total, sizes, prev, pager, next, jumper"
  366. :total="orderList.data_total"
  367. >
  368. </el-pagination>
  369. <span slot="footer" class="dialog-footer">
  370. <el-button @click="closeOrder">取 消</el-button>
  371. <el-button type="primary">确 定</el-button>
  372. </span>
  373. </el-dialog>
  374. </div>
  375. </template>
  376. <script>
  377. import { mapGetters } from "vuex";
  378. import { Foundation, RegExp } from "~/ui-utils";
  379. import * as API_GoodsExchange from "@/api/goodsExchange";
  380. import * as API_Setting from "@/api/setting";
  381. import * as API_BasicSetting from "@/api/basicSetting";
  382. import * as API_Erp from "@/api/erp";
  383. import * as API_Auth from "@/api/auth";
  384. import * as API_order from "@/api/order";
  385. import * as API_Goods from "@/api/goods";
  386. import * as API_CollectingAccount from "@/api/collectingAccount";
  387. export default {
  388. name: "goodsExchangeAdd",
  389. data() {
  390. const checkPrice = (rule, value, callback) => {
  391. if (!value && value !== 0) {
  392. return callback(new Error("换货金额不能为空"));
  393. } else if (!RegExp.money.test(value)) {
  394. callback(new Error("请输入正整数或者两位小数"));
  395. } else if (parseFloat(value) > 99999999) {
  396. callback(new Error("换货金额设置超过上限值"));
  397. } else {
  398. callback();
  399. }
  400. };
  401. return {
  402. //分页
  403. params: {
  404. page_no: 1,
  405. page_size: 10,
  406. },
  407. typeList: [
  408. /* {
  409. real_name: "采购入库",
  410. id: "采购入库",
  411. },
  412. {
  413. real_name: "租赁返回",
  414. id: "租赁返回",
  415. },
  416. {
  417. real_name: "其他入库",
  418. id: "其他入库",
  419. }, */
  420. ],
  421. adminList: [],
  422. dialogVisible: false,
  423. warehouseList: [],
  424. deptList: [],
  425. deptListAll: [],
  426. orderList: [],
  427. id: "",
  428. type: "",
  429. /** 入库单表单*/
  430. goodsExchangeAddForm: {
  431. contract_product_list: [],
  432. /* additionalProp1: {
  433. barcode: "string",
  434. category_id: 0,
  435. category_name: "string",
  436. contract_id: 0,
  437. goods_id: 0,必填
  438. num: 0,
  439. price: 0,
  440. product_id: 0,//必填
  441. product_name: "string",
  442. product_sn: "string",
  443. specification: "string",
  444. stock_num: 0,
  445. tax_rate: 0,
  446. total_price: 0,
  447. unit: "string",
  448. },
  449. additionalProp2: {
  450. barcode: "string",
  451. category_id: 0,
  452. category_name: "string",
  453. contract_id: 0,
  454. goods_id: 0,
  455. num: 0,
  456. price: 0,
  457. product_id: 0,
  458. product_name: "string",
  459. product_sn: "string",
  460. specification: "string",
  461. stock_num: 0,
  462. tax_rate: 0,
  463. total_price: 0,
  464. unit: "string",
  465. },
  466. additionalProp3: {
  467. barcode: "string",
  468. category_id: 0,
  469. category_name: "string",
  470. contract_id: 0,
  471. goods_id: 0,
  472. num: 0,
  473. price: 0,
  474. product_id: 0,
  475. product_name: "string",
  476. product_sn: "string",
  477. specification: "string",
  478. stock_num: 0,
  479. tax_rate: 0,
  480. total_price: 0,
  481. unit: "string",
  482. }, */
  483. product_list: [],
  484. },
  485. /** 校验规则 */
  486. goodsExchangeAddFormRule: {
  487. warehouse_id: [
  488. { required: true, message: "请选择入库仓库", trigger: "change" },
  489. ],
  490. type: [
  491. { required: true, message: "请选择入库类型", trigger: "change" },
  492. ],
  493. // order_id: [
  494. // { required: true, message: "请输入订单编号", trigger: "blur" },
  495. // ],
  496. // change_amount: [
  497. // { required: true, message: '请输入换货金额', trigger: 'blur' },
  498. // { validator: checkPrice, trigger: 'blur' }
  499. // ]
  500. },
  501. warehouseProduct: null,
  502. scanDialogVisible: false,
  503. scanGoodsForm: {},
  504. routeName: "",
  505. //出入库
  506. sttorageType: "",
  507. // 出库商品明细
  508. goodsVisible: false,
  509. goodsData: [],
  510. // 暂存已勾选商品
  511. goodsList: [],
  512. //订单列表
  513. orderVisible: false,
  514. deliveryTypeList: [
  515. {
  516. code: "express",
  517. name: "快递配送",
  518. },
  519. {
  520. code: "self_pick",
  521. name: "门店自提",
  522. },
  523. ],
  524. };
  525. },
  526. mounted() {
  527. this.$nextTick(() => {
  528. this.$refs.order.focus();
  529. });
  530. this.routeName = this.$route.name;
  531. this.sttorageType = this.$route.params.type;
  532. this.GET_WarehouseList();
  533. this.GET_DeptList();
  534. },
  535. watch: {
  536. $route: {
  537. immediate: true,
  538. handler(newVal) {
  539. if (this.$route.name === "goodsExchangeEdit") {
  540. this.type = "edit";
  541. } else if (this.$route.name === "goodsExchangeAudit") {
  542. this.type = "audit";
  543. } else if (this.$route.name === "goodsExchangeReturn") {
  544. this.type = "return";
  545. } else if (this.$route.name === "goodsExchangeAdd") {
  546. this.type = "add";
  547. this.goodsExchangeAddForm = {
  548. change_amount: 0,
  549. change_list: [],
  550. return_list: [],
  551. product_list: [],
  552. handled_by_id: this.user.uid,
  553. dept_id: this.user.dept_id,
  554. };
  555. // this.goodsExchangeAddForm.handled_by_id = this.user.uid
  556. // this.goodsExchangeAddForm.dept_id = this.user.dept_id
  557. this.GET_WarehouseList({ dept_id: this.user.dept_id });
  558. this.$set(
  559. this.goodsExchangeAddForm,
  560. "change_time",
  561. new Date().getTime()
  562. );
  563. } else if (this.$route.name === "goodsExchangeDetail") {
  564. this.type = "detail";
  565. }
  566. if (this.$route.params.id) {
  567. this.id = this.$route.params.id;
  568. this.GET_goodsExchangeAddDetail();
  569. }
  570. this.GET_AdministratorList();
  571. },
  572. },
  573. },
  574. computed: {
  575. ...mapGetters(["user"]),
  576. },
  577. methods: {
  578. orderBtn() {
  579. API_order.getOrderList(this.params).then((res) => {
  580. this.orderList = res;
  581. this.orderVisible = true;
  582. });
  583. },
  584. closeOrder(){
  585. this.orderVisible = false;
  586. },
  587. /** 分页大小发生改变 */
  588. handlePageSizeChange(size) {
  589. this.params.page_size = size;
  590. API_order.getOrderList(this.params).then((res) => {
  591. this.orderList = res;
  592. });
  593. },
  594. /** 分页页数发生改变 */
  595. handlePageCurrentChange(page) {
  596. this.params.page_no = page;
  597. API_order.getOrderList(this.params).then((res) => {
  598. this.orderList = res;
  599. });
  600. },
  601. /* 订单客户信息 */
  602. memberType(val) {
  603. let name = "";
  604. API_BasicSetting.customer(this.params).then((response) => {
  605. response.data.map((el) => {
  606. if (el.id == val) {
  607. return (name = el.name);
  608. }
  609. });
  610. return name;
  611. });
  612. },
  613. //获取仓库名称
  614. warehouseName(val) {
  615. let name = "";
  616. this.warehouseList.map((el) => {
  617. if (el.id == val) {
  618. return (name = el.name);
  619. }
  620. });
  621. return name;
  622. },
  623. //配送方式名称
  624. deliveryType(val) {
  625. let name = "";
  626. this.deliveryTypeList.map((el) => {
  627. if (el.code == val) {
  628. return (name = el.name);
  629. }
  630. });
  631. return name;
  632. },
  633. //获取付款方式
  634. payType(val) {
  635. let name = "";
  636. API_CollectingAccount.getList({
  637. page_no: 1,
  638. page_size: -1,
  639. enable_flag: true,
  640. }).then((response) => {
  641. response.data.map((el) => {
  642. if (el.id == val) {
  643. return (name = el.name);
  644. }
  645. });
  646. return name;
  647. });
  648. },
  649. //获取订单状态大小写转换.toUpperCase()
  650. typeName(val) {
  651. let name = "";
  652. this.$nextTick(() => {
  653. API_Setting.getPage({ dictType: "order_status" }).then((res) => {
  654. res.data.map((el) => {
  655. if (el.value == val) {
  656. name = el.label;
  657. console.log(name);
  658. return name;
  659. }
  660. });
  661. });
  662. });
  663. },
  664. // 根据条码 序列号查询商品
  665. blurCode() {
  666. if (
  667. this.scanGoodsForm.bar_code !== undefined ||
  668. this.scanGoodsForm.sn_code !== undefined
  669. ) {
  670. // 通过列表查询商品详细信息
  671. API_Goods.getGoodsList({
  672. barcode: this.scanGoodsForm.bar_code,
  673. sncode: this.scanGoodsForm.sn_code,
  674. }).then((res) => {
  675. console.log(res);
  676. this.goodsExchangeAddForm.contract_product_list = res.data;
  677. this.scanDialogVisible = false;
  678. });
  679. }
  680. },
  681. // 查询订单编号
  682. blurUsername() {
  683. if (this.goodsExchangeAddForm.sn !== undefined) {
  684. API_order.getOrderList({ sn: this.goodsExchangeAddForm.order_id }).then(
  685. (res) => {
  686. console.log(res.data);
  687. if (res.data.length !== 0) return;
  688. this.goodsExchangeAddForm.order_id = Number(res.data[0].id);
  689. this.goodsExchangeAddForm.contract_product_list = res.data;
  690. }
  691. );
  692. } /* else{
  693. this.$message.error("请填写订单编号")
  694. } */
  695. },
  696. /* 通过id查询商品信息
  697. orderInfo(id){
  698. API_
  699. },*/
  700. handleSelectionChange(val) {
  701. this.goodsList = val.map((el) => {
  702. el.product_id = el.id;
  703. el.goods_id = el.id;
  704. return el;
  705. });
  706. },
  707. // 保存已选商品
  708. submitGoosData() {
  709. if (this.goodsList.length >= 1) {
  710. /* let ids=[]
  711. const param_list={
  712. warehouse_id:this.goodsExchangeAddForm.warehouse_id,
  713. good_ids:ids
  714. }
  715. this.goodsList.forEach(el=>{
  716. ids.push(el.id)
  717. })
  718. API_GoodsExchange.getStockByWarehouseGood(param_list).then(res=>{
  719. res.map(el=>{
  720. el.product_id=el.id
  721. el.goods_id=el.id
  722. })
  723. this.goodsExchangeAddForm.product_list = res;
  724. this.goodsExchangeAddForm.contract_product_list = res;
  725. console.log(res);
  726. }) */
  727. this.goodsExchangeAddForm.product_list = this.goodsList;
  728. console.log(this.goodsExchangeAddForm.product_list);
  729. this.goodsVisible = false;
  730. } else {
  731. this.$message.error("请选择商品信息");
  732. }
  733. },
  734. // 关闭商品明细
  735. closeGoosData() {
  736. this.goodsVisible = false;
  737. },
  738. // 打印功能
  739. printIng() {},
  740. toSearch() {
  741. API_GoodsExchange.getGoodsInfo({
  742. barcode: this.scanGoodsForm.bar_code,
  743. }).then((res) => {
  744. console.log(res);
  745. });
  746. },
  747. // 扫码入库
  748. scanCode() {
  749. this.scanDialogVisible = true;
  750. this.$nextTick(() => {
  751. this.$refs.input.focus();
  752. });
  753. },
  754. /** 获取人员列表 */
  755. GET_AdministratorList() {
  756. API_Auth.getAdministratorList({
  757. page_no: 1,
  758. page_size: 9999,
  759. user_state: 0,
  760. }).then((response) => {
  761. this.adminList = response.data;
  762. });
  763. },
  764. /** 清除已选商品明细 */
  765. cleanGoodsList() {
  766. // 切换部门或仓库需要清除已选对应仓库下的商品数据 change_list
  767. this.goodsExchangeAddForm.contract_product_list = [];
  768. this.goodsExchangeAddForm.product_list = [];
  769. },
  770. changewarehouseList(e) {
  771. this.$set(this.goodsExchangeAddForm, "warehouse_id", "");
  772. this.GET_WarehouseList({ dept_id: e });
  773. this.cleanGoodsList();
  774. },
  775. /** 审核-通过 */
  776. handlePassGoodsExchange() {
  777. if (this.goodsExchangeAddForm.check_amount_same === false) {
  778. this.$confirm(this.goodsExchangeAddForm.diff_amount_message, "提示", {
  779. type: "warning",
  780. })
  781. .then(() => {
  782. this.$confirm("确定通过吗?", "提示", { type: "warning" })
  783. .then(() => {
  784. API_GoodsExchange.auditGoodsExchange(this.id, {
  785. status: "PASS",
  786. }).then(() => {
  787. this.$message.success("已通过!");
  788. const { callback } = this.$route.params;
  789. if (typeof callback === "function") callback();
  790. this.$store.dispatch("delCurrentViews", {
  791. view: this.$route,
  792. $router: this.$router,
  793. });
  794. this.$router.push({ name: "goodsExchange" });
  795. });
  796. })
  797. .catch(() => {});
  798. })
  799. .catch(() => {});
  800. } else {
  801. this.$confirm("确定通过吗?", "提示", { type: "warning" })
  802. .then(() => {
  803. API_GoodsExchange.auditGoodsExchange(this.id, {
  804. status: "PASS",
  805. }).then(() => {
  806. this.$message.success("已通过!");
  807. const { callback } = this.$route.params;
  808. if (typeof callback === "function") callback();
  809. this.$store.dispatch("delCurrentViews", {
  810. view: this.$route,
  811. $router: this.$router,
  812. });
  813. this.$router.push({ name: "goodsExchange" });
  814. });
  815. })
  816. .catch(() => {});
  817. }
  818. },
  819. /** 审核-拒绝 */
  820. handleRejectGoodsExchange() {
  821. this.$confirm("确定拒绝吗?", "提示", { type: "warning" })
  822. .then(() => {
  823. API_GoodsExchange.auditGoodsExchange(this.id, {
  824. status: "REJECT",
  825. reject_reason: this.goodsExchangeAddForm.reject_reason,
  826. }).then(() => {
  827. this.$message.success("已拒绝!");
  828. this.dialogVisible = false;
  829. const { callback } = this.$route.params;
  830. if (typeof callback === "function") callback();
  831. this.$store.dispatch("delCurrentViews", {
  832. view: this.$route,
  833. $router: this.$router,
  834. });
  835. this.$router.push({ name: "goodsExchange" });
  836. });
  837. })
  838. .catch(() => {});
  839. },
  840. /** 获取仓库 */
  841. GET_WarehouseList(e) {
  842. API_BasicSetting.getWarehouseListAll().then((response) => {
  843. this.warehouseList = response;
  844. });
  845. API_Setting.getPage({ dictType: "warehouse_entry_type" }).then((res) => {
  846. this.typeList = res.data;
  847. });
  848. },
  849. //保存
  850. savegoodsExchangeAddForm() {
  851. this.$refs["goodsExchangeAddForm"].validate((valid) => {
  852. if (valid) {
  853. const { id } = this.goodsExchangeAddForm;
  854. const params = this.MixinClone(this.goodsExchangeAddForm);
  855. params.handled_by = this.deptListAll;
  856. API_order.getOrderList({ sn: this.goodsExchangeAddForm.sn }).then(
  857. (res) => {
  858. params.order_id = Number(res.data[0].id);
  859. }
  860. );
  861. params.staff_name = this.goodsExchangeAddForm.distribution_name;
  862. if (params.warehouse_id) {
  863. params.warehouse_name = this.warehouseList.find(
  864. (ware) => ware.id === params.warehouse_id
  865. ).name;
  866. }
  867. if (params.handled_by_id) {
  868. params.handled_by = this.adminList.find(
  869. (admin) => admin.id === params.handled_by_id
  870. ).real_name;
  871. }
  872. params.change_time = Math.floor(params.change_time / 1000);
  873. //类型
  874. params.save_or_submit = "save";
  875. if (!params.product_list.length) {
  876. this.$message.error("请选择商品!");
  877. return;
  878. }
  879. if (this.$route.name === "editInventory") {
  880. API_GoodsExchange.editWarehouseEntry(id, params).then(
  881. (response) => {
  882. this.$message.success("修改成功!");
  883. const { callback } = this.$route.params;
  884. if (typeof callback === "function") callback();
  885. this.$store.dispatch("delCurrentViews", {
  886. view: this.$route,
  887. $router: this.$router,
  888. });
  889. this.$router.push({
  890. name: "goodsExchange",
  891. params: { type: "second" },
  892. });
  893. }
  894. );
  895. } else if (this.$route.name === "addInventory") {
  896. // 新增入库
  897. API_GoodsExchange.warehouseEntry(params).then(() => {
  898. this.$message.success("添加成功!");
  899. const { callback } = this.$route.params;
  900. if (typeof callback === "function") callback();
  901. this.$store.dispatch("delCurrentViews", {
  902. view: this.$route,
  903. $router: this.$router,
  904. });
  905. this.$router.push({
  906. name: "goodsExchange",
  907. params: { type: "second" },
  908. });
  909. });
  910. }
  911. }
  912. });
  913. },
  914. //入库
  915. submitgoodsExchangeAddForm() {
  916. this.$refs["goodsExchangeAddForm"].validate((valid) => {
  917. if (valid) {
  918. const { id } = this.goodsExchangeAddForm;
  919. const params = this.MixinClone(this.goodsExchangeAddForm);
  920. params.handled_by = this.deptListAll;
  921. API_order.getOrderList({ sn: this.goodsExchangeAddForm.sn }).then(
  922. (res) => {
  923. console.log(res.data);
  924. params.order_id = Number(res.data[0].id);
  925. }
  926. );
  927. params.staff_name = this.goodsExchangeAddForm.distribution_name;
  928. if (params.warehouse_id) {
  929. params.warehouse_name = this.warehouseList.find(
  930. (ware) => ware.id === params.warehouse_id
  931. ).name;
  932. }
  933. if (params.handled_by_id) {
  934. params.handled_by = this.adminList.find(
  935. (admin) => admin.id === params.handled_by_id
  936. ).real_name;
  937. }
  938. params.change_time = Math.floor(params.change_time / 1000);
  939. params.save_or_submit = "submit";
  940. if (!params.product_list.length) {
  941. this.$message.error("请选择商品!");
  942. return;
  943. }
  944. /* */ if (this.$route.name === "editInventory") {
  945. /* params.contract_product_list.map(el=>{
  946. el.product_id=el.id
  947. el.goods_id=el.id
  948. })
  949. params.product_list.map(el=>{
  950. el.product_id=el.id
  951. el.goods_id=el.id
  952. }) */
  953. API_GoodsExchange.editWarehouseEntry(id, params).then(
  954. (response) => {
  955. this.$message.success("修改成功!");
  956. const { callback } = this.$route.params;
  957. if (typeof callback === "function") callback();
  958. this.$store.dispatch("delCurrentViews", {
  959. view: this.$route,
  960. $router: this.$router,
  961. });
  962. this.$router.push({
  963. name: "goodsExchange",
  964. params: { type: "second" },
  965. });
  966. }
  967. );
  968. } else if (this.$route.name === "addInventory") {
  969. // 新增入库
  970. API_GoodsExchange.warehouseEntry(params).then(() => {
  971. this.$message.success("添加成功!");
  972. const { callback } = this.$route.params;
  973. if (typeof callback === "function") callback();
  974. this.$store.dispatch("delCurrentViews", {
  975. view: this.$route,
  976. $router: this.$router,
  977. });
  978. this.$router.push({
  979. name: "goodsExchange",
  980. params: { type: "second" },
  981. });
  982. });
  983. }
  984. }
  985. });
  986. },
  987. /* returngoodsExchangeAddForm() {
  988. const { id } = this.goodsExchangeAddForm;
  989. const params = this.MixinClone(this.goodsExchangeAddForm);
  990. params.dept_name = this.deptListAll.find(
  991. (dept) => dept.id === params.dept_id
  992. ).name;
  993. params.staff_name = this.goodsExchangeAddForm.distribution_name;
  994. params.warehouse_name = this.warehouseList.find(
  995. (ware) => ware.id === params.warehouse_id
  996. ).name;
  997. params.change_time = Math.floor(params.change_time / 1000);
  998. params.product_list = params.product_list.map((item) => {
  999. //change_list
  1000. item.product_sn = item.product_sn;
  1001. item.product_name = item.product_name;
  1002. item.specification = item.product_specification;
  1003. item.product_id = item.product_id;
  1004. item.unit = item.unit;
  1005. item.stock_sn = item.sn;
  1006. item.stock_num = item.remain_num;
  1007. item.cost_price = item.product_cost_price;
  1008. return item;
  1009. });
  1010. API_GoodsExchange.returnGoodsExchange(id, params).then(() => {
  1011. this.$message.success("换货成功!");
  1012. const { callback } = this.$route.params;
  1013. if (typeof callback === "function") callback();
  1014. this.$store.dispatch("delCurrentViews", {
  1015. view: this.$route,
  1016. $router: this.$router,
  1017. });
  1018. this.$router.push({ name: "goodsExchange" });
  1019. });
  1020. }, */
  1021. // 选择出库单
  1022. async handleSelectWarehouseEntryBatch() {
  1023. if (!this.goodsExchangeAddForm.warehouse_id) {
  1024. this.$message.error("请先选择仓库!");
  1025. return;
  1026. }
  1027. API_GoodsExchange.getGoodsInfo(this.params).then((res) => {
  1028. let item = {};
  1029. res.map((el) => {
  1030. item.sn = el.goods_vo.sn;
  1031. item.name = el.goods_vo.name;
  1032. /* item. */
  1033. return item;
  1034. });
  1035. this.goodsData = res;
  1036. this.goodsVisible = true;
  1037. });
  1038. /* if (!this.goodsExchangeAddForm.warehouse_id) {
  1039. this.$message.error('请先选择仓库!')
  1040. return
  1041. }
  1042. const goodsData = await this.$EnwarehouseEntryBatch({
  1043. goodsApi: "/admin/erp/goods",
  1044. warehouseList: this.warehouseList,
  1045. //change_list
  1046. selectedIds: this.id
  1047. ? this.goodsExchangeAddForm.product_list &&
  1048. this.goodsExchangeAddForm.product_list.map((item) => item.id)
  1049. : this.goodsExchangeAddForm.product_list.map((item) => item.id),
  1050. purchasePlanApiParams: {
  1051. warehouse_id: this.goodsExchangeAddForm.warehouse_id,
  1052. },
  1053. });
  1054. this.goodsExchangeAddForm.warehouse_id = goodsData.warehouse_id;
  1055. this.goodsExchangeAddForm.product_list = goodsData.purchasePlans.map(
  1056. (item) => {
  1057. item.amount = item.entry_price;
  1058. item.product_sn = item.product_sn;
  1059. item.product_name = item.product_name;
  1060. item.specification = item.product_specification;
  1061. item.product_id = item.product_id;
  1062. item.unit = item.product_unit;
  1063. item.stock_sn = item.warehouse_entry_sn;
  1064. item.stock_id = item.warehouse_entry_id;
  1065. item.stock_batch_sn = item.sn;
  1066. item.stock_batch_id = item.id;
  1067. item.cost_price = item.product_cost_price;
  1068. return item;
  1069. }
  1070. );
  1071. this.goodsExchangeAddForm.change_amount =
  1072. this.goodsExchangeAddForm.product_list.reduce(
  1073. (sum, obj) => sum + obj.entry_price,
  1074. 0
  1075. ); */
  1076. },
  1077. /** 选择订单编号 */
  1078. async handleSelectOrderSn() {
  1079. const orders = await this.$EnPickerOrder({
  1080. orderApi: "admin/erp/order",
  1081. selectedIds: [this.goodsExchangeAddForm.order_sn],
  1082. limit: 1,
  1083. });
  1084. this.$set(
  1085. this.goodsExchangeAddForm,
  1086. "distribution_name",
  1087. orders[0].distribution_name
  1088. );
  1089. const orderIds = orders.map((v) => v.sn);
  1090. this.$set(this.goodsExchangeAddForm, "order_sn", orderIds.join(","));
  1091. this.GET_WarehouseOutProduct();
  1092. },
  1093. /** 获取入库单商品明细 */
  1094. async GET_WarehouseOutProduct() {
  1095. const res = await API_Erp.getWarehouseOutProduct({
  1096. order_sn: this.goodsExchangeAddForm.order_sn,
  1097. });
  1098. this.goodsExchangeAddForm.return_list = res.data.map((item) => {
  1099. item.amount = item.product_price;
  1100. item.product_sn = item.product_sn;
  1101. item.product_name = item.product_name;
  1102. item.specification = item.product_specification;
  1103. item.product_id = item.product_id;
  1104. item.unit = item.product_unit;
  1105. item.num = item.return_num;
  1106. item.stock_sn = item.warehouse_entry_sn;
  1107. item.cost_price = item.product_cost_price;
  1108. return item;
  1109. });
  1110. },
  1111. /** 获取部门 */
  1112. GET_DeptList() {
  1113. API_GoodsExchange.getInfo().then((response) => {
  1114. this.deptListAll = response;
  1115. this.deptListAll.password = "";
  1116. });
  1117. },
  1118. /** 切换仓库 */
  1119. handleChangeWareHouse(val) {
  1120. //this.goodsExchangeAddForm.product_list = []change_list
  1121. },
  1122. /** 获取详情页面数据 */
  1123. GET_goodsExchangeAddDetail() {
  1124. this.$nextTick(() => {
  1125. API_GoodsExchange.getGoodsExchangeInfo(this.id).then((response) => {
  1126. this.goodsExchangeAddForm = response;
  1127. this.GET_WarehouseList({ dept_id: response.dept_id });
  1128. this.goodsExchangeAddForm.change_time = Math.floor(
  1129. this.goodsExchangeAddForm.change_time * 1000
  1130. );
  1131. this.goodsExchangeAddForm.distribution_name = response.staff_name;
  1132. this.goodsExchangeAddForm.product_list =
  1133. response.product_list; /* .map((item) => {
  1134. //change_list
  1135. item.name=item.goods_do.name
  1136. item.sn=item.goods_do.sn
  1137. item.sn_code=item.goods_do.sn_code
  1138. item.bar_code=item.goods_do.bar_code
  1139. item.entry_price = item.amount;
  1140. item.product_specification = item.specification;
  1141. item.product_unit = item.unit;
  1142. item.warehouse_entry_sn = item.stock_sn;
  1143. return item;
  1144. }); */
  1145. /* this.goodsExchangeAddForm.return_list = response.return_list.map(
  1146. (item) => {
  1147. item.product_price = item.amount;
  1148. item.product_specification = item.specification;
  1149. item.product_unit = item.unit;
  1150. item.return_num = item.num;
  1151. item.warehouse_entry_sn = item.stock_sn;
  1152. return item;
  1153. }
  1154. ); */
  1155. // this.GET_WarehouseOutProduct()
  1156. });
  1157. });
  1158. },
  1159. },
  1160. };
  1161. </script>
  1162. <style type="text/scss" lang="scss" scoped>
  1163. /deep/ {
  1164. }
  1165. /** 底部步骤 */
  1166. .footer {
  1167. width: 100%;
  1168. padding: 10px;
  1169. bottom: 0px;
  1170. text-align: center;
  1171. z-index: 999;
  1172. }
  1173. .mx {
  1174. display: flex;
  1175. align-items: center;
  1176. width: 100%;
  1177. .button {
  1178. margin-left: 10px;
  1179. }
  1180. }
  1181. .change-form {
  1182. display: flex;
  1183. justify-content: flex-start;
  1184. align-items: flex-start;
  1185. flex-wrap: wrap;
  1186. min-width: 900px;
  1187. .change-form-item {
  1188. width: 30%;
  1189. margin: 0 10px 20px 0;
  1190. display: flex;
  1191. flex-direction: row;
  1192. flex-wrap: nowrap;
  1193. }
  1194. /deep/ {
  1195. .el-form-item__content {
  1196. flex: 1;
  1197. width: 100%;
  1198. }
  1199. .el-date-editor,
  1200. .el-cascader,
  1201. .el-select {
  1202. width: 100%;
  1203. }
  1204. }
  1205. }
  1206. .bg-in-stock {
  1207. background-color: #fff;
  1208. margin: 10px;
  1209. padding: 25px;
  1210. }
  1211. .goods-info {
  1212. display: flex;
  1213. .goods-name-box {
  1214. text-align: left;
  1215. .goods-name {
  1216. text-overflow: ellipsis;
  1217. display: -webkit-box;
  1218. -webkit-line-clamp: 2;
  1219. -webkit-box-orient: vertical;
  1220. overflow: hidden;
  1221. line-height: 16px;
  1222. }
  1223. .specs {
  1224. color: #999999;
  1225. }
  1226. }
  1227. }
  1228. /deep/ {
  1229. .el-input--suffix .el-input__inner {
  1230. padding-right: 10px;
  1231. }
  1232. .error-input {
  1233. .el-input__inner {
  1234. border: 1px solid red;
  1235. }
  1236. }
  1237. }
  1238. </style>