addInventory.vue 49 KB

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