index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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. workListIds: {
  203. type: Array,
  204. default() {
  205. return [];
  206. }
  207. }
  208. },
  209. data() {
  210. return {
  211. visible: true,
  212. workList: [],
  213. rules: {},
  214. pickCode: null,
  215. pickName: null,
  216. typeName,
  217. tableRules: {}
  218. };
  219. },
  220. computed: {
  221. taskObj() {
  222. return this.$store.state.user.taskObj;
  223. }
  224. },
  225. watch: {},
  226. methods: {
  227. getList() {
  228. let param = {
  229. ids: this.workListIds,
  230. taskId: this.taskObj.id
  231. };
  232. workorderList(param).then((res) => {
  233. let arr = res.map((e) => {
  234. e.pickList = [...e.bomDetailDTOS];
  235. e.bomDetailDTOS = [];
  236. return e;
  237. });
  238. this.workList = arr;
  239. this.getOrderCode();
  240. this.$forceUpdate();
  241. });
  242. },
  243. async getOrderCode() {
  244. this.pickCode = await getCode('pick_order_code');
  245. },
  246. removeItem(idx, index) {
  247. this.workList[idx].pickList.splice(index, 1);
  248. },
  249. handleClose() {
  250. this.$emit('close', false);
  251. },
  252. openPicking(id, item) {
  253. this.$refs.pickingListRef.open(id, item);
  254. },
  255. allSelection(id, list) {
  256. this.workList.forEach((e) => {
  257. if (e.id == id) {
  258. e.pickList = list;
  259. this.$forceUpdate();
  260. }
  261. });
  262. },
  263. save() {
  264. console.log(this.workList);
  265. if (this.workList.length > 0) {
  266. let bol;
  267. let _i;
  268. bol = this.workList.every((e, i) => {
  269. _i = i;
  270. return (
  271. Object.prototype.hasOwnProperty.call(e, 'pickList') &&
  272. e.pickList.length > 0
  273. );
  274. });
  275. if (!bol) {
  276. this.$message.warning(
  277. `生成工单${this.workList[_i].code}领料不能为空`
  278. );
  279. return false;
  280. }
  281. }
  282. if (this.workList.length > 0) {
  283. let name;
  284. let bol2;
  285. let _i;
  286. this.workList.forEach((e, i) => {
  287. _i = i;
  288. console.log(e.pickList);
  289. bol2 = e.pickList.every((y) => {
  290. name = y.name;
  291. return (
  292. Object.prototype.hasOwnProperty.call(y, 'demandQuantity') &&
  293. Number(y.demandQuantity) > 0
  294. );
  295. });
  296. });
  297. if (!bol2) {
  298. this.$message.warning(
  299. `${this.workList[_i].code}的${name}数量不能为空`
  300. );
  301. return false;
  302. }
  303. }
  304. let _arr = [];
  305. _arr = this.workList.map((m) => {
  306. m.instanceList = [];
  307. m.bomDetailDTOSList = [];
  308. m.pickList.forEach((e) => {
  309. if (
  310. Object.prototype.hasOwnProperty.call(e, 'isBom') &&
  311. e.isBom == 1
  312. ) {
  313. m.bomDetailDTOSList.push(e);
  314. } else {
  315. m.instanceList.push(e);
  316. }
  317. });
  318. m.workOrderId = m.id;
  319. delete m.id;
  320. return {
  321. ...m
  322. };
  323. });
  324. let param = {
  325. allPickList: _arr,
  326. pickName: this.pickName,
  327. pickCode: this.pickCode
  328. };
  329. batchSave(param).then((res) => {
  330. this.$message.success('领料成功');
  331. this.$emit('close', true);
  332. });
  333. }
  334. },
  335. created() {
  336. this.getList();
  337. }
  338. };
  339. </script>
  340. <style lang="scss" scoped>
  341. .table_content {
  342. margin-bottom: 10px;
  343. }
  344. .tableZ_box {
  345. border: 1px solid #e3e5e5;
  346. margin: 6px 0;
  347. &:last-child {
  348. border-bottom: none;
  349. }
  350. .row {
  351. width: 100%;
  352. display: flex;
  353. }
  354. .col {
  355. width: calc(100% / 5);
  356. display: flex;
  357. align-items: center;
  358. min-width: 200px;
  359. min-height: 32px;
  360. border-bottom: 1px solid #e3e5e5;
  361. border-right: 1px solid #e3e5e5;
  362. &:last-child {
  363. border-right: none;
  364. }
  365. .name {
  366. display: flex;
  367. align-items: center;
  368. padding: 4px;
  369. width: 80px;
  370. height: 100%;
  371. background-color: #d0e4d5;
  372. color: #000;
  373. }
  374. .content {
  375. padding: 4px 6px;
  376. color: #000;
  377. }
  378. }
  379. .pd6 {
  380. padding: 0 6px;
  381. }
  382. }
  383. </style>
  384. <style>
  385. :v-deep .el-form-item__error {
  386. bottom: -6px !important;
  387. }
  388. </style>