freezeList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <template>
  2. <div>
  3. <!-- <div class="search">
  4. <el-form ref="advancedForm" :model="advancedForm" label-width="160px">
  5. <el-row>
  6. <el-col :span="12">
  7. <el-form-item label="仓库">
  8. <el-select v-model="advancedForm.out_warehouse_id">
  9. <el-option v-for="item in warehouseList" :key="item.id" :label="item.name"
  10. :value="item.id" />
  11. </el-select>
  12. </el-form-item>
  13. </el-col>
  14. <el-col :span="12">
  15. <el-form-item label="商品编号/sku/序列号">
  16. <el-input v-model="advancedForm.input" placeholder="请输入内容" width="200px"></el-input>
  17. </el-form-item>
  18. </el-col>
  19. </el-row>
  20. </el-form>
  21. <el-button @click="advancedSearchEvent"> 搜索 </el-button>
  22. </div> -->
  23. <en-table-layout :tableData="tableData.records" ref="table" :loading="loading"
  24. @selection-change="handleSelectionChange">
  25. <div slot="toolbar" class="inner-toolbar">
  26. <!-- <div class="toolbar-btns">
  27. </div> -->
  28. </div>
  29. <template slot="table-columns">
  30. <el-table-column type="selection" width="55" />
  31. <el-table-column prop="order_sn" label="单据编号">
  32. </el-table-column>
  33. <el-table-column label="单据类型" prop="order_type">
  34. <template slot-scope="scope">
  35. {{ typeName(scope.row.order_type) }}
  36. </template>
  37. </el-table-column>
  38. <el-table-column label="状态" prop="status">
  39. <template slot-scope="scope">
  40. {{ scope.row.status ? '解冻' : '未解冻' }}
  41. </template>
  42. </el-table-column>
  43. <el-table-column prop="locked_num" label="冻结个数" />
  44. <el-table-column prop="locked_time" label="冻结时间">
  45. </el-table-column>
  46. <el-table-column prop="un_locked_num" label="解冻个数" />
  47. <el-table-column prop="un_locked_time" label="解冻时间" />
  48. <!-- <el-table-column label="操作" width="250">
  49. <template slot-scope="scope">
  50. <el-button type="success1" size="mini" v-if="checkPermission(['goodsTransfer:submit'])"
  51. @click="handleSubmitGoodsTransfer(scope.row)">设置预警库存</el-button>
  52. <el-button type="success1" size="mini"
  53. v-if="scope.row.allowable.submit && checkPermission(['goodsTransfer:submit'])"
  54. @click="handleSubmitGoodsTransfer(scope.row)">提交</el-button>
  55. <el-button type="danger" size="mini"
  56. v-else-if="scope.row.allowable.withdraw && checkPermission(['goodsTransfer:withdraw'])"
  57. @click="handleWithdrawGoodsTransfer(scope.row)">撤回</el-button>
  58. <el-button size="mini" @click="handleEditGoodsTransfer(scope.row)"
  59. >查看</el-button
  60. >
  61. <el-button size="mini" @click="handleDelGoodsTransfer(scope.row)"
  62. >删除</el-button
  63. >
  64. <el-button size="mini" v-if="scope.row.allowable.confirm && checkPermission(['goodsTransfer:confirm'])"
  65. @click="handleSuccessGoodsTransfer(scope.row)" type="success">确认</el-button>
  66. <el-button size="mini" v-if="scope.row.allowable.confirm && checkPermission(['goodsTransfer:return'])"
  67. @click="handleRejectGoodsTransfer(scope.row)" type="danger">退回</el-button>
  68. </template>
  69. </el-table-column>-->
  70. </template>
  71. <el-pagination v-if="tableData" slot="pagination" @size-change="handlePageSizeChange"
  72. @current-change="handlePageCurrentChange" :current-page="tableData.pages"
  73. :page-sizes="[10, 20, 50, 100]" :page-size="tableData.size"
  74. layout="total, sizes, prev, pager, next, jumper" :total="tableData.total">
  75. </el-pagination>
  76. </en-table-layout>
  77. <!-- <el-dialog title="在途明细" :visible.sync="dialogVisible" append-to-body :close-on-click-modal="false"
  78. :close-on-press-escape="false">
  79. <el-table :data="transitDetails" border class="sku-table">
  80. <el-table-column prop="order_sn" label="订单编号" />
  81. <el-table-column prop="num" label="在途数量" />
  82. <el-table-column prop="end_time" label="返回日期" />
  83. </el-table>
  84. </el-dialog>
  85. <el-dialog title="设置预警数量" :visible.sync="numDialogVisible" append-to-body :close-on-click-modal="false"
  86. :close-on-press-escape="false" width="30%">
  87. <el-form ref="numAddForm" :model="numAddForm" :rules="numAddFormRule" label-width="160px" inline
  88. class="change-form">
  89. <el-form-item label="预警数量" prop="num" class="change-form-item">
  90. <el-input v-model="numAddForm.num" placeholder="请输入"></el-input>
  91. </el-form-item>
  92. </el-form>
  93. <span slot="footer" class="dialog-footer">
  94. <el-button @click="numDialogVisible = false">取 消</el-button>
  95. <el-button @click="submitNum" type="primary">确 定</el-button>
  96. </span>
  97. </el-dialog> -->
  98. </div>
  99. </template>
  100. <script>
  101. import * as API_GoodsTransfer from "@/api/goodsTransfer";
  102. import * as API_Setting from "@/api/setting";
  103. import * as API_BasicSetting from "@/api/basicSetting";
  104. import { mapGetters } from "vuex";
  105. export default {
  106. name: "GoodsTransfer",
  107. data() {
  108. return {
  109. warehouseList: [],
  110. goodstransferType: [],
  111. // 列表loading状态
  112. loading: false,
  113. // 列表参数
  114. params: {
  115. page_no: 1,
  116. page_size: 10,
  117. },
  118. // 高级搜索数据
  119. advancedForm: {},
  120. // 列表数据
  121. tableData: "",
  122. // 当前已选择的行
  123. multipleSelection: [],
  124. GoodsTransferForm: {},
  125. dialogVisible: false,
  126. // 在途明细
  127. transitDetails: [],
  128. numDialogVisible: false,
  129. numAddForm: {},
  130. stockId: '',//选择的id
  131. numAddFormRule: {
  132. num: [{
  133. required: true,
  134. message: '请输入预警库存数量',
  135. trigger: 'blur'
  136. },
  137. {
  138. validator: (rule, value, callback) => {
  139. if (/^(?:[1-9]\d*)$/.test(value) == false) {
  140. callback(new Error("请输入正整数"));
  141. } else {
  142. callback();
  143. }
  144. },
  145. trigger: "blur",
  146. },
  147. ],
  148. },
  149. selectedRow: null, // 用于记录当前选中的行
  150. orderDetailTypeL:[]
  151. };
  152. },
  153. mounted() {
  154. this.GET_GoodsTransferList();
  155. this.GET_DictDataInfo();
  156. this.GET_WarehouseList();
  157. },
  158. watch: {
  159. $route: function ({ query }) {
  160. this.params.page_no = 1;
  161. this.GET_GoodsTransferList();
  162. },
  163. },
  164. computed: {
  165. ...mapGetters(["user"]),
  166. },
  167. methods: {
  168. typeName(val) {
  169. let name = "";
  170. this.orderDetailType.map((el) => {
  171. if (el.value == val) {
  172. return (name = el.label);
  173. }
  174. });
  175. return name;
  176. },
  177. /* 提交预警数量 */
  178. submitNum() {
  179. console.log(this.$refs["numAddForm"]);
  180. this.$refs["numAddForm"].validate((valid) => {
  181. if (valid) {
  182. API_GoodsTransfer.updateWarnStock(this.stockId, this.numAddForm.num).then(res => {
  183. this.numDialogVisible = false
  184. this.numAddForm = {}
  185. this.$message.success('预警库存设置成功!')
  186. this.GET_GoodsTransferList();
  187. })
  188. }
  189. })
  190. },
  191. // 删除
  192. handleDelGoodsTransfer(row) {
  193. this.$confirm("确定要删除这些库存吗?", "提示", { type: "warning" })
  194. .then(() => {
  195. const ids = []
  196. ids.push(row.id)
  197. API_GoodsTransfer.deleteGoodsTransfer({ ids: ids }).then((res) => {
  198. this.$message.success("删除成功!");
  199. this.ids = []
  200. this.GET_GoodsTransferList();
  201. });
  202. })
  203. .catch(() => { });
  204. },
  205. // 导出
  206. checkExport() { },
  207. // 查看在途
  208. lookTransit() {
  209. if (!this.selectedRow) return this.$message.error('请先选择!')
  210. API_GoodsTransfer.transitDetail(this.selectedRow.id).then(res => {
  211. console.log(res);
  212. this.dialogVisible = true;
  213. this.transitDetails = res
  214. })
  215. },
  216. handleSuccessGoodsTransfer(row) {
  217. API_GoodsTransfer.successGoodsTransfer(row.id, {
  218. in_handled_by_id: this.user.uid,
  219. in_handled_by_name: this.user.username,
  220. }).then(() => {
  221. this.$message.success("确认成功!");
  222. this.GET_GoodsTransferList();
  223. });
  224. },
  225. handleRejectGoodsTransfer(row) {
  226. API_GoodsTransfer.rejectGoodsTransfer(row.id, {
  227. in_handled_by_id: this.user.uid,
  228. in_handled_by_name: this.user.username,
  229. }).then(() => {
  230. this.$message.success("退回成功!");
  231. this.GET_GoodsTransferList();
  232. });
  233. },
  234. /** 获取仓库 */
  235. GET_WarehouseList() {
  236. API_BasicSetting.getWarehouseListAll().then((response) => {
  237. this.warehouseList = response;
  238. });
  239. API_Setting.getPage({ dictType: "order_detail_type" }).then((res) => {
  240. this.orderDetailType = res.data;
  241. });
  242. },
  243. typeFilter(row) {
  244. return this.goodstransferType.find((type) => type.value === row).label;
  245. },
  246. GET_DictDataInfo() {
  247. API_Setting.getDictDataInfo("erp_goodstransfer_type").then((res) => {
  248. this.goodstransferType = res;
  249. });
  250. },
  251. handleSubmitGoodsTransfer(row) {
  252. this.stockId = row.id
  253. this.numDialogVisible = true
  254. /* API_GoodsTransfer.submitGoodsTransfer(row.id).then(() => {
  255. this.$message.success("提交成功!");
  256. this.GET_GoodsTransferList();
  257. }); */
  258. },
  259. handleWithdrawGoodsTransfer(row) {
  260. API_GoodsTransfer.withdrawGoodsTransfer(row.id).then(() => {
  261. this.$message.success("撤回成功!");
  262. this.GET_GoodsTransferList();
  263. });
  264. },
  265. /** 调拨单状态 */
  266. statusFilter(val) {
  267. switch (val) {
  268. case "NotSubmit":
  269. return "未提交";
  270. case "Submit":
  271. return "已提交";
  272. case "Confirm":
  273. return "已确认";
  274. case "AuditReject ":
  275. return "已退回";
  276. default:
  277. return "";
  278. }
  279. },
  280. handleDeleteGoodsTransfer() {
  281. if (!this.multipleSelection || !this.multipleSelection.length)
  282. return this.$message.error("请先选择!");
  283. this.$confirm("确定要删除这些库存吗?", "提示", { type: "warning" })
  284. .then(() => {
  285. const ids = this.multipleSelection.map((item) => item.id);
  286. API_GoodsTransfer.deleteGoodsTransfer({ ids: ids }).then(() => {
  287. this.$message.success("删除成功!");
  288. this.GET_GoodsTransferList();
  289. });
  290. })
  291. .catch(() => { });
  292. },
  293. /** 多选改变 */
  294. handleSelectionChange(selection, row) {
  295. if (selection.length > 0) {
  296. const lastSelected = selection[selection.length - 1];
  297. if (this.selectedRow && this.selectedRow !== lastSelected) {
  298. this.selectedRow = lastSelected;
  299. } else {
  300. this.selectedRow = lastSelected;
  301. }
  302. } else {
  303. this.selectedRow = null;
  304. }
  305. },
  306. selectableRow(row, index) {
  307. // 这个方法决定了哪些行是可选的
  308. return !this.selectedRow || this.selectedRow === row;
  309. },
  310. /** 分页大小发生改变 */
  311. handlePageSizeChange(size) {
  312. this.params.page_size = size;
  313. this.GET_GoodsTransferList();
  314. },
  315. /** 分页页数发生改变 */
  316. handlePageCurrentChange(page) {
  317. this.params.page_no = page;
  318. this.GET_GoodsTransferList();
  319. },
  320. /** 添加商品调拨 */
  321. handleAddGoodsTransfer() {
  322. this.$router.push({
  323. name: "goodsTransferAdd",
  324. params: { callback: this.GET_GoodsTransferList },
  325. });
  326. },
  327. /** 编辑商品调拨 */
  328. handleEditGoodsTransfer(row) {
  329. this.$router.push({
  330. name: "goodsTransferDetail",
  331. params: { id: row.id },
  332. });
  333. },
  334. /** 搜索事件触发 */
  335. searchEvent(data) {
  336. this.params = {
  337. ...this.params,
  338. sn: data,
  339. };
  340. Object.keys(this.advancedForm).forEach((key) => delete this.params[key]);
  341. this.params.page_no = 1;
  342. this.GET_GoodsTransferList();
  343. },
  344. /** 高级搜索事件触发 */
  345. advancedSearchEvent() {
  346. this.params = {
  347. ...this.params,
  348. ...this.advancedForm,
  349. };
  350. delete this.params.start_time;
  351. delete this.params.end_time;
  352. if (this.advancedForm.purchasePlan_time_range) {
  353. this.params.start_time = parseInt(
  354. Number(this.advancedForm.purchasePlan_time_range[0]) / 1000
  355. );
  356. this.params.end_time = parseInt(
  357. Number(this.advancedForm.purchasePlan_time_range[1]) / 1000
  358. );
  359. }
  360. delete this.params.purchasePlan_time_range;
  361. this.params.page_no = 1;
  362. this.GET_GoodsTransferList();
  363. },
  364. /** 获取商品调拨列表 */
  365. GET_GoodsTransferList() {
  366. this.loading = true;
  367. API_GoodsTransfer.getLockedStock(this.params)
  368. .then((response) => {
  369. this.loading = false;
  370. this.tableData = response;
  371. })
  372. .catch(() => {
  373. this.loading = false;
  374. });
  375. },
  376. },
  377. };
  378. </script>
  379. <style type="text/scss" lang="scss" scoped>
  380. .search {
  381. display: flex;
  382. align-items: center;
  383. background: #fff;
  384. overflow: hidden;
  385. padding: 30px 10px 10px 10px;
  386. /deep/ .el-form-item {
  387. .el-form-item__content {
  388. .el-input {
  389. width: 200px;
  390. }
  391. }
  392. }
  393. .el-button {
  394. margin-top: -19px;
  395. margin-left: 20px;
  396. }
  397. }
  398. .tips-t {
  399. display: flex;
  400. padding: 10px 0;
  401. div {
  402. flex: 1;
  403. text-align: center;
  404. }
  405. }
  406. .tips-f {
  407. padding: 20px 0;
  408. }
  409. .face-image {
  410. display: block;
  411. width: 50px;
  412. height: 50px;
  413. margin: 0 auto;
  414. }
  415. /deep/ .el-dialog__body {
  416. padding: 10px 20px;
  417. }
  418. </style>