addPick.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. <template>
  2. <ele-modal
  3. title="新建领料单"
  4. :visible.sync="visible"
  5. v-if="visible"
  6. :before-close="handleClose"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. :maxable="true"
  11. width="80%"
  12. >
  13. <div>
  14. <el-form :model="pickForm" ref="pickForm">
  15. <el-row :gutter="24">
  16. <el-col :span="6">
  17. <el-form-item label="领料单编号" prop="pickCode" label-width="90px">
  18. <el-input v-model="pickForm.pickCode" disabled=""></el-input>
  19. </el-form-item>
  20. </el-col>
  21. <el-col :span="6">
  22. <el-form-item label="领料单名称" prop="pickName" label-width="90px">
  23. <el-input v-model="pickForm.pickName"></el-input>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :span="6">
  27. <el-button type="primary" @click="selectOrder">选择工单</el-button>
  28. </el-col>
  29. </el-row>
  30. </el-form>
  31. <div v-for="(item, idx) in workList" :key="idx">
  32. <el-form
  33. :ref="`form22${idx}`"
  34. :model="{ pickList: item }"
  35. :rules="tableRules"
  36. size="mini"
  37. label-position="left"
  38. >
  39. <div class="tableZ_box">
  40. <div class="row">
  41. <div class="col">
  42. <div class="name">生产工单号</div>
  43. <div class="content">{{ item.code }}</div>
  44. </div>
  45. <div class="col">
  46. <div class="name">产品编码</div>
  47. <div class="content">{{ item.productCode }}</div>
  48. </div>
  49. <div class="col">
  50. <div class="name">产品名称</div>
  51. <div class="content">{{ item.productName }}</div>
  52. </div>
  53. <div class="col">
  54. <div class="name">批次号</div>
  55. <div class="content">{{ item.batchNo }}</div>
  56. </div>
  57. <div class="col pd6">
  58. <el-button
  59. type="primary"
  60. size="mini"
  61. @click="openPicking(item.id, item)"
  62. >新增</el-button
  63. >
  64. </div>
  65. </div>
  66. </div>
  67. <div>
  68. <el-table
  69. :ref="`form222${idx}`"
  70. class="table_content"
  71. :max-height="300"
  72. :data="item.pickList"
  73. tooltip-effect="dark"
  74. style="width: 100%"
  75. stripe
  76. border
  77. >
  78. <el-table-column label="序号" type="index" width="60">
  79. <template slot-scope="{ row, $index }">
  80. {{ $index + 1 }}
  81. </template>
  82. </el-table-column>
  83. <el-table-column
  84. label="类型"
  85. prop="rootCategoryLevelId"
  86. width="80"
  87. >
  88. <template slot-scope="{ row, $index }">
  89. <el-tag size="mini">{{
  90. typeName[Number(row.rootCategoryLevelId)]
  91. }}</el-tag>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="编码" prop="assetCode">
  95. <template slot-scope="{ row, $index }">
  96. <span
  97. v-if="
  98. Object.prototype.hasOwnProperty.call(row, 'isBom') &&
  99. row.isBom == 1
  100. "
  101. style="color: #faad14"
  102. >
  103. {{ row.categoryCode }}
  104. </span>
  105. <span>
  106. {{
  107. row.rootCategoryLevelId == 4 ? row.codeNumber : row.code
  108. }}</span
  109. >
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="名称" prop="name">
  113. <template slot-scope="{ row, $index }">
  114. <span
  115. v-if="
  116. Object.prototype.hasOwnProperty.call(row, 'isBom') &&
  117. row.isBom == 1
  118. "
  119. >
  120. {{ row.categoryName }}
  121. </span>
  122. <span> {{ row.name }}</span>
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="型号" prop="modelType"> </el-table-column>
  126. <el-table-column label="规格" prop="specification">
  127. </el-table-column>
  128. <el-table-column label="批次号" prop="batchNo"> </el-table-column>
  129. <el-table-column label="数量" prop="demandQuantity">
  130. <template slot-scope="{ row, $index }">
  131. <el-form-item>
  132. <el-input
  133. v-model="row.demandQuantity"
  134. @input="
  135. row.demandQuantity > row.availableCountBase
  136. ? (row.demandQuantity = row.availableCountBase)
  137. : row.demandQuantity
  138. "
  139. size="mini"
  140. >
  141. <template slot="append">{{ row.measuringUnit }}</template>
  142. </el-input>
  143. </el-form-item>
  144. </template>
  145. </el-table-column>
  146. <el-table-column label="计量库存数量" prop="availableCountBase">
  147. <template slot-scope="{ row, $index }">
  148. {{ row.availableCountBase }} {{ row.measuringUnit }}
  149. </template>
  150. </el-table-column>
  151. <el-table-column label="领料仓库" prop="warehouseId">
  152. <template slot-scope="{ row, $index }">
  153. <div
  154. v-if="
  155. Object.prototype.hasOwnProperty.call(row, 'isBom') &&
  156. row.isBom == 1
  157. "
  158. >
  159. <el-select
  160. v-model="row.warehouseId"
  161. placeholder="请选择"
  162. filterable
  163. size="mini"
  164. >
  165. <el-option
  166. v-for="item in row.warehouseList"
  167. :label="item.name"
  168. :value="item.id"
  169. :key="item.id"
  170. >
  171. </el-option>
  172. </el-select>
  173. </div>
  174. <div v-else>
  175. <el-select
  176. v-model="row.warehouseId"
  177. placeholder="请选择"
  178. filterable
  179. >
  180. <el-option
  181. v-for="item in row.warehouseLists"
  182. :label="item.warehouse_name"
  183. :value="item.warehouse_id"
  184. :key="item.warehouse_id"
  185. >
  186. </el-option>
  187. </el-select>
  188. </div>
  189. </template>
  190. </el-table-column>
  191. <el-table-column label="操作" fixed="right" width="100px">
  192. <template slot-scope="{ $index, row }">
  193. <el-link type="danger" @click="removeItem(idx, $index)"
  194. >删除</el-link
  195. >
  196. </template>
  197. </el-table-column>
  198. </el-table>
  199. </div>
  200. </el-form>
  201. </div>
  202. </div>
  203. <template slot="footer">
  204. <el-button size="mini" @click="handleClose">取 消</el-button>
  205. <el-button size="mini" type="primary" @click="save()">确 定</el-button>
  206. </template>
  207. <pickingList
  208. isType="pick"
  209. ref="pickingListRef"
  210. @allSelection="allSelection"
  211. ></pickingList>
  212. <produceOrder
  213. v-if="orderShow"
  214. @close="orderShow = false"
  215. @workSelect="workSelect"
  216. ></produceOrder>
  217. </ele-modal>
  218. </template>
  219. <script>
  220. import pickingList from '@/views/produce/components/picking/pickingList.vue';
  221. import { workorderList, getCode } from '@/api/produce/workOrder';
  222. import produceOrder from './produceOrder.vue';
  223. import { typeName } from '@/views/produce/components/common.js';
  224. import { batchSave } from '@/api/produce/picking';
  225. import { listTask } from '@/api/produce/index';
  226. export default {
  227. components: {
  228. pickingList,
  229. produceOrder
  230. },
  231. props: {},
  232. data() {
  233. return {
  234. visible: true,
  235. workList: [],
  236. rules: {},
  237. pickForm: {
  238. pickCode: null,
  239. pickName: null
  240. },
  241. typeName,
  242. tableRules: {},
  243. produceTaskList: [],
  244. orderShow: false
  245. };
  246. },
  247. computed: {
  248. taskObj() {
  249. return this.$store.state.user.taskObj;
  250. }
  251. },
  252. watch: {},
  253. methods: {
  254. getTaskList() {
  255. listTask().then((res) => {
  256. this.produceTaskList = res;
  257. });
  258. },
  259. getList(ids, taskId) {
  260. let param = {
  261. ids: ids,
  262. taskId: taskId
  263. };
  264. workorderList(param)
  265. .then((res) => {
  266. let _arr = res.map((e) => {
  267. e.pickList = [...e.bomDetailDTOS];
  268. e.bomDetailDTOS = [];
  269. return e;
  270. });
  271. this.workList = JSON.parse(JSON.stringify(_arr));
  272. this.$forceUpdate();
  273. })
  274. .finally(() => {});
  275. },
  276. async getOrderCode() {
  277. this.pickForm.pickCode = await getCode('pick_order_code');
  278. },
  279. removeItem(idx, index) {
  280. this.workList[idx].pickList.splice(index, 1);
  281. },
  282. handleClose() {
  283. this.$emit('close', false);
  284. },
  285. openPicking(id, item) {
  286. this.$refs.pickingListRef.open(id, item);
  287. },
  288. allSelection(id, list) {
  289. this.workList.forEach((e) => {
  290. if (e.id == id) {
  291. e.pickList = list;
  292. this.$forceUpdate();
  293. }
  294. });
  295. },
  296. save() {
  297. console.log(this.workList, 'this.workList');
  298. if (this.workList.length > 0) {
  299. let bol;
  300. let _i;
  301. bol = this.workList.every((e, i) => {
  302. _i = i;
  303. return (
  304. Object.prototype.hasOwnProperty.call(e, 'pickList') &&
  305. e.pickList.length > 0
  306. );
  307. });
  308. if (!bol) {
  309. this.$message.warning(
  310. `生成工单${this.workList[_i].code}领料不能为空`
  311. );
  312. return false;
  313. }
  314. }
  315. if (this.workList.length > 0) {
  316. let name;
  317. let bol2;
  318. let _i;
  319. this.workList.forEach((e, i) => {
  320. _i = i;
  321. console.log(e.pickList);
  322. bol2 = e.pickList.every((y) => {
  323. name = y.name;
  324. return (
  325. Object.prototype.hasOwnProperty.call(y, 'demandQuantity') &&
  326. Number(y.demandQuantity) > 0
  327. );
  328. });
  329. });
  330. if (!bol2) {
  331. this.$message.warning(
  332. `${this.workList[_i].code}的${name}数量不能为空`
  333. );
  334. return false;
  335. }
  336. }
  337. let _arr = [];
  338. _arr = this.workList.map((m) => {
  339. m.instanceList = [];
  340. m.bomDetailDTOSList = [];
  341. m.pickList.forEach((e) => {
  342. if (
  343. Object.prototype.hasOwnProperty.call(e, 'isBom') &&
  344. e.isBom == 1
  345. ) {
  346. m.bomDetailDTOSList.push(e);
  347. } else {
  348. m.instanceList.push(e);
  349. }
  350. });
  351. m.workOrderId = m.id;
  352. delete m.id;
  353. return {
  354. ...m
  355. };
  356. });
  357. let param = {
  358. allPickList: _arr,
  359. pickName: this.pickForm.pickName,
  360. pickCode: this.pickForm.pickCode
  361. };
  362. batchSave(param).then((res) => {
  363. this.$message.success('领料成功');
  364. this.$emit('close', true);
  365. });
  366. },
  367. selectOrder() {
  368. this.orderShow = true;
  369. },
  370. workSelect(ids, taskId) {
  371. this.getList(ids, taskId);
  372. this.orderShow = false;
  373. }
  374. },
  375. created() {
  376. this.getTaskList();
  377. this.getOrderCode();
  378. }
  379. };
  380. </script>
  381. <style lang="scss" scoped>
  382. .table_content {
  383. margin-bottom: 10px;
  384. }
  385. .tableZ_box {
  386. border: 1px solid #e3e5e5;
  387. margin: 6px 0;
  388. &:last-child {
  389. border-bottom: none;
  390. }
  391. .row {
  392. width: 100%;
  393. display: flex;
  394. }
  395. .col {
  396. width: calc(100% / 5);
  397. display: flex;
  398. align-items: center;
  399. // min-width: 200px;
  400. min-height: 32px;
  401. border-bottom: 1px solid #e3e5e5;
  402. border-right: 1px solid #e3e5e5;
  403. &:last-child {
  404. border-right: none;
  405. }
  406. .name {
  407. display: flex;
  408. align-items: center;
  409. padding: 4px;
  410. width: 60px;
  411. height: 100%;
  412. background-color: #d0e4d5;
  413. color: #000;
  414. }
  415. .content {
  416. padding: 4px 6px;
  417. color: #000;
  418. }
  419. }
  420. .pd6 {
  421. padding: 0 6px;
  422. }
  423. }
  424. </style>
  425. <style>
  426. :v-deep .el-form-item__error {
  427. bottom: -6px !important;
  428. }
  429. </style>