addPick.vue 12 KB

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