addInventory.vue 53 KB

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