unlockModal.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <ele-modal
  3. :title="title"
  4. :visible.sync="visible"
  5. :before-close="handleClose"
  6. :close-on-click-modal="false"
  7. :close-on-press-escape="false"
  8. append-to-body
  9. width="75%"
  10. :maxable="true"
  11. >
  12. <el-card shadow="never">
  13. <el-descriptions>
  14. <el-descriptions-item label="创建时间">{{ formData.createTime }}</el-descriptions-item>
  15. <!-- <el-descriptions-item label="创建人">{{ formData.createUser }}</el-descriptions-item> -->
  16. <el-descriptions-item label="物品编码">{{ formData.productCode }}</el-descriptions-item>
  17. <el-descriptions-item label="名称">{{ formData.productName }}</el-descriptions-item>
  18. <el-descriptions-item label="批次号">{{ formData.batchNo }}</el-descriptions-item>
  19. <!-- <el-descriptions-item label="规格">{{ formData.spec }}</el-descriptions-item> -->
  20. <!-- <el-descriptions-item label="型号">{{ formData.model }}</el-descriptions-item> -->
  21. <!-- <el-descriptions-item label="牌号">{{ formData.certificateNumber }}</el-descriptions-item> -->
  22. </el-descriptions>
  23. <div style="margin-top: 12px">
  24. <ele-pro-table
  25. ref="eleTable"
  26. :columns="tableColumns"
  27. :datasource="formData.details || []"
  28. height="calc(100vh - 405px)"
  29. full-height="calc(100vh - 116px)"
  30. tool-class="ele-toolbar-form"
  31. :pageSize="20"
  32. @selection-change="handleSelectionChange"
  33. :initLoad="false"
  34. :needPage="false"
  35. >
  36. <template v-slot:unionQuantity="{ row }">
  37. <el-input
  38. v-model="row.unionQuantity"
  39. placeholder="请输入"
  40. :disabled="readonlyMode"
  41. @input="(value) => inputNum(value, row)"
  42. ></el-input>
  43. </template>
  44. </ele-pro-table>
  45. </div>
  46. </el-card>
  47. <div class="btns" v-if="title != '详情'">
  48. <el-button :loading="loading" type="primary" size="small" @click="handleSave(0)"
  49. >保存</el-button
  50. >
  51. <el-button :loading="loading" type="primary" size="small" @click="handleSave(1)"
  52. >提交</el-button
  53. >
  54. <el-button size="small" @click="handleClose">取消</el-button>
  55. </div>
  56. </ele-modal>
  57. </template>
  58. <script>
  59. import storageApi from '@/api/warehouseManagement';
  60. export default {
  61. props: {},
  62. data() {
  63. return {
  64. visible: false,
  65. title: '',
  66. formData: {},
  67. modalType: '',
  68. columns: [
  69. {
  70. columnKey: 'selection',
  71. type: 'selection',
  72. width: 45,
  73. align: 'center'
  74. },
  75. {
  76. columnKey: 'index',
  77. type: 'index',
  78. width: 50,
  79. align: 'center',
  80. label: '序号',
  81. showOverflowTooltip: true,
  82. fixed: 'left'
  83. },
  84. {
  85. prop: 'quantity',
  86. label: '锁定数量',
  87. showOverflowTooltip: true,
  88. width: 130,
  89. align: 'center'
  90. },
  91. {
  92. prop: 'unionQuantity',
  93. label: '解锁数量',
  94. slot: 'unionQuantity',
  95. // sortable: 'custom',
  96. showOverflowTooltip: true,
  97. width: 130,
  98. align: 'center'
  99. },
  100. {
  101. prop: 'sourceOrderNo',
  102. label: '关联单据编码',
  103. align: 'center'
  104. },
  105. {
  106. prop: 'sourceType',
  107. label: '关联单据类型',
  108. align: 'center',
  109. formatter: (row) => {
  110. return this.LockOrderSourceTypeEnum[row.sourceType] || '-';
  111. }
  112. },
  113. {
  114. prop: 'orderDate',
  115. label: '锁定时间',
  116. align: 'center'
  117. },
  118. ],
  119. rules: {
  120. sourceType: [
  121. { required: true, message: '请选择申请类型', trigger: 'change' }
  122. ]
  123. },
  124. loading: false,
  125. selectionList: [],
  126. ids: [],
  127. detailJnVOList: [],
  128. tableData: [],
  129. businessId: '',
  130. LockOrderSourceTypeEnum: {
  131. 0: '无定义',
  132. 1: '销售发货单',
  133. 2: '领料出库单',
  134. 3: '调拨出库单',
  135. 4: '销售订单'
  136. }
  137. };
  138. },
  139. computed: {
  140. readonlyMode() {
  141. return this.title === '详情';
  142. },
  143. tableColumns() {
  144. return this.title === '详情'
  145. ? this.columns.filter((c) => c.type !== 'selection')
  146. : this.columns;
  147. }
  148. },
  149. methods: {
  150. reload(where) {
  151. this.$nextTick(() => {
  152. if (this.$refs.eleTable && this.$refs.eleTable.reload)
  153. this.$refs.eleTable.reload({ page: 1, where: where });
  154. });
  155. },
  156. async open(type, row) {
  157. this.visible = true;
  158. this.title = '解锁';
  159. console.log(type, row, 'row');
  160. this.modalType = type;
  161. if(type === 'add') {
  162. const res = await storageApi.inboundLockPage({
  163. pageNum: -1,
  164. systemBatchNo: row.systemBatchNo
  165. });
  166. console.log(res, 'res');
  167. this.tableData = res.list || [];
  168. this.formData = {
  169. ...row,
  170. productName: row.categoryName,
  171. productId: row.categoryId,
  172. productCode: row.categoryCode,
  173. details: res.list || []
  174. };
  175. console.log(this.formData, 'formData');
  176. } else {
  177. await this.getDraftDetail(row.id);
  178. }
  179. // await this.reload();
  180. },
  181. async getDraftDetail(id) {
  182. const res = await storageApi.getUnlockDetails(id);
  183. if (res) {
  184. console.log(res, '详情');
  185. this.$set(this, 'formData', res);
  186. this.businessId = res.id;
  187. this.formData = {
  188. ...res
  189. }
  190. this.selectionList = res.details || [];
  191. }
  192. },
  193. inputNum(value, row) {
  194. const num = value.replace(/[^\d.]/g, '');
  195. const oldValue = row.quantity;
  196. if (num > oldValue) {
  197. this.$set(row, 'unionQuantity', oldValue);
  198. } else {
  199. this.$set(row, 'unionQuantity', num);
  200. }
  201. },
  202. handleSelectionChange(selection) {
  203. console.log(selection, '勾选');
  204. // if (this.title === '新增' && selection.length > 1) {
  205. // const last = selection[selection.length - 1];
  206. // this.selectionList = [last];
  207. // this.$nextTick(() => {
  208. // if (this.$refs.eleTable && this.$refs.eleTable.setSelectedRowKeys) {
  209. // this.$refs.eleTable.setSelectedRowKeys([last.outInDetailId]);
  210. // }
  211. // });
  212. // return;
  213. // }
  214. this.selectionList = selection;
  215. },
  216. handleClose() {
  217. this.visible = false;
  218. },
  219. handleSave(status) {
  220. if (this.selectionList.length == 0)
  221. return this.$message.warning('请选择解锁数据');
  222. let isValid = true;
  223. this.selectionList.forEach((item) => {
  224. if (!item.unionQuantity) {
  225. isValid = false;
  226. }
  227. });
  228. if (!isValid) {
  229. this.$message.error('请填写解锁数量');
  230. return;
  231. }
  232. let postData = {
  233. ...this.formData,
  234. // productName: this.formData.categoryName,
  235. // productId: this.formData.categoryId,
  236. // productCode: this.formData.categoryCode,
  237. details: this.selectionList
  238. };
  239. this.loading = true;
  240. const api = this.modalType === 'add' ? storageApi.saveUnlock : storageApi.updateUnlock;
  241. api(postData)
  242. .then(async (res) => {
  243. console.log(res, 'res');
  244. // if (res == 0) {
  245. try {
  246. if(status == 1) {
  247. storageApi.submitUnlock({ businessId: this.modalType === 'add' ? res : this.businessId })
  248. this.$message.success('提交成功');
  249. this.loading = false;
  250. this.visible = false;
  251. this.$emit('success');
  252. } else {
  253. this.$message.success('保存成功');
  254. this.loading = false;
  255. this.visible = false;
  256. this.$emit('success');
  257. }
  258. } catch (error) {
  259. // this.visible = false;
  260. console.log('失败', error);
  261. }
  262. // }
  263. })
  264. .catch((err) => {
  265. console.log('申请失败', err);
  266. this.loading = false;
  267. this.visible = false;
  268. });
  269. }
  270. }
  271. };
  272. </script>
  273. <style lang="scss" scoped>
  274. .btns {
  275. text-align: center;
  276. padding: 10px 0;
  277. }
  278. .el-form-item__error {
  279. color: red;
  280. font-size: 12px;
  281. line-height: 1;
  282. padding-top: 4px;
  283. position: relative;
  284. }
  285. .is-error .el-input__inner {
  286. border-color: red;
  287. }
  288. </style>