newWokePopup.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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: 100,
  111. align: 'center',
  112. resizable: false,
  113. slot: 'action',
  114. fixed: 'right',
  115. showOverflowTooltip: true
  116. }
  117. ],
  118. typeName,
  119. tableRules: {},
  120. rightMode: 'list',
  121. currentRow: null,
  122. itemData: null,
  123. type: 1
  124. };
  125. },
  126. computed: {
  127. taskObj() {
  128. return this.$store.state.user.taskObj;
  129. }
  130. },
  131. watch: {},
  132. methods: {
  133. // datasource({ page, where, limit }) {
  134. // let req = {
  135. // "taskId": this.taskId,
  136. // "workOrderId": this.workListIds[0]
  137. // }
  138. // return craftFiles({
  139. // ...req,
  140. // pageNum: page,
  141. // size: limit,
  142. // });
  143. // },
  144. open(req) {
  145. this.rightMode = 'list';
  146. this.currentRow = null;
  147. this.itemData = req;
  148. this.type = 1;
  149. this.workList = [];
  150. craftFiles(req).then((res) => {
  151. let _ids = [];
  152. if (res.length != 0) {
  153. res.forEach((e) => {
  154. _ids.push(e.id);
  155. });
  156. const ids = _ids.join(',');
  157. this.getFilepProcess(ids);
  158. }
  159. });
  160. this.visible = true;
  161. },
  162. openTwo(req) {
  163. this.rightMode = 'list';
  164. this.currentRow = null;
  165. this.itemData = req;
  166. this.type = 2;
  167. this.workList = [];
  168. fileReleaseAPI({
  169. fileType: 0,
  170. isQueryAll: 1,
  171. jobNumber: '',
  172. lcyStatus: '3',
  173. loginName: '',
  174. name: req.productCode,
  175. pageNum: 1,
  176. size: 10
  177. }).then((res) => {
  178. this.workList = res.list;
  179. });
  180. this.visible = true;
  181. },
  182. async getFilepProcess(ids) {
  183. await filePageAPI({
  184. ids: "'" + ids + "'"
  185. }).then((res) => {
  186. this.workList = res;
  187. });
  188. },
  189. fileDetails(row) {
  190. this.currentRow = row;
  191. this.rightMode = 'detail';
  192. this.$nextTick(() => {
  193. this.$refs.browseRef.setFileUrl(row);
  194. });
  195. },
  196. closeDetail() {
  197. this.rightMode = 'list';
  198. if (this.type == 1) {
  199. this.open(this.itemData);
  200. } else if (this.type == 2) {
  201. this.openTwo(this.itemData);
  202. }
  203. },
  204. async getOrderCode() {
  205. this.pickCode = await getCode('pick_order_code');
  206. },
  207. removeItem(idx, index) {
  208. this.workList[idx].pickList.splice(index, 1);
  209. },
  210. handleClose() {
  211. this.visible = false;
  212. this.$emit('close', false);
  213. },
  214. getList() {
  215. console.log(123);
  216. },
  217. openPicking(id, item) {
  218. this.$refs.pickingListRef.open(id, item);
  219. },
  220. allSelection(id, list) {
  221. this.workList.forEach((e) => {
  222. if (e.id == id) {
  223. e.pickList = list;
  224. this.$forceUpdate();
  225. }
  226. });
  227. },
  228. save() {
  229. console.log(this.workList);
  230. if (this.workList.length > 0) {
  231. let bol;
  232. let _i;
  233. bol = this.workList.every((e, i) => {
  234. _i = i;
  235. return (
  236. Object.prototype.hasOwnProperty.call(e, 'pickList') &&
  237. e.pickList.length > 0
  238. );
  239. });
  240. if (!bol) {
  241. this.$message.warning(
  242. `生成工单${this.workList[_i].code}领料不能为空`
  243. );
  244. return false;
  245. }
  246. }
  247. if (this.workList.length > 0) {
  248. let name;
  249. let bol2;
  250. let _i;
  251. this.workList.forEach((e, i) => {
  252. _i = i;
  253. console.log(e.pickList);
  254. bol2 = e.pickList.every((y) => {
  255. name = y.name;
  256. return (
  257. Object.prototype.hasOwnProperty.call(y, 'demandQuantity') &&
  258. Number(y.demandQuantity) > 0
  259. );
  260. });
  261. });
  262. if (!bol2) {
  263. this.$message.warning(
  264. `${this.workList[_i].code}的${name}数量不能为空`
  265. );
  266. return false;
  267. }
  268. }
  269. let _arr = [];
  270. _arr = this.workList.map((m) => {
  271. m.instanceList = [];
  272. m.bomDetailDTOSList = [];
  273. m.pickList.forEach((e) => {
  274. if (
  275. Object.prototype.hasOwnProperty.call(e, 'isBom') &&
  276. e.isBom == 1
  277. ) {
  278. m.bomDetailDTOSList.push(e);
  279. } else {
  280. m.instanceList.push(e);
  281. }
  282. });
  283. m.workOrderId = m.id;
  284. delete m.id;
  285. return {
  286. ...m
  287. };
  288. });
  289. let param = {
  290. allPickList: _arr,
  291. pickName: this.pickName,
  292. pickCode: this.pickCode
  293. };
  294. batchSave(param).then((res) => {
  295. this.$message.success('领料成功');
  296. this.$emit('close', true);
  297. });
  298. }
  299. },
  300. created() {
  301. this.getList();
  302. }
  303. };
  304. </script>
  305. <style lang="scss" scoped>
  306. .table_content {
  307. margin-bottom: 10px;
  308. }
  309. .tableZ_box {
  310. border: 1px solid #e3e5e5;
  311. margin: 6px 0;
  312. &:last-child {
  313. border-bottom: none;
  314. }
  315. .row {
  316. width: 100%;
  317. display: flex;
  318. }
  319. .col {
  320. width: calc(100% / 5);
  321. display: flex;
  322. align-items: center;
  323. min-width: 200px;
  324. min-height: 32px;
  325. border-bottom: 1px solid #e3e5e5;
  326. border-right: 1px solid #e3e5e5;
  327. &:last-child {
  328. border-right: none;
  329. }
  330. .name {
  331. display: flex;
  332. align-items: center;
  333. padding: 4px;
  334. width: 80px;
  335. height: 100%;
  336. background-color: #d0e4d5;
  337. color: #000;
  338. }
  339. .content {
  340. padding: 4px 6px;
  341. color: #000;
  342. }
  343. }
  344. .pd6 {
  345. padding: 0 6px;
  346. }
  347. }
  348. .right-page {
  349. height: 100%;
  350. display: flex;
  351. flex-direction: column;
  352. min-height: 0;
  353. }
  354. .page-body {
  355. flex: 1;
  356. min-height: 0;
  357. overflow: hidden;
  358. }
  359. .page-body .pro-table {
  360. height: 100%;
  361. }
  362. .page-footer {
  363. flex-shrink: 0;
  364. padding: 10px 0;
  365. border-top: 1px solid #ebeef5;
  366. text-align: right;
  367. background: #fff;
  368. }
  369. </style>
  370. <style>
  371. :v-deep .el-form-item__error {
  372. bottom: -6px !important;
  373. }
  374. </style>