outboundRequisitionDialog.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. <template>
  2. <div>
  3. <el-dialog :title="`选择${type == 1 ? '入库' : '出库'}申请单`" :visible.sync="dialogVisible" width="90%"
  4. :before-close="handleClose" :close-on-click-modal="false" :close-on-press-escape="false">
  5. <div v-if="bizType == 10">
  6. <ele-pro-table ref="table" :columns="columns10" :datasource="datasource10" cache-key="workOrderTable"
  7. @cell-click="cellClick10">
  8. <template v-slot:selection="{ row }">
  9. <el-radio class="radio" v-model="currentRow.id" :label="row.id"><i></i></el-radio>
  10. </template>
  11. <template v-slot:requireDeliveryTime="{ row }">
  12. <span v-if="row.deliveryMethod == 1">{{
  13. row.requireDeliveryTime
  14. }}</span>
  15. <el-link v-if="row.deliveryMethod == 2" type="primary" :underline="false"
  16. @click.native="handleMethod(row)">分批时间</el-link>
  17. </template>
  18. <template v-slot:type="{ row }">
  19. <div v-if="row.type == 1">采购委外</div>
  20. <div v-if="row.type == 2">直接发货委外</div>
  21. <div v-if="row.type == 3">无采购委外</div>
  22. </template>
  23. <template v-slot:status="{ row }">
  24. <el-tag>{{ row.status == 1 ? '已发布' : '未发布' }}</el-tag>
  25. </template>
  26. <template v-slot:technicalDrawings="{ row }">
  27. <div v-if="row.technicalDrawings && row.technicalDrawings?.length">
  28. <el-link v-for="link in row.technicalDrawings" :key="link.id" type="primary" :underline="false"
  29. @click="downloadFile(link)">
  30. {{ link.name }}</el-link>
  31. </div>
  32. </template>
  33. <template v-slot:files="{ row }">
  34. <div v-if="row.files && row.files?.length">
  35. <el-link v-for="link in row.files" :key="link.id" type="primary" :underline="false"
  36. @click="downloadFile(link)">
  37. {{ link.name }}</el-link>
  38. </div>
  39. </template>
  40. </ele-pro-table>
  41. </div>
  42. <div class="main" v-if="bizType != 10">
  43. <!-- @cell-click="cellClick" -->
  44. <ele-pro-table ref="table" :columns="columns" :datasource="datasource" @select="selectChange"
  45. @select-all="changeSelectAll" cache-key="workOrderTable">
  46. <!-- 表头工具栏 -->
  47. <!-- <template v-slot:action="{ row }">
  48. <el-radio class="radio" v-model="currentId" :label="row.id"
  49. ><i></i
  50. ></el-radio>
  51. </template> -->
  52. <template v-slot:totalCount="{ row }">
  53. {{ row.totalCount }} {{ row.measuringUnit }}
  54. </template>
  55. <template v-slot:totalPackage="{ row }">
  56. {{ row.totalPackage }}
  57. </template>
  58. <template v-slot:totalWeight="{ row }">
  59. {{ row.totalWeight }} {{ row.weightUnit }}
  60. </template>
  61. <template v-slot:status="{ row }">
  62. <span>
  63. {{ statusFormatter(row.status) }}
  64. </span>
  65. </template>
  66. </ele-pro-table>
  67. </div>
  68. <span slot="footer" class="dialog-footer">
  69. <el-button @click="dialogVisible = false">取 消</el-button>
  70. <el-button type="primary" @click="handleMine()">确 定</el-button>
  71. </span>
  72. </el-dialog>
  73. </div>
  74. </template>
  75. <script>
  76. import { outputSceneState, sceneState } from '@/utils/dict/index';
  77. import storageApi from '@/api/warehouseManagement';
  78. import { getCode } from '@/api/codeManagement/index.js';
  79. export default {
  80. props: {
  81. // 1入库 2出库
  82. type: {
  83. type: String,
  84. default: '1'
  85. },
  86. bizType: {
  87. type: String,
  88. default: ''
  89. }
  90. },
  91. data() {
  92. return {
  93. outputSceneState,
  94. sceneState,
  95. dialogVisible: false,
  96. currentRow: {},
  97. checkRadioData: [],
  98. currentId: '',
  99. statusOpt: [
  100. { label: '待处理', value: 0 },
  101. { label: '已处理', value: 1 },
  102. { label: '已撤销', value: 2 }
  103. ],
  104. currentRow10: {}
  105. };
  106. },
  107. computed: {
  108. // 表格列配置
  109. columns() {
  110. return [
  111. // {
  112. // action: 'action',
  113. // slot: 'action',
  114. // align: 'center',
  115. // label: '选择'
  116. // },
  117. {
  118. width: 45,
  119. type: 'selection',
  120. columnKey: 'selection',
  121. align: 'center'
  122. },
  123. {
  124. columnKey: 'index',
  125. label: '序号',
  126. type: 'index',
  127. width: 55,
  128. align: 'center',
  129. showOverflowTooltip: true,
  130. fixed: 'left'
  131. },
  132. {
  133. prop: 'code',
  134. label: '编码',
  135. align: 'center',
  136. minWidth: 100
  137. },
  138. {
  139. prop: 'categoryNames',
  140. label: '名称',
  141. showOverflowTooltip: true,
  142. align: 'center'
  143. },
  144. { label: '型号', prop: 'modelType', width: '150' },
  145. { label: '规格', prop: 'specification', width: '150' },
  146. { label: '牌号', prop: 'brandNum', width: '100' },
  147. {
  148. prop: 'sourceType',
  149. label: '出入库类型',
  150. align: 'center',
  151. formatter: (row, column, cellValue) => {
  152. switch (this.type) {
  153. case '1':
  154. // 入库
  155. return this.sceneState.filter(
  156. (item) => item.code == row.sourceType
  157. )[0].label;
  158. case '2':
  159. // 出库
  160. return this.outputSceneState.filter(
  161. (item) => item.code == row.sourceType
  162. )[0].label;
  163. }
  164. }
  165. },
  166. {
  167. prop: 'approvalUserName',
  168. label: '审核人',
  169. align: 'center'
  170. },
  171. {
  172. prop: 'createUserName',
  173. label: '申请人',
  174. align: 'center'
  175. },
  176. {
  177. prop: 'createTime',
  178. label: '创建时间',
  179. align: 'center',
  180. showOverflowTooltip: true,
  181. minWidth: 110
  182. },
  183. {
  184. slot: 'status',
  185. label: '状态',
  186. align: 'center'
  187. }
  188. ];
  189. },
  190. columns10() {
  191. return [
  192. {
  193. slot: 'selection',
  194. label: '选择',
  195. width: 50,
  196. align: 'center'
  197. },
  198. {
  199. columnKey: 'index',
  200. label: '序号',
  201. type: 'index',
  202. width: 55,
  203. align: 'center',
  204. showOverflowTooltip: true,
  205. fixed: 'left'
  206. },
  207. {
  208. prop: 'code',
  209. label: '委外单编码',
  210. align: 'center'
  211. },
  212. {
  213. prop: 'name',
  214. label: '委外单名称',
  215. align: 'center'
  216. },
  217. {
  218. prop: 'workOrderCode',
  219. label: '工单编码',
  220. align: 'center'
  221. },
  222. {
  223. prop: 'taskName',
  224. label: '工序',
  225. align: 'center'
  226. },
  227. {
  228. prop: 'totalCount',
  229. label: '委外数量',
  230. align: 'center'
  231. },
  232. {
  233. prop: 'totalWeight',
  234. label: '委外重量',
  235. align: 'center'
  236. },
  237. {
  238. slot: 'type',
  239. label: '委外类型',
  240. align: 'center'
  241. },
  242. {
  243. prop: 'remark',
  244. label: '备注',
  245. align: 'center'
  246. },
  247. {
  248. slot: 'requireDeliveryTime',
  249. label: '预计到货日期',
  250. align: 'center',
  251. minWidth: 70
  252. },
  253. {
  254. prop: 'produceRoutingName',
  255. label: '工艺路线',
  256. align: 'center'
  257. },
  258. {
  259. prop: 'warehouseName',
  260. label: '仓库',
  261. align: 'center'
  262. },
  263. {
  264. prop: 'createTime',
  265. label: '创建时间',
  266. align: 'center',
  267. minWidth: 70
  268. },
  269. {
  270. slot: 'status',
  271. label: '状态',
  272. align: 'center'
  273. },
  274. {
  275. label: '图片附件',
  276. slot: 'technicalDrawings',
  277. action: 'technicalDrawings',
  278. minWidth: 100
  279. },
  280. {
  281. label: '附件',
  282. slot: 'files',
  283. action: 'files',
  284. minWidth: 100
  285. }
  286. ];
  287. }
  288. },
  289. created() {
  290. console.log(this.type, 'this.typethis.typethis.typethis.type')
  291. },
  292. methods: {
  293. /* 表格数据源 */
  294. datasource({ page, limit, where }) {
  295. return storageApi.getinboundRequestsList({
  296. pageNum: page,
  297. size: limit,
  298. status: 0,
  299. type: this.type,
  300. ...where
  301. });
  302. },
  303. /* 表格数据源 委外入库 */
  304. datasource10({ page, limit, where }) {
  305. return storageApi.getApplyoutsource({
  306. pageNum: page,
  307. size: limit,
  308. ...where
  309. });
  310. },
  311. cellClick10(row) {
  312. this.currentRow10 = row;
  313. },
  314. downloadFile(file) {
  315. getFile({ objectName: file.storePath }, file.name);
  316. },
  317. handleFlow(row) {
  318. this.$refs.flowRef.open(row.processInstanceId);
  319. },
  320. handleDetails(row) {
  321. this.$refs.detailsRef.open(row);
  322. },
  323. handleMethod(row) {
  324. this.$refs.timeDialogRef.open(row, 'details');
  325. },
  326. handleRelease(row) {
  327. this.$refs.releaseRef.open(row);
  328. },
  329. // 全选
  330. changeSelectAll(arr) {
  331. console.log('changeSelectAll---------', arr);
  332. let isBoolean = arr.every(
  333. (item) => arr[0].sourceType == item.sourceType
  334. );
  335. if (!isBoolean) {
  336. this.checkRadioData = [];
  337. this.$refs.table.clearSelection();
  338. return this.$message.error(
  339. `所选${this.type == 1 ? '入库' : '出库'
  340. }申请单出入库类型不一致,请重新选择`
  341. );
  342. }
  343. if (arr.length != 0) {
  344. this.checkRadioData = arr;
  345. } else {
  346. this.checkRadioData = [];
  347. }
  348. },
  349. selectChange(arr, row) {
  350. console.log('selectChange---------', arr);
  351. let isBoolean = arr.every(
  352. (item) => arr[0].sourceType == item.sourceType
  353. );
  354. if (!isBoolean) {
  355. this.checkRadioData = [];
  356. this.$refs.table.clearSelection();
  357. return this.$message.error(
  358. `所选${this.type == 1 ? '入库' : '出库'
  359. }申请单出入库类型不一致,请重新选择`
  360. );
  361. }
  362. if (arr.length != 0) {
  363. this.checkRadioData = arr;
  364. } else {
  365. this.checkRadioData = [];
  366. }
  367. },
  368. handleMine(val) {
  369. console.log(val, 'valvalvalvalvalvalvalvalvalvalvalvalvalval确认按钮');
  370. console.log(this.bizType, 'this.bizType');
  371. if (this.bizType != 10) {
  372. let checkRadioData = val ? val : this.checkRadioData;
  373. if (checkRadioData.length < 1) {
  374. return this.$message.error(
  375. `请选择${this.type == 1 ? '入库' : '出库'}申请单`
  376. );
  377. }
  378. let isBoolean = checkRadioData.every(
  379. (item) => checkRadioData[0].sourceType == item.sourceType
  380. );
  381. if (!isBoolean) {
  382. return this.$message.error(
  383. `所选${this.type == 1 ? '入库' : '出库'
  384. }申请单出入库类型不一致,请重新选择`
  385. );
  386. }
  387. let aaa = checkRadioData.map((item) => item.id);
  388. storageApi.getApplystoragedetails(aaa).then(async (res) => {
  389. if (this.type == 2) {
  390. // 出库
  391. let data = await storageApi.getHierarchyFifo({
  392. type: 1,
  393. builders: res.map((item) => {
  394. return {
  395. categoryId: item.categoryId,
  396. num: item.measureQuantity
  397. };
  398. })
  399. });
  400. if (data?.length > 0) {
  401. this.$emit('detailData', data, 1, {
  402. sourceBizNo: checkRadioData
  403. .map((item) => item.code)
  404. .join(','),
  405. bizType: checkRadioData[0].sourceType,
  406. assetType: Array.from(
  407. new Set(res.map((item) => item.rootCategoryLevelId))
  408. ).join(',')
  409. });
  410. this.dialogVisible = false;
  411. } else {
  412. this.$message.warning('该出库申请单无库存');
  413. }
  414. } else {
  415. // 入库
  416. const batchNo = await getCode('lot_number_code');
  417. let data = res.map((item, index) => {
  418. return {
  419. ...item,
  420. index,
  421. packingQuantity: 1,
  422. minPackingQuantity: item.measureQuantity,
  423. measureUnit: item.measuringUnit,
  424. batchNo,
  425. id: '',
  426. warehouseIds: [item.warehouseId],
  427. warehouseNames: [item.warehouseName]
  428. };
  429. });
  430. this.$emit('detailData', data, 1, {
  431. sourceBizNo: checkRadioData.map((item) => item.code).join(','),
  432. bizType: checkRadioData[0].sourceType,
  433. assetType: Array.from(
  434. new Set(res.map((item) => item.rootCategoryLevelId))
  435. ).join(',')
  436. });
  437. this.dialogVisible = false;
  438. }
  439. });
  440. } else {
  441. console.log(this.currentRow10, '10');
  442. this.$emit('detailData', [], 1, {
  443. sourceBizNo: this.currentRow10.code,
  444. taskId: this.currentRow10.taskId,
  445. workOrderId: this.currentRow10.workOrderId
  446. });
  447. this.dialogVisible = false;
  448. }
  449. },
  450. // 单击获取id
  451. cellClick(row) {
  452. this.currentRow = row;
  453. this.currentId = row.id;
  454. },
  455. statusFormatter(status) {
  456. const obj = this.statusOpt.find((i) => i.value == status);
  457. return obj && obj.label;
  458. },
  459. open() {
  460. this.dialogVisible = true;
  461. },
  462. handleClose() {
  463. this.dialogVisible = false;
  464. }
  465. }
  466. };
  467. </script>