outboundRequisitionDialog.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  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. align: 'center'
  142. },
  143. { label: '型号', prop: 'modelType', width: '150' },
  144. { label: '规格', prop: 'specification', width: '150' },
  145. { label: '牌号', prop: 'brandNum', width: '100' },
  146. {
  147. prop: 'sourceType',
  148. label: '出入库类型',
  149. align: 'center',
  150. formatter: (row, column, cellValue) => {
  151. switch (this.type) {
  152. case '1':
  153. // 入库
  154. return this.sceneState.filter(
  155. (item) => item.code == row.sourceType
  156. )[0].label;
  157. case '2':
  158. // 出库
  159. return this.outputSceneState.filter(
  160. (item) => item.code == row.sourceType
  161. )[0].label;
  162. }
  163. }
  164. },
  165. {
  166. prop: 'approvalUserName',
  167. label: '审核人',
  168. align: 'center'
  169. },
  170. {
  171. prop: 'createUserName',
  172. label: '申请人',
  173. align: 'center'
  174. },
  175. {
  176. prop: 'createTime',
  177. label: '创建时间',
  178. align: 'center',
  179. showOverflowTooltip: true,
  180. minWidth: 110
  181. },
  182. {
  183. slot: 'status',
  184. label: '状态',
  185. align: 'center'
  186. }
  187. ];
  188. },
  189. columns10() {
  190. return [
  191. {
  192. slot: 'selection',
  193. label: '选择',
  194. width: 50,
  195. align: 'center'
  196. },
  197. {
  198. columnKey: 'index',
  199. label: '序号',
  200. type: 'index',
  201. width: 55,
  202. align: 'center',
  203. showOverflowTooltip: true,
  204. fixed: 'left'
  205. },
  206. {
  207. prop: 'code',
  208. label: '委外单编码',
  209. align: 'center'
  210. },
  211. {
  212. prop: 'name',
  213. label: '委外单名称',
  214. align: 'center'
  215. },
  216. {
  217. prop: 'workOrderCode',
  218. label: '工单编码',
  219. align: 'center'
  220. },
  221. {
  222. prop: 'taskName',
  223. label: '工序',
  224. align: 'center'
  225. },
  226. {
  227. prop: 'totalCount',
  228. label: '委外数量',
  229. align: 'center'
  230. },
  231. {
  232. prop: 'totalWeight',
  233. label: '委外重量',
  234. align: 'center'
  235. },
  236. {
  237. slot: 'type',
  238. label: '委外类型',
  239. align: 'center'
  240. },
  241. {
  242. prop: 'remark',
  243. label: '备注',
  244. align: 'center'
  245. },
  246. {
  247. slot: 'requireDeliveryTime',
  248. label: '预计到货日期',
  249. align: 'center',
  250. minWidth: 70
  251. },
  252. {
  253. prop: 'produceRoutingName',
  254. label: '工艺路线',
  255. align: 'center'
  256. },
  257. {
  258. prop: 'warehouseName',
  259. label: '仓库',
  260. align: 'center'
  261. },
  262. {
  263. prop: 'createTime',
  264. label: '创建时间',
  265. align: 'center',
  266. minWidth: 70
  267. },
  268. {
  269. slot: 'status',
  270. label: '状态',
  271. align: 'center'
  272. },
  273. {
  274. label: '图片附件',
  275. slot: 'technicalDrawings',
  276. action: 'technicalDrawings',
  277. minWidth: 100
  278. },
  279. {
  280. label: '附件',
  281. slot: 'files',
  282. action: 'files',
  283. minWidth: 100
  284. }
  285. ];
  286. }
  287. },
  288. created() {
  289. console.log(this.type, 'this.typethis.typethis.typethis.type')
  290. },
  291. methods: {
  292. /* 表格数据源 */
  293. datasource({ page, limit, where }) {
  294. return storageApi.getinboundRequestsList({
  295. pageNum: page,
  296. size: limit,
  297. status: 0,
  298. type: this.type,
  299. ...where
  300. });
  301. },
  302. /* 表格数据源 委外入库 */
  303. datasource10({ page, limit, where }) {
  304. return storageApi.getApplyoutsource({
  305. pageNum: page,
  306. size: limit,
  307. ...where
  308. });
  309. },
  310. cellClick10(row) {
  311. this.currentRow10 = row;
  312. },
  313. downloadFile(file) {
  314. getFile({ objectName: file.storePath }, file.name);
  315. },
  316. handleFlow(row) {
  317. this.$refs.flowRef.open(row.processInstanceId);
  318. },
  319. handleDetails(row) {
  320. this.$refs.detailsRef.open(row);
  321. },
  322. handleMethod(row) {
  323. this.$refs.timeDialogRef.open(row, 'details');
  324. },
  325. handleRelease(row) {
  326. this.$refs.releaseRef.open(row);
  327. },
  328. // 全选
  329. changeSelectAll(arr) {
  330. console.log('changeSelectAll---------', arr);
  331. let isBoolean = arr.every(
  332. (item) => arr[0].sourceType == item.sourceType
  333. );
  334. if (!isBoolean) {
  335. this.checkRadioData = [];
  336. this.$refs.table.clearSelection();
  337. return this.$message.error(
  338. `所选${this.type == 1 ? '入库' : '出库'
  339. }申请单出入库类型不一致,请重新选择`
  340. );
  341. }
  342. if (arr.length != 0) {
  343. this.checkRadioData = arr;
  344. } else {
  345. this.checkRadioData = [];
  346. }
  347. },
  348. selectChange(arr, row) {
  349. console.log('selectChange---------', arr);
  350. let isBoolean = arr.every(
  351. (item) => arr[0].sourceType == item.sourceType
  352. );
  353. if (!isBoolean) {
  354. this.checkRadioData = [];
  355. this.$refs.table.clearSelection();
  356. return this.$message.error(
  357. `所选${this.type == 1 ? '入库' : '出库'
  358. }申请单出入库类型不一致,请重新选择`
  359. );
  360. }
  361. if (arr.length != 0) {
  362. this.checkRadioData = arr;
  363. } else {
  364. this.checkRadioData = [];
  365. }
  366. },
  367. handleMine(val) {
  368. console.log(val, 'valvalvalvalvalvalvalvalvalvalvalvalvalval确认按钮');
  369. console.log(this.bizType, 'this.bizType');
  370. if (this.bizType != 10) {
  371. let checkRadioData = val ? val : this.checkRadioData;
  372. if (checkRadioData.length < 1) {
  373. return this.$message.error(
  374. `请选择${this.type == 1 ? '入库' : '出库'}申请单`
  375. );
  376. }
  377. let isBoolean = checkRadioData.every(
  378. (item) => checkRadioData[0].sourceType == item.sourceType
  379. );
  380. if (!isBoolean) {
  381. return this.$message.error(
  382. `所选${this.type == 1 ? '入库' : '出库'
  383. }申请单出入库类型不一致,请重新选择`
  384. );
  385. }
  386. let aaa = checkRadioData.map((item) => item.id);
  387. storageApi.getApplystoragedetails(aaa).then(async (res) => {
  388. if (this.type == 2) {
  389. // 出库
  390. let data = await storageApi.getHierarchyFifo({
  391. type: 1,
  392. builders: res.map((item) => {
  393. return {
  394. categoryId: item.categoryId,
  395. num: item.measureQuantity
  396. };
  397. })
  398. });
  399. if (data?.length > 0) {
  400. this.$emit('detailData', data, 1, {
  401. sourceBizNo: checkRadioData
  402. .map((item) => item.code)
  403. .join(','),
  404. bizType: checkRadioData[0].sourceType,
  405. assetType: Array.from(
  406. new Set(res.map((item) => item.rootCategoryLevelId))
  407. ).join(',')
  408. });
  409. this.dialogVisible = false;
  410. } else {
  411. this.$message.warning('该出库申请单无库存');
  412. }
  413. } else {
  414. // 入库
  415. const batchNo = await getCode('lot_number_code');
  416. let data = res.map((item, index) => {
  417. return {
  418. ...item,
  419. index,
  420. packingQuantity: 1,
  421. minPackingQuantity: item.measureQuantity,
  422. measureUnit: item.measuringUnit,
  423. batchNo,
  424. id: '',
  425. warehouseIds: [item.warehouseId],
  426. warehouseNames: [item.warehouseName]
  427. };
  428. });
  429. this.$emit('detailData', data, 1, {
  430. sourceBizNo: checkRadioData.map((item) => item.code).join(','),
  431. bizType: checkRadioData[0].sourceType,
  432. assetType: Array.from(
  433. new Set(res.map((item) => item.rootCategoryLevelId))
  434. ).join(',')
  435. });
  436. this.dialogVisible = false;
  437. }
  438. });
  439. } else {
  440. console.log(this.currentRow10, '10');
  441. this.$emit('detailData', [], 1, {
  442. sourceBizNo: this.currentRow10.code,
  443. taskId: this.currentRow10.taskId,
  444. workOrderId: this.currentRow10.workOrderId
  445. });
  446. this.dialogVisible = false;
  447. }
  448. },
  449. // 单击获取id
  450. cellClick(row) {
  451. this.currentRow = row;
  452. this.currentId = row.id;
  453. },
  454. statusFormatter(status) {
  455. const obj = this.statusOpt.find((i) => i.value == status);
  456. return obj && obj.label;
  457. },
  458. open() {
  459. this.dialogVisible = true;
  460. },
  461. handleClose() {
  462. this.dialogVisible = false;
  463. }
  464. }
  465. };
  466. </script>