You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1124 lines
38 KiB

​
1 year ago
​
1 year ago
​
1 year ago
1 year ago
​
1 year ago
3 months ago
​
3 months ago
​
​
​
​
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
​
​
​
​
​
​
​
​
​
1 year ago
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
​
1 year ago
1 year ago
​
​
​
​
​
​
​
1 year ago
​
​
​
​
1 year ago
​
​
​
​
​
1 year ago
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
​
​
1 year ago
1 year ago
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
3 months ago
1 year ago
​
​
​
3 months ago
1 year ago
​
1 year ago
1 year ago
​
​
​
​
​
​
​
​
​
1 year ago
1 year ago
​
​
​
​
​
1 year ago
1 year ago
​
​
3 months ago
1 year ago
1 year ago
​
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
3 months ago
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
3 months ago
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
3 months ago
​
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
3 months ago
​
​
3 months ago
​
​
​
2 months ago
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <template>
  2. <div class="mod-config" style="margin-top: 10px">
  3. <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
  4. <el-form-item>
  5. <el-input v-model="dataForm.partNo" placeholder="物料编码" clearable @keyup.enter.native="getDataList()"></el-input>
  6. </el-form-item>
  7. <el-form-item>
  8. <el-input v-model="dataForm.batchNo" placeholder="批次号" clearable @keyup.enter.native="getDataList()"></el-input>
  9. </el-form-item>
  10. <el-form-item>
  11. <el-input v-model="dataForm.locationId" placeholder="库位" clearable @keyup.enter.native="getDataList()"></el-input>
  12. </el-form-item>
  13. <el-form-item>
  14. <el-input v-model="dataForm.descriptionLike" placeholder="物料描述" clearable @keyup.enter.native="getDataList()"></el-input>
  15. </el-form-item>
  16. <el-form-item>
  17. <el-input v-model="dataForm.minUnPrintQty" placeholder="最小未打印数量" type="number" clearable @keyup.enter.native="getDataList()"></el-input>
  18. </el-form-item>
  19. <el-form-item>
  20. <el-button @click="getDataList()">{{ $t('warehouse.common.search') }}</el-button>
  21. <el-button @click="resetForm()">{{ $t('warehouse.common.reset') }}</el-button>
  22. <el-button type="primary" @click="batchCreateHu()">批量创建HU</el-button>
  23. <el-button type="success" @click="openImportDialog()">导入Excel</el-button>
  24. <el-button type="danger" @click="batchDeleteInventory()">{{ $t('warehouse.common.batchDelete') }}</el-button>
  25. </el-form-item>
  26. </el-form>
  27. <el-table
  28. :data="dataList"
  29. border
  30. :height="height"
  31. v-loading="dataListLoading"
  32. @selection-change="selectionChangeHandle"
  33. style="width: 100%;">
  34. <el-table-column
  35. type="selection"
  36. header-align="center"
  37. align="center"
  38. width="50">
  39. </el-table-column>
  40. <el-table-column
  41. prop="site"
  42. header-align="center"
  43. align="center"
  44. label="工厂编码">
  45. </el-table-column>
  46. <el-table-column
  47. prop="warehouseId"
  48. header-align="center"
  49. align="center"
  50. label="仓库">
  51. </el-table-column>
  52. <el-table-column
  53. prop="partNo"
  54. header-align="center"
  55. align="center"
  56. label="物料编码">
  57. </el-table-column>
  58. <el-table-column
  59. prop="description"
  60. header-align="center"
  61. align="center"
  62. label="物料描述">
  63. </el-table-column>
  64. <el-table-column
  65. prop="umid"
  66. header-align="center"
  67. align="center"
  68. label="单位">
  69. </el-table-column>
  70. <el-table-column
  71. prop="batchNo"
  72. header-align="center"
  73. align="center"
  74. label="批次号">
  75. </el-table-column>
  76. <el-table-column
  77. prop="wdr"
  78. header-align="center"
  79. align="center"
  80. label="WDR">
  81. </el-table-column>
  82. <el-table-column
  83. prop="locationId"
  84. header-align="center"
  85. align="center"
  86. label="库位">
  87. </el-table-column>
  88. <el-table-column
  89. prop="qtyOnHand"
  90. header-align="center"
  91. align="center"
  92. label="现有库存">
  93. </el-table-column>
  94. <el-table-column
  95. prop="printQty"
  96. header-align="center"
  97. align="center"
  98. label="已打印数量">
  99. </el-table-column>
  100. <el-table-column
  101. prop="unPrintQty"
  102. header-align="center"
  103. align="center"
  104. label="未打印数量">
  105. </el-table-column>
  106. <el-table-column
  107. prop="manufactureDate"
  108. header-align="center"
  109. align="center"
  110. label="生产日期"
  111. min-width="120">
  112. <template slot-scope="scope">
  113. {{ formatDate(scope.row.manufactureDate) }}
  114. </template>
  115. </el-table-column>
  116. <el-table-column
  117. prop="expiredDate"
  118. header-align="center"
  119. align="center"
  120. label="失效日期"
  121. min-width="120">
  122. <template slot-scope="scope">
  123. {{ formatDate(scope.row.expiredDate) }}
  124. </template>
  125. </el-table-column>
  126. <el-table-column
  127. fixed="right"
  128. header-align="center"
  129. align="center"
  130. width="200"
  131. label="操作">
  132. <template slot-scope="scope">
  133. <a type="text" @click="createHuHandle(scope.row)">创建HU</a>
  134. <a type="text" @click="editPrintQtyHandle(scope.row)" style="color: #409EFF;">修改已打印数量</a>
  135. </template>
  136. </el-table-column>
  137. </el-table>
  138. <el-pagination
  139. @size-change="sizeChangeHandle"
  140. @current-change="currentChangeHandle"
  141. :current-page="pageIndex"
  142. :page-sizes="[ 20, 50, 100]"
  143. :page-size="pageSize"
  144. :total="totalPage"
  145. layout="total, sizes, prev, pager, next, jumper">
  146. </el-pagination>
  147. <!-- 修改已打印数量弹窗 -->
  148. <el-dialog
  149. title="修改已打印数量"
  150. :visible.sync="editPrintQtyVisible"
  151. width="400px"
  152. :close-on-click-modal="false">
  153. <el-form :model="editPrintQtyForm" :rules="editPrintQtyRules" class="edit-print-qty-form">
  154. <el-row :gutter="20">
  155. <el-col :span="12">
  156. <el-form-item label="物料编码" class="form-item-vertical">
  157. <el-input v-model="editPrintQtyForm.partNo" readonly></el-input>
  158. </el-form-item>
  159. </el-col>
  160. <el-col :span="12">
  161. <el-form-item label="批次号" class="form-item-vertical">
  162. <el-input v-model="editPrintQtyForm.batchNo" readonly></el-input>
  163. </el-form-item>
  164. </el-col>
  165. </el-row>
  166. <el-row :gutter="20">
  167. <el-col :span="12">
  168. <el-form-item label="库位" class="form-item-vertical">
  169. <el-input v-model="editPrintQtyForm.locationId" readonly></el-input>
  170. </el-form-item>
  171. </el-col>
  172. <el-col :span="12">
  173. <el-form-item label="WDR" class="form-item-vertical">
  174. <el-input v-model="editPrintQtyForm.wdr" readonly></el-input>
  175. </el-form-item>
  176. </el-col>
  177. </el-row>
  178. <el-row :gutter="20">
  179. <el-col :span="12">
  180. <el-form-item label="现有库存" class="form-item-vertical">
  181. <el-input v-model="editPrintQtyForm.qtyOnHand" readonly></el-input>
  182. </el-form-item>
  183. </el-col>
  184. <el-col :span="12">
  185. <el-form-item label="当前已打印" class="form-item-vertical">
  186. <el-input v-model="editPrintQtyForm.currentPrintQty" readonly></el-input>
  187. </el-form-item>
  188. </el-col>
  189. <el-col :span="12">
  190. <el-form-item label="未打印数量" class="form-item-vertical">
  191. <el-input v-model="editPrintQtyForm.unPrintQty" readonly></el-input>
  192. </el-form-item>
  193. </el-col>
  194. <el-col :span="12">
  195. <el-form-item label="已打印数量" prop="newPrintQty" class="form-item-vertical">
  196. <el-input
  197. v-model="editPrintQtyForm.newPrintQty"
  198. :min="0"
  199. :max="editPrintQtyForm.qtyOnHand"
  200. :precision="0"
  201. style="width: 100%"
  202. placeholder="请输入已打印数量">
  203. </el-input>
  204. </el-form-item>
  205. </el-col>
  206. </el-row>
  207. </el-form>
  208. <div slot="footer" class="dialog-footer">
  209. <el-button @click="editPrintQtyVisible = false">{{ $t('warehouse.common.cancel') }}</el-button>
  210. <el-button type="primary" @click="editPrintQtySubmit()" :loading="editPrintQtyLoading">确定修改</el-button>
  211. </div>
  212. </el-dialog>
  213. <!-- Excel导入对话框 -->
  214. <ifs-inventory-upload-excel ref="ifsInventoryUploadExcel" @refreshTable="getDataList"></ifs-inventory-upload-excel>
  215. <!-- 创建HU弹窗 -->
  216. <el-dialog
  217. title="创建HandlingUnit"
  218. :visible.sync="createHuVisible"
  219. width="400px"
  220. :close-on-click-modal="false">
  221. <el-form :model="createHuForm" ref="createHuForm" class="create-hu-form">
  222. <el-row :gutter="20">
  223. <el-col :span="12">
  224. <el-form-item label="物料编码" prop="partNo" class="form-item-vertical">
  225. <el-input v-model="createHuForm.partNo" readonly></el-input>
  226. </el-form-item>
  227. </el-col>
  228. <el-col :span="12">
  229. <el-form-item label="批次号" prop="batchNo" class="form-item-vertical">
  230. <el-input v-model="createHuForm.batchNo" readonly></el-input>
  231. </el-form-item>
  232. </el-col>
  233. </el-row>
  234. <el-row :gutter="20">
  235. <el-col :span="12">
  236. <el-form-item label="WDR" prop="wdr" class="form-item-vertical">
  237. <el-input v-model="createHuForm.wdr" readonly></el-input>
  238. </el-form-item>
  239. </el-col>
  240. <el-col :span="12">
  241. <el-form-item label="库位" prop="locationId" class="form-item-vertical">
  242. <el-input v-model="createHuForm.locationId" readonly></el-input>
  243. </el-form-item>
  244. </el-col>
  245. </el-row>
  246. <el-row :gutter="20">
  247. <el-col :span="8">
  248. <el-form-item label="库存数量" prop="qtyOnHand" class="form-item-vertical">
  249. <el-input v-model="createHuForm.qtyOnHand" readonly></el-input>
  250. </el-form-item>
  251. </el-col>
  252. <el-col :span="8">
  253. <el-form-item label="未打印数量" prop="unPrintQty" class="form-item-vertical">
  254. <el-input v-model="createHuForm.unPrintQty" readonly></el-input>
  255. </el-form-item>
  256. </el-col>
  257. <el-col :span="8">
  258. <el-form-item label="单位" prop="umid" class="form-item-vertical">
  259. <el-input v-model="createHuForm.umid" readonly></el-input>
  260. </el-form-item>
  261. </el-col>
  262. </el-row>
  263. <el-row :gutter="20">
  264. <el-col :span="24">
  265. <el-form-item label="物料描述" prop="partDesc" class="form-item-vertical">
  266. <el-input v-model="createHuForm.partDesc" readonly></el-input>
  267. </el-form-item>
  268. </el-col>
  269. </el-row>
  270. <el-row :gutter="20">
  271. <el-col :span="24">
  272. <el-form-item label="" prop="perPackageQty" class="form-item-vertical">
  273. <el-checkbox
  274. v-model="createHuForm.autoCalculate"
  275. @change="onAutoCalculateChange"
  276. style="margin-top: 5px;">
  277. 自动计算包装数和余数
  278. </el-checkbox>
  279. </el-form-item>
  280. </el-col>
  281. <el-col :span="12">
  282. <el-form-item label="单包装数量" prop="perPackageQty" class="form-item-vertical">
  283. <el-input
  284. v-model="createHuForm.perPackageQty"
  285. :min="0.01"
  286. :precision="2"
  287. placeholder="请输入单包装数量"
  288. @input="onPerPackageQtyChange">
  289. </el-input>
  290. </el-form-item>
  291. </el-col>
  292. <el-col :span="12">
  293. <el-form-item label="高度(mm)" prop="height" class="form-item-vertical">
  294. <el-input v-model="createHuForm.height"></el-input>
  295. </el-form-item>
  296. </el-col>
  297. <el-col :span="12">
  298. <el-form-item label="包装数" prop="packageCount" class="form-item-vertical">
  299. <el-input
  300. v-model="createHuForm.packageCount"
  301. type="number"
  302. :min="1"
  303. :placeholder="createHuForm.autoCalculate ? '自动计算' : '手动输入'"
  304. :readonly="createHuForm.autoCalculate"
  305. @input="onPackageCountChange">
  306. </el-input>
  307. <span style="font-size: 12px; color: #999;">
  308. {{ createHuForm.autoCalculate ? '自动计算' : '可手动输入' }}
  309. </span>
  310. </el-form-item>
  311. </el-col>
  312. <el-col :span="12">
  313. <el-form-item label="余数HU" prop="lastPackageQty" class="form-item-vertical">
  314. <el-input
  315. v-model="createHuForm.lastPackageQty"
  316. :placeholder="createHuForm.autoCalculate ? '自动计算' : '默认为0'"
  317. readonly
  318. @input="onLastPackageQtyChange">
  319. </el-input>
  320. <span style="font-size: 12px; color: #999;">
  321. {{ createHuForm.autoCalculate ? '自动计算' : '默认为0(不创建余数HU)' }}
  322. </span>
  323. </el-form-item>
  324. </el-col>
  325. </el-row>
  326. </el-form>
  327. <div slot="footer" class="dialog-footer" style="margin-top: 20px">
  328. <el-button @click="createHuVisible = false">{{ $t('warehouse.common.cancel') }}</el-button>
  329. <el-button type="primary" @click="createHuSubmit()" :loading="createHuLoading">创建并打印</el-button>
  330. </div>
  331. </el-dialog>
  332. </div>
  333. </template>
  334. <script>
  335. import { getInventoryStockList, createHandlingUnits, batchCreateHandlingUnits, printLabel, updatePrintQty,getPartAttributeInfo } from '@/api/warehouse/ifsInventoryInit'
  336. import IfsInventoryUploadExcel from './ifsInventory_upload_excel.vue'
  337. export default {
  338. components: {
  339. IfsInventoryUploadExcel
  340. },
  341. data () {
  342. return {
  343. dataForm: {
  344. partNo: '',
  345. batchNo: '',
  346. locationId: '',
  347. descriptionLike: '',
  348. minUnPrintQty: ''
  349. },
  350. dataList: [],
  351. pageIndex: 1,
  352. pageSize: 50,
  353. totalPage: 0,
  354. height: 500,
  355. dataListLoading: false,
  356. dataListSelections: [],
  357. editPrintQtyVisible: false,
  358. editPrintQtyLoading: false,
  359. editPrintQtyForm: {
  360. site: '',
  361. warehouseId: '',
  362. partNo: '',
  363. batchNo: '',
  364. locationId: '',
  365. wdr: '',
  366. qtyOnHand: 0,
  367. currentPrintQty: 0,
  368. unPrintQty: 0,
  369. newPrintQty: 0
  370. },
  371. createHuVisible: false,
  372. createHuLoading: false,
  373. createHuForm: {
  374. site: '',
  375. warehouseId: '',
  376. partNo: '',
  377. partDesc: '',
  378. batchNo: '',
  379. wdr: '',
  380. locationId: '',
  381. umid: '',
  382. qtyOnHand: 0,
  383. unPrintQty: 0,
  384. perPackageQty: '',
  385. packageCount: '',
  386. lastPackageQty: 0,
  387. height: '',
  388. autoCalculate: true // 默认自动计算
  389. },
  390. createHuRules: {
  391. perPackageQty: [
  392. { required: true, message: '单包装数量不能为空', trigger: 'blur' },
  393. { type: 'number', min: 0.01, message: '单包装数量必须大于0', trigger: 'blur' }
  394. ],
  395. packageCount: [
  396. { required: true, message: '包装数不能为空', trigger: 'blur' },
  397. { type: 'number', min: 1, message: '包装数必须大于等于1', trigger: 'blur' }
  398. ]
  399. },
  400. // 打印相关配置
  401. reportId: 'HU_LABEL',
  402. zplCode: '',
  403. paperSize: 'A4',
  404. orientation: 'Portrait',
  405. dpi: 300
  406. }
  407. },
  408. activated () {
  409. this.getDataList()
  410. },
  411. methods: {
  412. // 获取数据列表
  413. getDataList () {
  414. this.dataListLoading = true
  415. const params = {
  416. page: this.pageIndex,
  417. size: this.pageSize,
  418. site: localStorage.getItem('site'),
  419. ...this.dataForm
  420. }
  421. getInventoryStockList(params).then(({ data }) => {
  422. if (data && data.code === 0) {
  423. this.dataList = data.page.list
  424. this.totalPage = data.page.totalCount
  425. } else {
  426. this.dataList = []
  427. this.totalPage = 0
  428. }
  429. this.dataListLoading = false
  430. }).catch(() => {
  431. this.dataListLoading = false
  432. })
  433. },
  434. // 每页数
  435. sizeChangeHandle (val) {
  436. this.pageSize = val
  437. this.pageIndex = 1
  438. this.getDataList()
  439. },
  440. // 当前页
  441. currentChangeHandle (val) {
  442. this.pageIndex = val
  443. this.getDataList()
  444. },
  445. // 多选
  446. selectionChangeHandle (val) {
  447. this.dataListSelections = val
  448. },
  449. // 修改已打印数量
  450. editPrintQtyHandle (row) {
  451. this.editPrintQtyVisible = true
  452. this.editPrintQtyForm = {
  453. site: row.site,
  454. warehouseId: row.warehouseId,
  455. partNo: row.partNo,
  456. batchNo: row.batchNo,
  457. locationId: row.locationId,
  458. wdr: row.wdr,
  459. qtyOnHand: row.qtyOnHand,
  460. currentPrintQty: row.printQty || 0,
  461. unPrintQty: row.unPrintQty || 0,
  462. newPrintQty: row.printQty || 0
  463. }
  464. this.$nextTick(() => {
  465. this.$refs['editPrintQtyForm'].clearValidate()
  466. })
  467. },
  468. // 提交修改已打印数量
  469. editPrintQtySubmit () {
  470. if (this.editPrintQtyForm.newPrintQty < 0) {
  471. this.$alert('已打印数量不能小于0', this.$t('warehouse.common.error'), { confirmButtonText: this.$t('warehouse.common.confirm') })
  472. return
  473. }
  474. // 验证新的已打印数量不能超过现有库存
  475. if (this.editPrintQtyForm.newPrintQty > this.editPrintQtyForm.qtyOnHand) {
  476. this.$alert('已打印数量不能超过现有库存', this.$t('warehouse.common.error'), { confirmButtonText: this.$t('warehouse.common.confirm') })
  477. return
  478. }
  479. this.editPrintQtyLoading = true
  480. const updateData = {
  481. site: this.editPrintQtyForm.site,
  482. warehouseId: this.editPrintQtyForm.warehouseId,
  483. partNo: this.editPrintQtyForm.partNo,
  484. batchNo: this.editPrintQtyForm.batchNo,
  485. locationId: this.editPrintQtyForm.locationId,
  486. wdr: this.editPrintQtyForm.wdr,
  487. newPrintQty: this.editPrintQtyForm.newPrintQty
  488. }
  489. updatePrintQty(updateData).then(({ data }) => {
  490. if (data && data.code === 0) {
  491. this.$message({
  492. message: '修改已打印数量成功',
  493. type: 'success',
  494. duration: 1500
  495. })
  496. this.editPrintQtyVisible = false
  497. this.getDataList()
  498. } else {
  499. this.$alert(data.msg || '修改已打印数量失败', this.$t('warehouse.common.error'), { confirmButtonText: this.$t('warehouse.common.confirm') })
  500. }
  501. this.editPrintQtyLoading = false
  502. }).catch(() => {
  503. this.editPrintQtyLoading = false
  504. })
  505. },
  506. // 创建HU
  507. async createHuHandle (row) {
  508. this.createHuVisible = true
  509. let site = row.site;
  510. let partNo = row.partNo;
  511. let height = '';
  512. try {
  513. const { data } = await getPartAttributeInfo({ site, partNo });
  514. if (data.code === 0) {
  515. height = data.data.height;
  516. }
  517. } catch (error) {
  518. console.error('获取物料高度失败:', error);
  519. }
  520. this.createHuForm = {
  521. site: row.site,
  522. warehouseId: row.warehouseId,
  523. partNo: row.partNo,
  524. partDesc: row.description || '',
  525. batchNo: row.batchNo,
  526. wdr: row.wdr,
  527. locationId: row.locationId,
  528. qtyOnHand: row.qtyOnHand,
  529. unPrintQty: row.unPrintQty,
  530. umid: row.umid,
  531. perPackageQty: '',
  532. packageCount: '',
  533. lastPackageQty: 0,
  534. height: height,
  535. autoCalculate: false // 默认自动计算
  536. }
  537. this.$nextTick(() => {
  538. this.$refs['createHuForm'].clearValidate()
  539. })
  540. },
  541. /**
  542. * 单包装数量变化时的处理
  543. * 如果开启自动计算:基于未打印数量自动计算包装数和余数HU
  544. * 如果手动输入:不做自动计算
  545. *
  546. * 重要:自动计算时使用未打印数量(库存数量 - 已打印数量)
  547. * 例如:库存44,已打印0,未打印44,单包装10 -> 包装数4,余数HU数量4
  548. * 例如:库存44,已打印20,未打印24,单包装10 -> 包装数2,余数HU数量4
  549. */
  550. onPerPackageQtyChange() {
  551. // 只有在自动计算模式下才进行自动计算
  552. if (!this.createHuForm.autoCalculate) {
  553. return
  554. }
  555. const perPackageQty = parseFloat(this.createHuForm.perPackageQty)
  556. const unPrintQty = parseFloat(this.createHuForm.unPrintQty) // 使用未打印数量
  557. // 如果单包装数量为空或无效,重置包装数
  558. if (!perPackageQty || perPackageQty <= 0 || isNaN(perPackageQty)) {
  559. this.createHuForm.packageCount = ''
  560. this.createHuForm.lastPackageQty = 0
  561. return
  562. }
  563. // 如果未打印数量无效或为0,重置包装数
  564. if (!unPrintQty || unPrintQty <= 0 || isNaN(unPrintQty)) {
  565. this.createHuForm.packageCount = ''
  566. this.createHuForm.lastPackageQty = 0
  567. this.$message.warning('未打印数量为0,无法创建HU')
  568. return
  569. }
  570. // 如果单包装数量大于未打印数量,只创建1个余数HU
  571. if (perPackageQty >= unPrintQty) {
  572. this.createHuForm.packageCount = ''
  573. this.createHuForm.lastPackageQty = unPrintQty
  574. return
  575. }
  576. // 计算包装数(完整HU的数量)
  577. const packageCount = Math.floor(unPrintQty / perPackageQty)
  578. // 计算余数HU的数量
  579. const lastPackageQty = unPrintQty - (perPackageQty * packageCount)
  580. this.createHuForm.packageCount = packageCount
  581. this.createHuForm.lastPackageQty = parseFloat(lastPackageQty.toFixed(2)) // 保留2位小数
  582. },
  583. /**
  584. * 包装数手动修改时的处理
  585. * 只在手动输入模式下生效
  586. * 验证包装数是否合理(不超过库存),但不计算余数HU(余数固定为0)
  587. *
  588. * 场景1:库存44,单包装10,包装数5 -> 总数量50超过库存,提示错误
  589. * 场景2:库存44,单包装10,包装数4 -> 总数量40,合法,余数固定为0
  590. */
  591. onPackageCountChange() {
  592. // 只在手动输入模式下才进行验证
  593. if (this.createHuForm.autoCalculate) {
  594. return
  595. }
  596. const perPackageQty = parseFloat(this.createHuForm.perPackageQty)
  597. const packageCount = parseInt(this.createHuForm.packageCount)
  598. const qtyOnHand = parseFloat(this.createHuForm.qtyOnHand)
  599. // 验证输入
  600. if (!perPackageQty || perPackageQty <= 0 || isNaN(perPackageQty)) {
  601. return
  602. }
  603. if (packageCount === null || packageCount === undefined || isNaN(packageCount)) {
  604. return
  605. }
  606. if (!qtyOnHand || qtyOnHand <= 0 || isNaN(qtyOnHand)) {
  607. return
  608. }
  609. // 计算总数量(完整HU的总数量)
  610. const totalFullPackagesQty = perPackageQty * packageCount
  611. // 如果总数量超过库存,说明包装数过大
  612. if (totalFullPackagesQty > qtyOnHand) {
  613. this.$message.warning(`包装数过大!${packageCount}个完整HU的总数量(${totalFullPackagesQty})超过库存数量(${qtyOnHand})`)
  614. return
  615. }
  616. // 手动模式下余数固定为0,不进行计算
  617. this.createHuForm.lastPackageQty = 0
  618. },
  619. /**
  620. * 余数HU手动输入时的处理
  621. * 只在手动输入模式下生效,用于验证输入的合理性
  622. */
  623. onLastPackageQtyChange() {
  624. // 只在手动输入模式下才进行验证
  625. if (this.createHuForm.autoCalculate) {
  626. return
  627. }
  628. const perPackageQty = parseFloat(this.createHuForm.perPackageQty)
  629. const packageCount = parseInt(this.createHuForm.packageCount)
  630. const lastPackageQty = parseFloat(this.createHuForm.lastPackageQty)
  631. const qtyOnHand = parseFloat(this.createHuForm.qtyOnHand)
  632. // 基本验证
  633. if (!perPackageQty || !qtyOnHand || packageCount === null || packageCount === undefined) {
  634. return
  635. }
  636. // 验证总数量是否超过库存
  637. const totalQty = (perPackageQty * packageCount) + lastPackageQty
  638. if (totalQty > qtyOnHand) {
  639. this.$message.warning(`总数量(${totalQty})超过库存数量(${qtyOnHand})!`)
  640. }
  641. },
  642. /**
  643. * 自动计算勾选框变化时的处理
  644. * 切换自动计算/手动输入模式
  645. */
  646. onAutoCalculateChange(checked) {
  647. if (checked) {
  648. // 切换到自动计算模式,触发一次自动计算
  649. this.$message.info('已切换到自动计算模式')
  650. this.onPerPackageQtyChange()
  651. } else {
  652. // 切换到手动输入模式,将余数HU重置为0
  653. this.$message.info('已切换到手动输入模式,您可以自由输入包装数和余数HU')
  654. this.createHuForm.lastPackageQty = 0
  655. }
  656. },
  657. // 提交创建HU
  658. createHuSubmit () {
  659. this.$refs['createHuForm'].validate((valid) => {
  660. if (valid) {
  661. // 验证包装数
  662. if (!this.createHuForm.packageCount || this.createHuForm.packageCount <= 0) {
  663. this.$alert('请输入单包装数量以自动计算包装数', this.$t('warehouse.common.error'), { confirmButtonText: this.$t('warehouse.common.confirm') })
  664. return
  665. }
  666. // 构建提示信息
  667. const perQty = parseFloat(this.createHuForm.perPackageQty)
  668. const lastQty = parseFloat(this.createHuForm.lastPackageQty)
  669. const pkgCount = parseInt(this.createHuForm.packageCount)
  670. const qtyOnHand = parseFloat(this.createHuForm.qtyOnHand)
  671. const unPrintQty = parseFloat(this.createHuForm.unPrintQty)
  672. let confirmMsg = `即将创建 HU\n`
  673. confirmMsg += `库存数量: ${qtyOnHand}\n`
  674. confirmMsg += `未打印数量: ${unPrintQty}\n\n`
  675. if (lastQty > 0) {
  676. // 有余数HU
  677. const totalRegular = perQty * pkgCount
  678. const totalQty = totalRegular + lastQty
  679. const actualHuCount = pkgCount + 1
  680. confirmMsg += `创建 ${pkgCount} 个完整HU,每个数量: ${perQty}(小计: ${totalRegular})\n`
  681. confirmMsg += `创建 1 个余数HU,数量: ${lastQty}\n\n`
  682. confirmMsg += `总计: ${actualHuCount} 个HU,总数量: ${totalQty}\n`
  683. if (totalQty < unPrintQty) {
  684. const remaining = unPrintQty - totalQty
  685. confirmMsg += `\n注意: 剩余未打印数量 ${remaining} 未创建HU`
  686. }
  687. } else {
  688. // 无余数HU(余数为0)
  689. const total = perQty * pkgCount
  690. confirmMsg += `创建 ${pkgCount} 个HU,每个数量: ${perQty}\n`
  691. confirmMsg += `总计: ${pkgCount} 个HU,总数量: ${total}\n`
  692. if (total < unPrintQty) {
  693. const remaining = unPrintQty - total
  694. confirmMsg += `\n注意: 剩余未打印数量 ${remaining} 未创建HU`
  695. }
  696. }
  697. this.$confirm(confirmMsg, '确认创建', {
  698. confirmButtonText: this.$t('warehouse.common.confirm'),
  699. cancelButtonText: this.$t('warehouse.common.cancel'),
  700. type: 'info'
  701. }).then(() => {
  702. this.createHuLoading = true
  703. createHandlingUnits(this.createHuForm).then(({ data }) => {
  704. if (data && data.code === 0) {
  705. const lastQty = parseFloat(this.createHuForm.lastPackageQty)
  706. const actualHuCount = lastQty > 0 ? this.createHuForm.packageCount + 1 : this.createHuForm.packageCount
  707. this.$message({
  708. message: `创建HandlingUnit成功!共创建 ${actualHuCount} 个HU`,
  709. type: 'success',
  710. duration: 1500
  711. })
  712. let printLabelType;
  713. if (this.createHuForm.partNo && this.createHuForm.partNo.startsWith("80")) {
  714. printLabelType = '库存成品标签';
  715. } else {
  716. printLabelType = 'BIL标签';
  717. }
  718. // 同一行拆出的多个HU共用该行站点,不能用登录缓存站点。
  719. this.printHandlingUnits(data.unitIds, printLabelType, this.createHuForm.site)
  720. this.createHuVisible = false
  721. this.getDataList()
  722. } else {
  723. this.$alert(data.msg || '创建HandlingUnit失败', this.$t('warehouse.common.error'), { confirmButtonText: this.$t('warehouse.common.confirm') })
  724. }
  725. this.createHuLoading = false
  726. }).catch(() => {
  727. this.createHuLoading = false
  728. })
  729. }).catch(() => {
  730. // 用户取消
  731. })
  732. }
  733. })
  734. },
  735. // 打印HandlingUnit标签。site 必须是创建该批HU的库存行站点。
  736. async printHandlingUnits (unitIds, printLabelType, site) {
  737. if (!unitIds || unitIds.length === 0) {
  738. return
  739. }
  740. try {
  741. // 逐个打印每个HandlingUnit
  742. for (const unitId of unitIds) {
  743. await this.printViaServer(unitId, printLabelType, site)
  744. }
  745. this.$message({
  746. message: `成功打印 ${unitIds.length} 个HandlingUnit标签`,
  747. type: 'success',
  748. duration: 2000
  749. })
  750. } catch (error) {
  751. this.$alert('打印失败: ' + error.message, this.$t('warehouse.common.error'), { confirmButtonText: this.$t('warehouse.common.confirm') })
  752. }
  753. },
  754. // 通过服务器打印。站点取库存行,列表可能跨工厂,登录缓存站点会打到错误工厂。
  755. async printViaServer(unitId, printLabelType, site) {
  756. if (!site) {
  757. return Promise.reject(new Error('行站点为空,无法打印'))
  758. }
  759. try {
  760. const printRequest = {
  761. reportId: this.reportId,
  762. zplCode: this.zplCode,
  763. paperSize: this.paperSize,
  764. orientation: this.orientation,
  765. dpi: this.dpi,
  766. userId: localStorage.getItem('userName'),
  767. username: localStorage.getItem('userName'),
  768. site: site,
  769. unitId: unitId,
  770. labelType: printLabelType
  771. }
  772. const { data } = await printLabel(printRequest)
  773. if (data.code === 200) {
  774. return Promise.resolve();
  775. } else {
  776. return Promise.reject(new Error(data.msg || '打印失败'));
  777. }
  778. } catch (error) {
  779. return Promise.reject(error);
  780. }
  781. },
  782. // 重置表单
  783. resetForm() {
  784. this.dataForm = {
  785. partNo: '',
  786. batchNo: '',
  787. locationId: '',
  788. descriptionLike: '',
  789. minUnPrintQty: 0
  790. }
  791. this.pageIndex = 1
  792. this.getDataList()
  793. },
  794. /**
  795. * 打开导入对话框
  796. */
  797. openImportDialog() {
  798. this.$refs.ifsInventoryUploadExcel.init()
  799. },
  800. /**
  801. * 批量删除IFS库存数据
  802. * 真实删除,不可恢复,需要用户慎重确认
  803. */
  804. batchDeleteInventory() {
  805. // 检查是否有选中的数据
  806. if (!this.dataListSelections || this.dataListSelections.length === 0) {
  807. this.$alert('请至少选择一条数据进行删除!', this.$t('warehouse.common.error'), { confirmButtonText: this.$t('warehouse.common.confirm') })
  808. return
  809. }
  810. this.$confirm(
  811. '⚠️ 警告:此操作将永久删除这些数据,无法恢复!\n\n请再次确认是否要删除?',
  812. '确认',
  813. {
  814. confirmButtonText: '确认删除',
  815. cancelButtonText: '我再想想',
  816. type: 'error',
  817. confirmButtonClass: 'el-button--danger',
  818. distinguishCancelAndClose: true
  819. }
  820. ).then(() => {
  821. this.executeDeleteInventory()
  822. }).catch(() => {
  823. this.$message.info('已取消删除操作')
  824. })
  825. },
  826. /**
  827. * 执行批量删除操作
  828. */
  829. executeDeleteInventory() {
  830. const loading = this.$loading({
  831. lock: true,
  832. text: '正在删除数据,请稍候...',
  833. spinner: 'el-icon-loading',
  834. background: 'rgba(0, 0, 0, 0.7)'
  835. })
  836. // 构建删除请求参数
  837. const deleteItems = this.dataListSelections.map(row => ({
  838. site: row.site,
  839. warehouseId: row.warehouseId,
  840. partNo: row.partNo,
  841. batchNo: row.batchNo,
  842. locationId: row.locationId,
  843. wdr: row.wdr
  844. }))
  845. const requestData = {
  846. items: deleteItems
  847. }
  848. this.$http({
  849. url: this.$http.adornUrl('/ifsInventoryInit/batchDeleteInventory'),
  850. method: 'post',
  851. data: this.$http.adornData(requestData)
  852. }).then(({ data }) => {
  853. loading.close()
  854. if (data && data.code === 0) {
  855. this.$message.success(`批量删除成功!共删除 ${deleteItems.length} 条记录`)
  856. // 刷新列表
  857. this.getDataList()
  858. } else {
  859. this.$alert(data.msg || '批量删除失败', this.$t('warehouse.common.error'), { confirmButtonText: this.$t('warehouse.common.confirm') })
  860. }
  861. }).catch(error => {
  862. loading.close()
  863. this.$alert('批量删除异常: ' + (error.message || '未知错误', this.$t('warehouse.common.error'), { confirmButtonText: this.$t('warehouse.common.confirm') }))
  864. })
  865. },
  866. // 格式化日期
  867. formatDate(date) {
  868. if (!date) return '--'
  869. const d = new Date(date)
  870. if (isNaN(d.getTime())) return '--'
  871. // 如果是1900-01-01,也显示--
  872. if (d.getFullYear() === 1900 && d.getMonth() === 0 && d.getDate() === 1) {
  873. return '--'
  874. }
  875. const year = d.getFullYear()
  876. const month = String(d.getMonth() + 1).padStart(2, '0')
  877. const day = String(d.getDate()).padStart(2, '0')
  878. return `${year}-${month}-${day}`
  879. },
  880. /**
  881. * 批量创建HU
  882. * 业务规则:
  883. * 1. 必须选中至少一条数据
  884. * 2. 每行数据创建一条HU
  885. * 3. 批次号使用每行自己的批次号
  886. * 4. HU数量使用库存数量(qtyOnHand)
  887. */
  888. batchCreateHu() {
  889. // 检查是否有选中的数据
  890. if (!this.dataListSelections || this.dataListSelections.length === 0) {
  891. this.$alert('请至少选择一条数据进行批量创建HU!', this.$t('warehouse.common.error'), { confirmButtonText: this.$t('warehouse.common.confirm') })
  892. return
  893. }
  894. // 确认操作
  895. this.$confirm(`确定为选中的 ${this.dataListSelections.length} 条数据批量创建HU吗?`, '批量创建确认', {
  896. confirmButtonText: this.$t('warehouse.common.confirm'),
  897. cancelButtonText: this.$t('warehouse.common.cancel'),
  898. type: 'warning'
  899. }).then(() => {
  900. this.executeBatchCreateHu()
  901. }).catch(() => {
  902. this.$message.info('已取消批量创建HU操作')
  903. })
  904. },
  905. /**
  906. * 执行批量创建HU
  907. */
  908. executeBatchCreateHu() {
  909. const loading = this.$loading({
  910. lock: true,
  911. text: '正在批量创建HU,请稍候...',
  912. spinner: 'el-icon-loading',
  913. background: 'rgba(0, 0, 0, 0.7)'
  914. })
  915. // 构建批量创建请求参数
  916. const items = this.dataListSelections.map(row => ({
  917. site: row.site,
  918. warehouseId: row.warehouseId,
  919. partNo: row.partNo,
  920. partDesc: row.description || '',
  921. batchNo: row.batchNo, // 使用每行自己的批次号
  922. wdr: row.wdr,
  923. locationId: row.locationId,
  924. umid: row.umid,
  925. qtyOnHand: row.qtyOnHand, // 库存数量
  926. printQty: row.printQty || 0 // 已打印数量
  927. }))
  928. const requestData = {
  929. items: items
  930. }
  931. batchCreateHandlingUnits(requestData).then(({ data }) => {
  932. loading.close()
  933. if (data && data.code === 0) {
  934. const unitIds = data.unitIds || []
  935. this.$message.success(`批量创建HU成功!共创建 ${unitIds.length} 个HU`)
  936. // 询问是否打印
  937. if (unitIds.length > 0) {
  938. this.$confirm(`是否打印 ${unitIds.length} 个HU标签?`, '打印确认', {
  939. confirmButtonText: '打印',
  940. cancelButtonText: '不打印',
  941. type: 'info'
  942. }).then(() => {
  943. this.batchPrintLabels(unitIds, items.map(item => item.site))
  944. }).catch(() => {
  945. // 不打印,直接刷新列表
  946. this.getDataList()
  947. })
  948. } else {
  949. this.getDataList()
  950. }
  951. } else {
  952. this.$alert(data.msg || '批量创建HU失败', this.$t('warehouse.common.error'), { confirmButtonText: this.$t('warehouse.common.confirm') })
  953. }
  954. }).catch(error => {
  955. loading.close()
  956. this.$alert('批量创建HU异常: ' + (error.message || '未知错误', this.$t('warehouse.common.error'), { confirmButtonText: this.$t('warehouse.common.confirm') }))
  957. })
  958. },
  959. /**
  960. * 批量打印标签。sites 与 unitIds 同序,对应每条选中库存行的站点。
  961. */
  962. async batchPrintLabels(unitIds, sites) {
  963. const loading = this.$loading({
  964. lock: true,
  965. text: '正在打印标签,请稍候...',
  966. spinner: 'el-icon-loading',
  967. background: 'rgba(0, 0, 0, 0.7)'
  968. })
  969. try {
  970. let successCount = 0
  971. let failCount = 0
  972. // 逐个打印
  973. for (let i = 0; i < unitIds.length; i++) {
  974. const unitId = unitIds[i]
  975. loading.text = `正在打印标签 (${i + 1}/${unitIds.length})...`
  976. try {
  977. // 根据物料编码判断标签类型(这里简化处理,使用默认值)
  978. const printLabelType = 'BIL标签'
  979. const site = sites && sites[i]
  980. await this.printViaServer(unitId, printLabelType, site)
  981. successCount++
  982. } catch (error) {
  983. failCount++
  984. }
  985. }
  986. loading.close()
  987. if (successCount > 0) {
  988. this.$message.success(`成功打印 ${successCount} 个标签` + (failCount > 0 ? `,失败 ${failCount} 个` : ''))
  989. } else {
  990. this.$alert('所有标签打印失败', this.$t('warehouse.common.error'), { confirmButtonText: this.$t('warehouse.common.confirm') })
  991. }
  992. // 刷新列表
  993. this.getDataList()
  994. } catch (error) {
  995. loading.close()
  996. this.$alert('打印异常: ' + error.message, this.$t('warehouse.common.error'), { confirmButtonText: this.$t('warehouse.common.confirm') })
  997. this.getDataList()
  998. }
  999. }
  1000. }
  1001. }
  1002. </script>
  1003. <style scoped>
  1004. .mod-config .el-form-item {
  1005. margin-bottom: 15px;
  1006. }
  1007. /* 修改已打印数量表单样式 */
  1008. .edit-print-qty-form .form-item-vertical {
  1009. margin-bottom: 20px;
  1010. }
  1011. .edit-print-qty-form .form-item-vertical .el-form-item__label {
  1012. display: block;
  1013. text-align: left;
  1014. padding: 0 0 8px 0;
  1015. line-height: 1.5;
  1016. font-weight: 500;
  1017. }
  1018. .edit-print-qty-form .form-item-vertical .el-form-item__content {
  1019. margin-left: 0 !important;
  1020. }
  1021. .edit-print-qty-form .el-row {
  1022. margin-bottom: 0;
  1023. }
  1024. /* 创建HU表单样式 */
  1025. .create-hu-form .form-item-vertical {
  1026. margin-bottom: 20px;
  1027. }
  1028. .create-hu-form .form-item-vertical .el-form-item__label {
  1029. display: block;
  1030. text-align: left;
  1031. padding: 0 0 8px 0;
  1032. line-height: 1.5;
  1033. font-weight: 500;
  1034. }
  1035. .create-hu-form .form-item-vertical .el-form-item__content {
  1036. margin-left: 0 !important;
  1037. }
  1038. .create-hu-form .el-row {
  1039. margin-bottom: 0;
  1040. }
  1041. </style>