newWokePopup.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <template>
  2. <div v-if="visible" class="right-page">
  3. <!-- 内容区 -->
  4. <div class="page-body">
  5. <ele-pro-table
  6. height="calc(80vh - 160px)"
  7. ref="fileTable"
  8. :columns="jobColumns1"
  9. :datasource="workList"
  10. v-show="rightMode == 'list'"
  11. >
  12. <template v-slot:action="{ row }">
  13. <el-link type="primary" @click="fileDetails(row)">详情</el-link>
  14. </template>
  15. </ele-pro-table>
  16. <fileBrowse
  17. ref="browseRef"
  18. v-if="rightMode == 'detail'"
  19. @close="closeDetail"
  20. />
  21. </div>
  22. <pickingList
  23. isType="pick"
  24. ref="pickingListRef"
  25. @allSelection="allSelection"
  26. />
  27. </div>
  28. </template>
  29. <script>
  30. import pickingList from './pickingList.vue';
  31. import fileBrowse from './newFileBrowse.vue';
  32. import {
  33. workorderList,
  34. getCode,
  35. craftFiles,
  36. filePageAPI,
  37. fileReleaseAPI
  38. } from '@/api/produce/workOrder';
  39. import { typeName } from '../common.js';
  40. import { batchSave } from '@/api/produce/picking';
  41. export default {
  42. components: {
  43. pickingList,
  44. fileBrowse
  45. },
  46. props: {
  47. workListIds: {
  48. type: Array,
  49. default() {
  50. return [];
  51. }
  52. },
  53. taskId: {
  54. type: String,
  55. default() {
  56. return null;
  57. }
  58. }
  59. },
  60. data() {
  61. return {
  62. visible: false,
  63. workList: [],
  64. rules: {},
  65. pickCode: null,
  66. pickName: null,
  67. jobColumns1: [
  68. {
  69. label: '编码',
  70. prop: 'code',
  71. width: 180,
  72. align: 'center',
  73. showOverflowTooltip: true
  74. },
  75. {
  76. prop: 'name',
  77. label: '文档名称',
  78. align: 'center',
  79. slot: 'name',
  80. showOverflowTooltip: true,
  81. minWidth: 200
  82. },
  83. {
  84. prop: 'storagePath',
  85. label: '文件名称',
  86. align: 'center',
  87. showOverflowTooltip: true,
  88. minWidth: 200,
  89. formatter: (_row, _column, cellValue) => {
  90. return cellValue[0]?.name;
  91. }
  92. },
  93. {
  94. prop: 'version',
  95. label: '版本',
  96. align: 'center',
  97. showOverflowTooltip: true,
  98. minWidth: 100
  99. },
  100. {
  101. prop: 'createTime',
  102. label: '创建时间',
  103. showOverflowTooltip: true,
  104. align: 'center',
  105. minWidth: 110
  106. },
  107. {
  108. columnKey: 'action',
  109. label: '操作',
  110. width: 260,
  111. align: 'center',
  112. resizable: false,
  113. slot: 'action',
  114. showOverflowTooltip: true
  115. }
  116. ],
  117. typeName,
  118. tableRules: {},
  119. rightMode: 'list',
  120. currentRow: null,
  121. itemData: null,
  122. type: 1
  123. };
  124. },
  125. computed: {
  126. taskObj() {
  127. return this.$store.state.user.taskObj;
  128. }
  129. },
  130. watch: {},
  131. methods: {
  132. // datasource({ page, where, limit }) {
  133. // let req = {
  134. // "taskId": this.taskId,
  135. // "workOrderId": this.workListIds[0]
  136. // }
  137. // return craftFiles({
  138. // ...req,
  139. // pageNum: page,
  140. // size: limit,
  141. // });
  142. // },
  143. open(req) {
  144. this.itemData = req;
  145. this.type = 1;
  146. this.workList = [];
  147. craftFiles(req).then((res) => {
  148. let _ids = [];
  149. if (res.length != 0) {
  150. res.forEach((e) => {
  151. _ids.push(e.id);
  152. });
  153. const ids = _ids.join(',');
  154. this.getFilepProcess(ids);
  155. }
  156. });
  157. this.visible = true;
  158. },
  159. openTwo(req) {
  160. this.itemData = req;
  161. this.type = 2;
  162. this.workList = [];
  163. fileReleaseAPI({
  164. fileType: 0,
  165. isQueryAll: 1,
  166. jobNumber: '',
  167. lcyStatus: '3',
  168. loginName: '',
  169. name: req.productCode,
  170. pageNum: 1,
  171. size: 10
  172. }).then((res) => {
  173. this.workList = res.list;
  174. });
  175. this.visible = true;
  176. },
  177. async getFilepProcess(ids) {
  178. await filePageAPI({
  179. ids: "'" + ids + "'"
  180. }).then((res) => {
  181. this.workList = res;
  182. });
  183. },
  184. fileDetails(row) {
  185. this.currentRow = row;
  186. this.rightMode = 'detail';
  187. this.$nextTick(() => {
  188. this.$refs.browseRef.setFileUrl(row);
  189. });
  190. },
  191. closeDetail() {
  192. this.rightMode = 'list';
  193. if (this.type == 1) {
  194. this.open(this.itemData);
  195. } else if (this.type == 2) {
  196. this.openTwo(this.itemData);
  197. }
  198. },
  199. async getOrderCode() {
  200. this.pickCode = await getCode('pick_order_code');
  201. },
  202. removeItem(idx, index) {
  203. this.workList[idx].pickList.splice(index, 1);
  204. },
  205. handleClose() {
  206. this.visible = false;
  207. this.$emit('close', false);
  208. },
  209. getList() {
  210. console.log(123);
  211. },
  212. openPicking(id, item) {
  213. this.$refs.pickingListRef.open(id, item);
  214. },
  215. allSelection(id, list) {
  216. this.workList.forEach((e) => {
  217. if (e.id == id) {
  218. e.pickList = list;
  219. this.$forceUpdate();
  220. }
  221. });
  222. },
  223. save() {
  224. console.log(this.workList);
  225. if (this.workList.length > 0) {
  226. let bol;
  227. let _i;
  228. bol = this.workList.every((e, i) => {
  229. _i = i;
  230. return (
  231. Object.prototype.hasOwnProperty.call(e, 'pickList') &&
  232. e.pickList.length > 0
  233. );
  234. });
  235. if (!bol) {
  236. this.$message.warning(
  237. `生成工单${this.workList[_i].code}领料不能为空`
  238. );
  239. return false;
  240. }
  241. }
  242. if (this.workList.length > 0) {
  243. let name;
  244. let bol2;
  245. let _i;
  246. this.workList.forEach((e, i) => {
  247. _i = i;
  248. console.log(e.pickList);
  249. bol2 = e.pickList.every((y) => {
  250. name = y.name;
  251. return (
  252. Object.prototype.hasOwnProperty.call(y, 'demandQuantity') &&
  253. Number(y.demandQuantity) > 0
  254. );
  255. });
  256. });
  257. if (!bol2) {
  258. this.$message.warning(
  259. `${this.workList[_i].code}的${name}数量不能为空`
  260. );
  261. return false;
  262. }
  263. }
  264. let _arr = [];
  265. _arr = this.workList.map((m) => {
  266. m.instanceList = [];
  267. m.bomDetailDTOSList = [];
  268. m.pickList.forEach((e) => {
  269. if (
  270. Object.prototype.hasOwnProperty.call(e, 'isBom') &&
  271. e.isBom == 1
  272. ) {
  273. m.bomDetailDTOSList.push(e);
  274. } else {
  275. m.instanceList.push(e);
  276. }
  277. });
  278. m.workOrderId = m.id;
  279. delete m.id;
  280. return {
  281. ...m
  282. };
  283. });
  284. let param = {
  285. allPickList: _arr,
  286. pickName: this.pickName,
  287. pickCode: this.pickCode
  288. };
  289. batchSave(param).then((res) => {
  290. this.$message.success('领料成功');
  291. this.$emit('close', true);
  292. });
  293. }
  294. },
  295. created() {
  296. this.getList();
  297. }
  298. };
  299. </script>
  300. <style lang="scss" scoped>
  301. .table_content {
  302. margin-bottom: 10px;
  303. }
  304. .tableZ_box {
  305. border: 1px solid #e3e5e5;
  306. margin: 6px 0;
  307. &:last-child {
  308. border-bottom: none;
  309. }
  310. .row {
  311. width: 100%;
  312. display: flex;
  313. }
  314. .col {
  315. width: calc(100% / 5);
  316. display: flex;
  317. align-items: center;
  318. min-width: 200px;
  319. min-height: 32px;
  320. border-bottom: 1px solid #e3e5e5;
  321. border-right: 1px solid #e3e5e5;
  322. &:last-child {
  323. border-right: none;
  324. }
  325. .name {
  326. display: flex;
  327. align-items: center;
  328. padding: 4px;
  329. width: 80px;
  330. height: 100%;
  331. background-color: #d0e4d5;
  332. color: #000;
  333. }
  334. .content {
  335. padding: 4px 6px;
  336. color: #000;
  337. }
  338. }
  339. .pd6 {
  340. padding: 0 6px;
  341. }
  342. }
  343. .right-page {
  344. height: 100%;
  345. display: flex;
  346. flex-direction: column;
  347. min-height: 0;
  348. }
  349. .page-body {
  350. flex: 1;
  351. min-height: 0;
  352. overflow: hidden;
  353. }
  354. .page-body .pro-table {
  355. height: 100%;
  356. }
  357. .page-footer {
  358. flex-shrink: 0;
  359. padding: 10px 0;
  360. border-top: 1px solid #ebeef5;
  361. text-align: right;
  362. background: #fff;
  363. }
  364. </style>
  365. <style>
  366. :v-deep .el-form-item__error {
  367. bottom: -6px !important;
  368. }
  369. </style>